Loading...
Searching...
No Matches
MyPaintSurface Struct Reference

Abstract surface type for the MyPaint brush engine. More...

`#include <mypaint-surface.h>`

## Public Types

typedef int(* | MyPaintSurfaceDrawDabFunction) (MyPaintSurface *self, float x, float y, float radius, float color_r, float color_g, float color_b, float opaque, float hardness, float alpha_eraser, float aspect_ratio, float angle, float lock_alpha, float colorize)
| Function used to draw a dab with the given properties on the surface.
typedef void(* | MyPaintSurfaceDestroyFunction) (MyPaintSurface *self)
| Destructor for surface implementations.
typedef void(* | MyPaintSurfaceSavePngFunction) (MyPaintSurface *self, const char *path, int x, int y, int width, int height)
| Function for rendering a png file from a surface.
typedef void(* | MyPaintSurfaceBeginAtomicFunction) (MyPaintSurface *self)
| Prepare the surface for an atomic set of stroke operations.
typedef void(* | MyPaintSurfaceEndAtomicFunction) (MyPaintSurface *self, MyPaintRectangle *roi)
| Finalize an atomic set of stroke operations, setting an invalidation rectangle.

## Public Member Functions

int | mypaint_surface_draw_dab (MyPaintSurface *self, float x, float y, float radius, float color_r, float color_g, float color_b, float opaque, float hardness, float alpha_eraser, float aspect_ratio, float angle, float lock_alpha, float colorize)
| Invoke MyPaintSurface::draw_dab.
void | mypaint_surface_get_color (MyPaintSurface *self, float x, float y, float radius, float *color_r, float *color_g, float *color_b, float *color_a)
| Invoke MyPaintSurface::get_color.
float | mypaint_surface_get_alpha (MyPaintSurface *self, float x, float y, float radius)
| Invoke MyPaintSurface::get_color and return the alpha component.
void | mypaint_surface_save_png (MyPaintSurface *self, const char *path, int x, int y, int width, int height)
| Invoke MyPaintSurface::save_png.
void | mypaint_surface_begin_atomic (MyPaintSurface *self)
| Invoke MyPaintSurface::begin_atomic.
void | mypaint_surface_end_atomic (MyPaintSurface *self, MyPaintRectangle *roi)
| Invoke MyPaintSurface::begin_atomic.
void | mypaint_surface_init (MyPaintSurface *self)
| Set refcount to 1.
void | mypaint_surface_ref (MyPaintSurface *self)
| Increase refcount by 1.
void | mypaint_surface_unref (MyPaintSurface *self)
| Decrease refcount by 1 and call destroy if it reaches 0.

## Data Fields

MyPaintSurfaceDrawDabFunction | draw_dab
| Function for drawing a dab on the surface.
MyPaintSurfaceGetColorFunction | get_color
| Function for retrieving color data from the surface.
MyPaintSurfaceBeginAtomicFunction | begin_atomic
| Prepare the surface for a set of atomic stroke/dab operations.
MyPaintSurfaceEndAtomicFunction | end_atomic
| Finalize the operations run after a call to begin_atomic.
MyPaintSurfaceDestroyFunction | destroy
| Destroy the surface (free up all allocated resources).
MyPaintSurfaceSavePngFunction | save_png
| Save a region of the surface to a png file.
int | refcount
| Reference count - number of references to the struct.

## Detailed Description

Abstract surface type for the MyPaint brush engine.

The surface interface lets the brush engine specify dabs to render, and get color data for use in interpolations.

See also
  MyPaintSurface2

## Member Typedef Documentation

## MyPaintSurfaceBeginAtomicFunction

typedef void(* MyPaintSurfaceBeginAtomicFunction) (MyPaintSurface *self)

Prepare the surface for an atomic set of stroke operations.

Each call to functions of this type should be matched by a call to a ::MyPaintSurfaceEndAtomicFunction with the same surface.

## MyPaintSurfaceDestroyFunction

typedef void(* MyPaintSurfaceDestroyFunction) (MyPaintSurface *self)

Destructor for surface implementations.

Parameters

  self | The surface to free/destroy

## MyPaintSurfaceDrawDabFunction

typedef int(* MyPaintSurfaceDrawDabFunction) (MyPaintSurface *self, float x, float y, float radius, float color_r, float color_g, float color_b, float opaque, float hardness, float alpha_eraser, float aspect_ratio, float angle, float lock_alpha, float colorize)

Function used to draw a dab with the given properties on the surface.

The function drawing the dab is one of the core parts of any surface implementation. These functions will usually not be invoked directly by library users, but indirectly as part of the ::mypaint_brush_stroke_to call, where the interpolated parameters for each dab are calculated.

Parameters

  self | The surface on which the dab will be drawn
  x,y | The center of the dab
  radius | The radius of the dab
  color_r,color_g,color_b,opaque | color/opacity of the dab
  hardness | Determines how opacity is retained for pixels further from the dab center.
  alpha_eraser | Hell if I know
  aspect_ratio | The width/height ratio of the dab.
  angle | The angle of the dab (applied after aspect_ratio).
  lock_alpha | The extent to which the alpha values of affected pixels on the surface are retained, regardless of other dab parameters.
  colorize | The extent to which the dab will only affect the hue of existing pixels on the surface.

## MyPaintSurfaceEndAtomicFunction

typedef void(* MyPaintSurfaceEndAtomicFunction) (MyPaintSurface *self, MyPaintRectangle *roi)

Finalize an atomic set of stroke operations, setting an invalidation rectangle.

Each call to functions of this type should be matched by a call to a ::MyPaintSurfaceBeginAtomicFunction with the same surface.

## MyPaintSurfaceSavePngFunction

typedef void(* MyPaintSurfaceSavePngFunction) (MyPaintSurface *self, const char *path, int x, int y, int width, int height)

Function for rendering a png file from a surface.

Parameters

  self | The surface to render from
  path | The destination of the png file
  x,y | The top left corner of the area to export
  width,height | The dimensions of the area & of the resulting png

## Member Function Documentation

## mypaint_surface_begin_atomic()

void mypaint_surface_begin_atomic | ( | MyPaintSurface * | self | ) |

Invoke MyPaintSurface::begin_atomic.

See also
  MyPaintSurfaceBeginAtomicFunction

## mypaint_surface_draw_dab()

int mypaint_surface_draw_dab | ( | MyPaintSurface * | self,
|  | float | x,
|  | float | y,
|  | float | radius,
|  | float | color_r,
|  | float | color_g,
|  | float | color_b,
|  | float | opaque,
|  | float | hardness,
|  | float | alpha_eraser,
|  | float | aspect_ratio,
|  | float | angle,
|  | float | lock_alpha,
|  | float | colorize )

Invoke MyPaintSurface::draw_dab.

See also
  MyPaintSurfaceDrawDabFunction

## mypaint_surface_end_atomic()

void mypaint_surface_end_atomic | ( | MyPaintSurface * | self,
|  | MyPaintRectangle * | roi )

Invoke MyPaintSurface::begin_atomic.

See also
  MyPaintSurfaceBeginAtomicFunction

## mypaint_surface_get_alpha()

float mypaint_surface_get_alpha | ( | MyPaintSurface * | self,
|  | float | x,
|  | float | y,
|  | float | radius )

Invoke MyPaintSurface::get_color and return the alpha component.

See also
  MyPaintSurfaceGetColorFunction

## mypaint_surface_get_color()

void mypaint_surface_get_color | ( | MyPaintSurface * | self,
|  | float | x,
|  | float | y,
|  | float | radius,
|  | float * | color_r,
|  | float * | color_g,
|  | float * | color_b,
|  | float * | color_a )

Invoke MyPaintSurface::get_color.

See also
  MyPaintSurfaceGetColorFunction

## mypaint_surface_init()

void mypaint_surface_init | ( | MyPaintSurface * | self | ) |

Set refcount to 1.

## mypaint_surface_ref()

void mypaint_surface_ref | ( | MyPaintSurface * | self | ) |

Increase refcount by 1.

## mypaint_surface_save_png()

void mypaint_surface_save_png | ( | MyPaintSurface * | self,
|  | const char * | path,
|  | int | x,
|  | int | y,
|  | int | width,
|  | int | height )

Invoke MyPaintSurface::save_png.

See also
  MyPaintSurfaceSavePngFunction

## mypaint_surface_unref()

void mypaint_surface_unref | ( | MyPaintSurface * | self | ) |

Decrease refcount by 1 and call destroy if it reaches 0.

## Field Documentation

## begin_atomic

MyPaintSurfaceBeginAtomicFunction MyPaintSurface::begin_atomic

Prepare the surface for a set of atomic stroke/dab operations.

See ::MyPaintSurfaceBeginAtomicFunction for details.

## destroy

MyPaintSurfaceDestroyFunction MyPaintSurface::destroy

Destroy the surface (free up all allocated resources).

## draw_dab

MyPaintSurfaceDrawDabFunction MyPaintSurface::draw_dab

Function for drawing a dab on the surface.

See ::MyPaintSurfaceDrawDabFunction for details.

## end_atomic

MyPaintSurfaceEndAtomicFunction MyPaintSurface::end_atomic

Finalize the operations run after a call to begin_atomic.

See ::MyPaintSurfaceEndAtomicFunction for details.

## get_color

MyPaintSurfaceGetColorFunction MyPaintSurface::get_color

Function for retrieving color data from the surface.

See MyPaintSurfaceGetColorFunction for details.

## refcount

int MyPaintSurface::refcount

Reference count - number of references to the struct.

This is only useful when used in a context with automatic memory management and can be ignored if construction/destruction is handled manually.

## save_png

MyPaintSurfaceSavePngFunction MyPaintSurface::save_png

Save a region of the surface to a png file.

See MyPaintSurfaceSavePngFunction for details

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

- mypaint-surface.h