PptxGenJS icon indicating copy to clipboard operation
PptxGenJS copied to clipboard

How to add gradient fill to shapes?

Open sangramjagtap opened this issue 8 years ago • 24 comments

This is sample slide which I'm trying to export using PptxGenJS

new common slides

How to add gradient fill to shapes?

sangramjagtap avatar Jun 15 '17 09:06 sangramjagtap

Hi @sangramjagtap ,

Thanks for the question/issue.

The library does support gradients as of yet. I've added this to the enhancement list.

gitbrent avatar Jun 21 '17 02:06 gitbrent

Thanks for the clarification.

On Wed, Jun 21, 2017 at 8:24 AM, Brent Ely [email protected] wrote:

Hi @sangramjagtap https://github.com/sangramjagtap ,

Thanks for the question/issue.

The library does support gradients as of yet. I've added this to the enhancement list.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/gitbrent/PptxGenJS/issues/102#issuecomment-309948530, or mute the thread https://github.com/notifications/unsubscribe-auth/ARCCHKHgUd-ng9TKjjU6ZLkW5dEaB6miks5sGIXngaJpZM4N69Ru .

-- Thanks & Regards, Sangram M. Jagtap

Email: [email protected] [email protected] Phone: +91 844 644 6043 Skype: sangramjagtap7

sangramjagtap avatar Jun 21 '17 05:06 sangramjagtap

fyi - I've implemented this. I'll open up a PR when I get a chance.

Here's an example showing the fill on a slide master as the background.

    pptx.defineSlideMaster( {
	title: 'TITLE_SLIDE',
	bkgd:   { fill: {type:'gradient', stops: [{ pos: 0, color:'C1F15E' }, { pos: 62, color:'90BA3F' }, { pos: 100, color:'7FA03E'}],
			 linearAngle: 90, linearScaled: false}},
	objects: [
	    { 'image':{x:0,y:0,w:"100%", h:"100%", path: 'bee-background.png',
		       sizing: {type: 'cover', x:0, y:0, w:"100%", h:"100%"}}},
	    { 'rect': {x:"50%", y:0, w:'41%', h:"90%", fill:'FFFFFF',
		       line:'74A50F', lineSize:1}},
	    { 'rect': {x:"51%", y:0, w:'39%', h:"30%", fill:'71685A',
		       line:'000000', lineSize:0}},
	    { 'line': {x:"51%", y:"88%", w:'39%',line:'94C601',
		       lineSize:6}},
	    { 'image': { x:"70%", y:"60%", w:2.1, h:2.1, path:'bee-right.png' } }
	]
    });

The way it's implemented, it works on both slide masters and also slide shapes that currently support the 'fill' option, e.g. images and text.

The way the background is currently implemented in slide masters means it would be awfully hard to have both an image and also a fill. That threw me for a while until I realized basically there is no need to specify a background image - just specify fill as the background and then add an image that fills the entire slide.

Here is the slide created from the above: image

pstoll avatar Mar 10 '18 01:03 pstoll

@gitbrent you open to a PR on this? if so, anything you're looking for in particular in a PR?

pstoll avatar Mar 10 '18 01:03 pstoll

Hi @pstoll,

Absolutely, PR's are always welcome.

Content-wise:

  • The feature added using the same style the current code is in
  • A demo of the feature added to pptxgenjs-demo.js
  • A blurb showing the options/sample in the README

gitbrent avatar Mar 11 '18 05:03 gitbrent

Hi @pstoll !

You said you implemented this and wanted to open PR. Unfortunately still no PR here 😢.

Do you want some help ? We could try to open the PR with you if you want because we need this feature too 😄

Have a great day !

fleebzz avatar Dec 05 '18 15:12 fleebzz

Any news about that ?

jchambondynadmic avatar Jun 25 '19 15:06 jchambondynadmic

Sorry, lost track of this. Let me see if I can dig this up.

pstoll avatar Jun 25 '19 16:06 pstoll

Thanks, and so ? :D

jchambondynadmic avatar Jul 19 '19 15:07 jchambondynadmic

Hi @pstoll, Do you have any great news about a PR for gradient background ?

abaroiller avatar Aug 20 '19 15:08 abaroiller

Hello @pstoll, Any update ? This would be helpful for my app :)

Ouisticram avatar Sep 22 '19 09:09 Ouisticram

The same, need to set gradient to slides

Alex-Golovin avatar Oct 05 '19 16:10 Alex-Golovin

Hi All,

It appears Perry hasn't been on GitHub for awhile and the clone he made of the repo was never patched for gradient support.

As the community is interested in this, i've tagged it for triage so i can scope what needs to be coded to support this functionality. I'll circle back after 3.0 is released (soon!).

gitbrent avatar Oct 08 '19 03:10 gitbrent

Hi, Are there any news? Gradient is still not working :( Thanks

hawrancz99 avatar Feb 06 '20 10:02 hawrancz99

I have an almost complete gradient implementation that I'll submit a PR for. It's functional and supports linear, radial, rectangular, and path gradients. Still cleaning up some of the code before I create a PR.

ReimaFrgos avatar Jul 20 '20 03:07 ReimaFrgos

@ReimaFrgos hey, any news on this ? I saw your branch https://github.com/ReimaFrgos/PptxGenJS/tree/92+103-AddGradientSupport there is nothing on it yet, do you need a hand ?

hilnius avatar Jan 19 '21 08:01 hilnius

@ReimaFrgos @hilnius I have a partial solution, I would like to help with the issue

jencii avatar Jan 19 '21 09:01 jencii

Hello, this is my first github post so please excuse me if I break protocol. Unless I am mistaken the gradient feature still does not seem to be implemented. Is it still being worked on and or investigated?

Thank you.

veritas-k avatar Feb 10 '22 17:02 veritas-k

Hi! @gitbrent @ReimaFrgos do you guys still want to release this feature? If so I'll definitely wait on it, if not I'll work around it!

Thanks :)

JesseRiemens avatar Dec 26 '22 16:12 JesseRiemens

I've pushed this PR if people are interested. I have only done one implementation in the demo suite and haven't modified the docs. If anyone want's to contribute to the PR for those then please go ahead. https://github.com/gitbrent/PptxGenJS/pull/1295

This could potentially be used to add gradients to slide backgrounds and object outlines as well.

sambauers avatar Oct 19 '23 04:10 sambauers