New Post - Creating SimpleDraw.as from PaintCanvas.as
Posted: 07 April 2009 09:26 PM   [ Ignore ]
Avatar
RankRankRank
Joined  2008-10-28
Total Posts:  274
Sr. Member

I tried out a little converting and simplifying tonight.
Looking at PaintCanvas.as from Touchlib, I stepped through a simple line drawing app using nearly the same code, just without needing to use the blobs array.

Step 1: drawing only white lines using the TUIO info and not a blobs array
Step 2; Adding Random Colors
Step 3: Adding Random Colors to Touch Down Events
Step 4: Associating a specific random color for each Touch Point

Take a read, enjoy.
Test it out.

I’ve also added in a concern about how I use an array within the code and am looking for some feedback.
Thanks everyone.

http://www.cyancdesign.com/2009/04/paintcanvas-to-simpledraw/

and also in the wiki

http://wiki.nuigroup.com/Simple_Draw_from_PaintCanvas.as

 Signature 

Flash files and tutorial[s] available at:

cyancdesign Tutorial Blog Posts
and
http://wiki.nuigroup.com/Documents_and_tutorials

Profile
 
 
Posted: 07 April 2009 10:18 PM   [ Ignore ]   [ # 1 ]
Avatar
RankRankRankRank
Joined  2008-02-12
Total Posts:  1102
Member

nice work cyancdesign… looks good

 Signature 

Company Website - Knode Research and Development
My Youtube

Profile
 
 
Posted: 07 April 2009 11:02 PM   [ Ignore ]   [ # 2 ]
Avatar
RankRankRankRankRankRank
Joined  2007-04-08
Total Posts:  2539
Dedicated

Very nice tutorial and I think it’s a great template for future tutorials.

I do see what you’re talking about the color/blob array. I think making an absolute array probably isn’t the best, like you hinted especially since im not sure if flash garbage collects when it still has a object reference in an array (that’s not being used).

You might want to look into the Dictionary object in AS3 which can be very useful (although i’ve only tried it once). The Dictionary object, which lives in the flash.utils package is a new object type that allows you to associate a value with an object key. This is similar to how array associates values with numeric indexes, and how you can use a generic object to associate a value with a string key.

Here’s a great article about them: http://www.gskinner.com/blog/archives/2006/07/as3_dictionary.html and it’s cool to note that you can delete items from the dictionary (so up event you can remove from the dictionary without destroying the order/quality of it).

 Signature 

MTmini, MTbiggie, & Audiotouch creator & Community Core Vision Co-founder

Follow on:
My Blog | Facebook | Twitter | Youtube

Profile
 
 
Posted: 08 April 2009 09:55 PM   [ Ignore ]   [ # 3 ]
Avatar
RankRankRank
Joined  2008-10-28
Total Posts:  274
Sr. Member

Thanks for the link to GSkinner’s post. I’ve learned quite a bit off that site personally.
So I made one more iteration in my blog post / google code page / and wiki post.

This last one now uses the new Dictionary(true) Object, suggested in the gskinner’s post.
Touch down add’s the new color transformation to the Dictionary using the blob’s ID as the key, then on touch up, removes that same color transformation from the Dictionary. And initially defining the Dictionary with that ‘true’ value makes empty keys elligible for garbage collecting, at least according to everything I’ve read.

It sounds legit to me. I’m just not sure how to go about testing if it works or not.

 Signature 

Flash files and tutorial[s] available at:

cyancdesign Tutorial Blog Posts
and
http://wiki.nuigroup.com/Documents_and_tutorials

Profile