You're becoming a scripter, Nathan! Glad you were able to get what you
wanted. Suz
Nathan Gutman wrote:
>> Hell All,
>> We had a discussion about scripting flood filling a selection which I
>> started.
>> Thanks to a generous contribution of ideas from this wonderful group
>> and a script by SuzShook I finally got what I was originally looking
>> for. What I actually wanted was to emulate Photoshop's Stroke
>> Selection. Being a complete novice I succeeded to modify Suz's
>> script to stroke a selection with the foreground color and the user
>> determining the width of the stroke line.
>> The resulting script is attached.
>> Why all this?
>> I need sometimes to single out a face in a group. So I make a round
>> selection around the face, brighten it a bit and stroke it making the
>> desired face stand out.
>> Thank you all for getting me going.
>> Nathan
>>
>
>
>
> from JascApp import *
>
> def ScriptProperties():
> return {
> 'Author': u'SuzShook',
> 'Copyright': u'2008 SuzShook',
> 'Description': u'Fill any selection',
> 'Host': u'Paint Shop Pro',
> 'Host Version': u''
> }
>
> def Do(Environment):
>
> ###
> ### This script will fill any (and all) selection(s) in an image
> ### using the Foreground Material. Bind it to an icon and
> ### assign a shortcut key to imitate Photoshop's Edit...Fill
> Selection ### command
> ### This script uses Gary Barton's FindSelectionPoint function -
> ### thanks, Gary!
> ###
>
> # ReturnImageInfo
> Info = App.Do( Environment, 'ReturnImageInfo')
>
> if Info['Selection'] == 0:
> print '\n There is no selection! Try again!\n'
> App.Do(Environment, 'MsgBox', {
> 'Buttons': App.Constants.MsgButtons.OK,
> 'Icon': App.Constants.MsgIcons.Stop,
> 'Text': '\n There is no selection! Try again! ',
> })
> return
> #### Nathanâ?Ts addition
> # Select Selection Borders
> App.Do( Environment, 'SelectSelectionBorders', {
> 'Antialias': True,
> 'BordersType': App.Constants.BordersType.BothSide,
> 'BorderWidth': 5,
> 'GeneralSettings': {
> 'ExecutionMode': App.Constants.ExecutionMode.Default,
> 'AutoActionMode': App.Constants.AutoActionMode.Match,
> 'Version': ((10,0,3),1)
> }
> })
> ####....End of Nathanâ?Ts addition
>
> # Find a point within the selection
> selectionPoint = FindSelectionPoint(Environment)
>
> # Use the selectionPoint variable in the call to Fill
> App.Do(Environment, 'Fill', {
> 'BlendMode': App.Constants.BlendMode.Normal,
> 'MatchMode': App.Constants.MatchMode.None,
> 'Material': None,
> 'UseForground': App.Constants.Boolean.true,
> 'Opacity': 100,
> 'Point': selectionPoint,
> 'SampleMerged': App.Constants.Boolean.false,
> 'Tolerance': 200,
> 'GeneralSettings': {
> 'ExecutionMode': App.Constants.ExecutionMode.Default,
> 'AutoActionMode': App.Constants.AutoActionMode.Match
> }
> })
> # Nathanâ?Ts Selection none here
>
> # SelectNone
> App.Do( Environment, 'SelectNone', {
> 'GeneralSettings': {
> 'ExecutionMode': App.Constants.ExecutionMode.Default,
> 'AutoActionMode': App.Constants.AutoActionMode.Match,
> 'Version': ((10,0,3),1)
> }
> })
>
>
> # ----- FindSelectionPoint Start -----
> # Author: Gary Barton
> # Revision: 0.1
> # Home: http://pixelnook.home.comcast.net
>
> def FindSelectionPoint(Environment):
> # Find bounds of selection
> result = App.Do(Environment, 'GetRasterSelectionRect', {})
> xoff, yoff = result['Rect'][0]
> width = result['Rect'][1]
> try:
> height = result['Rect'][2]
> except:
> height = width
>
> # Remove all but a one pixel row of the selection
> if height > 1:
> App.Do( Environment, 'Selection', {
> 'General': {
> 'Mode': App.Constants.SelectionOperation.Remove,
> 'Antialias': App.Constants.Boolean.false,
> 'Feather': 0
> },
> 'SelectionShape':
> App.Constants.SelectionShape.Rectangle, 'Start':
> (xoff, yoff+1), 'End': (xoff+width, yoff+height),
> 'GeneralSettings': {
> 'ExecutionMode':
> App.Constants.ExecutionMode.Default,
> 'AutoActionMode':
> App.Constants.AutoActionMode.Match } })
> # Get the new bounding box
> result = App.Do(Environment, 'GetRasterSelectionRect', {})
> # Restore the previous selection
> App.Do(Environment, 'UndoLastCmd', {})
>
> # The upper left corner of the bounding box must now contain
> # a pixel within the original selection so return that point
> return result['Rect'][0]
>
> # ----- FindSelectionPoint End -----
|