ctx.strokeRect(x - size, y - size, 2 * size, 2 * size);
break;
case 'rectRot':
- ctx.translate(x, y);
- ctx.rotate(Math.PI / 4);
size = 1 / Math.SQRT2 * radius;
- ctx.fillRect(-size, -size, 2 * size, 2 * size);
- ctx.strokeRect(-size, -size, 2 * size, 2 * size);
- ctx.setTransform(1, 0, 0, 1, 0, 0);
+ ctx.beginPath();
+ ctx.moveTo(x - size, y);
+ ctx.lineTo(x, y + size);
+ ctx.lineTo(x + size, y);
+ ctx.lineTo(x, y - size);
+ ctx.closePath();
+ ctx.fill();
break;
case 'cross':
ctx.beginPath();
name: 'setFillStyle',
args: ['rgba(0, 255, 0)']
}, {
- name: 'translate',
- args: [10, 15]
+ name: 'beginPath',
+ args: []
}, {
- name: 'rotate',
- args: [Math.PI / 4]
+ name: 'moveTo',
+ args: [10 - 1 / Math.SQRT2 * 2, 15]
}, {
- name: 'fillRect',
- args: [-1 / Math.SQRT2 * 2, -1 / Math.SQRT2 * 2, 2 / Math.SQRT2 * 2, 2 / Math.SQRT2 * 2],
+ name: 'lineTo',
+ args: [10, 15 + 1 / Math.SQRT2 * 2]
}, {
- name: 'strokeRect',
- args: [-1 / Math.SQRT2 * 2, -1 / Math.SQRT2 * 2, 2 / Math.SQRT2 * 2, 2 / Math.SQRT2 * 2],
+ name: 'lineTo',
+ args: [10 + 1 / Math.SQRT2 * 2, 15],
}, {
- name: 'setTransform',
- args: [1, 0, 0, 1, 0, 0],
+ name: 'lineTo',
+ args: [10, 15 - 1 / Math.SQRT2 * 2],
+ }, {
+ name: 'closePath',
+ args: []
+ }, {
+ name: 'fill',
+ args: [],
}, {
name: 'stroke',
args: []