def apply_stroke(): global stroke_done, opacity_done, stroke_initial_color if opacity_done: image.undo() opacity_done = False if stroke_done: image.undo() stroke_done = False image.do_begin() if chosen_radius > 0.5: layer.duplicate() disk_id = layer.get_id() filters.blur(name=filters.BLUR_DISK, radius=chosen_radius-0.5) filters.filter_function(red=overlay_color.red/255, green=overlay_color.green/255, blue=overlay_color.blue/255, alpha="min(alpha*"+str(chosen_radius*5)+",(1-alpha)*"+str(chosen_radius*5)+")", gamma_correction=False) layer.select_id(stroke_layer_id) else: disk_id = None filters.blur(name=filters.BLUR_CORONA, radius=chosen_radius+0.5) filters.filter_function(red=overlay_color.red/255, green=overlay_color.green/255, blue=overlay_color.blue/255, alpha="min(alpha*"+str(chosen_radius)+",(1-alpha)*"+str(chosen_radius)+")", gamma_correction=False) if disk_id is not None: layer.select_id(disk_id) layer.merge_over() layer.set_registry("overlay-color", overlay_color) stroke_initial_color = overlay_color stroke_done = image.do_end() apply_opacity()
def apply_opacity(): global opacity_done, chosen_opacity, overlay_color if opacity_done: image.undo() opacity_done = False image.do_begin() layer.set_opacity(chosen_opacity) if overlay_color != stroke_initial_color: filters.filter_function(red=overlay_color.red/255, green=overlay_color.green/255, blue=overlay_color.blue/255, gamma_correction=False) layer.set_registry("overlay-color", overlay_color) opacity_done = image.do_end()
def create_shadow_layer(): global shadow_layer_id image.do_begin() if shadow_layer_id != None: layer.select_id(shadow_layer_id) layer.remove() layer.select_id(source_layer_id) layer.duplicate() layer.set_name(FRIENDLY_NAME + " - " + source_layer_name) layer.set_registry("shadow-source-layer-id", source_layer_id) shadow_layer_id = layer.get_id() shadow_index = image.get_layer_index() image.move_layer_index(shadow_index, shadow_index - 1) filters.filter_function(red=overlay_color.red / 255, green=overlay_color.green / 255, blue=overlay_color.blue / 255, gamma_correction=False) layer.set_registry("overlay-color", overlay_color) layer.set_opacity(chosen_opacity) 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()
"name": "Hue", "channel": "H", "hue": "hue", "saturation": "1", "lightness": "0.5", "alpha": "255", "blend": layer.BLEND_DRAW }) channels_id = [] for ch in channels: layer.select_id(layer_id) layer.duplicate() filters.filter_function(hue=ch["hue"], saturation=ch["saturation"], lightness=ch["lightness"], alpha=ch["alpha"], gamma_correction=False) layer.set_name(ch["name"] + " channel") layer.set_opacity(layer_opacity) if ch["channel"] != channels[-1]: layer.set_blend_op(ch["blend"]) layer.set_registry("split-channel", ch["channel"]) layer.set_registry("split-source-id", layer_id) channels_id.append(layer.get_id()) layer.select_id(layer_id) layer.set_registry("split-channels-id", channels_id) layer.set_visible(False) image.do_end()
"red": "max(max(red,green),blue)", "green": "max(max(red,green),blue)", "blue": "max(max(red,green),blue)", "alpha": "255" }) #channels.append({"name": "Black", "channel": "K", "hue":"0", "saturation": "0", "lightness": "max(max(red,green),blue)", "alpha": "255"}) channels_id = [] for ch in channels: layer.select_id(layer_id) layer.duplicate() filters.filter_function(red=ch.get("red"), green=ch.get("green"), blue=ch.get("blue"), hue=ch.get("hue"), saturation=ch.get("saturation"), lightness=ch.get("lightness"), alpha=ch["alpha"], gamma_correction=False, corrected_hue=False) layer.set_name(translation[ch["name"]]) layer.set_opacity(layer_opacity) if ch["channel"] == "A": layer.set_blend_op(layer.BLEND_MASK) layer.set_registry("split-channel", ch["channel"]) layer.set_registry("split-source-id", layer_id) if ch["channel"] == "K": black_id = layer.get_id() layer.duplicate() layer.set_blend_op(layer.BLEND_DIVIDE) black_div_id = layer.get_id()
"Supprimer ce calque pour enlever la teinte", "This is not a chromatic channel": "Ce n'est pas un canal chromatique" }, es={ "Remove this layer to remove hue": "Elimina esta capa para eliminar el tono", "This is not a chromatic channel": "Este no es un canal cromático" }, de={ "Remove this layer to remove hue": "Diese Ebene entfernen, um den Farbton zu entfernen", "This is not a chromatic channel": "Dies ist kein chromatischer Kanal" }, ) channel = layer.get_registry("split-channel") if channel == "R" or channel == "C": source = "red" elif channel == "G" or channel == "M": source = "green" elif channel == "B" or channel == "Y": source = "blue" elif channel == "H": dialog.show_message(translation["Remove this layer to remove hue"]) exit() else: dialog.show_message(translation["This is not a chromatic channel"]) exit() filters.filter_function(red=source, green=source, blue=source)
# Layer effect > Color overlay # (fr) Effet de calque > Couleur superposée # (es) Efectos de capa > Color superpuesto # (de) Ebeneneffekte > Farbüberlagerung from lazpaint import image, colors, layer, filters color = colors.show_dialog(layer.get_registry("overlay-color")) if color is not None: image.do_begin() filters.filter_function(red = color.red/255, green = color.green/255, blue = color.blue/255, gamma_correction = False) layer.set_registry("overlay-color", color) image.do_end()
# Mask > Mask from alpha channel # (fr) Masque > Masque depuis canal alpha # (es) Máscara > Máscara desde canal alpha # (de) Maske > Maske vom Alphakanal from lazpaint import image, layer, filters, 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.duplicate() layer.set_name(translation["Mask"]) filters.filter_function(red="alpha", green="alpha", blue="alpha", alpha=255, gamma_correction=False) layer.set_blend_op(layer.BLEND_MASK) image.do_end()
dialog.show_message(translation["Layer already split"]) exit() image.do_begin() channels = [] if layer_transparent: channels.append({"name": "Alpha", "channel": "A", "red": "alpha", "green": "alpha", "blue": "alpha", "alpha": "255"}) channels.append({"name": "Red", "channel": "R", "red": "red", "green": "0", "blue": "0", "alpha": "255"}) channels.append({"name": "Green", "channel": "G", "red": "0", "green": "green", "blue": "0", "alpha": "255"}) channels.append({"name": "Blue", "channel": "B", "red": "0", "green": "0", "blue": "blue", "alpha": "255"}) channels_id = [] for ch in channels: layer.select_id(layer_id) layer.duplicate() filters.filter_function(red = ch["red"], green = ch["green"], blue = ch["blue"], alpha = ch["alpha"], gamma_correction = False) layer.set_name(translation[ch["name"]]) layer.set_opacity(layer_opacity) if ch["channel"] == "A": layer.set_blend_op(layer.BLEND_MASK) elif ch != channels[-1]: layer.set_blend_op(layer.BLEND_LIGHTEN) layer.set_registry("split-channel", ch["channel"]) layer.set_registry("split-source-id", layer_id) channels_id.append(layer.get_id()) layer.select_id(layer_id) layer.set_registry("split-channels-id", channels_id) layer.set_visible(False) image.do_end()