sonolus.script.sprite¶
RenderMode
¶
Bases: StrEnum
Render mode for sprites.
DEFAULT = 'default'
class-attribute
instance-attribute
¶
Use the user's preferred render mode.
LIGHTWEIGHT = 'lightweight'
class-attribute
instance-attribute
¶
Use the lightweight render mode with projective interpolation of textures.
STANDARD = 'standard'
class-attribute
instance-attribute
¶
Use the standard render mode with bilinear interpolation of textures.
Sprite
¶
Bases: Record
Skin sprite.
Usage
Sprite(id: int)
is_available
property
¶
Check if the sprite is available.
draw(quad, z=0.0, a=1.0)
¶
Draw the sprite.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
quad
|
QuadLike
|
The quad to draw the sprite on. |
required |
z
|
float
|
The z-index of the sprite. |
0.0
|
a
|
float
|
The alpha of the sprite. |
1.0
|
draw_curved_b(quad, cp, n, z=0.0, a=1.0)
¶
Draw the sprite with a curved bottom with a quadratic Bézier curve.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
quad
|
QuadLike
|
The quad to draw the sprite on. |
required |
cp
|
Vec2
|
The control point of the curve. |
required |
n
|
float
|
The number of segments to approximate the curve (higher is smoother but more expensive). |
required |
z
|
float
|
The z-index of the sprite. |
0.0
|
a
|
float
|
The alpha of the sprite. |
1.0
|
draw_curved_bt(quad, cp1, cp2, n, z=0.0, a=1.0)
¶
Draw the sprite with a curved bottom and top with a cubic Bézier curve.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
quad
|
QuadLike
|
The quad to draw the sprite on. |
required |
cp1
|
Vec2
|
The control point of the bottom curve. |
required |
cp2
|
Vec2
|
The control point of the top curve. |
required |
n
|
float
|
The number of segments to approximate the curve (higher is smoother but more expensive). |
required |
z
|
float
|
The z-index of the sprite. |
0.0
|
a
|
float
|
The alpha of the sprite. |
1.0
|
draw_curved_l(quad, cp, n, z=0.0, a=1.0)
¶
Draw the sprite with a curved left side with a quadratic Bézier curve.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
quad
|
QuadLike
|
The quad to draw the sprite on. |
required |
cp
|
Vec2
|
The control point of the curve. |
required |
n
|
float
|
The number of segments to approximate the curve (higher is smoother but more expensive). |
required |
z
|
float
|
The z-index of the sprite. |
0.0
|
a
|
float
|
The alpha of the sprite. |
1.0
|
draw_curved_lr(quad, cp1, cp2, n, z=0.0, a=1.0)
¶
Draw the sprite with a curved left and right side with a cubic Bézier curve.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
quad
|
QuadLike
|
The quad to draw the sprite on. |
required |
cp1
|
Vec2
|
The control point of the left curve. |
required |
cp2
|
Vec2
|
The control point of the right curve. |
required |
n
|
float
|
The number of segments to approximate the curve (higher is smoother but more expensive). |
required |
z
|
float
|
The z-index of the sprite. |
0.0
|
a
|
float
|
The alpha of the sprite. |
1.0
|
draw_curved_r(quad, cp, n, z=0.0, a=1.0)
¶
Draw the sprite with a curved right side with a quadratic Bézier curve.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
quad
|
QuadLike
|
The quad to draw the sprite on. |
required |
cp
|
Vec2
|
The control point of the curve. |
required |
n
|
float
|
The number of segments to approximate the curve (higher is smoother but more expensive). |
required |
z
|
float
|
The z-index of the sprite. |
0.0
|
a
|
float
|
The alpha of the sprite. |
1.0
|
draw_curved_t(quad, cp, n, z=0.0, a=1.0)
¶
Draw the sprite with a curved top with a quadratic Bézier curve.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
quad
|
QuadLike
|
The quad to draw the sprite on. |
required |
cp
|
Vec2
|
The control point of the curve. |
required |
n
|
float
|
The number of segments to approximate the curve (higher is smoother but more expensive). |
required |
z
|
float
|
The z-index of the sprite. |
0.0
|
a
|
float
|
The alpha of the sprite. |
1.0
|
StandardSprite
¶
Standard skin sprites.
skin(cls)
¶
Decorator to define a skin.
Usage
@skin
class Skin:
render_mode: RenderMode
note: StandardSprite.NOTE_HEAD_RED
other: Sprite = skin_sprite("other")
sprite(name)
¶
Define a sprite with the given name.