Align for TextLabel in Processing

Hi,

Can you please tell me how to use the .align(int, int , int, int) for textlabel in processing?

Regards,
Padma

Hi Padma –

textlabel is not a part of Processing – it is a part of the Processing library ControlP5.

http://sojamo.de/libraries/controlP5/reference/controlP5/Textlabel.html

The example sketch is:

PDE > File > Examples > Contributed Libraries > ControlP5 > controllers > ControlP5textlabel

.align() is an inherited property of any Controller – it has an xy for the Caption and another for the Value:

http://sojamo.de/libraries/controlP5/reference/controlP5/Controller.html#align-int-int-int-int-

I’m not sure this will do anything with a TextLabel.

What are you trying to do?

I understand that now. I was just making textlabels and trying to aligning them in boxes.

Thank you,

Padma

I remember seeing this question long before – I don’t think align works on TextLabel in this way: Text Alignment in ControlP5 button - Processing 2.x and 3.x Forum

See also the idea of a callback workaround here: https://www.reddit.com/r/processing/comments/9wbfb0/is_there_no_alignment_function_for_controlp5/

For the label could you display it with a simple text(), so that you can use textAlign()?

Another discussion of using align on matrix vs scrollablelist:

Hi,

Do you know how tracers work? Any documentation available?

Regards,

Padma

By tracers, do you mean like this ?

Yes!

Regards,

Padma

Hi,

Can we add a texture to a ellipse in the drawtracer method. This is from the tracer example "custom_path_demo_1 of tracer library. i am using a ellipse instead of a point.

void drawTracer(Tracer t) {

img = loadImage(“image1.jpg”);

texture(img);

ellipse(t.x, t.y, 10, 40);

}

Sincerely,

Padma

Texture does not apply to primitive render methods like ellipse() or rect().

https://processing.org/reference/texture_.html

It works on PShape, and you can use it inline with beginShape / endShape if you don’t want to declare a PShape object, or use createShape.

createShape has an ELLIPSE parameter.

https://processing.org/reference/createShape_.html

However, that shape mode does not support texture, for complex reasons. There are complex manual workarounds listed at the bottom of the issue:

However, if you can use something other than an ellipse – like a polygon – then it is very easy to texture, as per the texture reference page linked above.

1 Like

Hi,

I used PShape and .enableStyle() method by giving the .svg format in loadShape. But currently styling is not enabled in processing, otherwise would have worked.

Thanks for the help,

Padma

Hi,

The **rotateY() **is not working in the below case. Do you understand why? I am just trying to show a sphere with text on it as a label and make a small sphere revolve around it using rotateY…

nya.beginTransform(0);
fill(#E74C3C);
noStroke();
lights();
sphere(20);
fill(#000000);
translate(0, 0, 20.3); 
noStroke();
fill(255, 50);
circle(20, -15, 20); 
translate(0, 0, 0.3); 
fill(0);
textSize(8);
text("Text", 40, 40, -15);
fill(#E74C3C);
noStroke();
lights();
translate(0,0,21);
rotateY((PI * frameCount )/ 300);
sphere(6);
nya.endTransform();

Regards,

Padma

Please ignore the previous email, I am planning to use processing.js

Thanks,

Padma

Do you want to use Processing.js, or are you going to use p5.js? Processing.js is an old cross-compiler that you can program in Java and output JavaScript – p5.js is a native JavaScript.

I an using it for augmented reality, so I think I can’t use p5.js.

12 posts were split to a new topic: Using nyar4psg library for augmented reality