Bitmap drawing tool test
Moderators: Víctor Paredes, Belgarath, slowtiger
-
- Posts: 370
- Joined: Thu Aug 05, 2004 2:23 am
- Location: Los Angeles
- Contact:
Bitmap drawing tool test
On Animators Forum I recently gained access to the VIP Scripting forum (around 50 posts needed) and in one of the threads Synthsin and Rudiger were talking about how you can use external .dll files to extend the scripting capabilities of Anime Studio.
This sounded very interesting and I've been playing around with two external bindings, Lua GD for creating and manipulating images, and Lua FileSystem for extending the file manipulation.
With these two Lua bindings I've written a tool for making bitmap drawings directly in AS.
Here's an image drawn in Anime Studio:
Now this is just a test and not a finished tool so it's pretty limited.
What it can do:
- Create png image layers of custom size.
A folder named 'images' will be created in the same folder as your .anme file. The PNG will be transparent and named "image" + the number of files in the directory.
- Draw on any image layer containing a png image.
Pencil size is set in Anime Studios style window under stroke width.
Pen pressure is supported when using a tablet.
- Erase by holding SHIFT. Eraser size is the same as pen width.
- Fill color by holding ALT
What it can't do (among other things):
- Antialiasing. This is posible with the GD library though, but filling antialiased shapes might look bad.
- Speedy drawing on high resolution images. Every time you draw something the PNG file will be saved and loaded back into Anime Studio so the bigger the file the more lag there will be after drawing something.
- Undo. The image is saved right away but one idea I had is creating a copy of the image before any changes. That would give you at least one level of undo but it might introduce more lag.
As previously stated, this is basically just a test but if you want to play around with it or look at the code, here it is:
http://animestudioscripts.com/temp/raster/ds_raster.zip
Unzip it in your Anime Studio folder and things should work.
To uninstall all the files installed, double click "uninstall_ds_raster.bat". It will even remove itself after removing the files so you will have no trace of the tool or the .dll files.
EDIT: This will only work on Windows using Anime Studio Pro 8.
EDIT AGAIN: Tried it on Anime Studio 7 and it works there too. Didn't think it would update the image layer but it did.
This sounded very interesting and I've been playing around with two external bindings, Lua GD for creating and manipulating images, and Lua FileSystem for extending the file manipulation.
With these two Lua bindings I've written a tool for making bitmap drawings directly in AS.
Here's an image drawn in Anime Studio:
Now this is just a test and not a finished tool so it's pretty limited.
What it can do:
- Create png image layers of custom size.
A folder named 'images' will be created in the same folder as your .anme file. The PNG will be transparent and named "image" + the number of files in the directory.
- Draw on any image layer containing a png image.
Pencil size is set in Anime Studios style window under stroke width.
Pen pressure is supported when using a tablet.
- Erase by holding SHIFT. Eraser size is the same as pen width.
- Fill color by holding ALT
What it can't do (among other things):
- Antialiasing. This is posible with the GD library though, but filling antialiased shapes might look bad.
- Speedy drawing on high resolution images. Every time you draw something the PNG file will be saved and loaded back into Anime Studio so the bigger the file the more lag there will be after drawing something.
- Undo. The image is saved right away but one idea I had is creating a copy of the image before any changes. That would give you at least one level of undo but it might introduce more lag.
As previously stated, this is basically just a test but if you want to play around with it or look at the code, here it is:
http://animestudioscripts.com/temp/raster/ds_raster.zip
Unzip it in your Anime Studio folder and things should work.
To uninstall all the files installed, double click "uninstall_ds_raster.bat". It will even remove itself after removing the files so you will have no trace of the tool or the .dll files.
EDIT: This will only work on Windows using Anime Studio Pro 8.
EDIT AGAIN: Tried it on Anime Studio 7 and it works there too. Didn't think it would update the image layer but it did.
- funksmaname
- Posts: 3174
- Joined: Tue May 29, 2007 11:31 am
- Location: New Zealand
- Víctor Paredes
- Site Admin
- Posts: 5664
- Joined: Wed Jan 26, 2005 12:18 am
- Location: Barcelona/Chile
- Contact:
It's an awesome advance! thank you very much, Ponysmasher. Great, really great.
I have a problem when creating new images. It creates at the project resolution (960x540), but it is not centered and have a black space on the right and down sides.
I have three questions:
- This dll thing have been around since what version?
- Can you give us an idea about what could be done now with that?
- Is there any chance yo have this tool working as a frame by frame tool? (maybe it could create automatically a switch and new keys for new images and you could edit each image over the switch layer on its respective keyframe, that would be fantastic)
I have a problem when creating new images. It creates at the project resolution (960x540), but it is not centered and have a black space on the right and down sides.
I have three questions:
- This dll thing have been around since what version?
- Can you give us an idea about what could be done now with that?
- Is there any chance yo have this tool working as a frame by frame tool? (maybe it could create automatically a switch and new keys for new images and you could edit each image over the switch layer on its respective keyframe, that would be fantastic)
Moho Product Manager
www.mohoanimation.com
Rigged animation supervisor in My father's dragon - Lead Moho artist in Wolfwalkers - Cartoon Saloon - My personal Youtube Channel
Wow, great job Ponysmasher! Using the GD library to add bitmap drawing to AS has been on my todo list for a while now, so I'm grateful to be able to cross it off without having to write a single line of code!
I hope you can add anti-aliasing as an option. It would be great when you just want to paint and have no need for the fill tool.
I also like Selgin's idea of making it work with switch layers. Could make it awesome for storyboarding.
To answer Selgin's question, it has been possible to import dlls with AS, since at least AS6, and quite possibly in AS5 or even Moho. I suspect it became possible when Mike first made all Lua functions available to the scripting interface. However, I don't think it is supported for Macs under any version. Not sure if this is a limitation with the OS or what, but I've submitted a request to Smith Micro to add support for this feature to the Mac version.
Actually, Ponysmasher, you might want to mention that this tool will only work under Windows, to save people the trouble with trying to get it to work on a Mac.
I hope you can add anti-aliasing as an option. It would be great when you just want to paint and have no need for the fill tool.
I also like Selgin's idea of making it work with switch layers. Could make it awesome for storyboarding.
To answer Selgin's question, it has been possible to import dlls with AS, since at least AS6, and quite possibly in AS5 or even Moho. I suspect it became possible when Mike first made all Lua functions available to the scripting interface. However, I don't think it is supported for Macs under any version. Not sure if this is a limitation with the OS or what, but I've submitted a request to Smith Micro to add support for this feature to the Mac version.
Actually, Ponysmasher, you might want to mention that this tool will only work under Windows, to save people the trouble with trying to get it to work on a Mac.
-
- Posts: 370
- Joined: Thu Aug 05, 2004 2:23 am
- Location: Los Angeles
- Contact:
Oops. Fixed it and uploaded to the same link.selgin wrote:I have a problem when creating new images. It creates at the project resolution (960x540), but it is not centered and have a black space on the right and down sides.
I'm not really sure, I've just started playing around with this. But it seems exciting.selgin wrote:- Can you give us an idea about what could be done now with that?
This is something I would like to do. I'll experiment some more.selgin wrote:- Is there any chance yo have this tool working as a frame by frame tool? (maybe it could create automatically a switch and new keys for new images and you could edit each image over the switch layer on its respective keyframe, that would be fantastic)
Thanks! You're the inspiration.Rudiger wrote:Wow, great job Ponysmasher!
I hardly know how it works on a PC and I don't have a mac so I'm afraid it's beyond my abilities.ulrik wrote:Fantastic work Ponysmasher!
I know this will not work on mac, do you have any plans for making it work on mac?
Hehe, actually I think a more fitting question would be what can't be done! Synthsin has used this technique to create a rather nifty native color picker that can get the color from anywhere on the screen. It's only available in the VIP scripting area of the Animators Forum though.ponysmasher wrote:I'm not really sure, I've just started playing around with this. But it seems exciting.selgin wrote:- Can you give us an idea about what could be done now with that?
Basically, it means that any c-library with Lua bindings can be accessed from inside AS. For example, if you could find a boolean operations library, you could integrate that into AS and have it support boolean operations on its shapes.
You could even use it the other way and use it to treat AS as a plugin for another application.
You can also write your own dlls in c. This is useful for accessing OS-level stuff that the AS scripting interface doesn't give you direct access to, which is what Synthsin did with his native color picker tool.
I think the only way you could currently make it work on a Mac is if you wrote a command-line program that uses the GD library and then execute it from AS using the os.execute() function. Not sure how much more laggy this approach would make it though.ponysmasher wrote:I hardly know how it works on a PC and I don't have a mac so I'm afraid it's beyond my abilities.ulrik wrote:Fantastic work Ponysmasher!
I know this will not work on mac, do you have any plans for making it work on mac?
Last edited by Rudiger on Fri Aug 12, 2011 5:26 pm, edited 1 time in total.
- neeters_guy
- Posts: 1619
- Joined: Mon Sep 14, 2009 7:33 pm
- Contact:
There's a pretty comprehensive list of add-ons for Lua here:JaMike wrote:This extra LUA stuff sounds great - what other LUA plugins are there that could be used? Has anyone got a list of them? I did a search but didn't really understand what I was looking at.
http://lua-users.org/wiki/LibrariesAndBindings
One idea that comes to mind is you could possibly combine one of the image manipulation libraries with one of the GUI libraries to create a full node-based compositor for AS.
I'm sure there's some interesting things that could be done with the 3D libraries as well.
I had a proper play with it, and it works really great. The default settings for the size of a new image seem to be fixed though. I would have thought you would want it to default to the project size and you then have the option to fiddle with it if you want to.
I also noticed an issue with the origin being redrawn with the same brush size that was used to draw the last line. It might be an idea to set the pen width back to 0 on MouseUp.
Another thing is the width of the bitmap stroke seems quite a bit smaller than the preview stroke, especially for large widths.
Also, I had an idea for how you could support onion skinning inside a switch layer. When onion-skinning is enabled you could still write the stroke to the current image but automatically blend the previous image with the current image when you do the update. It might add a bit to the lag, but you could always keep turning onion skinning on and off with a shortcut key to see how your current image looks compared to the previous one.
I also noticed that you are using a specific color to represent transparency in the image. I think the GD library supports using a separate alpha channel if you use the imagesaveslpha function. That way, you could just use the fill and line colors in the style window and support painting with variable transparency.
EDIT: I think I solved the brush size problem. Instead of calculating the width to put in the table as:
I think it should be:
I also noticed an issue with the origin being redrawn with the same brush size that was used to draw the last line. It might be an idea to set the pen width back to 0 on MouseUp.
Another thing is the width of the bitmap stroke seems quite a bit smaller than the preview stroke, especially for large widths.
Also, I had an idea for how you could support onion skinning inside a switch layer. When onion-skinning is enabled you could still write the stroke to the current image but automatically blend the previous image with the current image when you do the update. It might add a bit to the lag, but you could always keep turning onion skinning on and off with a shortcut key to see how your current image looks compared to the previous one.
I also noticed that you are using a specific color to represent transparency in the image. I think the GD library supports using a separate alpha channel if you use the imagesaveslpha function. That way, you could just use the fill and line colors in the style window and support painting with variable transparency.
EDIT: I think I solved the brush size problem. Instead of calculating the width to put in the table as:
Code: Select all
moho:NewShapeLineWidth()*self.newY
Code: Select all
moho:DocToPixel(moho:NewShapeLineWidth())
-
- Posts: 370
- Joined: Thu Aug 05, 2004 2:23 am
- Location: Los Angeles
- Contact:
Thanks for looking through the code Rudiger!
There is a lot to be done for sure. I was having a bit of trouble with the transparency and the way I do it now, with a color as transparent, is especially not good when you turn on antialiasing since that color will shine through the antialiased pixels.
But I will read up on it more, just have to catch up with work first.
There is a lot to be done for sure. I was having a bit of trouble with the transparency and the way I do it now, with a color as transparent, is especially not good when you turn on antialiasing since that color will shine through the antialiased pixels.
But I will read up on it more, just have to catch up with work first.