Skip to content

luxe: system/sprite.modifier


import "luxe: system/sprite.modifier" for Advanced

no docs found

var auto_size : Bool = true
var material_input : String = "sprite.image"
var HSV : HSV = Object
var outline : Outline = Object
var shadow : Shadow = Object
var dissolve : Dissolve = Object
var shine : Shine = Object
import "luxe: system/sprite.modifier" for Data

no docs found

var image : Asset = "luxe: image/logo"
var size : Float2 = [64, 64]
var origin : Float2 = [0.5, 0.5]
var skew : Float2 = [0, 0]
var color : Color = [1, 1, 1, 1]
var uv : Float4 = [0, 0, 1, 1]
var flip_x : Bool = false
var flip_y : Bool = false
var pixelated : Bool = false
var billboard : SpriteBillboard = SpriteBillboard.none
var billboard_lock : Float3 = [0, 0, 0]
var atlas : Asset = null
var atlas_image_id : String = null
var material : Asset = null
var advanced : Advanced = Object
import "luxe: system/sprite.modifier" for Dissolve

no docs found

var enabled : Bool = false
var image : Asset = null
var uv : Float4 = [0, 0, 1, 1]
var value : Num = 1
import "luxe: system/sprite.modifier" for HSV

no docs found

var enabled : Bool = false
var hue_change : Num = 0
var saturation : Num = 1
var value : Num = 1
import "luxe: system/sprite.modifier" for Outline

no docs found

var enabled : Bool = false
var color : Color = [1, 1, 1, 1]
var thickness : Num = 0
import "luxe: system/sprite.modifier" for Shadow

no docs found

var enabled : Bool = false
var offset : Float2 = [0, 0]
var color : Color = [0, 0, 0, 1]
var softness : Num = 0
import "luxe: system/sprite.modifier" for Shine

no docs found

var enabled : Bool = false
var color : Color = [1, 0.92, 0.16, 1]
var direction : Float2 = [0, 0]
var width : Num = 0
var speed : Num = 0
var spacing : Num = 0
import "luxe: system/sprite.modifier" for Sprite

A sprite is an image attached to an entity.
The Sprite modifier provides flipping, sizing, sub images and more. To attach a sprite to an entity, call Sprite.create:

var entity = Entity.create(world)
var material = Assets.material("luxe: material/logo")
Sprite.create(entity, material, 128, 128)

Sprite.create(entity : Entity, image : Image, width : Num, height : Num) : None

Attach a Sprite modifier to entity, drawn using image, with a given size of widthxheight.

var entity = Entity.create(world)
var image = Assets.image("luxe: image/logo")
Sprite.create(entity, material, 128, 128)

Sprite.create(entity : Entity, image : Image) : None

Attach a Sprite modifier to entity, drawn using image. The size of the sprite will be determined by the size of the image.

var entity = Entity.create(world)
var image = Assets.image("luxe: image/logo")
Sprite.create(entity, image)

Sprite.create(entity : Entity) : None

Attach a Sprite modifier to entity, drawn using a default image. Use Sprite.set_image or Sprite.set_material to change it later.

var entity = Entity.create(world)
Sprite.create(entity)

Sprite.create_with(entity : Entity, material : Material, width : Num, height : Num) : None

Attach a Sprite modifier to entity, drawn using material, with a size of widthxheight.

var entity = Entity.create(world)
var material = Assets.material("luxe: material/logo")
Sprite.create_with(entity, material, 128, 128)

Sprite.create_with(entity : Entity, material : Material) : None

Attach a Sprite modifier to entity, drawn using material. The size of the sprite will be determined by the sprite.image slot in the material.

var entity = Entity.create(world)
var material = Assets.material("luxe: material/logo")
Sprite.create(entity, material)

Sprite.create(entity : Entity, atlas : Atlas, atlas_image : String) : None

Attach a Sprite modifier to entity, drawn using the atlas, using the image name in the atlas as atlas_image, with a size defined by the image in the atlas.

var entity = Entity.create(world)
var atlas = Assets.atlas("atlas/example")
var image_name = "images/atlas/example/tree"
Sprite.create(entity, atlas, image_name)

Sprite.destroy(entity : Entity) : None

Detach and destroy the Sprite attached to entity

Sprite.destroy(entity)

Sprite.has(entity : Entity) : Bool

Returns true if entity has a Sprite modifier attached.

if(Sprite.has(entity)) {
Log.print("found sprite")
}

Sprite.contains(entity : Entity, x : Num, y : Num) : Bool

Returns true if the Sprite attached to entity contains the point at x,y (in world units). Note that the function is based on the sprite width and height, it is not pixel perfect.

//Convert mouse coords to world units
var pos = Camera.screen_point_to_world(
app.camera,
Input.mouse_x(),
Input.mouse_y())
//Check if point is inside the sprite
if(Sprite.contains(entity, pos.x, pos.y)) {
Log.print("mouse inside sprite!")
}

Sprite.set_material(entity : Entity, material : Material) : None

Change the material that the Sprite attached to entity is drawn with, so it will draw with material instead.

var material = Assets.material("luxe: material/logo.sprite")
Sprite.set_material(entity, material)

Sprite.get_material(entity : Entity) : Material

Returns the current material that the Sprite attached to entity is drawn with.

var material = Sprite.get_material(entity)

Sprite.set_image(entity : Entity, image : Image) : None

Change the image that the Sprite attached to entity is drawn with.

var image = Assets.image("luxe: image/logo.sprite")
Sprite.set_image(entity, image)

Sprite.get_image(entity : Entity) : Image

Returns the current image that the Sprite attached to entity is drawn with.

var image = Sprite.get_image(entity)

Sprite.set_origin(entity : Entity, x : Num, y : Num) : None

Sets the origin of the sprite in relation to the Transform on entity. The x and y values are 0...1 range, where 0, 0 is bottom left, and 1, 1 is top right. A centered sprite is 0.5, 0.5. To set the origin to the center, bottom you’d use 0.5, 0.

//centered
Sprite.set_origin(entity, 0.5, 0.5)
//bottom left
Sprite.set_origin(entity, 0, 0)
//bottom center
Sprite.set_origin(entity, 0.5, 0)

Sprite.get_origin(entity : Entity) : Float2

Returns the current origin for the Sprite attached to entity.

var origin = Sprite.get_origin(entity)
Log.print(origin) //[0.5, 0.5]

Sprite.set_flip_h(entity : Entity, flipped : Bool) : None

Set whether the Sprite attached to entity is flipped horizontally.

Sprite.set_flip_h(entity, true)

Sprite.get_flip_h(entity : Entity) : Bool

Returns true if the Sprite attached to entity is flipped horizontally.

var flipped = Sprite.get_flip_h(entity)

Sprite.set_flip_v(entity : Entity, flipped : Bool) : None

Set whether the Sprite attached to entity is flipped vertically.

Sprite.set_flip_v(entity, true)

Sprite.get_flip_v(entity : Entity) : Bool

Returns true if the Sprite attached to entity is flipped vertically.

var flipped = Sprite.get_flip_v(entity)

Sprite.set_billboard(entity : Entity, kind : SpriteBillboard, lock : Float3) : None

Set how the Sprite attached to entity behaves as a billboard sprite. The lock field is 0 for unlocked rotation, 1 for locked rotation on that axis.

Sprite.set_billboard(entity, SpriteBillboard.fixed_scale, [0,1,0])

Sprite.get_billboard(entity : Entity) : SpriteBillboard

Get how the Sprite attached to entity behaves as a billboard sprite.

var kind = Sprite.get_billboard(entity)
if(kind == SpriteBillboard.fixed_scale) { ... }

Sprite.set_size(entity : Entity, width : Num, height : Num) : None

Resize the Sprite attached to entity to be widthxheight.

Sprite.set_size(entity, 256, 256)

Sprite.set_width(entity : Entity, width : Num) : None

Resize the Sprite attached to entity to have a new width.

Sprite.set_width(entity, 64)

Sprite.get_width(entity : Entity) : Num

Returns the width of the Sprite attached to entity.

var width = Sprite.get_width(entity)

Sprite.set_height(entity : Entity, height : Num) : None

Resize the Sprite attached to entity to have a new height.

Sprite.set_height(entity, 64)

Sprite.get_height(entity : Entity) : Num

Returns the height of the Sprite attached to entity.

var height = Sprite.get_height(entity)

Sprite.set_alpha(entity : Entity, alpha : Num) : None

Change the alpha (transparency) of the Sprite attached to entity to be alpha. Modifies the color.

Sprite.set_alpha(entity, 0.5)

Sprite.get_alpha(entity : Entity) : Num

Returns the current alpha of the Sprite attached to entity.

var a = Sprite.get_alpha(entity)

Sprite.set_color(entity : Entity, color : Color) : None

Set the color of the Sprite attached to entity to be a color. The default color is white, [1, 1, 1, 1], so to undo a color change, set it to that.

var color = Color.hex(0xf6007c)
Sprite.set_color(entity, color)

Sprite.set_color(entity : Entity, r : Num, g : Num, b : Num, a : Num) : None

Set the color of the Sprite attached to entity to be a color of r,g,b,a. The default color is white, [1, 1, 1, 1], so to undo a color change, set it to that.

Sprite.set_color(entity, r, g, b, a)

Sprite.get_color(entity : Entity) : Color

Returns the current color of the Sprite attached to entity.

var color = Sprite.get_color(entity)

Sprite.set_uv(entity : Entity, x0 : Num, y0 : Num, x1 : Num, y1 : Num) : None

Set the UV coordinates for the Sprite attached to entity with top left at x0,y0 and bottom right x1,y1. The default is 0, 0, 1, 1, a full rectangle in UV coordinate space. If you want to tile the image on a sprite, set it to values > 1.

//tile 4 times on both x and y
Sprite.set_uv(entity, 0, 0, 4, 4)

Sprite.get_uv(entity : Entity) : Float4

Returns the current uv of the Sprite attached to entity.

var uv = Sprite.get_uv(entity)

Sprite.set_skew(entity : Entity, x : Num, y : Num) : None

Set the skew amounts for the Sprite attached to entity. The values of x and y are between 0 ... 1, where 1 is the most skew and 0 is none.

Sprite.set_skew(entity, 0, 0.25)

Sprite.get_skew(entity : Entity) : Float2

Return the skew for the Sprite attached to entity.

var skew = Sprite.get_skew(entity)

Sprite.get_geometry(entity : Entity) : Geometry

Returns the render Geometry for the Sprite attached to entity. The geometry is owned by the sprite, so be aware when modifying it.

var geometry = Sprite.get_geometry(entity)

Sprite.set_geometry(entity : Entity, geo : Geometry) : unknown

Sets the render Geometry for the Sprite attached to entity.

Sprite.set_geometry(entity, geo)

Sprite.get_auto_size(entity : Entity) : Bool

no docs found

Sprite.set_auto_size(entity : Entity, value : Bool) : None

When setting an image or material, resize the sprite to the image size

Sprite.get_pixelated(entity : Entity) : Bool

Displaying as pixelated or not

Sprite.set_pixelated(entity : Entity, value : Bool) : None

Display as pixelated or not

Sprite.get_material_input(entity : Entity) : Bool

no docs found

Sprite.set_material_input(entity : Entity, value : Bool) : None

For custom materials, the material input ID for the image.

Sprite.get_hsv_adjust(entity : Entity) : HSV

no docs found

Sprite.set_hsv_adjust(entity : Entity, enabled : Bool, hue_change : Num, saturation : Num, value : Num) : None

Set the values for the hsv adjustment effect. The effect applies several operations on the colors of the sprite in sRGB HSV space. Saturation and Value changes are applied with exponents as value ^ adjustment.

Sprite.set_effect_HSV_enabled(entity : Entity, enabled : Bool) : None

no docs found

Sprite.get_effect_HSV_enabled(entity : Entity, enabled : Bool) : None

no docs found

Sprite.set_effect_HSV_hue_change(entity : Entity, hue_change : Num) : None

no docs found

Sprite.get_effect_HSV_hue_change(entity : Entity, hue_change : Num) : None

no docs found

Sprite.set_effect_HSV_saturation(entity : Entity, saturation : Num) : None

no docs found

Sprite.get_effect_HSV_saturation(entity : Entity, saturation : Num) : None

no docs found

Sprite.set_effect_HSV_value(entity : Entity, value : Num) : None

no docs found

Sprite.get_effect_HSV_value(entity : Entity, value : Num) : None

no docs found

Sprite.get_outline(entity : Entity) : Outline

no docs found

Sprite.set_outline(entity : Entity, enabled : Bool, color : Color, thickness : Num) : None

Set the values of the outline effect.

Sprite.set_effect_outline_enabled(entity : Entity, enabled : Bool) : None

no docs found

Sprite.get_effect_outline_enabled(entity : Entity, enabled : Bool) : None

no docs found

Sprite.set_effect_outline_color(entity : Entity, color : Color) : None

no docs found

Sprite.get_effect_outline_color(entity : Entity, color : Color) : None

no docs found

Sprite.set_effect_outline_thickness(entity : Entity, thickness : Num) : None

no docs found

Sprite.get_effect_outline_thickness(entity : Entity, thickness : Num) : None

no docs found

Sprite.get_shadow(entity : Entity) : Shadow

no docs found

Sprite.set_shadow(entity : Entity, enabled : Bool, offset : Num, color : Color, softness : Num) : None

Set the values for the shadow effect. Shadows are the same color as the base sprite image, but only have a single color.

Sprite.set_effect_shadow_enabled(entity : Entity, enabled : Bool) : None

no docs found

Sprite.get_effect_shadow_enabled(entity : Entity, enabled : Bool) : None

no docs found

Sprite.set_effect_shadow_offset(entity : Entity, offset : Vector2) : None

no docs found

Sprite.get_effect_shadow_offset(entity : Entity, offset : Vector2) : None

no docs found

Sprite.set_effect_shadow_color(entity : Entity, color : Color) : None

no docs found

Sprite.get_effect_shadow_color(entity : Entity, color : Color) : None

no docs found

Sprite.get_dissolve(entity : Entity) : Dissolve

no docs found

Sprite.set_dissolve(entity : Entity, enabled : Bool, image : Image, uv : List, value : Num) : None

Set the values for the hsv adjustment effect. The effect applies several operations on the colors of the sprite in sRGB HSV space. Saturation and Value changes are applied with exponents as value ^ adjustment.

Sprite.set_effect_dissolve_enabled(entity : Entity, enabled : Bool) : None

no docs found

Sprite.get_effect_dissolve_enabled(entity : Entity, enabled : Bool) : None

no docs found

Sprite.set_effect_dissolve_image(entity : Entity, image : Image) : None

no docs found

Sprite.get_effect_dissolve_image(entity : Entity, image : Image) : None

no docs found

Sprite.set_effect_dissolve_uv(entity : Entity, uv : Vector4) : None

no docs found

Sprite.get_effect_dissolve_uv(entity : Entity, uv : Vector4) : None

no docs found

Sprite.set_effect_dissolve_value(entity : Entity, value : Num) : None

no docs found

Sprite.get_effect_dissolve_value(entity : Entity, value : Num) : None

no docs found

Sprite.get_shine(entity : Entity) : Shine

no docs found

Sprite.set_shine(entity : Entity, enabled : Bool, color : Num, direction : Vector2, width : Num, speed : Num, spacing : Num) : None

Set the values for the hsv adjustment effect. The effect applies several operations on the colors of the sprite in sRGB HSV space. Saturation and Value changes are applied with exponents as value ^ adjustment.

Sprite.set_effect_shine_enabled(entity : Entity, enabled : Bool) : None

no docs found

Sprite.get_effect_shine_enabled(entity : Entity, enabled : Bool) : None

no docs found

Sprite.set_effect_shine_color(entity : Entity, color : Color) : None

no docs found

Sprite.get_effect_shine_color(entity : Entity, color : Color) : None

no docs found

Sprite.set_effect_shine_direction(entity : Entity, direction : Vector2) : None

no docs found

Sprite.get_effect_shine_direction(entity : Entity, direction : Vector2) : None

no docs found

Sprite.set_effect_shine_width(entity : Entity, width : Num) : None

no docs found

Sprite.get_effect_shine_width(entity : Entity, width : Num) : None

no docs found

Sprite.set_effect_shine_speed(entity : Entity, speed : Num) : None

no docs found

Sprite.get_effect_shine_speed(entity : Entity, speed : Num) : None

no docs found

Sprite.set_effect_shine_spacing(entity : Entity, spacing : Num) : None

no docs found

Sprite.get_effect_shine_spacing(entity : Entity, spacing : Num) : None

no docs found

import "luxe: system/sprite.modifier" for SpriteBillboard

no docs found

SpriteBillboard.none : unknown

no docs found

SpriteBillboard.billboard : unknown

no docs found

SpriteBillboard.fixed_scale : unknown

no docs found

SpriteBillboard.fixed_screen_scale : unknown

no docs found

import "luxe: system/sprite.modifier" for System

no docs found

System.new(world : World) : System

no docs found