Antra

Standardbibliothek

Antra::Raylib::Textures

import Antra::Raylib::Textures

raylib's textures module for Antra: images (CPU side: loading, generating, editing, drawing into them, saving), textures and render textures (GPU side: loading, configuring, drawing) and color helpers.

Cheatsheet: module rtextures, https://www.raylib.com/cheatsheet/cheatsheet.html.

Images, textures and render textures are raylib's structs as maps (image.width, texture.height, ...); pass them back unchanged. Functions that change an image return the changed image - keep that one, the one passed in must not be used afterwards: img = Textures.image_resize(app, img, 64, 64). Drawing into an image uses the names of Antra::Raylib::Shapes with an image_ prefix. Positions are [x, y], rectangles [x, y, width, height]; colors are [r, g, b], [r, g, b, a] or raylib's names. Every function except the color helpers takes the app from Core.window first.

import Antra::Raylib::Core
import Antra::Raylib::Textures         # or: import Antra::Raylib::Textures as Tex

val app = Core.window("Textures", 320, 200).!
val bunny = Textures.load_texture(app, "raybunny.png").!
Core.run(app, 0) |app, angle, _dt| -> {
    app |> Core.clear(:raywhite)
        |> Textures.draw_texture_ex(bunny, [160, 100], [rotation: angle, scale: 3])
    angle + 1
}
Textures.unload_texture(app, bunny)
Core.close(app)

Funktionen#

fn color_alpha_blend(dst, src, tint)

src, colored by tint, blended over dst by its alpha (raylib: ColorAlphaBlend).

Example:

Textures.color_alpha_blend(:white, Textures.fade(:black, 0.5), :white)   # about [127, 127, 127, 255]
fn color_brightness(color, factor)

color made brighter (factor up to 1) or darker (down to -1) (raylib: ColorBrightness).

Example:

Textures.color_brightness([100, 100, 100], -0.5)   # => [50, 50, 50, 255]
fn color_contrast(color, contrast)

color with more (contrast up to 1) or less (down to -1) contrast (raylib: ColorContrast).

fn color_from_normalized(values)

The color for four numbers from 0 to 1, [r, g, b, a] (raylib: ColorFromNormalized).

Example:

Textures.color_from_normalized([1, 0, 0.2, 1])   # => [255, 0, 51, 255]
fn color_lerp(from, to, t)

Returns the color a fraction t (0..1, clamped) of the way from from to to, as [r, g, b, a] (raylib: ColorLerp).

Example:

Textures.color_lerp(:black, :white, 0.5)   # => [127, 127, 127, 255]
fn color_normalize(color)

A color as four numbers from 0 to 1, [r, g, b, a] (raylib: ColorNormalize) - e.g. for a shader's vec4.

Example:

Textures.color_normalize([255, 0, 51, 255])   # => [1, 0, 0.2, 1]
fn color_tint(color, tint)

color multiplied with tint (raylib: ColorTint).

Example:

Textures.color_tint(:white, [255, 0, 0])   # => [255, 0, 0, 255]
fn color_to_hex(color)

Converts a color to its hexadecimal value 0xRRGGBBAA (raylib: ColorToInt).

Example:

Textures.color_to_hex([255, 0, 0, 128])   # => 4278190208 (0xff000080)
fn color_to_hsv(color)

Converts a color to hue (0..360 degrees), saturation and value (0..1), [h, s, v] (raylib: ColorToHSV).

Example:

Textures.color_to_hsv([255, 0, 0])   # => [0, 1, 1]
fn cubemap_from_image(app, image, [layout: = :auto])

Uploads an image with the six faces of a cube as a cubemap texture, for skyboxes; layout: how the faces are arranged: :auto (default), :line_vertical, :line_horizontal, :cross_three_by_four, :cross_four_by_three (raylib: LoadTextureCubemap). %Ok[texture] or %Err[...].

Example:

val sky = Textures.cubemap_from_image(app, Textures.load_image(app, "skybox.png").!).!
fn draw_npatch(app, texture, patch, dest, [origin: = [0, 0], rotation: = 0, tint: = :white])

Draws a texture that stretches without distorting its borders - a button or a panel - into dest (raylib: DrawTextureNPatch). The patch names the part source: of the texture and its fixed borders left:, top:, right:, bottom: (all 0); layout: is :nine_patch (default, 3x3), :three_patch_vertical or :three_patch_horizontal. Options: origin:, rotation:, tint:. Returns app.

Example:

val ninepatch = Textures.load_texture(app, "ninepatch_button.png").!
Textures.draw_npatch(app, ninepatch, [source: [0, 0, 64, 64], left: 12, top: 40, right: 12, bottom: 12],
                     [100, 100, 200, 120])
fn draw_target(app, target, pos, [tint: = :white])

Draws a render texture from render_texture upright at pos [x, y] (OpenGL stores it upside down; raylib: DrawTextureRec with a flipped source); returns app.

Example:

val target = Textures.render_texture(app, 160, 100).!
Core.with_target(app, target) |app| -> Shapes.circle(app, [80, 50], 30, :red)
Textures.draw_target(app, target, [0, 0], [tint: :white])
fn draw_texture(app, texture, pos, [tint: = :white])

Draws a texture with its top-left corner at [x, y], colored by tint: (:white = unchanged) (raylib: DrawTextureV); returns app.

Example:

val bunny = Textures.load_texture(app, "raybunny.png").!
Textures.draw_texture(app, bunny, [10, 10])
Textures.draw_texture(app, bunny, [50, 10], [tint: Textures.fade(:white, 0.5)])
fn draw_texture_ex(app, texture, pos, [rotation: = 0, scale: = 1, tint: = :white])

Draws a texture at pos [x, y], rotated by rotation: degrees around its top-left corner and scaled by scale:, colored by tint: (raylib: DrawTextureEx); returns app.

Example:

val bunny = Textures.load_texture(app, "raybunny.png").!
Textures.draw_texture_ex(app, bunny, [100, 50], [rotation: 45, scale: 2])
fn draw_texture_pro(app, texture, source, dest, [origin: = [0, 0], rotation: = 0, tint: = :white])

Draws the part source of a texture stretched into the rectangle dest, rotated by rotation: degrees around origin: (relative to dest), colored by tint: (raylib: DrawTexturePro); returns app.

Example:

val bunny = Textures.load_texture(app, "raybunny.png").!
# 64x64 on screen, spinning around its center at [160, 100]
Textures.draw_texture_pro(app, bunny, [0, 0, 32, 32], [160, 100, 64, 64], [origin: [32, 32], rotation: 30])
fn draw_texture_rec(app, texture, source, pos, [tint: = :white])

Draws the part source [x, y, w, h] of a texture at pos - one frame of a sprite sheet; a negative width or height mirrors it (raylib: DrawTextureRec). Returns app.

Example:

val sheet = Textures.load_texture(app, "cubicmap_atlas.png").!
Textures.draw_texture_rec(app, sheet, [0, 0, 128, 128], [10, 10])
fn export_image(app, image, path)

Saves an image; the format comes from the file extension (.png, .bmp, .qoi, ...) (raylib: ExportImage): %Ok[path] or %Err[...].

Example:

val img = Textures.image_checked(app, 64, 64, 8, 8, :black, :white)
Textures.export_image(app, img, "checker.png").!
fn fade(color, alpha)

Returns color as [r, g, b, a] with its alpha scaled by alpha (0..1) (raylib: Fade).

Example:

Textures.fade(:red, 0.5)       # => [230, 41, 55, 127]
fn hex(value)

Converts a hexadecimal 0xRRGGBBAA value to [r, g, b, a] (raylib: GetColor).

Example:

Textures.hex(0xff000080)       # => [255, 0, 0, 128]
fn hsv(hue, saturation, value)

Converts hue (0..360 degrees), saturation and value (0..1) to [r, g, b, a] (raylib: ColorFromHSV).

Example:

Textures.hsv(0, 1, 1)          # => [255, 0, 0, 255]
fn image_alpha_border(app, image, threshold)

The rectangle [x, y, w, h] around the pixels whose alpha is above threshold (0..1) (raylib: GetImageAlphaBorder).

fn image_alpha_clear(app, image, color, threshold)

Paints every pixel whose alpha is at most threshold (0..1) with color (raylib: ImageAlphaClear). Returns the image.

fn image_alpha_crop(app, image, threshold)

Crops away the border whose alpha is at most threshold (0..1) (raylib: ImageAlphaCrop). Returns the image.

Example:

img = Textures.image_alpha_crop(app, img, 0)
fn image_alpha_mask(app, image, mask)

Uses the brightness of mask as the image's alpha channel (raylib: ImageAlphaMask). Returns the image.

Example:

img = Textures.image_alpha_mask(app, img, Textures.load_image(app, "mask.png").!)
fn image_alpha_premultiply(app, image)

Multiplies the color channels by the alpha channel (raylib: ImageAlphaPremultiply). Returns the image.

fn image_anim_frame(app, %{image:, frames:, ..}, index)

The pixel data of frame index (0-based, wrapping around) of an animation from load_image_anim, as a ByteString in the image's pixel format - for update_texture (raylib: the frames lie one after another in the image data).

Example:

val anim = Textures.load_image_anim(app, "scarfy_run.gif").!
val texture = Textures.texture_from_image(app, anim.image)
Textures.update_texture(app, texture, Textures.image_anim_frame(app, anim, 3))
fn image_blur(app, image, size)

Blurs an image by size pixels (raylib: ImageBlurGaussian). Returns the image.

Example:

img = Textures.image_blur(app, img, 4)
fn image_brightness(app, image, brightness)

Changes the brightness by brightness (-255..255) (raylib: ImageColorBrightness). Returns the image.

fn image_cellular(app, width, height, tile_size)

Generates cellular (Worley) noise with cells of tile_size pixels (raylib: GenImageCellular).

Example:

val cells = Textures.image_cellular(app, 128, 128, 16)
fn image_channel(app, image, channel)

Returns a new grayscale image from one channel, :r, :g, :b or :a (raylib: ImageFromChannel).

Example:

val alpha = Textures.image_channel(app, img, :a)
fn image_checked(app, width, height, cx, cy, c1, c2)

Generates a checkerboard image with cx x cy squares in colors c1 and c2 (raylib: GenImageChecked).

Example:

val board = Textures.image_checked(app, 64, 64, 8, 8, :black, :white)
fn image_circle(app, image, center, radius, color)

Draws a filled circle into an image (raylib: ImageDrawCircleV). Returns the image.

Example:

val dot = Textures.image_circle(app, Textures.image_color(app, 32, 32, :blank), [16, 16], 12, :red)
fn image_circle_gradient(app, image, center, radius, inner, outer)

Draws a circle fading from inner to outer into an image (raylib: ImageDrawCircleGradient). Returns the image.

fn image_circle_lines(app, image, center, radius, color)

Draws a circle outline into an image (raylib: ImageDrawCircleLinesV). Returns the image.

fn image_clear(app, image, color)

Fills an image with color (raylib: ImageClearBackground). Returns the image.

fn image_color(app, width, height, color)

Generates a width x height image filled with one color (raylib: GenImageColor).

Example:

val red = Textures.image_color(app, 16, 16, :red)
fn image_colors(app, image)

Returns the image's pixels as %RaylibCapture{width:, height:, rgba:} with RGBA bytes (width * height * 4, top row first) (raylib: LoadImageColors); Core.pixel reads single pixels from it.

Example:

val px = Textures.image_colors(app, Textures.image_color(app, 2, 2, :red))
Core.pixel(px, [1, 1])         # => [230, 41, 55, 255]
fn image_contrast(app, image, contrast)

Changes the contrast by contrast (-100..100) (raylib: ImageColorContrast). Returns the image.

fn image_convolve(app, image, kernel)

Applies a square convolution kernel, a flat list of n x n numbers (raylib: ImageKernelConvolution). Returns the image.

Example:

val sharpen = [0, -1, 0, -1, 5, -1, 0, -1, 0]
img = Textures.image_convolve(app, img, sharpen)
fn image_copy(app, image)

Returns an independent copy of an image (raylib: ImageCopy).

Example:

val backup = Textures.image_copy(app, img)
fn image_crop(app, image, r)

Returns a new image from the part r [x, y, w, h] of image (raylib: ImageFromImage); the original stays as it is.

Example:

val atlas = Textures.load_image(app, "cubicmap_atlas.png").!
val tile = Textures.image_crop(app, atlas, [0, 0, 128, 128])
tile.width                     # => 128
fn image_dither(app, image, [r, g, b, a])

Reduces an image to [r, g, b, a] bits per channel with Floyd-Steinberg dithering (raylib: ImageDither). Returns the image.

Example:

img = Textures.image_dither(app, img, [4, 4, 4, 4])
fn image_draw(app, image, source_image, pos, [source: = undef, scale: = 1, rotation: = 0, tint: = :white])

Draws the image source_image into image at pos - all of it, or the part source: [x, y, w, h] - scaled by scale:, rotated by rotation: degrees, colored by tint: (raylib: ImageDrawImageEx, ImageDrawImagePro). Returns the image.

Example:

canvas = Textures.image_draw(app, canvas, logo, [10, 10], [scale: 0.5])
fn image_draw_pro(app, image, source_image, source, dest, [origin: = [0, 0], rotation: = 0, tint: = :white])

Draws the part source of source_image stretched into the rectangle dest of image, rotated by rotation: degrees around origin: (raylib: ImageDrawImagePro). Returns the image.

fn image_draw_text(app, image, text, pos, size, color, [font: = undef, spacing: = undef, rotation: = 0,
    origin: = [0, 0]])

Writes text into an image at pos, size pixels high (raylib: ImageDrawText). Options: font: from Text.load_font (raylib's default font), spacing: between the letters (default font: size / 10, others: 1), rotation: in degrees (0) around origin: ([0, 0], relative to pos) - drawn as a text image (raylib: ImageTextEx + ImageDrawImagePro; raylib 6.2's ImageDrawTextPro draws nothing). Returns the image.

Example:

img = Textures.image_draw_text(app, img, "42", [4, 4], 20, :black)
img = Textures.image_draw_text(app, img, "tilted", [30, 30], 20, :maroon, [rotation: 30])
fn image_flip(app, image, direction)

Mirrors an image, :vertical (upside down - e.g. one read back from a render texture, which OpenGL stores bottom row first) or :horizontal (raylib: ImageFlipVertical, ImageFlipHorizontal). Returns the image.

Example:

val canvas = Textures.render_texture(app, 320, 200).!
val image = Textures.image_flip(app, Textures.image_from_texture(app, canvas.texture), :vertical)
fn image_format(app, image, format)

Converts an image to another pixel format: :grayscale, :gray_alpha, :r5g6b5, :r8g8b8, :r5g5b5a1, :r4g4b4a4, :r8g8b8a8, :r32, :r32g32b32, :r32g32b32a32, :r16, :r16g16b16, :r16g16b16a16 (raylib: ImageFormat). Returns the image.

Example:

img = Textures.image_format(app, img, :grayscale)
fn image_from_bytes(app, bytes, file_type)

Decodes an image from bytes in memory, a ByteString holding a file of type file_type (".png", ".qoi", ...) (raylib: LoadImageFromMemory): %Ok[image] or %Err[...].

Example:

import Antra::Bytes

val img = Textures.image_from_bytes(app, Bytes.from_file("icon.png").!, ".png").!
fn image_from_text(app, text, size, color, [font: = undef, spacing: = 1])

Renders text into a new image just big enough for it, with raylib's default font (raylib: ImageText) or a font: from Text.load_font with spacing: (1) between the letters (raylib: ImageTextEx).

Example:

val label = Textures.image_from_text(app, "Hello", 20, :maroon)
fn image_from_texture(app, texture)

Reads a texture back from the GPU into a new image (raylib: LoadImageFromTexture).

Example:

val tex = Textures.texture_from_image(app, Textures.image_color(app, 8, 4, :gold))
val img = Textures.image_from_texture(app, tex)
[img.width, img.height]        # => [8, 4]
fn image_gradient(app, width, height, from, to, [angle: = 0])

Generates a linear gradient image from from to to; angle: in degrees (0 = top to bottom) (raylib: GenImageGradientLinear).

Example:

val sky = Textures.image_gradient(app, 320, 200, :skyblue, :white)
val side = Textures.image_gradient(app, 320, 200, :red, :blue, [angle: 90])
fn image_gradient_radial(app, width, height, density, inner, outer)

Generates a radial gradient image; density (0..1) is how far inner reaches before it fades to outer (raylib: GenImageGradientRadial).

Example:

val glow = Textures.image_gradient_radial(app, 64, 64, 0, :white, :black)
fn image_gradient_square(app, width, height, density, inner, outer)

Generates a square gradient image; density (0..1) is how far inner reaches (raylib: GenImageGradientSquare).

Example:

val frame = Textures.image_gradient_square(app, 64, 64, 0.5, :gold, :brown)
fn image_grayscale(app, image)

Turns the colors into shades of gray (raylib: ImageColorGrayscale). Returns the image.

fn image_invert(app, image)

Inverts the colors (raylib: ImageColorInvert). Returns the image.

fn image_line(app, image, from, to, color, [thick: = undef])

Draws a line into an image, one pixel wide (raylib: ImageDrawLineV) or thick: pixels (raylib: ImageDrawLineEx). Returns the image.

Example:

img = Textures.image_line(app, img, [0, 0], [31, 31], :red, [thick: 2])
fn image_line_strip(app, image, points, color)

Draws one-pixel lines through a list of points into an image (raylib: ImageDrawLineStrip). Returns the image.

fn image_mipmaps(app, image)

Computes all mipmap levels of an image (raylib: ImageMipmaps). Returns the image.

fn image_palette(app, image, max)

The different colors of an image, at most max of them, as [r, g, b, a] (raylib: LoadImagePalette).

Example:

Textures.image_palette(app, Textures.image_color(app, 4, 4, :red), 8)   # => [[230, 41, 55, 255]]
fn image_perlin_noise(app, width, height, [offset_x, offset_y], scale)

Generates Perlin noise starting at [offset_x, offset_y], zoomed by scale (raylib: GenImagePerlinNoise).

Example:

val clouds = Textures.image_perlin_noise(app, 128, 128, [0, 0], 4)
fn image_pixel(app, image, [x, y])

The color [r, g, b, a] of the pixel at [x, y] (raylib: GetImageColor).

Example:

Textures.image_pixel(app, Textures.image_color(app, 4, 4, :red), [1, 2])   # => [230, 41, 55, 255]
fn image_pixel_at(app, image, point, color)

Sets one pixel [x, y] of an image (raylib: ImageDrawPixelV). Returns the image.

fn image_rect(app, image, r, color)

Draws a filled rectangle [x, y, w, h] into an image (raylib: ImageDrawRectangleRec). Returns the image.

Example:

my img = Textures.image_color(app, 32, 32, :white)
img = Textures.image_rect(app, img, [8, 8, 16, 16], :blue)
fn image_rect_gradient(app, image, r, [top_left, bottom_left, bottom_right, top_right])
fn image_rect_gradient(app, image, r, from, to, [direction: = :vertical])

Draws a rectangle filled with a gradient into an image, like Shapes.rect_gradient: from from to to (direction: :vertical or :horizontal) or one color per corner, [top_left, bottom_left, bottom_right, top_right] (raylib: ImageDrawRectangleGradientEx). Returns the image.

fn image_rect_lines(app, image, r, color, [thick: = 1])

Draws a rectangle outline into an image, thick: (1) pixels wide (raylib: ImageDrawRectangleLinesEx). Returns the image.

fn image_rect_pro(app, image, r, origin, rotation, color)

Draws a rectangle rotated by rotation degrees around origin into an image (raylib: ImageDrawRectanglePro). Returns the image.

fn image_replace_color(app, image, color, replacement)

Replaces every pixel of color with replacement (raylib: ImageColorReplace). Returns the image.

Example:

img = Textures.image_replace_color(app, img, :white, :blank)
fn image_resize(app, image, width, height, [filter: = :bicubic])

Scales an image to width x height: smooth with filter: :bicubic (default, raylib: ImageResize) or blocky with :nearest, for pixel art (raylib: ImageResizeNN). Returns the image.

Example:

img = Textures.image_resize(app, img, 64, 64, [filter: :nearest])
fn image_resize_canvas(app, image, width, height, [offset: = [0, 0], fill: = :blank])

Changes an image's canvas to width x height, keeping the pixels at offset: ([0, 0]) and filling the rest with fill: (:blank) (raylib: ImageResizeCanvas). Returns the image.

Example:

img = Textures.image_resize_canvas(app, img, 64, 64, [offset: [16, 16], fill: :white])
fn image_rotate(app, image, degrees)

Rotates an image by degrees (positive = clockwise); the image grows to hold the rotated corners and fills the rest with zero bytes (transparent, or black in an image without alpha) (raylib: ImageRotate). Returns the image.

Example:

my logo = Textures.load_image(app, "raylib_logo.png").!
logo = Textures.image_rotate(app, logo, 90)
fn image_tint(app, image, color)

Multiplies every pixel with color (raylib: ImageColorTint). Returns the image.

fn image_to_bytes(app, image, file_type)

Encodes an image as a file of type file_type (".png", ".qoi", ...) in memory (raylib: ExportImageToMemory): %Ok[bytes] with a ByteString, or %Err[...].

Example:

val png = Textures.image_to_bytes(app, img, ".png").!
fn image_to_pot(app, image, fill)

Grows an image to the next power-of-two size, filling the new pixels with fill (raylib: ImageToPOT). Returns the image.

fn image_triangle(app, image, p1, p2, p3, color)

Draws a filled triangle into an image; corners in counter-clockwise order (raylib: ImageDrawTriangle). Returns the image.

fn image_triangle_fan(app, image, points, color)

Draws a triangle fan (the first point is the center) into an image (raylib: ImageDrawTriangleFan). Returns the image.

fn image_triangle_gradient(app, image, p1, p2, p3, c1, c2, c3)

Draws a triangle whose colors blend from corner to corner into an image (raylib: ImageDrawTriangleGradient). Returns the image.

fn image_triangle_lines(app, image, p1, p2, p3, color)

Draws a triangle outline into an image (raylib: ImageDrawTriangleLines). Returns the image.

fn image_triangle_strip(app, image, points, color)

Draws a triangle strip into an image (raylib: ImageDrawTriangleStrip). Returns the image.

fn image_white_noise(app, width, height, factor)

Generates black and white noise; factor (0..1) is the share of white pixels (raylib: GenImageWhiteNoise).

Example:

val noise = Textures.image_white_noise(app, 64, 64, 0.5)
fn load_image(app, path)

Loads an image file (PNG, JPG, BMP, TGA, GIF, QOI, ...) into CPU memory (raylib: LoadImage): %Ok[image] or %Err[...] when it cannot be loaded. Free it with unload_image.

Example:

val img = Textures.load_image(app, "raybunny.png").!
[img.width, img.height]        # => [32, 32]
fn load_image_anim(app, path)

Loads all frames of an animated GIF (raylib: LoadImageAnim): %Ok[%{image:, frames:}] or %Err[...]. The image has the size of one frame; its pixel data holds all frames one after another (RGBA, each width * height * 4 bytes). Show frame i by updating a texture with the pixels at image.data plus i * width * height * 4.

Example:

val %{image:, frames:} = Textures.load_image_anim(app, "scarfy_run.gif").!
fn load_image_raw(app, path, width, height, format, [header: = 0])

Loads raw pixel data from a file: width x height pixels in format (:r8g8b8a8, :grayscale, ... - see image_format), after header: (0) bytes (raylib: LoadImageRaw). %Ok[image] or %Err[...].

Example:

val img = Textures.load_image_raw(app, "fudesumi.raw", 384, 512, :r8g8b8a8).!
fn load_texture(app, path)

Loads an image file straight into a GPU texture (raylib: LoadTexture): %Ok[texture] or %Err[...]. Free it with unload_texture.

Example:

val bunny = Textures.load_texture(app, "raybunny.png").!
Textures.draw_texture(app, bunny, [10, 10])
fn render_texture(app, width, height, [format: = undef])

Creates an off-screen drawing target of width x height pixels, with format: (see image_format) for its color buffer (raylib: LoadRenderTexture, LoadRenderTextureEx): %Ok[target] or %Err[...]. Draw into it with Core.with_target, show it with draw_target.

Example:

val target = Textures.render_texture(app, 160, 100).!
Core.with_target(app, target) |app| -> Core.clear(app, :skyblue)
Textures.draw_target(app, target, [80, 50])
fn texture_filter(app, texture, filter)

Sets how a texture is scaled: :point (sharp pixels, for pixel art), :bilinear or :trilinear (raylib: SetTextureFilter); returns app.

Example:

val bunny = Textures.load_texture(app, "raybunny.png").!
Textures.texture_filter(app, bunny, :bilinear)
fn texture_from_image(app, image)

Uploads an image to the GPU as a texture (raylib: LoadTextureFromImage); the image can be unloaded afterwards.

Example:

val img = Textures.image_checked(app, 64, 64, 8, 8, :black, :white)
val tex = Textures.texture_from_image(app, img)
Textures.unload_image(app, img)
fn texture_mipmaps(app, texture)

Generates the mipmaps of a texture on the GPU, for smooth scaling down with :trilinear (raylib: GenTextureMipmaps). Returns the updated texture.

Example:

tex = Textures.texture_mipmaps(app, tex)
Textures.texture_filter(app, tex, :trilinear)
fn texture_wrap(app, texture, wrap)

Sets what a texture shows outside its 0..1 coordinates: :repeat, :clamp, :mirror_repeat or :mirror_clamp (raylib: SetTextureWrap); returns app.

Example:

val tiles = Textures.load_texture(app, "texel_checker.png").!
Textures.texture_wrap(app, tiles, :repeat)
fn unload_image(app, image)

Frees an image (raylib: UnloadImage); returns app.

fn unload_render_texture(app, target)

Frees a render texture (raylib: UnloadRenderTexture); returns app.

fn unload_texture(app, texture)

Frees a texture (raylib: UnloadTexture); returns app.

fn update_texture(app, texture, pixels, [rect: = undef])

Replaces the pixels of a texture with pixels, a ByteString in the texture's format - RGBA bytes (width * height * 4, top row first) for a texture made from a generated image (raylib: UpdateTexture); with rect: [x, y, w, h] only that part (raylib: UpdateTextureRec). Returns app. For pictures computed pixel by pixel every frame.

Example:

import Antra::Bytes
val tex = Textures.texture_from_image(app, Textures.image_color(app, 2, 1, :black))
Textures.update_texture(app, tex, Bytes.from_list([255, 0, 0, 255, 0, 0, 255, 255]))

Quelle dieser Seite