The LM_Graphics class is used for drawing in an LM_View. It lets you draw basic lines and shapes, and to convert between coordinate systems (the screen pixel space and the 3D coordinate system of Moho layers). You typically would use an LM_Graphics object with a moho tool script to determine what object(s) the user clicks on and to draw extra tool elements like control handles.
Returns the width in pixels of the drawing area.
Return value (int): the width in pixels of the drawing areaReturns the height in pixels of the drawing area.
Return value (int): the height in pixels of the drawing areaSets the drawing color for subsequent drawing operations.
Return value: none r (int): red g (int): green b (int): blue a (int): alpha (opacity)Sets the width in pixels for line drawing operations.
Return value: none w (int): line pixel widthTurns on or off smoothing (antialaising) for drawing operations.
Return value: none value (bool): true to draw smooth lines and shapes, false to turn off smoothingConverts a screen pixel location to 2D world coordinates. As an example, this can be used to convert between a mouse click to a location in the current Moho layer.
Return value: none where (LM_Point): pixel location pt (LM_Vector2): 2D world position - filled in by this functionConverts a screen pixel location to 3D world coordinates.
Return value: none where (LM_Point): pixel location pt (LM_Vector3): 3D world position - filled in by this functionConverts a 2D world position to a screen pixel location. As an example, this can be used to convert between a point in a Moho layer to a screen pixel.
Return value (bool): returns true if the point is visible on screen, false otherwise pt (LM_Vector2): 2D world position where (LM_Point): pixel location - filled in by this functionConverts a 2D world position to a screen location.
Return value (bool): returns true if the point is visible on screen, false otherwise pt (LM_Vector2): 2D world position where (LM_Vector2): screen location - filled in by this functionCall this function before starting any drawing commands.
Return value: nonePush the current matrix stack. This is a way of saving the current transformation.
Return value: nonePop the current matrix stack. This is a way of restroing a saved transformation.
Return value: noneReturns the current matrix transformation.
Return value (LM_Matrix): the current matrix transformationPrepend a 2D translation to the current matrix transform.
Return value: none dx (float): x translation dy (float): y translationPrepend a 2D scale to the current matrix transform.
Return value: none sx (float): x scale sy (float): y scalePrepend a rotation to the current matrix transform.
Return value: none angle (float): angle in radiansPrepend an arbitrary matrix to the current matrix transform.
Return value: none matrix (const LM_Matrix): a matrix with any arbitrary transformation (2D or 3D)Returns the current scale of the drawing. A value of 1 means the drawing is actual size, 0.5 would be half size, 2.0 would be double size, etc.
Return value (float): the drawing's current scale ignoreZoom (bool): true if you wish to ignore zoom effects, false otherwiseCall this function when you're finished with all drawing operations.
Return value: noneCall this function to begin testing whether the user has clicked on an object.
Return value: none where (LM_Point): the pixel location you want to test (often the location of a mouse click)After drawing an object, call this function to see if it was clicked on by the user.
Return value (bool): true if the object was picked, otherwise falseTest whether a given pixel is 100% white.
Return value (bool): true if the pixel is white, otherwise false where (LM_Point): the pixel you wish to testDraw a selection rectangle.
Return value: none r (LM_Rect): the rectangle to drawClear the drawing area.
Return value: none r (int): red g (int): green b (int): blue a (int): alpha (opacity)Move the pen location to a given pixel. Nothing is drawn.
Return value: none x (float): x location y (float): y locationDraw a line from the current pen position to the given pixel.
Return value: none x (float): x location y (float): y locationDraw a line between two pixels.
Return value: none x1 (float): start x location y1 (float): start y location x2 (float): end x location y2 (float): end y locationBegin drawing an enclosed shape.
Return value: noneAdd a line segment to the current enclosed shape. All the line segments you add should form the outer boundary of the shape.
Return value: none end1 (LM_Vector2): first endpoint of the line segment end2 (LM_Vector2): second endpoint of the line segmentEnd the current enclosed shape and draw it on the screen.
Return value: noneDraw a circle outline.
Return value: none center (LM_Vector2): center point radius (float): radiusDraw a filled circle
Return value: none center (LM_Vector2): center point radius (float): radiusDraw a marker (for example, the control points on Moho curves).
Return value: none xf (float): x location yf (float): y locationDraw a fat marker.
Return value: none xf (float): x location yf (float): y location radius (float): radius