worked on adding more stuff to the nomi project
This commit is contained in:
@@ -113,13 +113,17 @@ int main (int argc, char *argv[]) {
|
||||
|
||||
signal(SIGINT, programClose);
|
||||
|
||||
float animStep = 0;
|
||||
|
||||
char str[255] = "This is a test";
|
||||
char commandPromt[16] = "Enter Command: ";
|
||||
char commandInput[255] = "";
|
||||
unsigned char keyPressed = 0;
|
||||
|
||||
branch b = create_branch(NULL, (nomi_vec2){0,1});
|
||||
branch b1 = create_branch(&b,(nomi_vec2){1,1});
|
||||
|
||||
branch b = create_branch(NULL, (nomi_vec2){0,1}, 0, TART_COLOR_BLUE_BACKGROUND);
|
||||
branch b1 = create_branch(&b,(nomi_vec2){1,1}, 50, TART_COLOR_BLUE_BACKGROUND);
|
||||
branch b2 = create_branch(&b1,(nomi_vec2){1,1}, 20, TART_COLOR_BRIGHT_GREEN_BACKGROUND);
|
||||
|
||||
// Window Createion
|
||||
struct tart_window window = tart_create_window();
|
||||
@@ -143,6 +147,9 @@ int main (int argc, char *argv[]) {
|
||||
|
||||
tart_restore_window(&window);
|
||||
tart_restore_buffer(tart_get_buffer(&window, 0));
|
||||
unsigned char branch1Color = TART_COLOR_GREEN_FOREGROUND;
|
||||
unsigned char branch2Color = TART_COLOR_GREEN_FOREGROUND;
|
||||
unsigned char branch3Color = TART_COLOR_GREEN_FOREGROUND;
|
||||
|
||||
for (;!__Close__;) {
|
||||
// LOOP START
|
||||
@@ -150,14 +157,30 @@ int main (int argc, char *argv[]) {
|
||||
tart_restore_window(&window);
|
||||
tart_restore_buffer(tart_get_buffer(&window, 0));
|
||||
|
||||
b = create_branch(NULL, (nomi_vec2){0,1});
|
||||
b1 = create_branch(&b,(nomi_vec2){1,4*2});
|
||||
b = create_branch(NULL, (nomi_vec2){0,1}, 0, branch1Color);
|
||||
b1 = create_branch(&b,(nomi_vec2){1,4*2}, 20, branch2Color);
|
||||
b2 = create_branch(&b1,(nomi_vec2){1,0}, 10, branch3Color);
|
||||
|
||||
if(keyPressed) {
|
||||
tart_draw_window(&window, 0);
|
||||
|
||||
char c = term_tinput();
|
||||
|
||||
if( c == '1') {
|
||||
branch1Color = TART_COLOR_WHITE_BACKGROUND;
|
||||
branch2Color = TART_COLOR_GREEN_FOREGROUND;
|
||||
branch3Color = TART_COLOR_GREEN_FOREGROUND;
|
||||
}
|
||||
if( c == '2') {
|
||||
branch2Color = TART_COLOR_WHITE_BACKGROUND;
|
||||
branch1Color = TART_COLOR_GREEN_FOREGROUND;
|
||||
branch3Color = TART_COLOR_GREEN_FOREGROUND;
|
||||
}
|
||||
if( c == '3') {
|
||||
branch3Color = TART_COLOR_WHITE_BACKGROUND;
|
||||
branch1Color = TART_COLOR_GREEN_FOREGROUND;
|
||||
branch2Color = TART_COLOR_GREEN_FOREGROUND;
|
||||
}
|
||||
|
||||
//Speual
|
||||
SetRichTextBox(&inputRtb, str, strlen(str), NULL_CELL);
|
||||
|
||||
@@ -259,8 +282,10 @@ int main (int argc, char *argv[]) {
|
||||
|
||||
|
||||
|
||||
DrawBranch(&b, &window, 0);
|
||||
DrawBranch(&b1, &window, 0);
|
||||
// Drawing Branches
|
||||
DrawBranch(&b,100, &window, 0);
|
||||
DrawBranch(&b1,100, &window, 0);
|
||||
DrawBranch(&b2,100, &window, 0);
|
||||
|
||||
tart_draw_window(&window, 0);
|
||||
if(mode == COMMAND_MODE) {
|
||||
|
||||
@@ -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++) {
|
||||
//
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -44,6 +44,7 @@ typedef struct {
|
||||
struct tart_cell cell;
|
||||
void* parent; // points the the branches parent
|
||||
char type; // holds the type as in if this struct is a branch or a trunk
|
||||
float angle;
|
||||
nomi_vec2 startPos; // the starting position of the branch
|
||||
nomi_curve curve;
|
||||
branchId id; // This holds the branch id.
|
||||
@@ -75,11 +76,11 @@ void CreaetBranch(trunk* trunk);
|
||||
* */
|
||||
branch* LocateBranch();
|
||||
|
||||
branch create_branch(branch* parent, nomi_vec2 d);
|
||||
branch create_branch(branch* parent, nomi_vec2 d, unsigned char percent, unsigned char b);
|
||||
/*
|
||||
* Draw Branch
|
||||
*/
|
||||
void DrawBranch(branch* branch, struct tart_window* w, tart_byte b);
|
||||
void DrawBranch(branch* branch,unsigned char p, struct tart_window* w, tart_byte b);
|
||||
|
||||
/*
|
||||
* Create Nomi File
|
||||
|
||||
Reference in New Issue
Block a user