-
Notifications
You must be signed in to change notification settings - Fork 7
Image
Refaltor77 edited this page Mar 29, 2026
·
2 revisions
Image/texture display element with extensive options.
use refaltor\ui\elements\Image;
$image = Image::create("my_image", "textures/ui/my_texture");Note: Texture paths do NOT include the
.pngextension.
Stretches the center while preserving border pixels:
$image->setNinesliceSize(4); // Uniform border
$image->setNinesliceSize([4, 4, 4, 4]); // Per-side [top, left, bottom, right]$image->setTiled(true); // Enable tiling
$image->setTiled("x"); // Tile horizontally only
$image->setTiledScale([2.0, 2.0]); // Scale of tiles$image->setUv([16, 16]); // Offset into sprite sheet
$image->setUvSize([16, 16]); // Size to crop$image->setClipDirection("left"); // left, right, up, down, center
$image->setClipRatio(0.5); // 0.0 = full, 1.0 = hidden
$image->setClipPixelPerfect(true);$image->setKeepRatio(true); // Maintain aspect ratio
$image->setBilinear(true); // Bilinear filtering
$image->setFill(true); // Fill mode
$image->setFitToWidth(true); // Fit to container width
$image->setGrayscale(true); // Grayscale filter
$image->setForceTextureReload(true); // Force reload
$image->setBaseSize([64, 64]); // Base size reference$image->setTextureFileSystem("InUserPackage"); // Default
$image->setZipFolder("skin_packs/my_pack"); // From zip// Background with 9-slice
$bg = Image::create("dialog_bg", "textures/ui/dialog_background_opaque")
->setSizePercentage(100, 100)
->setNinesliceSize(4)
->setKeepRatio(false)
->setLayer(-1);
// Sprite from a sheet
$icon = Image::create("heart_icon", "textures/ui/icons")
->setUv([16, 0])
->setUvSize([9, 9])
->setSize(18, 18)
->setKeepRatio(true);
// Tiled pattern
$pattern = Image::create("bg_pattern", "textures/ui/grid_pattern")
->setTiled(true)
->setTiledScale([2.0, 2.0])
->setSizePercentage(100, 100);