本文整理汇总了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())