Loading...
Searching...
No Matches
mypaint-surface.h
Go to the documentation of this file.
#ifndef MYPAINTSURFACE_H
#define MYPAINTSURFACE_H
/* libmypaint - The MyPaint Brush Library
* Copyright (C) 2008 Martin Renold <martinxyz@gmx.ch>
* Copyright (C) 2012 Jon Nordby <jononor@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "mypaint-config.h"
#include "mypaint-rectangle.h"
G_BEGIN_DECLS
typedef struct MyPaintSurface MyPaintSurface;
typedef void (*MyPaintSurfaceGetColorFunction) (
MyPaintSurface *self,
float x, float y,
float radius,
float * color_r, float * color_g, float * color_b, float * color_a
);
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
);
typedef void (*MyPaintSurfaceDestroyFunction) (MyPaintSurface *self);
typedef void (*MyPaintSurfaceSavePngFunction) (MyPaintSurface *self, const char *path, int x, int y, int width, int height);
typedef void (*MyPaintSurfaceBeginAtomicFunction) (MyPaintSurface *self);
typedef void (*MyPaintSurfaceEndAtomicFunction) (MyPaintSurface *self, MyPaintRectangle *roi);
struct MyPaintSurface {
MyPaintSurfaceDrawDabFunction draw_dab;
MyPaintSurfaceGetColorFunction get_color;
MyPaintSurfaceBeginAtomicFunction begin_atomic;
MyPaintSurfaceEndAtomicFunction end_atomic;
MyPaintSurfaceDestroyFunction destroy;
MyPaintSurfaceSavePngFunction save_png;
int refcount;
};
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);
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);
float mypaint_surface_get_alpha(MyPaintSurface* self, float x, float y, float radius);
void
mypaint_surface_save_png(MyPaintSurface *self, const char *path, int x, int y, int width, int height);
void mypaint_surface_begin_atomic(MyPaintSurface *self);
void mypaint_surface_end_atomic(MyPaintSurface *self, MyPaintRectangle *roi);
void mypaint_surface_init(MyPaintSurface *self);
void mypaint_surface_ref(MyPaintSurface *self);
void mypaint_surface_unref(MyPaintSurface *self);
/* Extended interface */
typedef struct MyPaintSurface2 MyPaintSurface2;
typedef 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);
typedef void (*MyPaintSurfaceGetColorFunction2) (
MyPaintSurface2 *self,
float x, float y,
float radius,
float * color_r, float * color_g, float * color_b, float * color_a,
float paint
);
typedef void (*MyPaintSurfaceEndAtomicFunction2) (MyPaintSurface2 *self, MyPaintRectangles *roi);
struct MyPaintSurface2 {
MyPaintSurface parent;
MyPaintSurfaceDrawDabFunction2 draw_dab_pigment;
MyPaintSurfaceGetColorFunction2 get_color_pigment;
MyPaintSurfaceEndAtomicFunction2 end_atomic_multi;
};
MyPaintSurface* mypaint_surface2_to_surface(MyPaintSurface2 *self);
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);
void mypaint_surface2_end_atomic(MyPaintSurface2 *self, MyPaintRectangles *roi);
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);
G_END_DECLS
#endif // MYPAINTSURFACE_H
mypaint-config.h
G_END_DECLS
#define G_END_DECLS
Definition mypaint-glib-compat.h:14
G_BEGIN_DECLS
#define G_BEGIN_DECLS
Definition mypaint-glib-compat.h:13
mypaint-rectangle.h
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
MyPaintRectangle
Representation of a rectangle, integer values: (x, y, w, h).
Definition mypaint-rectangle.h:33
MyPaintRectangles
Holds the size and location of a MyPaintRectangle array.
Definition mypaint-rectangle.h:51
MyPaintSurface2
Extends MyPaintSurface with support for spectral ops and multiple bounding boxes.
Definition mypaint-surface.h:321
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::draw_dab_pigment
MyPaintSurfaceDrawDabFunction2 draw_dab_pigment
See MyPaintSurfaceDrawDabFunction2.
Definition mypaint-surface.h:325
MyPaintSurface2::parent
MyPaintSurface parent
Parent interface.
Definition mypaint-surface.h:323
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
MyPaintSurface2::mypaint_surface2_end_atomic
void mypaint_surface2_end_atomic(MyPaintSurface2 *self, MyPaintRectangles *roi)
Call the surface's end_atomic_multi function.
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.
MyPaintSurface2::MyPaintSurfaceEndAtomicFunction2
void(* MyPaintSurfaceEndAtomicFunction2)(MyPaintSurface2 *self, MyPaintRectangles *roi)
Like MyPaintSurfaceEndAtomicFunction, but with support for multiple invalidation rectangles.
Definition mypaint-surface.h:303
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.
MyPaintSurface2::get_color_pigment
MyPaintSurfaceGetColorFunction2 get_color_pigment
See MyPaintSurfaceGetColorFunction2.
Definition mypaint-surface.h:327
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
Abstract surface type for the MyPaint brush engine.
Definition mypaint-surface.h:131
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::get_color
MyPaintSurfaceGetColorFunction get_color
Function for retrieving color data from the surface.
Definition mypaint-surface.h:142
MyPaintSurface::mypaint_surface_unref
void mypaint_surface_unref(MyPaintSurface *self)
Decrease refcount by 1 and call destroy if it reaches 0.
MyPaintSurface::mypaint_surface_end_atomic
void mypaint_surface_end_atomic(MyPaintSurface *self, MyPaintRectangle *roi)
Invoke MyPaintSurface::begin_atomic.
MyPaintSurface::mypaint_surface_ref
void mypaint_surface_ref(MyPaintSurface *self)
Increase refcount by 1.
MyPaintSurface::save_png
MyPaintSurfaceSavePngFunction save_png
Save a region of the surface to a png file.
Definition mypaint-surface.h:163
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_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::destroy
MyPaintSurfaceDestroyFunction destroy
Destroy the surface (free up all allocated resources).
Definition mypaint-surface.h:158
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.
MyPaintSurface::mypaint_surface_begin_atomic
void mypaint_surface_begin_atomic(MyPaintSurface *self)
Invoke MyPaintSurface::begin_atomic.
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
MyPaintSurface::refcount
int refcount
Reference count - number of references to the struct.
Definition mypaint-surface.h:170
MyPaintSurface::draw_dab
MyPaintSurfaceDrawDabFunction draw_dab
Function for drawing a dab on the surface.
Definition mypaint-surface.h:136
MyPaintSurface::mypaint_surface_init
void mypaint_surface_init(MyPaintSurface *self)
Set refcount to 1.
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::end_atomic
MyPaintSurfaceEndAtomicFunction end_atomic
Finalize the operations run after a call to begin_atomic.
Definition mypaint-surface.h:154
MyPaintSurface::begin_atomic
MyPaintSurfaceBeginAtomicFunction begin_atomic
Prepare the surface for a set of atomic stroke/dab operations.
Definition mypaint-surface.h:148
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
MyPaintSurface::MyPaintSurfaceBeginAtomicFunction
void(* MyPaintSurfaceBeginAtomicFunction)(MyPaintSurface *self)
Prepare the surface for an atomic set of stroke operations.
Definition mypaint-surface.h:112
MyPaintSurface::MyPaintSurfaceDestroyFunction
void(* MyPaintSurfaceDestroyFunction)(MyPaintSurface *self)
Destructor for surface implementations.
Definition mypaint-surface.h:91