added curves
This commit is contained in:
108
source/nomi.c
108
source/nomi.c
@@ -49,17 +49,19 @@ void DrawBranch(branch* branch, struct tart_window* w, tart_byte b) {
|
|||||||
struct tart_cell cell = NULL_CELL;
|
struct tart_cell cell = NULL_CELL;
|
||||||
cell.display = '*';
|
cell.display = '*';
|
||||||
struct nomiSpirel spirel;
|
struct nomiSpirel spirel;
|
||||||
int SizeOfFile = 210;
|
int SizeOfFile = 600;
|
||||||
char cellChart[] = {'%','*','\\','/','l','&','b','+','=','^',':'};
|
char cellChart[] = {'%','*','\\','/','l','&','b','+','=','^',':'};
|
||||||
int iderations = 0;
|
unsigned int iderations = 0;
|
||||||
int fib = 0;
|
|
||||||
int fib1 = 1;
|
|
||||||
int fib2 = 0;
|
|
||||||
struct tart_vec2 pos = {40,10};
|
|
||||||
struct tart_vec2 nextPos;
|
|
||||||
unsigned int count = 0;
|
|
||||||
|
|
||||||
while(SizeOfFile/10 > fib) {
|
struct tart_vec2 pos0 = {15+30, 0/2};
|
||||||
|
struct tart_vec2 c0 = { 0+30,30/2}; // controle point 0
|
||||||
|
struct tart_vec2 c1 = {30+30,19/2}; // controle point 1
|
||||||
|
struct tart_vec2 pos1 = {17+30,11/2};
|
||||||
|
|
||||||
|
struct tart_vec2 dpos = {0,0};
|
||||||
|
float count = 0;
|
||||||
|
|
||||||
|
while(count < 1) {
|
||||||
|
|
||||||
// This is the direction that the spirel is oreanted
|
// This is the direction that the spirel is oreanted
|
||||||
// 0 = up
|
// 0 = up
|
||||||
@@ -67,80 +69,26 @@ void DrawBranch(branch* branch, struct tart_window* w, tart_byte b) {
|
|||||||
// 2 = down
|
// 2 = down
|
||||||
// 3 = right
|
// 3 = right
|
||||||
|
|
||||||
if(iderations < 3){
|
iderations++;
|
||||||
iderations++;
|
|
||||||
} else {
|
|
||||||
iderations = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
fib = fib1 + fib2;
|
cell.display = cellChart[rand_r(&iderations)%11];
|
||||||
fib2 = fib1;
|
|
||||||
fib1 = fib;
|
|
||||||
|
|
||||||
|
dpos = (struct tart_vec2){
|
||||||
cell.display = cellChart[rand_r(&count)%11];
|
(1-count)*((1-count)*((1-count)*pos0.x + count * c0.x) + count *
|
||||||
|
((1-count)*c0.x + count*c1.x)) +
|
||||||
switch(iderations) {
|
count *((1-count)*((1-count)*c0.x + count * c1.x) +
|
||||||
case 0: // up
|
count * ((1-count)*c1.x + pos1.x)),
|
||||||
pos.x += fib/2;
|
(1-count)*((1-count)*((1-count)*pos0.y + count * c0.y) + count *
|
||||||
pos.y += fib/2;
|
((1-count)*c0.y + count*c1.y)) +
|
||||||
for(int i = 0; i < fib/2; i ++){
|
count *((1-count)*((1-count)*c0.y + count * c1.y) +
|
||||||
tart_draw_cell_position(tart_get_buffer(w, b),
|
count * ((1-count)*c1.y + pos1.y)),
|
||||||
cell,
|
};
|
||||||
(struct tart_vec2){pos.x-(i-2), pos.y-i});
|
|
||||||
count++;
|
|
||||||
cell.display = cellChart[rand_r(&count)%11];
|
|
||||||
|
|
||||||
tart_draw_cell_position(tart_get_buffer(w, b),
|
|
||||||
cell,
|
|
||||||
(struct tart_vec2){pos.x-(i-2) + 1, pos.y-i});
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1: // right
|
|
||||||
pos.x += fib/2;
|
|
||||||
pos.y -= fib/2;
|
|
||||||
for(int i = 0; i < fib/2; i ++){
|
|
||||||
tart_draw_cell_position(tart_get_buffer(w, b),
|
|
||||||
cell,
|
|
||||||
(struct tart_vec2){pos.x - i, pos.y+i});
|
|
||||||
count++;
|
|
||||||
cell.display = cellChart[rand_r(&count)%11];
|
|
||||||
tart_draw_cell_position(tart_get_buffer(w, b),
|
|
||||||
cell,
|
|
||||||
(struct tart_vec2){pos.x-i + 1, pos.y+i});
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2: // down
|
|
||||||
pos.x -= fib/2;
|
|
||||||
pos.y -= fib/2;
|
|
||||||
for(int i = 0; i < fib/2; i ++){
|
|
||||||
tart_draw_cell_position(tart_get_buffer(w, b),
|
|
||||||
cell,
|
|
||||||
(struct tart_vec2){pos.x+(i+2), pos.y+i});
|
|
||||||
count++;
|
|
||||||
cell.display = cellChart[rand_r(&count)%11];
|
|
||||||
tart_draw_cell_position(tart_get_buffer(w, b),
|
|
||||||
cell,
|
|
||||||
(struct tart_vec2){pos.x+(i+2) + 1, pos.y+i});
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 3: // left
|
|
||||||
pos.x -= fib/2;
|
|
||||||
pos.y += fib/2;
|
|
||||||
for(int i = 0; i < fib/2; i ++){
|
|
||||||
tart_draw_cell_position(tart_get_buffer(w, b),
|
|
||||||
cell,
|
|
||||||
(struct tart_vec2){pos.x+i, pos.y-i});
|
|
||||||
count++;
|
|
||||||
cell.display = cellChart[rand_r(&count)%11];
|
|
||||||
tart_draw_cell_position(tart_get_buffer(w, b),
|
|
||||||
cell,
|
|
||||||
(struct tart_vec2){pos.x+ i + 1, pos.y-i});
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
count++;
|
tart_draw_cell_position(tart_get_buffer(w, b), cell, dpos);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
count += .01f;
|
||||||
}
|
}
|
||||||
|
|
||||||
//for(int i = 0; i < rint((SizeOfFile/10.0f)*SPIREL_MOD); i++) {
|
//for(int i = 0; i < rint((SizeOfFile/10.0f)*SPIREL_MOD); i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user