Re: PhotoScripter and Curves
Re: PhotoScripter and Curves
- Subject: Re: PhotoScripter and Curves
- From: Arthur J Knapp <email@hidden>
- Date: Thu, 28 Jun 2001 15:35:34 -0400
>
Date: Thu, 28 Jun 2001 21:17:44 +1000
>
Subject: Re: PhotoScripter and Curves
>
From: Shane Stanley <email@hidden>
>
> I don't quite follow how you wrote out a new settings file each time. I
>
> opened a curve setting with bbedit to see if I could use AS to create them,
>
> but the code inside is all extended system characters. How did you read the
>
> files?
>
With AppleScript ;-) The key is the ASCII numbers of the characters. The
>
sequence is as follows, where each number represents the equivalent ASCII
>
character, n is the number of points plotted, and the i and o values
>
represent the plot pairs:
>
>
0, 1, 0, 1, 0, n, 0, i1, 0, o1, 0, i2, 0, o1, 0, i3, 0, o3 [...]
>
>
So here's a typical snippet for three points at {14, 0}, {191,128} and {250,
>
255}, a fairly vicious curve:
Can I help??? (please, please, please...) ;-)
script CurveClass
-- convenience constants
--
property kAsc0 : ASCII character 0
property kAsc1 : ASCII character 1
property fileHeader : "" & kAsc0 & kAsc1 & kAsc0 & kAsc1 & kAsc0
on SetPoints(points_list)
repeat with pointXY in points_list
AppendPoint(pointXY)
end repeat
end SetPoints
on AppendPoint(pointXY)
set pointX to ASCII character (item 1 of pointXY)
set pointY to ASCII character (item 2 of pointXY)
set end of my pointsList to {kAsc0, pointX, pointY}
set my pointsCount to (my pointsCount) + 1
end AppendPoint
on GetPoint(at_index)
set pointX to item 2 of item at_index of my pointsList
set pointY to item 3 of item at_index of my pointsList
set pointX to ASCII number (pointX)
set pointY to ASCII number (pointY)
return {pointX, pointY}
end GetPoint
on SetPoint(at_index, pointXY)
set pointX to ASCII character (item 1 of pointXY)
set pointY to ASCII character (item 2 of pointXY)
set item 2 of item at_index of my pointsList to pointX
set item 3 of item at_index of my pointsList to pointY
end SetPoint
on FileFormatted()
set file_string to ""
set file_string to file_string & fileHeader
set LengthAsByte to ASCII character (my pointsCount)
set file_string to file_string & LengthAsByte
set file_string to file_string & my pointsList
return file_string
end FileFormatted
end script
on MakeCurve(points_list)
script CurveObject
property parent : CurveClass
property pointsList : {}
property pointsCount : 0
end script
SetPoints(points_list) of CurveObject
return CurveObject
end MakeCurve
set somePoints to {{14, 0}, {191, 128}, {250, 255}}
set someCurve to MakeCurve(somePoints)
tell someCurve
GetPoint(2) -->{191, 128}
SetPoint(2, {4, 5})
GetPoint(2) -->{4, 5}
set ReadyForFile to FileFormatted() --> [string of binary-code]
end tell
Arthur J. Knapp
http://www.stellarvisions.com
mailto:email@hidden
Hey, check out:
http://www.AppleScriptSourceBook.com