Ver código fonte

script types

johann 5 anos atrás
pai
commit
6eae9b8296

+ 2 - 0
lazpaint/dialog/filter/uphongfilter.pas

@@ -233,6 +233,8 @@ begin
     end;
     if IsDefined('AltitudePercent') then
       SpinEdit_Altitude.Value := Integers['AltitudePercent'];
+    if IsDefined('LightPosPercent') then
+      FCenter := Points2D['LightPosPercent']*(1/100);
     if IsDefined('LightXPercent') then
       FCenter.x := Floats['LightXPercent']/100;
     if IsDefined('LightYPercent') then

+ 1 - 0
lazpaint/dialog/filter/utwirl.pas

@@ -166,6 +166,7 @@ begin
   begin
     if IsDefined('Radius') then SpinEdit_Radius.Value := Floats['Radius'];
     if IsDefined('Angle') then SpinEdit_Angle.Value:= Floats['Angle'];
+    if IsDefined('CenterPosPercent') then FCenter := Points2D['CenterPosPercent']*(1/100);
     if IsDefined('CenterXPercent') then FCenter.X := Floats['CenterXPercent']/100;
     if IsDefined('CenterYPercent') then FCenter.Y := Floats['CenterYPercent']/100;
   end;

+ 1 - 0
lazpaint/dialog/filter/uwavedisplacement.pas

@@ -175,6 +175,7 @@ begin
     if IsDefined('WaveLength') then SpinEdit_Wavelength.Value := Integers['WaveLength'];
     if IsDefined('Displacement') then SpinEdit_Displacement.Value := Integers['Displacement'];
     if IsDefined('Phase') then SpinEdit_Phase.Value := Integers['Phase'];
+    if IsDefined('CenterPosPercent') then FCenter := Points2D['CenterPosPercent']*(1/100);
     if IsDefined('CenterXPercent') then FCenter.X := Floats['CenterXPercent']/100;
     if IsDefined('CenterYPercent') then FCenter.Y := Floats['CenterYPercent']/100;
   end;

+ 2 - 0
lazpaint/image/uimageaction.pas

@@ -195,6 +195,7 @@ begin
   Scripting.RegisterScriptFunction('GetPixel',@GenericScriptFunction,ARegister);
   Scripting.RegisterScriptFunction('GetImageWidth',@GenericScriptFunction,ARegister);
   Scripting.RegisterScriptFunction('GetImageHeight',@GenericScriptFunction,ARegister);
+  Scripting.RegisterScriptFunction('GetImageSize',@GenericScriptFunction,ARegister);
   Scripting.RegisterScriptFunction('PutImage',@ScriptPutImage,ARegister);
   Scripting.RegisterScriptFunction('LayerFill',@ScriptLayerFill,ARegister);
 end;
@@ -264,6 +265,7 @@ begin
   if f = 'GetLayerCount' then AVars.Integers['Result']:= Image.NbLayers else
   if f = 'GetFrameCount' then AVars.Integers['Result']:= Image.FrameCount else
   if f = 'GetPixel' then AVars.Pixels['Result']:= GetPixel(AVars.Integers['X'],AVars.Integers['Y']) else
+  if f = 'GetImageSize' then AVars.Points2D['Result']:= PointF(Image.Width,Image.Height) else
   if f = 'GetImageWidth' then AVars.Integers['Result']:= Image.Width else
   if f = 'GetImageHeight' then AVars.Integers['Result']:= Image.Height else
     result := srFunctionNotDefined;

+ 1 - 1
lazpaint/lazpaintinstance.pas

@@ -618,7 +618,7 @@ begin
         if params.IsReferenceDefined(vRes) then
         begin
           case vRes.variableType of
-          svtFloat, svtInteger, svtBoolean: AResult := params.GetString(vRes);
+          svtFloat, svtInteger, svtPoint, svtBoolean: AResult := params.GetString(vRes);
           svtString: AResult := ScriptQuote(params.GetString(vRes));
           svtPixel: AResult := '"'+BGRAToStr(params.GetPixel(vRes))+'"';
           svtFloatList..svtPixList: AResult := params.GetString(vRes);

+ 9 - 6
lazpaint/uscripttype.pas

@@ -82,7 +82,7 @@ function ScriptQuote(const S: string): string;
 function ScriptUnquote(const S: string): string;
 function UnescapeString(const S: string): string;
 function TryScriptUnquote(const S: String; out unquotedS: string): TInterpretationErrors;
-function FloatToStrUS(AValue: double): string;
+function FloatToStrUS(AValue: double; AExplicitDot: boolean = true): string;
 function ScalarToStr(AVarType: TScriptVariableType; const AValue): string;
 function ParseLitteral(var cur: integer; expr: string; var errors: TInterpretationErrors): TParsedLitteral;
 function ParseListType(s: string): TScriptVariableType;
@@ -97,10 +97,13 @@ uses BGRAUTF8;
 
 {$i quote.inc}
 
-function FloatToStrUS(AValue: double): string;
+function FloatToStrUS(AValue: double; AExplicitDot: boolean = true): string;
 var idxE,idxPt,beforeE,afterE: integer;
 begin
-  str(AValue,result);
+  if frac(AValue) = 0 then
+    str(AValue:15:0, result)
+  else
+    str(AValue,result);
   result := trim(result);
   idxE := pos('E',result);
   idxPt := pos('.',result);
@@ -141,7 +144,7 @@ begin
   end;
   idxE := pos('E',result);
   idxPt := pos('.',result);
-  if (idxE = 0) and (idxPt = 0) then result := result+'.0';
+  if AExplicitDot and (idxE = 0) and (idxPt = 0) then result := result+'.0';
 end;
 
 function ScalarToStr(AVarType: TScriptVariableType; const AValue): string;
@@ -152,9 +155,9 @@ begin
     svtPoint: with TPoint3D(AValue) do
               begin
                 if z <> EmptySingle then
-                  result := '(' + FloatToStrUS(x)+', '+FloatToStrUS(y)+', '+FloatToStrUS(z)+')'
+                  result := '(' + FloatToStrUS(x, false)+', '+FloatToStrUS(y, false)+', '+FloatToStrUS(z, false)+')'
                 else
-                  result := '(' + FloatToStrUS(x)+', '+FloatToStrUS(y)+')';
+                  result := '(' + FloatToStrUS(x, false)+', '+FloatToStrUS(y, false)+')';
               end;
     svtPixel: result := '#'+BGRAToStr(TBGRAPixel(AValue));
     svtBoolean: result := BoolToStr(Boolean(AValue),TrueToken,FalseToken);

+ 12 - 10
scripts/lazpaint/colors.py

@@ -2,14 +2,16 @@ import collections, math
 from lazpaint import dialog, command, filters
 
 GAMMA = 2.2
+ALPHA_OPAQUE = 255
+ALPHA_TRANSPARENT = 0
 
 if __name__ == "__main__":
   dialog.show_message("Library defining colors.")
 
-def to_linear(std_value):
+def to_linear(std_value: int): #0..255
   return math.pow(std_value/255, 1/GAMMA)
 
-def to_std(linear_value):
+def to_std(linear_value: float):
   return round(math.pow(linear_value, GAMMA)*255)
 
 CustomRGBA = collections.namedtuple("RGBA", "red, green, blue, alpha")
@@ -36,10 +38,10 @@ class RGBA(CustomRGBA):
     gray = to_std(to_linear(self.red)*0.299 + to_linear(self.green)*0.587 + to_linear(self.blue)*0.114)
     return RGBA(gray, gray, gray, self.alpha)
 
-def RGB(red,green,blue):
-  return RGBA(red,green,blue,255)
+def RGB(red: int, green: int, blue: int): #0..255
+  return RGBA(red, green, blue, 255)
 
-def str_to_RGBA(s):
+def str_to_RGBA(s: str):
   if s[0:1] == "#":
     s = s[1:]
   if len(s) == 6:
@@ -70,7 +72,7 @@ PURPLE = RGB(128,0,128)
 OLIVE = RGB(128,128,0)
 SILVER = RGB(192,192,192)
 
-def get_curve(points, posterize=False):
+def get_curve(points: list, posterize=False):
   return {'Points': points, 'Posterize': posterize}
 
 def curves(red=[], red_posterize=False, green=[], green_posterize=False, blue=[], blue_posterize=False, hue=[], hue_posterize=False, saturation=[], saturation_posterize=False, lightness=[], lightness_posterize=False, validate=True):
@@ -79,19 +81,19 @@ def curves(red=[], red_posterize=False, green=[], green_posterize=False, blue=[]
 def posterize(levels=None, by_lightness=True, validate=True):
   command.send('ColorPosterize', Levels=levels, ByLightness=by_lightness, Validate=validate)
 
-def colorize(hue_angle=None, saturation=None, correction=None, validate=True):
+def colorize(hue_angle=None, saturation=None, correction=None, validate=True): #saturation: 0..1
   command.send('ColorColorize', Hue=hue_angle, Saturation=saturation, Correction=correction, Validate=validate)
 
 def complementary():
   filters.run(filters.COLOR_COMPLEMENTARY)
 
-def shift(hue_angle=None, saturation=None, correction=None, validate=True):
+def shift(hue_angle=None, saturation=None, correction=None, validate=True): #saturation shift: -2..2
   command.send('ColorShiftColors', Hue=hue_angle, Saturation=saturation, Correction=correction, Validate=validate)
 
-def intensity(factor=None, shift=None, validate=True):
+def intensity(factor=None, shift=None, validate=True): #factor and shift: -2..2
   command.send('ColorIntensity', Factor=factor, Shift=shift, Validate=validate)
 
-def lightness(factor=None, shift=None, validate=True):
+def lightness(factor=None, shift=None, validate=True): #factor and shift: -2..2
   command.send('ColorLightness', Factor=factor, Shift=shift, Validate=validate)
 
 def negative():

+ 2 - 2
scripts/lazpaint/command.py

@@ -7,14 +7,14 @@ if input('') != chr(27) + 'LazPaint':
   print("Needs to be run from LazPaint.")
   exit()
 
-def parse_str(text):
+def parse_str(text: str):
   if text[:1] == "#":
     return text
   else:
     return ast.literal_eval(text)
 
 # sends a command to LazPaint
-def send(command, **keywords):
+def send(command: str, **keywords):
   if keywords is None:
     print(chr(27) + command)
   else:

+ 1 - 1
scripts/lazpaint/dialog.py

@@ -5,7 +5,7 @@ def show_message(message):
   # wait for validation before continuing script
   command.send("ShowMessage?", Message=message)
 
-def input_text(prompt, default=None):
+def input_text(prompt, default=None) -> str:
   return command.send("InputBox?", Prompt=prompt, Default=default)
 
 def input_value(prompt, default):

+ 17 - 13
scripts/lazpaint/filters.py

@@ -79,35 +79,39 @@ def run(name, validate=True):
   else:
     command.send("Filter", Name=name, Validate=validate)
 
-def blur(name=BLUR_FAST, radius=None, radius_x=None, radius_y=None, validate=True):
+def blur(name=BLUR_FAST, radius=None, validate=True): #radius: float or (x,y) 
+  if isinstance(radius, tuple):
+    radius_x = radius[0]
+    radius_y = radius[1]
+    radius = None
   command.send("Filter", Name=name, Radius=radius, RadiusX=radius_x, RadiusY=radius_y, Validate=validate)
 
-def blur_motion(distance=None, angle=None, oriented=None, validate=True):
+def blur_motion(distance=None, angle=None, oriented=None, validate=True): #oriented: bool
   command.send("Filter", Name=BLUR_MOTION, Distance=distance, Angle=angle, Oriented=oriented, Validate=validate)
 
-def sharpen(amount=None, validate=True):
+def sharpen(amount=None, validate=True): #amout: 0..10
   command.send("Filter", Name=SHARPEN, Amount=amount, Validate=validate)
 
-def noise(grayscale=None, opacity=None, validate=True):
+def noise(grayscale=None, opacity=None, validate=True): #grayscale: bool, opacity: 0..255
   command.send("Filter", Name=NOISE, Grayscale=grayscale, Opacity=opacity, Validate=validate)
 
 def pixelate(pixel_size=None, quality=None, validate=True):
   command.send("Filter", Name=PIXELATE, PixelSize=pixel_size, Quality=quality, Validate=validate)
 
-def filter_function(red=None, green=None, blue=None, alpha=None, hue=None, saturation=None, lightness=None, validate=True):
+def filter_function(red=None, green=None, blue=None, alpha=None, hue=None, saturation=None, lightness=None, validate=True): #expressions: str
   command.send("Filter", Name=FILTER_FUNCTION, Red=red, Green=green, Blue=blue, Alpha=alpha, Hue=hue, Saturation=saturation, Lightness=lightness, Validate=validate)
 
 def emboss(angle=None, transparent=None, preserve_colors=None, validate=True):
   command.send("Filter", Name=EMBOSS, Angle=angle, Transparent=transparent, PreserveColors=preserve_colors, Validate=validate)
 
-def rain(amount=None, wind=None, validate=True):
-  command.send("Filter", Name=RAIN, Amount=amount, Wind=wind, Validate=validate)
+def rain(amount=None, wind=None, validate=True): #amount and wind: 0..2
+  command.send("Filter", Name=RENDER_RAIN, Amount=amount, Wind=wind, Validate=validate)
 
-def phong(color_source=None, altitude_percent=None, altitude_source=None, light_x_percent=None, light_y_percent=None, validate=True):
-  command.send("Filter", Name=PHONG, ColorSource=color_source, AltitudePercent=altitude_percent, AltitudeSource=altitude_source, LightXPercent=light_x_percent, LightYPercent=light_y_percent, Validate=validate)
+def phong(color_source=None, altitude_percent=None, altitude_source=None, light_pos_percent=None, light_x_percent=None, light_y_percent=None, validate=True):  
+  command.send("Filter", Name=PHONG, ColorSource=color_source, AltitudePercent=altitude_percent, AltitudeSource=altitude_source, LightPosPercent=light_pos_percent, LightXPercent=light_x_percent, LightYPercent=light_y_percent, Validate=validate)
 
-def twirl(radius=None, angle=None, center_x_percent=None, center_y_percent=None, validate=True):
-  command.send("Filter", Name=TWIRL, Radius=radius, Angle=angle, CenterXPercent=center_x_percent, CenterYPercent=center_y_percent, Validate=validate)
+def twirl(radius=None, angle=None, center_pos_percent=None, center_x_percent=None, center_y_percent=None, validate=True):
+  command.send("Filter", Name=TWIRL, Radius=radius, Angle=angle, CenterPosPercent=center_pos_percent, CenterXPercent=center_x_percent, CenterYPercent=center_y_percent, Validate=validate)
 
-def wave_displacement(wave_length=None, displacement=None, phase=None, center_x_percent=None, center_y_percent=None, validate=True):
-  command.send("Filter", Name=WAVE_DISPLACEMENT, WaveLength=wave_length, Displacement=displacement, Phase=phase, CenterXPercent=center_x_percent, CenterYPercent=center_y_percent, Validate=validate)
+def wave_displacement(wave_length=None, displacement=None, phase=None, center_pos_percent=None, center_x_percent=None, center_y_percent=None, validate=True): #phase: 0..360
+  command.send("Filter", Name=WAVE_DISPLACEMENT, WaveLength=wave_length, Displacement=displacement, Phase=phase, CenterPosPercent=center_pos_percent, CenterXPercent=center_x_percent, CenterYPercent=center_y_percent, Validate=validate)

+ 21 - 18
scripts/lazpaint/image.py

@@ -25,18 +25,21 @@ ANCHOR_BOTTOM_LEFT = 'BottomLeft'
 ANCHOR_BOTTOM = 'Bottom'
 ANCHOR_BOTTOM_RIGHT = 'BottomRight' 
 
-def new(width, height, color=colors.TRANSPARENT, ignore_modified=False):
+def new(width: int, height: int, color=colors.TRANSPARENT, ignore_modified=False):
   command.send("FileNew", Width=width, Height=height, BackColor=color, IgnoreModified=ignore_modified)
 
 def paste_as_new():
   command.send("EditPasteAsNew")
 
-def get_width():
+def get_width() -> int:
   return command.send("GetImageWidth?")
 
-def get_height():
+def get_height() -> int:
   return command.send("GetImageHeight?")
 
+def get_size() -> tuple:
+  return command.send("GetImageSize?")
+
 def get_registry(identifier):
   str_result = command.send("ImageGetRegistry?", Identifier=identifier)
   if str_result == "":
@@ -51,46 +54,46 @@ def set_registry(identifier, value):
     value = str(value)
   command.send("ImageSetRegistry", Identifier=identifier, Value=value)
 
-def get_layer_index(layer_id=None):
+def get_layer_index(layer_id=None) -> int:
   return command.send("GetLayerIndex?", LayerId=layer_id)
 
-def select_layer_index(index):
+def select_layer_index(index: int): #1..layer_count
   return command.send("SelectLayerIndex", Index=index)
 
-def move_layer_index(from_index, to_index):
+def move_layer_index(from_index: int, to_index: int):
   return command.send("ImageMoveLayerIndex", FromIndex=from_index, ToIndex=to_index)
 
-def get_layer_count():
+def get_layer_count() -> int:
   return command.send("GetLayerCount?")
 
-def get_frame_index():
+def get_frame_index() -> int: #1..frame_count
   return command.send("GetFrameIndex?")
 
-def get_frame_count():
+def get_frame_count() -> int:
   return command.send("GetFrameCount?")
 
-def load_frame(frame_index=None, ignore_modified=False):
+def load_frame(frame_index=None, ignore_modified=False) -> int:
   return command.send("FileChooseEntry?", EntryIndex=frame_index, IgnoreModified=ignore_modified)
 
-def new_frame(width=None, height=None, back_color=colors.TRANSPARENT, ignore_modified=False):
+def new_frame(width=None, height=None, back_color=colors.TRANSPARENT, ignore_modified=False) -> int:
   command.send("FileNewEntry", Width=width, Height=height, BackColor=back_color, IgnoreModified=ignore_modified)
 
 def open(file_name=None, ignore_modified=False):
   command.send("FileOpen", FileName=file_name, IgnoreModified=ignore_modified)
 
-def save(skip_options=False):
+def save(skip_options=False) -> str:
   return command.send("FileSave?", SkipOptions=skip_options)
 
-def save_as(file_name=None, validate=False, overwrite=False, skip_options=False):
+def save_as(file_name=None, validate=False, overwrite=False, skip_options=False) -> str:
   return command.send("FileSaveAs?", FileName=file_name, Validate=validate, Overwrite=overwrite, SkipOptions=skip_options) 
 
 def reload(ignore_modified=False):
   command.send("FileReload", IgnoreModified=ignore_modified)
 
-def get_name():
+def get_name() -> str:
   return command.send("GetFileName?")
 
-def resample(width, height, quality=RESAMPLE_QUALITY_BEST):
+def resample(width: int, height: int, quality=RESAMPLE_QUALITY_BEST):
   command.send("ImageResample", Width=width, Height=height, Quality=quality, Validate=True)
 
 def smart_zoom3():
@@ -126,10 +129,10 @@ def crop_to_selection_and_layer():
 def flatten():
   command.send("ImageFlatten")
 
-def canvas_size(width, height, anchor=ANCHOR_MIDDLE):
+def canvas_size(width: int, height: int, anchor=ANCHOR_MIDDLE):
   command.send("ImageCanvasSize", Width=width, Height=height, Anchor=anchor)
 
-def repeat(width, height, anchor=ANCHOR_MIDDLE, flip=False):
+def repeat(width: int, height: int, anchor=ANCHOR_MIDDLE, flip=False):
   command.send("ImageRepeat", Width=width, Height=height, Anchor=anchor, Flip=flip)
 
 def undo():
@@ -143,6 +146,6 @@ def do_begin():
   command.send("EditDoBegin")
 
 # returns True if some action was done within the series of actions
-def do_end():
+def do_end() -> bool:
   return command.send("EditDoEnd?")
 

+ 14 - 14
scripts/lazpaint/layer.py

@@ -43,49 +43,49 @@ BLEND_SVG_SOFT_LIGHT = 'SvgSoftLight'
 def get_id():
   return command.send("LayerGetId?")
 
-def get_name():
+def get_name() -> str:
   return command.send("LayerGetName?")
 
-def get_opacity():
+def get_opacity() -> int:
   return command.send("LayerGetOpacity?")
 
 def get_blend_op():
   return command.send("LayerGetBlendOp?")
 
-def get_visible():
+def get_visible() -> bool:
   return command.send("LayerGetVisible?")
 
 def select_id(id):
   command.send("LayerSelectId", Id=id)
 
-def set_name(name):
+def set_name(name: str):
   return command.send("LayerSetName", Name=name)
 
-def set_opacity(opacity):
+def set_opacity(opacity: int):
   return command.send("LayerSetOpacity", Opacity=opacity)
 
 def set_blend_op(blend_op):
   return command.send("LayerSetBlendOp", BlendOp=blend_op)
 
-def set_visible(visible):
+def set_visible(visible: bool):
   return command.send("LayerSetVisible", Visible=visible)
 
-def new():
+def new(): #-> id
   return command.send("LayerAddNew?")
 
-def paste_as_new():
+def paste_as_new(): #-> id
   return command.send("EditPasteAsNewLayer?")
 
-def add_from_file(file_name):
+def add_from_file(file_name): #-> id
   return command.send("LayerFromFile?", FileName=file_name)
 
-def duplicate():
+def duplicate(): #-> id
   return command.send("LayerDuplicate?")
 
 def merge_over():
   command.send("LayerMergeOver")
 
-def is_empty():
+def is_empty() -> bool:
   return command.send("IsLayerEmpty?")
 
 def get_registry(identifier):
@@ -105,13 +105,13 @@ def set_registry(identifier, value):
 def remove():
   command.send("LayerRemoveCurrent")
 
-def get_count():
+def get_count() -> int:
   return command.send("GetLayerCount?")
 
 def rasterize():
   command.send("LayerRasterize")
 
-def put_image(x, y, image, mode=DM_DRAW, opacity=255):
+def put_image(x: int, y: int, image, mode=DM_DRAW, opacity=255):
   height = len(image)
   if height == 0: return
   width = max([len(scanline) for scanline in image])
@@ -120,7 +120,7 @@ def put_image(x, y, image, mode=DM_DRAW, opacity=255):
     flattened += "".join([str(color) for color in scanline]) + "00000000" * (width - len(scanline))
   command.send("PutImage", X=x, Y=y, Width=width, Height=height, Data=flattened, Mode=mode, Opacity=opacity)
 
-def get_pixel(x, y):
+def get_pixel(x: int, y: int):
   return colors.str_to_RGBA(command.send("GetPixel?", X=x, Y=y))
 
 def fill(color, mode=DM_DRAW):

+ 3 - 3
scripts/lazpaint/selection.py

@@ -6,7 +6,7 @@ if __name__ == "__main__":
 def load(file_name=None):
   command.send("FileLoadSelection", FileName=file_name)
 
-def save_as(file_name=None):
+def save_as(file_name=None) -> str:
   return command.send("FileSaveSelectionAs?", FileName=file_name)
 
 def invert():
@@ -30,10 +30,10 @@ def select_all():
 def fit():
   command.send("EditSelectionFit")
 
-def is_mask_empty():
+def is_mask_empty() -> bool:
   return command.send("IsSelectionMaskEmpty?")
 
-def is_layer_empty():
+def is_layer_empty() -> bool:
   return command.send("IsSelectionLayerEmpty?")
 
 def paste():

+ 27 - 29
scripts/lazpaint/tools.py

@@ -200,13 +200,13 @@ def set_eraser_mode(mode):
 def get_eraser_mode():
   return command.send('ToolGetEraserMode?')
 
-def set_eraser_alpha(alpha):
+def set_eraser_alpha(alpha: int): #0..255
   command.send('ToolSetEraserAlpha', Alpha=alpha)
 
-def get_eraser_alpha():
+def get_eraser_alpha() -> int:
   return command.send('ToolGetEraserAlpha?')
 
-def set_pen_width(width):
+def set_pen_width(width: float):
   command.send('ToolSetPenWidth', Width=width)
 
 def get_pen_width():
@@ -230,54 +230,52 @@ def set_line_cap(cap):
 def get_line_cap():
   return command.send('ToolGetLineCap?')
 
-def set_shape_options(options):
+def set_shape_options(options: list):
   command.send('ToolSetShapeOptions', Options=options)
 
-def get_shape_options():
+def get_shape_options() -> list:
   return command.send('ToolGetShapeOptions?')
 
-def set_aliasing(enabled):
+def set_aliasing(enabled: bool):
   command.send('ToolSetAliasing', Enabled=enabled)
 
-def get_aliasing():
+def get_aliasing() -> bool:
   return command.send('ToolGetAliasing?')
 
-def set_shape_ratio(ratio):
+def set_shape_ratio(ratio: float):
   command.send('ToolSetShapeRatio', Ratio=ratio)
 
-def get_shape_ratio():
+def get_shape_ratio() -> float:
   return command.send('ToolGetShapeRatio?')
 
-def set_brush_index(index):
+def set_brush_index(index: int):
   command.send('ToolSetBrushIndex', Index=index)
 
-def get_brush_index():
+def get_brush_index() -> int:
   return command.send('ToolGetBrushIndex?')
 
-def get_brush_count(): 
+def get_brush_count() -> int: 
   return command.send('ToolGetBrushCount?')
 
-def set_brush_spacing(index):
-  command.send('ToolSetBrushSpacing', Index=index)
+def set_brush_spacing(spacing: int):
+  command.send('ToolSetBrushSpacing', Spacing=spacing)
 
-def get_brush_spacing():
+def get_brush_spacing() -> int:
   return command.send('ToolGetBrushSpacing?')
 
-def set_font_name(name):
+def set_font_name(name: str):
   command.send('ToolSetFontName', Name=name)
 
-def get_font_name():
+def get_font_name() -> str:
   return command.send('ToolGetFontName?')
 
-def set_font_size(size):
+def set_font_size(size: float):
   command.send('ToolSetFontSize', Size=size)
 
-def get_font_size():
+def get_font_size() -> float:
   return command.send('ToolGetFontSize?')
 
-def set_font_style(style):
-  if not isinstance(style, list):
-    style = [style]
+def set_font_style(style: list):
   command.send('ToolSetFontStyle', Style=style)
 
 def get_font_style():
@@ -289,22 +287,22 @@ def set_text_align(align):
 def get_text_align():
   return command.send('ToolGetTextAlign?')
 
-def set_text_outline(width):
+def set_text_outline(width: float):
   command.send('ToolSetTextOutline', Width=width)
 
-def get_text_outline():
+def get_text_outline() -> float:
   return command.send('ToolGetTextOutline?')
 
-def set_text_phong(enabled):
+def set_text_phong(enabled: bool):
   command.send('ToolSetTextPhong', Enabled=enabled)
 
-def get_text_phong():
+def get_text_phong() -> bool:
   return command.send('ToolGetTextPhong?')
 
-def set_light_position(x, y):
+def set_light_position(x: float, y: float):
   command.send('ToolSetLightPosition', Position=(x, y))
 
-def get_light_position():
+def get_light_position() -> tuple:
   return command.send('ToolGetLightPosition?')
 
 def set_arrow_start(arrow):
@@ -322,6 +320,6 @@ def get_arrow_end():
 def set_arrow_size(x, y):
   command.send('ToolSetArrowSize', Size=(x, y))
 
-def get_arrow_size():
+def get_arrow_size() -> tuple:
   return command.send('ToolGetArrowSize?')
 

+ 3 - 3
scripts/lazpaint/view.py

@@ -9,14 +9,14 @@ def zoom_out(fine=False):
 def zoom_fit():
   command.send("ViewZoomFit")
 
-def set_zoom(factor=1):
+def set_zoom(factor=1.0):
   command.send("ViewZoomSet", Factor=factor)
 
-def get_zoom():
+def get_zoom() -> float:
   return command.send("ViewZoomGet?")
 
 def set_grid_visible(visible=None):
   command.send("ViewGrid", Visible=visible)
 
-def get_grid_visible():
+def get_grid_visible() -> bool:
   return command.send("ViewGridGet?")

+ 7 - 6
scripts/test_color.py

@@ -1,10 +1,11 @@
 from lazpaint import colors, image
 
 #image.flatten()
-colors.curves(red=[(0, 0), (0.25, 1), (1, 1)])
-colors.curves(lightness=[(0, 0), (0.25, 1), (1, 1)])
-colors.posterize(levels=8, by_lightness=True)
-colors.colorize(hue_angle=0, saturation=0.8, correction=False)
-colors.complementary()
-colors.shift(hue_angle=90, saturation=0, correction=True)
+#colors.curves(red=[(0, 0), (0.25, 1), (1, 1)])
+#colors.curves(lightness=[(0, 0), (0.25, 1), (1, 1)])
+#colors.posterize(levels=8, by_lightness=True)
+#colors.colorize(hue_angle=180, saturation=0.8, correction=False)
+colors.lightness(-1, 0)
+#colors.complementary()
+#colors.shift(hue_angle=90, saturation=0, correction=True)
 

+ 3 - 2
scripts/test_filter.py

@@ -1,11 +1,12 @@
 from lazpaint import filters, image
 
 #filters.filter_function(green="green*2")
-#filters.phong(color_source=filter.PHONG_COLOR_LAYER, light_x_percent=20, light_y_percent=20, altitude_percent=30, altitude_source=filter.PHONG_ALTITUDE_ALPHA_CHANNEL)
+filters.phong(color_source=filters.PHONG_COLOR_LAYER, light_x_percent=20, light_y_percent=20, altitude_percent=30, altitude_source=filters.PHONG_ALTITUDE_ALPHA_CHANNEL)
 #filters.emboss(angle=45, transparent=False, preserve_colors=True)
 #filters.noise(grayscale=True, opacity=128)
-#filters.pixelate(20, filter.PIXELATE_QUALITY_BEST)
+filters.pixelate(20, filters.PIXELATE_QUALITY_BEST)
 #filters.twirl(radius=min(image.get_width(),image.get_height())/2, angle=360)
 #filters.blur_motion(50, 45, True)
 #filters.sharpen(1)
 filters.wave_displacement(100,30,0,25,25)
+filters.rain(0.5, 0.5)

+ 1 - 0
scripts/test_image.py

@@ -1,5 +1,6 @@
 from lazpaint import image, layer, colors, view, dialog
 
+dialog.show_message(image.get_size())
 w = 256
 h = 256
 image.new(2, 2)

+ 1 - 1
scripts/test_tools.py

@@ -24,7 +24,7 @@ tools.keys(tools.KEY_RETURN)
 tools.choose(tools.TEXT)
 tools.mouse( [(50,150), (450,350)] )
 tools.set_pen_color(colors.BLACK)
-tools.set_font_style(tools.FONT_STYLE_ITALIC)
+tools.set_font_style([tools.FONT_STYLE_ITALIC])
 tools.set_font_size(20)
 tools.set_text_phong(False)
 tools.write("Hello\nworld")