SVGhttplib : Différence entre versions
m |
m |
||
Ligne 112 : | Ligne 112 : | ||
} | } | ||
</source> | </source> | ||
+ | Ce fichier est utilisé dans cet [[MiniSVG|exemple en C]] |
Version du 16 janvier 2013 à 12:09
Voici le fichier SVGlib.h qu'il vous faut avoir dans votre répertoire courant :
#include <httpd.h>
//FILE *sortie;
struct pts {
int x,y;
};
void SVGopen(httpd *server,int dx, int dy){
// sortie=fopen("demo.svg","w+t");
httpdPrintf(server,"<?xml version=\"1.0\" standalone=\"no\"?>\n");
httpdPrintf(server,"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n");
httpdPrintf(server," \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
httpdPrintf(server,"<svg width=\"%dmm\" height=\"%dmm\" viewBox=\"0 0 %d %d\" preserveAspectRatio=\"xMinYMin\" xml:space=\"preserve\"\n",dx/10,dy/10,dx,dy);
httpdPrintf(server,"xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n");
}
void SVGClose(httpd *server){
httpdPrintf(server,"</svg>\n");
// fclose(sortie);
}
void SVGrectanglePlein(httpd *server,int x, int y, int Dx, int Dy,int rgbTour,int rgbFill){
httpdPrintf(server,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" style=\"fill:#%06x;stroke:#%06x;\"/>\n",x,y,Dx,Dy,rgbFill,rgbTour);
}
void SVGrectangleVide(httpd *server,int x, int y, int Dx, int Dy){
httpdPrintf(server,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" style=\"fill:none;stroke:black;\"/>\n",x,y,Dx,Dy);
}
void SVGline(httpd *server,int x1, int y1, int x2, int y2, int rgb){
httpdPrintf(server,"<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" style=\"stroke:#%06x;\"/>\n",x1,y1,x2,y2,rgb);
}
void SVGlineLarge(httpd *server,int x1, int y1, int x2, int y2, int rgb,int epaisseur){
httpdPrintf(server,"<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" style=\"stroke-width: %d;stroke:#%06x;\"/>\n",x1,y1,x2,y2,epaisseur,rgb);
}
void SVGcircleVide(httpd *server,int cx, int cy, int r){
httpdPrintf(server,"<circle cx=\"%d\" cy=\"%d\" r=\"%d\" style=\"fill:none;stroke:black;\"/>\n",cx,cy,r);
}
void SVGcirclePlein(httpd *server,int cx, int cy, int r, int rgbTour,int rgbFill){
httpdPrintf(server,"<circle cx=\"%d\" cy=\"%d\" r=\"%d\" style=\"fill:#%06x;stroke:#%06x;\"/>\n",cx,cy,r,rgbFill,rgbTour);
}
void SVGText(httpd *server,int x, int y, int size, char *chaine){
httpdPrintf(server,"<text x=\"%d\" y=\"%d\" font-family=\"Verdana\" font-size=\"%d\" fill=\"black\"> %s </text>\n",x,y,size,chaine);
}
void SVGellipseVide(httpd *server,int cx, int cy, int rx, int ry){
httpdPrintf(server,"<ellipse cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" style=\"fill:none;stroke:black;\"/>\n",cx,cy,rx,ry);
}
void SVGellipsePlein(httpd *server,int cx, int cy, int rx, int ry, int rgbTour,int rgbFill){
httpdPrintf(server,"<ellipse cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" style=\"fill:#%06x;stroke:#%06x;\"/>\n",cx,cy,rx,ry,rgbFill,rgbTour);
}
void SVGrectanglePleinArrondi(httpd *server,int x, int y, int Dx, int Dy, int rx, int ry, int rgbTour,int rgbFill){
httpdPrintf(server,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" rx=\"%d\" ry=\"%d\" style=\"fill:#%06x;stroke:#%06x;\"/>\n",x,y,Dx,Dy,rx,ry,rgbFill,rgbTour);
}
void SVGrectangleVideArrondi(httpd *server,int x, int y, int Dx, int Dy,int rx, int ry){
httpdPrintf(server,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" rx=\"%d\" ry=\"%d\" style=\"fill:none;stroke:black;\"/>\n",x,y,Dx,Dy,rx,ry);
}
void SVGpolyline(httpd *server,int nb, struct pts tabPts[],int rgbFill, int rgbTour) {
int i;
httpdPrintf(server,"<polyline points =\"");
for (i=0;i<nb;i++) {
httpdPrintf(server,"%d,%d ",tabPts[i].x,tabPts[i].y);
}
httpdPrintf(server,"\" style=\"fill:#%06x;stroke:#%06x;\"/>\n",rgbFill,rgbTour);
}
void SVGpolygon(httpd *server,int nb, struct pts tabPts[],int rgbFill, int rgbTour) {
int i;
httpdPrintf(server,"<polygon points =\"");
for (i=0;i<nb;i++) {
httpdPrintf(server,"%d,%d ",tabPts[i].x,tabPts[i].y);
}
httpdPrintf(server,"\" style=\"fill:#%06x;stroke:#%06x;\"/>\n",rgbFill,rgbTour);
}
void SVGrectanglePleinAnimate(httpd *server,int x, int y, int Dx, int Dy,int rgbTour,int rgbFill,int nb,struct pts tabPts[],int timesec){
int i;
httpdPrintf(server,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" style=\"fill:#%06x;stroke:#%06x;\">\n",x,y,Dx,Dy,rgbFill,rgbTour);
httpdPrintf(server,"<animate attributeName=\"x\" dur=\"%ds\" values=\"",timesec) ;
for (i=0;i<nb-1;i++)
httpdPrintf(server,"%d;",tabPts[i].x);
httpdPrintf(server,"%d\" />",tabPts[i]);
httpdPrintf(server,"<animate attributeName=\"y\" dur=\"%ds\" values=\"",timesec) ;
for (i=0;i<nb-1;i++)
httpdPrintf(server,"%d;",tabPts[i].y);
httpdPrintf(server,"%d\" />",tabPts[i]);
httpdPrintf(server,"</rect>\n");
}
void SVGrectanglePleinAnimateMouseOver(httpd *server,int x, int y, int Dx, int Dy,int rgbTour,int rgbFill,int nb,struct pts tabPts[],int timesec){
int i;
httpdPrintf(server,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" style=\"fill:#%06x;stroke:#%06x;\">\n",x,y,Dx,Dy,rgbFill,rgbTour);
httpdPrintf(server,"<animate begin=\"mouseover\" attributeName=\"x\" dur=\"%ds\" values=\"",timesec) ;
for (i=0;i<nb-1;i++)
httpdPrintf(server,"%d;",tabPts[i].x);
httpdPrintf(server,"%d\" />",tabPts[i].x);
httpdPrintf(server,"<animate begin=\"mouseover\" attributeName=\"y\" dur=\"%ds\" values=\"",timesec) ;
for (i=0;i<nb-1;i++)
httpdPrintf(server,"%d;",tabPts[i].y);
httpdPrintf(server,"%d\" />",tabPts[i].y);
httpdPrintf(server,"</rect>\n");
}
Ce fichier est utilisé dans cet exemple en C