mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-10 02:13:58 +01:00
28 lines
564 B
JavaScript
28 lines
564 B
JavaScript
import {Shape} from './shape'
|
|
|
|
export class CrossHair extends Shape {
|
|
constructor (x, y, rad) {
|
|
super();
|
|
this.x = x;
|
|
this.y = y;
|
|
this.rad = rad;
|
|
this.style = null;
|
|
}
|
|
|
|
draw(ctx, scale) {
|
|
ctx.beginPath();
|
|
const rad = this.rad / scale;
|
|
ctx.moveTo(this.x - rad, this.y);
|
|
ctx.lineTo(this.x + rad, this.y);
|
|
ctx.closePath();
|
|
ctx.moveTo(this.x, this.y - rad);
|
|
ctx.lineTo(this.x, this.y + rad);
|
|
ctx.closePath();
|
|
|
|
ctx.save();
|
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
ctx.stroke();
|
|
ctx.restore();
|
|
}
|
|
}
|
|
|