asquare
YaBB Newbies
Offline
Posts: 36
Re: make an image curve / bend?
Reply #5 - Aug 2nd , 2006, 4:12pm
Hi You've lost me on this now. Pretty sure I interpreted what you wrote correctly down as far as the first two lines in the while loop but not sure how the angle is calculated. What are the u and v variables, are these for a vertex() command? a+ gar int v_width, v_height, v_xoffset, v_yoffset; float v_x, v_y, v_radius, v_circumference, v_angle, v_i; color v_white; //width and height stored as a variable v_width = 768; v_height = 576; //set stage size //size(v_width, v_height); size(v_width, v_height, P3D); //set background colour background(0); //calculate the x and y offset v_xoffset = v_width / 2; v_yoffset = v_height / 2; //radius, circumference, alpha?, colour v_radius = 100; v_angle = 0.0; v_white = color(255); v_i = 0.0; noStroke(); PImage a = loadImage("dog.jpg"); beginShape(TRIANGLE_FAN); texture(a); //loop (how many times?) while(v_i <= TWO_PI) { //calculate x and y position v_y = v_xoffset + cos(v_angle) * v_radius; v_x = v_yoffset + sin(v_angle) * v_radius; //set pixel starting from stage centre set(int(v_x), int(v_y), v_white); //v_angle = 0 to HALF_PI..u = (v_angle/HALF_PI); v = 0; //v_angle = HALF_PI to PI.. u = 1, v = (v_angle-HALF_PI)/HALF_PI; //v_angle = PI -to 3*PI/2.. u = (v_angle-PI)/HALF_PI, v = 1; //v_angle = 3*PI/2 to TWO_PI.. u = 0, v = (v_angle-3*PI/2)/HALF_PI; //to test //println("x = " + x + ", y = " + y); //unsure as to how these work? v_i += PI/v_radius; } endShape();