mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-14 02:31:51 +00:00
Allow mods to replace builtin sub shapes
This commit is contained in:
parent
c553ee1632
commit
7e0689694c
@ -384,75 +384,79 @@ export class ShapeDefinition extends BasicSerializableObject {
|
|||||||
context.strokeStyle = THEME.items.outline;
|
context.strokeStyle = THEME.items.outline;
|
||||||
context.lineWidth = THEME.items.outlineWidth;
|
context.lineWidth = THEME.items.outlineWidth;
|
||||||
|
|
||||||
switch (subShape) {
|
if (MODS_ADDITIONAL_SUB_SHAPE_DRAWERS[subShape]) {
|
||||||
case enumSubShape.rect: {
|
MODS_ADDITIONAL_SUB_SHAPE_DRAWERS[subShape]({
|
||||||
context.beginPath();
|
context,
|
||||||
const dims = quadrantSize * layerScale;
|
layerScale,
|
||||||
context.rect(-quadrantHalfSize, quadrantHalfSize - dims, dims, dims);
|
quadrantSize,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
switch (subShape) {
|
||||||
|
case enumSubShape.rect: {
|
||||||
|
context.beginPath();
|
||||||
|
const dims = quadrantSize * layerScale;
|
||||||
|
context.rect(-quadrantHalfSize, quadrantHalfSize - dims, dims, dims);
|
||||||
|
context.fill();
|
||||||
|
context.stroke();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case enumSubShape.star: {
|
||||||
|
context.beginPath();
|
||||||
|
const dims = quadrantSize * layerScale;
|
||||||
|
|
||||||
break;
|
let originX = -quadrantHalfSize;
|
||||||
}
|
let originY = quadrantHalfSize - dims;
|
||||||
case enumSubShape.star: {
|
|
||||||
context.beginPath();
|
|
||||||
const dims = quadrantSize * layerScale;
|
|
||||||
|
|
||||||
let originX = -quadrantHalfSize;
|
const moveInwards = dims * 0.4;
|
||||||
let originY = quadrantHalfSize - dims;
|
context.moveTo(originX, originY + moveInwards);
|
||||||
|
context.lineTo(originX + dims, originY);
|
||||||
|
context.lineTo(originX + dims - moveInwards, originY + dims);
|
||||||
|
context.lineTo(originX, originY + dims);
|
||||||
|
context.closePath();
|
||||||
|
context.fill();
|
||||||
|
context.stroke();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
const moveInwards = dims * 0.4;
|
case enumSubShape.windmill: {
|
||||||
context.moveTo(originX, originY + moveInwards);
|
context.beginPath();
|
||||||
context.lineTo(originX + dims, originY);
|
const dims = quadrantSize * layerScale;
|
||||||
context.lineTo(originX + dims - moveInwards, originY + dims);
|
|
||||||
context.lineTo(originX, originY + dims);
|
|
||||||
context.closePath();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case enumSubShape.windmill: {
|
let originX = -quadrantHalfSize;
|
||||||
context.beginPath();
|
let originY = quadrantHalfSize - dims;
|
||||||
const dims = quadrantSize * layerScale;
|
const moveInwards = dims * 0.4;
|
||||||
|
context.moveTo(originX, originY + moveInwards);
|
||||||
|
context.lineTo(originX + dims, originY);
|
||||||
|
context.lineTo(originX + dims, originY + dims);
|
||||||
|
context.lineTo(originX, originY + dims);
|
||||||
|
context.closePath();
|
||||||
|
context.fill();
|
||||||
|
context.stroke();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
let originX = -quadrantHalfSize;
|
case enumSubShape.circle: {
|
||||||
let originY = quadrantHalfSize - dims;
|
context.beginPath();
|
||||||
const moveInwards = dims * 0.4;
|
context.moveTo(-quadrantHalfSize, quadrantHalfSize);
|
||||||
context.moveTo(originX, originY + moveInwards);
|
context.arc(
|
||||||
context.lineTo(originX + dims, originY);
|
-quadrantHalfSize,
|
||||||
context.lineTo(originX + dims, originY + dims);
|
quadrantHalfSize,
|
||||||
context.lineTo(originX, originY + dims);
|
quadrantSize * layerScale,
|
||||||
context.closePath();
|
-Math.PI * 0.5,
|
||||||
break;
|
0
|
||||||
}
|
);
|
||||||
|
context.closePath();
|
||||||
|
context.fill();
|
||||||
|
context.stroke();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case enumSubShape.circle: {
|
default: {
|
||||||
context.beginPath();
|
|
||||||
context.moveTo(-quadrantHalfSize, quadrantHalfSize);
|
|
||||||
context.arc(
|
|
||||||
-quadrantHalfSize,
|
|
||||||
quadrantHalfSize,
|
|
||||||
quadrantSize * layerScale,
|
|
||||||
-Math.PI * 0.5,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
context.closePath();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
if (MODS_ADDITIONAL_SUB_SHAPE_DRAWERS[subShape]) {
|
|
||||||
MODS_ADDITIONAL_SUB_SHAPE_DRAWERS[subShape]({
|
|
||||||
context,
|
|
||||||
layerScale,
|
|
||||||
quadrantSize,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
throw new Error("Unkown sub shape: " + subShape);
|
throw new Error("Unkown sub shape: " + subShape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context.fill();
|
|
||||||
context.stroke();
|
|
||||||
|
|
||||||
context.rotate(-rotation);
|
context.rotate(-rotation);
|
||||||
context.translate(-centerQuadrantX, -centerQuadrantY);
|
context.translate(-centerQuadrantX, -centerQuadrantY);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user