libsxbp  v0.27
Experimental generation of 2D spiralling lines based on input binary data.
Functions
initialise.h File Reference

This compilation unit provides basic functions to initialise a spiral. More...

#include "saxbospiral.h"
Include dependency graph for initialise.h:

Go to the source code of this file.

Functions

sxbp_direction_t sxbp_change_direction (sxbp_direction_t current, sxbp_rotation_t turn)
 Gets the direction which is clockwise or anti-clockwise to the current direction. More...
 
sxbp_spiral_t sxbp_blank_spiral (void)
 Builds a blank spiral struct. More...
 
sxbp_status_t sxbp_init_spiral (sxbp_buffer_t buffer, sxbp_spiral_t *spiral)
 Builds a partially-complete spiral from binary input data stored in a buffer. More...
 

Detailed Description

This compilation unit provides basic functions to initialise a spiral.

Author
Joshua Saxby <joshua.a.saxby+TNOPLuc8vM==.com
Date
2016, 2017

Function Documentation

sxbp_spiral_t sxbp_blank_spiral ( void  )

Builds a blank spiral struct.

This is a convenience function, as the struct has many fields. This function will create a spiral struct with all of these fields initialised to 0 or their default 'blank' state. No memory is allocated.

Returns
A blank spiral struct with all fields initialised to 0 or blank values.
sxbp_direction_t sxbp_change_direction ( sxbp_direction_t  current,
sxbp_rotation_t  turn 
)

Gets the direction which is clockwise or anti-clockwise to the current direction.

Given a current direction and a rotational direction, return the new direction which would be faced after turning 90 degrees in the given rotational direction.

Parameters
currentThe current direction to turn from.
turnThe rotational direction to turn in.
Returns
The new direction which will be faced after turning.
sxbp_status_t sxbp_init_spiral ( sxbp_buffer_t  buffer,
sxbp_spiral_t *  spiral 
)

Builds a partially-complete spiral from binary input data stored in a buffer.

This converts the 0s and 1s in the buffer data into UP, LEFT, DOWN, RIGHT instructions which are then used to build the pattern. Only the line directions are calculated at this point, all line lengths are 0.

Parameters
bufferA buffer containing at least one byte of data, used to determine the directions of the lines in the spiral it will create.
[out]spiralSpiral object which the line directions will be written to.
Returns
SXBP_OPERATION_OK on success.
SXBP_MALLOC_REFUSED on memory allocation failure.
Note
Asserts:
  • That all the pointer members of parameter spiral are set to NULL