An Objective-C/Perl Bridge


A CamelBones::NSPoint object represents a point in a two-dimensional coordinate space. It has two properties: x, the point's horizontal coordinate, and y, the point's vertical coordinate. Both are floating-point numbers.


Returns the value of the x property.
Returns the value of the y property.
Stores the value of $newX in the x property.
Stores the value of $newY in the y property.
setAll($newX, $newY)
Stores the value of $newX and $newY in the x and y properties, respectively.
$hr = getHashref()
Returns the point data as a reference to a hash with keys 'x' and 'y'.
$ar = getArrayref()
Returns the point data as an array reference. Properties are stored in the array in the order x,y.


$isEQ = NSEqualPoints($point1, $point2)
Returns a true (nonzero) value if both x and y properties are the same for both points, a false (zero) value if not.
$point = NSMakePoint($newX, $newY)
Creates a new NSPoint structure with the specified properties.
$point = NSPointFromString($str)
Creates a new NSPoint structure from the string representation in $str.
$str = NSStringFromPoint($point)
Returns a string representation of $point

NSPoint function and method arguments

Naturally, a function or method that is declared as taking an NSPoint structure as an argument will also take a CamelBones::NSPoint object. However, a hash or array reference may be passed as well, as illustrated by these examples:

# Create a CamelBones::NSPoint object
my $point = NSMakePoint(0.0, 1.0);

# Returns zero
my $isEQ = NSEqualPoints($point, { x => 1.0, y => 1.0 } );

# Returns nonzero
my $isEQ = NSEqualPoints($point, [0.0, 1.0]);

NSPoint return values

Cocoa functions and methods that are declared as returning NSPoint structures will return CamelBones::NSPoint objects to Perl.

See also


Managing Points