From: Koichi KAMICHI Date: Fri, 13 Feb 2004 06:37:53 +0000 (+0000) Subject: Support SVG output. X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=586c15cce46997e512cae2e321240d5edd786f15;p=chise%2Fkage.git Support SVG output. --- diff --git a/kagecgi/kagecgi.c b/kagecgi/kagecgi.c index 6fce983..385aab5 100755 --- a/kagecgi/kagecgi.c +++ b/kagecgi/kagecgi.c @@ -97,7 +97,12 @@ int main(int argc, char *argv[]){ //clear result buffer test2 = g_string_new(""); - if(kType == 2){ + if(kType == 1){ //svg + g_string_append(kResultText, "\n"); + g_string_append(kResultText, "\n"); + g_string_append(kResultText, ""); + } + else if(kType == 2){ //eps g_string_append(kResultText, "%!PS-Adobe-3.0 EPSF-3.0\n"); g_string_append(kResultText, "%%BoundingBox: 0 -208 1024 816\n"); g_string_append(kResultText, "%%Pages: 0\n"); @@ -160,11 +165,23 @@ int main(int argc, char *argv[]){ } } else if(kType == 1){ //svg(vector graphics) + if(test2->len != 0){ + test2 = CalcSizes(test2, 1); + kMode = 1; + drawGlyph(test2, 0); + g_string_append(kResultText, "\n"); + fprintf(stdout, "Content-type: image/svg-xml\n\n"); + fprintf(stdout, "%s", kResultText->str); + } + else{ + fprintf(stdout, "Content-type: text/plain\n\n"); + fprintf(stdout, "An error occurred."); + } } else if(kType == 2){ //eps(vector graphics) if(test2->len != 0){ test2 = CalcSizes(test2, 1); - kMode = 1; + kMode = 2; drawGlyph(test2, 0); g_string_append(kResultText, "fill\n"); g_string_append(kResultText, "%%EOF\n"); diff --git a/kagecgi/kageic.c b/kagecgi/kageic.c index 70281dc..eadef07 100755 --- a/kagecgi/kageic.c +++ b/kagecgi/kageic.c @@ -11,7 +11,17 @@ void icPolygon(struct kPoint *poly, int number){ if(kMode == 0){ //normal fillPolygon(poly, number, 0, kageCanvas); } - else{ //output for eps + else if(kMode == 1){ //output for svg + sprintf(buf, ""); + g_string_append(kResultText, buf); + } + else if(kMode == 2){ //output for eps sprintf(buf, "%d %d moveto\n", poly[0].X * 5, 1000 - (poly[0].Y * 5) - 200); g_string_append(kResultText, buf); for(i = 1; i < number; i++){ @@ -22,4 +32,5 @@ void icPolygon(struct kPoint *poly, int number){ g_string_append(kResultText, buf); g_string_append(kResultText, "closepath\n"); } + }