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

Improve the Pattern-detection in CanvasGraphics.stroke #12591

Merged
merged 1 commit into from
Nov 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/display/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -1350,11 +1350,7 @@ const CanvasGraphics = (function CanvasGraphicsClosure() {
// stroking alpha.
ctx.globalAlpha = this.current.strokeAlpha;
if (this.contentVisible) {
if (
strokeColor &&
strokeColor.hasOwnProperty("type") &&
strokeColor.type === "Pattern"
) {
if (typeof strokeColor === "object" && strokeColor?.getPattern) {
timvandermeij marked this conversation as resolved.
Show resolved Hide resolved
// for patterns, we transform to pattern space, calculate
// the pattern, call stroke, and restore to user space
ctx.save();
Expand Down
4 changes: 0 additions & 4 deletions src/display/pattern_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ ShadingIRs.RadialAxial = {
const r0 = raw[6];
const r1 = raw[7];
return {
type: "Pattern",
getPattern: function RadialAxial_getPattern(ctx) {
applyBoundingBox(ctx, bbox);
let grad;
Expand Down Expand Up @@ -340,7 +339,6 @@ ShadingIRs.Mesh = {
const bbox = raw[7];
const background = raw[8];
return {
type: "Pattern",
getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
applyBoundingBox(ctx, bbox);
let scale;
Expand Down Expand Up @@ -390,7 +388,6 @@ ShadingIRs.Mesh = {
ShadingIRs.Dummy = {
fromIR: function Dummy_fromIR() {
return {
type: "Pattern",
getPattern: function Dummy_fromIR_getPattern() {
return "hotpink";
},
Expand Down Expand Up @@ -429,7 +426,6 @@ const TilingPattern = (function TilingPatternClosure() {
this.color = color;
this.canvasGraphicsFactory = canvasGraphicsFactory;
this.baseTransform = baseTransform;
this.type = "Pattern";
this.ctx = ctx;
}

Expand Down