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.
IndexProgramming Questions & HelpOther Libraries › controlP5 peculiarities
Page Index Toggle Pages: 1
controlP5 peculiarities (Read 2673 times)
controlP5 peculiarities
Aug 11th, 2008, 7:05pm
 
Hi, just started using controlP5's newest version (0.2.12) and had a few questions:

why do all the interface elements have an unsightly line through them when in OPENGL mode?  (something to do with how OPENGL renders shapes/faces, i believe, since i see same problem with seams between other shapes.)

the Knob element is drawn with lines that are affected by strokeWeight!  i believe it would be better form if they force weight to 1 pixel.  anything else distorts the control and can make it unusable.  (make a knob that changes strokeWeight to see what i mean.)

why do control labels force your text into all caps?  the text field element displays lowercase, so it's not a font limitation.

what's the proper way to round off control values, or only allow Ints?  i tried this, which actually worked fine, but gave me error "exception: java.lang.reflect.InvocationTargetExceptionERROR. an error occured while forwarding a Controller value to a method in your program. please check your code for any possible errors that might occur in this method."  obviously some recursive warning, what's the correct way to do it?

Code:

void Line_Weight(float _lw) {
 _lw = round(_lw);
 lineWeight = _lw;
 controlP5.controller("Line_Weight").setValue(_lw);     // by the way, why doesn't 'this' work here?
}


i know it seems redundant, but if you don't force the setValue inside the event method, the rounded off value gets immediately overwritten by a non-rounded value.  perhaps i should be defining a different or additional method?

i know some of these questions i can resolve by extending classes, but i thought there might be a better way...

thanks

eric

Re: controlP5 peculiarities
Reply #1 - Aug 12th, 2008, 1:31am
 
okay the control rendering problem seems to be this bug:
http://dev.processing.org/bugs/show_bug.cgi?id=200

which i found a workaround for (posted on that bug page) - use Code:
noSmooth(); 

in conjunction with Code:
hint(ENABLE_OPENGL_4X_SMOOTH); 




Re: controlP5 peculiarities
Reply #2 - Aug 12th, 2008, 1:54am
 
okay i answered my own question about rounding off or using ints, stupid of me, i thought from the examples that controller functions only took floats but you can just recast the parameter as an Int and voila.

here is a knob example showing what i mean with the strokeWeight problem.  

Code:

import controlP5.*;
ControlP5 controlP5;
float lineWeight;
Knob lwControl;

void setup() {
size(200,200);
smooth();
controlP5 = new ControlP5(this);
lwControl = controlP5.addKnob("stroke_Weight", 1,20, 1, 75,75, 25);
}

void draw() {
background(0);
stroke(255);
line(25,25,175,25);
}

void stroke_Weight(int _lw) {
g.strokeWeight(_lw);
}
Re: controlP5 peculiarities
Reply #3 - Aug 20th, 2008, 8:27am
 
thanks for pointing out the strokeWeight issue, now fixed.

Quote:
void Line_Weight(float _lw) {
 _lw = round(_lw);
 lineWeight = _lw;  
 controlP5.controller("Line_Weight").setValue(_lw);     // by the way, why doesn't 'this' work here?
}

this will not work because setValue(_lw) is calling function Line_Weight() which means Line_Weight will then call itself over and over again and end up in an infinite loop.

best,
andreas
Re: controlP5 peculiarities
Reply #4 - Jun 12th, 2010, 12:12pm
 
Hi,

I'm running across this strokeWeight issue with a textField, a slider changes line width for a drawing program, but also changes the linewidth of the textfield!

The workaround I used is to set the strokeWeight back to 1 and then call the textfield.draw() method.

Looking at the source for textfield and knob I see that knob has some extra lines for handling the strokeWeight issue.


Page Index Toggle Pages: 1