Grids and Sine wave drawing tools

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Fahim, Distinct Sun, Víctor Paredes, erey, Belgarath, slowtiger

hayasidist
Posts: 2208
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Grids and Sine wave drawing tools

Post by hayasidist » Tue Aug 02, 2011 5:13 pm

Ok people ... be gentle with me - this is my first serious attempt at scripting for AS. For sure there are many other ways to do what this toolset does, so if no-one wants it --- well, as Thumper would say "if you can't say something nice don't say nothing at all..."

The file is at http://www.mediafire.com/?x5wsnah3wg3tc5e. It's a zip with a Readme, the LUA and the icons. It has been tested only on ASP7.

This set of tools is based on the SHAPE tools that come with Anime Studio.
The three key things are: Multipoint straight line; Grid; Sine wave (the other three were more of a practice run than anything else).

constructive criticism / ideas for improvement and enhancement etc always welcome.
ponysmasher
Posts: 370
Joined: Thu Aug 05, 2004 2:23 am
Location: Los Angeles
Contact:

Post by ponysmasher » Tue Aug 02, 2011 6:11 pm

I haven't tested your script yet (browsing on my phone during vacation), but I think it's great that you've started writing scripts. The more people writing scripts, the better.

And it's a great feeling when you need Anime Studio to do something and you can write a script that does it.
User avatar
Víctor Paredes
Posts: 4978
Joined: Wed Jan 26, 2005 12:18 am
Location: Ireland/Chile
Contact:

Post by Víctor Paredes » Tue Aug 02, 2011 7:14 pm

It's always fantastic to have a new scripter in the club :)
Thanks for sharing your first one, Hayasidist. I tested it on version 8 and works perfectly.
Víctor Paredes
Former Moho Product Manager
Rigged animation supervisor in 'My father's dragon' - Lead Moho artist in 'Wolfwalkers'
Cartoon Saloon
My Youtube Channel - My webinars
User avatar
funksmaname
Posts: 3113
Joined: Tue May 29, 2007 11:31 am
Location: Nelson, New Zealand

Post by funksmaname » Tue Aug 02, 2011 8:48 pm

cool man, will give it a try - i was just trying to make a grid the other day to test something and it presented itself as a missing option :) Also, making sine waves might be useful one day!
jonbo
Posts: 896
Joined: Thu Apr 08, 2010 2:53 am

Post by jonbo » Tue Aug 02, 2011 9:03 pm

Excellent. This could be very useful to me. Thanks :)
User avatar
uddhava
Posts: 314
Joined: Tue Nov 04, 2008 7:24 pm
Location: American back in Hungary

Post by uddhava » Fri Aug 05, 2011 11:27 am

Thanks, hayasidist,

Interesting....nice shapes. They could be useful. They remind me of some
Adobe Illustrator plugins I've seen.

I wish I had some skill at scripting. I feel it would be a little too much for me to start. I joked with my step son that he should learn to write scripts for ASP, but when he said he could try, I felt I might be exploiting him.

....Any way keep up the good work.

udd
hayasidist
Posts: 2208
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Post by hayasidist » Fri Aug 05, 2011 12:13 pm

Hi All,

thanks for your encouraging and positive replies.


WIP on this set is going in this direction:

number of points is configurable (menu bar entry option)

- "round edged" square is being ditched and replaced by circle segment (quadrant / semi circ or anything less than a full 360 circle) (if you want a round edged square then use the drawing tool then curvature .. :wink: )

- 4-point oval is being replaced by multipoint ellipse

- grid -- number of rows / columns configurable
- line -- number of points config
- star -- number of "spikes" config
- sine -- number of points in the curve config

My main current (soon to be resolved?!? :? ) problem is with point curvature on the ellipse (odd things happen where x or y dimension gets very small wrt the other) - so if you're not straining at the leash for the update, please hang on for a few days when I hope to get the issues fixed and the files into a release pack.

==
looking to the subsequent updates:

A question for the scripters ...

there's the set of functions mouseEvent. alt/shift/ctrl Key. is there a similar function to capture such as Arrow-up / arrow down key strokes at the same time as mouse is dragging. And/or mouse right click / thumbwheel??? I've been browsing the documentation that I've found in this part of the forum, but no luck finding anything useful so far...
User avatar
uddhava
Posts: 314
Joined: Tue Nov 04, 2008 7:24 pm
Location: American back in Hungary

Post by uddhava » Fri Aug 05, 2011 5:01 pm

Sounds great! Good luck.
ponysmasher
Posts: 370
Joined: Thu Aug 05, 2004 2:23 am
Location: Los Angeles
Contact:

Post by ponysmasher » Fri Aug 05, 2011 8:22 pm

hayasidist wrote: A question for the scripters ...

there's the set of functions mouseEvent. alt/shift/ctrl Key. is there a similar function to capture such as Arrow-up / arrow down key strokes at the same time as mouse is dragging. And/or mouse right click / thumbwheel??? I've been browsing the documentation that I've found in this part of the forum, but no luck finding anything useful so far...
Right mouse and scroll wheel, no. They're always used by AS. But keys you can. The K key would be used like this:

Code: Select all

if (keyEvent.key == 'k') then
Some keys you have to use the built in keycode constants for, like the up key:

Code: Select all

if (keyEvent.keyCode == LM.GUI.KEY_UP) then
The other constants are:

KEY_RETURN - The Return or Enter key
KEY_ESCAPE - The Escape key
KEY_TAB - The Tab key
KEY_BACKSPACE - The Backspace key
KEY_DELETE - The Delete key
KEY_HOME - The Home key
KEY_END - The End key
KEY_PAGEUP - The Page Up key
KEY_PAGEDOWN - The Page Down key
KEY_LEFT - The left arrow key
KEY_UP - The up arrow key
KEY_RIGHT - The right arrow key
KEY_DOWN - The down arrow key
KEY_F1 - The F1 key
KEY_F2 - The F2 key
KEY_F3 - The F3 key
KEY_F4 - The F4 key
KEY_F5 - The F5 key
KEY_F6 - The F6 key
KEY_F7 - The F7 key
KEY_F8 - The F8 key
KEY_F9 - The F9 key
KEY_F10 - The F10 key
KEY_F11 - The F11 key
KEY_F12 - The F12 key

There's more info in the scripting reference under Moho, KeyEvent
hayasidist
Posts: 2208
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Post by hayasidist » Fri Aug 05, 2011 11:11 pm

Thanks a lot - I hadn't found that ref... so much info - a blessing and a problem at the same time. I'll give it a go.

But in the meantime, another question comes to mind - If I'm trapping these keystrokes, does this mean that if (say) I trap an "S" key that this will override the S as Scale Points ... for just as long as I have the "trap" active?
hayasidist
Posts: 2208
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Post by hayasidist » Mon Aug 08, 2011 9:06 pm

Tools updated.
=========

the new version is at http://www.mediafire.com/?v9hqb20h3vobumd

The zip file has Readme, the LUA and the icons. It has been tested only on ASP7.

Main changes: number of points is selectable; circle segment replaces rectangle; generic ellipse replaces predefined oval (but you can still make the "eye" shape by creating a four-point shape); grid size selectable; grid fill now supported; UI flaws fixed in oval and sine.

as ever, comments / suggestions welcome.
jonbo
Posts: 896
Joined: Thu Apr 08, 2010 2:53 am

Post by jonbo » Mon Aug 08, 2011 9:45 pm

Tested in AS8, so far, so good. Thanks man 8)
User avatar
uddhava
Posts: 314
Joined: Tue Nov 04, 2008 7:24 pm
Location: American back in Hungary

Post by uddhava » Tue Aug 09, 2011 3:31 pm

Works fine for me.
Thanks, nice improvements.
hayasidist
Posts: 2208
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Post by hayasidist » Sun Aug 28, 2011 6:00 pm

Hi Again,

tweaked this around a bit more. the new version is at the old URL http://www.mediafire.com/?v9hqb20h3vobumd.

Key new things are better and more options; draw polygon added, "glitches" in sine and grid fixed.

The zip file has Readme, the LUA and the icons. It has been tested only on ASP7.

as ever, helpful comments and suggestions welcome.
ulrik
Posts: 1075
Joined: Thu Aug 11, 2005 10:32 pm
Location: Stockholm Sweden
Contact:

Post by ulrik » Sun Aug 28, 2011 6:34 pm

Thanks a lot for sharing these great scripts! :D
Post Reply