flatland.utils.graphics_pil moduleΒΆ

class flatland.utils.graphics_pil.PILGL(width, height, jupyter=False, screen_width=800, screen_height=600)[source]ΒΆ

Bases: flatland.utils.graphics_layer.GraphicsLayer

AGENT_LAYER = 3ΒΆ
PREDICTION_PATH_LAYER = 1ΒΆ
RAIL_LAYER = 0ΒΆ
SELECTED_AGENT_LAYER = 4ΒΆ
SELECTED_TARGET_LAYER = 5ΒΆ
TARGET_LAYER = 2ΒΆ
alpha_composite_layers()[source]ΒΆ
begin_frame()[source]ΒΆ
build_background_map(dTargets)[source]ΒΆ
clear_layer(iLayer=0, opacity=None)[source]ΒΆ
close_window()[source]ΒΆ
create_image(opacity=255)[source]ΒΆ
create_layer(iLayer=0, clear=True)[source]ΒΆ
create_layers(clear=True)[source]ΒΆ
draw_image_row_col(pil_img, rcTopLeft, layer=0)[source]ΒΆ
draw_image_xy(pil_img, xyPixLeftTop, layer=0)[source]ΒΆ
get_agent_color(iAgent)[source]ΒΆ
get_image()[source]ΒΆ

return a blended / alpha composited image composed of all the layers, with layer 0 at the β€œback”.

idle(seconds=1e-05)[source]ΒΆ

process any display events eg redraw, resize. Return only after the given number of seconds, ie idle / loop until that number.

open_window()[source]ΒΆ
pause(seconds=1e-05)[source]ΒΆ

deprecated

plot(gX, gY, color=None, linewidth=3, layer=0, opacity=255, **kwargs)[source]ΒΆ

Draw a line joining the points in gX, GY - each an

prettify(*args, **kwargs)[source]ΒΆ
prettify2(width, height, cell_size)[source]ΒΆ
rgb_s2i(sRGB)[source]ΒΆ

convert a hex RGB string like 0091ea to 3-tuple of ints

save_image(filename)[source]ΒΆ

Renders the current scene into a image file :param filename: filename where to store the rendering output_generator (supported image format *.bmp , .. , *.png)

scatter(gX, gY, color=None, marker='o', s=50, layer=0, opacity=255, *args, **kwargs)[source]ΒΆ
show(block=False)[source]ΒΆ
text(xPx, yPx, strText, layer=0)[source]ΒΆ
text_rowcol(rcTopLeft, strText, layer=3)[source]ΒΆ
class flatland.utils.graphics_pil.PILSVG(width, height, jupyter=False, screen_width=800, screen_height=600)[source]ΒΆ

Bases: flatland.utils.graphics_pil.PILGL

Note : This class should now ideally be called as PILPNG, but for backward compatibility, and to not introduce any breaking changes at this point we are sticking to the legacy name of PILSVG (when in practice we are not using SVG anymore)

clear_agents()[source]ΒΆ
clear_rails()[source]ΒΆ
draw_malfunction(agent_idx, rcTopLeft)[source]ΒΆ
load_agent()[source]ΒΆ
load_buildings()[source]ΒΆ
load_pngs(file_directory, rotate=False, agent_colors=False, background_image=None, whitefilter=None)[source]ΒΆ
load_rail()[source]ΒΆ

Load the rail SVG images, apply rotations, and store as PIL images.

load_scenery()[source]ΒΆ
pil_from_png_file(package, resource)[source]ΒΆ
process_events()[source]ΒΆ
recolor_image(pil, a3BaseColor, ltColors, invert=False)[source]ΒΆ
set_agent_at(agent_idx, row, col, in_direction, out_direction, is_selected, rail_grid=None, show_debug=False, clear_debug_text=True, malfunction=False)[source]ΒΆ
set_cell_occupied(agent_idx, row, col)[source]ΒΆ
set_predicion_path_at(row, col, binary_trans, agent_rail_color)[source]ΒΆ
set_rail_at(row, col, binary_trans, target=None, is_selected=False, rail_grid=None, num_agents=None, show_debug=True)[source]ΒΆ

Set the rail at cell (row, col) to have transitions binTrans. The target argument can contain the index of the agent to indicate that agent’s target is at that cell, so that a station can be rendered in the static rail layer.

flatland.utils.graphics_pil.main()[source]ΒΆ
flatland.utils.graphics_pil.main2()[source]ΒΆ