VectorSpriteSheet
Added in version 1.1.
Superclasses: Object
- Constructors:
VectorSpriteSheet(**properties)
new() -> Shumate.VectorSpriteSheet
Constructors
- class VectorSpriteSheet
- classmethod new() VectorSpriteSheet
Creates a new, empty
VectorSpriteSheet
.Added in version 1.1.
Methods
- class VectorSpriteSheet
- add_page(texture: Texture, json: str, default_scale: float) bool
Adds a page to the spritesheet.
See <https://maplibre.org/maplibre-gl-js-docs/style-spec/sprite/> for details about the spritesheet format. Most stylesheets provide these files along with the main style JSON.
Map styles should provide a double resolution spritesheet for high DPI displays. That spritesheet should be added as its own page, with a
default_scale
of 2.Added in version 1.1.
- Parameters:
texture – a
Texture
json – a JSON string
default_scale – the default scale factor of the page
- add_sprite(name: str, sprite: VectorSprite) None
Adds a sprite to the spritesheet.
Added in version 1.1.
- Parameters:
name – the name of the sprite
sprite – a
VectorSprite
- get_sprite(name: str, scale: float) VectorSprite | None
Gets a sprite from the spritesheet.
The returned sprite might not be at the requested scale factor if an exact match is not found.
Added in version 1.1.
- Parameters:
name – an icon name
scale – the scale factor of the icon
- set_fallback(fallback: Callable[[...], VectorSprite | None] | None = None, *user_data: Any) None
Sets a fallback function to generate sprites.
The fallback function is called when a texture is not found in the sprite sheet. It receives the icon name and scale factor, and should return a
VectorSprite
, orNone
if the icon could not be generated. It may be called in a different thread, and it may be called multiple times for the same icon name.If a previous fallback function was set, it will be replaced and any sprites it generated will be cleared.
fallback
may beNone
to clear the fallback function.Added in version 1.1.
- Parameters:
fallback – a
ShumateVectorSpriteFallbackFunc
orNone
user_data – user data to pass to
fallback