atlas

    Asset management for MoonBit: image repositories, atlas allocation, source-image bindings, codec wrappers, and a fetcher abstraction (extracted from kagura)

    Download zip
    Author
    Version
    0.6.0
    License
    Apache-2.0
    Last updated
    15 days ago
    Downloads
    58

    mizchi/atlas does not have a README file

    AtlasAllocator

    pub trait AtlasAllocator {
    fn allocate(Self, width : Int, height : Int) -> AtlasRegion?
    fn release(Self, region : AtlasRegion) -> Unit
    }

    ImageRepository

    pub trait ImageRepository {
    fn create_image(Self, key : AssetKey, spec : ImageSpec) ->
    ImageHandle
    raise
    fn get_image(Self, key : AssetKey) ->
    ImageHandle
    ?
    fn remove_image(Self, key : AssetKey) -> Unit raise
    }

    MaterialRepository

    pub trait MaterialRepository {
    fn register_material(Self, key : AssetKey, spec : MaterialSpec) -> Unit raise
    fn get_material(Self, key : AssetKey) -> MaterialSpec?
    }

    ShaderRepository

    pub trait ShaderRepository {
    fn create_shader(Self, key : AssetKey, spec : ShaderSpec) ->
    ShaderHandle
    raise
    fn get_shader(Self, key : AssetKey) ->
    ShaderHandle
    ?
    fn remove_shader(Self, key : AssetKey) -> Unit raise
    }

    AssetKey

    pub struct AssetKey {
    value : String
    } derive(
    Debug
    )

    impl Show for AssetKey

    AssetKey::output

    fn AssetKey::output(self : AssetKey, logger : &Logger) -> Unit

    AssetKey::to_repr

    AssetKey::to_string

    fn AssetKey::to_string(self : AssetKey) -> String

    AtlasCompactResult

    pub struct AtlasCompactResult {
    removed_page_ids : Array[Int]
    removed_page_count : Int
    remaining_page_count : Int
    } derive(
    Debug
    )

    AtlasCompactResult::output

    fn AtlasCompactResult::output(self : AtlasCompactResult, logger : &Logger) -> Unit

    AtlasCompactResult::to_string

    fn AtlasCompactResult::to_string(self : AtlasCompactResult) -> String

    AtlasDrawSource

    pub struct AtlasDrawSource {
    page_image_id : Int
    region : AtlasRegion
    u0 : Double
    v0 : Double
    u1 : Double
    v1 : Double
    } derive(
    Debug
    )

    AtlasDrawSource::output

    fn AtlasDrawSource::output(self : AtlasDrawSource, logger : &Logger) -> Unit

    AtlasDrawSource::to_string

    fn AtlasDrawSource::to_string(self : AtlasDrawSource) -> String

    AtlasPageStats

    pub struct AtlasPageStats {
    atlas_id : Int
    image_count : Int
    allocated_region_count : Int
    atlas_width : Int
    atlas_height : Int
    is_empty : Bool
    } derive(
    Debug
    )

    AtlasPageStats::output

    fn AtlasPageStats::output(self : AtlasPageStats, logger : &Logger) -> Unit

    AtlasPageStats::to_string

    fn AtlasPageStats::to_string(self : AtlasPageStats) -> String

    AtlasRegion

    pub struct AtlasRegion {
    x : Int
    y : Int
    width : Int
    height : Int
    atlas_id : Int
    } derive(
    Debug
    )

    impl Show for AtlasRegion

    AtlasRegion::output

    fn AtlasRegion::output(self : AtlasRegion, logger : &Logger) -> Unit

    AtlasRegion::to_string

    fn AtlasRegion::to_string(self : AtlasRegion) -> String

    ImagePalette2x2

    pub struct ImagePalette2x2 {
    p00 : Rgba
    p10 : Rgba
    p01 : Rgba
    p11 : Rgba
    } derive(
    Debug
    )

    ImagePalette2x2::output

    fn ImagePalette2x2::output(self : ImagePalette2x2, logger : &Logger) -> Unit

    ImagePalette2x2::to_string

    fn ImagePalette2x2::to_string(self : ImagePalette2x2) -> String

    ImagePaletteBinding

    pub struct ImagePaletteBinding {
    image_id : Int
    palette : ImagePalette2x2
    } derive(
    Debug
    )

    ImagePaletteBinding::output

    fn ImagePaletteBinding::output(self : ImagePaletteBinding, logger : &Logger) -> Unit

    ImagePaletteBinding::to_string

    fn ImagePaletteBinding::to_string(self : ImagePaletteBinding) -> String

    ImageSpec

    pub struct ImageSpec {
    width : Int
    height : Int
    format : String
    palette : ImagePalette2x2
    pixels_rgba8 : Array[Int]
    } derive(
    Debug
    )

    impl Show for ImageSpec

    ImageSpec::output

    fn ImageSpec::output(self : ImageSpec, logger : &Logger) -> Unit

    ImageSpec::to_string

    fn ImageSpec::to_string(self : ImageSpec) -> String

    MaterialSpec

    pub struct MaterialSpec {
    shader : AssetKey
    blend :
    BlendMode

    filter :
    FilterMode

    uniform_keys : Array[String]
    } derive(
    Debug
    )

    MaterialSpec::output

    fn MaterialSpec::output(self : MaterialSpec, logger : &Logger) -> Unit

    MaterialSpec::to_string

    fn MaterialSpec::to_string(self : MaterialSpec) -> String

    MultiPageAtlasRepository

    pub struct MultiPageAtlasRepository {
    page_width : Int
    page_height : Int
    next_page_id : Int
    pages : Array[SimpleAtlasImageRepository]
    key_page_index : Array[(String, Int)]
    }

    Multi-page atlas repository that auto-creates new pages when the current page runs out of space.

    Ebiten refs:
    • internal/atlas/image.go (multi-backend page management)

    RasterImageFormat

    pub enum RasterImageFormat {
    Png
    Jpeg
    Bmp
    } derive(Eq,
    Debug
    )

    RasterImageFormat::equal

    RasterImageFormat::not_equal

    fn RasterImageFormat::not_equal(x : RasterImageFormat, y : RasterImageFormat) -> Bool

    RasterImageFormat::output

    fn RasterImageFormat::output(self : RasterImageFormat, logger : &Logger) -> Unit

    RasterImageFormat::to_string

    fn RasterImageFormat::to_string(self : RasterImageFormat) -> String

    RasterResizeMethod

    pub enum RasterResizeMethod {
    Nearest
    Bilinear
    Bicubic
    } derive(
    Debug
    )

    RasterResizeMethod::output

    fn RasterResizeMethod::output(self : RasterResizeMethod, logger : &Logger) -> Unit

    RasterResizeMethod::to_string

    fn RasterResizeMethod::to_string(self : RasterResizeMethod) -> String

    Rgba

    pub struct Rgba {
    r : Int
    g : Int
    b : Int
    a : Int
    } derive(
    Debug
    )

    impl Show for Rgba

    Rgba::output

    fn Rgba::output(self : Rgba, logger : &Logger) -> Unit

    Rgba::to_repr

    Rgba::to_string

    fn Rgba::to_string(self : Rgba) -> String

    ShaderSpec

    pub struct ShaderSpec {
    debug_name : String
    source : String
    } derive(
    Debug
    )

    impl Show for ShaderSpec

    ShaderSpec::output

    fn ShaderSpec::output(self : ShaderSpec, logger : &Logger) -> Unit

    ShaderSpec::to_string

    fn ShaderSpec::to_string(self : ShaderSpec) -> String

    SimpleAtlasAllocator

    pub struct SimpleAtlasAllocator {
    atlas_width : Int
    atlas_height : Int
    atlas_id : Int
    cursor_x : Int
    cursor_y : Int
    row_height : Int
    allocated : Array[AtlasRegion]
    }

    SimpleAtlasAllocator::allocate

    fn SimpleAtlasAllocator::allocate(self : SimpleAtlasAllocator, width : Int, height : Int) -> AtlasRegion?

    SimpleAtlasAllocator::release

    fn SimpleAtlasAllocator::release(self : SimpleAtlasAllocator, region : AtlasRegion) -> Unit

    SimpleAtlasImageEntry

    type SimpleAtlasImageEntry derive(
    Debug
    )

    SimpleAtlasImageEntry::output

    fn SimpleAtlasImageEntry::output(self : SimpleAtlasImageEntry, logger : &Logger) -> Unit

    SimpleAtlasImageEntry::to_string

    fn SimpleAtlasImageEntry::to_string(self : SimpleAtlasImageEntry) -> String

    SimpleAtlasImageRepository

    pub struct SimpleAtlasImageRepository {
    atlas_width : Int
    atlas_height : Int
    atlas_id : Int
    next_image_id : Int
    allocator : SimpleAtlasAllocator
    images : Array[SimpleAtlasImageEntry]
    page_generation : Int
    page_dirty_rect : SourceImageDirtyRect?
    }

    Atlas image repository with page-level dirty tracking.

    Ebiten refs:
    • internal/atlas/image.go
    • internal/atlas/image.go (writePixels / region updates)

    SimpleImageEntry

    type SimpleImageEntry derive(
    Debug
    )

    SimpleImageEntry::output

    fn SimpleImageEntry::output(self : SimpleImageEntry, logger : &Logger) -> Unit

    SimpleImageEntry::to_string

    fn SimpleImageEntry::to_string(self : SimpleImageEntry) -> String

    SimpleImageRepository

    pub struct SimpleImageRepository {
    next_image_id : Int
    images : Array[SimpleImageEntry]
    }

    SimpleImageRepository::create_image

    SimpleImageRepository::get_image

    SimpleImageRepository::remove_image

    fn SimpleImageRepository::remove_image(self : SimpleImageRepository, key : AssetKey) -> Unit raise

    SimpleMaterialEntry

    type SimpleMaterialEntry derive(
    Debug
    )

    SimpleMaterialEntry::output

    fn SimpleMaterialEntry::output(self : SimpleMaterialEntry, logger : &Logger) -> Unit

    SimpleMaterialEntry::to_string

    fn SimpleMaterialEntry::to_string(self : SimpleMaterialEntry) -> String

    SimpleMaterialRepository

    pub struct SimpleMaterialRepository {
    materials : Array[SimpleMaterialEntry]
    }

    SimpleMaterialRepository::get_material

    SimpleMaterialRepository::register_material

    fn SimpleMaterialRepository::register_material(self : SimpleMaterialRepository, key : AssetKey, spec : MaterialSpec) -> Unit raise

    SimpleShaderEntry

    type SimpleShaderEntry derive(
    Debug
    )

    SimpleShaderEntry::output

    fn SimpleShaderEntry::output(self : SimpleShaderEntry, logger : &Logger) -> Unit

    SimpleShaderEntry::to_string

    fn SimpleShaderEntry::to_string(self : SimpleShaderEntry) -> String

    SimpleShaderRepository

    pub struct SimpleShaderRepository {
    next_shader_id : Int
    shaders : Array[SimpleShaderEntry]
    }

    SimpleShaderRepository::create_shader

    SimpleShaderRepository::get_shader

    SimpleShaderRepository::remove_shader

    fn SimpleShaderRepository::remove_shader(self : SimpleShaderRepository, key : AssetKey) -> Unit raise

    SourceImageBinding

    pub struct SourceImageBinding {
    image_id : Int
    width : Int
    height : Int
    generation : Int
    dirty_rect : SourceImageDirtyRect?
    palette : ImagePalette2x2
    pixels_rgba8 : Array[Int]
    } derive(
    Debug
    )

    SourceImageBinding::output

    fn SourceImageBinding::output(self : SourceImageBinding, logger : &Logger) -> Unit

    SourceImageBinding::to_string

    fn SourceImageBinding::to_string(self : SourceImageBinding) -> String

    SourceImageDirtyRect

    pub struct SourceImageDirtyRect {
    x : Int
    y : Int
    width : Int
    height : Int
    } derive(
    Debug
    )

    SourceImageDirtyRect::output

    fn SourceImageDirtyRect::output(self : SourceImageDirtyRect, logger : &Logger) -> Unit

    SourceImageDirtyRect::to_string

    fn SourceImageDirtyRect::to_string(self : SourceImageDirtyRect) -> String

    atlas_allocator_is_empty

    fn atlas_allocator_is_empty(allocator : SimpleAtlasAllocator) -> Bool

    atlas_allocator_reset_if_empty

    fn atlas_allocator_reset_if_empty(allocator : SimpleAtlasAllocator) -> Bool

    atlas_page_image_count

    fn atlas_page_image_count(repo : SimpleAtlasImageRepository) -> Int

    atlas_page_is_empty

    fn atlas_page_is_empty(repo : SimpleAtlasImageRepository) -> Bool

    atlas_page_stats

    fn atlas_page_stats(repo : SimpleAtlasImageRepository) -> AtlasPageStats

    checker_palette_from_seed

    fn checker_palette_from_seed(seed : Int) -> ImagePalette2x2

    clamp_channel

    fn clamp_channel(channel : Int) -> Int

    clear_dirty_atlas_page_flags

    fn clear_dirty_atlas_page_flags(repo : SimpleAtlasImageRepository) -> Int

    clear_source_image_dirty_flags

    fn clear_source_image_dirty_flags(repo : SimpleImageRepository) -> Int

    create_atlas_image

    fn create_atlas_image(repo : SimpleAtlasImageRepository, key : AssetKey, spec : ImageSpec) ->
    ImageHandle
    ?

    create_atlas_image_from_raster_bytes

    fn create_atlas_image_from_raster_bytes(repository : SimpleAtlasImageRepository, key : AssetKey, bytes : Bytes) ->
    ImageHandle
    ? raise

    create_image_from_raster_bytes

    fn create_image_from_raster_bytes(repository : SimpleImageRepository, key : AssetKey, bytes : Bytes) ->
    ImageHandle
    ? raise

    decode_bmp_image_spec

    fn decode_bmp_image_spec(bytes : Bytes) -> ImageSpec raise
    DecodeError

    decode_image_spec

    fn decode_image_spec(bytes : Bytes, format : RasterImageFormat) -> ImageSpec raise
    DecodeError

    decode_image_spec_auto

    fn decode_image_spec_auto(bytes : Bytes) -> ImageSpec? raise
    DecodeError

    decode_jpeg_image_spec

    fn decode_jpeg_image_spec(bytes : Bytes) -> ImageSpec raise
    DecodeError

    decode_png_image_spec

    fn decode_png_image_spec(bytes : Bytes) -> ImageSpec raise
    DecodeError

    default_image_spec

    fn default_image_spec(width : Int, height : Int) -> ImageSpec

    detect_raster_image_format

    fn detect_raster_image_format(bytes : Bytes) -> RasterImageFormat?

    encode_bmp_image_spec

    fn encode_bmp_image_spec(spec : ImageSpec) -> Bytes raise
    EncodeError

    encode_image_spec

    fn encode_image_spec(spec : ImageSpec, format : RasterImageFormat) -> Bytes raise
    EncodeError

    encode_jpeg_image_spec

    fn encode_jpeg_image_spec(spec : ImageSpec, quality? : Int) -> Bytes raise
    EncodeError

    encode_png_image_spec

    fn encode_png_image_spec(spec : ImageSpec) -> Bytes raise
    EncodeError

    fetch_bytes

    fn fetch_bytes(url : String, callback : (Bytes?) -> Unit) -> Unit

    fetch_image

    fn fetch_image(url : String, callback : (ImageSpec?) -> Unit) -> Unit

    get_atlas_draw_source

    fn get_atlas_draw_source(repo : SimpleAtlasImageRepository, key : AssetKey) -> AtlasDrawSource?

    get_atlas_image_region

    fn get_atlas_image_region(repo : SimpleAtlasImageRepository, key : AssetKey) -> AtlasRegion?

    get_image_generation_by_id

    fn get_image_generation_by_id(repo : SimpleImageRepository, image_id : Int) -> Int

    get_image_palette_by_id

    fn get_image_palette_by_id(repo : SimpleImageRepository, image_id : Int) -> ImagePalette2x2?

    get_image_pixels_by_id

    fn get_image_pixels_by_id(repo : SimpleImageRepository, image_id : Int) -> Array[Int]?

    image_spec_with_palette

    fn image_spec_with_palette(width : Int, height : Int, palette : ImagePalette2x2) -> ImageSpec

    image_spec_with_rgba8

    fn image_spec_with_rgba8(width : Int, height : Int, pixels_rgba8 : Array[Int]) -> ImageSpec

    list_dirty_atlas_page_bindings

    fn list_dirty_atlas_page_bindings(repo : SimpleAtlasImageRepository) -> Array[SourceImageBinding]

    list_dirty_source_image_bindings

    fn list_dirty_source_image_bindings(repo : SimpleImageRepository) -> Array[SourceImageBinding]

    list_image_palette_bindings

    fn list_image_palette_bindings(repo : SimpleImageRepository) -> Array[ImagePaletteBinding]

    list_source_image_bindings

    fn list_source_image_bindings(repo : SimpleImageRepository) -> Array[SourceImageBinding]

    multi_page_clear_dirty_flags

    fn multi_page_clear_dirty_flags(repo : MultiPageAtlasRepository) -> Int

    multi_page_compact

    fn multi_page_compact(repo : MultiPageAtlasRepository) -> AtlasCompactResult

    multi_page_count

    fn multi_page_count(repo : MultiPageAtlasRepository) -> Int

    multi_page_create_image

    fn multi_page_create_image(repo : MultiPageAtlasRepository, key : AssetKey, spec : ImageSpec) ->
    ImageHandle
    ?

    multi_page_get_draw_source

    fn multi_page_get_draw_source(repo : MultiPageAtlasRepository, key : AssetKey) -> AtlasDrawSource?

    multi_page_get_page_ids

    fn multi_page_get_page_ids(repo : MultiPageAtlasRepository) -> Array[Int]

    multi_page_get_region

    fn multi_page_get_region(repo : MultiPageAtlasRepository, key : AssetKey) -> AtlasRegion?

    multi_page_image_count

    fn multi_page_image_count(repo : MultiPageAtlasRepository) -> Int

    multi_page_list_dirty_bindings

    fn multi_page_list_dirty_bindings(repo : MultiPageAtlasRepository) -> Array[SourceImageBinding]

    multi_page_remove_image

    fn multi_page_remove_image(repo : MultiPageAtlasRepository, key : AssetKey) -> Unit

    multi_page_stats

    fn multi_page_stats(repo : MultiPageAtlasRepository) -> Array[AtlasPageStats]

    multi_page_update_image_spec

    fn multi_page_update_image_spec(repo : MultiPageAtlasRepository, key : AssetKey, spec : ImageSpec) ->
    ImageHandle
    ?

    new_asset_key

    fn new_asset_key(value : String) -> AssetKey

    new_atlas_region

    fn new_atlas_region(x : Int, y : Int, width : Int, height : Int, atlas_id : Int) -> AtlasRegion

    new_image_palette_2x2

    fn new_image_palette_2x2(p00 : Rgba, p10 : Rgba, p01 : Rgba, p11 : Rgba) -> ImagePalette2x2

    new_multi_page_atlas_repository

    fn new_multi_page_atlas_repository(page_width : Int, page_height : Int) -> MultiPageAtlasRepository

    new_rgba

    fn new_rgba(r : Int, g : Int, b : Int, a : Int) -> Rgba

    new_simple_atlas_allocator

    fn new_simple_atlas_allocator(atlas_width : Int, atlas_height : Int, atlas_id : Int) -> SimpleAtlasAllocator

    new_simple_atlas_image_repository

    fn new_simple_atlas_image_repository(atlas_width : Int, atlas_height : Int, atlas_id : Int) -> SimpleAtlasImageRepository

    new_simple_image_repository

    fn new_simple_image_repository() -> SimpleImageRepository

    new_simple_material_repository

    fn new_simple_material_repository() -> SimpleMaterialRepository

    new_simple_shader_repository

    fn new_simple_shader_repository() -> SimpleShaderRepository

    new_solid_palette

    fn new_solid_palette(color : Rgba) -> ImagePalette2x2

    new_source_image_binding

    fn new_source_image_binding(image_id : Int, width : Int, height : Int, generation : Int, dirty_rect : SourceImageDirtyRect?, palette : ImagePalette2x2, pixels_rgba8 : Array[Int]) -> SourceImageBinding

    new_source_image_dirty_rect

    fn new_source_image_dirty_rect(x : Int, y : Int, width : Int, height : Int) -> SourceImageDirtyRect

    new_unmanaged_atlas_draw_source

    fn new_unmanaged_atlas_draw_source(image_id : Int) -> AtlasDrawSource

    palette_channel

    fn palette_channel(palette : ImagePalette2x2, pixel_index : Int, channel_index : Int) -> Int

    raster_image_format_bmp

    fn raster_image_format_bmp() -> RasterImageFormat

    raster_image_format_jpeg

    fn raster_image_format_jpeg() -> RasterImageFormat

    raster_image_format_png

    fn raster_image_format_png() -> RasterImageFormat

    raster_resize_bicubic

    fn raster_resize_bicubic() -> RasterResizeMethod

    raster_resize_bilinear

    fn raster_resize_bilinear() -> RasterResizeMethod

    raster_resize_nearest

    fn raster_resize_nearest() -> RasterResizeMethod

    register_precomputed_image

    fn register_precomputed_image(repo : SimpleAtlasImageRepository, key : AssetKey, region : AtlasRegion, spec : ImageSpec) ->
    ImageHandle

    Register an image with a precomputed atlas region (bypasses allocator). Used by sprite_packer to register MaxRects-packed results directly.

    remove_atlas_image

    fn remove_atlas_image(repo : SimpleAtlasImageRepository, key : AssetKey) -> Unit

    resize_image_spec

    fn resize_image_spec(spec : ImageSpec, width : Int, height : Int, resize_method : RasterResizeMethod) -> ImageSpec raise
    EncodeError

    update_atlas_image_from_raster_bytes

    fn update_atlas_image_from_raster_bytes(repository : SimpleAtlasImageRepository, key : AssetKey, bytes : Bytes) ->
    ImageHandle
    ? raise

    update_atlas_image_spec

    fn update_atlas_image_spec(repo : SimpleAtlasImageRepository, key : AssetKey, spec : ImageSpec) ->
    ImageHandle
    ?

    update_image_from_raster_bytes

    fn update_image_from_raster_bytes(repository : SimpleImageRepository, key : AssetKey, bytes : Bytes) ->
    ImageHandle
    ? raise

    update_image_spec

    fn update_image_spec(repo : SimpleImageRepository, key : AssetKey, spec : ImageSpec) ->
    ImageHandle
    ?