Difference between revisions of "File:Eps32x22ringVector.jpg"
(Importing image file) |
|||
Line 1: | Line 1: | ||
+ | Example of the [[vector graphics]] in [[EPS]]. |
||
− | Importing image file |
||
+ | |||
+ | The black circle is plotted with the [[EPS]] command [[arc(eps)|arc]]. |
||
+ | |||
+ | The red cross is drawn with the [[EPS]] commands [[moveto]], [[lineto]], [[stroke]] |
||
+ | (simplified to M, L, S in the definitions in the beginning of the file). |
||
+ | |||
+ | The image should be compared to the roster version of such a ring at [[File:Eps32x22ringRoster.jpg|120px]]. |
||
+ | |||
+ | ==EPS version of the file== |
||
+ | |||
+ | The two empty lines and the [[spacebar]] at the beginning of lines are introduced to |
||
+ | improve the formatting at [[TORI]] and simplify the loading, they do not affect the view and conversion of this file to other formats. |
||
+ | |||
+ | %!PS-Adobe-2.0 EPSF-2.0 |
||
+ | |||
+ | %%BoundingBox: 0 0 322 222 |
||
+ | |||
+ | /RGB {setrgbcolor} bind def |
||
+ | /W {setlinewidth} bind def |
||
+ | /M {moveto} bind def |
||
+ | /L {lineto} bind def |
||
+ | /C {closepath} bind def |
||
+ | /S {stroke} bind def |
||
+ | 1 1 translate |
||
+ | 10 10 scale |
||
+ | 16.000 11.000 10 0 360 arc C 2 W S |
||
+ | 16.000 -1.000 M |
||
+ | 16.000 23.000 L |
||
+ | -1.000 11.000 M |
||
+ | 33.000 11.000 L |
||
+ | 1 0 0 RGB .3 W S |
||
+ | showpage |
||
+ | %%Trailer |
||
+ | |||
+ | ==[[C++]] generator== |
||
+ | |||
+ | //The image above is generated with the code below. All the routines are included, no additional files should be loaded for the compilation. |
||
+ | |||
+ | #include<math.h> |
||
+ | #include<stdio.h> |
||
+ | #include<stdlib.h> |
||
+ | #define DB double |
||
+ | void ado(FILE *O, int X, int Y) |
||
+ | {fprintf(O,"%c!PS-Adobe-2.0 EPSF-2.0\n",'%'); |
||
+ | fprintf(O,"%c%cBoundingBox: 0 0 %d %d\n",'%','%',X,Y); |
||
+ | //fprintf(O,"/times-Roman findfont 20 scalefont setfont\n"); |
||
+ | fprintf(O,"/RGB {setrgbcolor} bind def\n"); |
||
+ | fprintf(O,"/W {setlinewidth} bind def\n"); |
||
+ | fprintf(O,"/M {moveto} bind def\n"); |
||
+ | fprintf(O,"/L {lineto} bind def\n"); |
||
+ | fprintf(O,"/C {closepath} bind def\n"); |
||
+ | fprintf(O,"/S {stroke} bind def\n"); } |
||
+ | |||
+ | #define DO(x,y) for(x=0;x<y;x++) |
||
+ | |||
+ | main(){ int m,M=32,n,N=22; DB x,y, u,v; FILE *o; |
||
+ | o=fopen("eps32x22ringVector.eps","w"); ado(o, 10*M+2, 10*N+2); |
||
+ | fprintf(o,"1 1 translate\n"); |
||
+ | fprintf(o,"10 10 scale\n"); |
||
+ | |||
+ | /* |
||
+ | DB *a; a=(DB *)malloc((size_t)((M*N)*sizeof(DB))); |
||
+ | DO(m,M) DO(n,N){x=.1*(m-M/2.+.5);y=.1*(n-N/2.+.5); |
||
+ | u=x*x+y*y; v=u-1.; v*=v; |
||
+ | a[n*M+m]=1.-exp(-256.*v*v);} |
||
+ | fprintf(o,"gsave\n "); |
||
+ | fprintf(o," %2d %2d scale\n",M,N); |
||
+ | fprintf(o," %2d %2d 4 [%2d 0 0 %2d 0 %2d]\n<", M,N,M,-N,N); |
||
+ | for(n=N-1;n>=0;n--) |
||
+ | { fprintf(o,"\n "); |
||
+ | DO(m,M){ fprintf(o,"%1x",int(15.*a[n*M+m]+.5) ); |
||
+ | }} |
||
+ | fprintf(o,"\n >\n "); |
||
+ | fprintf(o,"image\n "); |
||
+ | free(a); |
||
+ | fprintf(o,"grestore\n "); |
||
+ | */ |
||
+ | |||
+ | fprintf(o," %6.3f %6.3f 10 0 360 arc C 2 W S\n ",M/2.,N/2.); |
||
+ | |||
+ | #define M(x,y) fprintf(o," %6.3f %6.3f M\n ",0.+x,0.+y); |
||
+ | #define L(x,y) fprintf(o," %6.3f %6.3f L\n ",0.+x,0.+y); |
||
+ | M(M/2.,-1); L(M/2.,N+1); |
||
+ | M(-1,N/2.); L(M+1,N/2.); |
||
+ | fprintf(o," 1 0 0 RGB .3 W S\n "); |
||
+ | fprintf(o,"showpage\n%c%cTrailer\n",'%','%'); fclose(o); |
||
+ | system("epstopdf eps32x22ringVector.eps"); |
||
+ | //system( "open eps32x22ringVector.pdf"); |
||
+ | system( "convert eps32x22ringVector.eps eps32x22ringVector.jpg "); |
||
+ | system( "open eps32x22ringVector.jpg"); |
||
+ | } |
||
+ | |||
+ | //The part generating the roster image in the code above is suppressed. |
||
+ | |||
+ | ==Keywords== |
||
+ | Some of commands of [[C++]] and [[EPS]] used above are listed below: |
||
+ | |||
+ | [[EPS]], [[vector graphics]], [[C++]], |
||
+ | |||
+ | [[BoundingBox]], |
||
+ | |||
+ | [[fopen]], [[fclose]], [[fprintf]], [[system(C++)|system]] |
||
+ | |||
+ | [[epstopdf]], [[convert]] |
||
+ | ==Refrerences== |
||
+ | <references/> |
||
+ | |||
+ | [[Category:EPS]] |
||
+ | [[Category:C++]] |
||
+ | [[Category:Visualization]] |
||
+ | [[Category:Vector graphics]] |
Latest revision as of 09:39, 21 June 2013
Example of the vector graphics in EPS.
The black circle is plotted with the EPS command arc.
The red cross is drawn with the EPS commands moveto, lineto, stroke (simplified to M, L, S in the definitions in the beginning of the file).
The image should be compared to the roster version of such a ring at .
EPS version of the file
The two empty lines and the spacebar at the beginning of lines are introduced to improve the formatting at TORI and simplify the loading, they do not affect the view and conversion of this file to other formats.
%!PS-Adobe-2.0 EPSF-2.0
%%BoundingBox: 0 0 322 222
/RGB {setrgbcolor} bind def /W {setlinewidth} bind def /M {moveto} bind def /L {lineto} bind def /C {closepath} bind def /S {stroke} bind def 1 1 translate 10 10 scale 16.000 11.000 10 0 360 arc C 2 W S 16.000 -1.000 M 16.000 23.000 L -1.000 11.000 M 33.000 11.000 L 1 0 0 RGB .3 W S showpage
%%Trailer
C++ generator
//The image above is generated with the code below. All the routines are included, no additional files should be loaded for the compilation.
#include<math.h> #include<stdio.h> #include<stdlib.h> #define DB double void ado(FILE *O, int X, int Y) {fprintf(O,"%c!PS-Adobe-2.0 EPSF-2.0\n",'%'); fprintf(O,"%c%cBoundingBox: 0 0 %d %d\n",'%','%',X,Y); //fprintf(O,"/times-Roman findfont 20 scalefont setfont\n"); fprintf(O,"/RGB {setrgbcolor} bind def\n"); fprintf(O,"/W {setlinewidth} bind def\n"); fprintf(O,"/M {moveto} bind def\n"); fprintf(O,"/L {lineto} bind def\n"); fprintf(O,"/C {closepath} bind def\n"); fprintf(O,"/S {stroke} bind def\n"); }
#define DO(x,y) for(x=0;x<y;x++)
main(){ int m,M=32,n,N=22; DB x,y, u,v; FILE *o; o=fopen("eps32x22ringVector.eps","w"); ado(o, 10*M+2, 10*N+2); fprintf(o,"1 1 translate\n"); fprintf(o,"10 10 scale\n");
/* DB *a; a=(DB *)malloc((size_t)((M*N)*sizeof(DB))); DO(m,M) DO(n,N){x=.1*(m-M/2.+.5);y=.1*(n-N/2.+.5); u=x*x+y*y; v=u-1.; v*=v; a[n*M+m]=1.-exp(-256.*v*v);} fprintf(o,"gsave\n "); fprintf(o," %2d %2d scale\n",M,N); fprintf(o," %2d %2d 4 [%2d 0 0 %2d 0 %2d]\n<", M,N,M,-N,N); for(n=N-1;n>=0;n--) { fprintf(o,"\n "); DO(m,M){ fprintf(o,"%1x",int(15.*a[n*M+m]+.5) ); }} fprintf(o,"\n >\n "); fprintf(o,"image\n "); free(a); fprintf(o,"grestore\n "); */
fprintf(o," %6.3f %6.3f 10 0 360 arc C 2 W S\n ",M/2.,N/2.);
#define M(x,y) fprintf(o," %6.3f %6.3f M\n ",0.+x,0.+y); #define L(x,y) fprintf(o," %6.3f %6.3f L\n ",0.+x,0.+y); M(M/2.,-1); L(M/2.,N+1); M(-1,N/2.); L(M+1,N/2.); fprintf(o," 1 0 0 RGB .3 W S\n "); fprintf(o,"showpage\n%c%cTrailer\n",'%','%'); fclose(o); system("epstopdf eps32x22ringVector.eps"); //system( "open eps32x22ringVector.pdf"); system( "convert eps32x22ringVector.eps eps32x22ringVector.jpg "); system( "open eps32x22ringVector.jpg");
}
//The part generating the roster image in the code above is suppressed.
Keywords
Some of commands of C++ and EPS used above are listed below:
fopen, fclose, fprintf, system
Refrerences
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 17:50, 20 June 2013 | 322 × 222 (12 KB) | Maintenance script (talk | contribs) | Importing image file |
You cannot overwrite this file.
File usage
The following page uses this file: