libmypaint  1.6.0
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 
#define G_END_DECLS
Definition: mypaint-glib-compat.h:14
#define G_BEGIN_DECLS
Definition: mypaint-glib-compat.h:13
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
Representation of a rectangle, integer values: (x, y, w, h)
Definition: mypaint-rectangle.h:33
Holds the size and location of a MyPaintRectangle array.
Definition: mypaint-rectangle.h:51
Extends MyPaintSurface with support for spectral ops and multiple bounding boxes.
Definition: mypaint-surface.h:321
MyPaintSurfaceEndAtomicFunction2 end_atomic_multi
See MyPaintSurfaceEndAtomicFunction2.
Definition: mypaint-surface.h:329
MyPaintSurface * mypaint_surface2_to_surface(MyPaintSurface2 *self)
Safely access the parent MyPaintSurface interface.
MyPaintSurfaceDrawDabFunction2 draw_dab_pigment
See MyPaintSurfaceDrawDabFunction2.
Definition: mypaint-surface.h:325
MyPaintSurface parent
Parent interface.
Definition: mypaint-surface.h:323
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
void mypaint_surface2_end_atomic(MyPaintSurface2 *self, MyPaintRectangles *roi)
Call the surface's end_atomic_multi function.
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.
void(* MyPaintSurfaceEndAtomicFunction2)(MyPaintSurface2 *self, MyPaintRectangles *roi)
Like MyPaintSurfaceEndAtomicFunction, but with support for multiple invalidation rectangles.
Definition: mypaint-surface.h:303
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.
MyPaintSurfaceGetColorFunction2 get_color_pigment
See MyPaintSurfaceGetColorFunction2.
Definition: mypaint-surface.h:327
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
Abstract surface type for the MyPaint brush engine.
Definition: mypaint-surface.h:131
float mypaint_surface_get_alpha(MyPaintSurface *self, float x, float y, float radius)
Invoke MyPaintSurface::get_color and return the alpha component.
MyPaintSurfaceGetColorFunction get_color
Function for retrieving color data from the surface.
Definition: mypaint-surface.h:142
void mypaint_surface_unref(MyPaintSurface *self)
Decrease refcount by 1 and call destroy if it reaches 0.
void mypaint_surface_end_atomic(MyPaintSurface *self, MyPaintRectangle *roi)
Invoke MyPaintSurface::begin_atomic.
void mypaint_surface_ref(MyPaintSurface *self)
Increase refcount by 1.
MyPaintSurfaceSavePngFunction save_png
Save a region of the surface to a png file.
Definition: mypaint-surface.h:163
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.
MyPaintSurfaceDestroyFunction destroy
Destroy the surface (free up all allocated resources).
Definition: mypaint-surface.h:158
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(* 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
int refcount
Reference count - number of references to the struct.
Definition: mypaint-surface.h:170
MyPaintSurfaceDrawDabFunction draw_dab
Function for drawing a dab on the surface.
Definition: mypaint-surface.h:136
void mypaint_surface_init(MyPaintSurface *self)
Set refcount to 1.
void(* MyPaintSurfaceEndAtomicFunction)(MyPaintSurface *self, MyPaintRectangle *roi)
Finalize an atomic set of stroke operations, setting an invalidation rectangle.
Definition: mypaint-surface.h:122
MyPaintSurfaceEndAtomicFunction end_atomic
Finalize the operations run after a call to begin_atomic.
Definition: mypaint-surface.h:154
MyPaintSurfaceBeginAtomicFunction begin_atomic
Prepare the surface for a set of atomic stroke/dab operations.
Definition: mypaint-surface.h:148
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
void(* MyPaintSurfaceBeginAtomicFunction)(MyPaintSurface *self)
Prepare the surface for an atomic set of stroke operations.
Definition: mypaint-surface.h:112
void(* MyPaintSurfaceDestroyFunction)(MyPaintSurface *self)
Destructor for surface implementations.
Definition: mypaint-surface.h:91