Advertisement
Guest User

Untitled

a guest
Dec 1st, 2015
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. PImage img;
  2. void setup() {
  3. size(500, 500);
  4. colorMode(HSB, 360, 100, 100);
  5. img = loadImage("lena_color.jpg");
  6. }
  7.  
  8. void draw() {
  9. int grid = 10;
  10. background(0, 0, 100);
  11. for (int j = 0; j < height; j+= grid) {
  12. for (int i = 0; i < width; i+= grid) {
  13. color c = img.get(i, j);
  14. int gradation = int(brightness(c)/10) + 1;
  15. stroke(c);
  16. rectPointGradation(i, j, grid, gradation);
  17. }
  18. }
  19. noLoop();
  20. }
  21.  
  22. void rectPointGradation(int x, int y, int grid, int gradation) {
  23. pushMatrix();
  24. translate(x, y);
  25. for (int j = 0; j < grid; j++) {
  26. for (int i = 0; i < grid; i++) {
  27. if ((j*grid + i)%gradation == 0) {
  28. point(i, j);
  29. }
  30. }
  31. }
  32. popMatrix();
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement