本文整理汇总了TypeScript中src/dvu/core/helpers/svg.SVG类的典型用法代码示例。如果您正苦于以下问题:TypeScript SVG类的具体用法?TypeScript SVG怎么用?TypeScript SVG使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SVG类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 ELLIPSIS = new PictureCommand('Circle', {
name: 'circle',
shortcutKey: 'c',
noOfInstances: 0,
onMousedown(context: PictureContext): Element {
const { start, end } = context
const ellipsis = SVG.createEllipse(start.x, start.y, context.getWidth(), context.getHeight())
ellipsis.setAttributeNS(null, 'stroke', '#555')
ellipsis.setAttributeNS(null, 'fill', 'transparent')
return ellipsis
},
onMousemove(element: Element, context: PictureContext): Element {
const { start, end } = context
const rx = context.getWidth(), ry = context.getHeight()
element.setAttributeNS(null, 'rx', rx.toString())
element.setAttributeNS(null, 'ry', ry.toString())
return element
},
onMouseup(element: Element, context: PictureContext): Element {
return this.onMousedown(element, context)
示例2: 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 PATH = new PictureCommand('Path', {
name: 'path',
shortcutKey: 'p',
noOfInstances: 0,
onMousedown(context: PictureContext): Element {
return SVG.createPath(context.points)
},
onMousemove(element: Element, context: PictureContext): Element {
const { end } = context
let d = element.getAttributeNS(null, 'd');
element.setAttributeNS(null, 'd', `${d} L${end.x.toString()},${end.y.toString()}`)
return element;
},
onMouseup(element: Element, context: PictureContext): Element {
return this.onMousedown(element, context)
},
getSummary(data: PictureContext) {
return `Draw ${data.name || (this.name + '-' + data.instanceCount)} from (${data.start.x}, ${data.start.y}) to (${data.end.x}, ${data.end.y})`
}
})
示例3: 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 LINE = new PictureCommand('Line', {
name: 'line',
shortcutKey: 'l',
noOfInstances: 0,
onMousedown(context: PictureContext): Element {
const { start, end } = context
return SVG.createLine(start.x, start.y, end.x, end.y)
},
onMousemove(element: Element, context: PictureContext): Element {
const { end } = context
element.setAttributeNS(null, 'x2', end.x.toString())
element.setAttributeNS(null, 'y2', end.y.toString())
return element
},
onMouseup(element: Element, context: PictureContext): Element {
return this.onMousedown(element, context)
},
getSummary(data: PictureContext) {
return `Draw ${data.name || (this.name + '-' + data.instanceCount)} from (${data.start.x}, ${data.start.y}) to (${data.end.x}, ${data.end.y})`
}
示例4: 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())