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

Add shadow options to image properties #4

Merged
merged 6 commits into from
Aug 4, 2022

Conversation

seekuehe
Copy link

@seekuehe seekuehe commented Aug 4, 2022

This will allow us to export preset shadows on image blocks.
Required for #44359

@seekuehe seekuehe requested a review from sam-pitch August 4, 2022 10:59
Copy link

@sam-pitch sam-pitch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running the following JS code in the sandbox produced the following presentation.

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

slide.addImage({
  x: 1,
  y: 1,
  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: 50,
    color: "FF0000",
    offset: 100,
    opacity: 0.5,
  },
});

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

Screenshot from 2022-08-04 13-04-52

I will note that while I was writing in the sandbox I made some errors which caused the shadow to not render. (I didn't wrap the shadow props in a shadow object, and I put a # at the beginning of the color string) It's good that the presentation could still render but there wasn't any feedback I had fed it bad data.

@seekuehe seekuehe force-pushed the pitch-io/add-shadow-opts-to-image branch 2 times, most recently from 11353f5 to 99102ef Compare August 4, 2022 11:23
Copy link

@pastafari pastafari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@seekuehe
Copy link
Author

seekuehe commented Aug 4, 2022

I added a validation in the correctShadowOptions function that will remove the extra # and send a warning on the console.

@seekuehe seekuehe force-pushed the pitch-io/add-shadow-opts-to-image branch from 3dd9ae5 to e5e8bfa Compare August 4, 2022 12:09
@seekuehe seekuehe requested a review from tjinauyeung August 4, 2022 12:22
@seekuehe seekuehe merged commit 3bdb364 into pitch-main Aug 4, 2022
@seekuehe seekuehe deleted the pitch-io/add-shadow-opts-to-image branch August 5, 2022 12:49
@seekuehe seekuehe restored the pitch-io/add-shadow-opts-to-image branch August 10, 2022 12:41
@seekuehe seekuehe deleted the pitch-io/add-shadow-opts-to-image branch August 10, 2022 13:51
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.

4 participants