Skip to content

luxe API (2025.1.2)


luxe: system/sprite.modifier module


Advanced

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

Data

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

Dissolve

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

HSV

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

Outline

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

Shadow

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

Shine

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

Sprite

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) returns 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) returns 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) returns 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) returns 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) returns 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) returns 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) returns None

Detach and destroy the Sprite attached to entity

Sprite.destroy(entity)

Sprite.has(entity: Entity) returns 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) returns 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) returns 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) returns 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) returns 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) returns 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) returns 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) returns 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) returns None

Set whether the Sprite attached to entity is flipped horizontally.

Sprite.set_flip_h(entity, true)

Sprite.get_flip_h(entity: Entity) returns 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) returns None

Set whether the Sprite attached to entity is flipped vertically.

Sprite.set_flip_v(entity, true)

Sprite.get_flip_v(entity: Entity) returns 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) returns 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) returns 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) returns None

Resize the Sprite attached to entity to be widthxheight.

Sprite.set_size(entity, 256, 256)

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

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

Sprite.set_width(entity, 64)

Sprite.get_width(entity: Entity) returns Num

Returns the width of the Sprite attached to entity.

var width = Sprite.get_width(entity)

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

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

Sprite.set_height(entity, 64)

Sprite.get_height(entity: Entity) returns Num

Returns the height of the Sprite attached to entity.

var height = Sprite.get_height(entity)

Sprite.set_alpha(entity: Entity, alpha: Num) returns 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) returns Num

Returns the current alpha of the Sprite attached to entity.

var a = Sprite.get_alpha(entity)

Sprite.set_color(entity: Entity, color: Color) returns 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) returns 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) returns 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) returns 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) returns 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) returns 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) returns Float2

Return the skew for the Sprite attached to entity.

var skew = Sprite.get_skew(entity)

Sprite.get_geometry(entity: Entity) returns 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) returns unknown

Sets the render Geometry for the Sprite attached to entity.

Sprite.set_geometry(entity, geo)

Sprite.get_auto_size(entity: Entity) returns Bool

no docs found

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

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

Sprite.get_material_input(entity: Entity) returns Bool

no docs found

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

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

Sprite.get_hsv_adjust(entity: Entity) returns HSV

no docs found

Sprite.set_hsv_adjust(entity: Entity, enabled: Bool, hue_change: Num, saturation: Num, value: Num) returns 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) returns None

no docs found

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

no docs found

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

no docs found

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

no docs found

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

no docs found

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

no docs found

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

no docs found

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

no docs found

Sprite.get_outline(entity: Entity) returns Outline

no docs found

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

Set the values of the outline effect.

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

no docs found

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

no docs found

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

no docs found

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

no docs found

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

no docs found

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

no docs found

Sprite.get_shadow(entity: Entity) returns Shadow

no docs found

Sprite.set_shadow(entity: Entity, enabled: Bool, offset: Num, color: Color, softness: Num) returns 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) returns None

no docs found

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

no docs found

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

no docs found

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

no docs found

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

no docs found

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

no docs found

Sprite.get_dissolve(entity: Entity) returns Dissolve

no docs found

Sprite.set_dissolve(entity: Entity, enabled: Bool, image: Image, uv: List, value: Num) returns 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) returns None

no docs found

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

no docs found

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

no docs found

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

no docs found

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

no docs found

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

no docs found

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

no docs found

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

no docs found

Sprite.get_shine(entity: Entity) returns Shine

no docs found

Sprite.set_shine(entity: Entity, enabled: Bool, color: Num, direction: Vector2, width: Num, speed: Num, spacing: Num) returns 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) returns None

no docs found

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

no docs found

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

no docs found

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

no docs found

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

no docs found

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

no docs found

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

no docs found

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

no docs found

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

no docs found

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

no docs found

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

no docs found

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

no docs found

SpriteBillboard

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

no docs found


SpriteBillboard.none returns unknown

no docs found

SpriteBillboard.billboard returns unknown

no docs found

SpriteBillboard.fixed_scale returns unknown

no docs found

SpriteBillboard.fixed_screen_scale returns unknown

no docs found

System

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

no docs found

  • new(world: World)

System.new(world: World) returns System

no docs found