|
@@ -96,6 +96,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
|
|
|
this.setPen();
|
|
|
this.setBrush();
|
|
|
this.setComposite();
|
|
|
+ this.setShadow();
|
|
|
this._canvas.fillRect(rect.x, rect.y, rect.width, rect.height);
|
|
|
this._canvas.strokeRect(rect.x, rect.y, rect.width, rect.height);
|
|
|
} // Function drawRect()
|
|
@@ -112,6 +113,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
|
|
|
this.setPen();
|
|
|
this.setBrush();
|
|
|
this.setComposite();
|
|
|
+ this.setShadow();
|
|
|
this._canvas.beginPath();
|
|
|
this._canvas.arc(cx, cy, r, 0, 2 * Math.PI, true);
|
|
|
this._canvas.fill();
|
|
@@ -131,6 +133,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
|
|
|
this.setPen();
|
|
|
this.setBrush();
|
|
|
this.setComposite();
|
|
|
+ this.setShadow();
|
|
|
this._canvas.beginPath();
|
|
|
this._canvas.ellipse(cx, cy, rx, ry, 0.5, 0, 2 * Math.PI, true);
|
|
|
} // Function drawEllipse()
|
|
@@ -157,6 +160,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
|
|
|
this.setPen();
|
|
|
this.setBrush();
|
|
|
this.setComposite();
|
|
|
+ this.setShadow();
|
|
|
let p = SPath2D.arc(x, y, width, height, startAngle, endAngle);
|
|
|
let path = new Path2D(
|
|
|
SPath2D.arc(x, y, width, height, startAngle, endAngle)
|
|
@@ -186,6 +190,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
|
|
|
this.setPen();
|
|
|
this.setBrush();
|
|
|
this.setComposite();
|
|
|
+ this.setShadow();
|
|
|
let path = new Path2D(
|
|
|
SPath2D.chord(x, y, width, height, startAngle, endAngle)
|
|
|
);
|
|
@@ -216,6 +221,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
|
|
|
this.setPen();
|
|
|
this.setBrush();
|
|
|
this.setComposite();
|
|
|
+ this.setShadow();
|
|
|
let path = new Path2D(
|
|
|
SPath2D.pie(x, y, width, height, startAngle, endAngle)
|
|
|
);
|
|
@@ -233,6 +239,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
|
|
|
this.setPen();
|
|
|
this.setBrush();
|
|
|
this.setComposite();
|
|
|
+ this.setShadow();
|
|
|
this._canvas.beginPath();
|
|
|
this._canvas.moveTo(line.x1, line.y1);
|
|
|
this._canvas.lineTo(line.x2, line.y2);
|
|
@@ -254,6 +261,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
|
|
|
this.setPen();
|
|
|
this.setBrush();
|
|
|
this.setComposite();
|
|
|
+ this.setShadow();
|
|
|
|
|
|
this._canvas.beginPath();
|
|
|
this._canvas.moveTo(points[0].x, points[0].y);
|
|
@@ -279,6 +287,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
|
|
|
this.setPen();
|
|
|
this.setBrush();
|
|
|
this.setComposite();
|
|
|
+ this.setShadow();
|
|
|
|
|
|
this._canvas.beginPath();
|
|
|
this._canvas.moveTo(points[0].x, points[0].y);
|
|
@@ -301,6 +310,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
|
|
|
this.setPen();
|
|
|
this.setBrush();
|
|
|
this.setComposite();
|
|
|
+ this.setShadow();
|
|
|
|
|
|
this._canvas.fill(path._path);
|
|
|
this._canvas.stroke(path._path);
|
|
@@ -320,6 +330,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
|
|
|
this.setBrush();
|
|
|
this.setFont();
|
|
|
this.setComposite();
|
|
|
+ this.setShadow();
|
|
|
|
|
|
if (maxWidth == undefined) {
|
|
|
this._canvas.fillText(text, x, y);
|
|
@@ -418,7 +429,6 @@ export class SCanvasPaintEngine extends SPaintEngine {
|
|
|
* @param style 风格
|
|
|
*/
|
|
|
private setLineCapStyle(style: SLineCapStyle): void {
|
|
|
- // TODO: 找原因,去下边一行
|
|
|
if (style == undefined) return;
|
|
|
if (style == SLineCapStyle.Round) {
|
|
|
this._canvas.lineCap = "round";
|
|
@@ -464,7 +474,9 @@ export class SCanvasPaintEngine extends SPaintEngine {
|
|
|
gradient.stopList.forEach((t: SGradientStop): void => {
|
|
|
drawGradient.addColorStop(
|
|
|
t.pos,
|
|
|
- `rgba(${t.color.red},${t.color.green},${t.color.blue},${t.color.alpha})`
|
|
|
+ `rgba(${t.color.red},${t.color.green},${
|
|
|
+ t.color.blue
|
|
|
+ },${t.color.alpha / 255.0})`
|
|
|
);
|
|
|
});
|
|
|
this._canvas.fillStyle = drawGradient;
|
|
@@ -486,6 +498,22 @@ export class SCanvasPaintEngine extends SPaintEngine {
|
|
|
} // Function setComposite()
|
|
|
|
|
|
/**
|
|
|
+ * 设置阴影
|
|
|
+ */
|
|
|
+ private setShadow(): void {
|
|
|
+ if (this.state.shadow.shadowBlur > 0 && this.state.shadow.shadowColor) {
|
|
|
+ this._canvas.shadowBlur = this.state.shadow.shadowBlur;
|
|
|
+ this._canvas.shadowColor = `rgba(${
|
|
|
+ this.state.shadow.shadowColor.red
|
|
|
+ },${this.state.shadow.shadowColor.green}, ${
|
|
|
+ this.state.shadow.shadowColor.blue
|
|
|
+ }, ${this.state.shadow.shadowColor.alpha / 255.0})`;
|
|
|
+ this._canvas.shadowOffsetX = this.state.shadow.shadowOffsetX;
|
|
|
+ this._canvas.shadowOffsetY = this.state.shadow.shadowOffsetY;
|
|
|
+ }
|
|
|
+ } // Function setShadow()
|
|
|
+
|
|
|
+ /**
|
|
|
* 设置字体
|
|
|
*/
|
|
|
private setFont(): void {
|