JScript Operation - RealWorld forums

Log-in or register.

JScript Operation

Getting the Active Primary Color
jediYellow
on August 7th 2016

Using RW API, how can I get the foreground color?

I found the mention of the Context object, but I guess I need a code example ... or more of a hint.

Vlasta
on August 7th 2016

That is kind of complicated, because the concept of a foreground/background colors was abandoned in later versions of RW apps in favor of a "fill style" and eventually "outline style". Some fill styles use no colors, other use multiple, so it is unclear what a foreground color is.

That said, you can access the state of the "SOLID" fill style in a raster editor like this:

Context.GetState("RASTEREDITSTATESOLID")

And you may get for example this result as a string:

F2F9400F-BA55-4BE2-A6A4-7359C100D0C3:0.107361,0.402811,0,1

The numbers behind the : represent RGBA values of the current solid fill color in ranges 0-1.

Vector editor has a different active fill style, which you can access via:

Context.GetState("VECTOREDITSTATESOLID")
Page views: 492       Posts: 2      
Select background
What about ICL files?
Vista & Win 7 icons