Actor > Kostüm#
Ein Costume ist eine Unterklasse von Appearance. Die meisten Methoden und Attribute werden von der Basisklasse Appearance geerbt.
API-Referenz#
- class miniworlds.appearances.costume.Costume(*args, **kwargs)[Quellcode]#
Ein Kostüm enthält ein oder mehrere Bilder
Jeder Actor hat ein Kostüm, das das “Aussehen” des Actors definiert. Sie können die Bilder in einem Kostüm wechseln, um den Actor zu animieren.
Ein Kostüm wird erstellt, wenn Sie einem Actor mit actor.add_image(path_to_image) ein Bild hinzufügen
Öffentliche Datenattribute:
Zugehörige Welt dieses Kostüms.
Shows info overlay (Rectangle around the actor and Direction marker)
image_managerInherited from
AppearanceCurrent font size used for text rendering.
Texture tile size used when is_textured is enabled.
Frames between animation steps.
If True, the image is tiled over the background.
If True, costume will be rotated with token direction
Whether drawing operations are centered on the parent position.
Whether shapes are rendered filled instead of outlined.
Flips the costume or background.
Wenn wahr, wird das Bild unter Beibehaltung des Seitenverhältnisses hochskaliert.
Whether the image is scaled to parent width and keeps aspect ratio.
Whether the image is scaled to parent height and keeps aspect ratio.
Primary fill color for shape-based rendering.
Skaliert das Token auf die Größe des übergeordneten Elements, ohne das Seitenverhältnis beizubehalten.
Wenn True, wird das Bild vor der Drehung entsprechend der Ausrichtung des übergeordneten Elements gedreht.
Defines a colored layer.
Defines a transparency.
Transparency value of the appearance.
If True, the costume will be animated.
->Füllfarbe anzeigen
see border color
border color of actor
Die Randgröße des Actors.
List of image surfaces managed by this appearance.
Führt alle Aktionen in der Bildpipeline aus
Dirty flag for the current rendering pipeline state.
In Unterklassen Kostüm und Hintergrund implementiert
image_managerPublic Methods:
__init__(actor)Gibt den zugehörigen Kostüm-Manager des Actors zurück.
Wendet nach der Konstruktion die Standardwerte von Actor und Welt an.
set_image(source)rotated()Markiert rotationsabhängiges Rendering nach einer Actor-Rotation als dirty.
Markiert Rendering nach einer Ursprungsänderung als dirty.
resized()Markiert skalierungsabhängiges Rendering als dirty.
Markiert nach Sichtbarkeitsänderungen das vollständige Rendering als dirty.
set_dirty([value, status])Setzt Dirty-Flags und hält Actor-Rect-/Masken-Caches synchron.
get_rect()Gibt ein frame-gecachtes lokales Rechteck für das gerenderte Kostümbild zurück.
Inherited from
Appearance__init__()set_image(source)Setzt das angezeigte Bild des Kostüms/Hintergrunds auf den ausgewählten Index
Finalize initialization after the metaclass constructor hook.
set_mode(**kwargs)Set multiple appearance mode flags at once.
Return all mode flags as a dictionary.
set_animated(value)Enable or disable frame-based animation.
flip(value)Convenience wrapper to set is_flipped.
Remove the most recently added image.
add_image(source)Add an image source and return its index.
add_images(sources)Adds multiple images to background/costume.
animate([loop])Animates the costume
the method is overwritten in subclasses costume and appearance
Create an array from costume or background.
from_array(arr)Create a background or costume from array.
fill(value)Set default fill color for borders and lines
set_filled(value)Set whether shapes are rendered filled.
get_color(position)Return the color at a local pixel position.
get_rect()Return the local rectangle of the rendered image.
draw(source, position, width, height)Draw an image source at a local position.
draw_on_image(path, position, width, height)Queue drawing an image file onto the appearance image.
draw_color_on_image(color, position, width, ...)Queue drawing a colored rectangle onto the appearance image.
__str__()Return str(self).
If dirty, the image will be reloaded.
update()Loads the next image, called 1/frame
register(method)Register method for decorator.
draw_shape_append(shape, arguments)Append a shape draw command to the render queue.
draw_shape_set(shape, arguments)Replace shape draw commands with a single command.
draw_image_append(surface, rect)Append a pre-rendered surface draw command.
draw_image_set(surface, rect)Replace image draw commands with one surface draw command.
set_dirty([value, status])Mark pipeline stages as dirty so the image is re-rendered.
In Unterklassen Kostüm und Hintergrund implementiert
Private Methods:
_set_default_color_values()_set_actor_default_values()_set_world_default_values()_inner_shape()Returns inner shape of costume
_outer_shape()Returns outer shape of costume
Inherited from
Appearance_get_rendering_facade()_set_defaults(**kwargs)_set_font(font, font_size)_set_animation_speed(value)_set_textured(value)bool: If True, the image is tiled over the background.
_set_rotatable(value)If set to True, costume will be rotated with actor direction
_set_centered(value)_set_flipped(value)Flips the costume or background.
_set_filled(value)Sets whether the costume or background should be filled with a color.
_set_scaled(value)Setzt den Actor auf die Eltern-Größe ohne das Seitenverhältnis beizubehalten.
_set_upscaled(value)Wenn auf True gesetzt, wird das Bild unter Beibehaltung des Seitenverhältnisses hochskaliert.
_set_scaled_to_width(value)_set_scaled_to_height(value)_set_image(source)Setzt das angezeigte Bild des Kostüms/Hintergrunds auf den ausgewählten Index
_before_transformation_pipeline()Called in get_image before the image transformation pipeline is processed (e.g. when size, rotation, or other display properties have changed).
_after_transformation_pipeline()Called in get_image after the image transformation pipeline is processed (e.g. when size, rotation, or other display properties have changed).
_load_image()Loads the image,
_update_draw_shape()_inner_shape()Returns inner shape of costume
_outer_shape()Returns outer shape of costume
_inner_shape_arguments()Gets arguments for inner shape.
_outer_shape_arguments()Gets arguments for outer shape
- after_init()[Quellcode]#
Wendet nach der Konstruktion die Standardwerte von Actor und Welt an.
- get_manager()[Quellcode]#
Gibt den zugehörigen Kostüm-Manager des Actors zurück.
- get_rect()[Quellcode]#
Gibt ein frame-gecachtes lokales Rechteck für das gerenderte Kostümbild zurück.
- property info_overlay#
Shows info overlay (Rectangle around the actor and Direction marker)
- origin_changed()[Quellcode]#
Markiert Rendering nach einer Ursprungsänderung als dirty.
- parent#
Das übergeordnete Element eines Kostüms ist der zugehörige Actor.
- resized()[Quellcode]#
Markiert skalierungsabhängiges Rendering als dirty.
- rotated()[Quellcode]#
Markiert rotationsabhängiges Rendering nach einer Actor-Rotation als dirty.
- set_dirty(value='all', status=1)[Quellcode]#
Setzt Dirty-Flags und hält Actor-Rect-/Masken-Caches synchron.
- set_image(source)[Quellcode]#
- Parameter:
source – Index, Aussehen oder Farbe.
- Rückgabe:
Wahr, wenn das Bild existiert
- visibility_changed()[Quellcode]#
Markiert nach Sichtbarkeitsänderungen das vollständige Rendering als dirty.