Exemple #1
0
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
    if opacity_done:
        image.undo()
        opacity_done = False
    image.do_begin()
    layer.set_opacity(chosen_opacity)
    opacity_done = image.do_end()
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()
Exemple #4
0
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 apply_blur():
    global blur_done, offset_done
    if offset_done:
        image.undo()
        offset_done = False
    if blur_done:
        image.undo()
        blur_done = False
    image.do_begin()
    filters.blur(radius=chosen_radius)
    blur_done = image.do_end()
    apply_offset()
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 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.rasterize()
    layer.set_name(FRIENDLY_NAME + " of " + source_layer_name)
    layer.set_registry(REGISTRY_NAME + "-source-layer-id", source_layer_id)
    shadow_layer_id = layer.get_id()
    layer.set_registry("overlay-color", overlay_color)
    layer.set_opacity(chosen_opacity)
    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()
Exemple #9
0
def create_stroke_layer():
    global stroke_layer_id
    image.do_begin()
    if stroke_layer_id != None:
        layer.select_id(stroke_layer_id)
        stroke_index = image.get_layer_index()
        selection.select_all()
        selection.delete()
        layer.select_id(source_layer_id)
        layer.duplicate()
        image.move_layer_index(image.get_layer_index(), stroke_index+1)
        layer.merge_over()        
    else:
        layer.select_id(source_layer_id)
        layer.duplicate()
        layer.set_name("Stroke of "+source_layer_name)
        layer.set_registry("stroke-source-layer-id", source_layer_id)
        stroke_layer_id = layer.get_id()
        stroke_index = image.get_layer_index()
        image.move_layer_index(stroke_index, stroke_index-1)
    image.do_end()
Exemple #10
0
    dialog.show_message("Layer already split")
    exit()

layer_id = layer.get_id()
layer_index = image.get_layer_index()
layer_opacity = layer.get_opacity()
layer_transparent = layer.is_transparent()

# check if it has been split
if layer.get_registry("split-channels-id") is not None:
    for cur_layer_id in image.iterate_layers():
        if layer.get_registry("split-source-id") == layer_id:
            dialog.show_message("Layer already split")
            exit()

image.do_begin()
channels = []
if layer_transparent:
    channels.append({
        "name": "Alpha",
        "channel": "A",
        "hue": "0",
        "saturation": "0",
        "lightness": "alpha",
        "alpha": "255",
        "blend": layer.BLEND_MASK
    })
channels.append({
    "name": "Saturation",
    "channel": "S",
    "hue": "0",