libmypaint  1.6.0
Public Types | Public Member Functions | Data Fields
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. More...
 
typedef void(* MyPaintSurfaceDestroyFunction) (MyPaintSurface *self)
 Destructor for surface implementations. More...
 
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. More...
 
typedef void(* MyPaintSurfaceBeginAtomicFunction) (MyPaintSurface *self)
 Prepare the surface for an atomic set of stroke operations. More...
 
typedef void(* MyPaintSurfaceEndAtomicFunction) (MyPaintSurface *self, MyPaintRectangle *roi)
 Finalize an atomic set of stroke operations, setting an invalidation rectangle. More...
 

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. More...
 
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. More...
 
float mypaint_surface_get_alpha (MyPaintSurface *self, float x, float y, float radius)
 Invoke MyPaintSurface::get_color and return the alpha component. More...
 
void mypaint_surface_save_png (MyPaintSurface *self, const char *path, int x, int y, int width, int height)
 Invoke MyPaintSurface::save_png. More...
 
void mypaint_surface_begin_atomic (MyPaintSurface *self)
 Invoke MyPaintSurface::begin_atomic. More...
 
void mypaint_surface_end_atomic (MyPaintSurface *self, MyPaintRectangle *roi)
 Invoke MyPaintSurface::begin_atomic. More...
 
void mypaint_surface_init (MyPaintSurface *self)
 Set refcount to 1. More...
 
void mypaint_surface_ref (MyPaintSurface *self)
 Increase refcount by 1. More...
 
void mypaint_surface_unref (MyPaintSurface *self)
 Decrease refcount by 1 and call destroy if it reaches 0. More...
 

Data Fields

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

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
selfThe 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
selfThe surface on which the dab will be drawn
x,yThe center of the dab
radiusThe radius of the dab
color_r,color_g,color_b,opaquecolor/opacity of the dab
hardnessDetermines how opacity is retained for pixels further from the dab center.
alpha_eraserHell if I know
aspect_ratioThe width/height ratio of the dab.
angleThe angle of the dab (applied after aspect_ratio).
lock_alphaThe extent to which the alpha values of affected pixels on the surface are retained, regardless of other dab parameters.
colorizeThe 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
selfThe surface to render from
pathThe destination of the png file
x,yThe top left corner of the area to export
width,heightThe dimensions of the area & of the resulting png

Member Function Documentation

◆ mypaint_surface_begin_atomic()

void mypaint_surface_begin_atomic ( MyPaintSurface self)

◆ 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 
)

◆ mypaint_surface_end_atomic()

void mypaint_surface_end_atomic ( MyPaintSurface self,
MyPaintRectangle roi 
)

◆ 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 
)

◆ 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 
)

◆ 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: