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

added new glitch effect #56

Merged
merged 1 commit into from
Oct 29, 2021
Merged
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
30 changes: 26 additions & 4 deletions examples/text/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,17 @@ Lo, brave adventurer! Choose a tasty treat:\

// shadow text
auto shadow_text = [](std::string m, color_t c, color_t s, int32_t x, int32_t y, int32_t sx, int32_t sy) {
blend(MASK);
blend(ALPHA);
pen(s);
text(m, x + sx, y + sy);
text(m, x + sx - 1, y + sy);
text(m, x + sx + 1, y + sy);
text(m, x + sx, y + sy + 1);
pen(c);
text(m, x, y);
};
int32_t sx = sin(time() / 250.0f) * 3.0f;
shadow_text("Shadow text example", rgb(13, 13, 15), rgb(7, 7, 9), 7, 20, sx, 2);
shadow_text("Shadow text example", rgb(13, 13, 15), rgb(7, 7, 9, 4), 7, 20, sx, 2);

// gradient text
auto gradient_text = [](std::string m, color_t c1, color_t c2, int32_t x, int32_t y) {
Expand Down Expand Up @@ -185,7 +188,7 @@ Lo, brave adventurer! Choose a tasty treat:\

// extrude text
auto extrude_text = [](std::string m, color_t c, color_t s, int32_t x, int32_t y, int32_t l) {
blend(MASK);
blend(ALPHA);
pen(s);
for(int i = 1; i <= l; i++) {
text(m, x + i, y + i);
Expand All @@ -194,7 +197,7 @@ Lo, brave adventurer! Choose a tasty treat:\
text(m, x, y);
};
int32_t l = 1 + ((sin(time() / 250.0f) + 1.0f) * 2.0f);
extrude_text("Extrude text example", rgb(2, 14, 14), rgb(14, 2, 2), 5, 65, l);
extrude_text("Extrude text example", rgb(0, 15, 15), rgb(15, 0, 0, 12), 5, 65, l);


auto split_text = [](std::string m, color_t c1, color_t c2, int32_t x, int32_t y) {
Expand Down Expand Up @@ -226,6 +229,25 @@ Lo, brave adventurer! Choose a tasty treat:\
};
int32_t g = 1 + ((sin(time() / 250.0f) + 1.0f) * 2.0f);
glow_text("Glow text example", hsv(hue, 1.0f, 1.0f, 0.2f), 15, 95);

// glitch text
auto glitch_text = [](std::string m, color_t c, int32_t x, int32_t y) {
blend(MASK);
pen(c);
for(uint8_t i = 0; i < 8; i++) {
clip(0, y + i, 120, 1);
int8_t o = 0;
if(std::rand() % 8 == 0) {
o = (std::rand() % 9) - 4;
}
text(m, x + o, y);
}
clip();
};

// split text
glitch_text("Glitch text example", rgb(6, 15, 12), 13, 110);

}break;
}
}