Skip to content

Commit

Permalink
Harmonize ration param name
Browse files Browse the repository at this point in the history
  • Loading branch information
amiika committed Dec 18, 2023
1 parent 8819a15 commit f46565f
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions src/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,9 @@ export type ShapeObject = {
fillStyle: string,
secondary: string,
strokeStyle: string,
rotate: number,
rotation: number,
points: number,
outerRadius: number,
rotation: number,
eyeSize: number,
happiness: number,
slices: number,
Expand Down Expand Up @@ -2455,22 +2454,22 @@ export class UserAPI {
public equilateral = (
radius: number|ShapeObject = this.hc()/3,
fillStyle: string = "white",
rotate: number = 0,
rotation: number = 0,
x: number = this.wc(),
y: number = this.hc(),
): boolean => {
if(typeof radius === "object") {
fillStyle = radius.fillStyle || "white";
x = radius.x || this.wc();
y = radius.y || this.hc();
rotate = radius.rotate || 0;
rotation = radius.rotation || 0;
radius = radius.radius || this.hc()/3;
}
const canvas: HTMLCanvasElement = this.app.interface.drawings as HTMLCanvasElement;
const ctx = canvas.getContext("2d")!;
ctx.save();
ctx.translate(x, y);
ctx.rotate((rotate * Math.PI) / 180);
ctx.rotate((rotation * Math.PI) / 180);
ctx.beginPath();
ctx.moveTo(0, -radius);
ctx.lineTo(radius, radius);
Expand All @@ -2486,23 +2485,23 @@ export class UserAPI {
width: number|ShapeObject = this.hc()/3,
height: number = this.hc()/3,
fillStyle: string = "white",
rotate: number = 0,
rotation: number = 0,
x: number = this.wc(),
y: number = this.hc(),
): boolean => {
if(typeof width === "object") {
fillStyle = width.fillStyle || "white";
x = width.x || this.wc();
y = width.y || this.hc();
rotate = width.rotate || 0;
rotation = width.rotation || 0;
height = width.height || this.hc()/3;
width = width.width || this.hc()/3;
}
const canvas: HTMLCanvasElement = this.app.interface.drawings as HTMLCanvasElement;
const ctx = canvas.getContext("2d")!;
ctx.save();
ctx.translate(x, y);
ctx.rotate((rotate * Math.PI) / 180);
ctx.rotate((rotation * Math.PI) / 180);
ctx.beginPath();
ctx.moveTo(0, -height);
ctx.lineTo(width, height);
Expand Down Expand Up @@ -2546,15 +2545,15 @@ export class UserAPI {
fillStyle: string = "white",
secondary: string = "black",
stroke: string = "black",
rotate: number = 0,
rotation: number = 0,
x: number = this.wc(),
y: number = this.hc(),
): boolean => {
if (typeof slices === "object") {
fillStyle = slices.fillStyle || "white";
x = slices.x || this.wc();
y = slices.y || this.hc();
rotate = slices.rotate || 0;
rotation = slices.rotation || 0;
radius = slices.radius || this.hc() / 3;
eaten = slices.eaten || 0;
hole = slices.hole || this.hc() / 12;
Expand All @@ -2567,7 +2566,7 @@ export class UserAPI {
const ctx = canvas.getContext("2d")!;
ctx.save();
ctx.translate(x, y);
ctx.rotate((rotate * Math.PI) / 180);
ctx.rotate((rotation * Math.PI) / 180);

if(slices<2) {
ctx.beginPath();
Expand Down Expand Up @@ -2629,15 +2628,15 @@ export class UserAPI {
fillStyle: string = "white",
secondary: string = "black",
stroke: string = "black",
rotate: number = 0,
rotation: number = 0,
x: number = this.wc(),
y: number = this.hc(),
): boolean => {
if (typeof slices === "object") {
fillStyle = slices.fillStyle || "white";
x = slices.x || this.wc();
y = slices.y || this.hc();
rotate = slices.rotate || 0;
rotation = slices.rotation || 0;
radius = slices.radius || this.hc() / 3;
secondary = slices.secondary || "black";
stroke = slices.stroke || "black";
Expand All @@ -2649,7 +2648,7 @@ export class UserAPI {
const ctx = canvas.getContext("2d")!;
ctx.save();
ctx.translate(x, y);
ctx.rotate((rotate * Math.PI) / 180);
ctx.rotate((rotation * Math.PI) / 180);

if(slices<2) {
ctx.beginPath();
Expand Down Expand Up @@ -2697,7 +2696,7 @@ export class UserAPI {
points: number|ShapeObject = 5,
radius: number = this.hc()/3,
fillStyle: string = "white",
rotate: number = 0,
rotation: number = 0,
outerRadius: number = radius/100,
x: number = this.wc(),
y: number = this.hc(),
Expand All @@ -2707,7 +2706,7 @@ export class UserAPI {
fillStyle = points.fillStyle || "white";
x = points.x || this.wc();
y = points.y || this.hc();
rotate = points.rotate || 0;
rotation = points.rotation || 0;
outerRadius = points.outerRadius || radius/100;
points = points.points || 5;
}
Expand All @@ -2717,7 +2716,7 @@ export class UserAPI {
const ctx = canvas.getContext("2d")!;
ctx.save();
ctx.translate(x, y);
ctx.rotate((rotate * Math.PI) / 180);
ctx.rotate((rotation * Math.PI) / 180);
ctx.beginPath();
ctx.moveTo(0, -radius);
for (let i = 0; i < points; i++) {
Expand All @@ -2736,7 +2735,7 @@ export class UserAPI {
public stroke = (
width: number|ShapeObject = 1,
strokeStyle: string = "white",
rotate: number = 0,
rotation: number = 0,
x1: number = this.wc()-this.wc()/10,
y1: number = this.hc(),
x2: number = this.wc()+this.wc()/5,
Expand All @@ -2748,14 +2747,14 @@ export class UserAPI {
y1 = width.y1 || this.hc();
x2 = width.x2 || this.wc()+this.wc()/5;
y2 = width.y2 || this.hc();
rotate = width.rotate || 0;
rotation = width.rotation || 0;
width = width.width || 1;
}
const canvas: HTMLCanvasElement = this.app.interface.drawings as HTMLCanvasElement;
const ctx = canvas.getContext("2d")!;
ctx.save();
ctx.translate(x1, y1);
ctx.rotate((rotate * Math.PI) / 180);
ctx.rotate((rotation * Math.PI) / 180);
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(x2-x1, y2-y1);
Expand All @@ -2770,24 +2769,23 @@ export class UserAPI {
width: number|ShapeObject = this.wc()/4,
height: number = this.wc()/4,
fillStyle: string = "white",
rotate: number = 0,
rotation: number = 0,
x: number = this.wc()-this.wc()/8,
y: number = this.hc()-this.hc()/8,
): boolean => {
if(typeof width === "object") {
fillStyle = width.fillStyle || "white";
x = width.x || this.wc()-this.wc()/4;
y = width.y || this.hc()-this.hc()/2;
rotate = width.rotate || 0;
rotation = width.rotation || 0;
height = width.height || this.wc()/4;
width = width.width || this.wc()/4;

}
const canvas: HTMLCanvasElement = this.app.interface.drawings as HTMLCanvasElement;
const ctx = canvas.getContext("2d")!;
ctx.save();
ctx.translate(x, y);
ctx.rotate((rotate * Math.PI) / 180);
ctx.rotate((rotation * Math.PI) / 180);
ctx.fillStyle = fillStyle;
ctx.fillRect(0, 0, width, height);
ctx.restore();
Expand Down

0 comments on commit f46565f

Please sign in to comment.