Loading...
Searching...
No Matches
MyPaintBrush Struct Reference

Maintains the data and state required to perform brush strokes. More...

`#include <mypaint-brush.h>`

## Public Member Functions

MyPaintBrush * | mypaint_brush_new (void)
| Create a new brush.
MyPaintBrush * | mypaint_brush_new_with_buckets (int num_smudge_buckets)
| Create a new brush with smudge buckets enabled.
void | mypaint_brush_unref (MyPaintBrush *self)
| Decrease the reference count by one, destroying the brush if it reaches 0.
void | mypaint_brush_ref (MyPaintBrush *self)
| Increase the reference count by one.
void | mypaint_brush_reset (MyPaintBrush *self)
| Request a reset if the brush state.
void | mypaint_brush_new_stroke (MyPaintBrush *self)
| Start a new stroke.
int | mypaint_brush_stroke_to (MyPaintBrush *self, MyPaintSurface *surface, float x, float y, float pressure, float xtilt, float ytilt, double dtime)
| Use the brush to draw a stroke segment on a MyPaintSurface.
int | mypaint_brush_stroke_to_2 (MyPaintBrush *self, MyPaintSurface2 *surface, float x, float y, float pressure, float xtilt, float ytilt, double dtime, float viewzoom, float viewrotation, float barrel_rotation)
| Use the brush to draw a stroke segment on a MyPaintSurface2.
int | mypaint_brush_stroke_to_2_linearsRGB (MyPaintBrush *self, MyPaintSurface2 *surface, float x, float y, float pressure, float xtilt, float ytilt, double dtime, float viewzoom, float viewrotation, float barrel_rotation)
| Same as mypaint_brush_stroke_to_2, but using linear sRGB for color dynamics.
void | mypaint_brush_set_base_value (MyPaintBrush *self, MyPaintBrushSetting id, float value)
| Set the base value of a brush setting.
float | mypaint_brush_get_base_value (MyPaintBrush *self, MyPaintBrushSetting id)
| Get the base value of a brush setting.
gboolean | mypaint_brush_is_constant (MyPaintBrush *self, MyPaintBrushSetting id)
| Check if there are no dynamics/mappings for a brush setting.
int | mypaint_brush_get_inputs_used_n (MyPaintBrush *self, MyPaintBrushSetting id)
| Get the number of input mappings for a brush setting.
void | mypaint_brush_set_mapping_n (MyPaintBrush *self, MyPaintBrushSetting id, MyPaintBrushInput input, int n)
| Set the number of points in an input mapping for a brush setting.
int | mypaint_brush_get_mapping_n (MyPaintBrush *self, MyPaintBrushSetting id, MyPaintBrushInput input)
| Get the number of points in an input mapping for a brush setting.
void | mypaint_brush_set_mapping_point (MyPaintBrush *self, MyPaintBrushSetting id, MyPaintBrushInput input, int index, float x, float y)
| Set the coordinates of a point in an input mapping for a brush setting.
void | mypaint_brush_get_mapping_point (MyPaintBrush *self, MyPaintBrushSetting id, MyPaintBrushInput input, int index, float *x, float *y)
| Get the coordinates of a point in an input mapping for a brush setting.
float | mypaint_brush_get_state (MyPaintBrush *self, MyPaintBrushState i)
| Get the value of a brush state.
void | mypaint_brush_set_state (MyPaintBrush *self, MyPaintBrushState i, float value)
| Set the value of a brush state.
double | mypaint_brush_get_total_stroke_painting_time (MyPaintBrush *self)
| Get the total time recorded since the last call to mypaint_brush_reset.
void | mypaint_brush_set_print_inputs (MyPaintBrush *self, gboolean enabled)
| Enable/Disable debug printouts.
void | mypaint_brush_from_defaults (MyPaintBrush *self)
| Initialize a brush with default values for all settings.
gboolean | mypaint_brush_from_string (MyPaintBrush *self, const char *string)
| Initialize a brush from a JSON string.

## Detailed Description

Maintains the data and state required to perform brush strokes.

This is the hub and core of the brush engine, holding the settings, mappings and state that is used to calculate the location, and other properties, of the dabs that make up painted strokes.

The brush is an opaque struct using manual reference counting and handles its own destruction based on that. See mypaint_brush_ref and mypaint_brush_unref.

## Member Function Documentation

## mypaint_brush_from_defaults()

void mypaint_brush_from_defaults | ( | MyPaintBrush * | self | ) |

Initialize a brush with default values for all settings.

## mypaint_brush_from_string()

gboolean mypaint_brush_from_string | ( | MyPaintBrush * | self,
|  | const char * | string )

Initialize a brush from a JSON string.

## mypaint_brush_get_base_value()

float mypaint_brush_get_base_value | ( | MyPaintBrush * | self,
|  | MyPaintBrushSetting | id )

Get the base value of a brush setting.

## mypaint_brush_get_inputs_used_n()

int mypaint_brush_get_inputs_used_n | ( | MyPaintBrush * | self,
|  | MyPaintBrushSetting | id )

Get the number of input mappings for a brush setting.

## mypaint_brush_get_mapping_n()

int mypaint_brush_get_mapping_n | ( | MyPaintBrush * | self,
|  | MyPaintBrushSetting | id,
|  | MyPaintBrushInput | input )

Get the number of points in an input mapping for a brush setting.

## mypaint_brush_get_mapping_point()

void mypaint_brush_get_mapping_point | ( | MyPaintBrush * | self,
|  | MyPaintBrushSetting | id,
|  | MyPaintBrushInput | input,
|  | int | index,
|  | float * | x,
|  | float * | y )

Get the coordinates of a point in an input mapping for a brush setting.

## mypaint_brush_get_state()

float mypaint_brush_get_state | ( | MyPaintBrush * | self,
|  | MyPaintBrushState | i )

Get the value of a brush state.

## mypaint_brush_get_total_stroke_painting_time()

double mypaint_brush_get_total_stroke_painting_time | ( | MyPaintBrush * | self | ) |

Get the total time recorded since the last call to mypaint_brush_reset.

## mypaint_brush_is_constant()

gboolean mypaint_brush_is_constant | ( | MyPaintBrush * | self,
|  | MyPaintBrushSetting | id )

Check if there are no dynamics/mappings for a brush setting.

This will return FALSE if any input mappings exist for the setting with the given id, even if all such mappings themselves are constant.

## mypaint_brush_new()

MyPaintBrush * mypaint_brush_new | ( | void |  | ) |

Create a new brush.

## mypaint_brush_new_stroke()

void mypaint_brush_new_stroke | ( | MyPaintBrush * | self | ) |

Start a new stroke.

Reset the stroke time parameters. Not directly related to mypaint_stroke_to (and varieties), calling the former does not require calling mypaint_brush_new_stroke.

## mypaint_brush_new_with_buckets()

MyPaintBrush * mypaint_brush_new_with_buckets | ( | int | num_smudge_buckets | ) |

Create a new brush with smudge buckets enabled.

This kind of brush is required to make use of the MYPAINT_BRUSH_SETTING_SMUDGE_BUCKET setting.

Smudge buckets are an array of smudge data states, used to allow dabs in offset locations to use smudge data consistent with their location, when those location-sequential dabs are not actually drawn consecutively.

## mypaint_brush_ref()

void mypaint_brush_ref | ( | MyPaintBrush * | self | ) |

Increase the reference count by one.

Not safe to call with NULL!

## mypaint_brush_reset()

void mypaint_brush_reset | ( | MyPaintBrush * | self | ) |

Request a reset if the brush state.

The request is not acted on immediately, but only in subsequent calls to mypaint_brush_stroke_to and/or mypaint_brush_stroke_to2.

Only state values (including smudge buckets, if used) are affected upon reset, not settings/mappings.

## mypaint_brush_set_base_value()

void mypaint_brush_set_base_value | ( | MyPaintBrush * | self,
|  | MyPaintBrushSetting | id,
|  | float | value )

Set the base value of a brush setting.

## mypaint_brush_set_mapping_n()

void mypaint_brush_set_mapping_n | ( | MyPaintBrush * | self,
|  | MyPaintBrushSetting | id,
|  | MyPaintBrushInput | input,
|  | int | n )

Set the number of points in an input mapping for a brush setting.

## mypaint_brush_set_mapping_point()

void mypaint_brush_set_mapping_point | ( | MyPaintBrush * | self,
|  | MyPaintBrushSetting | id,
|  | MyPaintBrushInput | input,
|  | int | index,
|  | float | x,
|  | float | y )

Set the coordinates of a point in an input mapping for a brush setting.

## mypaint_brush_set_print_inputs()

void mypaint_brush_set_print_inputs | ( | MyPaintBrush * | self,
|  | gboolean | enabled )

Enable/Disable debug printouts.

## mypaint_brush_set_state()

void mypaint_brush_set_state | ( | MyPaintBrush * | self,
|  | MyPaintBrushState | i,
|  | float | value )

Set the value of a brush state.

## mypaint_brush_stroke_to()

int mypaint_brush_stroke_to | ( | MyPaintBrush * | self,
|  | MyPaintSurface * | surface,
|  | float | x,
|  | float | y,
|  | float | pressure,
|  | float | xtilt,
|  | float | ytilt,
|  | double | dtime )

Use the brush to draw a stroke segment on a MyPaintSurface.

## mypaint_brush_stroke_to_2()

int mypaint_brush_stroke_to_2 | ( | MyPaintBrush * | self,
|  | MyPaintSurface2 * | surface,
|  | float | x,
|  | float | y,
|  | float | pressure,
|  | float | xtilt,
|  | float | ytilt,
|  | double | dtime,
|  | float | viewzoom,
|  | float | viewrotation,
|  | float | barrel_rotation )

Use the brush to draw a stroke segment on a MyPaintSurface2.

## mypaint_brush_stroke_to_2_linearsRGB()

int mypaint_brush_stroke_to_2_linearsRGB | ( | MyPaintBrush * | self,
|  | MyPaintSurface2 * | surface,
|  | float | x,
|  | float | y,
|  | float | pressure,
|  | float | xtilt,
|  | float | ytilt,
|  | double | dtime,
|  | float | viewzoom,
|  | float | viewrotation,
|  | float | barrel_rotation )

Same as mypaint_brush_stroke_to_2, but using linear sRGB for color dynamics.

The settings that are handled differently from the other call are:

- MYPAINT_BRUSH_SETTING_CHANGE_COLOR_H
- MYPAINT_BRUSH_SETTING_CHANGE_COLOR_L
- MYPAINT_BRUSH_SETTING_CHANGE_COLOR_HSL_S
- MYPAINT_BRUSH_SETTING_CHANGE_COLOR_V
- MYPAINT_BRUSH_SETTING_CHANGE_COLOR_HSV_S

## mypaint_brush_unref()

void mypaint_brush_unref | ( | MyPaintBrush * | self | ) |

Decrease the reference count by one, destroying the brush if it reaches 0.

Not safe to call with NULL!

The documentation for this struct was generated from the following file:

- mypaint-brush.h