#include #include #include "nomi.h" #include #define SPIREL_MOD 0.618055f struct nomiSpirel { struct tart_cell selected_cell; struct tart_cell unselected_cell; struct tart_vec2 startPos; struct tart_vec2 size; struct tart_vec2 endPos; unsigned char oreantation; int fibonacci[3]; }; struct nomiMenu { struct nomiSpirel branches[30]; struct tart_vec2 startPos; struct tart_vec2 size; struct tart_vec2 origin; unsigned char brachIds[30]; }; /* * This will Init Nomi */ void NomiInit(); /* * This will create the truk of the note. * */ trunk* CreateTrunk(); /* * This is a test * */ void CreaetBranch(trunk* trunk); /* * Locate Branch * */ branch* LocateBranch(); float t = 0; float a = 0; nomi_vec2 RotatePoint(nomi_vec2 or,nomi_vec2 t, nomi_vec2 d) { nomi_vec2 pos; float a = atan2(d.y, d.x) - 3.14f/2; //a+= 0.001f; pos.x = (t.x * cos(a) - t.y * sin(a)); pos.y = (t.x * sin(a) + t.y * cos(a))/2; return pos; } nomi_curve RotateCurve(nomi_curve og, nomi_vec2 d) { nomi_curve c; c.start = og.start; // start is the origin so there is no need to rotate c.start = RotatePoint(og.start, og.start, d); // this point c.c0 = RotatePoint(og.start,og.c0,d); c.c1 = RotatePoint(og.start,og.c1,d); c.end = RotatePoint(og.start,og.end,d); return c; } branch create_branch(branch* parent, nomi_vec2 d) { branch branch; branch.curve.start = (nomi_vec2){ 0, 0}; branch.curve.c0 = (nomi_vec2){ (( 25) * -1), ((35/2.f) * -1)}; // controle point 0 branch.curve.c1 = (nomi_vec2){ (( -10) * -1), ((35/2.f) * -1)}; // controle point 1 branch.curve.end = (nomi_vec2){ (( 3) * -1), ((20/2.f) * -1)}; branch.curve = RotateCurve(branch.curve, d); if(parent != NULL) { float count = .5; nomi_vec2 dpos = { (1-count)*((1-count)*((1-count)*parent->curve.start.x + count * parent->curve.c0.x) + count * ((1-count)*parent->curve.c0.x + count*parent->curve.c1.x)) + count * ((1-count)*((1-count)*parent->curve.c0.x + count * parent->curve.c1.x) + count * ((1-count)*parent->curve.c1.x + parent->curve.end.x)), (1-count)*((1-count)*((1-count)*parent->curve.start.y + count * parent->curve.c0.y) + count * ((1-count)*parent->curve.c0.y + count*parent->curve.c1.y)) + count *((1-count)*((1-count)*parent->curve.c0.y + count * parent->curve.c1.y) + count * ((1-count)*parent->curve.c1.y + parent->curve.end.y)), }; branch.startPos.x = dpos.x += parent->startPos.x; branch.startPos.y = dpos.y += parent->startPos.y*1; branch.cell.background = TART_COLOR_BRIGHT_CYAN_FOREGROUND; return branch; } branch.cell = NULL_CELL; branch.startPos.x = term_current_size().x/2.f; branch.startPos.y = term_current_size().y/2.f; return branch; } /* * Draw Branch */ void DrawBranch(branch* branch, struct tart_window* w, tart_byte b) { struct nomiSpirel spirel; nomi_curve c; int SizeOfFile = 600; char cellChart[] = {'%','*','\\','/','l','&','7','+','=','^',':'}; unsigned int iderations = 0; //if(branch->curve.start.x == 0) { //branch->curve.start = (nomi_vec2){ // 0, // 0}; //branch->curve.c0 = (nomi_vec2){ // (( 25) * -1), // ((35/2.f) * -1)}; // controle point 0 //branch->curve.c1 = (nomi_vec2){ // (( -10) * -1), // ((35/2.f) * -1)}; // controle point 1 //branch->curve.end = (nomi_vec2){ // (( 3) * -1), // ((20/2.f) * -1)}; ////c = RotateCurve(branch->curve, (nomi_vec2){0,0}); //} struct tart_vec2 dpos = {0,0}; float count = 0; while(count < 1) { // This is the direction that the spirel is oreanted // 0 = up // 1 = left // 2 = down // 3 = right iderations++; branch->cell.display = cellChart[rand_r(&iderations)%11]; dpos = (struct tart_vec2){ (1-count)*((1-count)*((1-count)*branch->curve.start.x + count * branch->curve.c0.x) + count * ((1-count)*branch->curve.c0.x + count*branch->curve.c1.x)) + count * ((1-count)*((1-count)*branch->curve.c0.x + count * branch->curve.c1.x) + count * ((1-count)*branch->curve.c1.x + branch->curve.end.x)), (1-count)*((1-count)*((1-count)*branch->curve.start.y + count * branch->curve.c0.y) + count * ((1-count)*branch->curve.c0.y + count*branch->curve.c1.y)) + count *((1-count)*((1-count)*branch->curve.c0.y + count * branch->curve.c1.y) + count * ((1-count)*branch->curve.c1.y + branch->curve.end.y)), }; dpos.x += branch->startPos.x; dpos.y += branch->startPos.y; if(dpos.x >= 0 && dpos.y >=0) { tart_draw_cell_position(tart_get_buffer(w, b), branch->cell, dpos); } count += .01f; } //for(int i = 0; i < rint((SizeOfFile/10.0f)*SPIREL_MOD); i++) { // //} } /* * Create Nomi File * * name: the name of the file that will be created. */ FILE CreateNomiFile(const char* name); /* * Save Nomi File * * file: the pointer to the nomi file. */ void SaveNomiFile(FILE* file);