Page 1 of 1

Scripting Gradient Property "via"

Posted: Wed Oct 21, 2015 3:58 pm
by ctflatt
Hello, everyone!

I am trying to script a gradient fill on a templateObject from top to bottom instead of side to side (default).

I understand that this is controlled using the "via" property based on the dictionary entry, but have no idea what " a coordinate specifying the intermediate point of the gradient..." refers to. What is the coordinate representing and how is written?

If someone could provide an example, I would really appreciate it.

Many thanks!

Re: Scripting Gradient Property "via"

Posted: Wed Oct 21, 2015 4:51 pm
by dunbarx
Hi.

I don't use gradients at all, but a reading of the dictionary entry tells me that (maybe?) if you specify the "linear", "from" and "to" parameters of the properties array, you might be able to orient the gradient as you wish. This property looks like it needs practice and experimentation.

Craig Newman

Re: Scripting Gradient Property "via"

Posted: Wed Oct 21, 2015 4:58 pm
by ctflatt
Thanks, Craig, but just setting the "from" and "to" on a "linear" fills the object from side to side.

I have experimented with it, but am getting gradients filling every direction but what I want (top to bottom).

If anyone can help explain what the via coordinates represent and how they're written, I could reference them dynamically in my script based on other object properties (topLeft, bottomLeft...).

Help. :)

Re: Scripting Gradient Property "via"

Posted: Wed Oct 21, 2015 5:24 pm
by dunbarx
Hi.

So if the two coordinates are at the top and bottom of the graphic, perhaps with the same "x" value, the gradient still fills from left to right?

Craig

Re: Scripting Gradient Property "via"

Posted: Wed Oct 21, 2015 6:11 pm
by SparkOut
There's a great thread here http://forums.livecode.com/viewtopic.ph ... 8&start=30 (read the whole thing) with an evolution of gradient tools which you can pick apart to find the details you need.

Re: Scripting Gradient Property "via"

Posted: Wed Oct 21, 2015 6:34 pm
by bn
Hi Todd,

nice to see you again... :)


have a look at this post where I reference a tool to explore gradients made by Scott Rossi: gradientexplorer.livecode
http://forums.livecode.com/phpBB2/viewt ... 669#p16669

I just tried and the link is still alive.

It makes it easy to understand what happens in gradients, also when setting the from, to and via.

Kind regards
Bernd

Re: Scripting Gradient Property "via"

Posted: Fri Oct 23, 2015 9:57 am
by bn
Hi Todd,

I reread your original posting today and realized that you asked for an example for the templateGraphic.

Here it is for a linear fillgradient running from top to bottom done in the templateGraphic.

See comments in the script and feel free to ask if unclear.

Kind regards
Bernd

Re: Scripting Gradient Property "via"

Posted: Fri Oct 23, 2015 7:42 pm
by ctflatt
Bernd,

Thank you so much for the solution to my problem!

I have been away from the forums for a while, but coding nonetheless.

Hope you've been doing well.

Thanks, again.

Todd