diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2017-03-19 19:59:10 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2017-03-19 19:59:10 (GMT) |
commit | c60eec16458a41c3185c09abdc6ec23174ae4859 (patch) | |
tree | 67e93353834a31e489f0edab4f5028882b39131a /tkmacosx | |
parent | fac94d1e0c1313892a0b3578e875300139f52272 (diff) | |
download | blt-c60eec16458a41c3185c09abdc6ec23174ae4859.zip blt-c60eec16458a41c3185c09abdc6ec23174ae4859.tar.gz blt-c60eec16458a41c3185c09abdc6ec23174ae4859.tar.bz2 |
clean up macosx code supporting fill
Diffstat (limited to 'tkmacosx')
-rw-r--r-- | tkmacosx/macosxlib.h | 10 | ||||
-rw-r--r-- | tkmacosx/macosxlib.mm | 92 | ||||
-rw-r--r-- | tkmacosx/tkmacosx.h | 10 | ||||
-rw-r--r-- | tkmacosx/tkmacosx.mm | 56 |
4 files changed, 92 insertions, 76 deletions
diff --git a/tkmacosx/macosxlib.h b/tkmacosx/macosxlib.h index 69e779b..73c3fa3 100644 --- a/tkmacosx/macosxlib.h +++ b/tkmacosx/macosxlib.h @@ -19,15 +19,17 @@ void macosxDash(float*,int); void macosxFont(const char*, float); void macosxClip(Vector, Vector); +void macosxNewPath(); +void macosxStroke(); +void macosxFill(); +void macosxArc(Vector, float, float, float); +void macosxCurve(Vector, Vector, Vector, Vector); + void macosxDrawText(Vector, float, const char*); void macosxDrawLine(Vector, Vector); void macosxDrawLines(Vector*, int); void macosxFillPolygon(Vector*, int); void macosxDrawArc(Vector, float, float, float); -void macosxFillArc(Vector, float, float, float); -void macosxDrawCurve(Vector, Vector, Vector, Vector); -void macosxFillCurve(Vector, Vector, Vector, Vector); - void macosxBitmapCreate(void*, int, int, const Vector&, const Vector&); diff --git a/tkmacosx/macosxlib.mm b/tkmacosx/macosxlib.mm index 454d026..0c9034d 100644 --- a/tkmacosx/macosxlib.mm +++ b/tkmacosx/macosxlib.mm @@ -71,6 +71,58 @@ void macosxClip(Vector v, Vector s) */ } +void macosxNewPath() +{ +/* + if (tkmacosx) { + tkmacosx->newpath(); + } +*/ +} + +void macosxStroke() +{ +/* + if (tkmacosx) { + tkmacosx->stroke(); + } +*/ +} + +void macosxFill() +{ +/* + if (tkmacosx) { + tkmacosx->fill(); + } +*/ +} + +void macosxArc(Vector v, float rad, float ang1, float ang2) +{ +/* + if (tkmacosx) { + Vector vv = v*tkmacosx->getCanvasToPage(); + tkmacosx->arc(vv[0], vv[1], rad, ang1, ang2); + } +*/ +} + +void macosxCurve(Vector v0, Vector t0, Vector t1, Vector v1) +{ +/* + if (tkmacosx) { + Vector vv0 = v0*tkmacosx->getCanvasToPage(); + Vector tt0 = t0*tkmacosx->getCanvasToPage(); + Vector tt1 = t1*tkmacosx->getCanvasToPage(); + Vector vv1 = v1*tkmacosx->getCanvasToPage(); + + tkmacosx->curve(vv0[0], vv0[1], tt0[0], tt0[1], + tt1[0], tt1[1], vv1[0], vv1[1]); + } +*/ +} + void macosxDrawText(Vector v, float ang, const char* text) { /* @@ -150,46 +202,6 @@ void macosxDrawArc(Vector v, float rad, float ang1, float ang2) */ } -void macosxFillArc(Vector v, float rad, float ang1, float ang2) -{ -/* - if (tkmacosx) { - Vector vv = v*tkmacosx->getCanvasToPage(); - tkmacosx->fillArc(vv[0], vv[1], rad, ang1, ang2); - } -*/ -} - -void macosxDrawCurve(Vector v0, Vector t0, Vector t1, Vector v1) -{ -/* - if (tkmacosx) { - Vector vv0 = v0*tkmacosx->getCanvasToPage(); - Vector tt0 = t0*tkmacosx->getCanvasToPage(); - Vector tt1 = t1*tkmacosx->getCanvasToPage(); - Vector vv1 = v1*tkmacosx->getCanvasToPage(); - - tkmacosx->drawCurve(vv0[0], vv0[1], tt0[0], tt0[1], - tt1[0], tt1[1], vv1[0], vv1[1]); - } -*/ -} - -void macosxFillCurve(Vector v0, Vector t0, Vector t1, Vector v1) -{ -/* - if (tkmacosx) { - Vector vv0 = v0*tkmacosx->getCanvasToPage(); - Vector tt0 = t0*tkmacosx->getCanvasToPage(); - Vector tt1 = t1*tkmacosx->getCanvasToPage(); - Vector vv1 = v1*tkmacosx->getCanvasToPage(); - - tkmacosx->fillCurve(vv0[0], vv0[1], tt0[0], tt0[1], - tt1[0], tt1[1], vv1[0], vv1[1]); - } -*/ -} - void macosxBitmapCreate(void* img, int width, int height, const Vector& v, const Vector& s) { diff --git a/tkmacosx/tkmacosx.h b/tkmacosx/tkmacosx.h index 65ae6de..83810dd 100644 --- a/tkmacosx/tkmacosx.h +++ b/tkmacosx/tkmacosx.h @@ -48,12 +48,16 @@ class TkMacosx { void font(const char*, float); void clip(float, float, float, float); + void newpath(); + void stroke(); + void fill(); + void arc(float, float, float, float, float); + void curve(float, float, float, float, float, float, float, float); + void drawText(float, float, float, const char*); void drawLines(float*, float*, int); - void drawRect(float, float, float, float); - void drawArc(float, float, float, float, float); - void drawCurve(float, float, float, float, float, float, float, float); void fillPolygon(float*, float*, int); + void drawArc(float, float, float, float, float); void bitmapCreate(void*, int, int, float, float, float, float); */ diff --git a/tkmacosx/tkmacosx.mm b/tkmacosx/tkmacosx.mm index 00b8163..f6fa8d2 100644 --- a/tkmacosx/tkmacosx.mm +++ b/tkmacosx/tkmacosx.mm @@ -735,6 +735,33 @@ void TkMacosx::clip(float x, float y, float w, float h) CGContextClip(context); } +void TkMacosx::newpath() +{ + CGContextBeginPath(context); +} + +void TkMacosx::stroke() +{ + CGContextStrokePath(context); +} + +void TkMacosx::fill() +{ + CGContextEOFillPath(context); +} + +void TkMacosx::arc(float x, float y, float rad, float ang1, float ang2) +{ + CGContextAddArc(context, x, y, rad, ang1, ang2, 0); +} + +void TkMacosx::curve(float x0, float y0, float u0, float v0, + float u1, float v1, float x1, float y1) +{ + CGContextMoveToPoint(context, x0, y0); + CGContextAddCurveToPoint(context, u0, v0, u1, v1, x1, y1); +} + void TkMacosx::drawText(float x, float y, float angle, const char* text) { CGAffineTransform mm = CGAffineTransformMakeRotation(angle); @@ -770,35 +797,6 @@ void TkMacosx::drawArc(float x, float y, float rad, float ang1, float ang2) CGContextStrokePath(context); } -void TkMacosx::fillArc(float x, float y, float rad, float ang1, float ang2) -{ - CGContextBeginPath(context); - CGContextAddArc(context, x, y, rad, ang1, ang2, 0); - CGContextEOFillPath(context); -} - -void TkMacosx::drawCurve(float x0, float y0, - float u0, float v0, - float u1, float v1, - float x1, float y1) -{ - CGContextBeginPath(context); - CGContextMoveToPoint(context, x0, y0); - CGContextAddCurveToPoint(context, u0, v0, u1, v1, x1, y1); - CGContextStrokePath(context); -} - -void TkMacosx::fillCurve(float x0, float y0, - float u0, float v0, - float u1, float v1, - float x1, float y1) -{ - CGContextBeginPath(context); - CGContextMoveToPoint(context, x0, y0); - CGContextAddCurveToPoint(context, u0, v0, u1, v1, x1, y1); - CGContextEOPath(context); -} - void TkMacosx::bitmapCreate(void* data, int width, int height, float x, float y, float w, float h) { |