Implement hexagram_cluster_resize(), hexagram_cluster_init()
This commit is contained in:
parent
393d35454d
commit
654dfac3d1
2 changed files with 27 additions and 10 deletions
|
@ -24,6 +24,14 @@ typedef struct _hexagram_cluster {
|
|||
} state;
|
||||
} hexagram_cluster;
|
||||
|
||||
void hexagram_cluster_resize(hexagram_cluster *cluster,
|
||||
double width,
|
||||
double height);
|
||||
|
||||
void hexagram_cluster_init(hexagram_cluster *cluster,
|
||||
double width,
|
||||
double height);
|
||||
|
||||
hexagram_cluster *hexagram_cluster_new(double width,
|
||||
double height);
|
||||
|
||||
|
|
|
@ -3,13 +3,9 @@
|
|||
|
||||
#include <hexagram/cluster.h>
|
||||
|
||||
hexagram_cluster *hexagram_cluster_new(double width, double height) {
|
||||
hexagram_cluster *cluster;
|
||||
|
||||
if ((cluster = malloc(sizeof(*cluster))) == NULL) {
|
||||
goto error_malloc_cluster;
|
||||
}
|
||||
|
||||
void hexagram_cluster_resize(hexagram_cluster *cluster,
|
||||
double width,
|
||||
double height) {
|
||||
/*
|
||||
* Ensure correct cluster aspect ratio
|
||||
*/
|
||||
|
@ -50,11 +46,24 @@ hexagram_cluster *hexagram_cluster_new(double width, double height) {
|
|||
|
||||
cluster->width = width;
|
||||
cluster->height = height;
|
||||
}
|
||||
|
||||
void hexagram_cluster_init(hexagram_cluster *cluster,
|
||||
double width,
|
||||
double height) {
|
||||
hexagram_cluster_resize(cluster, width, height);
|
||||
|
||||
/*
|
||||
* Initialize mutable state
|
||||
*/
|
||||
memset(&cluster->state, '\0', sizeof(cluster->state));
|
||||
}
|
||||
|
||||
hexagram_cluster *hexagram_cluster_new(double width, double height) {
|
||||
hexagram_cluster *cluster;
|
||||
|
||||
if ((cluster = malloc(sizeof(*cluster))) == NULL) {
|
||||
goto error_malloc_cluster;
|
||||
}
|
||||
|
||||
hexagram_cluster_init(cluster, width, height);
|
||||
|
||||
return cluster;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue