import {SGraphItem} from "@persagy-web/graph/lib"; import {SColor, SLinearGradient, SPainter, SRadialGradient, SRect} from "@persagy-web/draw/lib"; export class GradRect extends SGraphItem{ minX = 0; minY = 0; maxY = 1000; maxX = 1000; gradient: SRadialGradient | SLinearGradient | null = null; constructor(parent: SGraphItem, grad: SRadialGradient) { super(parent); this.gradient = grad; this.gradient.addColorStop(0, new SColor('#ff483b')); this.gradient.addColorStop(0.5, new SColor('#04ff00')); this.gradient.addColorStop(1, new SColor('#3d4eff')); } boundingRect() { return new SRect( this.minX, this.minY, this.maxX - this.minX, this.maxY - this.minY ); } onDraw(painter:SPainter) { painter.pen.color = SColor.Black; painter.brush.gradient = this.gradient; painter.drawRect(0,0,1000,1000); } }