-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added rendering for components and leds
- Loading branch information
Showing
12 changed files
with
172 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "NodeVector.h" | ||
#include "debugmalloc.h" | ||
|
||
NodeVector nodev_create(size_t count) { | ||
NodeVector result; | ||
result.capacity = count * 2 + 1; | ||
result.count = count; | ||
result.nodes = (Node *)malloc(sizeof(Node) * result.capacity); | ||
return result; | ||
} | ||
|
||
void nodev_push_back(NodeVector *vector, Node node) { | ||
if (vector->count >= vector->capacity) { | ||
vector->capacity *= 2; | ||
Node *newmem = (Node *)realloc(vector->nodes, sizeof(Node) * vector->capacity); | ||
if (newmem == NULL) { | ||
log_error("Couldn't reallocate vector!\n"); | ||
return; | ||
} | ||
vector->nodes = newmem; | ||
} | ||
memcpy(&(vector->nodes[vector->count]), &node, sizeof(node)); | ||
vector->count++; | ||
} | ||
|
||
void nodev_erase(NodeVector *vector, int index) { | ||
for (int i = index + 1; i < vector->count; i++) { | ||
vector->nodes[i - 1] = vector->nodes[i]; | ||
} | ||
vector->count--; | ||
} | ||
|
||
void nodev_free(NodeVector *vector) { | ||
for (int i = 0; i < vector->count; i++) | ||
node_free(&vector->nodes[i]); | ||
free(vector->nodes); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef HOMEWORK_NODEVECTOR_H | ||
#define HOMEWORK_NODEVECTOR_H | ||
|
||
#include <stddef.h> | ||
#include "Node.h" | ||
|
||
typedef struct NodeVector { | ||
Node *nodes; | ||
size_t count; | ||
size_t capacity; | ||
} NodeVector; | ||
|
||
NodeVector nodev_create(size_t count); | ||
|
||
void nodev_push_back(NodeVector *vector, Node node); | ||
|
||
void nodev_erase(NodeVector *vector, int index); | ||
|
||
void nodev_free(NodeVector *vector); | ||
|
||
#endif //HOMEWORK_NODEVECTOR_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
0.5 0.5 | ||
C 0.25,0.25 0.2 e | ||
L 0.1086,0.1086 0.3914,0.3914 | ||
L 0.1086,0.3914 0.3914,0.1086 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
1 | ||
in A 0.05,0.25 3.1415 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
assigns 0 | ||
in 1 | ||
out 0 |