00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <stdio.h>
00020 #include <math.h>
00021 #include <string.h>
00022 #include <stdlib.h>
00023 #include "defines.h"
00024 #include "cd.h"
00025
00026
00027 int main()
00028 {
00029
00030
00031 cdImagePtr im;
00032
00033
00034 FILE *outf;
00035
00036
00037
00038 int black, white, blue;
00039
00040
00041
00042 im = cdImageCreate( 800, 400 );
00043
00044
00045
00046 white = cdImageColorAllocate( im, 255, 255, 255 );
00047 black = cdImageColorAllocate( im, 0, 0, 0 );
00048 blue = cdImageColorAllocate( im, 0, 0, 255 );
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 if ( !( cdSetTextAttrib( im, 5, black, 20 ) ) )
00060 return 1;
00061
00062
00063
00064 if ( !( cdSetLineAttrib( im, 1, 1, blue ) ) )
00065 return 1;
00066
00067
00068 if ( !( cdLine( im, 0, 200, 799, 200 ) ) )
00069 return 1;
00070 if ( !( cdLine( im, 200, 0, 200, 399 ) ) )
00071 return 1;
00072 if ( !( cdLine( im, 600, 0, 600, 399 ) ) )
00073 return 1;
00074
00075
00076
00077
00078
00079
00080 if ( !( cdSetTextPath( im, 1 ) ) )
00081 return 1;
00082 if ( !( cdText( im, 200, 200, "Text Left" ) ) )
00083 return 1;
00084
00085
00086 if ( !( cdSetTextPath( im, 2 ) ) )
00087 return 1;
00088 if ( !( cdText( im, 200, 200, "Text Up" ) ) )
00089 return 1;
00090
00091
00092 if ( !( cdSetTextPath( im, 3 ) ) )
00093 return 1;
00094 if ( !( cdText( im, 200, 200, "Text Down" ) ) )
00095 return 1;
00096
00097
00098 if ( !( cdSetTextPath( im, 0 ) ) )
00099 return 1;
00100 if ( !( cdText( im, 200, 200, "Text Right" ) ) )
00101 return 1;
00102
00103
00104
00105
00106
00107 if ( !( cdText( im, 600, 200, "CGM Draw" ) ) )
00108 return 1;
00109
00110
00111 if ( !( cdSetTextOrient( im, -1, 1, 1, 1 ) ) )
00112 return 1;
00113 if ( !( cdText( im, 600, 200, "CGM Draw" ) ) )
00114 return 1;
00115
00116
00117 if ( !( cdSetTextOrient( im, -1, 0, 0, 1 ) ) )
00118 return 1;
00119 if ( !( cdText( im, 600, 200, "CGM Draw" ) ) )
00120 return 1;
00121
00122
00123 if ( !( cdSetTextOrient( im, -1, -1, -1, 1 ) ) )
00124 return 1;
00125 if ( !( cdText( im, 600, 200, "CGM Draw" ) ) )
00126 return 1;
00127
00128
00129 if ( !( cdSetTextOrient( im, 0, -1, -1, 0 ) ) )
00130 return 1;
00131 if ( !( cdText( im, 600, 200, "CGM Draw" ) ) )
00132 return 1;
00133
00134
00135 if ( !( cdSetTextOrient( im, 1, 1, 1, 0 ) ) )
00136 {
00137 return 1;
00138 }
00139 if ( !( cdSetTextAttrib( im, -1, -1, 40 ) ) )
00140 {
00141 return 1;
00142 }
00143 if ( !( cdText( im, 300, 300, "CGM Draw" ) ) )
00144 {
00145 return 1;
00146 }
00147
00148 if ( !( cdLine( im, 300, 300, 500, 300 ) ) )
00149 return 1;
00150 if ( !( cdLine( im, 300, 300, 340, 340 ) ) )
00151 return 1;
00152
00153
00154 if ( !( cdSetTextOrient( im, 0, 1, 1, 0 ) ) )
00155 return 1;
00156
00157
00158 if ( !( cdSetTextAttrib( im, 5, -1, 20 ) ) )
00159 return 1;
00160 if ( !( cdText( im, 5, 5, "G. Edward Johnson" ) ) )
00161 return 1;
00162
00163
00164 outf = fopen( "cdtext.cgm", "wb" );
00165 if ( !outf )
00166 return 1;
00167 cdImageCgm( im, outf );
00168 fclose( outf );
00169 outf = 0;
00170
00171
00172 cdImageDestroy( im );
00173 im = 0;
00174
00175 printf( "CGM Text Example!!!\n" );
00176
00177 return 0;
00178 }