本文整理匯總了TypeScript中src/dvu/core/helpers/svg.SVG.createRect方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript SVG.createRect方法的具體用法?TypeScript SVG.createRect怎麽用?TypeScript SVG.createRect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類src/dvu/core/helpers/svg.SVG
的用法示例。
在下文中一共展示了SVG.createRect方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: PictureCommand
import {PictureCommand} from 'src/dvu/core/commands/picture'
import {PictureContext} from 'src/dvu/geometry/picture_context'
import {SVG} from 'src/dvu/core/helpers/svg'
export const RECT = new PictureCommand('Rect', {
name: 'rect',
shortcutKey: 'x',
noOfInstances: 0,
onMousedown(context: PictureContext): Element {
const initPoint = context.getLeastSignificantPoint(),
endPoint = context.getMostSignificantPoint()
const rect = SVG.createRect(initPoint.x, initPoint.y, endPoint.x - initPoint.x, endPoint.y - initPoint.y)
rect.setAttributeNS(null, 'stroke', '#555')
rect.setAttributeNS(null, 'fill', 'transparent')
return rect
},
onMousemove(element: Element, context: PictureContext): Element {
const initPoint = context.getLeastSignificantPoint(),
endPoint = context.getMostSignificantPoint(),
width = endPoint.x - initPoint.x,
height = endPoint.y - initPoint.y
element.setAttributeNS(null, 'x', initPoint.x.toString())
element.setAttributeNS(null, 'y', initPoint.y.toString())
element.setAttributeNS(null, 'width', width.toString())
element.setAttributeNS(null, 'height', height.toString())