Skip to main content

CreateTexture

This function was added in DSL 1

Description

Create a texture for later drawing given a relative path of a .png file.

function CreateTexture(filename) --[[ ... ]] end

Parameters

  • filename: string - The relative path of the .png file to load as a texture. The path should be relative to the folder of your script.

Return Values

  • texture: userdata - The created texture object that can be used for drawing.

Example

local texture = CreateTexture("my_texture.png")
local x, y = 0.1, 0.1 -- Position to draw the texture (in normalized coordinates)
local w, h = 0.2, 0.3 -- Width and height of the texture (in normalized coordinates)
local r, g, b, a = 255, 255, 255, 255 -- Color and alpha values
DrawTexture(texture, x, y, w, h, r, g, b, a)

See Also

  • DSL