Krita/Scripting: Difference between revisions

From KDE Community Wiki
(formatting)
(usage for scripting: sharing/posting on-line via image hosters or social networks)
 
(3 intermediate revisions by 2 users not shown)
Line 2: Line 2:


== IRC log ==
== IRC log ==
19:22 < a----> C------B perhaps I think layer management would be important and useful to start with
< a----> C------B perhaps I think layer management would be important and useful to start with<br/>
19:22 < a----> E.g. adding a layer, positioning a layer and controlling common attributes like opacity special layers like masks etc. can come later.
< a----> E.g. adding a layer, positioning a layer and controlling common attributes like opacity special layers like masks etc. can come later.<br/>
19:23 < C------B> a----: that is actually what I am looking at now
< C------B> a----: that is actually what I am looking at now<br/>
19:24 < a----> that would be a good place to start I think.
< a----> that would be a good place to start I think.<br/>
19:24 < a----> Things like brush engines, brush opacity control are better done from within Krita and should not need to be used externally.
< a----> Things like brush engines, brush opacity control are better done from within Krita and should not need to be used externally.<br/>
19:28 < A-----o> C------B, I'd love to make a plugin that deletes the current layer (or fills it with a color) when I lift the pen from the tablet, so I guess being able to listen to pen  
< A-----o> C------B, I'd love to make a plugin that deletes the current layer (or fills it with a color) when I lift the pen from the tablet, so I guess being able to listen to pen events would be cool<br/>
                events would be cool
< A-----o> C------B, I'd also love to make some plugins that allow you to use external hardware to control e.g. brush parameters, so that would be cool<br/>
19:28 < A-----o> C------B, I'd also love to make some plugins that allow you to use external hardware to control e.g. brush parameters, so that would be cool
< a----> C------B I think its better to start from the outside gross functionalioty and then go to more deeper layers of Krita like an onion.<br/>
19:33 < a----> C------B I think its better to start from the outside gross functionalioty and then go to more deeper layers of Krita like an onion.


== Usecases ==
== Usecases ==
Line 24: Line 23:
# Pseudo filters like 'split alpha' or 'split layer' or 'seperate image'.
# Pseudo filters like 'split alpha' or 'split layer' or 'seperate image'.


Example use-case: Game Texturer:
 
=== Game Texturer ===
 
Has a file with three layers, called 'specular', 'diffuse', 'normal'.
Has a file with three layers, called 'specular', 'diffuse', 'normal'.
What they want to do is to make 'specular' the alpha channel of 'diffuse', and have the diffuse and normal layers exported as filename-layername.tiff.
What they want to do is to make 'specular' the alpha channel of 'diffuse', and have the diffuse and normal layers exported as filename-layername.tiff.
So the commands needed would be...
So the commands needed would be...
* Find layer 'specular'
* Find layer 'specular'
Line 36: Line 39:
* Export layer 'normal' as 'filename-normal.tiff'
* Export layer 'normal' as 'filename-normal.tiff'


Example use-case: Comic artist.
 
=== Comic artist ===
 
Has a file with several 'sketchlayers' a 'colour-layer' and 'lineart' layers.
Has a file with several 'sketchlayers' a 'colour-layer' and 'lineart' layers.
They would want to resize their files, and maybe even grayscale them:
They would want to resize their files, and maybe even grayscale them:
* Find all layers with name 'sketch'
* Find all layers with name 'sketch'
* Turn all these layers invisible.
* Turn all these layers invisible.
Line 47: Line 54:
* save as 'filename-800pxwide.png'
* save as 'filename-800pxwide.png'


Example use-case: Live export
 
=== Live export ===


Export the image as displayed on-screen (all layers merged) to a shared memory region for other applications to read. Interesting for game-developers et cetera who would like to have a preview of the texture they are editing right in their game.
Export the image as displayed on-screen (all layers merged) to a shared memory region for other applications to read. Interesting for game-developers et cetera who would like to have a preview of the texture they are editing right in their game.
* Example with gimp: https://www.youtube.com/watch?v=2M9-_zpfEm4
* Example with gimp: https://www.youtube.com/watch?v=2M9-_zpfEm4
* Requires efficient access to pixel-data
* Requires efficient access to pixel-data
* Requires access to pixel-data that is generated by already merging all layers correctly
* Requires access to pixel-data that is generated by already merging all layers correctly


Example use-case: Control brush parameters


Some artists like to use e.g. external hardware (e.g. with a scrollwheel or thumbstick) to interact with their painting program. It would be cool if it was possible for a plugin to manipulate brush parameters (size, flow, ...) on the fly through input it receives from e.g. external control-hardware or other such sources.
=== Control brush parameters ===


Example use-case: Warmup-script
Some artists like to use e.g. external hardware (e.g. with a scrollwheel or thumbstick, like an xbox-controller) to interact with their painting program. It would be cool if it was possible for a plugin to manipulate brush parameters (size, flow, ...) on the fly through input it receives from e.g. external control-hardware or other such sources.
 
 
=== Warmup-script ===


I like to use a script that deletes the entire canvas when I lift the stylus off my wacom tablet. Together with repeated or symmetry mode, as well as a speed sketch brush, it makes for a very nice way to generate shapes very quickly and warm up your "visual library". Currently I have this implemented in a very hacky way, if it was possible for plugins to listen for events such as "stroke end" or "pen lifted" and then issue a "clear canvas" command, this could be a simple 10-line script.
I like to use a script that deletes the entire canvas when I lift the stylus off my wacom tablet. Together with repeated or symmetry mode, as well as a speed sketch brush, it makes for a very nice way to generate shapes very quickly and warm up your "visual library". Currently I have this implemented in a very hacky way, if it was possible for plugins to listen for events such as "stroke end" or "pen lifted" and then issue a "clear canvas" command, this could be a simple 10-line script.


Big idea:
=== Easy on-line sharing/posting ===
 
When you're discussing with friends or you're keeping your friends up to date with WiP snapshots of something you're working on, you'll usually want to post these pictures online somewhere. There's many popular image sharing sites (I like using imgur; on #krita, pasteall.org seems popular) and of course there's social networks you could post to.
 
=== Big idea ===


A way to conveniently share scripts, similar to the GHNS mechanism that many other KDE components have, or the gimp/blender plugin registry? Users probably need to be told that plugins are not sandboxed!
A way to conveniently share scripts, similar to the GHNS mechanism that many other KDE components have, or the gimp/blender plugin registry? Users probably need to be told that plugins are not sandboxed!

Latest revision as of 01:22, 26 June 2015

This page is going to collect ideas on how to write the new scripting API for Krita 3.x

IRC log

< a----> C------B perhaps I think layer management would be important and useful to start with
< a----> E.g. adding a layer, positioning a layer and controlling common attributes like opacity special layers like masks etc. can come later.
< C------B> a----: that is actually what I am looking at now
< a----> that would be a good place to start I think.
< a----> Things like brush engines, brush opacity control are better done from within Krita and should not need to be used externally.
< A-----o> C------B, I'd love to make a plugin that deletes the current layer (or fills it with a color) when I lift the pen from the tablet, so I guess being able to listen to pen events would be cool
< A-----o> C------B, I'd also love to make some plugins that allow you to use external hardware to control e.g. brush parameters, so that would be cool
< a----> C------B I think its better to start from the outside gross functionalioty and then go to more deeper layers of Krita like an onion.

Usecases

What do people use scripting for in a program like Krita? To automate jobs!

What kind of jobs could be automated with ease?

  1. Exporting and Importing of files and to different filetypes(already possible with the command line)
  2. Layer handling -> Visible, lock, etc.
  3. Filters, or a set of filters.
  4. Transforms.
  5. Pseudo filters like 'split alpha' or 'split layer' or 'seperate image'.


Game Texturer

Has a file with three layers, called 'specular', 'diffuse', 'normal'.

What they want to do is to make 'specular' the alpha channel of 'diffuse', and have the diffuse and normal layers exported as filename-layername.tiff.

So the commands needed would be...

  • Find layer 'specular'
  • Convert layer to transparency mask.
  • Find layer 'diffuse'
  • Attach transparency mask 'specular' to 'diffuse'.
  • Export layer 'diffuse' as 'filename-diffuse.tiff'
  • Find layer 'normal'
  • Export layer 'normal' as 'filename-normal.tiff'


Comic artist

Has a file with several 'sketchlayers' a 'colour-layer' and 'lineart' layers.

They would want to resize their files, and maybe even grayscale them:

  • Find all layers with name 'sketch'
  • Turn all these layers invisible.
  • Find all layers named 'colour'.
  • Put a 'greyscale' filter on all these layers.
  • Flatten the image.
  • Resize the image to have 800px width.
  • save as 'filename-800pxwide.png'


Live export

Export the image as displayed on-screen (all layers merged) to a shared memory region for other applications to read. Interesting for game-developers et cetera who would like to have a preview of the texture they are editing right in their game.


Control brush parameters

Some artists like to use e.g. external hardware (e.g. with a scrollwheel or thumbstick, like an xbox-controller) to interact with their painting program. It would be cool if it was possible for a plugin to manipulate brush parameters (size, flow, ...) on the fly through input it receives from e.g. external control-hardware or other such sources.


Warmup-script

I like to use a script that deletes the entire canvas when I lift the stylus off my wacom tablet. Together with repeated or symmetry mode, as well as a speed sketch brush, it makes for a very nice way to generate shapes very quickly and warm up your "visual library". Currently I have this implemented in a very hacky way, if it was possible for plugins to listen for events such as "stroke end" or "pen lifted" and then issue a "clear canvas" command, this could be a simple 10-line script.

Easy on-line sharing/posting

When you're discussing with friends or you're keeping your friends up to date with WiP snapshots of something you're working on, you'll usually want to post these pictures online somewhere. There's many popular image sharing sites (I like using imgur; on #krita, pasteall.org seems popular) and of course there's social networks you could post to.

Big idea

A way to conveniently share scripts, similar to the GHNS mechanism that many other KDE components have, or the gimp/blender plugin registry? Users probably need to be told that plugins are not sandboxed!