Skip to content

Commit

Permalink
Fix field refactor regressions (see #139)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbrott committed Sep 9, 2023
1 parent a8884a5 commit 089c6de
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions FtcDashboard/dash/src/components/views/FieldView/Field.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export default class Field {
this.ctx.setTransform(pageTransform);
}

this.ctx.translate(op.x + op.pivotX, op.y + op.pivotY);
this.ctx.translate(op.x, op.y);

// Flipped to match text behavior.
if (!op.usePageFrame) {
Expand Down Expand Up @@ -292,9 +292,15 @@ export default class Field {
this.ctx.setTransform(pageTransform);
}

this.ctx.translate(op.x + op.pivotX, op.y + op.pivotY);
this.ctx.translate(op.x, op.y);

// Flipped to match text behavior.
if (!op.usePageFrame) {
this.ctx.scale(1, -1);
}

this.ctx.rotate(op.theta);
this.ctx.translate(-op.pivotX, -op.pivotY);
this.ctx.translate(op.X, op.Y);

this.ctx.strokeStyle = this.options.gridLineColor;

Expand All @@ -308,21 +314,21 @@ export default class Field {
this.options.gridLineWidth / (scalingY * devicePixelRatio);

for (let i = 0; i < op.numTicksX; i++) {
const lineX = horSpacing * i;
const lineX = -op.pivotX + horSpacing * i;
this.ctx.beginPath();
this.ctx.fineMoveTo(lineX, 0);
this.ctx.fineLineTo(lineX, op.height);
this.ctx.fineMoveTo(lineX, -op.pivotY );
this.ctx.fineLineTo(lineX, -op.pivotY + op.height);
this.ctx.stroke();
}

this.ctx.lineWidth =
this.options.gridLineWidth / (scalingX * devicePixelRatio);

for (let i = 0; i < op.numTicksY; i++) {
const lineY = vertSpacing * i;
const lineY = -op.pivotY + vertSpacing * i;
this.ctx.beginPath();
this.ctx.fineMoveTo(0, lineY);
this.ctx.fineLineTo(op.width, lineY);
this.ctx.fineMoveTo(-op.pivotX, lineY);
this.ctx.fineLineTo(-op.pivotX + op.width, lineY);
this.ctx.stroke();
}

Expand Down

0 comments on commit 089c6de

Please sign in to comment.