Class: M_Mesh

The M_Mesh class is a container for the actual vector shapes in a vector layer. It contains points, curves, and fill and outline shapes.

Member Functions


void Clear()

Completely empties a mesh of all points and curves.

Return value: none
int CountPoints()

Returns the number of points in the mesh.

Return value (int): number of points
int CountCurves()

Returns the number of curves in the mesh.

Return value (int): number of curves
int CountShapes()

Returns the number of shapes in the mesh.

Return value (int): number of shapes
int CountGroups()

Returns the number of point groups in the mesh.

Return value (int): number of point groups
M_Point Point(id)

Access a point in the mesh.

Return value (M_Point): a point object id (int): point identifier
M_Curve Curve(id)

Access a curve in the mesh.

Return value (M_Curve): a curve object id (int): curve identifier
M_Shape Shape(id)

Access a shape in the mesh.

Return value (M_Shape): a shape object id (int): shape identifier
M_PointGroup Group(id)

Access a point group in the mesh.

Return value (M_PointGroup): a point group object id (int): point group identifier
void AddPoint(pos, attachID, frame)

Add a new point to the mesh.

Return value: none pos (LM_Vector2): location of the new point attachID (int): if -1, then start a new curve, otherwise attach the new point to this point id frame (int): frame number
void AddPoint(pos, attachCurve, attachSeg, frame)

Add a new point to the middle of a curve.

Return value: none pos (LM_Vector2): location of the new point attachCurve (int): curve identifier to attach to attachSeg (int): which segment of the curve frame (int): frame number
void AddLonePoint(pos, frame)

Adds a lone, unconnected point to the mesh. Lone points are not normally allowed in Moho, so this function must be followed by one or more calls to the AppendPoint function.

Return value: none pos (LM_Vector2): location of the new point frame (int): frame number
void AppendPoint(pos, frame)

Adds a new point, connecting it with a curve to either the AddLonePoint point, or the last call to AppendPoint.

Return value: none pos (LM_Vector2): location of the new point frame (int): frame number
void DeletePoint(id)

Deletes a point from the mesh.

Return value: none id (int): point identifier
bool WeldPoints(movingID, solidID, frame)

Welds two points together. The point identified by movingID will move if necessary to line up with solidID. Not all welding operations are allowed, so this function will return the status of the weld.

Return value (bool): true if successful, otherwise false movingID (int): point identifier solidID (int): point identifier frame (int): frame number
bool ArePointsAdjacent(p1, p2)

Tests whether two points are adjacent on a curve.

Return value (bool): true if adjacent, otherwise false p1 (int): point identifier p2 (int): point identifier
int ClosestPoint(pos, ignoreID, maxPointID)

Returns the closest point to the given location.

Return value (int): point identifier pos (LM_Vector2): a 2D location in the layer ignoreID (int): point identifier - ignore this point when testing for the closest point maxPointID (int): point identifier - ignore points with identifiers higher than this id
LM_Vector2 SelectedCenter()

Returns the location of the center point of the current group of selected points.

Return value (LM_Vector2): center location
void SelectedBounds(min, max)

Returns the boundaries of the current selection.

Return value: none min (LM_Vector2): minimum X and Y coordinates max (LM_Vector2): maximum X and Y coordinates
void PrepMovePoints()

Call this before moving a group of points around.

Return value: none
void TranslatePoints(offset)

Translate the currently selected points.

Return value: none offset (LM_Vector2): the distance to translate them
void ScalePoints(sx, sy, centerVec)

Scale the currently selected points.

Return value: none sx (float): x scale sy (float): y scale centerVec (LM_Vector2): the center point of the scaling operation
void RotatePoints(angle, centerVec)

Rotate the currently selected points.

Return value: none angle (float): angle in radians centerVec (LM_Vector2): the center point of the rotation operation
void SelectNone()

Deselect all points.

Return value: none
void SelectAll()

Select all points.

Return value: none
void SelectInverse()

Invert the current selection.

Return value: none
void SelectConnected()

Select all points that are connected by curves to any currently selected points.

Return value: none
void DeleteEdge(curveID, segID, frame)

Delete an edge of a curve.

Return value: none curveID (int): curve identifier segID (int): which segment on the curve to delete frame (int): frame number
void DeleteShape(id)

Delete a fill or outline shape.

Return value: none id (int): shape identifier
void LowerShape(id, toBottom)

Lower a shape in the stacking order.

Return value: none id (int): shape identifier toBottom (bool): true to lower it to the bottom, false to lower it one step
void RaiseShape(id, toTop)

Raise a shape in the stacking order.

Return value: none id (int): shape identifier toTop (bool): true to raise it to the top, false to raise it one step
void AddGroup(name)

Add a new point group, made up of the currently selected points.

Return value: none name (string): name for the new group
void SelectGroup(name)

Select all the points in a given group.

Return value: none name (string): name of the group to select
void DeleteGroup(name)

Delete a point group from the mesh.

Return value: none name (string): name of the group to delete