worked on adding more stuff to the nomi project

This commit is contained in:
2025-11-04 16:42:42 -08:00
parent 998c2aa393
commit 98a190eb5e
3 changed files with 62 additions and 50 deletions

View File

@@ -1,3 +1,4 @@
#include <string.h>
#include <tart.h>
#include <math.h>
#include "nomi.h"
@@ -50,10 +51,10 @@ 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;
float c = atan2(d.y, d.x) - 3.14f/2;
//a+= 0.0002f;
pos.x = (t.x * cos(a+c) - t.y * sin(a+c));
pos.y = (t.x * sin(a+c) + t.y * cos(a+c))/2;
return pos;
@@ -70,7 +71,15 @@ nomi_curve RotateCurve(nomi_curve og, nomi_vec2 d) {
return c;
}
branch create_branch(branch* parent, nomi_vec2 d) {
/*
* create_branch
*
* branch* parent: this is the parent that this branch is connected to.
* nomi_vec2 d: This is the direction within the vector.
*/
branch create_branch(branch* parent, nomi_vec2 d, unsigned char percent,
unsigned char b) {
branch branch;
branch.curve.start = (nomi_vec2){
0,
@@ -87,7 +96,7 @@ branch create_branch(branch* parent, nomi_vec2 d) {
branch.curve = RotateCurve(branch.curve, d);
if(parent != NULL) {
float count = .5;
float count = percent/100.f;
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)) +
@@ -100,10 +109,12 @@ branch create_branch(branch* parent, nomi_vec2 d) {
};
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;
branch.cell = NULL_CELL;
branch.cell.background = b;
return branch;
}
branch.cell = NULL_CELL;
branch.cell.background = b;
branch.startPos.x = term_current_size().x/2.f;
branch.startPos.y = term_current_size().y/2.f;
return branch;
@@ -111,42 +122,25 @@ branch create_branch(branch* parent, nomi_vec2 d) {
/*
* Draw Branch
*
* *branch* branch*: this is the branch that would be rendered.
* *unsigned char* p*: this is the persentage.
* *struct tart_window* w*: this is the window that will be rendered.
* *tart_byte b*: this is the selected buffer.
*/
void DrawBranch(branch* branch, struct tart_window* w, tart_byte b) {
struct nomiSpirel spirel;
nomi_curve c;
int SizeOfFile = 600;
void DrawBranch(branch* branch, unsigned char p, struct tart_window* w, tart_byte b) {
// List of random chars to be renderd
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) {
while(count < p/100.0) {
// This is the direction that the spirel is oreanted
// 0 = up
// 1 = left
// 2 = down
// 3 = right
iderations++;
iderations++; // for selecting a random char to be renderd
branch->cell.display = cellChart[rand_r(&iderations)%11];
@@ -167,16 +161,8 @@ void DrawBranch(branch* branch, struct tart_window* w, tart_byte b) {
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++) {
//
//}
}
/*