Description
  This structure inherit from
t_bunny_buffer and represent any picture
that can serve as graphical source. This source can be used in different
fashion: it can be partially used only, can be rotated, can be placed
and its color can be altered without touching the real material.
The
t_bunny_clipable format can be describe by a configuration file.
Attributes
-
t_bunny_buffer buffer:
  Informations about the buffer itself can be found here.
Having this field make t_bunny_clipable compatible with
all functions that use t_bunny_buffer.
-
int32_t clip_x_position:
  The X position of the subpart that will be used as source.
By default, it is 0.
-
int32_t clip_y_position:
  The Y position of the subpart that will be used as source.
By default, it is 0.
-
int32_t clip_width:
  The width of the subpart that will be used as source.
By default, it is buffer.width, the complete width.
-
int32_t clip_height:
  The height of the subpart that will be used as source.
By default, it is buffer.height, the complete height.
-
t_bunny_accurate_position position:
  When the clipable is used as source with bunny_blit or bunny_blit_shader
and that the position parameter is NULL, this attribute
indicates where on the target the subpart will be drawn.
-
t_bunny_accurate_position origin:
  The origin of the clipable and the center of rotation. By default,
it is on top left corner.
-
t_bunny_accurate_position scale:
  The scale of the clipable. By default, it is 1, 1.
-
double rotation:
  The rotation in degree of the clipable. By default, it is 0.
-
t_bunny_color color_mask:
  A AND mask used on every color when the clipable is being used
as source. By default, it is fully opaque white.
Configuration file format
You can set properties of a t_bunny_clipable thanks to a file at runtime.
This allow you to get rid of a lot of configuration and to create space for
any outside editor.
INI format and complete field description
Mandatory field
-
RessourceFile is a single string that contains the address of a picture.
Usage:
RessourceFile="Picture file that will be loaded"
Optionnal fields
-
Position is the position of the clipable when blitted.
It must be two int or double long.
Usage:
Position=XPosition,YPosition
-
Scale is a zoom. It can be a single float or two.
If there is a single float, then it scales on X and Y.
If there is two floats, theen it scales accordingly on X and Y.
Usage:
Scale=XandYScale
Scale=XScale,YScale
-
Origin move the spot used to place the clipable, turn or scale it.
It is two int or double long.
Usage:
Origin=XPosition,YPosition
-
Rotation is a float that represent the rotation in degree of the clipable.
It turns as in trigonometry.
Usage:
Rotation=Degree
-
ColorMask is a collection of integer between 0 and 255 used as color mask.
It can be one field long to create a grey mask.
It can be three fields long to create a RGB mask with no transparency.
It can be four fields long to create a RGBA mask.
About transparency, 0 is transparent.
Usage:
ColorMask=GreyLevel
ColorMask=Red,Green,Blue
ColorMask=Red,Green,Blue,Alpha
-
Transparency is a single integer between 0 and 255 used as color mask.
It is redundant with the Color field and will override it.
About transparency, 0 is transparent.
Usage:
Transparency=TransparencyLevel
-
Clip.Position is the position of a clip inside the clipable.
It is two positive integer long.
Usage:
[Clip]
Position=XPosition,YPosition
-
Clip.Size is the size of the clip inside the clipable.
It is two positive integer long.
Usage:
[Clip]
Size=Width,Height
-
Clip.Selected is the number of the current clip. This field needs
the Clip.Size field to be set. It is a positive integer.
This field is redundant with the Clip.Position field and will override it.
Usage:
[Clip]
Size=Width,Height
Selected=NbrCase
DABSIC format
The Dabsic format follow the same architecture as the INI one.
Here is a complete usage:
RessourceFile="PathToRessourceFile"
Position=XPosition,YPosition
Scale=XScale,YScale
Scale=XYScale
Origin=XPosition,YPosition
Rotation=Degree
ColorMask=GreyLevel
ColorMask=Red,Green,Blue
ColorMask=Red,Green,Blue,Alpha
Transparency=TransparencyLevel
[Clip
  Size=Width,Height
  Position=XPosition,YPosition
  Selected=NbrCase
]
Note that the ability of Dabsic to create array with the following fashion:
ColorMask = [Array
  Red
  Green
  Blue
]
Does not interfere with the way the value is get. It is perfectly equivalent.
CSV format
The CSV format does not follow the same architecture as the INI one.
Here is its architecture:
"RessourceFile";"path_to_ressource_file"
"Position";xposition;ypostition
"Scale";xscale;yscale
"Scale";xscale
"Origin";xposition;yposition
"Rotation";degree
"ColorMask";greylevel
"ColorMask";red;green;blue
"ColorMask";red;green;blue;alpha
"Transparency";transparency
"Clip"
;"Size";width;height
;"Position";xposition;yposition
;"Selected";nbrcase
Note that fields inside clip does not start on the first column!
XML format
Not documented yet.
LUA format
Not documented yet.
JSON format
Not documented yet.
YAML format
Not documented yet.
LISP format
Not documented yet.
INDEX
Description
  Copy all clipable fields (except buffer) from ori to dest.
INDEX
Attributes
-
t_bunny_clipable clipable:
  The mother structure.
-
void * const pixels:
  The picture pixels themselves. They are width multiplied by height
multiplied by color size long.
INDEX
Parameters
-
unsigned int width:
  The width of the picture in pixels.
-
unsigned int height:
  The height of the picture in pixels.
Error values and logs
On error, $Vbunny_errno is set to:
Logs written by this function are tagged with the "ressource" and
"graphics" label.
INDEX
Error values and logs
On error, $Vbunny_errno is set to:
Logs written by this function are tagged with the "graphics" or
"ressource" or "syntax" label.
INDEX
Parameters
-
const void *buffer:
  The memory space containing the picture file.
-
size_t length:
  The size of buffer in bytes.
-
const char *from_file:
  The file from which buffer is extracted. NULL is acceptable,
but it will prevent the ressource manager to index this picture.
Error values and logs
On error, $Vbunny_errno is set to:
Logs written by this function are tagged with the "graphics" or
"ressource" label.
INDEX
Parameters
-
const void *buffer:
  The memory space containing the picture file.
-
size_t length:
  The size of buffer in bytes.
Error values and logs
On error, $Vbunny_errno is set to:
Logs written by this function are tagged with the "graphics" or
"ressource" label.
INDEX
Description
  This function pointer is currently unused. Its purpose is to support
original picture file format.
INDEX
Description
  This function pointer is currently unused. Its purpose is to support
original picture file format.
INDEX
Description
  This function pointer is currently unused. Its purpose is to support
original picture file format.
INDEX
Description
  This function pointer is currently unused. Its purpose is to support
original picture file format.
INDEX
Description
  Save the sent pixelarray into a file.
Parameters
-
const t_bunny_pixelarray *pixelarray:
  The pixelarray to save.
-
const char *file:br />
  The file in which you will save. Supported formats are .png and .jpg.
Return value
-
On success, the function returns true.
-
On failure, it returns false.
Logs
Logs written by this function are tagged with the "graphics" or
"ressource" label.
INDEX
Parameters
-
unsigned int width:
  The width of the picture in pixels.
-
unsigned int height:
  The height of the picture in pixels.
Error values and logs
On error, $Vbunny_errno is set to:
Logs written by this function are tagged with the "ressource" and
"graphics" label.
INDEX
Error values and logs
On error, $Vbunny_errno is set to:
Logs written by this function are tagged with the "graphics" or
"ressource" or "syntax" label.
INDEX
Parameters
-
const void *buffer:
  The memory space containing the picture file.
-
size_t length:
  The size of buffer in bytes.
-
const char *from_file:
  The file from which buffer is extracted. NULL is acceptable,
but it will prevent the ressource manager to index this picture.
Error values and logs
On error, $Vbunny_errno is set to:
Logs written by this function are tagged with the "graphics" or
"ressource" label.
INDEX
k
Parameters
-
const void *buffer:
  The memory space containing the picture file.
-
size_t length:
  The size of buffer in bytes.
Error values and logs
On error, $Vbunny_errno is set to:
Logs written by this function are tagged with the "graphics" or
"ressource" label.
INDEX
Description
  Delete the sent clipable.
INDEX
Description
  This function compute every drawing made before on the sent
clipable.
This is specificaly important for
t_bunny_font: this operation is the one
that effectively draw text inside it.
INDEX
Parameters
-
t_bunny_buffer *target:
  The surface on which drawing will be done.
-
t_bunny_position position:
  The position on the surface for the drawing, this is the center of the
circle.
-
t_bunny_size radius:
  The size of the circle.
-
unsigned int inside_color:
  The color of the disk. Can be transparent.
-
unsigned int lining_color:
  The color of the disk lining. Can be transparent.
-
int lining_thickness:
  The thickness of the lining in pixels.
INDEX
Parameters
-
t_bunny_buffer *target:
  The surface on which drawing will be done.
-
unsigned int color:
  The color that will be applied. Alpha channel is included
in the color computation.
INDEX
Parameters
-
t_bunny_buffer *target:
  The surface on which drawing will be done.
-
unsigned int color:
  The color that will be applied. Alpha channel is not included
in the color computation.
INDEX
typedef enum e_bunny_geometry
{
 
BGY_PIXELS,
 
BGY_LINES,
 
BGY_LINE_STRIP,
 
BGY_TRIANGLES,
 
BGY_TRIANGLE_STRIP,
 
BGY_TRIANGLE_FAN,
 
BGY_QUADS,
 
LAST_GEOMETRY,
}
t_bunny_geometry;
Symbols
-
BGY_PIXELS:
  Indicates the vertex array contains pixels.
-
BGY_LINES:
  Indicates the vertex array contains couple of coordinates forming several lines.
-
BGY_LINE_STRIP:
  Indicates the vertex array contains several coordinates forming a single
broken lines.
-
BGY_TRIANGLES:
  Indicates the vertex array contains trio of coordinates forming several triangles.
-
BGY_TRIANGLE_STRIP:
  Indicates the vertex array contains at least three coordinates and then, each
additionnal coordinate use the two previous ones to add a new triangle.
-
BGY_TRIANGLE_FAN:
  Indicates the vertex array contains at least three coordinates. The first
coordinate is shared by every triangles formed by following ones.
-
BGY_QUADS:
  Indicates the vertex array contains quartets of coordinates forming quads.
Coordinates of a single quad must be fully clockwise or anti clockwise.
INDEX
k
Description
  Coordinates for the vertex on screen and for the associated texture or color.
INDEX
Description
  In the bunny library, some bottom level ressources are shared. This means
that when you load several times the same picture, the picture
itself is only loaded once and then it is given to multiples holders.
Sometimes, you only base your work on a picture but plan to edit
it to create a new one... And editing it would edit all sounds played
by all other holders, so before doing it, you will need to call
bunny_make_picture_unique so your picture got duplicated and pulled
out the ressource manager.
In
t_bunny_clipable, shared parts are the private side. In
t_bunny_pixelarray,
they include the
pixels array itself and all
t_bunny_clipable shared parts.
Return value
Return true if everything went well. false if instead it went wrong.
Error values and logs
On error, $Vbunny_errno is set to:
Logs written by this function or subfunctions may be tagged with
"sound"
labels.
INDEX