Fix typos and do not use window as a var name

This commit is contained in:
linarphy 2024-01-25 16:36:21 +01:00
parent 3b9242e287
commit cdb46185ef
No known key found for this signature in database
GPG key ID: 1D42980937147C95

View file

@ -711,18 +711,18 @@ class Axis
* draw xaxis and yaxis to canvas
*
* @param ctx CanvasRenderingContext2D Context of canvas
* @param window 2darray<Number> Window where to draw the canvas
* @param view 2darray<Number> Window where to draw the canvas with
* the real value
* @param box 2darray<Number> Window where to draw the axis
* @param view 2darray<Number> Window where to draw the canvas with the
* real value
*/
draw(ctx, window, view)
draw(ctx, box, view)
{
ctx.strokeStyle = 'black';
ctx.fillStyle = 'black';
let index = 0;
let start_pos = window[0][1];
let start_pos = box[0][1];
let padding = (
window[1][1] - window[0][1] - this.margin - this.text_height - this.size_tick
box[1][1] - box[0][1] - this.margin - this.text_height - this.size_tick
) / this.number_y_tick;
let step = (view[1][1] - view[0][1]) / this.number_y_tick;
let width = 2 * this.text_height;
@ -735,27 +735,27 @@ class Axis
let text_position = current_y + this.text_height / 2
ctx.beginPath();
ctx.moveTo(
window[0][0] + this.margin + width,
box[0][0] + this.margin + width,
current_y,
);
ctx.lineTo(
window[0][0] + this.margin + this.size_tick + width,
box[0][0] + this.margin + this.size_tick + width,
current_y,
);
ctx.stroke();
ctx.fillText(
text,
window[0][0] + this.margin,
box[0][0] + this.margin,
text_position,
);
current_y += padding;
index += 1;
}
index = 0;
start_pos = window[0][0] + this.margin + this.size_tick
start_pos = box[0][0] + this.margin + this.size_tick
+ width;
padding = (
window[1][0] - this.margin - start_pos
box[1][0] - this.margin - start_pos
) / this.number_x_tick;
step = (view[1][0] - view[0][0]) / this.number_x_tick;
while (index <= this.number_x_tick)
@ -770,23 +770,23 @@ class Axis
ctx.beginPath();
ctx.moveTo(
current_x,
window[1][1] - this.margin - this.text_height,
box[1][1] - this.margin - this.text_height,
);
ctx.lineTo(
current_x,
window[1][1] - this.margin - this.size_tick - this.text_height,
box[1][1] - this.margin - this.size_tick - this.text_height,
);
ctx.stroke();
ctx.fillText(
text ,
text_position,
window[1][1] - this.margin,
box[1][1] - this.margin,
);
index += 1;
}
return [
[window[0][0] + this.margin + this.size_tick + width, window[0][1]],
[window[1][0] - this.margin , window[1][1] - this.text_height - this.margin - this.size_tick],
[box[0][0] + this.margin + this.size_tick + width, box[0][1]],
[box[1][0] - this.margin , box[1][1] - this.text_height - this.margin - this.size_tick],
];
}
}