SVGlib.h : Différence entre versions

De troyesGEII
Aller à : navigation, rechercher
m
m
 
Ligne 3 : Ligne 3 :
 
<source lang="c">
 
<source lang="c">
 
#include <stdio.h>
 
#include <stdio.h>
FILE *sortie;<br>
+
FILE *sortie;
 +
 
 
struct pts {
 
struct pts {
 
  int x,y;
 
  int x,y;
};<br>
+
};
 +
 
 
void SVGopen(int dx, int dy){
 
void SVGopen(int dx, int dy){
 
   sortie=fopen("demo.svg","w+t");
 
   sortie=fopen("demo.svg","w+t");
Ligne 14 : Ligne 16 :
 
   fprintf(sortie,"<svg  width=\"%dmm\" height=\"%dmm\" viewBox=\"0 0 %d %d\" preserveAspectRatio=\"xMinYMin\" xml:space=\"preserve\"\n",dx,dy,dx,dy);
 
   fprintf(sortie,"<svg  width=\"%dmm\" height=\"%dmm\" viewBox=\"0 0 %d %d\" preserveAspectRatio=\"xMinYMin\" xml:space=\"preserve\"\n",dx,dy,dx,dy);
 
   fprintf(sortie,"xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n");
 
   fprintf(sortie,"xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n");
}<br>
+
}
 +
 
 
void SVGClose(){
 
void SVGClose(){
 
   fprintf(sortie,"</svg>\n");
 
   fprintf(sortie,"</svg>\n");
 
   fclose(sortie);
 
   fclose(sortie);
}<br>
+
}
 +
 
 
void SVGrectanglePlein(int x, int y, int Dx, int Dy,int rgbTour,int rgbFill){
 
void SVGrectanglePlein(int x, int y, int Dx, int Dy,int rgbTour,int rgbFill){
 
     fprintf(sortie,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" style=\"fill:#%06x;stroke:#%06x;\"/>\n",x,y,Dx,Dy,rgbFill,rgbTour);
 
     fprintf(sortie,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" style=\"fill:#%06x;stroke:#%06x;\"/>\n",x,y,Dx,Dy,rgbFill,rgbTour);
}<br>
+
}
 +
 
 
void SVGrectangleVide(int x, int y, int Dx, int Dy){
 
void SVGrectangleVide(int x, int y, int Dx, int Dy){
 
     fprintf(sortie,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" style=\"fill:none;stroke:black;\"/>\n",x,y,Dx,Dy);
 
     fprintf(sortie,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" style=\"fill:none;stroke:black;\"/>\n",x,y,Dx,Dy);
}<br>
+
}
 
void SVGline(int x1, int y1, int x2, int y2, int rgb){
 
void SVGline(int x1, int y1, int x2, int y2, int rgb){
 
     fprintf(sortie,"<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" style=\"stroke:#%06x;\"/>\n",x1,y1,x2,y2,rgb);
 
     fprintf(sortie,"<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" style=\"stroke:#%06x;\"/>\n",x1,y1,x2,y2,rgb);
}<br>
+
}
 +
 
 
void SVGlineLarge(int x1, int y1, int x2, int y2, int rgb,int epaisseur){
 
void SVGlineLarge(int x1, int y1, int x2, int y2, int rgb,int epaisseur){
 
     fprintf(sortie,"<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" style=\"stroke-width: %d;stroke:#%06x;\"/>\n",x1,y1,x2,y2,epaisseur,rgb);
 
     fprintf(sortie,"<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" style=\"stroke-width: %d;stroke:#%06x;\"/>\n",x1,y1,x2,y2,epaisseur,rgb);
}<br>
+
}
 +
 
 
void SVGcircleVide(int cx, int cy, int r){
 
void SVGcircleVide(int cx, int cy, int r){
 
     fprintf(sortie,"<circle cx=\"%d\" cy=\"%d\" r=\"%d\" style=\"fill:none;stroke:black;\"/>\n",cx,cy,r);
 
     fprintf(sortie,"<circle cx=\"%d\" cy=\"%d\" r=\"%d\" style=\"fill:none;stroke:black;\"/>\n",cx,cy,r);
}<br>
+
}
 +
 
 
void SVGcirclePlein(int cx, int cy, int r, int rgbTour,int rgbFill){
 
void SVGcirclePlein(int cx, int cy, int r, int rgbTour,int rgbFill){
 
     fprintf(sortie,"<circle cx=\"%d\" cy=\"%d\" r=\"%d\" style=\"fill:#%06x;stroke:#%06x;\"/>\n",cx,cy,r,rgbFill,rgbTour);
 
     fprintf(sortie,"<circle cx=\"%d\" cy=\"%d\" r=\"%d\" style=\"fill:#%06x;stroke:#%06x;\"/>\n",cx,cy,r,rgbFill,rgbTour);
}<br>
+
}
 +
 
 
void SVGText(int x, int y, int size, char *chaine){
 
void SVGText(int x, int y, int size, char *chaine){
 
     fprintf(sortie,"<text x=\"%d\" y=\"%d\"  font-family=\"Verdana\" font-size=\"%d\" fill=\"black\"> %s </text>\n",x,y,size,chaine);
 
     fprintf(sortie,"<text x=\"%d\" y=\"%d\"  font-family=\"Verdana\" font-size=\"%d\" fill=\"black\"> %s </text>\n",x,y,size,chaine);
}<br>
+
}
 +
 
 
void SVGellipseVide(int cx, int cy, int rx, int ry){
 
void SVGellipseVide(int cx, int cy, int rx, int ry){
 
     fprintf(sortie,"<ellipse cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" style=\"fill:none;stroke:black;\"/>\n",cx,cy,rx,ry);
 
     fprintf(sortie,"<ellipse cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" style=\"fill:none;stroke:black;\"/>\n",cx,cy,rx,ry);
}<br>
+
}
 +
 
 
void SVGellipsePlein(int cx, int cy, int rx, int ry, int rgbTour,int rgbFill){
 
void SVGellipsePlein(int cx, int cy, int rx, int ry, int rgbTour,int rgbFill){
 
     fprintf(sortie,"<ellipse cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" style=\"fill:#%06x;stroke:#%06x;\"/>\n",cx,cy,rx,ry,rgbFill,rgbTour);
 
     fprintf(sortie,"<ellipse cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" style=\"fill:#%06x;stroke:#%06x;\"/>\n",cx,cy,rx,ry,rgbFill,rgbTour);
}<br>
+
}
 +
 
 
void SVGrectanglePleinArrondi(int x, int y, int Dx, int Dy, int rx, int ry, int rgbTour,int rgbFill){
 
void SVGrectanglePleinArrondi(int x, int y, int Dx, int Dy, int rx, int ry, int rgbTour,int rgbFill){
 
     fprintf(sortie,"<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);
 
     fprintf(sortie,"<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);
}<br>
+
}
 +
 
 
void SVGrectangleVideArrondi(int x, int y, int Dx, int Dy,int rx, int ry){
 
void SVGrectangleVideArrondi(int x, int y, int Dx, int Dy,int rx, int ry){
 
     fprintf(sortie,"<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);
 
     fprintf(sortie,"<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);
}<br>
+
}
 +
 
 
void SVGpolyline(int nb, struct pts tabPts[],int rgbFill, int rgbTour) {
 
void SVGpolyline(int nb, struct pts tabPts[],int rgbFill, int rgbTour) {
 
  int i;
 
  int i;
Ligne 59 : Ligne 73 :
 
  }  
 
  }  
 
  fprintf(sortie,"\" style=\"fill:#%06x;stroke:#%06x;\"/>\n",rgbFill,rgbTour);
 
  fprintf(sortie,"\" style=\"fill:#%06x;stroke:#%06x;\"/>\n",rgbFill,rgbTour);
}<br>
+
}
 +
 
 
void SVGpolygon(int nb, struct pts tabPts[],int rgbFill, int rgbTour) {
 
void SVGpolygon(int nb, struct pts tabPts[],int rgbFill, int rgbTour) {
 
  int i;
 
  int i;
Ligne 67 : Ligne 82 :
 
  }  
 
  }  
 
  fprintf(sortie,"\" style=\"fill:#%06x;stroke:#%06x;\"/>\n",rgbFill,rgbTour);
 
  fprintf(sortie,"\" style=\"fill:#%06x;stroke:#%06x;\"/>\n",rgbFill,rgbTour);
}<br>
+
}
 +
 
 
void SVGrectanglePleinAnimate(int x, int y, int Dx, int Dy,int rgbTour,int rgbFill,int nb,struct pts tabPts[],int timesec){
 
void SVGrectanglePleinAnimate(int x, int y, int Dx, int Dy,int rgbTour,int rgbFill,int nb,struct pts tabPts[],int timesec){
 
     int i;
 
     int i;
Ligne 80 : Ligne 96 :
 
     fprintf(sortie,"%d\" />",tabPts[i].y);
 
     fprintf(sortie,"%d\" />",tabPts[i].y);
 
     fprintf(sortie,"</rect>\n");
 
     fprintf(sortie,"</rect>\n");
}<br>
+
}
 +
 
 
void SVGrectanglePleinAnimateMouseOver(int x, int y, int Dx, int Dy,int rgbTour,int rgbFill,int nb,struct pts tabPts[],int timesec){
 
void SVGrectanglePleinAnimateMouseOver(int x, int y, int Dx, int Dy,int rgbTour,int rgbFill,int nb,struct pts tabPts[],int timesec){
 
     int i;
 
     int i;

Version actuelle datée du 15 décembre 2012 à 19:18

retour vers la page des Tps II

#include <stdio.h>
FILE *sortie;

struct pts {
 int x,y;
};

void SVGopen(int dx, int dy){
  sortie=fopen("demo.svg","w+t");
  fprintf(sortie,"<?xml version=\"1.0\" standalone=\"no\"?>\n");
  fprintf(sortie,"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n");
  fprintf(sortie," \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
  fprintf(sortie,"<svg  width=\"%dmm\" height=\"%dmm\" viewBox=\"0 0 %d %d\" preserveAspectRatio=\"xMinYMin\" xml:space=\"preserve\"\n",dx,dy,dx,dy);
  fprintf(sortie,"xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n");
}

void SVGClose(){
  fprintf(sortie,"</svg>\n");
  fclose(sortie);
}

void SVGrectanglePlein(int x, int y, int Dx, int Dy,int rgbTour,int rgbFill){
    fprintf(sortie,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" style=\"fill:#%06x;stroke:#%06x;\"/>\n",x,y,Dx,Dy,rgbFill,rgbTour);
}

void SVGrectangleVide(int x, int y, int Dx, int Dy){
    fprintf(sortie,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" style=\"fill:none;stroke:black;\"/>\n",x,y,Dx,Dy);
}
void SVGline(int x1, int y1, int x2, int y2, int rgb){
    fprintf(sortie,"<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" style=\"stroke:#%06x;\"/>\n",x1,y1,x2,y2,rgb);
}

void SVGlineLarge(int x1, int y1, int x2, int y2, int rgb,int epaisseur){
    fprintf(sortie,"<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" style=\"stroke-width: %d;stroke:#%06x;\"/>\n",x1,y1,x2,y2,epaisseur,rgb);
}

void SVGcircleVide(int cx, int cy, int r){
    fprintf(sortie,"<circle cx=\"%d\" cy=\"%d\" r=\"%d\" style=\"fill:none;stroke:black;\"/>\n",cx,cy,r);
}

void SVGcirclePlein(int cx, int cy, int r, int rgbTour,int rgbFill){
    fprintf(sortie,"<circle cx=\"%d\" cy=\"%d\" r=\"%d\" style=\"fill:#%06x;stroke:#%06x;\"/>\n",cx,cy,r,rgbFill,rgbTour);
}

void SVGText(int x, int y, int size, char *chaine){
    fprintf(sortie,"<text x=\"%d\" y=\"%d\"  font-family=\"Verdana\" font-size=\"%d\" fill=\"black\"> %s </text>\n",x,y,size,chaine);
}

void SVGellipseVide(int cx, int cy, int rx, int ry){
    fprintf(sortie,"<ellipse cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" style=\"fill:none;stroke:black;\"/>\n",cx,cy,rx,ry);
}

void SVGellipsePlein(int cx, int cy, int rx, int ry, int rgbTour,int rgbFill){
    fprintf(sortie,"<ellipse cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" style=\"fill:#%06x;stroke:#%06x;\"/>\n",cx,cy,rx,ry,rgbFill,rgbTour);
}

void SVGrectanglePleinArrondi(int x, int y, int Dx, int Dy, int rx, int ry, int rgbTour,int rgbFill){
    fprintf(sortie,"<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(int x, int y, int Dx, int Dy,int rx, int ry){
    fprintf(sortie,"<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(int nb, struct pts tabPts[],int rgbFill, int rgbTour) {
 int i;
 fprintf(sortie,"<polyline points =\"");
 for (i=0;i<nb;i++) {
    fprintf(sortie,"%d,%d ",tabPts[i].x,tabPts[i].y);
 } 
 fprintf(sortie,"\" style=\"fill:#%06x;stroke:#%06x;\"/>\n",rgbFill,rgbTour);
}

void SVGpolygon(int nb, struct pts tabPts[],int rgbFill, int rgbTour) {
 int i;
 fprintf(sortie,"<polygon points =\"");
 for (i=0;i<nb;i++) {
    fprintf(sortie,"%d,%d ",tabPts[i].x,tabPts[i].y);
 } 
 fprintf(sortie,"\" style=\"fill:#%06x;stroke:#%06x;\"/>\n",rgbFill,rgbTour);
}

void SVGrectanglePleinAnimate(int x, int y, int Dx, int Dy,int rgbTour,int rgbFill,int nb,struct pts tabPts[],int timesec){
    int i;
    fprintf(sortie,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" style=\"fill:#%06x;stroke:#%06x;\">\n",x,y,Dx,Dy,rgbFill,rgbTour);
    fprintf(sortie,"<animate attributeName=\"x\" dur=\"%ds\" values=\"",timesec) ;
    for (i=0;i<nb-1;i++)
       fprintf(sortie,"%d;",tabPts[i].x);
    fprintf(sortie,"%d\" />",tabPts[i].x);
    fprintf(sortie,"<animate attributeName=\"y\" dur=\"%ds\" values=\"",timesec) ;
    for (i=0;i<nb-1;i++)
       fprintf(sortie,"%d;",tabPts[i].y);
    fprintf(sortie,"%d\" />",tabPts[i].y);
    fprintf(sortie,"</rect>\n");
}

void SVGrectanglePleinAnimateMouseOver(int x, int y, int Dx, int Dy,int rgbTour,int rgbFill,int nb,struct pts tabPts[],int timesec){
    int i;
    fprintf(sortie,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" style=\"fill:#%06x;stroke:#%06x;\">\n",x,y,Dx,Dy,rgbFill,rgbTour);
    fprintf(sortie,"<animate begin=\"mouseover\" attributeName=\"x\" dur=\"%ds\" values=\"",timesec) ;
    for (i=0;i<nb-1;i++)
       fprintf(sortie,"%d;",tabPts[i].x);
    fprintf(sortie,"%d\" />",tabPts[i].x);
    fprintf(sortie,"<animate begin=\"mouseover\" attributeName=\"y\" dur=\"%ds\" values=\"",timesec) ;
    for (i=0;i<nb-1;i++)
       fprintf(sortie,"%d;",tabPts[i].y);
    fprintf(sortie,"%d\" />",tabPts[i].y);
    fprintf(sortie,"</rect>\n");
}

retour vers la page des Tps II