RenderSurface Element
RenderSurface is a module that provides a drawing surface for custom rendering.
It supports text rendering, mouse interaction, and redraw handling.
RenderSurface Element Element LuaRT Element
Constructor
RenderSurface.new() Function
RenderSurface.new(RenderSurfaceProperties)
- Creates a new
RenderSurfaceelement,actually aCanvasobject.
You can just create your
RenderSurfacewithbgcolorandvisibleproperties. Other properties will be set to default values. If you want more than oneRenderSurface, remember you may need to set thezIndexmanually,alsoalign,sizeandpositionproperties.
Parameters:
-
IsRenderSurfacetrue- READONLY: Used internally by Weo for parent checking.
-
RenderElementstable- READONLY: Managed internally by Weo.
-
parentWindow- READONLY: Parent window of the
RenderSurface. Mostly it's aWindow.
- READONLY: Parent window of the
-
xnumber?- Horizontal position of the
RenderSurface.
- Horizontal position of the
-
ynumber?- Vertical position of the
RenderSurface.
- Vertical position of the
-
widthnumber?- Width of the
RenderSurface.
- Width of the
-
heightnumber?- Height of the
RenderSurface.
- Height of the
-
alignstring?- Alignment relative to parent. Automatically set to "all" by Weo.
-
enabledboolean?- Whether the
RenderSurfaceresponds to input.
- Whether the
-
visibleboolean?- Controls visibility of the
RenderSurface.
- Controls visibility of the
-
colorstring?- Current drawing color.
-
bgcolornumber?LinearGradient?RadialGradient?- Background color of the
RenderSurface.
- Background color of the
-
fontstring?- Current font (from Windows system fonts).
-
fontsizenumber?- Font size.
-
fontweightnumber?- Font weight (1–999).
-
fontstretchnumber?- Font stretch (1–9).
-
fontstyleEnum.FontStyle?- Font style.
-
windowWindow- The window to which the
RenderSurfaceis attached.
- The window to which the
-
cursorEnum.CursorStyle?- The cursor to display when the mouse is over the
RenderSurface.
- The cursor to display when the mouse is over the
Weo uses this property to set the cursor when the mouse is over the other elements,like
Button.
Methods
(RenderSurface):LinearGradient() Method
- Please use
Color.LinearGradientinstead.
(RenderSurface):RadialGradient() Method
- Please use
Color.RadialGradientinstead.
(RenderSurface):show() Method
- Shows the
RenderSurface.
(RenderSurface):hide() Method
- Hides the
RenderSurface.
(RenderSurface):measure() Method
(RenderSurface):measure(text)
- Measures text size.
Parameters:
- text string
Returns:
{ width: number, height: number }
(RenderSurface):Refresh() Method
(RenderSurface):Refresh(force)
- Forces redraw of the
RenderSurface.
This is for a bug in LuaRT 2.0.1 x64. After hiding (Window) and showing it again, the
RenderSurfacewill not be redrawn.
This method calls(RenderSurface):onPaint()to redraw viaUpdateService,performance is not guaranteed.
Parameters:
- force boolean
(RenderSurface):print() Method
(RenderSurface):print(text, x, y, color)
- Prints text at a position.
Parameters:
- text string
- x number
- y number
- color number?LinearGradient?RadialGradient?
Please use
Labelinstead.
(RenderSurface):rotate() Method
(RenderSurface):rotate(angle, x, y)
- Rotates the
RenderSurface.
Parameters:
- angle number
- x number?— Optional. Default is the center of the
RenderSurface. - y number?— Optional. Default is the center of the
RenderSurface.
(RenderSurface):scale() Method
(RenderSurface):scale(x, y,centerx, centery)
- Scales the
RenderSurface.
Parameters:
- x number
- y number
- centerx number?— Optional. Default is the center of the
RenderSurface. - centery number?— Optional. Default is the center of the
RenderSurface.
(RenderSurface):translate() Method
(RenderSurface):translate(x, y)
- Translates the
RenderSurface.
Parameters:
- x number
- y number
(RenderSurface):identity() Method
(RenderSurface):identity()
- Resets the transformation matrix of the
RenderSurface.
Signals
(RenderSurface).Shown Signal
- Fires when the
RenderSurfaceis shown.
(RenderSurface).Hidden Signal
- Fires when the
RenderSurfaceis hidden.
(RenderSurface).Created Signal
- Fires when the
RenderSurfaceis created.
(RenderSurface).MouseButton1Click Signal
- Fires when the
RenderSurfaceis clicked.
Parameters:
- position Vector2
(RenderSurface).MouseButton2Click Signal
- Fires when the
RenderSurfaceis right-clicked.
Parameters:
- position Vector2
(RenderSurface).MouseHover Signal
- Fires when the mouse hovers over the
RenderSurface.
Parameters:
- position Vector2
(RenderSurface).MouseButtonDown Signal
- Fires when a mouse button is pressed down.
Parameters:
- position Vector2
- buttons table— mouse buttons state
- Table containing mouse button states:
left— Left mouse button state.middle— Middle mouse button state.right— Right mouse button state.control— Control key state.shift— Shift key state.
- Table containing mouse button states:
(RenderSurface).MouseButtonUp Signal
- Fires when a mouse button is released.
Parameters:
- position Vector2
- buttons table— mouse buttons state
- Table containing mouse button states:
left— Left mouse button state.middle— Middle mouse button state.right— Right mouse button state.control— Control key state.shift— Shift key state.
- Table containing mouse button states:
Does not work on LuaRT 2.0.1 x64. Use
(buttons.left, buttons.right)fromMouseButtonDowninstead.
(RenderSurface).MouseWheel Signal
- Fires when the mouse wheel is scrolled.
Parameters:
- delta number
- buttons table— mouse buttons state
- Table containing mouse button states:
left— Left mouse button state.middle— Middle mouse button state.right— Right mouse button state.control— Control key state.shift— Shift key state.
- Table containing mouse button states:
(RenderSurface).MouseLeave Signal
- Fires when the mouse leaves the
RenderSurface.
Example
-- Creating a RenderSurface
local Render = RenderSurface.new(window, {
bgcolor = Color.fromHEX("#7E0202FF"),
visible = true,
})
-- Creating a Frame,which renders on the RenderSurface
local MyFrame = Frame.new(Render, {
position = UDim2.new(0, 300, 0, 300),
size = UDim2.new(0, 100, 0, 100),
bgcolor = Color.fromHEX("#1593CEFF"),
visible = true,
borderRadius = 15,
zIndex = 0,
})
Notes
- See LuaRT Canvas Documentation for details.
RenderSurfacestops updating:onPaint()after the window hidden and shown again. It's a known bug in LuaRT 2.0.1 x64 and not an issue of Weo.- You can force
(RenderSurface):Refresh(force : boolean)to updateRenderSurfacewithUpdateService.Heartbeat, but performance is not guaranteed since this is a workaround for the issue.
- You can force