Increase Brush Opacity

A forum dedicated to George scripting questions
Post Reply
User avatar
leandro
Posts: 12
Joined: 27 Jul 2010, 00:41
Location: Sao Paulo, Brazil

Increase Brush Opacity

Post by leandro »

Hi There guys,

I was trying to be smart ass and copied a code from someone else to try to make it work as I need it but I can't do it.
Can you guys help me out?

Basically I need a code to decrease or increase incrementally the opacity of the selected brush.
What I have is this:

bOppacity = 10 <- My problem is how to make this not 10 but the actual opacity + 10 or -10
tv_GetActiveTool
Parse Result TT dummy
tv_Cmd TT Opacity bOppacity

tnx,

Leandro
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

Re: Increase Brush Opacity

Post by Mads Juul »

Here you go
Make an action paste this code into embedded george script
you can change delta to for instance -2 if you want a script that decreases the opacity with -2

Code: Select all

Param none
delta = 10

tv_getActiveShape
activeShape=result

tv_setActiveShape activeShape backup
values = result
PARSE values tool restValues

IF CMP(tool,"tv_setactiveshape")==1
PARSE restValues shape mode modeVAL vector vectorA vectorB vectorC vectorC aaliasing aaliasingVAL map_xbrush map_xbrushVAL map_xbrushz map_xbrushzVAL map_gradient map_gradientVAL map_xopacity map_xopacityVAL map_yopacity map_yopacityVAL opacity opacityVAL gap gapVAL expand expandVAL range rangeVAL src srcVAL autopickcolor autopickcolorVAL smooth smoothVAL
IF CMP(opacity,"opacity")==1
newOpacity = opacityVAL+delta
tv_setactiveshape shape 'opacity' newOpacity
END
EXIT
END

IF CMP(tool,"tv_restorebrush")==1
parse restValues mode modeVAL width widthVAL height heightVAL step stepVAL opacity opacityVAL rest
newOpacity = opacityVAL+delta
tv_cmd tool opacity newOpacity
EXIT
END


IF CMP(tool,"tv_setactiveshape")==0

parse restValues one oneVal two twoVal three threeVal four fourVal five fiveVal six sixVal seven sevenVal eight eightVal
newOpacity = fourVal+delta
tv_cmd tool opacity newOpacity
END
Enjoy :-) Mads
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

Re: Increase Brush Opacity

Post by Mads Juul »

I just made a edit so it also works with custom brushes.
it is a little trick because as far as I know the different tools have different george commands. If anyone knows a smarter way to obtain this please let me know
-Mads
User avatar
leandro
Posts: 12
Joined: 27 Jul 2010, 00:41
Location: Sao Paulo, Brazil

Re: Increase Brush Opacity

Post by leandro »

Thanks a lot madsjuul!!
That's exactly what I was looking for. Already use this code to set up my tablet.
I hope this hadn't given you too much work in the end.

Took a look at your site by the way.. Great stuff there... I am studying storyboard myself. So you draw and do programming right?
That's rare talent!

Take care,
;)

Leandro
Svengali
Posts: 1577
Joined: 28 Dec 2006, 10:08

Re: Increase Brush Opacity

Post by Svengali »

Hi Mads,

A few simplifications I think (tv_AreaInit command helps)...

Code: Select all

// OpacityShift.grg

Param None

delta = 10							// set increment or decrement

tv_GetActiveShape
ShapeMode = result					// preserve shapemode

tv_AreaInit Opacity
parse result d AreaOpac				// get opacity setting for shape

tv_GetActiveTool
parse result ToolMode d				// get active tool
tv_cmd ToolMode Opacity
parse result d ToolOpac				// get opacity setting for active tool					

AreaOpac = AreaOpac + Delta			// calculate opacity increment or decrement for fill
ToolOpac = ToolOpac + Delta			// calculate opacity increment or decrement for tool

tv_cmd ToolMode Opacity ToolOpac		// set new opacity for tool
tv_AreaInit Opacity AreaOpac			// set new opacity for fill

tv_SetActiveShape ShapeMode			// restores shapemode (lost whenever retrieving info about tool)

Sven
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

Re: Increase Brush Opacity

Post by Mads Juul »

leandro wrote:Thanks a lot madsjuul!!
That's exactly what I was looking for. Already use this code to set up my tablet.
You'r welcome glad you can use it
leandro wrote: I hope this hadn't given you too much work in the end.
No problem I needed a break from the storyboard I was sitting doing.
leandro wrote: Took a look at your site by the way.. Great stuff there... I am studying storyboard myself. So you draw and do programming right?
That's rare talent!
Thank you.
I really like to draw especially storyboards. But I also have an old interest in mathematics and physics, as a child I dreamed about being an inventor. Later came the thought
about doing animation, So the scripting is me as an 'inventor' :-)
leandro wrote: Take care,
;)
Leandro
You to
-Mads
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

Re: Increase Brush Opacity

Post by Mads Juul »

Svengali wrote:Hi Mads,

A few simplifications I think (tv_AreaInit command helps)...
thank you for sharing Sven I'm not familiar with the tv_areaInit command I will look into it.
It nice to learn from how others approach the same problem.

One thing your script does that wasn't intended by mine(but maybe Leandro better like this?) is that it increases the opacity of the fill and the line tools simultaniously.
MIne was supposed only to increase the current tool.
-mads
User avatar
leandro
Posts: 12
Joined: 27 Jul 2010, 00:41
Location: Sao Paulo, Brazil

Re: Increase Brush Opacity

Post by leandro »

Thank you Sven and Mads,
I got both Scripts saved here in any case.
:)
Post Reply