6. Januar 2013
Hier mein Code für die Struktur des Moduls Grafic Design Basics. Es handelt sich dabei um die Struktur für Fett, gesättigte Fettsäuren, Zucker und Salz. Beim Parameter Bio wird der Hintergrund grün. Beim Parameter Gentech fängt die Struktur an in einem Doppelpuls zu pulsieren. Beim Parameter Allergie fängt die Struktur an zu drehen. Hier speziell mit verschiedenen Tempi auf dem Radius von innen nach aussen. es entsteht so eine Sogwirkung. Es sind die Produkte, Nutella, Red Bull, Sardellen, Kinder Schokolade, Muesli und Bio Orangensaft mit den Tasten 1-6 wählbar Codestatic final int FAT = 1; static final int GESFAT = 2; static final int SUGAR = 3; static final int SALT = 4; static final int NUTELLA = 1; static final int REDBULL = 2; static final int SARDELLEN = 3; static final int KINDERSCHOKOLADE = 4; static final int MUESLI = 5; static final int ORANGENSAFT = 6; ArrayList fettItemList = new ArrayList(); ArrayList gesFettitemList = new ArrayList(); ArrayList zuckerItemList = new ArrayList(); ArrayList salzItemList = new ArrayList(); int borderDist = 5; int gridX = 20; int gridY = 20; boolean bio = false; boolean gen = false; boolean allerg = false; void setup() { size(1200,300); setupStructure(FAT,100); setupStructure(GESFAT,100); setupStructure(SUGAR,100); setupStructure(SALT,100); } void setupStructure(int structureType, int ammount) { // setup the grid float stepX = (float)(width/4 - borderDist * 2) / (gridX - 1); float stepY = (float)(height - borderDist * 2) / (gridY - 1); for(int x=0;x < gridX;x++) { for(int y=0;y 150) radius=150; float itemSize = map(radius, 0, 150, 16, 3); float ammountPosition = map(radius,0,150,100,0); if(ammountPosition > ammount) { itemSize = 2; } switch(structureType) { case FAT: fettItemList.add(new FettItem((int)posX, (int)posY, (int)itemSize, gen, allerg)); break; case GESFAT: gesFettitemList.add(new gesFettItem((int)posX, (int)posY, (int)itemSize, gen, allerg)); break; case SUGAR: zuckerItemList.add(new ZuckerItem((int)posX, (int)posY, (int)itemSize,gen, allerg)); break; case SALT: salzItemList.add(new SalzItem((int)posX, (int)posY, (int)itemSize, gen, allerg)); break; } } } } void draw() { background(236,236,236); if(bio) { background(145,173,28); } for(int i=0;i < fettItemList.size();i++) { fettItemList.get(i).draw(); } translate(300,0); for(int i=0;i < gesFettitemList.size();i++) { gesFettitemList.get(i).draw(); } translate(300,0); for(int i=0;i < zuckerItemList.size();i++) { zuckerItemList.get(i).draw(); } translate(300,0); for(int i=0;i 250) radius = 250; rot += map(radius,0,250, 0.05, 0.001); } void draw() { PVector pos = new PVector(posX, posY); PVector center = new PVector(150,height/2); float radius = PVector.sub(pos,center).mag(); calculateRotation(radius); pushMatrix(); if(allerg && radius 250) radius = 250; rot += map(radius,0,250, 0.05, 0.001); } void draw() { PVector pos = new PVector(posX, posY); PVector center = new PVector(150,height/2); float radius = PVector.sub(pos,center).mag(); calculateRotation(radius); pushMatrix(); if(allerg && radius 250) radius = 250; rot += map(radius,0,250, 0.05, 0.001); } void draw() { noStroke(); PVector pos = new PVector(posX, posY); PVector center = new PVector(150,height/2); float radius = PVector.sub(pos,center).mag(); calculateRotation(radius); pushMatrix(); if(allerg && radius 250) radius = 250; rot += map(radius,0,250, 0.05, 0.001); } void draw() { float a = itemSize * 1 * getMovementFactor(); float hdown = sqrt(sq(itemSize*3/8 * getMovementFactor())); float hup = sqrt(sq(itemSize*5/8 * getMovementFactor())); PVector pos = new PVector(posX, posY); PVector center = new PVector(150,height/2); float radius = PVector.sub(pos,center).mag(); calculateRotation(radius); pushMatrix(); if(allerg && radius < 250) { translate(150,height/2); rotate(rot); translate(-150,-height/2); } triangle(posX, posY-hup, posX+a/2 ,posY + hdown, posX- a/2, posY + hdown); popMatrix(); } }