2009-12-24 03:02:05 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
|
|
|
gb.paint.h
|
|
|
|
|
2018-02-12 02:53:46 +01:00
|
|
|
(c) 2000-2017 Benoît Minisini <g4mba5@gmail.com>
|
2009-12-24 03:02:05 +01:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2011-06-03 02:51:09 +02:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
2011-12-31 03:39:20 +01:00
|
|
|
MA 02110-1301, USA.
|
2009-12-24 03:02:05 +01:00
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __GB_PAINT_H
|
|
|
|
#define __GB_PAINT_H
|
|
|
|
|
|
|
|
#include "gb_common.h"
|
|
|
|
#include "gambas.h"
|
|
|
|
#include "gb.draw.h"
|
|
|
|
|
|
|
|
enum {
|
|
|
|
GB_PAINT_EXTEND_PAD,
|
|
|
|
GB_PAINT_EXTEND_REPEAT,
|
|
|
|
GB_PAINT_EXTEND_REFLECT
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
GB_PAINT_FILL_RULE_WINDING,
|
|
|
|
GB_PAINT_FILL_RULE_EVEN_ODD
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
GB_PAINT_LINE_CAP_BUTT,
|
|
|
|
GB_PAINT_LINE_CAP_ROUND,
|
|
|
|
GB_PAINT_LINE_CAP_SQUARE
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
GB_PAINT_LINE_JOIN_MITER,
|
|
|
|
GB_PAINT_LINE_JOIN_ROUND,
|
|
|
|
GB_PAINT_LINE_JOIN_BEVEL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
GB_PAINT_OPERATOR_CLEAR,
|
|
|
|
GB_PAINT_OPERATOR_SOURCE,
|
|
|
|
GB_PAINT_OPERATOR_OVER,
|
|
|
|
GB_PAINT_OPERATOR_IN,
|
|
|
|
GB_PAINT_OPERATOR_OUT,
|
|
|
|
GB_PAINT_OPERATOR_ATOP,
|
|
|
|
GB_PAINT_OPERATOR_DEST,
|
|
|
|
GB_PAINT_OPERATOR_DEST_OVER,
|
|
|
|
GB_PAINT_OPERATOR_DEST_IN,
|
2009-12-24 16:09:08 +01:00
|
|
|
GB_PAINT_OPERATOR_DEST_OUT,
|
2009-12-24 03:02:05 +01:00
|
|
|
GB_PAINT_OPERATOR_DEST_ATOP,
|
|
|
|
GB_PAINT_OPERATOR_XOR,
|
|
|
|
GB_PAINT_OPERATOR_ADD,
|
|
|
|
GB_PAINT_OPERATOR_SATURATE
|
|
|
|
};
|
|
|
|
|
2014-01-12 02:59:49 +01:00
|
|
|
enum {
|
|
|
|
GB_PAINT_PATH_MOVE,
|
|
|
|
GB_PAINT_PATH_LINE
|
|
|
|
};
|
2012-11-25 02:39:49 +01:00
|
|
|
|
2009-12-24 16:09:08 +01:00
|
|
|
struct GB_PAINT_DESC;
|
|
|
|
|
2012-11-26 07:33:49 +01:00
|
|
|
typedef
|
|
|
|
struct {
|
|
|
|
int x, y, w, h;
|
|
|
|
}
|
|
|
|
GB_RECT;
|
|
|
|
|
2009-12-24 03:02:05 +01:00
|
|
|
typedef
|
|
|
|
struct {
|
2009-12-27 16:51:27 +01:00
|
|
|
float x1, y1, x2, y2;
|
2009-12-24 03:02:05 +01:00
|
|
|
}
|
|
|
|
GB_EXTENTS;
|
|
|
|
|
|
|
|
typedef
|
|
|
|
void *GB_BRUSH;
|
|
|
|
|
|
|
|
typedef
|
|
|
|
void *GB_TRANSFORM;
|
|
|
|
|
|
|
|
typedef
|
|
|
|
struct {
|
|
|
|
GB_BASE ob;
|
|
|
|
GB_EXTENTS ext;
|
|
|
|
}
|
|
|
|
PAINT_EXTENTS;
|
|
|
|
|
|
|
|
typedef
|
|
|
|
struct {
|
|
|
|
GB_BASE ob;
|
2009-12-28 02:19:27 +01:00
|
|
|
GB_TRANSFORM transform;
|
2009-12-24 03:02:05 +01:00
|
|
|
}
|
|
|
|
PAINT_MATRIX;
|
|
|
|
|
|
|
|
typedef
|
|
|
|
struct {
|
|
|
|
GB_BASE ob;
|
2009-12-24 16:09:08 +01:00
|
|
|
struct GB_PAINT_DESC *desc; // drawing driver
|
2009-12-28 02:19:27 +01:00
|
|
|
GB_BRUSH brush; // brush
|
2009-12-24 03:02:05 +01:00
|
|
|
}
|
|
|
|
PAINT_BRUSH;
|
|
|
|
|
|
|
|
typedef
|
|
|
|
struct GB_PAINT {
|
2009-12-24 16:09:08 +01:00
|
|
|
struct GB_PAINT_DESC *desc; // drawing driver
|
|
|
|
struct GB_PAINT *previous; // previous drawing context
|
2009-12-24 03:02:05 +01:00
|
|
|
void *device; // drawing object
|
2015-03-02 19:20:56 +01:00
|
|
|
struct {
|
|
|
|
double x;
|
|
|
|
double y;
|
|
|
|
double width;
|
|
|
|
double height;
|
|
|
|
} area; // drawing area
|
2009-12-28 02:19:27 +01:00
|
|
|
int resolutionX; // device horizontal resolution in DPI
|
|
|
|
int resolutionY; // device vertical resolution in DPI
|
|
|
|
PAINT_BRUSH *brush; // current brush
|
|
|
|
void *extra; // driver-specific state
|
2012-11-25 02:39:49 +01:00
|
|
|
unsigned opened : 1; // if the painting has been opened
|
2013-08-09 22:42:38 +02:00
|
|
|
unsigned other : 1; // if painting are imbricated on that device
|
2014-12-14 23:27:44 +01:00
|
|
|
unsigned has_path : 1; // if there is a current path
|
2012-11-27 19:42:24 +01:00
|
|
|
void *tag; // needed to support the old Draw class
|
2009-12-24 03:02:05 +01:00
|
|
|
}
|
|
|
|
GB_PAINT;
|
|
|
|
|
2014-01-12 02:59:49 +01:00
|
|
|
typedef
|
|
|
|
void (*GB_PAINT_OUTLINE_CB)(int, float, float);
|
|
|
|
|
2009-12-24 03:02:05 +01:00
|
|
|
typedef
|
|
|
|
struct GB_PAINT_DESC {
|
|
|
|
// Size of the GB_PAINT structure extra data
|
|
|
|
int size;
|
|
|
|
// Begins and terminates the drawing
|
|
|
|
int (*Begin)(GB_PAINT *d);
|
|
|
|
void (*End)(GB_PAINT *d);
|
|
|
|
|
|
|
|
void (*Save)(GB_PAINT *d);
|
|
|
|
void (*Restore)(GB_PAINT *d);
|
|
|
|
|
2011-04-12 13:07:22 +02:00
|
|
|
void (*Antialias)(GB_PAINT *d, int set, int *antialias);
|
|
|
|
|
2009-12-28 02:19:27 +01:00
|
|
|
void (*Font)(GB_PAINT *d, int set, GB_FONT *font);
|
2009-12-24 03:02:05 +01:00
|
|
|
|
2012-11-26 07:33:49 +01:00
|
|
|
void (*Background)(GB_PAINT *d, int set, GB_COLOR *color);
|
2012-11-25 02:39:49 +01:00
|
|
|
void (*Invert)(GB_PAINT *d, int set, int *invert);
|
|
|
|
|
2009-12-28 02:19:27 +01:00
|
|
|
void (*Clip)(GB_PAINT *d, int preserve);
|
2009-12-24 03:02:05 +01:00
|
|
|
void (*ResetClip)(GB_PAINT *d);
|
|
|
|
void (*ClipExtents)(GB_PAINT *d, GB_EXTENTS *ext);
|
2012-12-31 04:13:04 +01:00
|
|
|
void (*ClipRect)(GB_PAINT *d, int x, int y, int w, int h);
|
2009-12-24 03:02:05 +01:00
|
|
|
|
2009-12-28 02:19:27 +01:00
|
|
|
void (*Fill)(GB_PAINT *d, int preserve);
|
|
|
|
void (*Stroke)(GB_PAINT *d, int preserve);
|
2009-12-24 03:02:05 +01:00
|
|
|
|
|
|
|
void (*PathExtents)(GB_PAINT *d, GB_EXTENTS *ext);
|
2009-12-28 02:19:27 +01:00
|
|
|
int (*PathContains)(GB_PAINT *d, float x, float y);
|
2014-01-12 02:59:49 +01:00
|
|
|
void (*PathOutline)(GB_PAINT *d, GB_PAINT_OUTLINE_CB cb);
|
2009-12-24 03:02:05 +01:00
|
|
|
|
2009-12-28 02:19:27 +01:00
|
|
|
void (*Dash)(GB_PAINT *d, int set, float **dash, int *count);
|
|
|
|
void (*DashOffset)(GB_PAINT *d, int set, float *offset);
|
2009-12-24 03:02:05 +01:00
|
|
|
|
2009-12-28 02:19:27 +01:00
|
|
|
void (*FillRule)(GB_PAINT *d, int set, int *value);
|
2012-11-25 02:39:49 +01:00
|
|
|
void (*FillStyle)(GB_PAINT *d, int set, int *value);
|
2009-12-28 02:19:27 +01:00
|
|
|
void (*LineCap)(GB_PAINT *d, int set, int *value);
|
|
|
|
void (*LineJoin)(GB_PAINT *d, int set, int *value);
|
|
|
|
void (*LineWidth)(GB_PAINT *d, int set, float *value);
|
|
|
|
void (*MiterLimit)(GB_PAINT *d, int set, float *value);
|
2009-12-24 03:02:05 +01:00
|
|
|
|
2009-12-28 02:19:27 +01:00
|
|
|
void (*Operator)(GB_PAINT *d, int set, int *value);
|
2009-12-24 03:02:05 +01:00
|
|
|
|
|
|
|
void (*NewPath)(GB_PAINT *d);
|
|
|
|
void (*ClosePath)(GB_PAINT *d);
|
|
|
|
|
2012-12-06 01:21:16 +01:00
|
|
|
void (*Arc)(GB_PAINT *d, float xc, float yc, float radius, float angle, float length, bool pie);
|
|
|
|
void (*Ellipse)(GB_PAINT *d, float x, float y, float width, float height, float angle, float length, bool pie);
|
2009-12-27 16:51:27 +01:00
|
|
|
void (*Rectangle)(GB_PAINT *d, float x, float y, float width, float height);
|
|
|
|
void (*GetCurrentPoint)(GB_PAINT *d, float *x, float *y);
|
|
|
|
void (*MoveTo)(GB_PAINT *d, float x, float y);
|
|
|
|
void (*LineTo)(GB_PAINT *d, float x, float y);
|
|
|
|
void (*CurveTo)(GB_PAINT *d, float x1, float y1, float x2, float y2, float x3, float y3);
|
2009-12-24 03:02:05 +01:00
|
|
|
|
2011-02-23 16:49:56 +01:00
|
|
|
void (*Text)(GB_PAINT *d, const char *text, int len, float w, float h, int align, bool draw);
|
2010-01-01 23:19:11 +01:00
|
|
|
void (*TextExtents)(GB_PAINT *d, const char *text, int len, GB_EXTENTS *ext);
|
2012-11-27 19:42:24 +01:00
|
|
|
void (*TextSize)(GB_PAINT *d, const char *text, int len, float *w, float *h);
|
2011-02-23 16:49:56 +01:00
|
|
|
void (*RichText)(GB_PAINT *d, const char *text, int len, float w, float h, int align, bool draw);
|
|
|
|
void (*RichTextExtents)(GB_PAINT *d, const char *text, int len, GB_EXTENTS *ext, float width);
|
2012-11-27 19:42:24 +01:00
|
|
|
void (*RichTextSize)(GB_PAINT *d, const char *text, int len, float width, float *w, float *h);
|
2009-12-24 03:02:05 +01:00
|
|
|
|
2009-12-28 02:19:27 +01:00
|
|
|
void (*Matrix)(GB_PAINT *d, int set, GB_TRANSFORM matrix);
|
2009-12-24 16:09:08 +01:00
|
|
|
|
2009-12-29 02:21:39 +01:00
|
|
|
void (*SetBrush)(GB_PAINT *d, GB_BRUSH brush);
|
2012-11-25 02:39:49 +01:00
|
|
|
void (*BrushOrigin)(GB_PAINT *d, int set, float *x, float *y);
|
2009-12-24 16:09:08 +01:00
|
|
|
|
2012-11-26 07:33:49 +01:00
|
|
|
void (*DrawImage)(GB_PAINT *d, GB_IMAGE image, float x, float y, float w, float h, float opacity, GB_RECT *source);
|
|
|
|
void (*DrawPicture)(GB_PAINT *d, GB_PICTURE picture, float x, float y, float w, float h, GB_RECT *source);
|
|
|
|
void (*GetPictureInfo)(GB_PAINT *d, GB_PICTURE picture, GB_PICTURE_INFO *info);
|
2012-11-27 19:42:24 +01:00
|
|
|
void (*FillRect)(GB_PAINT *d, float x, float y, float width, float height, GB_COLOR color);
|
2010-12-07 02:20:40 +01:00
|
|
|
|
2009-12-24 16:09:08 +01:00
|
|
|
struct {
|
|
|
|
void (*Free)(GB_BRUSH brush);
|
|
|
|
void (*Color)(GB_BRUSH *brush, GB_COLOR color);
|
2009-12-28 02:19:27 +01:00
|
|
|
void (*Image)(GB_BRUSH *brush, GB_IMAGE image);
|
|
|
|
void (*LinearGradient)(GB_BRUSH *brush, float x0, float y0, float x1, float y1, int nstop, double *positions, GB_COLOR *colors, int extend);
|
2009-12-30 00:18:43 +01:00
|
|
|
void (*RadialGradient)(GB_BRUSH *brush, float cx, float cy, float r, float fx, float fy, int nstop, double *positions, GB_COLOR *colors, int extend);
|
2009-12-28 02:19:27 +01:00
|
|
|
void (*Matrix)(GB_BRUSH brush, int set, GB_TRANSFORM matrix);
|
2009-12-24 16:09:08 +01:00
|
|
|
}
|
|
|
|
Brush;
|
2009-12-24 03:02:05 +01:00
|
|
|
}
|
|
|
|
GB_PAINT_DESC;
|
|
|
|
|
2013-08-09 22:42:38 +02:00
|
|
|
typedef
|
|
|
|
struct GB_PAINT_MATRIX_DESC {
|
|
|
|
void (*Create)(GB_TRANSFORM *matrix);
|
|
|
|
void (*Copy)(GB_TRANSFORM *matrix, GB_TRANSFORM copy);
|
|
|
|
void (*Delete)(GB_TRANSFORM *matrix);
|
|
|
|
void (*Init)(GB_TRANSFORM matrix, float xx, float yx, float xy, float yy, float x0, float y0);
|
|
|
|
void (*Translate)(GB_TRANSFORM matrix, float tx, float ty);
|
|
|
|
void (*Scale)(GB_TRANSFORM matrix, float sx, float sy);
|
|
|
|
void (*Rotate)(GB_TRANSFORM matrix, float angle);
|
|
|
|
int (*Invert)(GB_TRANSFORM matrix);
|
|
|
|
void (*Multiply)(GB_TRANSFORM matrix, GB_TRANSFORM matrix2);
|
|
|
|
void (*Map)(GB_TRANSFORM matrix, double *x, double *y);
|
|
|
|
}
|
|
|
|
GB_PAINT_MATRIX_DESC;
|
|
|
|
|
2009-12-24 03:02:05 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|