Web extrusion project loads VERY SLOWLY
in
Processing with Other Languages
•
2 years ago
I'm working on a fairly simple project using the extrusion code, and using Processing.js to put it on the web.
Here's the address (though I wouldn't recommend going to it, because it makes my browser freeze up):
asciifriends.com/playinwdan2.html
No idea why this would be moving so slowly and eating up so much processing power (or whatever).
Any ideas, my wonderful nerds?
Here is my code:
Here's the address (though I wouldn't recommend going to it, because it makes my browser freeze up):
asciifriends.com/playinwdan2.html
No idea why this would be moving so slowly and eating up so much processing power (or whatever).
Any ideas, my wonderful nerds?
Here is my code:
- /* @pjs preload="4wD4N.jpg"; */
- PImage extrude;
- int[][] values;
- float angle = 0;
- void setup()
- {
- size(640, 500, P3D);
- // Load the image into a new array
- extrude = loadImage("4wD4N.jpg");
- extrude.loadPixels();
- values = new int[extrude.width+25][extrude.height+25];
- for (int y = 0; y < extrude.height; y++) {
- for (int x = 0; x < extrude.width; x++) {
- color pixel = extrude.get(x, y);
- values[x][y] = int(brightness(pixel));
- }
- }
- }
- void draw() {
- background(221,252,84);
- // Update the angle
- if (mousePressed) {
- angle -= 0.1;}
- else {
- angle += 0.005;}
- // Rotate around the center axis
- translate(width/2, 0, -128);
- rotateY(angle);
- translate(-extrude.width/2, 100, -128);
- // Display the image mass
- for (int y = 0; y < extrude.height+25; y++) {
- for (int x = 0; x < extrude.width; x++) {
- stroke(values[x][y]);
- point(x, y, -values[x][y]);
- }
- }
- }
1