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_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_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()
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: channels_id.append(layer.get_id()) if cmy_id is not None: channels = [] channels.append({ "name": "Cyan", "channel": "C", "red": "red", "green": "1", "blue": "1", "alpha": "255" }) channels.append({