nme.geom.Point

type
class
available in
nme
The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis.

The following code creates a point at(0,0):

Methods and properties of the following classes use Point objects:

You can use the new Point() constructor to create a Point object.

Static Methods

distance(pt1 : Point, pt2 : Point) : Float

parameters
pt1 The first point.
pt2 The second point.
returns
The distance between the first and second points.
Returns the distance between pt1 and pt2.

interpolate(pt1 : Point, pt2 : Point, f : Float) : Point

parameters
pt1 The first point.
pt2 The second point.
f The level of interpolation between the two points. Indicates where the new point will be, along the line between pt1 and pt2. If f=1, pt1 is returned; if f=0, pt2 is returned.
returns
The new, interpolated point.
Determines a point between two specified points. The parameter f determines where the new interpolated point is located relative to the two end points specified by parameters pt1 and pt2. The closer the value of the parameter f is to 1.0, the closer the interpolated point is to the first point(parameter pt1). The closer the value of the parameter f is to 0, the closer the interpolated point is to the second point(parameter pt2).

polar(len : Float, angle : Float) : Point

parameters
len The length coordinate of the polar pair.
angle The angle, in radians, of the polar pair.
returns
The Cartesian point.
Converts a pair of polar coordinates to a Cartesian point coordinate.

Constructor

new(?x : Float, ?y : Float)
parameters
x The horizontal coordinate.
y The vertical coordinate.
Creates a new point. If you pass no parameters to this method, a point is created at(0,0).

Instance Variables

copyFrom : sourcePoint : Point -> Void

metadata
:require
flash11

length(default,null) : Float

The length of the line segment from(0,0) to this point.

setTo : xa : Float -> ya : Float -> Void

metadata
:require
flash11

x : Float

The horizontal coordinate of the point. The default value is 0.

y : Float

The vertical coordinate of the point. The default value is 0.

Instance Methods

add(v : Point) : Point

parameters
v The point to be added.
returns
The new point.
Adds the coordinates of another point to the coordinates of this point to create a new point.

clone() : Point

returns
The new Point object.
Creates a copy of this Point object.

equals(toCompare : Point) : Bool

parameters
toCompare The point to be compared.
returns
A value of true if the object is equal to this Point object; false if it is not equal.
Determines whether two points are equal. Two points are equal if they have the same x and y values.

normalize(thickness : Float) : Void

parameters
thickness The scaling value. For example, if the current point is (0,5), and you normalize it to 1, the point returned is at(0,1).
returns
The normalized point.
Scales the line segment between(0,0) and the current point to a set length.

offset(dx : Float, dy : Float) : Void

parameters
dx The amount by which to offset the horizontal coordinate, x.
dy The amount by which to offset the vertical coordinate, y.
Offsets the Point object by the specified amount. The value of dx is added to the original value of x to create the new x value. The value of dy is added to the original value of y to create the new y value.

subtract(v : Point) : Point

parameters
v The point to be subtracted.
returns
The new point.
Subtracts the coordinates of another point from the coordinates of this point to create a new point.

toString() : String

returns
The string representation of the coordinates.
Returns a string that contains the values of the x and y coordinates. The string has the form "(x=x, y=y)", so calling the toString() method for a point at 23,17 would return "(x=23, y=17)".