123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- import {CADElement, ElementProps} from './element'
- import {SVGURI} from '../constant/Element'
- import Renderer from '../base/renderer'
- export interface SeftProps {
- r?: number,
- r1?: number,
- strokeWidth?: number,
- fillColor?: string,
- storkeColor?: string
- }
- export interface point extends SeftProps {
- x: number,
- y: number
- }
- let a = 1;
- export interface PointProps extends point, ElementProps { }
- class Point extends CADElement<PointProps, Point> {
- init: SeftProps
- real: SVGEllipseElement
- static fillColor = 'rgb(0, 200, 175)'
- static storkeColor = 'green'
- static Setting = new Map<Renderer, SeftProps>()
- constructor({strokeWidth = 0, r = 4, r1 = 4, fillColor, storkeColor, ...args}: PointProps) {
- fillColor = fillColor || Point.Setting.get(args.renderer).fillColor
- storkeColor = storkeColor || Point.Setting.get(args.renderer).storkeColor
- super({storkeColor, fillColor, r, r1, strokeWidth, ...args})
- this.init = { strokeWidth, r, r1, fillColor, storkeColor }
- this.update()
- }
- grentNode() {
- let point = document.createElementNS(SVGURI, 'ellipse')
- point.setAttribute('_id', (a++).toString())
- return point
- }
- update() {
- let r1 = this.r * this.multiple
- let r2 = this.r1 * this.multiple
- let strokeWidth = this.strokeWidth * this.multiple
- // console.log(this)
- try {
- this.real.setAttribute('cx', this.x.toString())
- this.real.setAttribute('cy', this.y.toString())
- this.real.setAttribute('fill', this.fillColor)
- this.real.setAttribute('rx', r1.toString())
- this.real.setAttribute('ry', r2.toString())
- this.real.setAttribute('stroke-width', strokeWidth.toString())
- this.real.setAttribute('stroke', this.storkeColor)
- } catch (e) {
- console.error(this.x)
- }
- }
- destroy() {
- super.destroy()
- }
- }
- export default Point
|