More drawing API work.
This commit is contained in:
parent
cd215c260c
commit
c37d81cb06
|
@ -35,17 +35,17 @@ void uiDrawBeginPathRGBA(uiDrawContext *c, uint8_t r, uint8_t g, uint8_t b, uint
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiDrawLineTo(uiDrawContext *c, intmax_t x, intmax_t y)
|
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)
|
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);
|
cairo_rectangle(c->cr, ((double) x) + 0.5, ((double) y) + 0.5, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiDrawArc(uiDrawContext *c, intmax_t xCenter, intmax_t yCenter, intmax_t radius, double startAngle, double endAngle, int lineFromCurrentPointToStart)
|
void uiDrawArc(uiDrawContext *c, intmax_t xCenter, intmax_t yCenter, intmax_t radius, double startAngle, double endAngle, int lineFromCurrentPointToStart)
|
||||||
|
@ -62,6 +62,17 @@ void uiDrawArc(uiDrawContext *c, intmax_t xCenter, intmax_t yCenter, intmax_t ra
|
||||||
startAngle);
|
startAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uiDrawBezierTo(uiDrawContext *c, intmax_t c1x, intmax_t c1y, intmax_t c2x, intmax_t c2y, intmax_t endX, intmax_t endY)
|
||||||
|
{
|
||||||
|
cairo_curve_to(c->cr,
|
||||||
|
((double) c1x) + 0.5,
|
||||||
|
((double) c1y) + 0.5,
|
||||||
|
((double) c2x) + 0.5,
|
||||||
|
((double) c2y) + 0.5,
|
||||||
|
((double) endX) + 0.5,
|
||||||
|
((double) endY) + 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
void uiDrawCloseFigure(uiDrawContext *c)
|
void uiDrawCloseFigure(uiDrawContext *c)
|
||||||
{
|
{
|
||||||
cairo_close_path(c->cr);
|
cairo_close_path(c->cr);
|
||||||
|
|
|
@ -75,6 +75,18 @@ static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *p)
|
||||||
sp.Thickness = 1;
|
sp.Thickness = 1;
|
||||||
sp.MiterLimit = uiDrawDefaultMiterLimit;
|
sp.MiterLimit = uiDrawDefaultMiterLimit;
|
||||||
uiDrawStroke(p->Context, &sp);
|
uiDrawStroke(p->Context, &sp);
|
||||||
|
|
||||||
|
uiDrawBeginPathRGB(p->Context, 0x00, 0x80, 0xC0);
|
||||||
|
uiDrawMoveTo(p->Context, 300, 300);
|
||||||
|
uiDrawBezierTo(p->Context,
|
||||||
|
350, 320,
|
||||||
|
310, 390,
|
||||||
|
435, 372);
|
||||||
|
sp.Cap = uiDrawLineCapFlat;
|
||||||
|
sp.Join = uiDrawLineJoinMiter;
|
||||||
|
sp.Thickness = 1;
|
||||||
|
sp.MiterLimit = uiDrawDefaultMiterLimit;
|
||||||
|
uiDrawStroke(p->Context, &sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uintmax_t handlerHScrollMax(uiAreaHandler *a, uiArea *area)
|
static uintmax_t handlerHScrollMax(uiAreaHandler *a, uiArea *area)
|
||||||
|
|
|
@ -80,6 +80,8 @@ void uiDrawLineTo(uiDrawContext *, intmax_t, intmax_t);
|
||||||
void uiDrawRectangle(uiDrawContext *, intmax_t, intmax_t, intmax_t, intmax_t);
|
void uiDrawRectangle(uiDrawContext *, intmax_t, intmax_t, intmax_t, intmax_t);
|
||||||
// notes: angles are both relative to 0 and go counterclockwise
|
// notes: angles are both relative to 0 and go counterclockwise
|
||||||
void uiDrawArc(uiDrawContext *, intmax_t, intmax_t, intmax_t, double, double, int);
|
void uiDrawArc(uiDrawContext *, intmax_t, intmax_t, intmax_t, double, double, int);
|
||||||
|
// TODO behavior when there is no initial point on Windows and OS X
|
||||||
|
void uiDrawBezierTo(uiDrawContext *, intmax_t, intmax_t, intmax_t, intmax_t, intmax_t, intmax_t);
|
||||||
void uiDrawCloseFigure(uiDrawContext *);
|
void uiDrawCloseFigure(uiDrawContext *);
|
||||||
|
|
||||||
void uiDrawStroke(uiDrawContext *, uiDrawStrokeParams *);
|
void uiDrawStroke(uiDrawContext *, uiDrawStrokeParams *);
|
||||||
|
|
Loading…
Reference in New Issue