Textures & Images
Images (CPU), Textures (GPU), RenderTextures, cubemaps, n-patches, palette, color math.
Textures reference
Images (CPU), Textures (GPU), RenderTextures, cubemaps, n-patches, 26-color palette, color math. Every function from raylib's rtextures.c exposed as idiomatic Iron.
Image loading
Image.load(path: String) -> Image
Category: Image loading · raylib: LoadImage
Load image from PNG/JPG/TGA/BMP/GIF/QOI/PSD/DDS/HDR/KTX/PIC/PVR/PKM/ASTC. Returns invalid-shaped Image on failure; check with Image.is_valid.
val img = Image.load("sprite.png")
raylib cheatsheet ·
Iron source ·
Test usage
Image.is_valid(img: Image) -> Bool / Image.unload(img: Image)
Category: Image loading · raylib: IsImageValid / UnloadImage
Runtime validity guard + pixel-buffer release.
if Image.is_valid(img) {
-- process
Image.unload(img)
}
raylib cheatsheet ·
Iron source ·
Test usage
Image.load_raw(file_name, width, height, format: Int32, header_size: Int32) -> Image
Category: Image loading · raylib: LoadImageRaw
Load a headerless byte-plane image. format = PixelFormat variant ordinal.
val img = Image.load_raw("data.raw", Int32(256), Int32(256), Int32(4), Int32(0))
raylib cheatsheet ·
Iron source ·
Test usage
Image.load_anim(path: String) -> Image
Category: Image loading · raylib: LoadImageAnim
Load animated image (GIF) as a sequence of concatenated frames.
val anim = Image.load_anim("walk.gif")
raylib cheatsheet ·
Iron source ·
Test usage
Image.load_from_memory(file_type: String, file_data: [UInt8], data_size: Int32) -> Image
Category: Image loading · raylib: LoadImageFromMemory
Load image from in-memory byte buffer. file_type is the extension including dot (".png").
val img = Image.load_from_memory(".png", bytes, Int32(bytes.length))
raylib cheatsheet ·
Iron source ·
Test usage
Image.from_texture(tex: Texture) -> Image / Image.from_screen()
Category: Image loading · raylib: LoadImageFromTexture / LoadImageFromScreen
Read back GPU texture to CPU Image; capture current framebuffer.
val img = Image.from_texture(tex)
raylib cheatsheet ·
Iron source ·
Test usage
Image generation
Image.color(width, height: Int32, color: Color) -> Image
Category: Generation · raylib: GenImageColor
Solid-color procedural image.
val bg = Image.color(Int32(64), Int32(64), RAYWHITE)
raylib cheatsheet ·
Iron source ·
Test usage
Image.gradient_linear / gradient_radial / gradient_square
Category: Generation · raylib: GenImageGradient*
Linear, radial, square gradients between two colors.
val g = Image.gradient_linear(Int32(256), Int32(256), Int32(0), RED, BLUE)
raylib cheatsheet ·
Iron source ·
Test usage
Image.checked(width, height, checks_x, checks_y: Int32, c1, c2: Color) -> Image
Category: Generation · raylib: GenImageChecked
Checkerboard pattern. Used by raylib_showcase.iron for the TEX demo.
val board = Image.checked(Int32(256), Int32(256), Int32(16), Int32(16), red, white)
raylib cheatsheet ·
Iron source ·
Test usage
Image.white_noise / perlin_noise / cellular
Category: Generation · raylib: GenImageWhiteNoise / PerlinNoise / Cellular
Procedural noise textures. Perlin uses offset + scale; cellular uses tile size.
val noise = Image.perlin_noise(Int32(256), Int32(256), Int32(0), Int32(0), Float32(8.0))
raylib cheatsheet ·
Iron source ·
Test usage
Image.text(width, height: Int32, text: String) -> Image / Image.text_ex(font, text, fontSize, spacing, tint)
Category: Generation · raylib: ImageText / ImageTextEx
Render text into a new Image (default font or user-loaded Font).
val label = Image.text(Int32(128), Int32(32), "hello")
raylib cheatsheet ·
Iron source ·
Test usage
Image export
Image.export(img: Image, path: String) -> Bool / export_as_code / export_to_memory
Category: Export · raylib: ExportImage / ExportImageAsCode / ExportImageToMemory
Write image to disk (auto-detects format by extension); embed as C source; export to byte buffer.
Image.export(img, "out.png")
raylib cheatsheet ·
Iron source ·
Test usage
image.crop / resize / resize_nn / resize_canvas / to_pot
Category: Transforms · raylib: ImageCrop / Resize / ResizeNN / ResizeCanvas / ToPOT
Region crop, resample resize (linear or nearest-neighbour), pad canvas, next-power-of-2 pad.
var img = Image.resize(img, Int32(512), Int32(512))
raylib cheatsheet ·
Iron source ·
Test usage
image.flip_vertical / flip_horizontal / rotate / rotate_cw / rotate_ccw
Category: Transforms · raylib: ImageFlip / Rotate*
Flip and rotate in CPU. rotate accepts arbitrary degrees; rotate_cw / _ccw are 90° shortcuts.
var img = Image.flip_vertical(img)
raylib cheatsheet ·
Iron source ·
Test usage
image.color_tint / color_invert / color_grayscale / color_contrast / color_brightness / color_replace
Category: Transforms · raylib: ImageColor*
Per-pixel color operations on CPU. Chainable.
var img = Image.color_grayscale(img)
raylib cheatsheet ·
Iron source ·
Test usage
image.alpha_crop / alpha_clear / alpha_mask / alpha_premultiply / blur_gaussian / dither / mipmaps / format / kernel_convolution
Category: Transforms · raylib: ImageAlpha* / BlurGaussian / Dither / Mipmaps / Format / KernelConvolution
Alpha/gaussian/dither/mip/format/kernel ops. alpha_mask uses another Image as alpha source.
var img = Image.blur_gaussian(img, Int32(4))
raylib cheatsheet ·
Iron source ·
Test usage
Image.load_colors(img: Image) -> [Color] / load_palette / get_alpha_border / get_color
Category: Extraction · raylib: LoadImageColors / LoadImagePalette / GetImageAlphaBorder / GetImageColor
Extract all pixel colors; quantize palette; alpha bounding rect; pick single pixel.
val colors = Image.load_colors(img)
raylib cheatsheet ·
Iron source ·
Test usage
Image CPU draw
image.draw_pixel / draw_line / draw_circle / draw_rectangle / draw_triangle / draw / draw_text
Category: CPU draw · raylib: ImageDraw*
Rasterize into an Image in CPU — same primitive set as GPU Draw.* but pixel-exact, useful for atlases / offline baking.
var img = Image.draw_text(img, "label", Int32(10), Int32(10), Int32(20), BLACK)
raylib cheatsheet ·
Iron source ·
Test usage
Texture loading
Texture.load(path: String) -> Texture
Category: Texture loading · raylib: LoadTexture
Load image from file and upload to GPU in one step.
val tex = Texture.load("sprite.png")
raylib cheatsheet ·
Iron source ·
Test usage
Image.to_texture(img: Image) -> Texture
Category: Texture loading · raylib: LoadTextureFromImage
Upload an existing Image (CPU) to the GPU as a Texture.
val tex = Image.to_texture(img)
raylib cheatsheet ·
Iron source ·
Test usage
Texture.load_cubemap(img: Image, layout: CubemapLayout) -> Texture
Category: Texture loading · raylib: LoadTextureCubemap
Unpack 6-face cubemap from a single Image using CubemapLayout.
val cube = Texture.load_cubemap(img, CubemapLayout.CROSS_FOUR_BY_THREE)
raylib cheatsheet ·
Iron source ·
Test usage
RenderTexture.load(width, height: Int32) -> RenderTexture
Category: Texture loading · raylib: LoadRenderTexture
Allocate offscreen framebuffer. rt.texture is the color attachment.
val rt = RenderTexture.load(Int32(800), Int32(600))
raylib cheatsheet ·
Iron source ·
Test usage
Texture update
Texture.update(tex: Texture, pixels: Int) / update_rec(tex, rec, pixels)
Category: Update · raylib: UpdateTexture / UpdateTextureRec
Upload new pixel data to an existing texture — whole texture or a rectangle region.
Texture.update(tex, buffer_ptr)
raylib cheatsheet ·
Iron source ·
Test usage
Texture.set_filter(tex, filter: TextureFilter) / set_wrap(tex, wrap: TextureWrap) / gen_mipmaps(tex)
Category: Update · raylib: SetTextureFilter / SetTextureWrap / GenTextureMipmaps
Configure texture sampler. POINT filter for pixel-art; BILINEAR for smoother.
Texture.set_filter(tex, TextureFilter.POINT)
raylib cheatsheet ·
Iron source ·
Test usage
Texture draw
Texture.draw(tex, x, y, tint: Color)
Category: Draw · raylib: DrawTexture
Draw texture at integer screen position.
Texture.draw(tex, Int32(100), Int32(100), WHITE)
raylib cheatsheet ·
Iron source ·
Test usage
Texture.draw_v / draw_ex / draw_rec / draw_pro / draw_n_patch
Category: Draw · raylib: DrawTextureV / Ex / Rec / Pro / NPatch
Vector2 pos (_v); rotation + scale (_ex); source region (_rec); source + dest + origin + rotation (_pro); n-patch UI scale (_n_patch).
Texture.draw_rec(rt.texture, src, pos, WHITE)
raylib cheatsheet ·
Iron source ·
Test usage
Color math
Color.is_equal(c, other) -> Bool / fade(c, alpha: Float32) / to_int / to_hsv / from_hsv / from_int / tint / lerp
Category: Color math · raylib: ColorIsEqual / Fade / ToInt / ToHSV / FromHSV / Tint / Lerp
Predicate, alpha fade, int hex pack/unpack, HSV roundtrip, tint/lerp between two colors.
val ghost = Color.fade(RED, Float32(0.5))
val hsv = Color.to_hsv(BLUE)
raylib cheatsheet ·
Iron source ·
Test usage
Color.normalize(c) -> Vector4 / from_normalized(v: Vector4)
Category: Color math · raylib: ColorNormalize / ColorFromNormalized
Convert [0..255] byte channels to [0..1] float Vector4 (and back) — essential for shader uniforms.
val n = Color.normalize(RED)
raylib cheatsheet ·
Iron source ·
Test usage
Color.brightness(c, factor: Float32) / contrast(c, contrast: Float32) / alpha(c, alpha: Float32) / alpha_blend(dst, src, tint: Color)
Category: Color math · raylib: ColorBrightness / Contrast / Alpha / AlphaBlend
Single-channel adjustments + manual alpha blend.
val brighter = Color.brightness(c, Float32(0.2))
raylib cheatsheet ·
Iron source ·
Test usage
Color.from_pixel_data(data: Int, format: PixelFormat) / to_pixel_data / pixel_data_size(w, h, format)
Category: Color math · raylib: GetPixelColor / SetPixelColor / GetPixelDataSize
Low-level pixel read/write + per-format byte size.
val bytes = Color.pixel_data_size(Int32(256), Int32(256), PixelFormat.UNCOMPRESSED_R8G8B8A8)
raylib cheatsheet ·
Iron source ·
Test usage
Color palette
26 predeclared color constants in raylib.iron:
LIGHTGRAY, GRAY, DARKGRAY
Category: Palette · raylib: LIGHTGRAY / GRAY / DARKGRAY
Gray ramp. LIGHTGRAY = Color(200, 200, 200, 255), GRAY = Color(130, 130, 130, 255), DARKGRAY = Color(80, 80, 80, 255).
Draw.clear(DARKGRAY)
raylib cheatsheet ·
Iron source ·
Test usage
YELLOW, GOLD, ORANGE, PINK, RED, MAROON
Category: Palette · raylib: YELLOW / GOLD / ORANGE / PINK / RED / MAROON
Warm tones. YELLOW = Color(253, 249, 0, 255), RED = Color(230, 41, 55, 255), MAROON = Color(190, 33, 55, 255).
Draw.rectangle(0, 0, 100, 100, RED)
raylib cheatsheet ·
Iron source ·
Test usage
GREEN, LIME, DARKGREEN
Category: Palette · raylib: GREEN / LIME / DARKGREEN
Greens. GREEN = Color(0, 228, 48, 255), DARKGREEN = Color(0, 117, 44, 255).
Draw.circle(400, 300, Float32(30.0), LIME)
raylib cheatsheet ·
Iron source ·
Test usage
SKYBLUE, BLUE, DARKBLUE
Category: Palette · raylib: SKYBLUE / BLUE / DARKBLUE
Blues. SKYBLUE = Color(102, 191, 255, 255), BLUE = Color(0, 121, 241, 255).
Draw.clear(SKYBLUE)
raylib cheatsheet ·
Iron source ·
Test usage
PURPLE, VIOLET, DARKPURPLE
Category: Palette · raylib: PURPLE / VIOLET / DARKPURPLE
Purple/violet ramp. PURPLE = Color(200, 122, 255, 255).
Draw.text("title", 10, 10, 32, VIOLET)
raylib cheatsheet ·
Iron source ·
Test usage
BEIGE, BROWN, DARKBROWN
Category: Palette · raylib: BEIGE / BROWN / DARKBROWN
Earth tones. BEIGE = Color(211, 176, 131, 255), BROWN = Color(127, 106, 79, 255).
Draw.rectangle(0, 500, 800, 100, BROWN)
raylib cheatsheet ·
Iron source ·
Test usage
WHITE, BLACK, BLANK, MAGENTA, RAYWHITE
Category: Palette · raylib: WHITE / BLACK / BLANK / MAGENTA / RAYWHITE
Core constants. WHITE = Color(255, 255, 255, 255), BLACK = Color(0, 0, 0, 255), BLANK = Color(0, 0, 0, 0) (transparent), MAGENTA = Color(255, 0, 255, 255), RAYWHITE = Color(245, 245, 245, 255) (raylib's signature off-white clear color).
Draw.clear(RAYWHITE)
Draw.text("hi", 10, 10, 20, BLACK)
raylib cheatsheet ·
Iron source ·
Test usage
See also