From: ellson Date: Fri, 28 Jan 2005 20:37:10 +0000 (+0000) Subject: Add: fillarc, openarc, chord, fillchord, openchord, fillpie, openpie. X-Git-Tag: LAST_LIBGRAPH~32^2~7983 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0ea5ac1b49105f4480f61581a7b496638670b5bc;p=graphviz Add: fillarc, openarc, chord, fillchord, openchord, fillpie, openpie. --- diff --git a/tclpkg/gdtclft/examples/arc.tcl b/tclpkg/gdtclft/examples/arc.tcl new file mode 100755 index 000000000..3f7d6cba2 --- /dev/null +++ b/tclpkg/gdtclft/examples/arc.tcl @@ -0,0 +1,22 @@ +#!/bin/sh +# next line is a comment in tcl \ +exec tclsh "$0" ${1+"$@"} + +package require Gdtclft + +set gd [gd create 200 700] +set white [gd color new $gd 255 255 255] +set black [gd color new $gd 0 0 0] + +gd arc $gd $black 100 40 120 40 225 315 +gd fillarc $gd $black 100 80 120 40 225 315 +gd openarc $gd $black 100 120 120 40 225 315 + +gd chord $gd $black 100 160 120 40 225 315 +gd fillchord $gd $black 100 200 120 40 225 315 +gd openchord $gd $black 100 240 120 40 225 315 + +gd fillpie $gd $black 100 280 120 40 225 315 +gd openpie $gd $black 100 320 120 40 225 315 + +gd writePNG $gd stdout diff --git a/tclpkg/gdtclft/gdtclft.c b/tclpkg/gdtclft/gdtclft.c index 1b90542d9..b3cbe5648 100644 --- a/tclpkg/gdtclft/gdtclft.c +++ b/tclpkg/gdtclft/gdtclft.c @@ -146,6 +146,18 @@ static cmdOptions subcmdVec[] = { "gdhandle color cx cy width height start end"}, {"fillarc", tclGdArcCmd, 8, 8, 0, 1, "gdhandle color cx cy width height start end"}, + {"openarc", tclGdArcCmd, 8, 8, 0, 1, + "gdhandle color cx cy width height start end"}, + {"fillpie", tclGdArcCmd, 8, 8, 0, 1, + "gdhandle color cx cy width height start end"}, + {"openpie", tclGdArcCmd, 8, 8, 0, 1, + "gdhandle color cx cy width height start end"}, + {"chord", tclGdArcCmd, 8, 8, 0, 1, + "gdhandle color cx cy width height start end"}, + {"fillchord", tclGdArcCmd, 8, 8, 0, 1, + "gdhandle color cx cy width height start end"}, + {"openchord", tclGdArcCmd, 8, 8, 0, 1, + "gdhandle color cx cy width height start end"}, {"polygon", tclGdPolygonCmd, 2, 999, 0, 1, "gdhandle color x1 y1 x2 y2 x3 y3 ..."}, {"fillpolygon", tclGdPolygonCmd, 3, 999, 0, 1, @@ -1024,14 +1036,27 @@ tclGdArcCmd(Tcl_Interp * interp, GdData * gdData, /* Call the appropriate arc function. */ cmd = Tcl_GetString(objv[1]); - if (cmd[0] == 'a') + if (cmd[0] == 'a') /* arc */ gdImageArc(im, cx, cy, width, height, start, end, color); - else { -/* gdImageFilledArc(im, cx, cy, width, height, start, end, color); */ - Tcl_SetResult(interp, "gdImageFilledArc not supported in gd1.2", - TCL_STATIC); - return TCL_ERROR; +/* This one is not really useful as gd renderers it the same as fillpie */ +/* It would be more useful if gd provided fill between arc and chord */ + else if (cmd[0] == 'f' && cmd[4] == 'a') /* fill arc */ + gdImageFilledArc(im, cx, cy, width, height, start, end, color, gdArc); +/* this one is a kludge */ + else if (cmd[0] == 'o' && cmd[4] == 'a') { /* open arc */ + gdImageArc(im, cx, cy, width, height, start, end, color); + gdImageFilledArc(im, cx, cy, width, height, start, end, color, gdChord | gdNoFill); } + else if (cmd[0] == 'c') /* chord */ + gdImageFilledArc(im, cx, cy, width, height, start, end, color, gdChord | gdNoFill); + else if (cmd[0] == 'f' && cmd[4] == 'c') /* fill chord */ + gdImageFilledArc(im, cx, cy, width, height, start, end, color, gdChord); + else if (cmd[0] == 'o' && cmd[4] == 'c') /* open chord */ + gdImageFilledArc(im, cx, cy, width, height, start, end, color, gdChord | gdEdged | gdNoFill); + else if (cmd[0] == 'f' && cmd[4] == 'p') /* fill pie */ + gdImageFilledArc(im, cx, cy, width, height, start, end, color, gdPie); + else if (cmd[0] == 'o' && cmd[4] == 'p') /* open pie */ + gdImageFilledArc(im, cx, cy, width, height, start, end, color, gdPie | gdEdged | gdNoFill); return TCL_OK; }