User Tools

Site Tools


cs276:mirrorhorz

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
cs276:mirrorhorz [2007/10/01 15:50]
scarl
cs276:mirrorhorz [2016/09/27 14:14] (current)
scarl
Line 1: Line 1:
 +<code java>
   // Note: this code example only shows the function needed to perform the operation.   // Note: this code example only shows the function needed to perform the operation.
   // You need to provide your own setup() and draw() or other functions to test it.   // You need to provide your own setup() and draw() or other functions to test it.
Line 10: Line 11:
     pi.loadPixels();​     pi.loadPixels();​
     // loop through all columns     // loop through all columns
-    for (int = 0; < pi.width; ​x++) { +    for (int col = 0; col < pi.width; ​col++) { 
-       ​// loop from 0 to just before the mirrorPoint +      // loop from 0 to just before the mirrorPoint 
-       ​for (int = 0; < mirrorPoint; ​y++) { +      for (int row = 0; row < mirrorPoint; ​row++) { 
-          topPixel = pi.get(xy); +        topPixel = pi.get(colrow); 
-          // put the color into the pixel at (height-1) - y +        // put the color into the pixel at (height-1) - y 
-          pi.set(pi.height - 1 - y, y, topPixel);​ +        pi.set(col, pi.height - 1 - row, topPixel);​ 
-       ​}+        }
     }     }
     pi.updatePixels();​     pi.updatePixels();​
   }   }
 +</​code>​
cs276/mirrorhorz.1191271825.txt.gz · Last modified: 2007/10/01 15:50 by scarl