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 shadow types: inner and none #10

Merged
merged 2 commits into from
Aug 11, 2022
Merged

Fix shadow types: inner and none #10

merged 2 commits into from
Aug 11, 2022

Conversation

seekuehe
Copy link

@seekuehe seekuehe commented Aug 11, 2022

This PR fixes a previously undetected bug for shadow types none and inner which images and shapes.
Since Pitch only uses the type outer for images, the bug did not break export.

Code Snippet for the Sandbox

let pptx = new PptxGenJS();
let slide = pptx.addSlide();

slide.addImage({
  x: 1,
  y: 2,
  path: "https://images.unsplash.com/photo-1506744038136-46273834b3fb?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwyMTIyMnwwfDF8c2VhcmNofDJ8fGxhbmRzY2FwZXxlbnwwfHx8fDE2NTg5MzE0MDM&ixlib=rb-1.2.1&q=80&w=1080",
  shadow: {
    type: "none",
    angle: 90,
    blur: 10,
    color: "000000",
    offset: 4,
    opacity: 1
  }
});

slide.addImage({
  x: 3,
  y: 2,
  path: "https://images.unsplash.com/photo-1506744038136-46273834b3fb?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwyMTIyMnwwfDF8c2VhcmNofDJ8fGxhbmRzY2FwZXxlbnwwfHx8fDE2NTg5MzE0MDM&ixlib=rb-1.2.1&q=80&w=1080",
  shadow: {
    type: "inner",
    angle: 90,
    blur: 10,
    color: "000000",
    offset: 4,
    opacity: 1
  }
});

slide.addImage({
  x: 5,
  y: 2,
  path: "https://images.unsplash.com/photo-1506744038136-46273834b3fb?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwyMTIyMnwwfDF8c2VhcmNofDJ8fGxhbmRzY2FwZXxlbnwwfHx8fDE2NTg5MzE0MDM&ixlib=rb-1.2.1&q=80&w=1080",
  shadow: {
    type: "outer",
    angle: 90,
    blur: 10,
    color: "000000",
    offset: 4,
    opacity: 1
  }
});

// When type is not provided, defaults to `outer`
slide.addImage({
  x: 7,
  y: 2,
  path: "https://images.unsplash.com/photo-1506744038136-46273834b3fb?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwyMTIyMnwwfDF8c2VhcmNofDJ8fGxhbmRzY2FwZXxlbnwwfHx8fDE2NTg5MzE0MDM&ixlib=rb-1.2.1&q=80&w=1080",
  shadow: {
    angle: 90,
    blur: 10,
    color: "000000",
    offset: 4,
    opacity: 1
  }
});

slide.addShape(pptx.ShapeType.rect, { fill: { color: "FF0000" }, x: 1, y: 0.5, shadow: {
    type: "none",
    angle: 90,
    blur: 10,
    color: "000000",
    offset: 4,
    opacity: 1
  } });

  slide.addShape(pptx.ShapeType.rect, { fill: { color: "FF0000" }, x: 3, y: 0.5, shadow: {
    type: "inner",
    angle: 90,
    blur: 10,
    color: "000000",
    offset: 4,
    opacity: 1
  } });

  slide.addShape(pptx.ShapeType.rect, { fill: { color: "FF0000" }, x: 5, y: 0.5, shadow: {
    type: "outer",
    angle: 90,
    blur: 10,
    color: "000000",
    offset: 4,
    opacity: 1
  } });

// When type is not provided, defaults to `outer`
  slide.addShape(pptx.ShapeType.rect, { fill: { color: "FF0000" }, x: 7, y: 0.5, shadow: {
    angle: 90,
    blur: 10,
    color: "000000",
    offset: 4,
    opacity: 1
  } });

pptx.writeFile({ fileName: "PptxGenJS-Shadows.pptx" });

@seekuehe seekuehe self-assigned this Aug 11, 2022
@seekuehe seekuehe merged commit 11cc1f7 into pitch-main Aug 11, 2022
@seekuehe seekuehe deleted the fix-shadow branch August 11, 2022 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants