Skip to content

Commit

Permalink
Merge pull request #1440 from rvilarl/fix/1439
Browse files Browse the repository at this point in the history
fix colon in tuplets and dot in debug bars
  • Loading branch information
rvilarl authored Sep 26, 2022
2 parents 7fb9554 + f01e0ba commit bded017
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/rendercontext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function drawDot(ctx: RenderContext, x: number, y: number, color = '#F55'

// draw a circle
ctx.beginPath();
ctx.arc(x, y, 3, 0, Math.PI * 2, true);
ctx.arc(x, y, 3, 0, Math.PI * 2, false);
ctx.closePath();
ctx.fill();
ctx.restore();
Expand Down
15 changes: 8 additions & 7 deletions src/svgcontext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,14 @@ export class SVGContext extends RenderContext {
const x0 = x + radius * Math.cos(startAngle);
const y0 = y + radius * Math.sin(startAngle);

// Handle the edge case where arc length is greater than or equal to
// the circle's circumference:
// https://html.spec.whatwg.org/multipage/canvas.html#ellipse-method-steps
// svg behavior different from canvas. Don't normalize angles if
// we are drawing a circle because they both normalize to 0
const tmpStartTest = normalizeAngle(startAngle);
const tmpEndTest = normalizeAngle(endAngle);
if (
(!counterclockwise && endAngle - startAngle >= TWO_PI) ||
(counterclockwise && startAngle - endAngle >= TWO_PI)
(counterclockwise && startAngle - endAngle >= TWO_PI) ||
tmpStartTest === tmpEndTest
) {
const x1 = x + radius * Math.cos(startAngle + Math.PI);
const y1 = y + radius * Math.sin(startAngle + Math.PI);
Expand All @@ -461,9 +463,8 @@ export class SVGContext extends RenderContext {
const x1 = x + radius * Math.cos(endAngle);
const y1 = y + radius * Math.sin(endAngle);

startAngle = normalizeAngle(startAngle);
endAngle = normalizeAngle(endAngle);

startAngle = tmpStartTest;
endAngle = tmpEndTest;
let large: boolean;
if (Math.abs(endAngle - startAngle) < Math.PI) {
large = counterclockwise;
Expand Down
4 changes: 2 additions & 2 deletions src/tuplet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,11 @@ export class Tuplet extends Element {
const colon_x = notation_start_x + x_offset + this.point * 0.16;
const colon_radius = this.point * 0.06;
ctx.beginPath();
ctx.arc(colon_x, this.y_pos - this.point * 0.08, colon_radius, 0, Math.PI * 2, true);
ctx.arc(colon_x, this.y_pos - this.point * 0.08, colon_radius, 0, Math.PI * 2, false);
ctx.closePath();
ctx.fill();
ctx.beginPath();
ctx.arc(colon_x, this.y_pos + this.point * 0.12, colon_radius, 0, Math.PI * 2, true);
ctx.arc(colon_x, this.y_pos + this.point * 0.12, colon_radius, 0, Math.PI * 2, false);
ctx.closePath();
ctx.fill();
x_offset += this.point * 0.32;
Expand Down

0 comments on commit bded017

Please sign in to comment.