Class LM_Graphics

Version added: before 9.5
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.

>>> WIP >>>
there are two groups of "Draw" methods.
Those that use a vec2 as the location and those that separate the x and y dimensions.
Empirical evidence indicates that these groups interpret "radius" values differently.
The vec2 group uses moho units so: ... where the view is of a very small area of the workspace a very small radius gives the same number of on-screen pixels as … where the screen shows the whole work area and beyond a large radius is needed to give the same on-screen size.
The x,y group interprets "radius" as an on-screen size irrespective of the level of workspace zoom.
>>> More when I have it ….

Methods of LM_Graphics:

Name Returns Description Ver
AddLine AddLine(end1, end2) void Add a line segment to the current enclosed shape < 9.5
ApplyMatrix ApplyMatrix(matrix) void Prepend an arbitrary matrix to the current matrix transform < 9.5
BeginDraw BeginDraw() void Call this function before starting any drawing commands < 9.5
BeginPicking BeginPicking(where, pickWidth) void Call this function to begin testing whether the user has clicked on an object < 9.5
BeginShape BeginShape() void Begin drawing an enclosed shape < 9.5
Clear Clear(r, g, b, a) void Clear the drawing area < 9.5
CurrentScale CurrentScale(ignoreZoom) real Returns the current scale of the drawing < 9.5
CurrentTransform CurrentTransform() Matrix Returns the current matrix transformation < 9.5
DrawDiamondMarker DrawDiamondMarker(xf, yf, radius) void Added in version 9.5 9.5
DrawDiamondMarker DrawDiamondMarker(xf, yf, zf, radius) void Added in version 9.5 9.5
DrawFatLine DrawFatLine(width, x1, y1, x2, y2) void Added in version 10 10.0
DrawFatLine2 DrawFatLine2(width1, width2, x1, y1, x2, y2) void Added in version 11 11.0
DrawFatMarker DrawFatMarker(xf, yf, radius) void Draw a fat marker < 9.5
DrawLine DrawLine(x1, y1, x2, y2) void Draw a line between two pixels < 9.5
DrawMarker DrawMarker(xf, yf) void Draw a marker (for example, the control points on Moho curves) < 9.5
EndDraw EndDraw() void Call this function when you're finished with all drawing operations < 9.5
EndShape EndShape() void End the current enclosed shape and draw it on the screen < 9.5
FillCircle FillCircle(center, radius) void Draw a filled circle < 9.5
FillCirclePixelRadius FillCirclePixelRadius(center, radius) void < 9.5
FillOval FillOval(r) void Added in version 9.5 9.5
FloodFill FloodFill(seedX, seedY) bool < 9.5
FrameCircle FrameCircle(center, radius) void Draw a circle outline < 9.5
FrameCirclePixelRadius FrameCirclePixelRadius(center, radius) void < 9.5
FrameOval FrameOval(r) void Added in version 9.5 9.5
Height Height() int32 Returns the height in pixels of the drawing area < 9.5
IsFullWhite IsFullWhite(where) bool Test whether a given pixel is 100% white < 9.5
LineTo LineTo(x, y) void Draw a line from the current pen position to the given pixel < 9.5
LineTo LineTo(x, y) void Draw a line from the current pen position to the given pixel < 9.5
MoveTo MoveTo(x, y) void Move the pen location to a given pixel < 9.5
MoveTo MoveTo(x, y) void Move the pen location to a given pixel < 9.5
Pick Pick() bool After drawing an object, call this function to see if it was clicked on by the user < 9.5
Pop Pop() void Pop the current matrix stack < 9.5
Push Push() void Push the current matrix stack < 9.5
Rotate Rotate(angle) void Prepend a rotation to the current matrix transform < 9.5
Scale Scale(sx, sy) void Prepend a 2D scale to the current matrix transform < 9.5
ScreenToWorld ScreenToWorld(where, pt) void Converts a screen pixel location to 2D world coordinates < 9.5
ScreenToWorld ScreenToWorld(where, pt) void Converts a screen pixel location to 3D world coordinates < 9.5
SelectionRect SelectionRect(r, fillRect) void Draw a selection rectangle < 9.5
SetBezierTolerance SetBezierTolerance(pixels) void < 9.5
SetColor SetColor(color) void Sets the drawing color for subsequent drawing operations < 9.5
SetColor SetColor(r, g, b, a) void Sets the drawing color for subsequent drawing operations < 9.5
SetPenWidth SetPenWidth(w) void Sets the width in pixels for line drawing operations < 9.5
SetSmoothing SetSmoothing(value) void Turns on or off smoothing (antialaising) for drawing operations < 9.5
SetViewMode SetViewMode(mode) void Added in version 10 10.0
SetViewOffset SetViewOffset(offsetX, offsetY) void Added in version 10 10.0
SetViewPixelScaling SetViewPixelScaling(pixelScaling) void Added in version 10 10.0
SetViewRotation SetViewRotation(angle) void Added in version 10 10.0
SetViewZoom SetViewZoom(z) void Added in version 10 10.0
Translate Translate(dx, dy) void Prepend a 2D translation to the current matrix transform < 9.5
ViewMode ViewMode() int32 Added in version 10 10.0
ViewOffset ViewOffset() Vector2 Added in version 10 10.0
ViewPixelScaling ViewPixelScaling() int32 Added in version 10 10.0
ViewRotation ViewRotation() real Added in version 10 10.0
ViewZoom ViewZoom() real Added in version 10 10.0
Width Width() int32 Returns the width in pixels of the drawing area < 9.5
WorldToScreen WorldToScreen(pt, where) bool Converts a 2D world position to a screen pixel location < 9.5
WorldToScreen WorldToScreen(pt, where) bool Converts a 2D world position to a screen pixel location < 9.5