text in sphere please
in
Programming Questions
•
2 years ago
hi,
thanks to arthurG for helping me with the attached code- can someone tweak it so that some text (any word) is attached to the sphere and moves with it as you drag the mouse..i've tried but having no joy...
josh
- boolean over1 = false;
- boolean selected1 = false;
- int pos1X, pos1Y ;
- int offset1X, offset1Y ;
- float radius = 25.0f;
- void setup() { size(512, 512,P3D);
- textFont(createFont("SanSerif", 12));
- pos1X = width/2-50; pos1Y = height/2;
- smooth();
- noStroke();
- lights();
- } void draw()
- { background(0);
- ambientLight(20, 20, 20);
- directionalLight(255,155,40, -1, 0.5, -0.8);
- float valUpdown = map(pos1Y, 0, height, 6, -48);
- translate (pos1X,pos1Y,0); sphere (radius);
- fill (255,0,0);
- { over1 = true;
- } } void mousePressed() { if (over1) { selected1 = true;
- offset1X = pos1X-mouseX; offset1Y = pos1Y-mouseY; } } void mouseReleased() { selected1 = false;
- } void mouseDragged() { if (selected1) { pos1X = max(0,min(mouseX+offset1X,width));
- pos1Y = max(0,min(mouseY+offset1Y,height)); } }
1