Difference between revisions of "LazPaint scripts"

From Free Pascal wiki
Jump to navigationJump to search
(created)
 
(→‎How to make a script: tutorial folder)
Line 23: Line 23:
  
 
So here is our hello world program:
 
So here is our hello world program:
   # Hello world program
+
   # Tutorial > Hello world program
 
   from lazpaint import dialog
 
   from lazpaint import dialog
 
   dialog.show_message("hello world")
 
   dialog.show_message("hello world")

Revision as of 07:54, 16 April 2020

Scripts are accessible from the Script menu. There are in Python language and stored in the scripts folder of the application.

Provided scripts

  • Channels: separate the color channels to RGB or HSL.
  • Layer effects: known layer effects like drop shadow, stroke or color overlay.
  • Mask: function to create a mask layer
  • Render: some example of using the tools from a script
  • Version: show the version of Python

How to make a script

A script is a text file with the extension .py that contains the code to run. The first line is a comment that contains the title of the script:

 # My script

Or if you want it to be in a submenu:

 # My folder > My script

You will need modules to communicate with Lazpaint from the script, so for example to show a message you would write:

 from lazpaint import dialog

To use a function from the module:

 dialog.show_message("hello world")

So here is our hello world program:

 # Tutorial > Hello world program
 from lazpaint import dialog
 dialog.show_message("hello world")

Available modules

  • colors: definitions of colors and color filters
  • command: send raw commands and get version of LazPaint
  • dialog: show messages and dialog boxes
  • filters: apply filters (other than color filters)
  • image: new, load, rotate...
  • imagelist: use the imagelist window (get next image, add files)
  • layer: configure layers, access pixels
  • selection: act on the selection (in particular the blue selection)
  • tools: use the tools by providing mouse positions and key strokes
  • view: zoom and grid