Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path is distorted #163

Open
doublex opened this issue Apr 17, 2023 · 0 comments
Open

Path is distorted #163

doublex opened this issue Apr 17, 2023 · 0 comments

Comments

@doublex
Copy link

doublex commented Apr 17, 2023

Expected image:

r

Actual image:

out

Two issues:

  • Second path is missing
  • The top-most pixels are not painted

Steps To Reproduce

import * as PImage from "pureimage"
import * as fs from 'fs'

// make image
const img1 = PImage.make(100, 100)
const ctx = img1.getContext('2d');
ctx.clearRect(0, 0, 100,100)

// <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><path d="M0 0 H40  V100 H0 V60 H20 V40 H0z M60 0 H100 V40 H80 V60 H100 V100 H60z"></path></svg>
// http://www.professorcloud.com/svg-to-canvas/
ctx.fillStyle = "#0000ff";
ctx.beginPath();
ctx.moveTo(0,0);
ctx.lineTo(40,0);
ctx.lineTo(40,100);
ctx.lineTo(0,100);
ctx.lineTo(0,60);
ctx.lineTo(20,60);
ctx.lineTo(20,40);
ctx.lineTo(0,40);
ctx.closePath();
ctx.moveTo(60,0);
ctx.lineTo(100,0);
ctx.lineTo(100,40);
ctx.lineTo(80,40);
ctx.lineTo(80,60);
ctx.lineTo(100,60);
ctx.lineTo(100,100);
ctx.lineTo(60,100);
ctx.closePath();
ctx.fill();
ctx.stroke();

PImage.encodePNGToStream(img1, fs.createWriteStream('out.png'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant