Skip to content

Commit

Permalink
Update to new coding standards.
Browse files Browse the repository at this point in the history
  • Loading branch information
anachrocomputer committed Apr 28, 2019
1 parent 84f80ba commit 07a58d5
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 55 deletions.
60 changes: 30 additions & 30 deletions rtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,64 +12,64 @@
#define RIGHT_ANGLE (22.0)
#define RIGHT_SIZE (0.70)

void tree (int level, double len);
void tree(const int level, const double len);

double Left_angle;
double Right_angle;
double Left_size;
double Right_size;

int main (int argc, const char *argv[])
int main(int argc, const char *argv[])
{
int level = 8;
double size = 65.0; /* 65mm trunk for A3 */
const int level = 8;
const double size = 65.0; /* 65mm trunk for A3 */

turtle (DEV_HPGL, SIZ_A3, ORI_LAND, FLG_BORD|FLG_RELS);
turtle(DEV_HPGL, SIZ_A3, ORI_LAND, FLG_BORD|FLG_RELS);

// title ("http://www.dorkbot.org/dorkbotbristol/", 3.75, BOT|LEFT, FLG_NONE);
title ("Bristol Hackspace", 3.75, BOT|LEFT, FLG_NONE);
title ("2018-04-22", 3.75, BOT|RIGHT, FLG_NONE);
// title("http://www.dorkbot.org/dorkbotbristol/", 3.75, BOT|LEFT, FLG_NONE);
title("Bristol Hackspace", 3.75, BOT|LEFT, FLG_NONE);
title("2018-04-22", 3.75, BOT|RIGHT, FLG_NONE);

srand ((unsigned int)time (NULL));
srand((unsigned int)time(NULL));

Left_angle = LEFT_ANGLE + (((double)rand () / (double)RAND_MAX) * 6.0);
Right_angle = RIGHT_ANGLE + (((double)rand () / (double)RAND_MAX) * 6.0);
Left_angle = LEFT_ANGLE + (((double)rand() / (double)RAND_MAX) * 6.0);
Right_angle = RIGHT_ANGLE + (((double)rand() / (double)RAND_MAX) * 6.0);

Left_size = LEFT_SIZE + (((double)rand () / (double)RAND_MAX) * 0.05);
Right_size = RIGHT_SIZE + (((double)rand () / (double)RAND_MAX) * 0.05);
Left_size = LEFT_SIZE + (((double)rand() / (double)RAND_MAX) * 0.05);
Right_size = RIGHT_SIZE + (((double)rand() / (double)RAND_MAX) * 0.05);

pen (UP);
turn (-90.0);
forward (1.9 * size);
turn (180.0);
pen (DOWN);
pen(UP);
turn(-90.0);
forward(1.9 * size);
turn(180.0);
pen(DOWN);

colour (BLACK);
colour(BLACK);

tree (level, size);
tree(level, size);

show ();
show();

return (0);
}


/* tree --- recursive function to plot a tree */

void tree (int level, double len)
void tree(const int level, const double len)
{
forward (len);
forward(len);

if (level == 0) {
turn (180.0);
turn(180.0);
}
else {
turn (Left_angle);
tree (level - 1, len * Left_size);
turn ((180.0 - Left_angle) - Right_angle);
tree (level - 1, len * Right_size);
turn (Right_angle);
turn(Left_angle);
tree(level - 1, len * Left_size);
turn((180.0 - Left_angle) - Right_angle);
tree(level - 1, len * Right_size);
turn(Right_angle);
}

forward (len);
forward(len);
}
50 changes: 25 additions & 25 deletions tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,51 +10,51 @@
#define RIGHT_ANGLE (25.0)
#define RIGHT_SIZE (0.75)

void tree (int level, double len);
void tree(const int level, const double len);

int main (int argc, const char *argv[])
int main(int argc, const char *argv[])
{
int level = 8;
// double size = 30.0; /* 30mm trunk for A4 */
double size = 65.0; /* 65mm trunk for A3 */
const int level = 8;
// const double size = 30.0; /* 30mm trunk for A4 */
const double size = 65.0; /* 65mm trunk for A3 */

turtle (DEV_HPGL, SIZ_A1, ORI_LAND, FLG_NONE|FLG_RELS|FLG_BORD);
turtle(DEV_HPGL, SIZ_A1, ORI_LAND, FLG_NONE|FLG_RELS|FLG_BORD);

// title ("http://www.dorkbot.org/dorkbotbristol/", 3.75, BOT|CENTRE, FLG_NONE);
title ("Bristol Hackspace", 3.75, BOT|CENTRE, FLG_NONE);
// title("http://www.dorkbot.org/dorkbotbristol/", 3.75, BOT|CENTRE, FLG_NONE);
title("Bristol Hackspace", 3.75, BOT|CENTRE, FLG_NONE);

pen (UP);
turn (-90.0);
forward (1.9 * size);
turn (180.0);
pen (DOWN);
pen(UP);
turn(-90.0);
forward(1.9 * size);
turn(180.0);
pen(DOWN);

colour (BLACK);
colour(BLACK);

tree (level, size);
tree(level, size);

show ();
show();

return (0);
}


/* tree --- recursive function to plot a tree */

void tree (int level, double len)
void tree(const int level, const double len)
{
forward (len);
forward(len);

if (level == 0) {
turn (180.0);
turn(180.0);
}
else {
turn (LEFT_ANGLE);
tree (level - 1, len * LEFT_SIZE);
turn ((180.0 - LEFT_ANGLE) - RIGHT_ANGLE);
tree (level - 1, len * RIGHT_SIZE);
turn (RIGHT_ANGLE);
turn(LEFT_ANGLE);
tree(level - 1, len * LEFT_SIZE);
turn((180.0 - LEFT_ANGLE) - RIGHT_ANGLE);
tree(level - 1, len * RIGHT_SIZE);
turn(RIGHT_ANGLE);
}

forward (len);
forward(len);
}

0 comments on commit 07a58d5

Please sign in to comment.