Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HColorPool, HGridLayout examples #172

Open
wants to merge 3 commits into
base: lib_staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions HYPE/examples/HColorPool/HColorPool_001/HColorPool_001.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import hype.*;
import hype.extended.colorist.HColorPool;
import hype.extended.behavior.HRotate;


int numAssets = 100;

HRotate[] rot = new HRotate[numAssets];
HDrawable[] d = new HDrawable[numAssets];
HColorPool colors;
// **************************************************

void setup(){
size(640,640);
background(#242424);
H.init(this);

colors = new HColorPool(#FFFFFF, #F7F7F7, #ECECEC, #333333, #0095a8, #00616f, #FF3300, #FF6600);

for (int i = 0; i < numAssets; ++i) {
d[i]=(i%2==0) ? new HRect().rounding(10): new HEllipse();
d[i].noStroke();
d[i].fill( colors.getColor() );
d[i].loc( (int)random(width), (int)random(height) );
d[i].anchor( new PVector(25,25) );
d[i].size( 25+((int)random(3)*25) );

rot[i] = new HRotate().speed(random(-4,4));
}
}

void draw(){
background(#242424);
for (int i = 0; i < numAssets; ++i) {
rot[i].run();
d[i].rotation(rot[i].cur()).draw(this.g);
}
}

48 changes: 48 additions & 0 deletions HYPE/examples/HColorPool/HColorPool_002/HColorPool_002.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import hype.*;
import hype.extended.colorist.HColorPool;
import hype.extended.behavior.HRotate;


int numAssets = 100;

HRotate[] rot = new HRotate[numAssets];
HDrawable[] d = new HDrawable[numAssets];
HColorPool colors;
// **************************************************

void setup(){
size(640,640);
background(#242424);
H.init(this);

// add a higher probability of white & grey by inserting more entries into the pool
colors = new HColorPool()
.add(#FFFFFF, 9)
.add(#ECECEC, 9)
.add(#CCCCCC, 9)
.add(#333333, 3)
.add(#0095a8, 2)
.add(#00616f, 2)
.add(#FF3300)
.add(#FF6600)
;
for (int i = 0; i < numAssets; ++i) {
d[i]=(i%2==0) ? new HRect().rounding(10): new HEllipse();
d[i].noStroke();
d[i].fill( colors.getColor() );
d[i].loc( (int)random(width), (int)random(height) );
d[i].anchor( new PVector(25,25) );
d[i].size( 25+((int)random(3)*25) );

rot[i] = new HRotate().speed(random(-4,4));
}
}

void draw(){
background(#242424);
for (int i = 0; i < numAssets; ++i) {
rot[i].run();
d[i].rotation(rot[i].cur()).draw(this.g);
}
}

48 changes: 48 additions & 0 deletions HYPE/examples/HColorPool/HColorPool_003/HColorPool_003.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import hype.*;
import hype.extended.colorist.HColorPool;
import hype.extended.behavior.HRotate;


int numAssets = 100;

HRotate[] rot = new HRotate[numAssets];
HDrawable[] d = new HDrawable[numAssets];
HColorPool colors;
// **************************************************

void setup(){
size(640,640);
background(#242424);
H.init(this);

// add a higher probability of white & grey by inserting more entries into the pool
colors = new HColorPool()
.add(#FFFFFF, 9)
.add(#ECECEC, 9)
.add(#CCCCCC, 9)
.add(#333333, 3)
.add(#0095a8, 2)
.add(#00616f, 2)
.add(#FF3300)
.add(#FF6600)
;
for (int i = 0; i < numAssets; ++i) {
d[i]=(i%2==0) ? new HRect().rounding(10): new HEllipse();
d[i].stroke(colors.getColor(), 150);
d[i].fill( colors.getColor(), 50 );
d[i].loc( (int)random(width), (int)random(height) );
d[i].anchor( new PVector(25,25) );
d[i].size( 25+((int)random(3)*25) );

rot[i] = new HRotate().speed(random(-4,4));
}
}

void draw(){
background(#242424);
for (int i = 0; i < numAssets; ++i) {
rot[i].run();
d[i].rotation(rot[i].cur()).draw(this.g);
}
}

50 changes: 50 additions & 0 deletions HYPE/examples/HColorPool/HColorPool_004/HColorPool_004.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import hype.*;
import hype.extended.colorist.HColorPool;
import hype.extended.layout.HGridLayout;

int numAssets = 15876;

HDrawable[] d = new HDrawable[numAssets];
HColorPool colors;
HGridLayout layout;

// **************************************************

void setup(){
size(640,640);
background(#242424);
H.init(this);

colors = new HColorPool()
.add(#FFFFFF, 9)
.add(#ECECEC, 9)
.add(#CCCCCC, 9)
.add(#333333, 3)
.add(#0095a8, 2)
.add(#00616f, 2)
.add(#FF3300)
.add(#FF6600)
;

layout = new HGridLayout()
.startX(5)
.startY(5)
.spacing(5,5)
.cols(126)
;

for (int i = 0; i < numAssets; ++i) {
d[i]= new HRect(5);
d[i].noStroke();
d[i].fill( colors.getColor(i*3) );
d[i].loc( layout.getNextPoint() );
d[i].draw(this.g);
}

noLoop();
}

void draw(){

}

50 changes: 50 additions & 0 deletions HYPE/examples/HColorPool/HColorPool_005/HColorPool_005.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import hype.*;
import hype.extended.colorist.HColorPool;
import hype.extended.behavior.HRotate;


int numAssets = 200;


HRotate[] rot = new HRotate[numAssets];
HDrawable[] d = new HDrawable[numAssets];

HColorPool colors;
int colorIndex = 0;
// **************************************************

void setup(){
size(640,640);
background(#242424);
H.init(this);

colors = new HColorPool(#FFFFFF, #333333, #0095a8, #FF3300);

for (int i = 0; i < numAssets; ++i) {
d[i]=(i%2==0) ? new HRect().rounding(10): new HEllipse();
d[i].noStroke();
d[i].fill( colors.getColorAt(colorIndex) );
d[i].loc( (int)random(width), (int)random(height) );
d[i].anchor( new PVector(25,25) );
d[i].size( 25+((int)random(3)*25) );

rot[i] = new HRotate().speed(random(-4,4));
}
}

void draw(){
background(#242424);
for (int i = 0; i < numAssets; ++i) {
rot[i].run();
d[i].fill( colors.getColorAt(colorIndex) );
d[i].rotation(rot[i].cur()).draw(this.g);
}
}

void keyPressed() {
switch (key) {
case ' ':
colorIndex = ++colorIndex%colors.size(); // press the spacebar on your keyboard to cycle through the colors
break;
}
}
32 changes: 32 additions & 0 deletions HYPE/examples/HGridLayout/HGridLayout_001/HGridLayout_001.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import hype.*;
import hype.extended.layout.HGridLayout;

int numAssets = 576;

HGridLayout layout;
HRect[] d = new HRect[numAssets];

void setup(){
size(640,640);
background(#242424);
H.init(this);

layout = new HGridLayout()
.startX(21)
.startY(21)
.spacing(26,26)
.cols(24);

for (int i = 0; i < numAssets; ++i){
d[i] = new HRect(25).rounding(4);
d[i].noStroke().fill(#ECECEC).anchorAt(H.CENTER);
d[i].loc( layout.getNextPoint() );
}
}

void draw(){
background(#242424);
for (int i = 0; i < numAssets; ++i){
d[i].draw(this.g);
}
}
46 changes: 46 additions & 0 deletions HYPE/examples/HGridLayout/HGridLayout_002/HGridLayout_002.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import hype.*;
import hype.extended.colorist.HColorPool;
import hype.extended.layout.HGridLayout;

int numAssets = 576;

HGridLayout layout;
HColorPool colors;

HRect[] d = new HRect[numAssets];

void setup(){
size(640,640);
background(#242424);
H.init(this);

colors = new HColorPool()
.add(#FFFFFF, 9)
.add(#ECECEC, 9)
.add(#CCCCCC, 9)
.add(#333333, 3)
.add(#0095a8, 2)
.add(#00616f, 2)
.add(#FF3300)
.add(#FF6600)
;

layout = new HGridLayout()
.startX(21)
.startY(21)
.spacing(26,26)
.cols(24);

for (int i = 0; i < numAssets; ++i){
d[i] = new HRect(36).rounding(4);
d[i].noStroke().fill(colors.getColor()).anchorAt(H.CENTER).rotation(45);
d[i].loc( layout.getNextPoint() );
}
}

void draw(){
background(#242424);
for (int i = 0; i < numAssets; ++i){
d[i].draw(this.g);
}
}
57 changes: 57 additions & 0 deletions HYPE/examples/HGridLayout/HGridLayout_003/HGridLayout_003.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import hype.*;
import hype.extended.colorist.HColorPool;
import hype.extended.layout.HGridLayout;
import hype.extended.behavior.HRotate;


int numAssets = 576;

HGridLayout layout;

HRotate[] rot = new HRotate[numAssets];
HDrawable[] d = new HDrawable[numAssets];
HColorPool colors;
// **************************************************

void setup(){
size(640,640);
background(#242424);
H.init(this);

// add a higher probability of white & grey by inserting more entries into the pool
colors = new HColorPool()
.add(#FFFFFF, 9)
.add(#ECECEC, 9)
.add(#CCCCCC, 9)
.add(#333333, 3)
.add(#0095a8, 2)
.add(#00616f, 2)
.add(#FF3300)
.add(#FF6600)
;

layout = new HGridLayout()
.startX(32)
.startY(32)
.spacing(25,25)
.cols(24)
;


for (int i = 0; i < numAssets; ++i) {
d[i]=new HRect(50).rounding(4);
d[i].noStroke().fill( colors.getColor() ).alpha( (int)random(50,200) );
d[i].anchorAt( H.CENTER );
d[i].loc( layout.getNextPoint() );

rot[i] = new HRotate().speed(random(-2,2));
}
}

void draw(){
background(#242424);
for (int i = 0; i < numAssets; ++i) {
rot[i].run();
d[i].rotation(rot[i].cur()).draw(this.g);
}
}
Loading