def apply_offset(): global offset_done if offset_done: image.undo() offset_done = False image.do_begin() tools.choose(tools.MOVE_LAYER) tools.mouse([(0, 0), chosen_offset]) layer.set_opacity(chosen_opacity) offset_done = image.do_end()
def apply_blur(): global blur_done, opacity_done if opacity_done: image.undo() opacity_done = False if blur_done: image.undo() blur_done = False image.do_begin() if chosen_radius == 0: filters.filter_function(alpha=0, gamma_correction=False) else: layer.duplicate() layer.set_opacity(255) filters.filter_function(red="alpha", green="alpha", blue="alpha", alpha=1, gamma_correction=False) mask_layer_id = layer.get_id() layer.select_id(shadow_layer_id) filters.filter_function(red=overlay_color.red / 255, green=overlay_color.green / 255, blue=overlay_color.blue / 255, gamma_correction=False) tools.choose(tools.MOVE_LAYER) offset = (math.sin(chosen_angle * math.pi / 180) * chosen_radius, -math.cos(chosen_angle * math.pi / 180) * chosen_radius) tools.mouse([(0, 0), (offset[0], offset[1])]) layer.select_id(mask_layer_id) layer.duplicate() mask_layer_id2 = layer.get_id() layer.select_id(mask_layer_id) tools.choose(tools.MOVE_LAYER) tools.mouse([(offset[0] / 2, offset[1] / 2), (0, 0)]) colors.linear_negative() layer.set_blend_op(layer.BLEND_MASK) layer.merge_over() mask_layer_id = mask_layer_id2 filters.blur(radius=chosen_radius) layer.select_id(mask_layer_id) layer.set_blend_op(layer.BLEND_MASK) layer.merge_over() blur_done = image.do_end() apply_opacity()
def flush_line(): global line_buf if len(line_buf) > 0: tools.choose(tools.PEN) tools.mouse(line_buf) line_buf = []
# Mask > New mask # (fr) Masque > Nouveau masque # (es) Máscara > Máscara nueva # (de) Maske > Neue Maske from lazpaint import image, layer, tools, colors, selection, dialog translation = dialog.select_translation(en={"Mask": "Mask"}, fr={"Mask": "Masque"}, es={"Mask": "Máscara"}, de={"Mask": "Maske"}) image.do_begin() selection.deselect() layer_index = image.get_layer_index() layer.new(translation["Mask"]) mask_index = image.get_layer_index() image.move_layer_index(mask_index, layer_index + 1) layer.set_blend_op(layer.BLEND_MASK) tools.set_fore_color(colors.WHITE) tools.set_back_color(colors.BLACK) tools.choose(tools.FLOOD_FILL) tools.mouse((0, 0), [tools.STATE_LEFT]) image.do_end()
from lazpaint import tools, image, layer, colors image.new(800, 600) tools.choose(tools.PEN) tools.set_pen_width(10) tools.set_fore_color(colors.RED) tools.set_back_color(colors.ORANGE) tools.mouse( (50,50) ) tools.mouse( [(50,100, 0.5), (100,100, 0.5)], [tools.STATE_RIGHT] ) tools.choose(tools.ELLIPSE) tools.mouse( [(150,50), (250,150)], [tools.STATE_RIGHT] ) tools.set_fore_color(colors.YELLOW) tools.set_back_color(colors.BLUE) tools.keys(tools.KEY_RETURN) tools.choose(tools.PHONG_SHAPE) tools.set_light_position(500, 500) tools.mouse( [(50,300), (300,450)] ) tools.set_light_position(50, 600) tools.keys(tools.KEY_RETURN) tools.choose(tools.TEXT) tools.mouse( [(50,150), (450,350)] ) tools.set_fore_color(colors.BLACK) tools.set_font_style([tools.FONT_STYLE_ITALIC]) tools.set_font_size(20) tools.set_text_phong(False) tools.write("Hello\nworld")
def line(x, y, x2, y2): tools.choose(tools.PEN) tools.mouse([(x, y), (x2, y2)])