|
| 1 | +int ArectX = 42; |
| 2 | +int BrectX = 30; //2 - vel oszthato kell legyen!!! |
| 3 | +int ABrectY = 42; //3 - mal oszthato kell legyen!!! |
| 4 | +int Aspace = 10; |
| 5 | +int Bspace = 10; |
| 6 | +int ABshape = 7; |
| 7 | + |
| 8 | +int BYspace = 4; |
| 9 | + |
| 10 | +int AXCoords[][] = {{0,0},{0,0},{0,0},{0,0},{0,0}}; |
| 11 | +int ABYCoords[] = {0,0}; |
| 12 | +int BXCoords[] = {0,0}; |
| 13 | + |
| 14 | +int trashX = 35; |
| 15 | +int trashY = 35; |
| 16 | + |
| 17 | + |
| 18 | +int selectedItem = 0; |
| 19 | +int red = 255; |
| 20 | +int green = 255; |
| 21 | +int blue = 255; |
| 22 | +int S = 0; |
| 23 | +int G = 0; |
| 24 | + |
| 25 | + |
| 26 | +void setup() |
| 27 | +{ |
| 28 | + size(700,500); |
| 29 | + background(255); |
| 30 | + |
| 31 | + //calculating rects Coords |
| 32 | + |
| 33 | + //Y |
| 34 | + ABYCoords[0] = trashY; |
| 35 | + ABYCoords[1] = trashY + ABrectY; |
| 36 | + |
| 37 | + int first = 0; |
| 38 | + int second = 0; |
| 39 | + |
| 40 | + //AX |
| 41 | + for(int j = 0; j < 10; j++){ |
| 42 | + AXCoords[first][second] = trashX; |
| 43 | + if(j%2 == 0){ |
| 44 | + trashX = trashX + ArectX; |
| 45 | + }else{ |
| 46 | + trashX = trashX + Aspace; |
| 47 | + } |
| 48 | + |
| 49 | + if(j%2 == 1){ |
| 50 | + second = 0; |
| 51 | + first++; |
| 52 | + } else{ |
| 53 | + second = 1; |
| 54 | + } |
| 55 | + } |
| 56 | + |
| 57 | + //BX |
| 58 | + trashX = trashX + Bspace; |
| 59 | + for(int j = 0; j < 2; j++){BXCoords[j] = trashX; trashX = trashX + 4*Bspace + 3*BrectX;} |
| 60 | + |
| 61 | +} |
| 62 | + |
| 63 | + |
| 64 | +boolean mouseMenu(int minX, int maxX, int minY, int maxY) |
| 65 | +{ |
| 66 | + boolean Mc = mousePressed == true; |
| 67 | + boolean MouseMenuResult = mouseX > minX && mouseX < maxX && mouseY > minY && mouseY < maxY && Mc; |
| 68 | + return MouseMenuResult; |
| 69 | +} |
| 70 | + |
| 71 | + |
| 72 | +void backgroundMenuRGB(int xCoord,int yCoord){ |
| 73 | + strokeWeight(1); |
| 74 | + int W = 0; |
| 75 | + int Vertical = ABrectY/3; |
| 76 | + int SmallBXCoords[][][] = {{{0,0},{0,0},{0,0}},{{0,0},{0,0},{0,0}},{{0,0},{0,0},{0,0}}}; |
| 77 | + int SmallBYCoords[][][] = {{{0,0},{0,0},{0,0}},{{0,0},{0,0},{0,0}},{{0,0},{0,0},{0,0}}}; |
| 78 | + for(int j = 0; j < 3; j++){ |
| 79 | + W = W + Bspace; |
| 80 | + |
| 81 | + SmallBXCoords[j][0][0] = W + xCoord + 1; |
| 82 | + SmallBXCoords[j][0][1] = W + BrectX + xCoord - 1; |
| 83 | + SmallBXCoords[j][1][0] = W + xCoord; |
| 84 | + SmallBXCoords[j][1][1] = W + xCoord + BrectX; |
| 85 | + SmallBXCoords[j][2][0] = W + xCoord + 1; |
| 86 | + SmallBXCoords[j][2][1] = W + (BrectX/2) + xCoord; |
| 87 | + |
| 88 | + SmallBYCoords[j][0][0] = ABYCoords[0] + Vertical - BYspace; |
| 89 | + SmallBYCoords[j][0][1] = ABYCoords[0] + BYspace; |
| 90 | + SmallBYCoords[j][1][0] = ABYCoords[0] + Vertical; |
| 91 | + SmallBYCoords[j][1][1] = ABYCoords[0] + 2*Vertical; |
| 92 | + SmallBYCoords[j][2][0] = ABYCoords[0] + 2*Vertical + BYspace; |
| 93 | + SmallBYCoords[j][2][1] = ABYCoords[0] + 3*Vertical - BYspace; |
| 94 | + |
| 95 | + triangle(SmallBXCoords[j][0][0], SmallBYCoords[j][0][0], SmallBXCoords[j][0][1], SmallBYCoords[j][0][0], SmallBXCoords[j][2][1], SmallBYCoords[j][0][1]); |
| 96 | + rect(SmallBXCoords[j][1][0],SmallBYCoords[j][1][0],BrectX,Vertical); |
| 97 | + triangle(SmallBXCoords[j][2][0], SmallBYCoords[j][2][0], SmallBXCoords[j][0][1], SmallBYCoords[j][2][0], SmallBXCoords[j][2][1], SmallBYCoords[j][2][1]); |
| 98 | + W = W + BrectX; |
| 99 | + } |
| 100 | + //ellenorzes |
| 101 | + |
| 102 | +} |
| 103 | + |
| 104 | +void backgroundMenu() |
| 105 | +{ |
| 106 | + //clear(); |
| 107 | + color[] colors = {#00ffdc,#009984,#00d4b7,#32ff8a,#94ffff}; |
| 108 | + |
| 109 | + if(selectedItem == 5){ |
| 110 | + background(red,green,blue); |
| 111 | + } else{ |
| 112 | + background(colors[selectedItem]); |
| 113 | + } |
| 114 | + |
| 115 | + for(int i = 0; i < 6; i++){ |
| 116 | + strokeWeight(1); |
| 117 | + if(i == selectedItem){ |
| 118 | + strokeWeight(2); |
| 119 | + stroke(#000000); |
| 120 | + } |
| 121 | + |
| 122 | + switch(i){ |
| 123 | + case 0:fill(colors[0]);break; |
| 124 | + case 1:fill(colors[1]);break; |
| 125 | + case 2:fill(colors[2]);break; |
| 126 | + case 3:fill(colors[3]);break; |
| 127 | + case 4:fill(colors[4]);break; |
| 128 | + case 5:noFill(); |
| 129 | + } |
| 130 | + |
| 131 | + if(i == 5){ |
| 132 | + rect(BXCoords[0],ABYCoords[0],4*Bspace + 3*BrectX,ABrectY,ABshape); |
| 133 | + backgroundMenuRGB(BXCoords[0],ABYCoords[0]); |
| 134 | + } else{ |
| 135 | + rect(AXCoords[i][0],ABYCoords[0],ArectX,ABrectY,ABshape); |
| 136 | + } |
| 137 | + } |
| 138 | + if(mouseMenu(AXCoords[0][0],AXCoords[0][1],ABYCoords[0],ABYCoords[1])){ |
| 139 | + selectedItem = 0; |
| 140 | + } else if(mouseMenu(AXCoords[1][0],AXCoords[1][1],ABYCoords[0],ABYCoords[1])){ |
| 141 | + selectedItem = 1; |
| 142 | + } else if(mouseMenu(AXCoords[2][0],AXCoords[2][1],ABYCoords[0],ABYCoords[1])){ |
| 143 | + selectedItem = 2; |
| 144 | + } else if(mouseMenu(AXCoords[3][0],AXCoords[3][1],ABYCoords[0],ABYCoords[1])){ |
| 145 | + selectedItem = 3; |
| 146 | + } else if(mouseMenu(AXCoords[4][0],AXCoords[4][1],ABYCoords[0],ABYCoords[1])){ |
| 147 | + selectedItem = 4; |
| 148 | + } else if(mouseMenu(BXCoords[0],BXCoords[1],ABYCoords[0],ABYCoords[1])){ |
| 149 | + selectedItem = 5; |
| 150 | + } |
| 151 | +} |
| 152 | + |
| 153 | +void clock(int X, int Y,int radius){ |
| 154 | + stroke(255); |
| 155 | + strokeWeight(3); |
| 156 | + ellipse(X,Y,radius,radius); |
| 157 | + |
| 158 | + translate(X,Y); |
| 159 | + rotate(second()*6/57.3); |
| 160 | + line(0,0,0,0-(radius/2-5)); |
| 161 | + rotate(second()*6/57.3*(-1)); |
| 162 | + rotate(minute()*6/57.3); |
| 163 | + line(0,0,0,0-(radius/2-20)); |
| 164 | + rotate(minute()*6/57.3*(-1)); |
| 165 | + rotate(hour()*30/57.3); |
| 166 | + line(0,0,0,0-(radius/2-50)); |
| 167 | +} |
| 168 | + |
| 169 | +void draw(){ |
| 170 | + backgroundMenu(); |
| 171 | + clock(200,270,200); |
| 172 | +} |
0 commit comments