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

Fix ShadingPattern issues + eslint #3468

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

Trisard
Copy link

@Trisard Trisard commented Aug 17, 2022

Bugs fixed

  • Patterns was unable to work with all functions who use fillWithPattern.
    I rollback on that but fillWithPattern should take pattern key or pattern object in parameter and not patternData. All datas are already in patterns.
  • Shading patterns was not using scaling for its coordinates.
  • fillWithPattern function was writing matrix every time for shading patterns but the parameter is optional.

Tested with below code

import { jsPDF } from "../../../ProjetJS/jsPDF/dist/jspdf.node.min.js";

const doc = new jsPDF();

const pattern = doc.ShadingPattern(
    "axial",
    [10, 100, 100, 10],
    [
        { offset: 0, color: [255, 0, 0] },
        { offset: 0.3, color: [255, 255, 0] },
        { offset: 0.5, color: [0, 255, 0] },
        { offset: 0.7, color: [0, 255, 255] },
        { offset: 1, color: [0, 0, 255] }
    ]
);

doc.advancedAPI(doc => {
    doc.addShadingPattern("testPattern", pattern);
});

doc.path([
    { op: "m", c: [10, 10] },
    { op: "l", c: [100, 10] },
    { op: "l", c: [100, 10] },
    { op: "l", c: [100, 100] },
    { op: "l", c: [10, 100] }
]);

doc.fill({key:"testPattern"});

doc.save();

Result

image

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

Successfully merging this pull request may close these issues.

None yet

1 participant