Page 1 of 1

What is the right way to use GradientImage?

Posted: 2019-12-04T14:46:41-07:00
by gribuser
I know that there is read("radial-gradient:#202020FF-#00000000") hack, and I know I can import some internal private headers to do some hacking over the MagicWand to inject something somewhere and get it over with (and forget asap).
But may be there is a sane, conventional way to do the trick? That's what I do now (it is not working as you would expect it to, it draws circles):

Code: Select all

	Magick::Image ObjectPict({ ObjectSizeX, ObjectSizeX }, BaseColor);
	
	MagickCore::_StopInfo* GradientStops = new MagickCore::_StopInfo[3];
	GradientStops[0].color = Magick::Color("#202020FF");
	GradientStops[0].offset = 0;

	GradientStops[1].color = Magick::Color("#101010FF");
	GradientStops[1].offset = ObjectSizeX / 3;

	GradientStops[2].color = Magick::Color("#000000FF");
	GradientStops[2].offset = ObjectSizeX;

	MagickCore::GradientImage(ObjectPict.image(), MagickCore::RadialGradient, MagickCore::PadSpread, GradientStops, 3, nullptr);

Re: What is the right way to use GradientImage?

Posted: 2019-12-04T16:11:55-07:00
by snibgo
"offset" should be in the range 0.0 to 1.0.

Re: What is the right way to use GradientImage?

Posted: 2019-12-04T20:27:35-07:00
by gribuser
Yeah, that works, thanks.