Set up a system for brushes.

This commit is contained in:
Pietro Gagliardi 2015-10-07 10:10:03 -04:00
parent ed340dc017
commit 4d39f77dbc
1 changed files with 43 additions and 3 deletions

View File

@ -36,15 +36,26 @@ struct uiAreaDrawParams {
intmax_t VScrollPos;
};
// TODO proper sources
// TODO dotting/dashing
typedef struct uiDrawPath uiDrawPath;
typedef struct uiDrawBrush uiDrawBrush;
typedef struct uiDrawStrokeParams uiDrawStrokeParams;
typedef enum uiDrawBrushType uiDrawBrushType;
typedef struct uiDrawBrushGradientStop uiDrawBrushGradientStop;
typedef enum uiDrawLineCap uiDrawLineCap;
typedef enum uiDrawLineJoin uiDrawLineJoin;
typedef enum uiDrawFillMode uiDrawFillMode;
enum uiDrawBrushType {
uiDrawBrushTypeSolid,
/*TODO uiDrawBrushTypeLinearGradient,
uiDrawBrushTypeRadialGradient,
uiDrawBrushTypeImage,
*/};
enum uiDrawLineCap {
uiDrawLineCapFlat,
uiDrawLineCapRound,
@ -67,6 +78,35 @@ enum uiDrawFillMode {
uiDrawFillModeAlternate,
};
struct uiDrawBrush {
uiDrawBrushType Type;
// solid brushes
double R;
double G;
double B;
double A;
// gradient brushes
double X0; // linear: start X, radial: start X
double Y0; // linear: start Y, radial: start Y
double X1; // linear: end X, radial: outer circle center X
double Y1; // linear: end Y, radial: outer circle center Y
double OuterRadius; // radial gradients only
uiDrawBrushGradientStop *Stops;
size_t NumStops;
// TODO images
};
struct uiDrawBrushGradientStop {
double Pos;
double R;
double G;
double B;
double A;
};
struct uiDrawStrokeParams {
uiDrawLineCap Cap;
uiDrawLineJoin Join;
@ -91,8 +131,8 @@ void uiDrawPathAddRectangle(uiDrawPath *, double, double, double, double);
void uiDrawPathEnd(uiDrawPath *);
void uiDrawStroke(uiDrawContext *, uiDrawPath *, uiDrawStrokeParams *);
void uiDrawFill(uiDrawContext *, uiDrawPath *);
void uiDrawStroke(uiDrawContext *, uiDrawPath *, uiDrawBrush *, uiDrawStrokeParams *);
void uiDrawFill(uiDrawContext *, uiDrawPath *, uiDrawBrush *);
// TODO primitives:
// - rounded rectangles