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