2026_08_31
This commit is contained in:
commit
73015386e9
2320 files changed
+80291
No files matched your search
@@ -0,0 +1,98 @@
|
||||
import { DrawElement } from "./draw"
|
||||
|
||||
interface PropEllipse {
|
||||
cx: number
|
||||
cy: number
|
||||
rx: number
|
||||
ry: number
|
||||
}
|
||||
|
||||
interface SvgOptions {
|
||||
color?: string
|
||||
storkWidth?: number,
|
||||
stroke?:string,
|
||||
dasharray?: string,
|
||||
fill?: string,
|
||||
opacity?: number
|
||||
}
|
||||
|
||||
|
||||
export class DrawEllipse extends DrawElement {
|
||||
|
||||
|
||||
|
||||
constructor(private posAndSize: PropEllipse) {
|
||||
super();
|
||||
|
||||
// Default Attribute
|
||||
this.attributes.set('strokeWidth', 1);
|
||||
this.attributes.set('stroke', "#000000");
|
||||
this.attributes.set('fill', 'none');
|
||||
}
|
||||
|
||||
|
||||
setAtrr(att: Partial<SvgOptions>) {
|
||||
Object.entries(att).forEach(([key, value]) => {
|
||||
this.attributes.set(key, value);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
drawSvg() {
|
||||
const paraStr = this.convertAttributesToString(this.attributes);
|
||||
const posSvg = this.getSvgPositions(this.posAndSize)
|
||||
const posStr = this.convertAttributesToString(posSvg);
|
||||
|
||||
const shape = this.drawElementSvg(posStr, paraStr);
|
||||
|
||||
return shape;
|
||||
}
|
||||
|
||||
drawXaml(): string {
|
||||
const paraStr = this.convertAttributesToString(this.attributes, true);
|
||||
const posXaml = this.getXamlPositions(this.posAndSize)
|
||||
const posStr = this.convertAttributesToString(posXaml, true);
|
||||
|
||||
const shape = this.drawElementXaml(posStr, paraStr);
|
||||
|
||||
return shape;
|
||||
}
|
||||
|
||||
drawElementSvg(position: string, options: string) {
|
||||
return `<ellipse ${position} ${options}></ellipse>`
|
||||
}
|
||||
|
||||
drawElementXaml(position: string, options: string) {
|
||||
|
||||
return `<Ellipse ${position} ${options}></Ellipse>`
|
||||
|
||||
}
|
||||
|
||||
getSvgPositions(dim: PropEllipse) {
|
||||
|
||||
let retValue = new Map<string, number>();
|
||||
|
||||
retValue.set('cx', dim.cx);
|
||||
retValue.set('cy', dim.cy);
|
||||
retValue.set('rx', dim.rx);
|
||||
retValue.set('ry', dim.ry);
|
||||
|
||||
return retValue;
|
||||
|
||||
}
|
||||
|
||||
getXamlPositions(dim: PropEllipse) {
|
||||
|
||||
let retValue = new Map<string, number>();
|
||||
|
||||
retValue.set('Canvas.Left', dim.cx - dim.rx);
|
||||
retValue.set('Canvas.Top', dim.cy - dim.ry);
|
||||
retValue.set('Width', dim.rx * 2);
|
||||
retValue.set('Height', dim.ry * 2);
|
||||
|
||||
return retValue;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user