diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2017-03-12 20:05:27 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2017-03-12 20:05:27 (GMT) |
commit | 75a3a39ed8f422f44c1d969e8f96eecedebb3a5a (patch) | |
tree | 67b21f92deba50180608f5a33afdf2b20a5cf3ae /tksao | |
parent | 91d550b39033a5527170f822b7bb01611b0179be (diff) | |
download | blt-75a3a39ed8f422f44c1d969e8f96eecedebb3a5a.zip blt-75a3a39ed8f422f44c1d969e8f96eecedebb3a5a.tar.gz blt-75a3a39ed8f422f44c1d969e8f96eecedebb3a5a.tar.bz2 |
add fill option polygon
Diffstat (limited to 'tksao')
-rw-r--r-- | tksao/frame/polygon.C | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/tksao/frame/polygon.C b/tksao/frame/polygon.C index 2302f1b..f6370c9 100644 --- a/tksao/frame/polygon.C +++ b/tksao/frame/polygon.C @@ -51,43 +51,43 @@ void Polygon::renderX(Drawable drawable, Coord::InternalSystem sys, GC lgc = renderXGC(mode); vertex.head(); - Vector v1; - Vector v2 = fwdMap(vertex.current()->vector,sys); - int done = 0; - - do { - if (!vertex.next()) { - done = 1; + int cnt = vertex.count()+1; + XPoint* pp = new XPoint[cnt]; + for (int ii=0; ii<cnt; ii++) { + Vector vv = fwdMap(vertex.current()->vector,sys); + pp[ii].x = (short)vv[0]; + pp[ii].y = (short)vv[1]; + if (!vertex.next()) vertex.head(); - } - v1 = v2; - v2 = fwdMap(vertex.current()->vector,sys); - XDrawLine(display, drawable, lgc, v1[0], v1[1], v2[0], v2[1]); - } while (!done); + } + + if (fill_) + XFillPolygon(display, drawable, lgc, pp, cnt, Complex, CoordModeOrigin); + else + XDrawLines(display, drawable, lgc, pp, cnt, CoordModeOrigin); } void Polygon::renderPS(int mode) { renderPSGC(mode); + ostringstream str; + vertex.head(); - int first = 1; - do { - ostringstream str; + Vector v = fwdMap(vertex.current()->vector,Coord::CANVAS); + str << "newpath " << endl + << v.TkCanvasPs(parent->canvas) << " moveto" << endl; + while (vertex.next()) { Vector v = fwdMap(vertex.current()->vector,Coord::CANVAS); - if (first) { - str << "newpath " << endl - << v.TkCanvasPs(parent->canvas) << " moveto" << endl << ends; - first = 0; - } - else - str << v.TkCanvasPs(parent->canvas) << " lineto" << endl << ends; + str << v.TkCanvasPs(parent->canvas) << " lineto" << endl; + } - Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); - } while (vertex.next()); + str << "closepath "; + if (fill_) + str << "fill" << endl << ends; + else + str << "stroke" << endl << ends; - ostringstream str; - str << "closepath stroke" << endl << ends; Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); } |