We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexDiscussionExhibition › Tweak your processing code in realtime
Page Index Toggle Pages: 1
Tweak your processing code in realtime (Read 2655 times)
Tweak your processing code in realtime
Mar 26th, 2010, 10:42am
 
I've been working with http://dslabs.teague.com on a library for Processing that allows you to modify variables on-the-fly via a simple user interface.  

I do a lot of prototyping and quick mock-ups in Processing and have found that tweaking variables can often be tedious and time consuming.  Tweak is a first-pass at making variable modification simple and simultaneous to what you see while your sketch is running.

More info about Tweak and examples sketches are available here: http://dslabs.teague.com/?p=22.

Cheers,
Adam

...
Re: Tweak your processing code in realtime
Reply #1 - Mar 26th, 2010, 11:16am
 
Whoa thats a great idea. Great work!
Ill check it out.
Re: Tweak your processing code in realtime
Reply #2 - Mar 26th, 2010, 12:35pm
 
You should make this into a library! and also add these imports to your example

import java.awt.*;
import java.awt.event.*;

beside that its great! i like how you can do variable grouping and also scroll up and down in the complex example and also how you use simple click and drag as opposed to sliders to change values!
Re: Tweak your processing code in realtime
Reply #3 - Mar 26th, 2010, 12:46pm
 
Also you could use java's reflection api to auto create your Tweak object somehow so you can either use your TweakType object  or float/int/boolean variables. But then youd have to think of how else to set min/max. I had some of the same problems when adding parameter based tweens to my animation library. but anyhow its good as is! but maybe that could be something else to think about adding somehow...
Re: Tweak your processing code in realtime
Reply #4 - Mar 26th, 2010, 1:28pm
 
Thanks for the great suggestions.  I'm playing with it now! :)
Re: Tweak your processing code in realtime
Reply #5 - Mar 26th, 2010, 2:08pm
 
Keep up the great work! i was always hoping for a librarie like that since i saw "field" for the first time...

I still love to see a built in tool for the processing IDE. that let you change the variables withing the IDE. like field does... but this is a great start! looking forward to see more of it.
Re: Tweak your processing code in realtime
Reply #6 - Mar 26th, 2010, 2:12pm
 
oh and i always thought it would be great if there would exist a button like "update variables" that take the changes you did with the sliders and change them in your code... But yeah like i said, its more like a tool that needs to be implemented into the ide than a library
Re: Tweak your processing code in realtime
Reply #7 - Mar 26th, 2010, 2:12pm
 
I've updated Tweak to now include two "import" lines mentioned, as well as a new Tweak type, TweakString. :)

You can tell which version of Tweak you are using by looking in the console when your sketch starts up (it corresponds with the release date).

To use TweakString, just instantiate it with a description and a value:

Code:

TweakString tString = new TweakString("Title", "This title can be changed.");


Let me know of other suggestions and I'll do what I can!

Adam
Re: Tweak your processing code in realtime
Reply #8 - Mar 26th, 2010, 4:03pm
 
btw i am getting some render problems. at first your tweak window is black, just black and when i click on it, it gets white. and the text gray...
Re: Tweak your processing code in realtime
Reply #9 - Mar 26th, 2010, 4:14pm
 
What system are you using (OS and version)?  

This could be a race condition, since it renders once on startup and then tries to free up the processor by not rendering unless something is changed.  I'll try to reproduce the issue and make a fix if I can find it.

Adam
Re: Tweak your processing code in realtime
Reply #10 - Mar 26th, 2010, 4:17pm
 
i tested it on windows vista so far.
Re: Tweak your processing code in realtime
Reply #11 - Mar 26th, 2010, 5:09pm
 
Thanks for the info.  

I just loaded it up on Vista, rand into the same problem, and made a fix.  The latest version of Tweak should now paint the Tweak window correctly.

Let me know if you find other issues. :)

Cheers,
Adam
Re: Tweak your processing code in realtime
Reply #12 - Mar 26th, 2010, 5:25pm
 
just curious, what was the reason ?
Re: Tweak your processing code in realtime
Reply #13 - Mar 27th, 2010, 8:49am
 
Cedric, I think it was two things.  

The background color of one of the components wasn't being explicitly set (I guess it was inheriting the black color from its parent or being transparent on Mac, but not behaving the same way in Vista), so I added a line to set the component's background to black.

There was also an issue of drawing the content too soon after loading, and since it doesn't continually redraw, there was a race condition.  I added an "invokeLater" call to asynchronously force a repaint shortly after loading and that seemed to clear it up (at least for me).

Hope that helps,
Adam

Re: Tweak your processing code in realtime
Reply #14 - Mar 27th, 2010, 5:38pm
 
I have to say that you are right on target with this one, I have found the same scenario exactly. You are absolutely correct.
Page Index Toggle Pages: 1