本文整理匯總了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())