Align for TextLabel in Processing


#1

Hi,

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

Regards,
Padma


#2

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?


#3

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

Thank you,

Padma


#4

I remember seeing this question long before – I don’t think align works on TextLabel in this way: https://forum.processing.org/two/discussion/10129/text-alignment-in-controlp5-button

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:


#5

Hi,

Do you know how tracers work? Any documentation available?

Regards,

Padma


#6

By tracers, do you mean like this ?


#7

Yes!

Regards,

Padma


#8

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


#9

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.


#10

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


#11

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


#12

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

Thanks,

Padma


#13

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.


#14

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


#15

Hi,

I am using the nyar4psg library for augmented reality. I am able to see the 3d cube in the below picture in my tablet when its camera is pointing to a marker image, but how is it coming out on the paper. I mean how is it projected in the real world? Its not coming out as in the below picture for me, its showing only in the phone/tablet. Could you please help. Is it some sort of digitized or image tracking paper?

image.png

Regards,

Padma


#16

No, it is normal paper. The content appears only on the screen of the phone / tablet. Like this:

Augmented reality is not projected in the real world. It is displayed on a phone / tablet / headset / glasses.


#17

image.png

In the above video, he has executed the processing code and the cube has come out of the system. Do we need any extra hardware for that?

Regards,

Padma


#18

maybe its some sort of surface projector.

Regards,

Padma


#19

No, he hasn’t.

He is in front of his laptop, recording it with a camera or web cam. The video stream gets the cube added to it by processing, using video processing. He cannot see the cube in the air in front of him – it isn’t there. He can only see the cube through his laptop screen – it is never projected into the real world.

Watch this part closely. He can’t see the cube in his hand, because it isn’t projected – he can only see it on his screen. That is why he is watching his laptop so carefully.

There are ways to project onto fiducials from a fixed perspective, but they are usually not close-up 3D – they are either top-down onto tables or floors like reactable, or else they are onto the side of a building like projection mapping. You can have projectors map 2D videos (not cubes!) onto moving 2D surfaces with fiducials – like a sign on a stick – but it is hard to get right, and it works much better with 2D than with 3D due to needing to force a perspective.

The setup in this particular video doesn’t use a projector at all.


#20

Yeah you are right. Maybe we could use a desktop projector to see our screen on the surface to see a 3d view of the cube as it appears in 3d in the screen.

Thanks,

Padma