Actually turning the origin upside down is easy enough mathematically, you just have to take the difference in the top-relative coordinate and the bottom of the card. Making it work consistently and "semi-natively" in Rev under all permutations of geometry handling (drawing, moving, resizing, etc) is obviously a non-trivial job.
You could do some basic things like putting these in the stack script, or a library:
Code: Select all
function fnBottomLeftOrigin pX, pY
local tYLimit
put the bottom of this card into tYLimit --in theory "this" card should be apparent from the source of the function call
--but might need checking in different stack/substack/palette situations
--the setProp handler below does full checking for the card/stack paths to get the right card height
put tYLimit - pY into pY
return pX & comma & pY
end fnBottomLeftOrigin
and use this as in
Code: Select all
if there is a graphic "myNewLine" then delete graphic "myNewLine" --just here to tidy up while testing
put fnBottomLeftOrigin(390,10) into tPointsList --returns the first coordinate turned upside down
put cr & fnBottomLeftOrigin(300,100) after tPointsList --returns the next coordinate also turned upside down
create invisible graphic "myNewLine" --optionally invisible, but allows you to manipulate the properties before showing the line on screen
set the style of graphic "myNewLine" to "line" --you could set the style to polygon, etc instead
set the lineSize of graphic "myNewLine" to 1
set the points of graphic "myNewLine" to tPointsList
set the antialiased of graphic "myNewLine" to true
set the visible of graphic "myNewLine" to true
This should draw a line from the bottom right hand corner (390,10) diagonally up and left to (300,100) (relative to the origin being bottom left, and assuming an appropriate card width - say 400 here. If you examine the points of the graphic, it will show Rev's native coords).
Perhaps more powerful and useful would be to make a setProp handler. Put this in the mainstack or library scripts:
Code: Select all
setProp myOriginPoints pPointsList
local tYLimit, tLongName, tCardName, tPoints, tLoop, tCardPos
put the long name of the target into tLongName
put (wordOffset ("card", tLongName)) into tCardPos
put word (tCardPos) to -1 of tLongName into tCardName
--you could also use "the owner of the target" to get the card name, but you'd
--also need to check for the control being part of a group
put the bottom of (tCardName) into tYLimit
repeat for each line tLoop in pPointsList
put item 1 of tLoop & comma & (tYlimit - item 2 of tLoop) & cr after tPoints
end repeat
set the points of the target to tPoints
pass myOriginPoints
end myOriginPoints
Then you can use almost the same syntax as normal, as in:
Code: Select all
local tPointsList
if there is a graphic "myNewTriangle" then delete graphic "myNewTriangle" --just here to tidy up while testing
put "10,10" into tPointsList --the first coordinate
put cr & "100,100" after tPointsList --the next coordinate
put cr & "100,10" after tPointsList --third vertex
put cr & "10,10" after tPointsList --back again to close polygon at first vertex
create invisible graphic "myNewTriangle"
set the style of graphic "myNewTriangle" to "polygon"
set the lineSize of graphic "myNewTriangle" to 1
set the myOriginPoints of graphic "myNewTriangle" to tPointsList
--the above line sets the custom property "myOriginPoints" of the target to your list with the origin at bottom left
--the setProp handler is thereby triggered, and converts that list to Rev top left origin coodinates and sets the points of the target (to the native points)
--it also passes the custom property so that your bottom left origin relative points are saved.
--You can then interrogate either the native or your custom points in the future.
set the antialiased of graphic "myNewTriangle" to true
set the visible of graphic "myNewTriangle" to true
This should draw a right-angled triangle in the bottom left hand corner.
This setProp can be adapted to call a function which returns the (reverted to native) Rev points list so that you can have a similar setProp myOriginRelativePoints as well as setProp myOriginPoints handler.
You can obviously rename the functions and setProp handlers to something a bit more shorthand for you.
The above will NOT be useful for other commands, like "move" for example, and the other coordinate processing features, which will all use the top left as the origin. This is pretty ubiquitous in screen handling, as resizing and redrawing geometry will tend to be pulls from the bottom "adding" to the height, rather than "dragging" the origin "backwards". To be honest, the whole business is easier to just remember the top left as the origin.