More drawing API work.
This commit is contained in:
parent
2dc3dba97b
commit
850f996d27
|
@ -23,6 +23,16 @@ void uiDrawBeginPathRGB(uiDrawContext *c, uint8_t r, uint8_t g, uint8_t b)
|
||||||
cairo_new_path(c->cr);
|
cairo_new_path(c->cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uiDrawBeginPathRGBA(uiDrawContext *c, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
|
||||||
|
{
|
||||||
|
cairo_set_source_rgba(c->cr,
|
||||||
|
((double) r) / 255,
|
||||||
|
((double) g) / 255,
|
||||||
|
((double) b) / 255,
|
||||||
|
((double) a) / 255);
|
||||||
|
cairo_new_path(c->cr);
|
||||||
|
}
|
||||||
|
|
||||||
void uiDrawMoveTo(uiDrawContext *c, intmax_t x, intmax_t y)
|
void uiDrawMoveTo(uiDrawContext *c, intmax_t x, intmax_t y)
|
||||||
{
|
{
|
||||||
cairo_move_to(c->cr, (double) x + 0.5, (double) y + 0.5);
|
cairo_move_to(c->cr, (double) x + 0.5, (double) y + 0.5);
|
||||||
|
@ -33,6 +43,11 @@ void uiDrawLineTo(uiDrawContext *c, intmax_t x, intmax_t y)
|
||||||
cairo_line_to(c->cr, (double) x + 0.5, (double) y + 0.5);
|
cairo_line_to(c->cr, (double) x + 0.5, (double) y + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uiDrawRectangle(uiDrawContext *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height)
|
||||||
|
{
|
||||||
|
cairo_rectangle(c->cr, (double) x + 0.5, (double) y + 0.5, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
void uiDrawCloseFigure(uiDrawContext *c)
|
void uiDrawCloseFigure(uiDrawContext *c)
|
||||||
{
|
{
|
||||||
cairo_close_path(c->cr);
|
cairo_close_path(c->cr);
|
||||||
|
@ -67,3 +82,16 @@ void uiDrawStroke(uiDrawContext *c, uiDrawStrokeParams *p)
|
||||||
cairo_set_line_width(c->cr, ((double) p->Thickness) / 2);
|
cairo_set_line_width(c->cr, ((double) p->Thickness) / 2);
|
||||||
cairo_stroke(c->cr);
|
cairo_stroke(c->cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uiDrawFill(uiDrawContext *c, uiDrawFillMode mode)
|
||||||
|
{
|
||||||
|
switch (mode) {
|
||||||
|
case uiDrawFillModeWinding:
|
||||||
|
cairo_set_fill_rule(c->cr, CAIRO_FILL_RULE_WINDING);
|
||||||
|
break;
|
||||||
|
case uiDrawFillModeAlternate:
|
||||||
|
cairo_set_fill_rule(c->cr, CAIRO_FILL_RULE_EVEN_ODD);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cairo_fill(c->cr);
|
||||||
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *p)
|
||||||
sp.MiterLimit = uiDrawDefaultMiterLimit;
|
sp.MiterLimit = uiDrawDefaultMiterLimit;
|
||||||
uiDrawStroke(p->Context, &sp);
|
uiDrawStroke(p->Context, &sp);
|
||||||
|
|
||||||
uiDrawBeginPathRGB(p->Context, 0x00, 0x00, 0x80);
|
uiDrawBeginPathRGB(p->Context, 0x00, 0x00, 0xC0);
|
||||||
uiDrawMoveTo(p->Context, p->ClipX, p->ClipY);
|
uiDrawMoveTo(p->Context, p->ClipX, p->ClipY);
|
||||||
uiDrawLineTo(p->Context, p->ClipX + p->ClipWidth, p->ClipY);
|
uiDrawLineTo(p->Context, p->ClipX + p->ClipWidth, p->ClipY);
|
||||||
uiDrawLineTo(p->Context, 50, 150);
|
uiDrawLineTo(p->Context, 50, 150);
|
||||||
|
@ -36,6 +36,10 @@ static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *p)
|
||||||
sp.Thickness = 5;
|
sp.Thickness = 5;
|
||||||
uiDrawStroke(p->Context, &sp);
|
uiDrawStroke(p->Context, &sp);
|
||||||
|
|
||||||
|
uiDrawBeginPathRGBA(p->Context, 0x00, 0xC0, 0x00, 0x80);
|
||||||
|
uiDrawRectangle(p->Context, 120, 80, 50, 50);
|
||||||
|
uiDrawFill(p->Context, uiDrawFillModeWinding);
|
||||||
|
|
||||||
uiDrawBeginPathRGB(p->Context, 0x00, 0x80, 0x00);
|
uiDrawBeginPathRGB(p->Context, 0x00, 0x80, 0x00);
|
||||||
uiDrawMoveTo(p->Context, 5, 10);
|
uiDrawMoveTo(p->Context, 5, 10);
|
||||||
uiDrawLineTo(p->Context, 5, 50);
|
uiDrawLineTo(p->Context, 5, 50);
|
||||||
|
|
|
@ -60,6 +60,7 @@ enum uiDrawLineJoin {
|
||||||
// - os x: FillPath/EOFillPath functions
|
// - os x: FillPath/EOFillPath functions
|
||||||
enum uiDrawFillMode {
|
enum uiDrawFillMode {
|
||||||
uiDrawFillModeWinding,
|
uiDrawFillModeWinding,
|
||||||
|
// TODO rename to EvenOdd?
|
||||||
uiDrawFillModeAlternate,
|
uiDrawFillModeAlternate,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -72,14 +73,15 @@ struct uiDrawStrokeParams {
|
||||||
};
|
};
|
||||||
|
|
||||||
void uiDrawBeginPathRGB(uiDrawContext *, uint8_t, uint8_t, uint8_t);
|
void uiDrawBeginPathRGB(uiDrawContext *, uint8_t, uint8_t, uint8_t);
|
||||||
//TODO void uiDrawBeginPathRGBA(uiDrawContext *, uint8_t, uint8_t, uint8_t, uint8_t);
|
void uiDrawBeginPathRGBA(uiDrawContext *, uint8_t, uint8_t, uint8_t, uint8_t);
|
||||||
|
|
||||||
void uiDrawMoveTo(uiDrawContext *, intmax_t, intmax_t);
|
void uiDrawMoveTo(uiDrawContext *, intmax_t, intmax_t);
|
||||||
void uiDrawLineTo(uiDrawContext *, intmax_t, intmax_t);
|
void uiDrawLineTo(uiDrawContext *, intmax_t, intmax_t);
|
||||||
|
void uiDrawRectangle(uiDrawContext *, intmax_t, intmax_t, intmax_t, intmax_t);
|
||||||
void uiDrawCloseFigure(uiDrawContext *);
|
void uiDrawCloseFigure(uiDrawContext *);
|
||||||
|
|
||||||
void uiDrawStroke(uiDrawContext *, uiDrawStrokeParams *);
|
void uiDrawStroke(uiDrawContext *, uiDrawStrokeParams *);
|
||||||
//TODO void uiDrawFill(uiDrawContext *, uiDrawFillMode);
|
void uiDrawFill(uiDrawContext *, uiDrawFillMode);
|
||||||
|
|
||||||
// path functions
|
// path functions
|
||||||
// cairo gdi core graphics
|
// cairo gdi core graphics
|
||||||
|
|
Loading…
Reference in New Issue