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()
Beispiel #2
0
    "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()
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()
        layer.select_id(layer_id)
        layer.duplicate()
        copy_index = image.get_layer_index()
        image.move_layer_index(copy_index, copy_index + 1)
        image.select_layer_index(copy_index + 2)
        layer.merge_over()
        cmy_id = layer.get_id()
    else:
# 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()
b = Image.merge("RGB", [zero, zero, im.getchannel("B")])

image.do_begin()

layer.select_id(layer_id)
layer.set_visible(False)

channels = [(r, "Red", "R"), (g, "Green", "G"), (b, "Blue", "B")]
if layer_transparent:
  a = im.getchannel("A")
  channels.insert(0, (a, "Alpha", "A"))

channels_id = []
for ch in channels:
  ch[0].save(temp_name, "BMP")
  layer.add_from_file(temp_name)
  layer.set_name(ch[1] + " channel")
  layer.set_opacity(layer_opacity)
  if ch[2] == "A":
    layer.set_blend_op(layer.BLEND_MASK)
  elif ch[2] != channels[-1][2]:
    layer.set_blend_op(layer.BLEND_LIGHTEN)
  layer.set_registry("split-channel", ch[2])
  layer.set_registry("split-source-id", layer_id)
  channels_id.append(layer.get_id())
  image.move_layer_index(image.get_layer_index(), layer_index+1)

layer.select_id(layer_id)
layer.set_registry("split-channels-id", channels_id)
image.do_end()
Beispiel #6
0
# Render > Lava
# (fr) Rendu > Lave
# (es) Renderizar > Lava
# (de) Rendering > Lava
from lazpaint import image, layer, filters, colors, dialog

image.do_begin()
layer.new()
filters.run(filters.RENDER_WOOD)
layer.new()
filters.run(filters.RENDER_WATER)
layer.set_blend_op(layer.BLEND_LINEAR_SUBTRACT)
layer.merge_over()
layer.set_name(dialog.get_script_name())
image.do_end()