Change demo to flower output

This commit is contained in:
Madeline Busig 2025-05-07 02:47:40 -07:00
parent 57db942f9e
commit 7ba5b07ec6

View File

@ -21,14 +21,26 @@ int main(void) {
mlog::debug << "Hello world!" << mtl::flush; mlog::debug << "Hello world!" << mtl::flush;
constexpr float cos_PI_2 = std::cos(M_PI_2); constexpr float cos_PI_2 = std::cos(M_PI_2);
constexpr float cos_PI_3 = std::cos(M_PI / 3);
constexpr float cos_PI_4 = std::cos(M_PI_4); constexpr float cos_PI_4 = std::cos(M_PI_4);
constexpr float cos_PI_8 = std::cos(M_PI_4 / 2);
constexpr float cos_PI_16 = std::cos(M_PI_4 / 4);
constexpr float sin_PI_2 = std::sin(M_PI_2); constexpr float sin_PI_2 = std::sin(M_PI_2);
constexpr float sin_PI_3 = std::sin(M_PI / 3);
constexpr float sin_PI_4 = std::sin(M_PI_4); constexpr float sin_PI_4 = std::sin(M_PI_4);
constexpr float sin_PI_8 = std::sin(M_PI_4 / 2);
constexpr float sin_PI_16 = std::sin(M_PI_4 / 4);
fixed cos_PI_2_fx = cos_PI_2; fixed cos_PI_2_fx = cos_PI_2;
fixed cos_PI_3_fx = cos_PI_3;
fixed cos_PI_4_fx = cos_PI_4; fixed cos_PI_4_fx = cos_PI_4;
fixed cos_PI_8_fx = cos_PI_8;
fixed cos_PI_16_fx = cos_PI_16;
fixed sin_PI_2_fx = sin_PI_2; fixed sin_PI_2_fx = sin_PI_2;
fixed sin_PI_3_fx = sin_PI_3;
fixed sin_PI_4_fx = sin_PI_4; fixed sin_PI_4_fx = sin_PI_4;
fixed sin_PI_8_fx = sin_PI_8;
fixed sin_PI_16_fx = sin_PI_16;
try { try {
fixed branch_angle = M_PI_4; fixed branch_angle = M_PI_4;
@ -36,10 +48,10 @@ int main(void) {
token_id_t walk_petal_length = rules.add_token(token_type_e::walk, 8); token_id_t walk_petal_length = rules.add_token(token_type_e::walk, 8);
token_id_t walk_petal_side = rules.add_token(token_type_e::walk, 2); token_id_t walk_petal_side = rules.add_token(token_type_e::walk, 2);
token_id_t rotate_axiom = rules.add_token(token_type_e::rotate, cos_PI_2_fx, sin_PI_2_fx); token_id_t rotate_axiom = rules.add_token(token_type_e::rotate, cos_PI_3_fx, sin_PI_3_fx);
token_id_t rotate_petal = rules.add_token(token_type_e::rotate, cos_PI_2_fx, -sin_PI_2_fx); token_id_t rotate_petal = rules.add_token(token_type_e::rotate, cos_PI_3_fx, -sin_PI_3_fx);
token_id_t rotate_branchr = rules.add_token(token_type_e::rotate, cos_PI_4_fx, -sin_PI_4_fx); token_id_t rotate_branchr = rules.add_token(token_type_e::rotate, cos_PI_8_fx, -sin_PI_8_fx);
token_id_t rotate_branchl = rules.add_token(token_type_e::rotate, cos_PI_2_fx, sin_PI_2_fx); token_id_t rotate_branchl = rules.add_token(token_type_e::rotate, cos_PI_4_fx, sin_PI_4_fx);
token_id_t branch = rules.add_token(token_type_e::empty); token_id_t branch = rules.add_token(token_type_e::empty);
token_id_t petal = rules.add_token(token_type_e::empty); token_id_t petal = rules.add_token(token_type_e::empty);
@ -47,7 +59,7 @@ int main(void) {
mlog::info << "Added tokens" << endl; mlog::info << "Added tokens" << endl;
uint32_t axiom_factor = 4; uint32_t axiom_factor = 6;
etl::vector axiom_chr{ branch, rotate_axiom }; etl::vector axiom_chr{ branch, rotate_axiom };
group_id_t axiom_grp = rules.add_group_characteristic(axiom_chr, axiom_factor); group_id_t axiom_grp = rules.add_group_characteristic(axiom_chr, axiom_factor);
@ -73,11 +85,11 @@ int main(void) {
size_t gen_num = 0; size_t gen_num = 0;
try { try {
constexpr fixed scale = 0.5; constexpr fixed scale = 0.8;
gen.parse_ruleset(rules); gen.parse_ruleset(rules);
gen.set_scale(scale); gen.set_scale(scale);
while (gen.step_generation(output) && gen.generation_num() < 4) { while (gen.step_generation(output) && gen.generation_num() < 6) {
mlog::debug << "Stepped generation" << gen.generation_num() << endl; mlog::debug << "Stepped generation" << gen.generation_num() << endl;
gen_num = gen.generation_num(); gen_num = gen.generation_num();
} }
@ -96,6 +108,50 @@ int main(void) {
mlog::info << " " << marker.m_pos << endl; mlog::info << " " << marker.m_pos << endl;
} }
vec2 origin(120, 80);
int imgscale = 8;
uint8_t r = 0;
uint8_t g = 0;
uint8_t b = 0;
uint8_t a = 0;
COLOR color[3] = { CLR_FUCHSIA, CLR_CREAM, CLR_MAROON };
for (size_t i = 2; i < output.size(); i += 3) {
const marker_t& m1 = output[i-2];
const marker_t& m2 = output[i-1];
const marker_t& m3 = output[i-0];
r = 0xFF * 2 / i;
g = 0xFF * 2 / i;
b = 0x33;
a = 0xFF;
//color = (a << 24) | (r << 16) | (g << 8) | b;
clr_rotate(color, 3, 1);
vec2 v1 = origin + imgscale * m1.m_pos;
vec2 v2 = origin + imgscale * m2.m_pos;
vec2 v3 = origin + imgscale * m3.m_pos;
mlog::debug << "Vertices: " << v1 << ", " << v2 << ", " << v3 << endl;
int32_t iv1_x = v1.x.raw() / 256;
int32_t iv1_y = v1.y.raw() / 256;
int32_t iv2_x = v2.x.raw() / 256;
int32_t iv2_y = v2.y.raw() / 256;
int32_t iv3_x = v3.x.raw() / 256;
int32_t iv3_y = v3.y.raw() / 256;
mlog::debug << " (" << iv1_x << ", " << iv1_y << ")" << endl;
mlog::debug << " (" << iv2_x << ", " << iv2_y << ")" << endl;
mlog::debug << " (" << iv3_x << ", " << iv3_y << ")" << endl;
bmp16_line(iv1_x, iv1_y, iv2_x, iv2_y, color[0], vid_mem, 480);
bmp16_line(iv1_x, iv1_y, iv3_x, iv3_y, color[0], vid_mem, 480);
bmp16_line(iv2_x, iv2_y, iv3_x, iv3_y, color[0], vid_mem, 480);
}
while (true) { while (true) {
vid_vsync(); vid_vsync();
} }