zextra
Version:
zikojs extra components
49 lines (48 loc) • 1.22 kB
JavaScript
import { UIElementrom "ziko";
class ZikoSvgElement extends UIElement
constructor(type) {
super()
Object.assign(this.cache,{
type
})
}
pos(x,y){
return this.posX(x).posY(y);
}
posX(x){
if(["circle","ellipse"].includes(this.cache.type))this.element.cx.baseVal.value=x;
else this.element.x.baseVal.value=x;
return this;
}
posY(y){
if(["circle","ellipse"].includes(this.cache.type))this.element.cy.baseVal.value=y;
else this.element.y.baseVal.value=y;
return this;
}
translate(x,y){
return this;
}
color({ stroke, fill }) {
this.element?.setAttribute("stroke", stroke);
this.element?.setAttribute("fill", fill);
return this;
}
fill(color = "none") {
this.element?.setAttribute("fill", color);
return this;
}
stroke(color = "none", width) {
this.element?.setAttribute("stroke", color);
width && this.strokeWidth(width);
return this;
}
strokeWidth(width = 1) {
this.element?.setAttribute("stroke-width", width);
return this;
}
opacity(value = 1) {
this.element?.setAttribute("opacity", value);
return this;
}
}
export default ZikoSvgElement;