mirror of
https://github.com/1disk/edp445.git
synced 2024-08-14 22:47:02 +00:00
Changed alot of things.
This commit is contained in:
parent
a5a0523e5a
commit
3513d5390c
2016 changed files with 336930 additions and 9 deletions
22
node_modules/canvacord/plugins/rect.js
generated
vendored
Normal file
22
node_modules/canvacord/plugins/rect.js
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
module.exports = (ctx, x, y, height, width, color, stroke = false, lineWidth = 1) => {
|
||||
if (!ctx) throw new Error("Missing canvas context!");
|
||||
if (isNaN(x)) throw new Error(`Expected height to be a number, received ${typeof height}!`);
|
||||
if (isNaN(y)) throw new Error(`Expected width to be a number, received ${typeof width}!`);
|
||||
if (isNaN(height)) throw new Error(`Expected height to be a number, received ${typeof height}!`);
|
||||
if (isNaN(width)) throw new Error(`Expected width to be a number, received ${typeof width}!`);
|
||||
if (!color) color = "#000000";
|
||||
stroke = !!stroke;
|
||||
|
||||
ctx.beginPath();
|
||||
if (stroke) {
|
||||
ctx.lineWidth = lineWidth;
|
||||
ctx.strokeStyle = color;
|
||||
ctx.rect(x, y, width, height);
|
||||
ctx.stroke();
|
||||
} else {
|
||||
ctx.fillStyle = color;
|
||||
ctx.fillRect(x, y, width, height);
|
||||
}
|
||||
ctx.closePath();
|
||||
return ctx;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue