CGFloat array in F-Script?

23 views
Skip to first unread message

Dong Linlan

unread,
Feb 2, 2012, 10:43:38 AM2/2/12
to F-Script
I want to draw a dash line with NSBezierPath's -
setLineDash:count:phase method, which require a CGFloat array as
parameter.
Is there a way to specify a CGFloat array in F-Script?

Philippe Mougin

unread,
Feb 8, 2012, 12:39:48 PM2/8/12
to F-Script
Yes, through the FSPointer/FSGenericPointer classes.

For example, assuming you run with garbage collection and in 64 bit,
here is how you can create a C array with two CGFloat values (e.g., 5
and 2):

myPointer := FSPointer allocateCollectable:2 * 8. "In 64-bit a CGFloat
is a double, and a double is 8 bytes"
myPointer setType:'d'.
myPointer at:0 put:5.
myPointer at:1 put:2.

You can then pass myPointer as argument to the setLineDash:...
method .

Philippe
Reply all
Reply to author
Forward
0 new messages