Contents

Appearance: Costume

Contents

Appearance: Costume

The ‘Costume’ class is a child classes of the ‘Appearance’ class.

classDiagram Appearance <|-- Costume Appearance <|-- Background Token o-- Appearance class Token{ +add_costume() } class Appearance{ +add_image(str) } class Costume{ } class Background{ }

Note

Usually costumes are created with token.add_costume([image_path|color])

Costume

class miniworldmaker.appearances.costume.Costume(*args, **kwargs)[source]

A costume contains one or multiple images

Every token has a costume which defines the “look” of the token. You can switch the images in a costume to animate the token.

A costume is created if you add an image to an actor with token.add_image(path_to_image)

Public Data Attributes:

info_overlay

Shows info overlay (Rectangle around the token and Direction marker) :param color: Color of info_overlay

Inherited from : py: class:Appearance

font_size

is_textured

If True, the image is tiled over the background.

is_rotatable

If True, costume will be rotated with token direction

is_centered

orientation

If True, the image will be rotated by parent orientation before it is rotated.

is_flipped

Flips the costume or background.

is_scaled

Scales the actor to parent-size without remaining aspect-ratio.

is_upscaled

If True, the image will be upscaled remaining aspect-ratio.

is_scaled_to_width

is_scaled_to_height

fill_color

coloring

Defines a colored layer.

transparency

Defines a transparency.

alpha

transparent, 255: visible If value < 1, it will be multiplied with 255.

is_animated

If True, the costume will be animated.

color

->See fill color

is_filled

Is token filled with color?

stroke_color

see border color

border_color

border color of token

border

The border-size of token.

Inherited from : py: class:AppearanceBase

counter

RELOAD_ACTUAL_IMAGE

LOAD_NEW_IMAGE

dirty

image

Performs all actions in image pipeline

text

Examples:

images

Public Methods:

__init__(token)

after_init()

set_dirty(value, status)

set_image(source)

Sets the displayed image of costume/background to selected index

rotated()

resized()

visible()

Inherited from : py: class:Appearance

set_font(font, font_size)

set_animation_speed(value)

flip(value)

get_text_width()

remove_last_image()

add_image([source])

Adds an image to the appearance

add_images(sources)

Adds multiple images to background/costume.

count_pixels_by_color(rect, color[, threshold])

Counts the number of pixels of a color under the appearance.

animate()

Animates the costume

after_animation()

the method is overwritten in subclasses costume and appearance

reset()

set_image(source)

Sets the displayed image of costume/background to selected index

to_colors_array()

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

get_color(position)

find_color_in_rect(rect, color[, threshold])

draw(source, position, width, height)

draw_on_image(path, position, width, height)

draw_color_on_image(color, position, width, ...)

Inherited from : py: class:AppearanceBase

__init__(token)

after_init()

draw_shape_append(shape, arguments)

draw_shape_set(shape, arguments)

draw_image_append(surface, rect)

draw_image_set(surface, rect)

set_dirty(value, status)

get_image()

If dirty, the image will be reloaded.

add_images(sources)

Adds multiple images to background/costume.

add_image([source])

Adds an image to the appearance

set_image(source)

Sets the displayed image of costume/background to selected index

update()

Loads the next image, called 1/frame

__str__()

Return str(self).

register(method)

Register method for decorator.

Private Methods:

_set_default_color_values()

_set_token_default_values()

_set_board_default_values()

_inner_shape()

Returns inner shape of costume

_outer_shape()

Returns outer shape of costume

_update_draw_shape()

_inner_shape_arguments()

def setGets arguments for inner shape

_outer_shape_arguments()

Gets arguments for outer shape

Inherited from : py: class:AppearanceBase

_before_transformation_pipeline()

_after_transformation_pipeline()


after_init()[source]
property info_overlay

Shows info overlay (Rectangle around the token and Direction marker) :param color: Color of info_overlay

parent

the parent of a costume is the associated token.

resized()[source]
rotated()[source]
set_dirty(value, status)[source]
set_image(source)[source]

Sets the displayed image of costume/background to selected index

Parameters:

source – The image index or an image.

Returns:

True, if image index exists

Examples

Add two images two background and switch to image 2

from miniworldmaker import *

board = Board()
background = board.add_background("images/1.png")
background.add_image("images/2.png")
background.set_image(1)
board.run()
Return type:

bool

visible()[source]