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

HFontPool + examples #154

Open
wants to merge 2 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
52 changes: 52 additions & 0 deletions examples/HFontPool/HFontPool_001/HFontPool_001.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import hype.*;
import hype.extended.colorist.*;
import hype.extended.layout.HGridLayout;

HColorPool colors;
HDrawablePool pool;
HFontPool fonts;

void setup() {
size(900, 900, P2D);
H.init(this).background(#202020).use3D(false);
colors = new HColorPool(#FFFFFF, #F7F7F7, #ECECEC, #333333, #0095a8, #00616f, #FF3300, #FF6600);
noLoop();

PFont font1, font2, font3, font4;
font1 = createFont("DroidSerifRegular.ttf", 18);
font2 = createFont("DroidSerifItalic.ttf", 48);
font3 = createFont("DroidSerifBold.ttf", 48);
font4 = createFont("DroidSerifBoldItalic.ttf", 48);

fonts = new HFontPool(font1, font2, font3, font4);

pool = new HDrawablePool(4);
pool.autoAddToStage()
.add(new HText("", 24, null))
.layout(
new HGridLayout()
.startX(40)
.startY(40)
.spacing(36, 36)
.cols(1)
)
.onCreate(
new HCallback() {
public void run(Object obj) {
int i = pool.currentIndex();
HText t = (HText) obj;
t.fill( colors.getColor() );
t.font(fonts.getFontAt(i));
t.text(i+1 + ". " + fonts.currentName());
t.anchorAt(H.LEFT);
}
}
)
.requestAll()
;

H.drawStage();
}

void draw() {
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
53 changes: 53 additions & 0 deletions examples/HFontPool/HFontPool_002/HFontPool_002.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import hype.*;
import hype.extended.colorist.*;
import hype.extended.layout.HGridLayout;

HColorPool colors;
HDrawablePool pool;
HFontPool fonts;

void setup() {
size(900, 900, P2D);
H.init(this).background(#202020).use3D(false);
colors = new HColorPool(#FFFFFF, #F7F7F7, #ECECEC, #333333, #0095a8, #00616f, #FF3300, #FF6600);
noLoop();

PFont font1, font2, font3, font4;
font1 = createFont("DroidSerifRegular.ttf", 18);
font2 = createFont("DroidSerifItalic.ttf", 48);
font3 = createFont("DroidSerifBold.ttf", 48);
font4 = createFont("DroidSerifBoldItalic.ttf", 48);

fonts = new HFontPool().add(font1).add(font2).add(font3).add(font4,8);
//weighted so that font 4 (DroidSerifBoldItalic) will be added 8 times

pool = new HDrawablePool(20);
pool.autoAddToStage()
.add(new HText("", 24, null))
.layout(
new HGridLayout()
.startX(40)
.startY(40)
.spacing(36, 36)
.cols(1)
)
.onCreate(
new HCallback() {
public void run(Object obj) {
int i = pool.currentIndex()+1;
HText t = (HText) obj;
t.fill( colors.getColor() );
t.font(fonts.getRandomFont()); //pick random font
t.text(i + ". " + fonts.currentName());
t.anchorAt(H.LEFT);
}
}
)
.requestAll()
;

H.drawStage();
}

void draw() {
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
46 changes: 46 additions & 0 deletions examples/HFontPool/HFontPool_003/HFontPool_003.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import hype.*;
import hype.extended.colorist.*;
import hype.extended.layout.HGridLayout;

HColorPool colors;
HDrawablePool pool;
HFontPool fonts;

void setup() {
size(900, 900, P2D);
H.init(this).background(#202020).use3D(false);
colors = new HColorPool(#FFFFFF, #F7F7F7, #ECECEC, #333333, #0095a8, #00616f, #FF3300, #FF6600);
noLoop();

fonts = new HFontPool().addSystemFonts(); //load all available system fonts...

pool = new HDrawablePool(20);
pool.autoAddToStage()
.add(new HText("", 24, null))
.layout(
new HGridLayout()
.startX(40)
.startY(40)
.spacing(36, 36)
.cols(1)
)
.onCreate(
new HCallback() {
public void run(Object obj) {
int i = pool.currentIndex()+1;
HText t = (HText) obj;
t.fill( colors.getColor() );
t.font(fonts.getRandomFont()); //pick random font
t.text(i + ". " + fonts.currentName());
t.anchorAt(H.LEFT);
}
}
)
.requestAll()
;

H.drawStage();
}

void draw() {
}
46 changes: 46 additions & 0 deletions examples/HFontPool/HFontPool_004/HFontPool_004.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import hype.*;
import hype.extended.colorist.*;
import hype.extended.layout.HGridLayout;

HColorPool colors;
HDrawablePool pool;
HFontPool fonts;

void setup() {
size(900, 900, P2D);
H.init(this).background(#202020).use3D(false);
colors = new HColorPool(#FFFFFF, #F7F7F7, #ECECEC, #333333, #0095a8, #00616f, #FF3300, #FF6600);
noLoop();

fonts = new HFontPool().addSystemFonts(); //load all available system fonts...

pool = new HDrawablePool(20);
pool.autoAddToStage()
.add(new HText("", 24, null))
.layout(
new HGridLayout()
.startX(40)
.startY(40)
.spacing(36, 36)
.cols(1)
)
.onCreate(
new HCallback() {
public void run(Object obj) {
int i = pool.currentIndex()+1;
HText t = (HText) obj;
t.fill( colors.getColor() );
t.font(fonts.getRandomFont()); //pick random font
t.text(i + ". " + fonts.currentName());
t.anchorAt(H.LEFT);
}
}
)
.requestAll()
;

H.drawStage();
}

void draw() {
}
Loading