alteredgenome / grafx2

Automatically exported from code.google.com/p/grafx2
0 stars 0 forks source link

Lua support #228

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Pulkomandy started implementing Lua scripting in Grafx2.
This allows the program to read a user script and execute it.
At the moment, a new window opens when you right-click the Brush FX icon,
and when you click 'Run', it loads and executes the script 'test.lua'.
The sample script fills the brush with a diagonal gradient. (you need to
have a user-grabbed brush already in order to see the effect)

Possible uses:
- generating a brush by some algorithm 
- graphic filters on the brush. For example the built-in 'Outline' and
'Nibble' could have been done in a Lua script.

For Windows, I compiled the lua library myself, because the official
binaries require Windows 2000/XP. To Roberto: Normally this should work on
DOS with HX extender, no new DLL is needed.

Feel free to share your impressions and ideas.

Original issue reported on code.google.com by yrizoud on 30 Oct 2009 at 9:33

GoogleCodeExporter commented 9 years ago
Note it is also possible to generate an image, not only a picture.
And it is possible to generate a brush even if the user did not capture one 
before, 
but you have to set the size by yourself from the lua script. The sample script 
will 
take the size of the current brush so yo uend up with a gradient on an 1x1 
brush 
which isn't so interesting. BTW, check the BrushFactory page on the wiki for 
some 
documentation :)

Original comment by pulkoma...@gmail.com on 30 Oct 2009 at 9:41

GoogleCodeExporter commented 9 years ago
Scripts that alter the color brush should call a function that switches to color
brush mode.

Original comment by yrizoud on 30 Oct 2009 at 9:52

GoogleCodeExporter commented 9 years ago
Yes. I'd have liked to do that automatically but can't find a solution for 
that. So 
the script will have to do it by itself.
Will add it in a moment.

Original comment by pulkoma...@gmail.com on 30 Oct 2009 at 10:05

GoogleCodeExporter commented 9 years ago
Binding added :)

Original comment by pulkoma...@gmail.com on 30 Oct 2009 at 10:48

GoogleCodeExporter commented 9 years ago

Original comment by pulkoma...@gmail.com on 30 Oct 2009 at 11:38

GoogleCodeExporter commented 9 years ago
I have a little doubt with the factory window.
Do you think we should keep it, or just make lua scripts loadable from the 
load/save 
window ?

Eventually i'd like to allow users to assign shortcuts (or even buttons) to 
their 
favourite lua scripts. The factory window could then be used for that.

About it's button : i've put it on the brush FX button as it was meant to 
generate 
or alter brush, but I ended up allowing the scripts to also change the picture, 
so, 
should I move this window to another button ?

Original comment by pulkoma...@gmail.com on 31 Oct 2009 at 12:47

GoogleCodeExporter commented 9 years ago
Listing scripts from a specific directory (with specific file extension, even) 
seems
best. Can even read the first comment line(s) and display as script description.

About shortcuts: Free association would cause a big change in config format. A
smaller change would be having internally shortcuts for "script 1", "script 2" 
etc,
and a separate configuration that lets the user put a script in a slot (stored 
for
example as .ini variables : script1=test.lua). This sets a limit to the number 
of
shortcuts, however.
I don't know how far you want to go with this... At the extreme,you can make 
macros
which are simple sequences of actions, with a recorder, and record the 
parameters to
these actions as well... But then every single editing action needs to be 
available
in Lua, including some which require a lots of parameters (I'm thinking of all 
we can
do in palette or shade screen, for example)

Button: I don't know if it needs a direct button on status bar... there's not 
even
room for layers and animation menus.

Original comment by yrizoud on 2 Nov 2009 at 2:48

GoogleCodeExporter commented 9 years ago
File list : I'm now listing files from the $(data_dir)/scripts directory. No 
extension filtering as there are .lua (normal script) and .lub (precompiled lua 
bytecode).

Anyway, I don't have any particular plans for this, I added it on user request 
to 
generate pictures with a simple putpixel() function. The only really 
interesting 
extension I can see is towards scripted animation, but we don't even have 
animations 
yet :)

Original comment by pulkoma...@gmail.com on 2 Nov 2009 at 5:43

GoogleCodeExporter commented 9 years ago
Ok, this seems stable enough, so closing the issue.

Original comment by pulkoma...@gmail.com on 17 Jan 2010 at 8:57