tools.choose(tools.PEN) tools.mouse(line_buf) line_buf = [] DEG_TO_RAD = math.pi / 180 ANGLE = abs(dialog.input_value("Angle (< 90)", 45)) if ANGLE >= 90: dialog.show_message("Invalid angle") DEFAULT_SIZE_Y = 7 * 8 / 2 * 2 * (1.14 + math.cos(ANGLE * DEG_TO_RAD)) / 2.14 MULTIPLIER = image.get_height() / DEFAULT_SIZE_Y ZOOM = dialog.input_value("Vertical size (%)", 95) MULTIPLIER = MULTIPLIER * ZOOM / 100 def drawTree(x1, y1, angle, depth): if (depth > 0): x2 = x1 + (math.cos(angle * DEG_TO_RAD) * depth * MULTIPLIER) y2 = y1 + (math.sin(angle * DEG_TO_RAD) * depth * MULTIPLIER) line(x1, y1, x2, y2) drawTree(x2, y2, angle - ANGLE, depth - 2) drawTree(x2, y2, angle + ANGLE, depth - 2) image.do_begin() layer.new() drawTree(image.get_width() / 2, image.get_height(), -90, 14) flush_line() image.do_end()
for cur_layer_id in image.iterate_layers(): cur_source_id = layer.get_registry("split-source-id") if cur_source_id == layer_id: channels_id.insert(0, cur_layer_id) if new_layer_index is None: new_layer_index = image.get_layer_index() else: layer_id = layer.get_id() channels_id = layer.get_registry("split-channels-id") new_layer_index = image.get_layer_index() + 1 if channels_id is None: dialog.show_message("Current layer is not split") exit() layer.new("Merged channels") image.move_layer_index(image.get_layer_index(), new_layer_index) for cur_layer_id in reversed(channels_id): layer.select_id(cur_layer_id) image.move_layer_index(image.get_layer_index(), new_layer_index + 1) layer.merge_over() new_layer_id = layer.get_id() if image.contains_layer_id(layer_id): layer.select_id(layer_id) layer_index = image.get_layer_index() layer_name = layer.get_name() layer_opacity = layer.get_opacity() image.move_layer_index(new_layer_index, layer_index + 1)
# Mask > New mask from lazpaint import image, layer, tools, colors, selection image.do_begin() selection.deselect() layer_index = image.get_layer_index() layer.new("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()
# 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()
for cur_layer_id in image.iterate_layers(): cur_source_id = layer.get_registry("split-source-id") if cur_source_id == layer_id: channels_id.insert(0, cur_layer_id) if new_layer_index is None: new_layer_index = image.get_layer_index() else: layer_id = layer.get_id() channels_id = layer.get_registry("split-channels-id") new_layer_index = image.get_layer_index() + 1 if channels_id is None: dialog.show_message(translation["Current layer is not split"]) exit() layer.new(dialog.get_script_name()) image.move_layer_index(image.get_layer_index(), new_layer_index) for cur_layer_id in reversed(channels_id): layer.select_id(cur_layer_id) image.move_layer_index(image.get_layer_index(), new_layer_index + 1) layer.merge_over() new_layer_id = layer.get_id() if image.contains_layer_id(layer_id): layer.select_id(layer_id) layer_index = image.get_layer_index() layer_name = layer.get_name() layer_opacity = layer.get_opacity() image.move_layer_index(new_layer_index, layer_index + 1)