more drawing funcs

This commit is contained in:
p989 2009-07-11 17:09:43 +00:00
parent d0200bdbcd
commit 073b71a46e
2 changed files with 159 additions and 5 deletions

View File

@ -188,6 +188,79 @@ void AGGDraw() {
aggDraw.target->setFont("verdana18_bold");
aggDraw.target->renderText(60,60, "testing testing testing");
// Gradients (Aqua Buttons)
//=======================================
// m_graphics.font("Verdana", 20.0, false, false, TAGG2D::VectorFontCache);
double xb1 = 10;
double yb1 = 80;
double xb2 = xb1 + 150;
double yb2 = yb1 + 36;
aggDraw.target->fillColor(0,50,180,180);
aggDraw.target->lineColor(0,0,80, 255);
aggDraw.target->lineWidth(1.0);
aggDraw.target->roundedRect(xb1, yb1, xb2, yb2, 12, 18);
aggDraw.target->lineColor(0,0,0,0);
aggDraw.target->fillLinearGradient(xb1, yb1, xb1, yb1+30,
agg::rgba8(100,200,255,255),
agg::rgba8(255,255,255,0));
aggDraw.target->roundedRect(xb1+3, yb1+2.5, xb2-3, yb1+30, 9, 18, 1, 1);
aggDraw.target->fillColor(0,0,50, 200);
aggDraw.target->noLine();
/* m_graphics.textAlignment(TAGG2D::AlignCenter, TAGG2D::AlignCenter);
m_graphics.text((xb1 + xb2) / 2.0, (yb1 + yb2) / 2.0, "Aqua Button", true, 0.0, 0.0);
*/
aggDraw.target->fillLinearGradient(xb1, yb2-20, xb1, yb2-3,
agg::rgba8(0, 0, 255,0),
agg::rgba8(100,255,255,255));
aggDraw.target->roundedRect(xb1+3, yb2-20, xb2-3, yb2-2, 1, 1, 9, 18);
// Basic Shapes -- Ellipse
//===========================================
aggDraw.target->lineWidth(3.5);
aggDraw.target->lineColor(20, 80, 80);
aggDraw.target->fillColor(200, 255, 80, 200);
aggDraw.target->ellipse(150, 200, 50, 90);
// Paths
//===========================================
aggDraw.target->resetPath();
aggDraw.target->fillColor(255, 0, 0, 100);
aggDraw.target->lineColor(0, 0, 255, 100);
aggDraw.target->lineWidth(2);
aggDraw.target->moveTo(300/2, 200/2);
aggDraw.target->horLineRel(-150/2);
aggDraw.target->arcRel(150/2, 150/2, 0, 1, 0, 150/2, -150/2);
aggDraw.target->closePolygon();
aggDraw.target->drawPath();
aggDraw.target->resetPath();
aggDraw.target->fillColor(255, 255, 0, 100);
aggDraw.target->lineColor(0, 0, 255, 100);
aggDraw.target->lineWidth(2);
aggDraw.target->moveTo(275/2, 175/2);
aggDraw.target->verLineRel(-150/2);
aggDraw.target->arcRel(150/2, 150/2, 0, 0, 0, -150/2, 150/2);
aggDraw.target->closePolygon();
aggDraw.target->drawPath();
aggDraw.target->resetPath();
aggDraw.target->noFill();
aggDraw.target->lineColor(127, 0, 0);
aggDraw.target->lineWidth(5);
aggDraw.target->moveTo(600/2, 350/2);
aggDraw.target->lineRel(50/2, -25/2);
aggDraw.target->arcRel(25/2, 25/2, aggDraw.target->deg2Rad(-30), 0, 1, 50/2, -25/2);
aggDraw.target->lineRel(50/2, -25/2);
aggDraw.target->arcRel(25/2, 50/2, aggDraw.target->deg2Rad(-30), 0, 1, 50/2, -25/2);
aggDraw.target->lineRel(50/2, -25/2);
aggDraw.target->arcRel(25/2, 75/2, aggDraw.target->deg2Rad(-30), 0, 1, 50/2, -25/2);
aggDraw.target->lineRel(50, -25);
aggDraw.target->arcRel(25/2, 100/2, aggDraw.target->deg2Rad(-30), 0, 1, 50/2, -25/2);
aggDraw.target->lineRel(50/2, -25/2);
aggDraw.target->drawPath();
}

View File

@ -59,8 +59,8 @@ public:
virtual void clear() = 0;
virtual void lineColor(unsigned r, unsigned g, unsigned b, unsigned a) = 0;
virtual void fillColor(unsigned r, unsigned g, unsigned b, unsigned a) = 0;
virtual void lineColor(unsigned r, unsigned g, unsigned b, unsigned a = 255) = 0;
virtual void fillColor(unsigned r, unsigned g, unsigned b, unsigned a = 255) = 0;
virtual void noFill() = 0;
virtual void noLine() = 0;
virtual void lineWidth(double w) = 0;
@ -69,10 +69,50 @@ public:
virtual void roundedRect(double x1, double y1, double x2, double y2,double rx_bottom, double ry_bottom,double rx_top, double ry_top) = 0;
virtual void roundedRect(double x1, double y1, double x2, double y2, double r) = 0;
virtual void roundedRect(double x1, double y1, double x2, double y2, double rx, double ry) = 0;
virtual void fillLinearGradient(double x1, double y1, double x2, double y2, agg::rgba8 c1, agg::rgba8 c2, double profile=1.0) = 0;
virtual void ellipse(double cx, double cy, double rx, double ry) = 0;
virtual void resetPath() = 0;
virtual void moveTo(double x, double y)= 0;
virtual void moveRel(double dx, double dy) = 0;
virtual void lineTo(double x, double y) = 0;
virtual void lineRel(double dx, double dy) = 0;
virtual void horLineTo(double x) = 0;
virtual void horLineRel(double dx) = 0;
virtual void verLineTo(double y) = 0;
virtual void verLineRel(double dy) = 0;
virtual void arcTo(double rx, double ry,double angle, bool largeArcFlag,bool sweepFlag,double x, double y) = 0;
virtual void arcRel(double rx, double ry,double angle, bool largeArcFlag,bool sweepFlag,double dx, double dy) = 0;
virtual void quadricCurveTo(double xCtrl, double yCtrl,double xTo, double yTo) = 0;
virtual void quadricCurveRel(double dxCtrl, double dyCtrl,double dxTo, double dyTo) = 0;
virtual void quadricCurveTo(double xTo, double yTo) = 0;
virtual void quadricCurveRel(double dxTo, double dyTo) = 0;
virtual void cubicCurveTo(double xCtrl1, double yCtrl1,double xCtrl2, double yCtrl2,double xTo, double yTo) = 0;
virtual void cubicCurveRel(double dxCtrl1, double dyCtrl1,double dxCtrl2, double dyCtrl2,double dxTo, double dyTo) = 0;
virtual void cubicCurveTo(double xCtrl2, double yCtrl2,double xTo, double yTo) = 0;
virtual void cubicCurveRel(double xCtrl2, double yCtrl2,double xTo, double yTo) = 0;
virtual void addEllipse(double cx, double cy, double rx, double ry, Agg2DBase::Direction dir) = 0;
virtual void closePolygon() = 0;
virtual void drawPath(Agg2DBase::DrawPathFlag flag = Agg2DBase::FillAndStroke) = 0;
// virtual void drawPathNoTransform(Agg2DBase::DrawPathFlag flag = Agg2DBase::FillAndStroke) = 0;
static const agg::int8u* lookupFont(const std::string& name);
virtual void setFont(const std::string& name) = 0;
virtual void renderText(double dstX, double dstY, const std::string& str) = 0;
// Auxiliary
virtual double pi() { return agg::pi; }
virtual double deg2Rad(double v) { return v * agg::pi / 180.0; }
virtual double rad2Deg(double v) { return v * 180.0 / agg::pi; }
};
@ -99,8 +139,8 @@ public:
}
}
virtual void lineColor(unsigned r, unsigned g, unsigned b, unsigned a) { BASE::lineColor(r,g,b,a); }
virtual void fillColor(unsigned r, unsigned g, unsigned b, unsigned a) { BASE::fillColor(r,g,b,a); }
virtual void lineColor(unsigned r, unsigned g, unsigned b, unsigned a = 255) { BASE::lineColor(r,g,b,a); }
virtual void fillColor(unsigned r, unsigned g, unsigned b, unsigned a = 255) { BASE::fillColor(r,g,b,a); }
virtual void noFill() { BASE::noFill(); }
virtual void noLine() { BASE::noLine(); }
virtual void lineWidth(double w) { BASE::lineWidth(w); }
@ -109,9 +149,50 @@ public:
virtual void roundedRect(double x1, double y1, double x2, double y2,double rx_bottom, double ry_bottom,double rx_top,double ry_top) { dirty(); BASE::roundedRect(x1,y1,x2,y2,rx_bottom,ry_bottom,rx_top,ry_top); }
virtual void roundedRect(double x1, double y1, double x2, double y2, double r) { dirty(); BASE::roundedRect(x1,y1,x2,y2,r); }
virtual void roundedRect(double x1, double y1, double x2, double y2, double rx, double ry) { dirty(); BASE::roundedRect(x1,y1,x2,y2,rx,ry); }
virtual void fillLinearGradient(double x1, double y1, double x2, double y2, Color c1, Color c2, double profile=1.0) {BASE::fillLinearGradient(x1, y1, x2, y2, c1, c2, profile); }
virtual void ellipse(double cx, double cy, double rx, double ry) {BASE::ellipse(cx, cy, rx, ry);}
virtual void setFont(const std::string& name) { BASE::font(lookupFont(name)); }
virtual void renderText(double dstX, double dstY, const std::string& str) { dirty(); BASE::renderText(dstX, dstY, str); }
// Path commands
virtual void resetPath() {BASE::resetPath();};
virtual void moveTo(double x, double y) {BASE::moveTo(x, y);}
virtual void moveRel(double dx, double dy) {BASE::moveRel(dx,dy);};
virtual void lineTo(double x, double y) {BASE::lineTo(x, y);};
virtual void lineRel(double dx, double dy) {BASE::lineRel(dx, dy);};
virtual void horLineTo(double x) {BASE::horLineTo(x);};
virtual void horLineRel(double dx) {BASE::horLineRel(dx);};
virtual void verLineTo(double y) {BASE::verLineTo(y);};
virtual void verLineRel(double dy) {BASE::verLineRel(dy);};
virtual void arcTo(double rx, double ry, double angle, bool largeArcFlag, bool sweepFlag, double x, double y) {BASE::arcTo(rx, ry, angle, largeArcFlag, sweepFlag, x, y);};
virtual void arcRel(double rx, double ry, double angle, bool largeArcFlag, bool sweepFlag, double dx, double dy) {BASE::arcRel(rx, ry, angle, largeArcFlag, sweepFlag, dx, dy);};
virtual void quadricCurveTo(double xCtrl, double yCtrl, double xTo, double yTo) {BASE::quadricCurveTo(xCtrl, yCtrl, xTo, yTo);};
virtual void quadricCurveRel(double dxCtrl, double dyCtrl, double dxTo, double dyTo) {BASE::quadricCurveRel(dxCtrl, dyCtrl, dxTo, dyTo);};
virtual void quadricCurveTo(double xTo, double yTo) {BASE::quadricCurveTo(xTo, yTo);};
virtual void quadricCurveRel(double dxTo, double dyTo) {BASE::quadricCurveRel(dxTo, dyTo);};
virtual void cubicCurveTo(double xCtrl1, double yCtrl1, double xCtrl2, double yCtrl2, double xTo, double yTo) {BASE::cubicCurveTo(xCtrl1, yCtrl1, xCtrl2, yCtrl2, xTo, yTo);};
virtual void cubicCurveRel(double dxCtrl1, double dyCtrl1, double dxCtrl2, double dyCtrl2, double dxTo, double dyTo) {BASE::cubicCurveRel(dxCtrl1, dyCtrl1, dxCtrl2, dyCtrl2, dxTo, dyTo);};
virtual void cubicCurveTo(double xCtrl2, double yCtrl2, double xTo, double yTo) {BASE::cubicCurveTo(xCtrl2, yCtrl2, xTo, yTo);};
virtual void cubicCurveRel(double xCtrl2, double yCtrl2, double xTo, double yTo) {BASE::cubicCurveRel(xCtrl2, yCtrl2, xTo, yTo);};
virtual void addEllipse(double cx, double cy, double rx, double ry, Direction dir) {BASE::addEllipse(cx, cy, rx, ry, dir);};
virtual void closePolygon() {BASE::closePolygon();};
virtual void drawPath(DrawPathFlag flag = FillAndStroke) {BASE::drawPath(flag);};
// virtual void drawPathNoTransform(DrawPathFlag flag = FillAndStroke) {BASE::drawPathNoTransform(flag);};
// Auxiliary
virtual double pi() { return agg::pi; }
virtual double deg2Rad(double v) { return v * agg::pi / 180.0; }
virtual double rad2Deg(double v) { return v * 180.0 / agg::pi; }
};
class AggDraw