|
Author |
Topic: need help to load image into code! (Read 440 times) |
|
lexy
|
need help to load image into code!
« on: Dec 14th, 2004, 9:26pm » |
|
i adapted this code, and i am having problems running the image. can anyone see how to get my gif running? thanks // BABEL 1 // by arielm - JUNE 4, 2003 // http://www.chronotext.org // text in hebrew from the Bible, Genesis 11:1 float fovy, aspect; float elevation, azimuth, distance; float va, aa; //float drawTower; //BImage b; BImage img; float x, y, z, turns, r1, r2, h, hh, dd; boolean collapse, exploded; float v, a; void setup () { size(300, 400); BImage b; b = loadImage ("untitled-1.gif"); image (b, 0, 0); background(255); fovy = 60.0; aspect = (float) width / (float) height; distance = 260.0; elevation = radians(270.0); azimuth = radians(235.0); va = radians(2.0); aa = 0.0; // --- x = 0.0; y = 0.0; z = -92; r1 = 100.0; r2 = 50.0; h = 200.0; hh = 14.0; dd = 12.0; v = 0.0; a = -0.05; } void loop() { beginCamera(); perspective(fovy, aspect, 1.0, 1000.0); translate(0.0, 0.0, -distance); rotateX(-elevation); rotateZ(-azimuth); endCamera(); } void confuse(BImage bi) // a.k.a makeTransparent() { bi.format = ALPHA; for (int i = 0; i < bi.width * bi.height; i++) { bi.pixels[i] = bi.pixels[i] & 0xff; } } if (mousePressed) { collapse = true; } if (collapse) { v += a; h = max(15.0, h + v); if (h <= 15.0) { if (!exploded) { confuse(img); r2 = (r1 + r2) / 2.0; va = 0.0; exploded = true; } v = -v / 1.667; } aa = exploded ? 0.0 : radians(-0.0167); } void drawTower(BImage bi, float x, float y, float z, float turns, float r1, float r2, float h, float hh, float dd) { float d; float r = 0.0; float dr = 0.0; float l = TWO_PI * turns; float L = PI * turns * (r1 + r2); float dz = h / l; boolean conical = (abs(r1 - r2) > 0.5f); // avoids infinity and divisions by zero with cylindrical helices (r1 = r2) if (conical) { dr = (r2 - r1) / l; } else { r = r1; } drawTower(img, x, y, z, turns, r1, r2, h, hh, dd); turns = (img.width * hh / img.height) / (PI * (r1 + r2)); fill(255); va = max(0.0, va + aa); azimuth += va; boolean b = false; float xx, yy, zz, uu; float du = bi.height / hh; noStroke(); beginShape(QUAD_STRIP); texture(bi); for (float D = 0.0; D < L + dd; D += dd) { if (conical) { r = sqrt(r1 * r1 + 2.0 * dr * D); d = (r - r1) / dr; } else { d = D / r; } b = !b; xx = x + cos(d) * r; yy = y - sin(d) * r; zz = z + d * dz; uu = D * du; vertex(uu, b ? (float) bi.height : 0.0); vertex(xx, yy, b ? zz : zz + hh); vertex(uu, b ? 0.0 : (float) bi.height); vertex(xx, yy, b ? zz + hh : zz); } endShape(); }
|
|
|
|
mad
|
Re: need help to load image into code!
« Reply #1 on: Jan 18th, 2005, 6:36am » |
|
The background statement should be before the image statement.
|
|
|
|
|