Files
Nomi/source/nomi.c
2025-11-01 19:00:41 -07:00

115 lines
2.6 KiB
C

#include <tart.h>
#include <math.h>
#include "nomi.h"
#include <stdlib.h>
#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();
/*
* Draw Branch
*/
void DrawBranch(branch* branch, struct tart_window* w, tart_byte b) {
struct tart_cell cell = NULL_CELL;
cell.display = '*';
struct nomiSpirel spirel;
int SizeOfFile = 600;
char cellChart[] = {'%','*','\\','/','l','&','b','+','=','^',':'};
unsigned int iderations = 0;
struct tart_vec2 pos0 = {10+30,( 10/2)+20};
struct tart_vec2 c0 = { 5+30,-( 20/2)+20}; // controle point 0
struct tart_vec2 c1 = {30+30,-( 25/2)+20}; // controle point 1
struct tart_vec2 pos1 = {17+30,( 30/2)+20};
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
cell.display = cellChart[rand_r(&iderations)%11];
dpos = (struct tart_vec2){
(1-count)*((1-count)*((1-count)*pos0.x + count * c0.x) + count *
((1-count)*c0.x + count*c1.x)) +
count *((1-count)*((1-count)*c0.x + count * c1.x) +
count * ((1-count)*c1.x + pos1.x)),
(1-count)*((1-count)*((1-count)*pos0.y + count * c0.y) + count *
((1-count)*c0.y + count*c1.y)) +
count *((1-count)*((1-count)*c0.y + count * c1.y) +
count * ((1-count)*c1.y + pos1.y)),
};
iderations += 1 + dpos.x + dpos.y;
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++) {
//
//}
}
/*
* 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);