Hi,
I'm in trouble with text rendering in processingjs and firefox(but I didn't tried other browers), the text is cropped at the base, I can't figure out why, here is the image sample:
Can someone help me?
I've also tryed with the "/* @pjs font */ directive" but the problem is still there....
Here is menu.pde:
void setup() { size(1024, 650, OPENGL); textFont(createFont("Verdana", 20)); //textMode(SHAPE); // this won't work colorMode(HSB, 200);
function tryFindSketch () { sketch = Processing.getInstanceById(getProcessingSketchId()); if ( sketch == undefined ) return setTimeout(tryFindSketch, 200); }
Here is test.html
<!DOCTYPE html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>test</title> <!--[if lt IE 9]> <script type="text/javascript">alert("Your browser does not support the canvas tag.");</script> <![endif]--> <script src="processing.js" type="text/javascript"></script> <script type="text/javascript"> // convenience function to get the id attribute of generated sketch html element function getProcessingSketchId () { return 'menu'; }
</script> <script src="interface.js" type="text/javascript"></script> </head> <body> <canvas data-processing-sources="menu.pde" id="menu"> <p>Your browser does not support the canvas tag.</p> </canvas> <noscript> <p>JavaScript is required to view the contents of this page.</p> </noscript> </body> </html>
Hi, I'm new to the forum and quite new to Processing.
I'm doing this 3D colored points map, I'm implementing this for a school project, the code is'nt the goal for this project so, I'm not cheating.
I'd like to print on screen a text relative to the hovered point, I've looked to the picking example in Shape3D and implemented it in my sketch. Here is the problem, it is very approsimative, it almost doesn't work...
for (int i = 0; i < luoghi.length; i++) { // set up for the points luoghi[i] = new luogo(this, 20, 1); luoghi[i].setLuogo((int)random(resolution),(int)random(resolution),(int)random(resolution),"ciccia"+i); } }
void draw() {
background(0,0,0);
translate((int)width/2,(int)height/2);
// check if the mouse is over a point picked = Shape3D.pickShape(this, mouseX-width/2, mouseY-height/2); if (picked != null) { println("found : "+mouseX+" "+mouseY); pickedPos = picked.getPosVec(); }
// draw the points for (int i = 0; i < luoghi.length; i++) { luoghi[i].disegna(resolution,pickedPos); } }
void mouseClicked() { clicked = true; }
// this class extends the Helix class in Shape3D library class luogo extends Helix { // mi appoggio alla funzione Helix della libreria Shape3D int h,s,b,mX,mY; String nome; // connected text boolean drawTXT = false;
luogo (PApplet app, int a, int b) { super(app, a, b); this.setRadius(5,5,1); this.setHelix(1f, 0); this.drawMode(S3D.BOTH_CAP | S3D.WIRE); this.tag = "Box " + random(5); }
void setLuogo (int hh, int ss, int bb, String nom) { h=hh; s=ss; b=bb; nome=nom; }
void disegna(int res, PVector pick) { // color the point and positionate it as hsb rapresentation this.fill(color(h,s,b),S3D.S_CAP | S3D.E_CAP); this.stroke(color(0,0,100)); float x = sin((float)((TWO_PI/res)*h)+(float)frameCount/360)*s; float y = map(b,0,res,-res/2,res/2); float z = cos((float)((TWO_PI/res)*h)+(float)frameCount/360)*s;
// if the mouse is over this point print the text if (pickedPos.dist(this.getPosVec())==0f) { pushMatrix(); rotateX((float)30/360*TWO_PI); translate(-200,-85); text(nome, 0, 0, 0); popMatrix(); }