mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Get rid of all unused options
This commit is contained in:
parent
a59a2ff806
commit
94578e5d9d
2 changed files with 19 additions and 50 deletions
|
@ -520,9 +520,7 @@ function renderScene(
|
||||||
scrollBar.y,
|
scrollBar.y,
|
||||||
scrollBar.width,
|
scrollBar.width,
|
||||||
scrollBar.height,
|
scrollBar.height,
|
||||||
SCROLLBAR_WIDTH / 2,
|
SCROLLBAR_WIDTH / 2
|
||||||
true,
|
|
||||||
true
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
context.strokeStyle = strokeStyle;
|
context.strokeStyle = strokeStyle;
|
||||||
|
|
|
@ -1,66 +1,37 @@
|
||||||
/**
|
/**
|
||||||
* https://stackoverflow.com/a/3368118
|
* https://stackoverflow.com/a/3368118
|
||||||
* Draws a rounded rectangle using the current state of the canvas.
|
* Draws a rounded rectangle using the current state of the canvas.
|
||||||
* If you omit the last three params, it will draw a rectangle
|
* @param {CanvasRenderingContext2D} context
|
||||||
* outline with a 5 pixel border radius
|
|
||||||
* @param {CanvasRenderingContext2D} ctx
|
|
||||||
* @param {Number} x The top left x coordinate
|
* @param {Number} x The top left x coordinate
|
||||||
* @param {Number} y The top left y coordinate
|
* @param {Number} y The top left y coordinate
|
||||||
* @param {Number} width The width of the rectangle
|
* @param {Number} width The width of the rectangle
|
||||||
* @param {Number} height The height of the rectangle
|
* @param {Number} height The height of the rectangle
|
||||||
* @param {Number} [radius = 5] The corner radius; It can also be an object
|
* @param {Number} radius The corner radius
|
||||||
* to specify different radii for corners
|
|
||||||
* @param {Number} [radius.tl = 0] Top left
|
|
||||||
* @param {Number} [radius.tr = 0] Top right
|
|
||||||
* @param {Number} [radius.br = 0] Bottom right
|
|
||||||
* @param {Number} [radius.bl = 0] Bottom left
|
|
||||||
* @param {Boolean} [fill = false] Whether to fill the rectangle.
|
|
||||||
* @param {Boolean} [stroke = true] Whether to stroke the rectangle.
|
|
||||||
*/
|
*/
|
||||||
export function roundRect(
|
export function roundRect(
|
||||||
ctx: CanvasRenderingContext2D,
|
context: CanvasRenderingContext2D,
|
||||||
x: number,
|
x: number,
|
||||||
y: number,
|
y: number,
|
||||||
width: number,
|
width: number,
|
||||||
height: number,
|
height: number,
|
||||||
radius?: number | { tl: number; tr: number; br: number; bl: number },
|
radius: number
|
||||||
fill?: boolean,
|
|
||||||
stroke?: boolean
|
|
||||||
) {
|
) {
|
||||||
if (typeof stroke === "undefined") {
|
context.beginPath();
|
||||||
stroke = true;
|
context.moveTo(x + radius, y);
|
||||||
}
|
context.lineTo(x + width - radius, y);
|
||||||
if (typeof radius === "undefined") {
|
context.quadraticCurveTo(x + width, y, x + width, y + radius);
|
||||||
radius = 5;
|
context.lineTo(x + width, y + height - radius);
|
||||||
}
|
context.quadraticCurveTo(
|
||||||
if (typeof radius === "number") {
|
|
||||||
radius = { tl: radius, tr: radius, br: radius, bl: radius };
|
|
||||||
} else {
|
|
||||||
const sides = ["tl", "tr", "br", "bl"] as const;
|
|
||||||
for (const side of sides) {
|
|
||||||
radius[side] = radius[side] || 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.moveTo(x + radius.tl, y);
|
|
||||||
ctx.lineTo(x + width - radius.tr, y);
|
|
||||||
ctx.quadraticCurveTo(x + width, y, x + width, y + radius.tr);
|
|
||||||
ctx.lineTo(x + width, y + height - radius.br);
|
|
||||||
ctx.quadraticCurveTo(
|
|
||||||
x + width,
|
x + width,
|
||||||
y + height,
|
y + height,
|
||||||
x + width - radius.br,
|
x + width - radius,
|
||||||
y + height
|
y + height
|
||||||
);
|
);
|
||||||
ctx.lineTo(x + radius.bl, y + height);
|
context.lineTo(x + radius, y + height);
|
||||||
ctx.quadraticCurveTo(x, y + height, x, y + height - radius.bl);
|
context.quadraticCurveTo(x, y + height, x, y + height - radius);
|
||||||
ctx.lineTo(x, y + radius.tl);
|
context.lineTo(x, y + radius);
|
||||||
ctx.quadraticCurveTo(x, y, x + radius.tl, y);
|
context.quadraticCurveTo(x, y, x + radius, y);
|
||||||
ctx.closePath();
|
context.closePath();
|
||||||
if (fill) {
|
context.fill();
|
||||||
ctx.fill();
|
context.stroke();
|
||||||
}
|
|
||||||
if (stroke) {
|
|
||||||
ctx.stroke();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue