Skip to content

Commit

Permalink
font outline and index rollover
Browse files Browse the repository at this point in the history
  • Loading branch information
darkshoxx committed Sep 12, 2024
1 parent 1891d9f commit 3c47229
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 18 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,4 @@ TODO:
- make textbox prettier
- make build easier
- refactor file loading
- add javadoc
- general refactor
- implement: if not enough information: loop over previous
- general refactor
30 changes: 22 additions & 8 deletions WheelV1/WheelV1.pde
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,11 @@ void drawLabels(float half, float angle, float angle2, float almost, int segnum)
rotate(angle/2+ angle2);
for (int i=0; i< segments.length; i++) {
// get font colour
color fontColour = 0;
color fontColour2 = 0;
if (colours != null){
fill(get_first_colour_from_line(colours[i]));
} else {
//default font colour: black
fill(0);
fontColour = get_first_colour_from_line(colours[i%colours.length]);
fontColour2 = get_second_colour_from_line(colours[i%colours.length]);
}
rotate(angle);
// inital estimates on font size, requried for helper function
Expand All @@ -380,7 +380,8 @@ void drawLabels(float half, float angle, float angle2, float almost, int segnum)
// rotate font in each segments
float adjustAngle = asin(newSize/(almost/2));
rotate(adjustAngle);
text(segments[i], 100, 0);
strokeText(segments[i], 100, 0, 0, fontColour, newSize);
// strokeText(segments[i], 100, 0, fontColour2, fontColour); // optional: choose font border yourself
// rotate back to origin for next segment
rotate(-adjustAngle);
}
Expand All @@ -404,7 +405,7 @@ void drawSegments(float half, float almost, float angle, float angle2) {
// I somehow messed up the index further down, so I'm hiding the crimes in this
// fixedindex variable
int fixedindex = ((i+segments.length - 1)%segments.length);
color inbetween = get_second_colour_from_line(colours[fixedindex]);
color inbetween = get_second_colour_from_line(colours[fixedindex%colours.length]);
fill(inbetween);
} else {
// no background colours: follow colour wheel
Expand All @@ -424,14 +425,27 @@ void drawSegments(float half, float almost, float angle, float angle2) {
maskImage.beginDraw();
maskImage.arc(half, half, almost-10, almost-10, i*angle + angle2, (i+1)*angle + angle2 );
maskImage.endDraw();
images[fixedindex].mask(maskImage);
image(images[fixedindex], 0, 0);
PImage currentImage = images[fixedindex%images.length];
currentImage.mask(maskImage);
image(currentImage, 0, 0);
} else { //<>//
arc(half, half, almost-10, almost-10, i*angle + angle2, (i+1)*angle + angle2 );
}
}
}

void strokeText(String message, int x, int y, color c1, color c2, float fontsize)
{
float thickness = fontsize/25;
fill(c1);
text(message, x-thickness, y);
text(message, x, y-thickness);
text(message, x+thickness, y);
text(message, x, y+thickness);
fill(c2);
text(message, x, y);
}

void mouseClicked() {
// TODO: for some reason, sometimes clicks are not registered.
if (abs(mouseX-height/2)<25 & abs(mouseY-height/2)<25 ) {
Expand Down
3 changes: 2 additions & 1 deletion colours.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
#22DD22 #DD22DD
#2222DD #DDDD22
#22DDDD #DD2222
#DD22DD #22DD22
#DD22DD #22DD22
#DDDD22 #2222DD
4 changes: 1 addition & 3 deletions images.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
1.png
2.png
3.png
4.png
5.png
3.png
14 changes: 11 additions & 3 deletions segments.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
1 RED on CYAN
2 GREEN on MAGENTA
2 GREE
3 BLUE on YELLOW
4 CYAN on RED
5 MAGENTA on GREEN
4
5 MAGENTA on GREEN1 RED on CYAN
2 GREE
3 BLUE on YELLOW
4
5 MAGENTA on GREEN
1 RED on CYAN
2 GREE
3 BLUE on YELLOW
4

0 comments on commit 3c47229

Please sign in to comment.