Skip to content

context2D closePath on arc closes path to centre x point and not to drawn line start #3293

Closed
@chinanwu

Description

@chinanwu

I have read and understood the contribution guidelines.

Version: ^2.4.0

The closePath() the context2D seems to be closing on the centre x point of the arc rather than the actual drawn arc line.

Simple example (This can be copied and pasted into the playground https://raw.githack.com/MrRio/jsPDF/master/#):

var doc = new jsPDF();
const canvas = doc.canvas;
const ctx = canvas.getContext('2d')
ctx.beginPath();
ctx.arc(80, 80, 65, 0, Math.PI);
ctx.closePath();
ctx.lineWidth = 6;
ctx.stroke();

Which is grabbed from this page: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/closePath#closing_just_one_sub-path (You can see the correct behaviour here)
template

Slightly more complex example (can also be copied into the playground):

var doc = new jsPDF();
const canvas = doc.canvas;
const ctx = canvas.getContext('2d')
ctx.beginPath();
ctx.arc(
    106,
    130,
    100,
    -1.5707963267948966,
    -0.3141592653589793,
    false);
ctx.arc(
    106,
    130,
    62.5,
    -0.3141592653589793, 
    -1.5707963267948966, 
    true);
ctx.closePath();
ctx.stroke();

template-2

Here is the jsfiddle page for the expected behaviour: https://jsfiddle.net/p7vmqu6r/1/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions