libmypaint  1.6.1
/builddir/build/BUILD/libmypaint-1.6.1/mypaint-surface.h
Go to the documentation of this file.
1 #ifndef MYPAINTSURFACE_H
2 #define MYPAINTSURFACE_H
3 
4 /* libmypaint - The MyPaint Brush Library
5  * Copyright (C) 2008 Martin Renold <martinxyz@gmx.ch>
6  * Copyright (C) 2012 Jon Nordby <jononor@gmail.com>
7  *
8  * Permission to use, copy, modify, and/or distribute this software for any
9  * purpose with or without fee is hereby granted, provided that the above
10  * copyright notice and this permission notice appear in all copies.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19  */
20 
21 #include "mypaint-config.h"
22 #include "mypaint-rectangle.h"
23 
25 
26 typedef struct MyPaintSurface MyPaintSurface;
27 
43  MyPaintSurface *self,
44  float x, float y,
45  float radius,
46  float * color_r, float * color_g, float * color_b, float * color_a
47  );
48 
74  MyPaintSurface *self,
75  float x, float y,
76  float radius,
77  float color_r, float color_g, float color_b,
78  float opaque, float hardness,
79  float alpha_eraser,
80  float aspect_ratio, float angle,
81  float lock_alpha,
82  float colorize
83  );
84 
92 
102 typedef void (*MyPaintSurfaceSavePngFunction) (MyPaintSurface *self, const char *path, int x, int y, int width, int height);
103 
113 
123 
170  int refcount;
171 };
172 
180  MyPaintSurface* self, float x, float y, float radius, float color_r, float color_g, float color_b, float opaque,
181  float hardness, float alpha_eraser, float aspect_ratio, float angle, float lock_alpha, float colorize);
182 
190  MyPaintSurface* self, float x, float y, float radius, float* color_r, float* color_g, float* color_b,
191  float* color_a);
192 
199 float mypaint_surface_get_alpha(MyPaintSurface* self, float x, float y, float radius);
200 
207 void
208 mypaint_surface_save_png(MyPaintSurface *self, const char *path, int x, int y, int width, int height);
209 
210 
218 
226 
233 
241 
248 
249 
250 /* Extended interface */
251 
252 typedef struct MyPaintSurface2 MyPaintSurface2;
253 
265  MyPaintSurface2 *self,
266  float x, float y,
267  float radius,
268  float color_r, float color_g, float color_b,
269  float opaque, float hardness,
270  float alpha_eraser,
271  float aspect_ratio, float angle,
272  float lock_alpha,
273  float colorize,
274  float posterize,
275  float posterize_num,
276  float paint);
277 
278 
290  MyPaintSurface2 *self,
291  float x, float y,
292  float radius,
293  float * color_r, float * color_g, float * color_b, float * color_a,
294  float paint
295  );
296 
304 
330 };
331 
338 
347  MyPaintSurface2* self, float x, float y, float radius,float* color_r, float* color_g, float* color_b,
348  float* color_a, float paint);
349 
358 
367  MyPaintSurface2* self, float x, float y, float radius, float color_r, float color_g, float color_b, float opaque,
368  float hardness, float alpha_eraser, float aspect_ratio, float angle, float lock_alpha, float colorize,
369  float posterize, float posterize_num, float paint);
370 
372 
373 #endif // MYPAINTSURFACE_H
374 
MyPaintSurface::MyPaintSurfaceSavePngFunction
void(* MyPaintSurfaceSavePngFunction)(MyPaintSurface *self, const char *path, int x, int y, int width, int height)
Function for rendering a png file from a surface.
Definition: mypaint-surface.h:102
MyPaintSurface2::MyPaintSurfaceGetColorFunction2
void(* MyPaintSurfaceGetColorFunction2)(MyPaintSurface2 *self, float x, float y, float radius, float *color_r, float *color_g, float *color_b, float *color_a, float paint)
Like MyPaintSurfaceGetColorFunction, but for spectral colors.
Definition: mypaint-surface.h:289
MyPaintSurface::mypaint_surface_unref
void mypaint_surface_unref(MyPaintSurface *self)
Decrease refcount by 1 and call destroy if it reaches 0.
MyPaintSurface::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.
MyPaintSurface::begin_atomic
MyPaintSurfaceBeginAtomicFunction begin_atomic
Prepare the surface for a set of atomic stroke/dab operations.
Definition: mypaint-surface.h:148
mypaint-config.h
MyPaintSurface
Abstract surface type for the MyPaint brush engine.
Definition: mypaint-surface.h:131
MyPaintSurface2::MyPaintSurfaceDrawDabFunction2
int(* MyPaintSurfaceDrawDabFunction2)(MyPaintSurface2 *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, float posterize, float posterize_num, float paint)
Like MyPaintSurfaceDrawDabFunction, but supporting posterization and spectral mixing.
Definition: mypaint-surface.h:264
MyPaintRectangle
Representation of a rectangle, integer values: (x, y, w, h)
Definition: mypaint-rectangle.h:33
MyPaintSurface::end_atomic
MyPaintSurfaceEndAtomicFunction end_atomic
Finalize the operations run after a call to begin_atomic.
Definition: mypaint-surface.h:154
MyPaintSurface::mypaint_surface_ref
void mypaint_surface_ref(MyPaintSurface *self)
Increase refcount by 1.
MyPaintSurface::refcount
int refcount
Reference count - number of references to the struct.
Definition: mypaint-surface.h:170
MyPaintSurface2::end_atomic_multi
MyPaintSurfaceEndAtomicFunction2 end_atomic_multi
See MyPaintSurfaceEndAtomicFunction2.
Definition: mypaint-surface.h:329
MyPaintSurface2::mypaint_surface2_to_surface
MyPaintSurface * mypaint_surface2_to_surface(MyPaintSurface2 *self)
Safely access the parent MyPaintSurface interface.
MyPaintSurface2
Extends MyPaintSurface with support for spectral ops and multiple bounding boxes.
Definition: mypaint-surface.h:321
MyPaintSurface::MyPaintSurfaceBeginAtomicFunction
void(* MyPaintSurfaceBeginAtomicFunction)(MyPaintSurface *self)
Prepare the surface for an atomic set of stroke operations.
Definition: mypaint-surface.h:112
mypaint-rectangle.h
MyPaintSurface::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.
MyPaintSurface::draw_dab
MyPaintSurfaceDrawDabFunction draw_dab
Function for drawing a dab on the surface.
Definition: mypaint-surface.h:136
MyPaintSurface::MyPaintSurfaceEndAtomicFunction
void(* MyPaintSurfaceEndAtomicFunction)(MyPaintSurface *self, MyPaintRectangle *roi)
Finalize an atomic set of stroke operations, setting an invalidation rectangle.
Definition: mypaint-surface.h:122
MyPaintSurface::destroy
MyPaintSurfaceDestroyFunction destroy
Destroy the surface (free up all allocated resources).
Definition: mypaint-surface.h:158
MyPaintSurface2::mypaint_surface2_end_atomic
void mypaint_surface2_end_atomic(MyPaintSurface2 *self, MyPaintRectangles *roi)
Call the surface's end_atomic_multi function.
MyPaintSurface::MyPaintSurfaceDestroyFunction
void(* MyPaintSurfaceDestroyFunction)(MyPaintSurface *self)
Destructor for surface implementations.
Definition: mypaint-surface.h:91
MyPaintSurfaceGetColorFunction
void(* MyPaintSurfaceGetColorFunction)(MyPaintSurface *self, float x, float y, float radius, float *color_r, float *color_g, float *color_b, float *color_a)
Function used to retrieve the average color/alpha from a region of a surface.
Definition: mypaint-surface.h:42
MyPaintSurface::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.
MyPaintSurface::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.
MyPaintSurface2::parent
MyPaintSurface parent
Parent interface.
Definition: mypaint-surface.h:323
MyPaintSurface2::get_color_pigment
MyPaintSurfaceGetColorFunction2 get_color_pigment
See MyPaintSurfaceGetColorFunction2.
Definition: mypaint-surface.h:327
MyPaintRectangles
Holds the size and location of a MyPaintRectangle array.
Definition: mypaint-rectangle.h:51
MyPaintSurface::mypaint_surface_end_atomic
void mypaint_surface_end_atomic(MyPaintSurface *self, MyPaintRectangle *roi)
Invoke MyPaintSurface::begin_atomic.
MyPaintSurface::save_png
MyPaintSurfaceSavePngFunction save_png
Save a region of the surface to a png file.
Definition: mypaint-surface.h:163
G_END_DECLS
#define G_END_DECLS
Definition: mypaint-glib-compat.h:14
MyPaintSurface2::draw_dab_pigment
MyPaintSurfaceDrawDabFunction2 draw_dab_pigment
See MyPaintSurfaceDrawDabFunction2.
Definition: mypaint-surface.h:325
MyPaintSurface2::MyPaintSurfaceEndAtomicFunction2
void(* MyPaintSurfaceEndAtomicFunction2)(MyPaintSurface2 *self, MyPaintRectangles *roi)
Like MyPaintSurfaceEndAtomicFunction, but with support for multiple invalidation rectangles.
Definition: mypaint-surface.h:303
MyPaintSurface::get_color
MyPaintSurfaceGetColorFunction get_color
Function for retrieving color data from the surface.
Definition: mypaint-surface.h:142
MyPaintSurface::MyPaintSurfaceDrawDabFunction
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.
Definition: mypaint-surface.h:73
G_BEGIN_DECLS
#define G_BEGIN_DECLS
Definition: mypaint-glib-compat.h:13
MyPaintSurface::mypaint_surface_init
void mypaint_surface_init(MyPaintSurface *self)
Set refcount to 1.
MyPaintSurface2::mypaint_surface2_draw_dab
int mypaint_surface2_draw_dab(MyPaintSurface2 *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, float posterize, float posterize_num, float paint)
Call the surface's draw_dab_pigment function.
MyPaintSurface::mypaint_surface_begin_atomic
void mypaint_surface_begin_atomic(MyPaintSurface *self)
Invoke MyPaintSurface::begin_atomic.
MyPaintSurface2::mypaint_surface2_get_color
void mypaint_surface2_get_color(MyPaintSurface2 *self, float x, float y, float radius, float *color_r, float *color_g, float *color_b, float *color_a, float paint)
Call the surface's get_color_pigment function.