iomikron

iomikron_Patterns_pattern-04

May 9th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. // PATTERNS - pattern-04
  2. //********************************************************************************************
  3. // iomikron.tumblr.com - You can use and modify this software for free. Sharing your code with
  4. // others is highly recommended. Please credit me, keeping these lines of comments.
  5. //********************************************************************************************
  6.  
  7. int numOfRows = 17;
  8. int numOfColumns = 42;
  9. int numOfItems = numOfColumns*numOfRows;
  10. int counter = 0;
  11. int imageCounter = 0;
  12.  
  13. Triangle trg;
  14. float[] omega01 = new float[numOfItems];
  15. float[] amp01 = new float[numOfItems];
  16. float[] phase01 = new float[numOfItems];
  17. float[] opacity01 = new float[numOfItems];
  18.  
  19. float[] omega02 = new float[numOfItems];
  20. float[] amp02 = new float[numOfItems];
  21. float[] phase02 = new float[numOfItems];
  22. float[] opacity02 = new float[numOfItems];
  23.  
  24. float d1, d2, initX, initY, t;
  25.  
  26. void setup()
  27. {
  28. size(600, 500);
  29.  
  30. d1 = 3.;
  31. d2 = 3.;
  32.  
  33. initX = 25.;
  34. initY = 25.;
  35.  
  36. trg = new Triangle();
  37.  
  38. for(int i = 0; i < numOfRows; i++)
  39. {
  40. for(int j = 0; j < numOfColumns; j++)
  41. {
  42. omega01[counter] = random(25, 35);
  43. amp01[counter] = random(150, 180);
  44. phase01[counter] = random(1, 2*PI);
  45. opacity01[counter] = random(10, 255);
  46.  
  47. omega02[counter] = random(25, 35);
  48. amp02[counter] = random(150, 180);
  49. phase02[counter] = random(1, 2*PI);
  50. opacity02[counter] = random(10, 255);
  51.  
  52. counter ++;
  53. }
  54. }
  55. }
  56.  
  57. void draw()
  58. {
  59. background(200);
  60. counter = 0;
  61.  
  62. for(int i = 0; i < numOfColumns; i ++)
  63. {
  64. for(int j = 0; j < numOfRows; j++)
  65. {
  66. noStroke();//stroke(color(255, 0, 0), opacity01[counter]);
  67. fill(amp01[counter]*cos(omega01[counter]*t + phase01[counter])+ 100,
  68. opacity01[counter]);
  69. trg.Display01(initX + i*(trg.W + d1),
  70. initY + j*(trg.H + 2*d2));
  71.  
  72. noStroke();//stroke(color(255, 0, 0), opacity[i]);
  73. fill(amp02[counter]*cos(omega02[counter]*t + phase02[counter])+ 100,
  74. opacity02[counter]);
  75. trg.Display02(initX + i*(trg.W + d1),
  76. initY + j*(trg.H + 2*d2) + d2);
  77.  
  78. counter ++;
  79. }
  80. }
  81. t += 0.003;
  82.  
  83. // noLoop();
  84. }
  85.  
  86. class Triangle
  87. {
  88. float W = 10.;
  89. float H = 20.;
  90.  
  91. void Display01(float x1, float y1)
  92. {
  93. quad(x1, y1,
  94. x1 + W, y1 + H/2,
  95. x1, y1 + H,
  96. x1, y1 + H
  97. );
  98. }
  99.  
  100. void Display02(float x1, float y1)
  101. {
  102. quad(x1, y1 + H,
  103. x1 + W, y1 + H/2,
  104. x1 + W, y1 + H + H/2,
  105. x1 + W, y1 + H + H/2
  106. );
  107. }
  108. }
  109. void mouseReleased()
  110. {
  111. imageCounter ++;
  112.  
  113. save("image" + str(imageCounter) + ".png");
  114. }
Advertisement
Add Comment
Please, Sign In to add comment