Page 1 of 1

Need Help with Script - For selecting color for a Certain Layer. Svengali or Anybody?

Posted: 13 Apr 2021, 04:44
by TheQuestionMark
I need help with a Script - For selecting color for a Certain Layer.

Code: Select all

// LayerColorPick.grg
// Svengali - April 2013

											// get current layer ID
tv_layergetid = "Color Shape Objects"
iLayerId = result


tv_PicColor												// display pointer for user to pick color of pixel

tv_GetMouse												// get X and Y where user just clicked
parse result MX MY
tv_GetPixelLayer "Color Shape Objects" MX MY							// read the RGBA values for the current layer
parse result PR PG PB PA
//tv_warn "Pr Pg Pb Pa = " PR PG PB PA


IF (PR == 0) && (PG == 0) && (PB == 0) && (PA == 00)	// IF R G B AND A are all zero then the pixel is transparent 
	tv_NOP												// don't do anything leaving original APen color
ELSE
	tv_SetAPen PR PG PB									// otherwise set the APen color
END
It doesn't seems to when I want to target a specific layer. The old code was for current layer. I was wondering if you can make it a certain layer. How about any layers below?

I think TVPaint Command list needs more example. Without any any examples it seems very confusing. What does oLayerId mean? What does iLayerPosition mean? What does "i" and "o" mean? It so confusing without any examples. :cry:

Re: Need Help with Script - For selecting color for a Certain Layer. Svengali or Anybody?

Posted: 13 Apr 2021, 05:13
by Svengali
For specifics about GEORGE syntax and what the commands mean (stuff like i and o [input,output variables], etc.) can be found at the beginning of "the GEORGE Instructions & Commands Documentation List".

A very good reference on Scripting with GEORGE can be found on the "George - TVPaintWiki Page".

Also, Mads Juul kindly shares many of his scripting examples which are cut&paste downloadable on his "Mads Juul's TVPaintWiki Page".

sven

Re: Need Help with Script - For selecting color for a Certain Layer. Svengali or Anybody?

Posted: 13 Apr 2021, 05:28
by TheQuestionMark
Svengali wrote: 13 Apr 2021, 05:13 For specifics about GEORGE syntax and what the commands mean (stuff like i and o [input,output variables], etc.) can be found at the beginning of "the GEORGE Instructions & Commands Documentation List".

A very good reference on Scripting with GEORGE can be found on the "George - TVPaintWiki Page".

Also, Mads Juul kindly shares many of his scripting examples which are cut&paste downloadable on his "Mads Juul's TVPaintWiki Page".

sven
Mad Juul seems very confusing.

What about the "o" what does that mean?

And what's wrong with my code to select a specific layer. I don't get it why it doesn't work. It keep selecting the current layer, not the layer I want to pick color.

Re: Need Help with Script - For selecting color for a Certain Layer. Svengali or Anybody?

Posted: 13 Apr 2021, 06:20
by Svengali
o = output?

Re: Need Help with Script - For selecting color for a Certain Layer. Svengali or Anybody?

Posted: 13 Apr 2021, 06:34
by TheQuestionMark
Svengali wrote: 13 Apr 2021, 06:20o = output?
But what does output mean?


---

Is this how you type it? tv_GetPixelLayer "Color Shape Objects" MX MY ? I just want a certain layer and not current layer.

Re: Need Help with Script - For selecting color for a Certain Layer. Svengali or Anybody?

Posted: 13 Apr 2021, 14:35
by Svengali
Input is data in the form of one or more variables you assign using: variable-name+equal-sign+value, for instance the X and Y position of a pixel.
Output is data you get back from a command and is contained in the parse-able "return" variable following a command.

Example, you want to know what color is at pixel 0,0 on a specific layer, 3 for example:

tv_LayercurrentID // get current layer Identifying number
OriginalLayerID = result // store it in variable
LayerPosition = 3 // store position for layer in question
tv_LayerGetID LayerPosition // get layer for the layer in question (layer 3)
NewLayerID = result // store Identifying layer for layer in question (layer 3)
tv_LayerSet NewLayerID // move temporarily to layer in question (layer 3)
X = 0 // horizontal position
Y = 0 // vertical position
tv_GetPixel X Y // get the color at pixel X,Y
parse result r g b a // store 4 variables
tv_warn "red = " r " green = " g " blue = " b " alpha = " a // show the values for red, green, blue, alpha components
tv_LayerSet OriginalLayerID // return to the original layer

As to problems in your script, I'll pass on debugging that.

I have enough trouble debugging my own scripts where I know the questionable assumptions or ill-informed thinking behind the sequence of commands I choose to use and take personal responsibility for fixing the mistakes I've made.

sven

Re: Need Help with Script - For selecting color for a Certain Layer. Svengali or Anybody?

Posted: 13 Apr 2021, 21:23
by TheQuestionMark
Svengali wrote: 13 Apr 2021, 14:35 Input is data in the form of one or more variables you assign using: variable-name+equal-sign+value, for instance the X and Y position of a pixel.
Output is data you get back from a command and is contained in the parse-able "return" variable following a command.

Example, you want to know what color is at pixel 0,0 on a specific layer, 3 for example:

tv_LayercurrentID // get current layer Identifying number
OriginalLayerID = result // store it in variable
LayerPosition = 3 // store position for layer in question
tv_LayerGetID LayerPosition // get layer for the layer in question (layer 3)
NewLayerID = result // store Identifying layer for layer in question (layer 3)
tv_LayerSet NewLayerID // move temporarily to layer in question (layer 3)
X = 0 // horizontal position
Y = 0 // vertical position
tv_GetPixel X Y // get the color at pixel X,Y
parse result r g b a // store 4 variables
tv_warn "red = " r " green = " g " blue = " b " alpha = " a // show the values for red, green, blue, alpha components
tv_LayerSet OriginalLayerID // return to the original layer

As to problems in your script, I'll pass on debugging that.

I have enough trouble debugging my own scripts where I know the questionable assumptions or ill-informed thinking behind the sequence of commands I choose to use and take personal responsibility for fixing the mistakes I've made.

sven
Thank you! It really help!