Scripting Gradient Property "via"

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
ctflatt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 243
Joined: Sun Dec 06, 2009 12:24 am
Contact:

Scripting Gradient Property "via"

Post by ctflatt » Wed Oct 21, 2015 3:58 pm

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!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Scripting Gradient Property "via"

Post by dunbarx » Wed Oct 21, 2015 4:51 pm

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

ctflatt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 243
Joined: Sun Dec 06, 2009 12:24 am
Contact:

Re: Scripting Gradient Property "via"

Post by ctflatt » Wed Oct 21, 2015 4:58 pm

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. :)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Scripting Gradient Property "via"

Post by dunbarx » Wed Oct 21, 2015 5:24 pm

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

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: Scripting Gradient Property "via"

Post by SparkOut » Wed Oct 21, 2015 6:11 pm

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.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Scripting Gradient Property "via"

Post by bn » Wed Oct 21, 2015 6:34 pm

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

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Scripting Gradient Property "via"

Post by bn » Fri Oct 23, 2015 9:57 am

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
Attachments
fillgradientGraphic.livecode.zip
(1.87 KiB) Downloaded 253 times

ctflatt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 243
Joined: Sun Dec 06, 2009 12:24 am
Contact:

Re: Scripting Gradient Property "via"

Post by ctflatt » Fri Oct 23, 2015 7:42 pm

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

Post Reply