├── CHANGES ├── COPYING ├── Makefile.am ├── Makefile.in ├── README ├── TODO ├── aclocal.m4 ├── common.c ├── common.h ├── config.h.in ├── config.status ├── configure ├── configure.in ├── g2-0.40 ├── CHANGES ├── COPYING ├── INSTALL ├── Makefile.in ├── README ├── TODO ├── config.guess ├── config.sub ├── configure ├── configure.in ├── demo │ ├── Makefile.in │ ├── demo_f.f │ ├── descrip.mms │ ├── g2_test.c │ ├── penguin.c │ ├── simple_GIF.c │ ├── simple_PS.c │ ├── simple_X11.c │ └── xlink.opt ├── descrip.mms ├── doc │ ├── g2-0.40.lsm │ ├── g2_ref.html │ └── g2_ref.txt ├── g2.dsp ├── g2.dsw ├── g2_perl │ ├── Changes │ ├── G2.pm │ ├── G2.xs │ ├── MANIFEST │ ├── Makefile.PL.in │ ├── test.pl │ └── typemap ├── g2demo.dsp ├── g2res.dsp ├── gd.dsp ├── install-sh └── src │ ├── GIF │ ├── g2_GIF.c │ ├── g2_GIF.h │ ├── g2_GIF_P.h │ └── g2_GIF_funix.h │ ├── PS │ ├── g2_PS.c │ ├── g2_PS.h │ ├── g2_PS_P.h │ ├── g2_PS_definitions.h │ └── g2_PS_funix.h │ ├── Win32 │ ├── g2_Win32.ico │ ├── g2_win32.c │ ├── g2_win32.h │ ├── g2_win32.rc │ ├── g2_win32_P.h │ ├── g2_win32_funix.h │ ├── g2_win32_thread.c │ ├── g2res.c │ └── resource.h │ ├── X11 │ ├── g2.xpm │ ├── g2_X11.c │ ├── g2_X11.h │ ├── g2_X11_P.h │ └── g2_X11_funix.h │ ├── g2.h │ ├── g2_config.h │ ├── g2_control_pd.c │ ├── g2_control_pd.h │ ├── g2_device.c │ ├── g2_device.h │ ├── g2_fif.c │ ├── g2_funix.h │ ├── g2_graphic_pd.c │ ├── g2_graphic_pd.h │ ├── g2_physical_device.c │ ├── g2_physical_device.h │ ├── g2_ui_control.c │ ├── g2_ui_device.c │ ├── g2_ui_graphic.c │ ├── g2_ui_virtual_device.c │ ├── g2_util.c │ ├── g2_util.h │ ├── g2_virtual_device.c │ └── g2_virtual_device.h ├── install-sh ├── missing ├── mkinstalldirs ├── signal.c ├── signal.h ├── tempest_am_X11.c └── tempest_am_svga.c /CHANGES: -------------------------------------------------------------------------------- 1 | /* 2 | * Version 1.0 2001-04-27 3 | * Created the Makefile and configure scripts 4 | * 5 | * Version 0.9 1999-08-23 6 | * Major code improvements 7 | * AM signal calculation improvements 8 | * X11 version draws the picture on screen faster now 9 | * SVGA version displays supported resolutions 10 | * Added PGM (Portable Bitmap) picture file support 11 | * Added square waves support 12 | * 13 | * Version 0.8 1999-08-05 14 | * Initial public release. 15 | * 16 | */ 17 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile.am 3 | # 4 | # Author: Pekka Riikonen 5 | # 6 | # Copyright (C) 2001 Pekka Riikonen 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | 19 | AUTOMAKE_OPTIONS = 1.0 no-dependencies foreign 20 | 21 | SUBDIRS = g2-0.40 22 | 23 | bin_PROGRAMS = tempest_am_svga tempest_am_X11 24 | 25 | tempest_am_svga_SOURCES = \ 26 | tempest_am_svga.c \ 27 | signal.c \ 28 | common.c 29 | 30 | tempest_am_X11_SOURCES = \ 31 | tempest_am_X11.c \ 32 | signal.c \ 33 | common.c 34 | 35 | LDADD = -L./g2-0.40/ -lg2 -L/usr/X11R6/lib -lX11 -lm -lvga -lvgagl 36 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | * Add frame-buffer version of the program. 2 | * Add Frequency Modulation (FM) support. The program uses 3 | currently only Amplitude Modulation (AM). 4 | * Change the name to Tempest-Radio after adding FM support. 5 | -------------------------------------------------------------------------------- /aclocal.m4: -------------------------------------------------------------------------------- 1 | dnl aclocal.m4 generated automatically by aclocal 1.4 2 | 3 | dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. 4 | dnl This file is free software; the Free Software Foundation 5 | dnl gives unlimited permission to copy and/or distribute it, 6 | dnl with or without modifications, as long as this notice is preserved. 7 | 8 | dnl This program is distributed in the hope that it will be useful, 9 | dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without 10 | dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A 11 | dnl PARTICULAR PURPOSE. 12 | 13 | # Do all the work for Automake. This macro actually does too much -- 14 | # some checks are only needed if your package does certain things. 15 | # But this isn't really a big deal. 16 | 17 | # serial 1 18 | 19 | dnl Usage: 20 | dnl AM_INIT_AUTOMAKE(package,version, [no-define]) 21 | 22 | AC_DEFUN(AM_INIT_AUTOMAKE, 23 | [AC_REQUIRE([AC_PROG_INSTALL]) 24 | PACKAGE=[$1] 25 | AC_SUBST(PACKAGE) 26 | VERSION=[$2] 27 | AC_SUBST(VERSION) 28 | dnl test to see if srcdir already configured 29 | if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then 30 | AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) 31 | fi 32 | ifelse([$3],, 33 | AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) 34 | AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])) 35 | AC_REQUIRE([AM_SANITY_CHECK]) 36 | AC_REQUIRE([AC_ARG_PROGRAM]) 37 | dnl FIXME This is truly gross. 38 | missing_dir=`cd $ac_aux_dir && pwd` 39 | AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir) 40 | AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir) 41 | AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir) 42 | AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir) 43 | AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) 44 | AC_REQUIRE([AC_PROG_MAKE_SET])]) 45 | 46 | # 47 | # Check to make sure that the build environment is sane. 48 | # 49 | 50 | AC_DEFUN(AM_SANITY_CHECK, 51 | [AC_MSG_CHECKING([whether build environment is sane]) 52 | # Just in case 53 | sleep 1 54 | echo timestamp > conftestfile 55 | # Do `set' in a subshell so we don't clobber the current shell's 56 | # arguments. Must try -L first in case configure is actually a 57 | # symlink; some systems play weird games with the mod time of symlinks 58 | # (eg FreeBSD returns the mod time of the symlink's containing 59 | # directory). 60 | if ( 61 | set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` 62 | if test "[$]*" = "X"; then 63 | # -L didn't work. 64 | set X `ls -t $srcdir/configure conftestfile` 65 | fi 66 | if test "[$]*" != "X $srcdir/configure conftestfile" \ 67 | && test "[$]*" != "X conftestfile $srcdir/configure"; then 68 | 69 | # If neither matched, then we have a broken ls. This can happen 70 | # if, for instance, CONFIG_SHELL is bash and it inherits a 71 | # broken ls alias from the environment. This has actually 72 | # happened. Such a system could not be considered "sane". 73 | AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken 74 | alias in your environment]) 75 | fi 76 | 77 | test "[$]2" = conftestfile 78 | ) 79 | then 80 | # Ok. 81 | : 82 | else 83 | AC_MSG_ERROR([newly created file is older than distributed files! 84 | Check your system clock]) 85 | fi 86 | rm -f conftest* 87 | AC_MSG_RESULT(yes)]) 88 | 89 | dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY) 90 | dnl The program must properly implement --version. 91 | AC_DEFUN(AM_MISSING_PROG, 92 | [AC_MSG_CHECKING(for working $2) 93 | # Run test in a subshell; some versions of sh will print an error if 94 | # an executable is not found, even if stderr is redirected. 95 | # Redirect stdin to placate older versions of autoconf. Sigh. 96 | if ($2 --version) < /dev/null > /dev/null 2>&1; then 97 | $1=$2 98 | AC_MSG_RESULT(found) 99 | else 100 | $1="$3/missing $2" 101 | AC_MSG_RESULT(missing) 102 | fi 103 | AC_SUBST($1)]) 104 | 105 | -------------------------------------------------------------------------------- /common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * common.c 3 | * 4 | * Copyright (c) 1999 Pekka Riikonen, priikone@poseidon.pspt.fi. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "signal.h" 23 | #include "common.h" 24 | 25 | /* 26 | * Generates Portable Bitmap picture file (type P5 PGM). 27 | */ 28 | void generate_pgm(int o_fp, int o_fh, int o_fv, double o_tone, 29 | double o_carr, int o_res_x, int o_res_y, int o_square) 30 | { 31 | int i, x, y; 32 | double p, R; 33 | Signal ns; 34 | double *signal; 35 | 36 | ns.o_fp = o_fp; 37 | ns.o_fh = o_fh; 38 | ns.o_fv = o_fv; 39 | ns.o_tone = o_tone; 40 | ns.o_carr = o_carr; 41 | ns.o_res_x = o_res_x; 42 | ns.o_res_y = o_res_y; 43 | ns.o_square = o_square; 44 | 45 | signal = (double *)NULL; 46 | signal = generate_am_signal(&ns); 47 | 48 | fprintf(stdout, "P5\n"); 49 | fprintf(stdout, "%d %d 255\n", o_res_x, o_res_y); 50 | 51 | srand((unsigned int)time(0)); 52 | i = 0; 53 | for (y = 0; y < o_res_y; y++) { 54 | for (x = 0; x < o_res_x; x++) { 55 | R = 1+(double) (1.0*rand() / (RAND_MAX+1.0)) - 1; 56 | p = ((double)127.5 + signal[i++]) + R; 57 | if (p < 0) 58 | p = 0; 59 | if (p > 255) 60 | p = 255; 61 | putchar((int)p); 62 | } 63 | } 64 | 65 | fflush(stdout); 66 | 67 | if (signal) 68 | free(signal); 69 | } 70 | -------------------------------------------------------------------------------- /common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * common.h 3 | * 4 | * Copyright (c) 1999 Pekka Riikonen, priikone@poseidon.pspt.fi. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | */ 17 | 18 | #ifndef _COMMON_H 19 | #define _COMMON_H 20 | 21 | void generate_pgm(int o_fp, int o_fh, int o_fv, double o_tone, 22 | double o_carr, int o_res_x, int o_res_y, int o_square); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated automatically from configure.in by autoheader. */ 2 | 3 | /* Define to empty if the keyword does not work. */ 4 | #undef const 5 | 6 | /* Define as __inline if that's what the C compiler calls it. */ 7 | #undef inline 8 | 9 | /* Define if the `S_IS*' macros in do not work properly. */ 10 | #undef STAT_MACROS_BROKEN 11 | 12 | /* Define if you have the ANSI C header files. */ 13 | #undef STDC_HEADERS 14 | 15 | /* Define if you can safely include both and . */ 16 | #undef TIME_WITH_SYS_TIME 17 | 18 | /* Name of package */ 19 | #undef PACKAGE 20 | 21 | /* Version number of package */ 22 | #undef VERSION 23 | 24 | -------------------------------------------------------------------------------- /config.status: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Generated automatically by configure. 3 | # Run this file to recreate the current configuration. 4 | # This directory was configured as follows, 5 | # on host leevi.kuo.fi.ssh.com: 6 | # 7 | # ./configure 8 | # 9 | # Compiler output produced by configure, useful for debugging 10 | # configure, is in ./config.log if it exists. 11 | 12 | ac_cs_usage="Usage: ./config.status [--recheck] [--version] [--help]" 13 | for ac_option 14 | do 15 | case "$ac_option" in 16 | -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) 17 | echo "running ${CONFIG_SHELL-/bin/sh} ./configure --no-create --no-recursion" 18 | exec ${CONFIG_SHELL-/bin/sh} ./configure --no-create --no-recursion ;; 19 | -version | --version | --versio | --versi | --vers | --ver | --ve | --v) 20 | echo "./config.status generated by autoconf version 2.13" 21 | exit 0 ;; 22 | -help | --help | --hel | --he | --h) 23 | echo "$ac_cs_usage"; exit 0 ;; 24 | *) echo "$ac_cs_usage"; exit 1 ;; 25 | esac 26 | done 27 | 28 | ac_given_srcdir=. 29 | ac_given_INSTALL="/usr/bin/install -c" 30 | 31 | trap 'rm -fr Makefile conftest*; exit 1' 1 2 15 32 | 33 | # Protect against being on the right side of a sed subst in config.status. 34 | sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\&%]/\\&/g; 35 | s/@@/%@/; s/@@/@%/; s/@g$/%g/' > conftest.subs <<\CEOF 36 | /^[ ]*VPATH[ ]*=[^:]*$/d 37 | 38 | s%@SHELL@%/bin/sh%g 39 | s%@CFLAGS@%-Wall %g 40 | s%@CPPFLAGS@%%g 41 | s%@CXXFLAGS@%%g 42 | s%@FFLAGS@%%g 43 | s%@DEFS@% -DPACKAGE=\"tempest-AM\" -DVERSION=\"1.0\" -DSTDC_HEADERS=1 -DTIME_WITH_SYS_TIME=1 %g 44 | s%@LDFLAGS@%%g 45 | s%@LIBS@%%g 46 | s%@exec_prefix@%${prefix}%g 47 | s%@prefix@%/usr/local%g 48 | s%@program_transform_name@%s,x,x,%g 49 | s%@bindir@%${exec_prefix}/bin%g 50 | s%@sbindir@%${exec_prefix}/sbin%g 51 | s%@libexecdir@%${exec_prefix}/libexec%g 52 | s%@datadir@%${prefix}/share%g 53 | s%@sysconfdir@%${prefix}/etc%g 54 | s%@sharedstatedir@%${prefix}/com%g 55 | s%@localstatedir@%${prefix}/var%g 56 | s%@libdir@%${exec_prefix}/lib%g 57 | s%@includedir@%${prefix}/include%g 58 | s%@oldincludedir@%/usr/include%g 59 | s%@infodir@%${prefix}/info%g 60 | s%@mandir@%${prefix}/man%g 61 | s%@INSTALL_PROGRAM@%${INSTALL}%g 62 | s%@INSTALL_SCRIPT@%${INSTALL_PROGRAM}%g 63 | s%@INSTALL_DATA@%${INSTALL} -m 644%g 64 | s%@PACKAGE@%tempest-AM%g 65 | s%@VERSION@%1.0%g 66 | s%@ACLOCAL@%aclocal%g 67 | s%@AUTOCONF@%autoconf%g 68 | s%@AUTOMAKE@%automake%g 69 | s%@AUTOHEADER@%autoheader%g 70 | s%@MAKEINFO@%makeinfo%g 71 | s%@SET_MAKE@%%g 72 | s%@CC@%gcc%g 73 | s%@LN_S@%ln -s%g 74 | s%@RANLIB@%ranlib%g 75 | s%@CPP@%gcc -E%g 76 | s%@subdirs@%g2-0.40%g 77 | 78 | CEOF 79 | 80 | # Split the substitutions into bite-sized pieces for seds with 81 | # small command number limits, like on Digital OSF/1 and HP-UX. 82 | ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. 83 | ac_file=1 # Number of current file. 84 | ac_beg=1 # First line for current file. 85 | ac_end=$ac_max_sed_cmds # Line after last line for current file. 86 | ac_more_lines=: 87 | ac_sed_cmds="" 88 | while $ac_more_lines; do 89 | if test $ac_beg -gt 1; then 90 | sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file 91 | else 92 | sed "${ac_end}q" conftest.subs > conftest.s$ac_file 93 | fi 94 | if test ! -s conftest.s$ac_file; then 95 | ac_more_lines=false 96 | rm -f conftest.s$ac_file 97 | else 98 | if test -z "$ac_sed_cmds"; then 99 | ac_sed_cmds="sed -f conftest.s$ac_file" 100 | else 101 | ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" 102 | fi 103 | ac_file=`expr $ac_file + 1` 104 | ac_beg=$ac_end 105 | ac_end=`expr $ac_end + $ac_max_sed_cmds` 106 | fi 107 | done 108 | if test -z "$ac_sed_cmds"; then 109 | ac_sed_cmds=cat 110 | fi 111 | 112 | CONFIG_FILES=${CONFIG_FILES-"Makefile"} 113 | for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then 114 | # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". 115 | case "$ac_file" in 116 | *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` 117 | ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; 118 | *) ac_file_in="${ac_file}.in" ;; 119 | esac 120 | 121 | # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. 122 | 123 | # Remove last slash and all that follows it. Not all systems have dirname. 124 | ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` 125 | if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then 126 | # The file is in a subdirectory. 127 | test ! -d "$ac_dir" && mkdir "$ac_dir" 128 | ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" 129 | # A "../" for each directory in $ac_dir_suffix. 130 | ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` 131 | else 132 | ac_dir_suffix= ac_dots= 133 | fi 134 | 135 | case "$ac_given_srcdir" in 136 | .) srcdir=. 137 | if test -z "$ac_dots"; then top_srcdir=. 138 | else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; 139 | /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; 140 | *) # Relative path. 141 | srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" 142 | top_srcdir="$ac_dots$ac_given_srcdir" ;; 143 | esac 144 | 145 | case "$ac_given_INSTALL" in 146 | [/$]*) INSTALL="$ac_given_INSTALL" ;; 147 | *) INSTALL="$ac_dots$ac_given_INSTALL" ;; 148 | esac 149 | 150 | echo creating "$ac_file" 151 | rm -f "$ac_file" 152 | configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." 153 | case "$ac_file" in 154 | *Makefile*) ac_comsub="1i\\ 155 | # $configure_input" ;; 156 | *) ac_comsub= ;; 157 | esac 158 | 159 | ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` 160 | sed -e "$ac_comsub 161 | s%@configure_input@%$configure_input%g 162 | s%@srcdir@%$srcdir%g 163 | s%@top_srcdir@%$top_srcdir%g 164 | s%@INSTALL@%$INSTALL%g 165 | " $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file 166 | fi; done 167 | rm -f conftest.s* 168 | 169 | 170 | 171 | exit 0 172 | -------------------------------------------------------------------------------- /configure.in: -------------------------------------------------------------------------------- 1 | # 2 | # configure.in 3 | # 4 | # Author: Pekka Riikonen 5 | # 6 | # Copyright (C) 2001 Pekka Riikonen 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | 19 | AC_INIT(common.c) 20 | 21 | # Compiler settings 22 | CFLAGS="-Wall $CFLAGS" 23 | 24 | AM_INIT_AUTOMAKE(tempest-AM, 1.0) 25 | AC_PREREQ(2.3) 26 | 27 | AC_PROG_CC 28 | AC_C_INLINE 29 | AC_C_CONST 30 | AC_ARG_PROGRAM 31 | 32 | AC_PROG_LN_S 33 | AC_SUBST(LN_S) 34 | 35 | # Program checking 36 | AC_PROG_INSTALL 37 | AC_PROG_RANLIB 38 | AC_PROG_MAKE_SET 39 | 40 | # Header checking 41 | AC_HEADER_STDC 42 | AC_HEADER_TIME 43 | AC_HEADER_STAT 44 | 45 | AC_CONFIG_SUBDIRS(g2-0.40) 46 | 47 | AC_OUTPUT(Makefile) 48 | -------------------------------------------------------------------------------- /g2-0.40/CHANGES: -------------------------------------------------------------------------------- 1 | 0.40 () 2 | ======= 3 | - added perl support 4 | - g2_draw_string replaced with g2_string 5 | - added g2_image function 6 | - added g2_control_pd.* files 7 | - g2_device_exist moved to user space (perl) 8 | - added g2_set_line_width support in GIF device 9 | - added prefix to Makefile.in 10 | - updated descrip.mms 11 | 12 | 0.30 (23.10.1998) 13 | ================ 14 | - finished Win32 implementation 15 | - fixed bug in virtual device section 16 | - minor changes in g2_X11.c (include string.h) 17 | - finished VMS port (descrip.mms files) 18 | 19 | 0.23 (09.07.1998) 20 | ================= 21 | - finished Fortran interface (tested on Linux and DU) 22 | - added arc and filled_arc emulation 23 | - minor bug fix in g2_ui_control.c (thanks to E.M. (Mark) Palandri) 24 | - finished GIF interface 25 | - added new demo files 26 | - some bug fixes 27 | 28 | 0.22 (03.06.1998) 29 | ================= 30 | - bugfix in g2_device.c 31 | - minor changes 32 | 33 | 0.21 (03.06.1998) 34 | ================= 35 | - added g2_ld (last device) concept 36 | - minor changes in make procedures 37 | - back to the normal 'numbering' :-) 38 | - added (very simple) demo0.c 39 | 40 | 0.20a (02.06.1998) 41 | ================== 42 | - added configure script 43 | - changed file/make structure of g2 project 44 | - changed version numbering (a-alpha, b-beta etc.) 45 | 46 | 0.11 (30.04.1998) 47 | ================= 48 | - fixed bug in Makefile 49 | - fixed bug with r rescaling (circle, ellipse and arc) in g2_graphic_pd.c 50 | - small fix in g2_X11 51 | - added g2_us2pds_xxxx in g2_util.c 52 | - minor changes in makefile.i386 and makefile.alpha 53 | 54 | 0.10 (24.04.1998) 55 | ================= 56 | - major kernel rewrite 57 | - small fixes in X11 part 58 | - removed funix: g2_AllocateBasicColors 59 | - added Fortran interface (alpha) 60 | 61 | 0.02 (31.03.1998) 62 | ================= 63 | - new funix: g2_Save 64 | - added contrib directory 65 | 66 | 67 | 0.01 (19.03.1998) 68 | ================= 69 | - created CHANGES file :-) 70 | - some small fixes 71 | - added g2_attach_X11X and changed g2_attach_X11 to be a wrapper to 72 | the new function 73 | - added PostScript interface 74 | 75 | -------------------------------------------------------------------------------- /g2-0.40/INSTALL: -------------------------------------------------------------------------------- 1 | Installation 2 | ============ 3 | 4 | LINUX 5 | ----- 6 | 7 | Either install RPM packet with binaries, or compile as described in the 8 | UNIX section 9 | 10 | UNIX 11 | ---- 12 | 13 | 1. Extract package with gzip -dc g2-xxxx.tar.gz | tar xvf - 14 | 15 | 2. Run './configure' 16 | 17 | 3. Optionally run 'make depend' 18 | 19 | 4. Run 'make' 20 | 21 | 5. Run 'make install' or copy libg2.a and g2.h, g2_X11.h, g2_GIF.h, and 22 | g2_PS.h to the default locations for library and include files. 23 | 24 | 6. Optional: run 'make demo' to compile demo applications 25 | 26 | 27 | WINDOWS NT 28 | ---------- 29 | 30 | 1. Extract package: unzip 'g2-xxxx.zip' 31 | 32 | 2. MS Visual C++ users can build both library and demos with the supplied 33 | project file: g2.xxx 34 | users of gcc or other commandline based compilers with make support 35 | continue as in Unix example 36 | 37 | 38 | VMS 39 | --- 40 | 41 | 1. set default to root of distribution directory 42 | 43 | 2. type mms to build g2.olb library 44 | 45 | 3. to compile demo files, set defualt to [.demo] and type mms 46 | 47 | 4. to install: copy g2.olb and g2.h, g2_X11.h and g2_PS.h to install 48 | directories 49 | 50 | 51 | GIF-SUPPORT 52 | ----------- 53 | 54 | g2 needs to be linked to the free available gd library written by 55 | Thomas Boutell in order to create GIF files. g2 is tested with 56 | version 1.3 of gd. gd is available at http://www.boutell.com/gd/ and 57 | at numerous mirror sites. Use a ftp search 58 | (e.g. http://ftpsearch.ntnu.no/) and search for "gd1.3.tar.gz" to find 59 | your nearest mirror site. 60 | 61 | 62 | PERL SUPPORT 63 | ------------ 64 | 1. build g2 library 65 | 2. cd to g2_perl and run 66 | perl Makefile.PL 67 | make 68 | make test 69 | -------------------------------------------------------------------------------- /g2-0.40/Makefile.in: -------------------------------------------------------------------------------- 1 | # 2 | # 3 | # Makefile for g2 library 4 | # 5 | # 6 | 7 | # 8 | # g2 installation directories 9 | # 10 | LIBDIR = @prefix@/lib 11 | INCDIR = @prefix@/include 12 | 13 | #LIBDIR = $(HOME)/local/lib 14 | #INCDIR = $(HOME)/local/include 15 | 16 | # 17 | #------------------------ do not edit ------------------------ 18 | # 19 | SHELL = /bin/sh 20 | 21 | CC = @CC@ 22 | CFLAGS = -I./src @CFLAGS@ @DEFS@ 23 | INSTALL = @INSTALL@ 24 | INSTALL_DATA = @INSTALL_DATA@ 25 | FIND = @FIND@ 26 | MAKEDEPEND = @MAKEDEPEND@ 27 | AR = ar 28 | ARFLAGS = -rs 29 | 30 | BASE_DIR = ./src 31 | BASE_SRC = $(BASE_DIR)/g2_device.c $(BASE_DIR)/g2_ui_control.c \ 32 | $(BASE_DIR)/g2_util.c $(BASE_DIR)/g2_fif.c \ 33 | $(BASE_DIR)/g2_virtual_device.c $(BASE_DIR)/g2_physical_device.c \ 34 | $(BASE_DIR)/g2_graphic_pd.c $(BASE_DIR)/g2_control_pd.c \ 35 | $(BASE_DIR)/g2_ui_graphic.c $(BASE_DIR)/g2_ui_virtual_device.c \ 36 | $(BASE_DIR)/g2_ui_device.c 37 | BASE_INS = $(BASE_DIR)/g2.h 38 | 39 | 40 | @DO_PS@PS_DIR = ./src/PS 41 | @DO_PS@PS_SRC = $(PS_DIR)/g2_PS.c 42 | @DO_PS@PS_INS = $(PS_DIR)/g2_PS.h 43 | 44 | 45 | @DO_X11@X11_DIR = ./src/X11 46 | @DO_X11@X11_SRC = $(X11_DIR)/g2_X11.c 47 | @DO_X11@X11_INS = $(X11_DIR)/g2_X11.h 48 | 49 | 50 | @DO_GIF@GIF_DIR = ./src/GIF 51 | @DO_GIF@GIF_SRC = $(GIF_DIR)/g2_GIF.c 52 | @DO_GIF@GIF_INS = $(GIF_DIR)/g2_GIF.h 53 | 54 | 55 | SRC = $(BASE_SRC) $(PS_SRC) $(X11_SRC) $(GIF_SRC) 56 | OBJ = $(SRC:.c=.o) 57 | 58 | INS = $(BASE_INS) $(PS_INS) $(X11_INS) $(GIF_INS) 59 | 60 | .c.o: 61 | $(CC) $(CFLAGS) -c $< -o $@ 62 | 63 | 64 | all: libg2.a 65 | test -d ./include || mkdir ./include 66 | cp $(INS) ./include/ 67 | 68 | shared: libg2.so 69 | @echo 70 | 71 | libg2.a: $(OBJ) 72 | $(AR) $(ARFLAGS) libg2.a $(OBJ) 73 | ln -s libg2.a libg2.0.40.a 74 | 75 | libg2.so: $(OBJ) 76 | $(CC) -shared -o libg2.so $(OBJ) -lc -lm 77 | 78 | install: libg2.a 79 | test -d $(LIBDIR) || mkdir -p $(LIBDIR) 80 | test -d $(INCDIR) || mkdir -p $(INCDIR) 81 | $(INSTALL_DATA) libg2.a $(LIBDIR) 82 | for IFILE in $(INS); do \ 83 | $(INSTALL_DATA) $$IFILE $(INCDIR); \ 84 | done 85 | 86 | clean: 87 | -(cd ./demo ; make clean) 88 | -rm -f $(OBJ) 89 | -rm -f libg2.a config.cache config.log Makefile.bak config.status 90 | -rm -f ./include/*.h 91 | -$(FIND) . -name "*~" -exec rm -f {} \; 92 | -(cd ./g2_perl ; make clean) 93 | -rm -f ./g2_perl/test.ps ./g2_perl/test.gif 94 | -rm -f ./libg2.0.40.a 95 | 96 | demo: libg2.a 97 | (cd ./demo ; make) 98 | 99 | depend: 100 | $(MAKEDEPEND) -- $(CFLAGS) -- $(SRC) 101 | @echo 102 | @echo "Run 'make' to build g2 library." 103 | @echo 104 | 105 | 106 | # DO NOT DELETE THIS LINE -- make depend depends on it. 107 | 108 | -------------------------------------------------------------------------------- /g2-0.40/README: -------------------------------------------------------------------------------- 1 | g2 - graphic library (C) 1999 Lj. Milanovic, H. Wagner 2 | 3 | Version 0.40 4 | 5 | License Information 6 | =================== 7 | 8 | This program is covered with GNU General Public License (GPL) and 9 | _not_ with GNU Library General Public License (LGPL)! It is allowed 10 | only for GPL programs to use (static/dynamic linkage or any other 11 | using of code) g2 library. If you want to develop a non GPL 12 | application and to use g2 please contact the authors. 13 | 14 | see INSTALL for information on how to install g2 see the html 15 | documentation in the doc/ subdirectory for a function reference 16 | 17 | What is g2 ? 18 | ============ 19 | 20 | Short version (if you are in hurry): 21 | 22 | 2D graphic library 23 | Simple to use 24 | Supports several types of output devices (currently X11, GIF, PostScript) 25 | Concept allows easy implementation of new device types 26 | Virtual devices allow to send output simultaneously to several devices 27 | User definable coordinate system 28 | Written in ANSI-C 29 | Tested under Digital Unix, AIX, Linux, VMS and Windows NT 30 | Fortran interface 31 | 32 | Long version: 33 | 34 | g2 is a simple to use graphics library for 2D graphical applications 35 | written in Ansi-C. This library provides a comprehensive set of 36 | functions for simultaneous generation of graphical output on different 37 | types of devices. Presently, following devices are currently supported 38 | by g2: X11, GIF, PostScript (xfig and Win32 are in developement). One 39 | major feature of the g2_library is the concept of virtual devices. An 40 | arbitrary number of physical devices (such as GIF, or X11) can be 41 | grouped to create a so-called virtual device. Commands sent to such a 42 | virtual devices will automatically issued to all attached physical 43 | devices. This allows for example simultaneous output to a GIF file and 44 | a Postscript file. A virtual device in turn can be attached to another 45 | virtual device, allowing to construct trees of devices. Virtual 46 | devices can also be useful when using different user-coordinate 47 | systems. E.g. one X11 window showing an overview of a graphical 48 | output, and a second window showing a zoom of a more detailed area of 49 | the graphic. Drawing in both windows is performed by one single 50 | command to the virtual device. 51 | 52 | 53 | /-------> GIF: g2_attach(id_GIF,... 54 | ----------------------- 55 | g2_plot---> | Virtual device: id |--------> X11: g2_attach(id_X11,... 56 | ----------------------- 57 | \-------> PS: g2_attach(id_PS,... 58 | 59 | If you don't need or like the concept of virtual devices, simply ignore it. 60 | 61 | CONTACT 62 | ======= 63 | 64 | You can contact the authors by e-mail: 65 | 66 | ljubo@ap.univie.ac.at 67 | wagner@iap.tuwien.ac.at 68 | 69 | or visit g2 home page on: 70 | 71 | http://www.ap.univie.ac.at/users/ljubo/g2/g2.shtml 72 | 73 | -------------------------------------------------------------------------------- /g2-0.40/TODO: -------------------------------------------------------------------------------- 1 | 2 | - native g2_image support 3 | - GIF: setlinedash 4 | - finish xfig support 5 | - test (and add) Fortran interface on more platforms 6 | - new devices (e.g. PNG, JPG, etc.) 7 | - documentation for developement of new devices 8 | 9 | -------------------------------------------------------------------------------- /g2-0.40/configure.in: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # Check for one project file 4 | # 5 | AC_INIT(src/g2_device.c) 6 | 7 | PRODUCT=g2 8 | 9 | # 10 | # check cannonical system name 11 | # 12 | AC_CANONICAL_HOST 13 | case "$host" in 14 | *-linux-gnu ) AC_DEFINE(LINUX) ;; 15 | *-aix* ) AC_DEFINE(AIX) ;; 16 | * ) AC_DEFINE(UNIX) ;; 17 | esac 18 | 19 | # 20 | # check C compiler, preprocesor, etc. 21 | # 22 | AC_PROG_CC 23 | AC_PROG_CPP 24 | AC_PROG_INSTALL 25 | AC_CHECK_PROG(FIND, find, find, :) 26 | AC_CHECK_PROG(MAKEDEPEND, makedepend, makedepend, :) 27 | 28 | # 29 | # Try to locate the X Window System include files and libraries 30 | # and add /usr/local to include and lib path and add -lm (for testing) 31 | # 32 | AC_PATH_XTRA 33 | CFLAGS="$CFLAGS $X_CFLAGS -I/usr/local/include" 34 | LDFLAGS="$LDFLAGS $X_LIBS -L/usr/local/lib" 35 | 36 | 37 | DO_PS="#" 38 | DO_X11="#" 39 | DO_GIF="#" 40 | 41 | AC_CHECK_LIB(m, main, DO_PS=""; LDFLAGS="$LDFLAGS -lm";AC_DEFINE(DO_PS), break) 42 | AC_CHECK_LIB(X11, main, DO_X11="";LDFLAGS="$LDFLAGS -lX11";AC_DEFINE(DO_X11)) 43 | AC_CHECK_LIB(gd, main, DO_GIF="";LDFLAGS="$LDFLAGS -lgd";AC_DEFINE(DO_GIF)) 44 | 45 | # 46 | # Declare variables which we want substituted in the Makefile.in's 47 | # 48 | AC_SUBST(DO_PS) 49 | AC_SUBST(DO_X11) 50 | AC_SUBST(DO_GIF) 51 | 52 | 53 | AC_HEADER_STDC 54 | AC_CHECK_HEADERS(limits.h) 55 | 56 | 57 | # 58 | # finally create makefiles using Makefile.in 59 | # 60 | echo 61 | AC_OUTPUT(Makefile demo/Makefile g2_perl/Makefile.PL) 62 | 63 | #echo 64 | #echo "Run 'make depend' to create dependencies." 65 | #echo 66 | -------------------------------------------------------------------------------- /g2-0.40/demo/Makefile.in: -------------------------------------------------------------------------------- 1 | # 2 | # 3 | # Makefile for g2_library (demo) 4 | # 5 | # 6 | 7 | 8 | CC = @CC@ 9 | 10 | CFLAGS = -I../src -I../src/X11 -I../src/PS -I../src/GIF @CFLAGS@ @DEFS@ 11 | LDFLAGS = -L.. -lg2 @LDFLAGS@ 12 | 13 | @DO_PS@DEMO_PS = simple_PS 14 | @DO_X11@DEMO_X11 = simple_X11 15 | @DO_GIF@DEMO_GIF = simple_GIF 16 | 17 | DEMO = g2_test $(DEMO_PS) $(DEMO_X11) $(DEMO_GIF) 18 | 19 | all: $(DEMO) 20 | 21 | demo: $(DEMO) 22 | 23 | 24 | g2_test: g2_test.c 25 | $(CC) $(CFLAGS) g2_test.c $(LDFLAGS) -o $@ 26 | 27 | simple_PS: simple_PS.c 28 | $(CC) $(CFLAGS) simple_PS.c $(LDFLAGS) -o $@ 29 | 30 | simple_X11: simple_X11.c 31 | $(CC) $(CFLAGS) simple_X11.c $(LDFLAGS) -o $@ 32 | 33 | simple_GIF: simple_GIF.c 34 | $(CC) $(CFLAGS) simple_GIF.c $(LDFLAGS) -o $@ 35 | 36 | 37 | 38 | demo_f: demo_f.f 39 | f77 -i8 demo_f.f $(LDFLAGS) -o $@ 40 | 41 | 42 | clean: 43 | -rm $(DEMO) demo_f *~ core *.ps *.gif 44 | 45 | 46 | -------------------------------------------------------------------------------- /g2-0.40/demo/demo_f.f: -------------------------------------------------------------------------------- 1 | real demo_f 2 | real a, b 3 | real d, d1, d2 4 | real color 5 | 6 | d=g2_open_vd() 7 | write (6,*) d 8 | d1=g2_open_X11(100.0, 100.0) 9 | write (6,*) d1 10 | d2=g2_open_PS('demo_f.ps', 4.0, 1.0) 11 | write (6,*) d2 12 | 13 | call g2_attach(d, d1) 14 | call g2_attach(d, d2) 15 | 16 | call g2_plot(d, 50.0, 50.0) 17 | call g2_arc(d, 50.0, 50.0, 30.0, 20.0, 45.0, 180.0) 18 | 19 | color=g2_ink(d1, 1.0, 0.0, 0.0) 20 | call g2_pen(d1, color) 21 | write (6,*) color 22 | call g2_string(d1, 15.0, 75.0, 'TEST (Window)') 23 | 24 | color=g2_ink(d2, 0.0, 1.0, 0.0) 25 | call g2_pen(d2, color) 26 | write (6,*) color 27 | call g2_string(d2, 15.0, 75.0, 'TEST (File)') 28 | 29 | call g2_pen(d, 1.0) 30 | call g2_circle(d, 20.0, 20.0, 10.0) 31 | call g2_string(d, 20.0, 20.0, 'All devices!') 32 | call g2_flush(d) 33 | 34 | call g2_close(d2) 35 | 36 | read (*,*) a 37 | 38 | stop 39 | end 40 | 41 | 42 | -------------------------------------------------------------------------------- /g2-0.40/demo/descrip.mms: -------------------------------------------------------------------------------- 1 | ! 2 | ! VMS descrip.mms for g2 demos 3 | ! 4 | 5 | .IFDEF debug 6 | CC_FLAGS = /noopt/debug/nolist/warnings \ 7 | /include_directory=([-.src],[-.src.X11],[-.src.PS]) \ 8 | /define=(DO_PS=1, DO_X11=1) 9 | LINK_FLAGS = 10 | .ELSE 11 | CC_FLAGS = /nolist/warnings \ 12 | /include_directory=([-.src],[-.src.X11],[-.src.PS]) \ 13 | /define=(DO_PS=1, DO_X11=1) 14 | LINK_FLAGS = 15 | .ENDIF 16 | 17 | ! 18 | ! Rules 19 | ! 20 | .c.obj : ; cc $(CC_FLAGS)/obj=$(mms$target) $(mms$source) 21 | 22 | 23 | ! 24 | ! exe files 25 | ! 26 | all : g2_test.exe, simple_X11.exe, simple_PS.exe 27 | @ write sys$output "Demo files compiled." 28 | 29 | 30 | g2_test.exe : g2_test.obj 31 | link $(LINK_FLAGS)/exe=g2_test.exe g2_test.obj, \ 32 | [-]g2.olb/lib, []xlink.opt/opt 33 | 34 | simple_X11.exe : simple_X11.obj 35 | link $(LINK_FLAGS)/exe=simple_X11.exe simple_X11.obj, \ 36 | [-]g2.olb/lib, []xlink.opt/opt 37 | 38 | simple_PS.exe : simple_PS.obj 39 | link $(LINK_FLAGS)/exe=simple_PS.exe simple_PS.obj, [-]g2.olb/lib 40 | 41 | 42 | 43 | clean : 44 | delete *.exe;* , *.obj;* , *.olb;* 45 | 46 | 47 | ! 48 | ! Dependencies 49 | ! 50 | g2_test.obj : g2_test.c 51 | simple_X11.obj : simple_X11.c 52 | simple_PS.obj : simple_PS.c 53 | -------------------------------------------------------------------------------- /g2-0.40/demo/g2_test.c: -------------------------------------------------------------------------------- 1 | 2 | /***************************************************************************** 3 | ** This is part of the g2 library 4 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 5 | ** 6 | ** This program is free software; you can redistribute it and/or modify 7 | ** it under the terms of the GNU General Public License (version 2) as 8 | ** published by the Free Software Foundation. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | ******************************************************************************/ 19 | 20 | #include 21 | #include 22 | 23 | #ifdef DO_PS 24 | #include 25 | #endif 26 | #ifdef DO_X11 27 | #include 28 | #endif 29 | #ifdef DO_GIF 30 | #include 31 | #endif 32 | #ifdef DO_WIN32 33 | #include 34 | #endif 35 | #ifdef DO_WMF32 36 | #include 37 | #endif 38 | 39 | #define ndev 5 40 | 41 | int main() 42 | { 43 | int i, j; 44 | int d, dev[ndev]={-1, -1, -1, -1, -1}; 45 | char str[256]; 46 | double pts[10]; 47 | double y; 48 | #include "penguin.c" 49 | int image[64]={ 0, 0, 2, 2, 2, 2, 0, 0, 50 | 0, 2, 0, 0, 0, 0, 2, 0, 51 | 2, 0, 3, 0, 0, 3, 0, 2, 52 | 2, 0, 0, 0, 0, 0, 0, 2, 53 | 2, 3, 0, 0, 0, 0, 3, 2, 54 | 2, 0, 3, 3, 3, 3, 0, 2, 55 | 0, 2, 0, 0, 0, 0, 2, 0, 56 | 0, 0, 2, 2, 2, 2, 0, 0 }; 57 | d=g2_open_vd(); /* open virtual device */ 58 | 59 | printf("\nAdding.."); 60 | 61 | #ifdef DO_PS 62 | printf("..PS"); 63 | dev[0]=g2_open_PS("g2_test.ps", g2_A4, g2_PS_land); 64 | g2_attach(d, dev[0]); 65 | #endif 66 | #ifdef DO_X11 67 | printf("..X11"); 68 | dev[1]=g2_open_X11(775, 575); 69 | g2_attach(d, dev[1]); 70 | #endif 71 | #ifdef DO_GIF 72 | printf("..GIF"); 73 | dev[2]=g2_open_GIF("g2_test.gif", 775, 575); 74 | g2_attach(d, dev[2]); 75 | #endif 76 | #ifdef DO_WIN32 77 | printf("..WIN32"); 78 | dev[3]=g2_open_win32(775, 575,"g2_test",0); 79 | g2_set_auto_flush(dev[3],0); 80 | g2_attach(d, dev[3]); 81 | #endif 82 | #ifdef DO_WMF32 83 | printf("..WMF32"); 84 | dev[4]=g2_open_win32(775, 575,"g2_test.emf",1); 85 | g2_set_auto_flush(dev[3],0); 86 | g2_attach(d, dev[4]); 87 | #endif 88 | g2_set_auto_flush(d,0); 89 | 90 | printf("\n"); 91 | 92 | /* g2_set_coordinate_system(d, 775, 575, -0.75, -1.0); */ 93 | 94 | for(i=0;i<27;i++) { 95 | g2_pen(d, i); 96 | g2_filled_circle(d, i*20+10, 10, 10); 97 | g2_pen(d, 1); 98 | g2_circle(d, i*20+10, 10, 10); 99 | sprintf(str, "%d", i); 100 | g2_string(d, i*20+7, 21, str); 101 | } 102 | 103 | for(j=0;j=0) 105 | for(i=0;i<=64;i++) { 106 | g2_move(dev[j], 2*i+575, 5); 107 | g2_pen(dev[j], g2_ink(dev[j], i/64., 0, 0)); 108 | g2_line_r(dev[j], 0, 20); 109 | g2_pen(dev[j], g2_ink(dev[j], 0, i/64., 0)); 110 | g2_line_r(dev[j], 10, 20); 111 | g2_pen(dev[j], g2_ink(dev[j], 0, 0, i/64.)); 112 | g2_line_r(dev[j], -10, 20); 113 | } 114 | 115 | g2_pen(d, 1); 116 | g2_line(d, 200, 50, 350, 50); 117 | g2_line(d, 200, 48, 350, 48); 118 | g2_line(d, 200, 46, 350, 46); 119 | g2_line(d, 200, 46, 200, 75); 120 | g2_line(d, 198, 46, 198, 75); 121 | g2_line(d, 196, 46, 196, 75); 122 | g2_string(d, 200, 50, "012abcABC#())(\\-+~*!$%&"); 123 | 124 | g2_pen(d, 1); 125 | for(i=1;i<25;i++) { 126 | g2_line(d, 15, i*20+50, 15, i*20+50+i); 127 | g2_set_font_size(d, 12); 128 | sprintf(str, "%2d:", i); 129 | g2_string(d, 20, i*20+50, str); 130 | g2_set_font_size(d, i); 131 | g2_string(d, 40, i*20+50, "hello, world"); 132 | } 133 | 134 | g2_plot(d, 150, 70); 135 | g2_line(d, 147, 68, 153, 68); 136 | 137 | y=100; 138 | g2_line(d, 100, y, 150, y+50); 139 | g2_triangle(d, 150, y, 250, y, 200, y+50); 140 | g2_rectangle(d, 300, y, 400, y+50); 141 | g2_circle(d, 450, y+25, 25); 142 | g2_ellipse(d, 550, y+25, 45, 25); 143 | g2_arc(d, 650, y+25, 25, 45, 90, 360); 144 | 145 | y=200; 146 | g2_filled_triangle(d, 150, y, 250, y, 200, y+50); 147 | g2_filled_rectangle(d, 300, y, 400, y+50); 148 | g2_filled_circle(d, 450, y+25, 25); 149 | g2_filled_ellipse(d, 550, y+25, 45, 25); 150 | g2_filled_arc(d, 650, y+25, 25, 45, 90, 360); 151 | 152 | 153 | y=300; 154 | pts[0]=150; pts[1]=y; 155 | pts[2]=175; pts[3]=y+100; 156 | pts[4]=200; pts[5]=y; 157 | pts[6]=225; pts[7]=y+100; 158 | pts[8]=250; pts[9]=y; 159 | g2_poly_line(d, 5, pts); 160 | 161 | pts[0]=300; pts[1]=y; 162 | pts[2]=350; pts[3]=y; 163 | pts[4]=375; pts[5]=y+50; 164 | pts[6]=325; pts[7]=y+90; 165 | pts[8]=275; pts[9]=y+50; 166 | g2_polygon(d, 5, pts); 167 | 168 | pts[0]=450; pts[1]=y; 169 | pts[2]=500; pts[3]=y; 170 | pts[4]=525; pts[5]=y+50; 171 | pts[6]=475; pts[7]=y+90; 172 | pts[8]=425; pts[9]=y+50; 173 | g2_filled_polygon(d, 5, pts); 174 | 175 | 176 | g2_image(d, 55., 50., 53, 62, penguin); 177 | g2_image(d, 75., 130., 53, 62, penguin); 178 | g2_pen(d, 1); 179 | 180 | g2_line(d, 225, 448, 200+19*25, 448); 181 | for(i=1;i<20;i++) { 182 | g2_pen(d,i+1); 183 | g2_set_line_width(d, i); 184 | g2_move(d, 200+i*25, 450); 185 | g2_line_to(d, 200+i*25, 550); 186 | } 187 | g2_pen(d,1); 188 | 189 | g2_set_line_width(d, 5); 190 | for(i=1;i<10;i++) { 191 | pts[0]=1*i; 192 | pts[1]=2*i; 193 | pts[2]=3*i; 194 | g2_set_dash(d, 3, pts); 195 | g2_line(d, 550, 300+i*8, 750, 350+i*8); 196 | } 197 | 198 | g2_set_dash(d, 0, NULL); 199 | g2_set_line_width(d, 5); 200 | g2_arc(d, 740, 180, 25, 100, -45+15, -45-15); 201 | g2_filled_arc(d, 740, 180, 12, 50, -45+15, -45-15); 202 | 203 | g2_flush(d); 204 | printf("\nDone.\n[Enter]\n"); 205 | getchar(); 206 | g2_close(d); 207 | return 0; 208 | } 209 | 210 | 211 | 212 | 213 | 214 | -------------------------------------------------------------------------------- /g2-0.40/demo/simple_GIF.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | int d; 7 | d=g2_open_GIF("simple.gif", 100, 100); 8 | g2_line(d, 10, 10, 90, 90); 9 | g2_close(d); 10 | return 0; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /g2-0.40/demo/simple_PS.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | int d; 7 | d=g2_open_PS("simple.ps", g2_A4, g2_PS_port); 8 | g2_line(d, 10, 10, 90, 90); 9 | g2_close(d); 10 | return 0; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /g2-0.40/demo/simple_X11.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | int d; 8 | int i; 9 | 10 | d=g2_open_X11(1024, 768); 11 | 12 | for (i = 0; i < 255; i++) { 13 | g2_pen(d, g2_ink(d, i/255., i/255., i/255.)); 14 | g2_plot(d, 0 + i, 600); 15 | g2_plot(d, 0 + i, 601); 16 | g2_plot(d, 0 + i, 602); 17 | } 18 | getchar(); 19 | } 20 | 21 | -------------------------------------------------------------------------------- /g2-0.40/demo/xlink.opt: -------------------------------------------------------------------------------- 1 | sys$share:decw$xlibshr/share 2 | -------------------------------------------------------------------------------- /g2-0.40/descrip.mms: -------------------------------------------------------------------------------- 1 | ! 2 | ! VMS descrip.mms for g2 3 | ! 4 | 5 | .IFDEF debug 6 | CC_FLAGS = /noopt/debug/nolist/warnings/include_directory=("./src") \ 7 | /define=(DO_PS=1, DO_X11=1) 8 | .ELSE 9 | CC_FLAGS = /nolist/warnings/include_directory=("./src") \ 10 | /define=(DO_PS=1, DO_X11=1) 11 | .ENDIF 12 | 13 | ! 14 | ! Object files 15 | ! 16 | OBJ = [.src]g2_device.obj, [.src]g2_fif.obj, [.src]g2_graphic_pd.obj, \ 17 | [.src]g2_physical_device.obj, [.src]g2_ui_control.obj, \ 18 | [.src]g2_ui_device.obj, [.src]g2_ui_graphic.obj, \ 19 | [.src]g2_ui_virtual_device.obj, [.src]g2_util.obj, \ 20 | [.src]g2_virtual_device.obj, [.src]g2_control_pd.obj 21 | OBJ_X11 = [.src.X11]g2_X11.obj 22 | OBJ_PS = [.src.PS]g2_PS.obj 23 | 24 | HEADERS = [.src]g2.h, [.src]g2_config.h, [.src]g2_device.h, \ 25 | [.src]g2_funix.h, [.src]g2_graphic_pd.h, \ 26 | [.src]g2_physical_device.h, [.src]g2_util.h, \ 27 | [.src]g2_virtual_device.h, [.src]g2_control_pd.h 28 | HEADERS_X11 = [.src.X11]g2_X11.h, [.src.X11]g2_X11_P.h, \ 29 | [.src.X11]g2_X11_funix.h 30 | HEADERS_PS = [.src.PS]g2_PS.h, [.src.PS]g2_PS_P.h, \ 31 | [.src.PS]g2_PS_definitions.h, [.src.PS]g2_PS_funix.h 32 | ! 33 | ! Rules 34 | ! 35 | .c.obj : ; cc $(CC_FLAGS)/obj=$(mms$target) $(mms$source) 36 | 37 | 38 | all : g2.olb 39 | @ write sys$output "Done." 40 | 41 | g2.olb : $(OBJ) $(OBJ_X11) $(OBJ_PS) 42 | library/create g2.olb $(OBJ), $(OBJ_X11), $(OBJ_PS) 43 | 44 | clean : 45 | delete [...]*.exe;* , [...]*.obj;* , [...]*.olb;* 46 | 47 | 48 | ! 49 | ! Dependencies 50 | ! 51 | [.src]g2_device.obj : [.src]g2_device.c $(HEADERS) 52 | [.src]g2_fif.obj : [.src]g2_fif.c $(HEADERS) 53 | [.src]g2_graphic_pd.obj : [.src]g2_graphic_pd.c $(HEADERS) 54 | [.src]g2_physical_device.obj : [.src]g2_physical_device.c $(HEADERS) 55 | [.src]g2_ui_control.obj : [.src]g2_ui_control.c $(HEADERS) 56 | [.src]g2_ui_device.obj : [.src]g2_ui_device.c $(HEADERS) 57 | [.src]g2_ui_graphic.obj : [.src]g2_ui_graphic.c $(HEADERS) 58 | [.src]g2_ui_virtual_device.obj : [.src]g2_ui_virtual_device.c $(HEADERS) 59 | [.src]g2_util.obj : [.src]g2_util.c $(HEADERS) 60 | [.src]g2_virtual_device.obj : [.src]g2_virtual_device.c $(HEADERS) 61 | 62 | [.X11]g2_X11.obj : [.src.X11]g2_X11.c $(HEADERS) $(HEADERS_X11) 63 | [.PS]g2_PS.obj : [.src.PS]g2_PS.c $(HEADERS) $(HEADERS_PS) 64 | 65 | -------------------------------------------------------------------------------- /g2-0.40/doc/g2-0.40.lsm: -------------------------------------------------------------------------------- 1 | Begin3 2 | Title: g2 3 | Version: 0.40 4 | Entered-date: 03FEB99 5 | Description: g2 is an easy to use graphics library for 2D 6 | graphical applications written in Ansi-C. g2 7 | library provides a comprehensive set of functions 8 | for simultaneous generation of graphical output 9 | on different types of devices. Following devices 10 | are currently supported by g2: PostScript, X11, 11 | GIF (using gd) and Win32 (xfig is in development). 12 | g2 has C, Fortran and perl interface. 13 | Keywords: library graphics visualization scientific 14 | Author: ljubo@ap.univie.ac.at (Ljubomir Milanovic) 15 | wagner@iap.tuwien.ac.at (Horst Wagner) 16 | Maintained-by: milanovic@iap.tuwien.ac.at (Ljubomir Milanovic) 17 | wagner@iap.tuwien.ac.at (Horst Wagner) 18 | Primary-site: sunsite.unc.edu /pub/Linux/libs/graphics/ 19 | 102kB g2-0.30.tar.gz 20 | 1kB g2-0.30.lsm 21 | Alternate-site: 22 | Original-site: http://www.ap.univie.ac.at/users/ljubo/g2/ 23 | Platforms: Unix, WindowsNT, VMS 24 | Copying-policy: GPL 25 | End 26 | -------------------------------------------------------------------------------- /g2-0.40/g2.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="g2" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 5.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Static Library" 0x0104 6 | 7 | CFG=g2 - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "g2.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "g2.mak" CFG="g2 - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "g2 - Win32 Release" (based on "Win32 (x86) Static Library") 21 | !MESSAGE "g2 - Win32 Debug" (based on "Win32 (x86) Static Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP Scc_ProjName "" 26 | # PROP Scc_LocalPath "" 27 | CPP=cl.exe 28 | 29 | !IF "$(CFG)" == "g2 - Win32 Release" 30 | 31 | # PROP BASE Use_MFC 0 32 | # PROP BASE Use_Debug_Libraries 0 33 | # PROP BASE Output_Dir "Release" 34 | # PROP BASE Intermediate_Dir "Release" 35 | # PROP BASE Target_Dir "" 36 | # PROP Use_MFC 0 37 | # PROP Use_Debug_Libraries 0 38 | # PROP Output_Dir "Release" 39 | # PROP Intermediate_Dir "Release" 40 | # PROP Target_Dir "" 41 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 42 | # ADD CPP /nologo /W3 /GX /O2 /I "../gd" /I "./src" /I "../src" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "DO_PS" /D "DO_GIF" /D "DO_WIN32" /YX /FD /c 43 | BSC32=bscmake.exe 44 | # ADD BASE BSC32 /nologo 45 | # ADD BSC32 /nologo 46 | LIB32=link.exe -lib 47 | # ADD BASE LIB32 /nologo 48 | # ADD LIB32 /nologo 49 | 50 | !ELSEIF "$(CFG)" == "g2 - Win32 Debug" 51 | 52 | # PROP BASE Use_MFC 0 53 | # PROP BASE Use_Debug_Libraries 1 54 | # PROP BASE Output_Dir "Debug" 55 | # PROP BASE Intermediate_Dir "Debug" 56 | # PROP BASE Target_Dir "" 57 | # PROP Use_MFC 0 58 | # PROP Use_Debug_Libraries 1 59 | # PROP Output_Dir "Debug" 60 | # PROP Intermediate_Dir "Debug" 61 | # PROP Target_Dir "" 62 | # ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c 63 | # ADD CPP /nologo /W3 /GX /Z7 /Od /I "../gd" /I "./src" /I "../src" /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /D "DO_PS" /D "DO_GIF" /D "DO_WIN32" /FR /YX /FD /c 64 | BSC32=bscmake.exe 65 | # ADD BASE BSC32 /nologo 66 | # ADD BSC32 /nologo 67 | LIB32=link.exe -lib 68 | # ADD BASE LIB32 /nologo 69 | # ADD LIB32 /nologo 70 | 71 | !ENDIF 72 | 73 | # Begin Target 74 | 75 | # Name "g2 - Win32 Release" 76 | # Name "g2 - Win32 Debug" 77 | # Begin Source File 78 | 79 | SOURCE=.\src\g2_control_pd.c 80 | # End Source File 81 | # Begin Source File 82 | 83 | SOURCE=.\src\g2_device.c 84 | # End Source File 85 | # Begin Source File 86 | 87 | SOURCE=.\src\g2_fif.c 88 | # End Source File 89 | # Begin Source File 90 | 91 | SOURCE=.\src\GIF\g2_GIF.c 92 | # End Source File 93 | # Begin Source File 94 | 95 | SOURCE=.\src\g2_graphic_pd.c 96 | # End Source File 97 | # Begin Source File 98 | 99 | SOURCE=.\src\g2_physical_device.c 100 | # End Source File 101 | # Begin Source File 102 | 103 | SOURCE=.\src\PS\g2_PS.c 104 | # End Source File 105 | # Begin Source File 106 | 107 | SOURCE=.\src\g2_ui_control.c 108 | # End Source File 109 | # Begin Source File 110 | 111 | SOURCE=.\src\g2_ui_device.c 112 | # End Source File 113 | # Begin Source File 114 | 115 | SOURCE=.\src\g2_ui_graphic.c 116 | # End Source File 117 | # Begin Source File 118 | 119 | SOURCE=.\src\g2_ui_virtual_device.c 120 | # End Source File 121 | # Begin Source File 122 | 123 | SOURCE=.\src\g2_util.c 124 | # End Source File 125 | # Begin Source File 126 | 127 | SOURCE=.\src\g2_virtual_device.c 128 | # End Source File 129 | # Begin Source File 130 | 131 | SOURCE=.\src\Win32\g2_win32.c 132 | # End Source File 133 | # Begin Source File 134 | 135 | SOURCE=.\src\Win32\g2_win32_thread.c 136 | # End Source File 137 | # End Target 138 | # End Project 139 | -------------------------------------------------------------------------------- /g2-0.40/g2.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 5.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "g2"=".\g2.dsp" - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Project: "g2demo"=".\g2demo.dsp" - Package Owner=<4> 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<4> 25 | {{{ 26 | Begin Project Dependency 27 | Project_Dep_Name g2 28 | End Project Dependency 29 | Begin Project Dependency 30 | Project_Dep_Name gd 31 | End Project Dependency 32 | }}} 33 | 34 | ############################################################################### 35 | 36 | Project: "g2res"=".\g2res.dsp" - Package Owner=<4> 37 | 38 | Package=<5> 39 | {{{ 40 | }}} 41 | 42 | Package=<4> 43 | {{{ 44 | }}} 45 | 46 | ############################################################################### 47 | 48 | Project: "gd"=".\gd.dsp" - Package Owner=<4> 49 | 50 | Package=<5> 51 | {{{ 52 | }}} 53 | 54 | Package=<4> 55 | {{{ 56 | }}} 57 | 58 | ############################################################################### 59 | 60 | Global: 61 | 62 | Package=<5> 63 | {{{ 64 | }}} 65 | 66 | Package=<3> 67 | {{{ 68 | }}} 69 | 70 | ############################################################################### 71 | 72 | -------------------------------------------------------------------------------- /g2-0.40/g2_perl/Changes: -------------------------------------------------------------------------------- 1 | Revision history for Perl extension G2. 2 | 3 | 0.01 Wed Nov 11 17:34:43 1998 4 | - original version; created by h2xs 1.18 5 | 6 | -------------------------------------------------------------------------------- /g2-0.40/g2_perl/MANIFEST: -------------------------------------------------------------------------------- 1 | Changes 2 | G2.pm 3 | G2.xs 4 | MANIFEST 5 | Makefile.PL 6 | test.pl 7 | typemap 8 | -------------------------------------------------------------------------------- /g2-0.40/g2_perl/Makefile.PL.in: -------------------------------------------------------------------------------- 1 | use ExtUtils::MakeMaker; 2 | # See lib/ExtUtils/MakeMaker.pm for details of how to influence 3 | # the contents of the Makefile that is written. 4 | WriteMakefile( 5 | 'NAME' => 'G2', 6 | 'VERSION_FROM' => 'G2.pm', # finds $VERSION 7 | 'LIBS' => ['-L./.. -lg2.0.40 @LDFLAGS@'], # e.g., '-lm' 8 | 'DEFINE' => '@DEFS@', # e.g., '-DHAVE_SOMETHING' 9 | 'INC' => '-I./../include', # e.g., '-I/usr/local/include' 10 | ); 11 | -------------------------------------------------------------------------------- /g2-0.40/g2_perl/test.pl: -------------------------------------------------------------------------------- 1 | # Before `make install' is performed this script should be runnable with 2 | # `make test'. After `make install' it should work as `perl test.pl' 3 | 4 | ######################### We start with some black magic to print on failure. 5 | 6 | # Change 1..1 below to 1..last_test_to_print . 7 | # (It may become useful if the test is moved to ./t subdirectory.) 8 | 9 | BEGIN { $| = 1; print "1..1\n"; } 10 | END {print "not ok 1\n" unless $loaded;} 11 | use G2; 12 | 13 | $loaded = 1; 14 | print "ok 1\n"; 15 | 16 | ######################### End of black magic. 17 | 18 | # Insert your test code below (better if it prints "ok 13" 19 | # (correspondingly "not ok 13") depending on the success of chunk 13 20 | # of the test code): 21 | 22 | $d = newvd G2::Device(); 23 | 24 | $dev[1] = newX11 G2::Device(775, 575); 25 | $d->attach($dev[1]); 26 | 27 | $dev[2] = newGIF G2::Device("test.gif", 775, 575); 28 | $d->attach($dev[2]); 29 | 30 | $dev[0] = newPS G2::Device("test.ps", 4, 0); 31 | $d->attach($dev[0]); 32 | 33 | $d->set_auto_flush(0); 34 | 35 | for($i=0;$i<27;$i++) { 36 | $d->pen($i); 37 | $d->filled_circle($i*20+10, 10, 10); 38 | $d->pen(1); 39 | $d->circle($i*20+10, 10, 10); 40 | $str = sprintf("%d", $i); 41 | $d->string($i*20+7, 21, $str); 42 | } 43 | 44 | for($j=0;$j<$#dev;$j++) 45 | { 46 | if($dev[$j] > 0) 47 | { 48 | for($i=0;$i<=64;$i++) { 49 | $dev[$j]->move( 2*$i+575, 5); 50 | $dev[$j]->pen($dev[$j]->ink($i/64., 0, 0)); 51 | $dev[$j]->line_r(0, 20); 52 | $dev[$j]->pen($dev[$j]->ink(0, $i/64., 0)); 53 | $dev[$j]->line_r(10, 20); 54 | $dev[$j]->pen($dev[$j]->ink(0, 0, $i/64.)); 55 | $dev[$j]->line_r(-10, 20); 56 | } 57 | } 58 | } 59 | 60 | $d->pen(1); 61 | $d->line(200, 50, 350, 50); 62 | $d->line(200, 48, 350, 48); 63 | $d->line(200, 46, 350, 46); 64 | $d->line(200, 46, 200, 75); 65 | $d->line(198, 46, 198, 75); 66 | $d->line(196, 46, 196, 75); 67 | $d->string(200, 50, "012abcABC#())(\\-+~*!$%&"); 68 | $d->pen(1); 69 | for($i=1;$i<25;$i++) { 70 | $d->line(15, $i*20+50, 15, $i*20+50+$i); 71 | $d->set_font_size(12); 72 | $str = sprintf("%2d:", $i); 73 | $d->string(20, $i*20+50, $str); 74 | $d->set_font_size($i); 75 | $d->string(40, $i*20+50, "hello, world"); 76 | } 77 | 78 | $d->plot(150, 70); 79 | $d->line(147, 68, 153, 68); 80 | 81 | $y=100; 82 | $d->line(100, $y, 150, $y+50); 83 | $d->triangle(150, $y, 250, $y, 200, $y+50); 84 | $d->rectangle(300, $y, 400, $y+50); 85 | $d->circle(450, $y+25, 25); 86 | $d->ellipse(550, $y+25, 45, 25); 87 | $d->arc(650, $y+25, 25, 45, 90, 360); 88 | 89 | $y=200; 90 | $d->filled_triangle(150, $y, 250, $y, 200, $y+50); 91 | $d->filled_rectangle(300, $y, 400, $y+50); 92 | $d->filled_circle(450, $y+25, 25); 93 | $d->filled_ellipse(550, $y+25, 45, 25); 94 | $d->filled_arc(650, $y+25, 25, 45, 90, 360); 95 | 96 | $y=300.; 97 | $pts[0]=150.; $pts[1]=$y; 98 | $pts[2]=175.; $pts[3]=$y+100.; 99 | $pts[4]=200.; $pts[5]=$y; 100 | $pts[6]=225.; $pts[7]=$y+100.; 101 | $pts[8]=250.; $pts[9]=$y; 102 | $d->poly_line(5, \@pts); 103 | 104 | $pts[0]=300; $pts[1]=$y; 105 | $pts[2]=350; $pts[3]=$y; 106 | $pts[4]=375; $pts[5]=$y+50; 107 | $pts[6]=325; $pts[7]=$y+90; 108 | $pts[8]=275; $pts[9]=$y+50; 109 | $d->polygon(5, \@pts); 110 | 111 | $pts[0]=450; $pts[1]=$y; 112 | $pts[2]=500; $pts[3]=$y; 113 | $pts[4]=525; $pts[5]=$y+50; 114 | $pts[6]=475; $pts[7]=$y+90; 115 | $pts[8]=425; $pts[9]=$y+50; 116 | $d->filled_polygon(5, \@pts); 117 | 118 | 119 | $d->line(225, 448, 200+19*25, 448); 120 | for($i=1;$i<20;$i++) { 121 | $d->set_line_width($i); 122 | $d->move(200+$i*25, 450); 123 | $d->line_to(200+$i*25, 550); 124 | } 125 | 126 | $d->set_line_width(5); 127 | for($i=1;$i<10;$i++) { 128 | $pts[0]=1*$i; 129 | $pts[1]=2*$i; 130 | $pts[2]=3*$i; 131 | $d->set_dash(3, \@pts); 132 | $d->line(550, 300+$i*8, 750, 350+$i*8); 133 | } 134 | 135 | $d->set_dash(0); 136 | $d->set_line_width(5); 137 | $d->arc(740, 180, 25, 100, -45+15, -45-15); 138 | $d->filled_arc(740, 180, 12, 50, -45+15, -45-15); 139 | 140 | $d->flush; 141 | print "\nDone.\n[Enter]\n"; 142 | getc(STDIN); 143 | $d->close(); 144 | -------------------------------------------------------------------------------- /g2-0.40/g2_perl/typemap: -------------------------------------------------------------------------------- 1 | enum QPshape T_PTROBJ 2 | G2::Device T_PTROBJ 3 | double * T_dbl_array 4 | 5 | INPUT 6 | T_dbl_array 7 | { 8 | AV *tempav; 9 | I32 len; 10 | int i; 11 | SV **tv; 12 | if (!SvROK($arg)) { 13 | croak(\"$arg is not a reference.\"); 14 | } 15 | if (SvTYPE(SvRV($arg)) != SVt_PVAV) { 16 | croak(\"$arg is not an array.\"); 17 | } 18 | tempav = (AV*)SvRV($arg); 19 | len = av_len(tempav)+1; 20 | $var = (double *) malloc(len*sizeof(double)); 21 | for (i=0;i 2 | # Microsoft Developer Studio Generated Build File, Format Version 5.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Console Application" 0x0103 6 | 7 | CFG=g2demo - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "g2demo.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "g2demo.mak" CFG="g2demo - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "g2demo - Win32 Release" (based on "Win32 (x86) Console Application") 21 | !MESSAGE "g2demo - Win32 Debug" (based on "Win32 (x86) Console Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP Scc_ProjName "" 26 | # PROP Scc_LocalPath "" 27 | CPP=cl.exe 28 | RSC=rc.exe 29 | 30 | !IF "$(CFG)" == "g2demo - Win32 Release" 31 | 32 | # PROP BASE Use_MFC 0 33 | # PROP BASE Use_Debug_Libraries 0 34 | # PROP BASE Output_Dir "Release" 35 | # PROP BASE Intermediate_Dir "Release" 36 | # PROP BASE Target_Dir "" 37 | # PROP Use_MFC 0 38 | # PROP Use_Debug_Libraries 0 39 | # PROP Output_Dir "Release" 40 | # PROP Intermediate_Dir "Release" 41 | # PROP Ignore_Export_Lib 0 42 | # PROP Target_Dir "" 43 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 44 | # ADD CPP /nologo /W3 /GX /O2 /I "../gd" /I "./src" /I "src" /I "src/PS" /I "src/GIF" /I "src/WIN32" /D "NDEBUG" /D "DO_WMF32" /D "_CONSOLE" /D "_MBCS" /D "WIN32" /D "DO_PS" /D "DO_GIF" /D "DO_WIN32" /YX /FD /c 45 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 46 | # ADD RSC /l 0x409 /d "NDEBUG" 47 | BSC32=bscmake.exe 48 | # ADD BASE BSC32 /nologo 49 | # ADD BSC32 /nologo 50 | LINK32=link.exe 51 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 52 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib g2.lib gd.lib /nologo /subsystem:console /machine:I386 /libpath:"./Release" 53 | # SUBTRACT LINK32 /verbose 54 | 55 | !ELSEIF "$(CFG)" == "g2demo - Win32 Debug" 56 | 57 | # PROP BASE Use_MFC 0 58 | # PROP BASE Use_Debug_Libraries 1 59 | # PROP BASE Output_Dir "g2demo__" 60 | # PROP BASE Intermediate_Dir "g2demo__" 61 | # PROP BASE Target_Dir "" 62 | # PROP Use_MFC 0 63 | # PROP Use_Debug_Libraries 1 64 | # PROP Output_Dir "Debug" 65 | # PROP Intermediate_Dir "Debug" 66 | # PROP Ignore_Export_Lib 0 67 | # PROP Target_Dir "" 68 | # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 69 | # ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "../gd" /I "./src" /I "src" /I "src/PS" /I "src/GIF" /I "src/WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "WIN32" /D "DO_PS" /D "DO_GIF" /D "DO_WIN32" /D "DO_WMF32" /FR /YX /FD /c 70 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 71 | # ADD RSC /l 0x409 /fo"g2_win32.res" /d "_DEBUG" 72 | BSC32=bscmake.exe 73 | # ADD BASE BSC32 /nologo 74 | # ADD BSC32 /nologo 75 | LINK32=link.exe 76 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept 77 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib g2.lib gd.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /pdbtype:sept /libpath:"./Debug" 78 | 79 | !ENDIF 80 | 81 | # Begin Target 82 | 83 | # Name "g2demo - Win32 Release" 84 | # Name "g2demo - Win32 Debug" 85 | # Begin Source File 86 | 87 | SOURCE=.\demo\g2_test.c 88 | # End Source File 89 | # End Target 90 | # End Project 91 | -------------------------------------------------------------------------------- /g2-0.40/g2res.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="g2res" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 5.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 6 | 7 | CFG=g2res - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "g2res.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "g2res.mak" CFG="g2res - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "g2res - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") 21 | !MESSAGE "g2res - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP Scc_ProjName "" 26 | # PROP Scc_LocalPath "" 27 | CPP=cl.exe 28 | MTL=midl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "g2res - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "g2res__0" 36 | # PROP BASE Intermediate_Dir "g2res__0" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "Release" 41 | # PROP Intermediate_Dir "Release" 42 | # PROP Target_Dir "" 43 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 44 | # ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 45 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 46 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 47 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 48 | # ADD RSC /l 0x409 /d "NDEBUG" 49 | BSC32=bscmake.exe 50 | # ADD BASE BSC32 /nologo 51 | # ADD BSC32 /nologo 52 | LINK32=link.exe 53 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 54 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 55 | 56 | !ELSEIF "$(CFG)" == "g2res - Win32 Debug" 57 | 58 | # PROP BASE Use_MFC 0 59 | # PROP BASE Use_Debug_Libraries 1 60 | # PROP BASE Output_Dir "g2res__1" 61 | # PROP BASE Intermediate_Dir "g2res__1" 62 | # PROP BASE Target_Dir "" 63 | # PROP Use_MFC 0 64 | # PROP Use_Debug_Libraries 1 65 | # PROP Output_Dir "Debug" 66 | # PROP Intermediate_Dir "Debug" 67 | # PROP Target_Dir "" 68 | # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c 69 | # ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c 70 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 71 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 72 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 73 | # ADD RSC /l 0x409 /d "_DEBUG" 74 | BSC32=bscmake.exe 75 | # ADD BASE BSC32 /nologo 76 | # ADD BSC32 /nologo 77 | LINK32=link.exe 78 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept 79 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept 80 | 81 | !ENDIF 82 | 83 | # Begin Target 84 | 85 | # Name "g2res - Win32 Release" 86 | # Name "g2res - Win32 Debug" 87 | # Begin Source File 88 | 89 | SOURCE=.\src\Win32\g2_Win32.ico 90 | # End Source File 91 | # Begin Source File 92 | 93 | SOURCE=.\src\Win32\g2_win32.rc 94 | # End Source File 95 | # Begin Source File 96 | 97 | SOURCE=.\src\Win32\g2res.c 98 | # End Source File 99 | # End Target 100 | # End Project 101 | -------------------------------------------------------------------------------- /g2-0.40/gd.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="gd" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 5.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Static Library" 0x0104 6 | 7 | CFG=gd - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "gd.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "gd.mak" CFG="gd - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "gd - Win32 Release" (based on "Win32 (x86) Static Library") 21 | !MESSAGE "gd - Win32 Debug" (based on "Win32 (x86) Static Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP Scc_ProjName "" 26 | # PROP Scc_LocalPath "" 27 | CPP=cl.exe 28 | 29 | !IF "$(CFG)" == "gd - Win32 Release" 30 | 31 | # PROP BASE Use_MFC 0 32 | # PROP BASE Use_Debug_Libraries 0 33 | # PROP BASE Output_Dir "Release" 34 | # PROP BASE Intermediate_Dir "Release" 35 | # PROP BASE Target_Dir "" 36 | # PROP Use_MFC 0 37 | # PROP Use_Debug_Libraries 0 38 | # PROP Output_Dir "Release" 39 | # PROP Intermediate_Dir "Release" 40 | # PROP Target_Dir "" 41 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 42 | # ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 43 | BSC32=bscmake.exe 44 | # ADD BASE BSC32 /nologo 45 | # ADD BSC32 /nologo 46 | LIB32=link.exe -lib 47 | # ADD BASE LIB32 /nologo 48 | # ADD LIB32 /nologo 49 | 50 | !ELSEIF "$(CFG)" == "gd - Win32 Debug" 51 | 52 | # PROP BASE Use_MFC 0 53 | # PROP BASE Use_Debug_Libraries 1 54 | # PROP BASE Output_Dir "gd___Win" 55 | # PROP BASE Intermediate_Dir "gd___Win" 56 | # PROP BASE Target_Dir "" 57 | # PROP Use_MFC 0 58 | # PROP Use_Debug_Libraries 1 59 | # PROP Output_Dir "Debug" 60 | # PROP Intermediate_Dir "Debug" 61 | # PROP Target_Dir "" 62 | # ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c 63 | # ADD CPP /nologo /W3 /GX /Z7 /Od /I "../../../gd1.3" /I "./src" /I "../src" /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /YX /FD /c 64 | BSC32=bscmake.exe 65 | # ADD BASE BSC32 /nologo 66 | # ADD BSC32 /nologo 67 | LIB32=link.exe -lib 68 | # ADD BASE LIB32 /nologo 69 | # ADD LIB32 /nologo 70 | 71 | !ENDIF 72 | 73 | # Begin Target 74 | 75 | # Name "gd - Win32 Release" 76 | # Name "gd - Win32 Debug" 77 | # Begin Source File 78 | 79 | SOURCE=..\gd\gd.c 80 | # End Source File 81 | # Begin Source File 82 | 83 | SOURCE=..\gd\gdfontg.c 84 | # End Source File 85 | # Begin Source File 86 | 87 | SOURCE=..\gd\gdfontl.c 88 | # End Source File 89 | # Begin Source File 90 | 91 | SOURCE=..\gd\gdfontmb.c 92 | # End Source File 93 | # Begin Source File 94 | 95 | SOURCE=..\gd\gdfonts.c 96 | # End Source File 97 | # Begin Source File 98 | 99 | SOURCE=..\gd\gdfontt.c 100 | # End Source File 101 | # End Target 102 | # End Project 103 | -------------------------------------------------------------------------------- /g2-0.40/install-sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # install - install a program, script, or datafile 4 | # This comes from X11R5. 5 | # 6 | # Calling this script install-sh is preferred over install.sh, to prevent 7 | # `make' implicit rules from creating a file called install from it 8 | # when there is no Makefile. 9 | # 10 | # This script is compatible with the BSD install script, but was written 11 | # from scratch. 12 | # 13 | 14 | 15 | # set DOITPROG to echo to test this script 16 | 17 | # Don't use :- since 4.3BSD and earlier shells don't like it. 18 | doit="${DOITPROG-}" 19 | 20 | 21 | # put in absolute paths if you don't have them in your path; or use env. vars. 22 | 23 | mvprog="${MVPROG-mv}" 24 | cpprog="${CPPROG-cp}" 25 | chmodprog="${CHMODPROG-chmod}" 26 | chownprog="${CHOWNPROG-chown}" 27 | chgrpprog="${CHGRPPROG-chgrp}" 28 | stripprog="${STRIPPROG-strip}" 29 | rmprog="${RMPROG-rm}" 30 | mkdirprog="${MKDIRPROG-mkdir}" 31 | 32 | transformbasename="" 33 | transform_arg="" 34 | instcmd="$mvprog" 35 | chmodcmd="$chmodprog 0755" 36 | chowncmd="" 37 | chgrpcmd="" 38 | stripcmd="" 39 | rmcmd="$rmprog -f" 40 | mvcmd="$mvprog" 41 | src="" 42 | dst="" 43 | dir_arg="" 44 | 45 | while [ x"$1" != x ]; do 46 | case $1 in 47 | -c) instcmd="$cpprog" 48 | shift 49 | continue;; 50 | 51 | -d) dir_arg=true 52 | shift 53 | continue;; 54 | 55 | -m) chmodcmd="$chmodprog $2" 56 | shift 57 | shift 58 | continue;; 59 | 60 | -o) chowncmd="$chownprog $2" 61 | shift 62 | shift 63 | continue;; 64 | 65 | -g) chgrpcmd="$chgrpprog $2" 66 | shift 67 | shift 68 | continue;; 69 | 70 | -s) stripcmd="$stripprog" 71 | shift 72 | continue;; 73 | 74 | -t=*) transformarg=`echo $1 | sed 's/-t=//'` 75 | shift 76 | continue;; 77 | 78 | -b=*) transformbasename=`echo $1 | sed 's/-b=//'` 79 | shift 80 | continue;; 81 | 82 | *) if [ x"$src" = x ] 83 | then 84 | src=$1 85 | else 86 | # this colon is to work around a 386BSD /bin/sh bug 87 | : 88 | dst=$1 89 | fi 90 | shift 91 | continue;; 92 | esac 93 | done 94 | 95 | if [ x"$src" = x ] 96 | then 97 | echo "install: no input file specified" 98 | exit 1 99 | else 100 | true 101 | fi 102 | 103 | if [ x"$dir_arg" != x ]; then 104 | dst=$src 105 | src="" 106 | 107 | if [ -d $dst ]; then 108 | instcmd=: 109 | else 110 | instcmd=mkdir 111 | fi 112 | else 113 | 114 | # Waiting for this to be detected by the "$instcmd $src $dsttmp" command 115 | # might cause directories to be created, which would be especially bad 116 | # if $src (and thus $dsttmp) contains '*'. 117 | 118 | if [ -f $src -o -d $src ] 119 | then 120 | true 121 | else 122 | echo "install: $src does not exist" 123 | exit 1 124 | fi 125 | 126 | if [ x"$dst" = x ] 127 | then 128 | echo "install: no destination specified" 129 | exit 1 130 | else 131 | true 132 | fi 133 | 134 | # If destination is a directory, append the input filename; if your system 135 | # does not like double slashes in filenames, you may need to add some logic 136 | 137 | if [ -d $dst ] 138 | then 139 | dst="$dst"/`basename $src` 140 | else 141 | true 142 | fi 143 | fi 144 | 145 | ## this sed command emulates the dirname command 146 | dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` 147 | 148 | # Make sure that the destination directory exists. 149 | # this part is taken from Noah Friedman's mkinstalldirs script 150 | 151 | # Skip lots of stat calls in the usual case. 152 | if [ ! -d "$dstdir" ]; then 153 | defaultIFS=' 154 | ' 155 | IFS="${IFS-${defaultIFS}}" 156 | 157 | oIFS="${IFS}" 158 | # Some sh's can't handle IFS=/ for some reason. 159 | IFS='%' 160 | set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` 161 | IFS="${oIFS}" 162 | 163 | pathcomp='' 164 | 165 | while [ $# -ne 0 ] ; do 166 | pathcomp="${pathcomp}${1}" 167 | shift 168 | 169 | if [ ! -d "${pathcomp}" ] ; 170 | then 171 | $mkdirprog "${pathcomp}" 172 | else 173 | true 174 | fi 175 | 176 | pathcomp="${pathcomp}/" 177 | done 178 | fi 179 | 180 | if [ x"$dir_arg" != x ] 181 | then 182 | $doit $instcmd $dst && 183 | 184 | if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && 185 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && 186 | if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && 187 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi 188 | else 189 | 190 | # If we're going to rename the final executable, determine the name now. 191 | 192 | if [ x"$transformarg" = x ] 193 | then 194 | dstfile=`basename $dst` 195 | else 196 | dstfile=`basename $dst $transformbasename | 197 | sed $transformarg`$transformbasename 198 | fi 199 | 200 | # don't allow the sed command to completely eliminate the filename 201 | 202 | if [ x"$dstfile" = x ] 203 | then 204 | dstfile=`basename $dst` 205 | else 206 | true 207 | fi 208 | 209 | # Make a temp file name in the proper directory. 210 | 211 | dsttmp=$dstdir/#inst.$$# 212 | 213 | # Move or copy the file name to the temp name 214 | 215 | $doit $instcmd $src $dsttmp && 216 | 217 | trap "rm -f ${dsttmp}" 0 && 218 | 219 | # and set any options; do chmod last to preserve setuid bits 220 | 221 | # If any of these fail, we abort the whole thing. If we want to 222 | # ignore errors from any of these, just make sure not to ignore 223 | # errors from the above "$doit $instcmd $src $dsttmp" command. 224 | 225 | if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && 226 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && 227 | if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && 228 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && 229 | 230 | # Now rename the file to the real destination. 231 | 232 | $doit $rmcmd -f $dstdir/$dstfile && 233 | $doit $mvcmd $dsttmp $dstdir/$dstfile 234 | 235 | fi && 236 | 237 | 238 | exit 0 239 | -------------------------------------------------------------------------------- /g2-0.40/src/GIF/g2_GIF.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "g2.h" 24 | #include "g2_device.h" 25 | #include "g2_util.h" 26 | #include "g2_config.h" 27 | 28 | #include "g2_GIF_P.h" 29 | #include "g2_GIF.h" 30 | 31 | #define PDP ((struct g2_GIF_STRUCT *)pdp) 32 | 33 | #include "g2_GIF_funix.h" 34 | 35 | #ifndef PI 36 | #define PI 3.14159265358979323846 37 | #endif /* PI */ 38 | 39 | 40 | int g2_GIF_Alloc_Basic(int pid, void *pdp) 41 | { 42 | int icol; 43 | for (icol=0;icol<32;icol++) 44 | gdImageColorAllocate(PDP->im,g2_Basic_Colors[icol][0]/256,g2_Basic_Colors[icol][1]/256,g2_Basic_Colors[icol][2]/256); 45 | PDP->NoOfInks = 32; 46 | return 0; 47 | } 48 | 49 | int g2_GIF_Delete(int pid, void *pdp) 50 | { 51 | gdImageGif(PDP->im,PDP->f); 52 | fclose(PDP->f); 53 | gdImageDestroy(PDP->im); 54 | free(PDP); 55 | return 0; 56 | } 57 | 58 | int g2_GIF_Clear(int pid, void *pdp) 59 | { 60 | gdImageFilledRectangle(PDP->im, 0, 0, PDP->width, PDP->height, PDP->BackCol); 61 | return 0; 62 | } 63 | 64 | int g2_GIF_Save(int pid, void *pdp) 65 | { 66 | gdImageGif(PDP->im,PDP->f); 67 | fflush(PDP->f); 68 | rewind(PDP->f); 69 | return 0; 70 | } 71 | 72 | int g2_GIF_Flush(int pid, void *pdp) 73 | { 74 | return 0; 75 | } 76 | 77 | int g2_GIF_Pen(int pid, void *pdp, int color) 78 | { 79 | PDP->CurCol = color; 80 | return 0; 81 | } 82 | 83 | int g2_GIF_Ink(int pid, void *pdp, double red, double green, double blue) 84 | { 85 | if(PDP->NoOfInks == 256) 86 | return -1; 87 | else 88 | PDP->NoOfInks++; 89 | return gdImageColorAllocate(PDP->im,(int)(255*red),(int)(255*green),(int)(255*blue)); 90 | } 91 | 92 | int g2_GIF_ClearPalette(int pid, void *pdp) 93 | { 94 | int i; 95 | for (i=0;iNoOfInks;i++) 96 | gdImageColorDeallocate(PDP->im,i); 97 | PDP->NoOfInks = 0; 98 | return 0; 99 | } 100 | 101 | int g2_GIF_ResetPalette(int pid, void *pdp) 102 | { 103 | g2_GIF_ClearPalette(pid,pdp); 104 | g2_GIF_Alloc_Basic(pid,pdp); 105 | return 0; 106 | } 107 | 108 | int g2_GIF_SetBackground(int pid, void *pdp, int color) 109 | { 110 | PDP->BackCol = color; 111 | return 0; 112 | } 113 | 114 | int g2_GIF_SetLineWidth(int pid, void *pdp, int w) 115 | { 116 | PDP->LineWidth = w; 117 | return 0; 118 | } 119 | /* { 120 | if (PDP->brush != NULL) 121 | { 122 | gdImageDestroy(PDP->brush); 123 | } 124 | PDP->brush = gdImageCreate(w,w); 125 | gdImageColorTransparent(PDP->brush,0); 126 | gdImageColorAllocate(PDP->brush,0,0,0); 127 | gdImageColorAllocate(PDP->brush, 128 | gdImageRed(PDP->im,PDP->CurCol), 129 | gdImageGreen(PDP->im,PDP->CurCol), 130 | gdImageBlue(PDP->im,PDP->CurCol)); 131 | gdImageArc(PDP->brush, w/2, w/2, w/2,w/2, 0, 360, 1); 132 | gdImageFill(PDP->brush,w/2,w/2,1); 133 | gdImageSetBrush(PDP->im, PDP->brush); 134 | PDP->OldCol = PDP->CurCol; 135 | PDP->CurCol = gdBrushed; 136 | } 137 | else 138 | { 139 | PDP->CurCol = PDP->OldCol; 140 | } 141 | return 0; 142 | } 143 | */ 144 | 145 | int g2_GIF_SetDash(int pid, void *pdp, int n, char *data) 146 | { 147 | return 0; 148 | } 149 | 150 | int g2_GIF_SetDashX(int pid, void *pdp, int N, double *dashes) 151 | { 152 | return 0; 153 | } 154 | 155 | int g2_GIF_SetFontSize(int pid, void *pdp, int size) 156 | { 157 | if (size <=10) 158 | PDP->FontSize = gdFontTiny; 159 | else if (size <=12) 160 | PDP->FontSize = gdFontSmall; 161 | else if (size <=13) 162 | PDP->FontSize = gdFontMediumBold; 163 | else if (size <=15) 164 | PDP->FontSize = gdFontLarge; 165 | else 166 | PDP->FontSize = gdFontGiant; 167 | return 0; 168 | } 169 | 170 | int g2_GIF_Plot(int pid, void *pdp, int x, int y) 171 | { 172 | gdImageSetPixel(PDP->im, x, y, PDP->CurCol); 173 | return 0; 174 | } 175 | 176 | int g2_GIF_Line(int pid, void *pdp, int x1, int y1, int x2, int y2) 177 | { 178 | if (PDP->LineWidth <= 1) 179 | gdImageLine(PDP->im, x1, y1, x2, y2, PDP->CurCol); 180 | else 181 | { 182 | float dx,dy,l; 183 | gdPoint points[4]; 184 | dx=-(y2-y1); 185 | dy=x2-x1; 186 | l = PDP->LineWidth/sqrt(dy*dy+dx*dx)/2.; 187 | dx = dx*l; 188 | dy = dy*l; 189 | points[0].x = x1+dx; 190 | points[0].y = y1+dy; 191 | points[1].x = x1-dx; 192 | points[1].y = y1-dy; 193 | points[2].x = x2-dx; 194 | points[2].y = y2-dy; 195 | points[3].x = x2+dx; 196 | points[3].y = y2+dy; 197 | gdImageFilledPolygon(PDP->im,points,4,PDP->CurCol); 198 | } 199 | return 0; 200 | } 201 | 202 | int g2_GIF_PolyLine(int pid, void *pdp, int N, int *points) 203 | { 204 | return 0; 205 | } 206 | 207 | int g2_GIF_Triangle(int pid, void *pdp, int x1, int y1, 208 | int x2, int y2, 209 | int x3, int y3) 210 | { 211 | return 0; 212 | } 213 | 214 | int g2_GIF_FilledTriangle(int pid, void *pdp, int x1, int y1, 215 | int x2, int y2, 216 | int x3, int y3) 217 | { 218 | return 0; 219 | } 220 | 221 | int g2_GIF_Rectangle(int pid, void *pdp, int x, int y, int x2, int y2) 222 | { 223 | gdImageRectangle(PDP->im, x, y, x2, y2, PDP->CurCol); 224 | return 0; 225 | } 226 | 227 | int g2_GIF_FilledRectangle(int pid, void *pdp, int x, int y, int x2, int y2) 228 | { 229 | gdImageFilledRectangle(PDP->im, x, y, x2, y2, PDP->CurCol); 230 | return 0; 231 | } 232 | 233 | int g2_GIF_Polygon(int pid, void *pdp, int N, int *points) 234 | { 235 | return 0; 236 | } 237 | 238 | int g2_GIF_FilledPolygon(int pid, void *pdp, int N, int *points) 239 | { 240 | gdPoint *GIFPolygon; 241 | int i; 242 | GIFPolygon = (gdPoint *)malloc(N*sizeof(gdPoint)); 243 | for (i=0;iim,GIFPolygon,N,PDP->CurCol); 249 | free(GIFPolygon); 250 | return 0; 251 | } 252 | 253 | int g2_GIF_Circle(int pid, void *pdp, int x, int y, int r) 254 | { 255 | gdImageArc(PDP->im, (int)x, (int)y, (int)r, (int)r, 0, 360, PDP->CurCol); 256 | return 0; 257 | } 258 | 259 | int g2_GIF_FilledCircle(int pid, void *pdp, int x, int y, int r) 260 | { 261 | return 0; 262 | } 263 | 264 | int g2_GIF_Ellipse(int pid, void *pdp, int x, int y, int r1, int r2) 265 | { 266 | return 0; 267 | } 268 | 269 | int g2_GIF_FilledEllipse(int pid, void *pdp, int x, int y, int r1, int r2) 270 | { 271 | return 0; 272 | } 273 | 274 | int g2_GIF_Arc(int pid, void *pdp, int x, int y, int r1, int r2, double a1, double a2) 275 | { 276 | gdImageArc(PDP->im,x,y,2*r1,2*r2,dtoi(a1),dtoi(a2),PDP->CurCol); 277 | return 0; 278 | } 279 | 280 | int g2_GIF_FilledArc(int pid, void *pdp, int x, int y, 281 | int r1, int r2, 282 | double a1, double a2) 283 | { 284 | double a, da; /* emulate filled arc */ 285 | int pts[6]; 286 | int N, i; 287 | pts[0] = dtoi(x); 288 | pts[1] = dtoi(y); 289 | N=(int)fabs(a2-a1)+8; 290 | while (a2 < a1) a2+=360; 291 | a=a1*2.*PI/360.; 292 | da=(a2-a1)*2.*PI/360./(N-1); 293 | pts[2] = dtoi(x+r1*cos(a)); 294 | pts[3] = dtoi(y+r2*sin(a)); 295 | for(i=1;iim,PDP->FontSize,x,y+2-PDP->FontSize->h,(unsigned char *)text,PDP->CurCol); 312 | return 0; 313 | } 314 | 315 | int g2_open_GIF(const char *filename, int width, int height) 316 | { 317 | int pid=-1; 318 | g2_GIF_STRUCT *pdp; 319 | 320 | pdp = (g2_GIF_STRUCT *)malloc(sizeof(g2_GIF_STRUCT)); 321 | 322 | pdp->width = width; 323 | pdp->height = height; 324 | pdp->im = gdImageCreate(width,height); 325 | pdp->f = fopen(filename,"wb"); 326 | pdp->NoOfInks = 0; 327 | pdp->BackCol = 0; 328 | g2_GIF_Clear(pid,pdp); 329 | 330 | pid = g2_register_physical_device(pid, pdp, 331 | g2_IntCoor, g2_GIF_funix, 332 | 1.0, -1.0, 333 | 0.0, height-1); 334 | 335 | g2_set_font_size(pid, 12.0); 336 | g2_allocate_basic_colors(pid); 337 | g2_pen(pid, 1); 338 | 339 | return pid; 340 | } 341 | -------------------------------------------------------------------------------- /g2-0.40/src/GIF/g2_GIF.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | /* This is g2_GIF.h */ 19 | #ifndef _G2_GIF_H 20 | #define _G2_GIF_H 21 | 22 | #include 23 | 24 | int g2_open_GIF(const char *filename, int width, int height); 25 | 26 | #endif /* _G2_GIF_H */ 27 | -------------------------------------------------------------------------------- /g2-0.40/src/GIF/g2_GIF_P.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #ifndef _g2_GIF_P_H 19 | #define _g2_GIF_P_H 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include "g2_config.h" 28 | 29 | static unsigned short g2_Basic_Colors[32][3] = { 30 | {65535,65535,65535},{0,0,0}, 31 | {44461,55512,59110},{0,65535,65535},{0,0,65535}, 32 | {0,0,32896},{61166,33410,61166}, 33 | {65535,0,65535},{41120,8224,61680},{65535,49344,52171}, 34 | {61680,59110,35980},{32639,65535,54484}, 35 | {39064,64507,39064},{0,65535,0},{12850,52685,12850}, 36 | {39578,52685,12850},{44461,65535,12079},{65535,65535,0}, 37 | {65535,55255,0},{61166,56797,33410},{56026,42405,8224},{47288,34438,2827}, 38 | {42405,10794,10794},{53970,26985,7710}, 39 | {52685,34181,16191},{65535,32639,20560}, 40 | {61680,32896,32896},{64250,32896,29298}, 41 | {65535,35980,0},{65535,42405,0},{65535,17733,0}, 42 | {65535,0,0}}; 43 | 44 | 45 | typedef struct g2_GIF_STRUCT { 46 | int height; 47 | int width; 48 | FILE *f; 49 | gdImagePtr im; 50 | gdImagePtr brush; 51 | int LineWidth; 52 | int NoOfInks; 53 | int Inks[256]; 54 | int CurCol; 55 | int OldCol; 56 | int BackCol; 57 | gdFontPtr FontSize; 58 | } g2_GIF_STRUCT; 59 | 60 | 61 | 62 | int g2_GIF_init_GIF(int pid, void *pdp, int vid, int width,int height); 63 | int g2_GIF_init_GIFX(int pid, void *pdp, 64 | int width, int height, 65 | int xposition, int yposition, 66 | char *windowname, char *iconname, 67 | char *icondata, int iconwidth, int iconheight); 68 | int g2_GIF_Delete(int pid, void *pdp); 69 | int g2_GIF_Clear(int pid, void *pdp); 70 | int g2_GIF_Flush(int pid, void *pdp); 71 | int g2_GIF_Ink(int pid, void *pdp, 72 | double red, double green, double blue); 73 | int g2_GIF_ClearPalette(int pid, void *pdp); 74 | int g2_GIF_ResetPalette(int pid, void *pdp); 75 | int g2_GIF_SetBackground(int pid, void *pdp, int color); 76 | int g2_GIF_Pen(int pid, void *pdp, int color); 77 | int g2_GIF_Paper(int pid, void *pdp, int color); 78 | int g2_GIF_SetLineWidth(int pid, void *pdp, int w); 79 | int g2_GIF_SetDash(int pid, void *pdp, int n, char *data); 80 | int g2_GIF_SetFontSize(int pid, void *pdp, int size); 81 | int g2_GIF_Plot(int pid, void *pdp, int x, int y); 82 | int g2_GIF_Line(int pid, void *pdp, int x1, int y1, int x2, int y2); 83 | int g2_GIF_PolyLine(int pid, void *pdp, int N, int *p); 84 | int g2_GIF_Polygon(int pid, void *pdp, int N, int *p); 85 | int g2_GIF_FilledPolygon(int pid, void *pdp, int N, int *p); 86 | int g2_GIF_Triangle(int pid, void *pdp, 87 | int x1, int y1, 88 | int x2, int y2, 89 | int x3, int y3); 90 | int g2_GIF_FilledTriangle(int pid, void *pdp, int x1, int y1, 91 | int x2, int y2, 92 | int x3, int y3); 93 | int g2_GIF_Rectangle(int pid, void *pdp, int x1, int y1, int x2, int y2); 94 | int g2_GIF_FilledRectangle(int pid, void *pdp, 95 | int x1, int y1, int x2, int y2); 96 | int g2_GIF_Circle(int pid, void *pdp, int x, int y, int r); 97 | int g2_GIF_FilledCircle(int pid, void *pdp, int x, int y, int r); 98 | int g2_GIF_Arc(int pid, void *pdp, int x, int y, 99 | int r1, int r2, double a1, double a2); 100 | int g2_GIF_FilledArc(int pid, void *pdp, int x, int y, 101 | int r1, int r2, double a1, double a2); 102 | int g2_GIF_Ellipse(int pid, void *pdp, int x, int y, int r1, int r2); 103 | int g2_GIF_FilledEllipse(int pid, void *pdp, int x, int y, int r1, int r2); 104 | int g2_GIF_DrawString(int pid, void *pdp, int x, int y, char *text); 105 | 106 | int g2_GIF_AllocateBasicColors(int pid, void *pdp); 107 | 108 | 109 | 110 | #endif /* _g2_GIF_P_H */ 111 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /g2-0.40/src/GIF/g2_GIF_funix.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #ifndef _g2_GIF_TOKEN_FUN_H 19 | #define _g2_GIF_TOKEN_FUN_H 20 | 21 | 22 | #include "g2_virtual_device.h" 23 | #include "g2_GIF_P.h" 24 | 25 | const g2_funix_fun g2_GIF_funix[] = 26 | {{g2_Delete,g2_GIF_Delete}, 27 | {g2_Ink, g2_GIF_Ink}, 28 | {g2_Pen,g2_GIF_Pen}, 29 | {g2_SetBackground,g2_GIF_SetBackground}, 30 | {g2_ClearPalette,g2_GIF_ClearPalette}, 31 | {g2_SetLineWidth,g2_GIF_SetLineWidth}, 32 | /* {g2_SetDash,g2_GIF_SetDash}, */ 33 | {g2_SetFontSize,g2_GIF_SetFontSize}, 34 | {g2_Clear,g2_GIF_Clear}, 35 | {g2_Flush,g2_GIF_Flush}, 36 | {g2_Plot,g2_GIF_Plot}, 37 | {g2_Line,g2_GIF_Line}, 38 | /* {g2_PolyLine,g2_GIF_PolyLine}, */ 39 | {g2_Rectangle,g2_GIF_Rectangle}, 40 | {g2_FilledRectangle,g2_GIF_FilledRectangle}, 41 | /* {g2_Polygon,g2_GIF_Polygon}, */ 42 | {g2_FilledPolygon,g2_GIF_FilledPolygon}, 43 | /* {g2_Circle,g2_GIF_Circle}, */ 44 | /* {g2_FilledCircle,g2_GIF_FilledCircle}, */ 45 | /* {g2_Ellipse,g2_GIF_Ellipse}, */ 46 | /* {g2_FilledEllipse,g2_GIF_FilledEllipse}, */ 47 | /* {g2_Arc,g2_GIF_Arc}, */ 48 | {g2_FilledArc,g2_GIF_FilledArc}, 49 | {g2_String,g2_GIF_DrawString}, 50 | {g2_FUNIX_NULL, NULL}}; 51 | 52 | 53 | #endif /* _g2_GIF_TOKEN_FUN_H */ 54 | -------------------------------------------------------------------------------- /g2-0.40/src/PS/g2_PS.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #ifndef _G2_PS_H 19 | #define _G2_PS_H 20 | 21 | /* 22 | * g2 Paper Type 23 | */ 24 | enum g2_PS_paper { /* Name Size(Pt) */ 25 | g2_A0, /* A0 2384 x 3370 */ 26 | g2_A1, /* A1 1684 x 2384 */ 27 | g2_A2, /* A2 1191 x 1684 */ 28 | g2_A3, /* A3 842 x 1191 */ 29 | g2_A4, /* A4 595 x 842 */ 30 | g2_A5, /* A5 420 x 595 */ 31 | g2_A6, /* A6 297 x 420 */ 32 | g2_A7, /* A7 210 x 297 */ 33 | g2_A8, /* A8 148 x 210 */ 34 | g2_A9, /* A9 105 x 148 */ 35 | g2_B0, /* B0 2920 x 4127 */ 36 | g2_B1, /* B1 2064 x 2920 */ 37 | g2_B2, /* B2 1460 x 2064 */ 38 | g2_B3, /* B3 1032 x 1460 */ 39 | g2_B4, /* B4 729 x 1032 */ 40 | g2_B5, /* B5 516 x 729 */ 41 | g2_B6, /* B6 363 x 516 */ 42 | g2_B7, /* B7 258 x 363 */ 43 | g2_B8, /* B8 181 x 258 */ 44 | g2_B9, /* B9 127 x 181 */ 45 | g2_B10, /* B10 91 x 127 */ 46 | g2_Comm_10_Envelope, /* Comm #10 Envelope 297 x 684 */ 47 | g2_C5_Envelope, /* C5 Envelope 461 x 648 */ 48 | g2_DL_Envelope, /* DL Envelope 312 x 624 */ 49 | g2_Folio, /* Folio 595 x 935 */ 50 | g2_Executive, /* Executive 522 x 756 */ 51 | g2_Letter, /* Letter 612 x 792 */ 52 | g2_Legal, /* Legal 612 x 1008 */ 53 | g2_Ledger, /* Ledger 1224 x 792 */ 54 | g2_Tabloid /* Tabloid 792 x 1224 */ 55 | }; 56 | 57 | /* 58 | * g2 Orientation 59 | */ 60 | enum g2_PS_orientation { 61 | g2_PS_land, /* landscape */ 62 | g2_PS_port /* portrait */ 63 | }; 64 | 65 | 66 | 67 | int g2_open_PS(const char *file_name, 68 | enum g2_PS_paper paper, 69 | enum g2_PS_orientation orientation); 70 | 71 | 72 | 73 | #endif /* _G2_PS_H */ 74 | -------------------------------------------------------------------------------- /g2-0.40/src/PS/g2_PS_P.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #ifndef _G2_PS_P_H 19 | #define _G2_PS_P_H 20 | 21 | #include "g2_PS.h" 22 | 23 | 24 | typedef struct _g2_PS_inks { 25 | double r; /* red [0:1] */ 26 | double g; /* green [0:1] */ 27 | double b; /* blue [0:1] */ 28 | } g2_PS_inks; 29 | 30 | 31 | 32 | typedef struct _g2_PS_device { 33 | FILE *fp; /* output file pointer */ 34 | enum g2_PS_paper paper; /* paper type */ 35 | enum g2_PS_orientation orient; /* page orientation */ 36 | 37 | g2_PS_inks *inks; /* allocated colors */ 38 | int N_ink; /* number of allocated colors*/ 39 | int pen; /* current pen */ 40 | int page_counter; /* page counter ( Clear() ) */ 41 | } g2_PS_device; 42 | 43 | 44 | 45 | int g2_PS_write_file_header(g2_PS_device *psd); 46 | int g2_PS_delete(int pid, void *pdp); 47 | int g2_PS_ink(int pid, void *pdp, 48 | double red, double green, double blue); 49 | int g2_PS_pen(int pid, void *pdp, int color); 50 | int g2_PS_set_background(int pid, void *pdp, int color); 51 | int g2_PS_reset_palette(int pid, void *pdp); 52 | int g2_PS_clear_palette(int pid, void *pdp); 53 | int g2_PS_set_line_width(int pid, void *pdp, double w); 54 | int g2_PS_set_dash(int pid, void *pdp, int N, double *data); 55 | int g2_PS_set_font_size(int pid, void *pdp, double size); 56 | int g2_PS_clear(int pid, void *pdp); 57 | int g2_PS_flush(int pid, void *pdp); 58 | int g2_PS_plot(int pid, void *pdp, double x, double y); 59 | int g2_PS_line(int pid, void *pdp, double x1, double y1, double x2, double y2); 60 | int g2_PS_poly_line(int pid, void *pdp, int N, double *points); 61 | int g2_PS_polygon(int pid, void *pdp, int N, double *points); 62 | int g2_PS_filled_polygon(int pid, void *pdp, int N, double *points); 63 | int g2_PS_rectangle(int pid, void *pdp, 64 | double x1, double y1, double x2, double y2); 65 | int g2_PS_filled_rectangle(int pid, void *pdp, 66 | double x1, double y1, double x2, double y2); 67 | int g2_PS_triangle(int pid, void *pdp, 68 | double x1, double y1, 69 | double x2, double y2, 70 | double x3, double y3); 71 | int g2_PS_filled_triangle(int pid, void *pdp, 72 | double x1, double y1, 73 | double x2, double y2, 74 | double x3, double y3); 75 | int g2_PS_arc(int pid, void *pdp, 76 | double x, double y, 77 | double r1, double r2, 78 | double a1, double a2); 79 | int g2_PS_filled_arc(int pid, void *pdp, 80 | double x, double y, 81 | double r1, double r2, 82 | double a1, double a2); 83 | int g2_PS_ellipse(int pid, void *pdp, 84 | double x, double y, 85 | double r1, double r2); 86 | int g2_PS_filled_ellipse(int pid, void *pdp, 87 | double x, double y, 88 | double r1, double r2); 89 | int g2_PS_draw_string(int pid, void *pdp, 90 | double x, double y, char *text); 91 | 92 | #endif /* _G2_PS_P_H */ 93 | 94 | -------------------------------------------------------------------------------- /g2-0.40/src/PS/g2_PS_definitions.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | 19 | /* 20 | * 21 | * Sizes for paper defined in g2_PS.h 22 | * Size is in 1/72 inch (=0.351mm) 23 | */ 24 | static int g2_PS_paper_size[][2]={ 25 | { 2384, 3370 }, /* g2_A0 - A0 */ 26 | { 1684, 2384 }, /* g2_A1 - A1 */ 27 | { 1191, 1684 }, /* g2_A2 - A2 */ 28 | { 842, 1191 }, /* g2_A3 - A3 */ 29 | { 595, 842 }, /* g2_A4 - A4 */ 30 | { 420, 595 }, /* g2_A5 - A5 */ 31 | { 297, 420 }, /* g2_A6 - A6 */ 32 | { 210, 297 }, /* g2_A7 - A7 */ 33 | { 148, 210 }, /* g2_A8 - A8 */ 34 | { 105, 148 }, /* g2_A9 - A9 */ 35 | { 2920, 4127 }, /* g2_B0 - B0 */ 36 | { 2064, 2920 }, /* g2_B1 - B1 */ 37 | { 1460, 2064 }, /* g2_B2 - B2 */ 38 | { 1032, 1460 }, /* g2_B3 - B3 */ 39 | { 729, 1032 }, /* g2_B4 - B4 */ 40 | { 516, 729 }, /* g2_B5 - B5 */ 41 | { 363, 516 }, /* g2_B6 - B6 */ 42 | { 258, 363 }, /* g2_B7 - B7 */ 43 | { 181, 258 }, /* g2_B8 - B8 */ 44 | { 127, 181 }, /* g2_B9 - B9 */ 45 | { 91, 127 }, /* g2_B10 - B10 */ 46 | { 297, 684 }, /* g2_Comm_10_Envelope - Comm #10 Envelope */ 47 | { 461, 648 }, /* g2_C5_Envelope - C5 Envelope */ 48 | { 312, 624 }, /* g2_DL_Envelope - DL Envelope */ 49 | { 595, 935 }, /* g2_Folio - Folio */ 50 | { 522, 756 }, /* g2_Executive - Executive */ 51 | { 612, 792 }, /* g2_Letter - Letter */ 52 | { 612, 1008 }, /* g2_Legal - Legal */ 53 | { 1224, 792 }, /* g2_Ledger - Ledger */ 54 | { 792, 1224 } /* g2_Tabloid - Tabloid */ 55 | }; 56 | 57 | 58 | /* 59 | * 60 | * PS operators 61 | * 62 | */ 63 | char *g2_PS_operators[]={ 64 | " /L { lineto } def", /* lineto */ 65 | " /St { stroke } def", /* stroke */ 66 | " /M { moveto } def", /* moveto */ 67 | " /P {", /* plot */ 68 | " gsave newpath [] 0 setdash 1 setlinecap 0 setlinewidth", 69 | " 0.2 sub exch 0.2 sub exch moveto 0.4 0.4 rlineto", 70 | " stroke grestore} def", 71 | " /T {", /* triangle */ 72 | " newpath", 73 | " moveto lineto lineto", 74 | " closepath stroke} def", 75 | " /FT {", /* filled triangle */ 76 | " newpath", 77 | " moveto lineto lineto", 78 | " closepath fill} def", 79 | " /R {", /* rectangle */ 80 | " newpath", 81 | " 3 index 1 index 6 4 roll 5 index 1 index", 82 | " moveto lineto lineto lineto closepath stroke} def", 83 | " /FR {", /* filled rectangle */ 84 | " newpath", 85 | " 3 index 1 index 6 4 roll 5 index 1 index", 86 | " moveto lineto lineto lineto closepath fill} def", 87 | " /A {", /* arc */ 88 | " gsave /g2_old_matrix matrix currentmatrix def newpath", 89 | " translate scale 0 0 1 5 3 roll arc", 90 | " g2_old_matrix setmatrix stroke grestore } def", 91 | " /FA {", /* filled arc */ 92 | " gsave /g2_old_matrix matrix currentmatrix def newpath", 93 | " translate scale 0 0 moveto 0 0 1 5 3 roll arc closepath", 94 | " g2_old_matrix setmatrix fill grestore } def", 95 | " /S {", /* draw string */ 96 | " gsave newpath", 97 | " translate 0 0 moveto show", 98 | " stroke grestore} def", 99 | "\n", 100 | NULL 101 | }; 102 | 103 | 104 | -------------------------------------------------------------------------------- /g2-0.40/src/PS/g2_PS_funix.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #ifndef _G2_PS_FUNIX_H 19 | #define _G2_PS_FUNIX_H 20 | 21 | #include "g2_PS_P.h" 22 | #include "g2_physical_device.h" 23 | 24 | const g2_funix_fun g2_PS_funix[] = { 25 | { g2_Delete, g2_PS_delete }, 26 | { g2_Ink, g2_PS_ink }, 27 | { g2_Pen, g2_PS_pen }, 28 | { g2_SetBackground, g2_PS_set_background }, 29 | { g2_ClearPalette, g2_PS_clear_palette }, 30 | { g2_SetLineWidth, g2_PS_set_line_width }, 31 | { g2_SetDash, g2_PS_set_dash }, 32 | { g2_SetFontSize, g2_PS_set_font_size }, 33 | { g2_Clear, g2_PS_clear }, 34 | { g2_Flush, g2_PS_flush }, 35 | { g2_Save, g2_PS_flush }, 36 | { g2_Plot, g2_PS_plot }, 37 | { g2_Line, g2_PS_line }, 38 | { g2_PolyLine, g2_PS_poly_line }, 39 | { g2_Polygon, g2_PS_polygon }, 40 | { g2_FilledPolygon, g2_PS_filled_polygon }, 41 | { g2_Rectangle, g2_PS_rectangle }, 42 | { g2_FilledRectangle, g2_PS_filled_rectangle }, 43 | { g2_Triangle, g2_PS_triangle }, 44 | { g2_FilledTriangle, g2_PS_filled_triangle }, 45 | { g2_Arc, g2_PS_arc }, 46 | { g2_FilledArc, g2_PS_filled_arc }, 47 | { g2_Ellipse, g2_PS_ellipse }, 48 | { g2_FilledEllipse, g2_PS_filled_ellipse }, 49 | { g2_Circle, NULL }, 50 | { g2_FilledCircle, NULL }, 51 | { g2_String, g2_PS_draw_string }, 52 | { g2_FUNIX_NULL, NULL } }; 53 | 54 | 55 | #endif /* _G2_PS_FUNIX_H */ 56 | -------------------------------------------------------------------------------- /g2-0.40/src/Win32/g2_Win32.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/priikone/tempest-AM/438a5bb9fb0f51d8e76cc0e7a5404f175ce2840b/g2-0.40/src/Win32/g2_Win32.ico -------------------------------------------------------------------------------- /g2-0.40/src/Win32/g2_win32.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | /* This is g2_win32.h */ 19 | 20 | #include 21 | 22 | int g2_open_win32(int width, int height, const char *filename,int type); 23 | 24 | 25 | -------------------------------------------------------------------------------- /g2-0.40/src/Win32/g2_win32.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/priikone/tempest-AM/438a5bb9fb0f51d8e76cc0e7a5404f175ce2840b/g2-0.40/src/Win32/g2_win32.rc -------------------------------------------------------------------------------- /g2-0.40/src/Win32/g2_win32_P.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | 19 | #ifndef G2_WIN32_P_H 20 | #define G2_WIN32_P_H 21 | 22 | #include "windows.h" 23 | #include 24 | 25 | #define g2_win32 0 26 | #define g2_wmf32 1 27 | 28 | extern HMENU hmenu; 29 | extern HANDLE ghModule; 30 | extern HINSTANCE g2res_DLL; 31 | 32 | BOOL SaveBitmapAs(HWND hWnd,struct XPGTHREADINFO *pThreadInfo); 33 | LRESULT CALLBACK g2_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 34 | long g2_StartThread(struct g2_win32_STRUCT *pdp); 35 | void errhandler(LPSTR errtxt,HWND hwnd); 36 | 37 | typedef struct g2_win32_STRUCT { 38 | HANDLE hThread; 39 | HWND hwndThreadWindow; 40 | HANDLE hinst; 41 | HBITMAP hBitmap; 42 | HDC hMemDC; 43 | HPEN hPen; 44 | HPEN hNullPen; 45 | HBRUSH hBrush; 46 | HFONT hFont; 47 | int nWidth; 48 | int nHeight; 49 | int x; 50 | int y; 51 | int NoOfInks; 52 | int PenWidth; 53 | int PenStyle; 54 | DWORD *PenDash; 55 | int Pen; 56 | int BkColor; 57 | COLORREF PenColor; 58 | COLORREF *Inks; 59 | char *title; 60 | int type; 61 | int messageloop; 62 | } g2_win32_STRUCT; 63 | 64 | 65 | int g2_win32_init_win32(int pid, void *pdp, int vid, int width,int height); 66 | int g2_win32_init_win32X(int pid, void *pdp, 67 | int width, int height, 68 | int xposition, int yposition, 69 | char *windowname, char *iconname, 70 | char *icondata, int iconwidth, int iconheight); 71 | int g2_win32_Delete(int pid, void *pdp); 72 | int g2_win32_Clear(int pid, void *pdp); 73 | int g2_win32_Flush(int pid, void *pdp); 74 | int g2_win32_Ink(int pid, void *pdp, 75 | double red, double green, double blue); 76 | int g2_win32_ClearPalette(int pid, void *pdp); 77 | int g2_win32_ResetPalette(int pid, void *pdp); 78 | int g2_win32_SetBackground(int pid, void *pdp, int color); 79 | int g2_win32_Pen(int pid, void *pdp, int color); 80 | int g2_win32_Paper(int pid, void *pdp, int color); 81 | int g2_win32_SetLineWidth(int pid, void *pdp, int w); 82 | int g2_win32_SetDash(int pid, void *pdp, int n, int *data); 83 | int g2_win32_SetFontSize(int pid, void *pdp, int size); 84 | int g2_win32_Plot(int pid, void *pdp, int x, int y); 85 | int g2_win32_Line(int pid, void *pdp, int x1, int y1, int x2, int y2); 86 | int g2_win32_PolyLine(int pid, void *pdp, int N, int *p); 87 | int g2_win32_Polygon(int pid, void *pdp, int N, int *p); 88 | int g2_win32_FilledPolygon(int pid, void *pdp, int N, int *p); 89 | int g2_win32_Triangle(int pid, void *pdp, 90 | int x1, int y1, 91 | int x2, int y2, 92 | int x3, int y3); 93 | int g2_win32_FilledTriangle(int pid, void *pdp, int x1, int y1, 94 | int x2, int y2, 95 | int x3, int y3); 96 | int g2_win32_Rectangle(int pid, void *pdp, int x1, int y1, int x2, int y2); 97 | int g2_win32_FilledRectangle(int pid, void *pdp, 98 | int x1, int y1, int x2, int y2); 99 | int g2_win32_Circle(int pid, void *pdp, int x, int y, int r); 100 | int g2_win32_FilledCircle(int pid, void *pdp, int x, int y, int r); 101 | int g2_win32_Arc(int pid, void *pdp, int x, int y, 102 | int r1, int r2, double a1, double a2); 103 | int g2_win32_FilledArc(int pid, void *pdp, int x, int y, 104 | int r1, int r2, double a1, double a2); 105 | int g2_win32_Ellipse(int pid, void *pdp, int x, int y, int r1, int r2); 106 | int g2_win32_FilledEllipse(int pid, void *pdp, int x, int y, int r1, int r2); 107 | int g2_win32_DrawString(int pid, void *pdp, int x, int y, char *text); 108 | 109 | int g2_win32_AllocateBasicColors(int pid, void *pdp); 110 | 111 | int g2_win32_Cleanup(int pid, void *pdp); 112 | 113 | 114 | #endif /* g2_win32_P_H */ 115 | 116 | 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /g2-0.40/src/Win32/g2_win32_funix.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #ifndef G2_WIN32_FUNIX_H 19 | #define G2_WIN32_FUNIX_H 20 | 21 | #include "g2_win32_P.h" 22 | #include "g2_physical_device.h" 23 | 24 | const g2_funix_fun g2_win32_funix[] = { 25 | { g2_Delete, g2_win32_Delete }, 26 | { g2_Ink, g2_win32_Ink }, 27 | { g2_Pen, g2_win32_Pen }, 28 | { g2_SetBackground, g2_win32_SetBackground }, 29 | { g2_ClearPalette, g2_win32_ClearPalette }, 30 | { g2_SetLineWidth, g2_win32_SetLineWidth }, 31 | { g2_SetDash, g2_win32_SetDash }, 32 | { g2_SetFontSize, g2_win32_SetFontSize }, 33 | { g2_Clear, g2_win32_Clear }, 34 | { g2_Flush, g2_win32_Flush }, 35 | { g2_Save, g2_win32_Flush }, 36 | { g2_Plot, g2_win32_Plot }, 37 | { g2_Line, g2_win32_Line }, 38 | { g2_PolyLine, g2_win32_PolyLine }, 39 | { g2_Polygon, g2_win32_Polygon }, 40 | { g2_FilledPolygon, g2_win32_FilledPolygon }, 41 | { g2_Rectangle, g2_win32_Rectangle }, 42 | { g2_FilledRectangle, g2_win32_FilledRectangle }, 43 | { g2_Arc, g2_win32_Arc }, 44 | { g2_FilledArc, g2_win32_FilledArc }, 45 | { g2_Ellipse, g2_win32_Ellipse }, 46 | { g2_FilledEllipse, g2_win32_FilledEllipse }, 47 | { g2_Circle, NULL }, 48 | { g2_FilledCircle, NULL }, 49 | { g2_String, g2_win32_DrawString }, 50 | { g2_FUNIX_NULL, NULL } }; 51 | 52 | 53 | #endif /* G2_WIN32_FUNIX_H */ 54 | 55 | -------------------------------------------------------------------------------- /g2-0.40/src/Win32/g2_win32_thread.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "g2_win32_P.h" 26 | 27 | #include "resource.h" 28 | 29 | 30 | 31 | int WINAPI About(HWND hDlg,UINT message, WPARAM wParam,LPARAM lParam) 32 | { 33 | switch (message){ 34 | case WM_INITDIALOG: 35 | return TRUE; 36 | 37 | case WM_COMMAND: 38 | if (wParam == IDOK) 39 | EndDialog(hDlg,wParam); 40 | break; 41 | } 42 | 43 | return FALSE; 44 | } 45 | 46 | 47 | 48 | LRESULT CALLBACK g2_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 49 | { 50 | PAINTSTRUCT ps; 51 | HDC hDC; 52 | RECT Rect; 53 | struct g2_win32_STRUCT *pdp; 54 | 55 | pdp = (struct g2_win32_STRUCT *)GetWindowLong(hWnd, GWL_USERDATA); 56 | switch (message) { 57 | 58 | case WM_PAINT: 59 | if (pdp == NULL) break; 60 | if (pdp->hBitmap == NULL) break; 61 | 62 | // printf("Received WM_PAINT\n"); 63 | 64 | hDC = BeginPaint (hWnd, &ps); 65 | GetClientRect(hWnd,&Rect); 66 | BitBlt( hDC, Rect.left, Rect.top, Rect.right - Rect.left, 67 | Rect.bottom - Rect.top, pdp->hMemDC, 0, 0, SRCCOPY ); 68 | EndPaint (hWnd, &ps); 69 | 70 | 71 | return 0; 72 | case WM_DESTROY: 73 | 74 | // printf("Received WM_DESTROY\n"); 75 | g2_win32_Cleanup(0,pdp); 76 | ExitThread(0); 77 | 78 | case WM_COMMAND: 79 | switch(LOWORD(wParam)){ 80 | 81 | case ID_FILE_COPY: 82 | if (OpenClipboard(hWnd)) 83 | { 84 | HBITMAP hBitmap; 85 | 86 | EmptyClipboard(); 87 | 88 | if (pdp->hBitmap) 89 | { 90 | if (hBitmap = CopyImage(pdp->hBitmap,IMAGE_BITMAP, 91 | 0,0,LR_COPYRETURNORG)); 92 | SetClipboardData(CF_BITMAP, hBitmap); 93 | } 94 | CloseClipboard(); 95 | } 96 | return 0L; 97 | 98 | case ID_FILE_ABOUT: 99 | if(DialogBox(g2res_DLL,"ABOUTBOX",hWnd,(DLGPROC)About) == -1) 100 | errhandler("Failed to create Dialogbox",NULL); 101 | return 0L; 102 | 103 | case ID_FILE_CLOS: 104 | g2_win32_Delete(0,pdp); 105 | return 0L; 106 | 107 | default: 108 | return (DefWindowProc(hWnd, message, wParam, lParam)); 109 | } 110 | 111 | default: 112 | return (DefWindowProc(hWnd, message, wParam, lParam)); 113 | } 114 | } 115 | 116 | long g2_StartThread(struct g2_win32_STRUCT *pdp) 117 | { 118 | RECT Rect; 119 | HWND hWnd; 120 | MSG msg; 121 | HDC hDC; 122 | int py,px; 123 | HMENU hmenu; 124 | 125 | hmenu = NULL; 126 | if (g2res_DLL != NULL) 127 | { 128 | hmenu = LoadMenu(g2res_DLL,"G2WIN32"); 129 | if (hmenu == NULL) errhandler("Load menu failed",NULL); 130 | } 131 | 132 | // enlarge window for border and menu 133 | py = pdp->nHeight + GetSystemMetrics(SM_CYMENU) + 134 | 2 * GetSystemMetrics(SM_CYBORDER)+ 135 | GetSystemMetrics(SM_CYSMCAPTION)+3; 136 | px = pdp->nWidth + 2 * GetSystemMetrics(SM_CXBORDER)+3; 137 | 138 | /* Save the instance handle in static variable, which will be used in */ 139 | /* many subsequence calls from this application to Windows. */ 140 | 141 | /* Create a main window for this application instance. */ 142 | pdp->hinst = GetModuleHandle(NULL); 143 | 144 | hWnd = CreateWindow( 145 | "g2Window", // See RegisterClass() call. 146 | pdp->title, // Text for window title bar. 147 | WS_POPUPWINDOW | WS_CAPTION |WS_OVERLAPPED | WS_MINIMIZEBOX, 148 | pdp->x, pdp->y, 149 | px, py, 150 | NULL, // Overlapped windows have no parent. 151 | hmenu, // Use the window class menu. 152 | 0, // This instance owns this window. 153 | NULL // Pointer not needed. 154 | ); 155 | 156 | // If window could not be created, return "failure" 157 | 158 | if (!hWnd) 159 | { 160 | errhandler("CreateWindow",NULL); 161 | return (FALSE); // return failure :(( 162 | } 163 | 164 | #define WIDTH(x) (x.right-x.left+1) // Macro to get rect width 165 | #define HEIGHT(x) (x.bottom-x.top+1) // Macro to get rect height 166 | 167 | // How big is the window? 168 | GetClientRect( hWnd, &Rect ); 169 | 170 | // Need a DC 171 | hDC = GetDC( hWnd ); 172 | SetBkColor(hDC,RGB(255,255,255)); 173 | // Create a bitmap big enough to hold the window's image 174 | pdp->hBitmap = CreateCompatibleBitmap( hDC, WIDTH(Rect), HEIGHT(Rect) ); 175 | // printf("memdc size: %d %d\n",WIDTH(Rect),HEIGHT(Rect)); 176 | // Create MemDC 177 | pdp->hMemDC = CreateCompatibleDC(hDC); 178 | SelectObject( pdp->hMemDC, pdp->hBitmap ); 179 | // clean up 180 | ReleaseDC( hWnd, hDC ); 181 | #undef WIDTH 182 | #undef HEIGHT 183 | 184 | 185 | 186 | SetWindowLong(hWnd, GWL_USERDATA, (long)pdp); 187 | 188 | pdp->hwndThreadWindow = hWnd; 189 | // Make the window visible; update its client area; and return "success" 190 | ShowWindow(hWnd, SW_SHOWDEFAULT); // Show the window 191 | UpdateWindow(hWnd); // Sends WM_PAINT message 192 | //printf("pdp->messageloop ->= 1;\n"); 193 | pdp->messageloop = 1; 194 | //printf("pdp->messageloop = 1;\n"); 195 | 196 | while (GetMessage(&msg, NULL, 0, 0)) { 197 | TranslateMessage(&msg); 198 | DispatchMessage(&msg); 199 | } 200 | 201 | 202 | return (TRUE); // Returns success :) 203 | } 204 | 205 | 206 | 207 | -------------------------------------------------------------------------------- /g2-0.40/src/Win32/g2res.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID lpv) 5 | { 6 | return 1; 7 | } -------------------------------------------------------------------------------- /g2-0.40/src/Win32/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Developer Studio generated include file. 3 | // Used by g2_win32.rc 4 | // 5 | #define IDI_ICON1 101 6 | #define IDD_DIALOG1 104 7 | #define ID_FILE_SAVEASBMP 40002 8 | #define ID_FILE_COPY 40003 9 | #define ID_FILE_ABOUT 40005 10 | #define ID_FILE_CLOS 40006 11 | 12 | // Next default values for new objects 13 | // 14 | #ifdef APSTUDIO_INVOKED 15 | #ifndef APSTUDIO_READONLY_SYMBOLS 16 | #define _APS_NEXT_RESOURCE_VALUE 107 17 | #define _APS_NEXT_COMMAND_VALUE 40007 18 | #define _APS_NEXT_CONTROL_VALUE 1000 19 | #define _APS_NEXT_SYMED_VALUE 101 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /g2-0.40/src/X11/g2.xpm: -------------------------------------------------------------------------------- 1 | /* XPM */ 2 | static char * g2_xpm[] = { 3 | "40 40 137 2", 4 | " c none", 5 | ". c #6B1214", 6 | "+ c #6E1314", 7 | "@ c #891C18", 8 | "# c #8F1E19", 9 | "$ c #821A17", 10 | "% c #841A17", 11 | "& c #BD2D1E", 12 | "* c #EC3C24", 13 | "= c #C22F1F", 14 | "- c #7D1816", 15 | "; c #851A17", 16 | "> c #731515", 17 | ", c #BC2C1E", 18 | "' c #B1291D", 19 | ") c #8D1D18", 20 | "! c #721415", 21 | "~ c #942019", 22 | "{ c #A0231B", 23 | "] c #C93120", 24 | "^ c #6A1214", 25 | "/ c #6D1314", 26 | "( c #771616", 27 | "_ c #8A1C18", 28 | ": c #A5251B", 29 | "< c #C12E1F", 30 | "[ c #D53522", 31 | "} c #9E231B", 32 | "| c #6F1315", 33 | "1 c #681114", 34 | "2 c #7A1716", 35 | "3 c #831A17", 36 | "4 c #7F1817", 37 | "5 c #911E19", 38 | "6 c #AA271C", 39 | "7 c #C73020", 40 | "8 c #E03823", 41 | "9 c #E73B24", 42 | "0 c #D23421", 43 | "a c #B42A1D", 44 | "b c #962019", 45 | "c c #7E1817", 46 | "d c #711415", 47 | "e c #9B221A", 48 | "f c #7F1917", 49 | "g c #AF281D", 50 | "h c #CA3120", 51 | "i c #DD3722", 52 | "j c #E13923", 53 | "k c #D73522", 54 | "l c #C42F1F", 55 | "m c #AE281D", 56 | "n c #9D221A", 57 | "o c #931F19", 58 | "p c #8E1E19", 59 | "q c #861B18", 60 | "r c #751515", 61 | "s c #B52A1D", 62 | "t c #881B18", 63 | "u c #6C1214", 64 | "v c #761615", 65 | "w c #AD281C", 66 | "x c #D83622", 67 | "y c #D03321", 68 | "z c #C83120", 69 | "A c #C22E1F", 70 | "B c #BD2D1F", 71 | "C c #A9261C", 72 | "D c #A4251B", 73 | "E c #DB3722", 74 | "F c #851B17", 75 | "G c #A3241B", 76 | "H c #E43A23", 77 | "I c #B32A1D", 78 | "J c #9C221A", 79 | "K c #9E231A", 80 | "L c #D33421", 81 | "M c #901E19", 82 | "N c #A7261C", 83 | "O c #C02E1F", 84 | "P c #AC271C", 85 | "Q c #8E1D18", 86 | "R c #761515", 87 | "S c #691114", 88 | "T c #8B1C18", 89 | "U c #761616", 90 | "V c #B82B1E", 91 | "W c #871B18", 92 | "X c #671114", 93 | "Y c #8C1D18", 94 | "Z c #7B1716", 95 | "` c #861B17", 96 | " . c #881C18", 97 | ".. c #801917", 98 | "+. c #A6251C", 99 | "@. c #CB3120", 100 | "#. c #DC3722", 101 | "$. c #791716", 102 | "%. c #9A221A", 103 | "&. c #BA2C1E", 104 | "*. c #98211A", 105 | "=. c #B2291D", 106 | "-. c #99211A", 107 | ";. c #B62B1E", 108 | ">. c #D13421", 109 | ",. c #D53521", 110 | "'. c #CE3321", 111 | "). c #952019", 112 | "!. c #EB3C24", 113 | "~. c #E83B24", 114 | "{. c #DE3823", 115 | "]. c #9F231B", 116 | "^. c #BB2C1E", 117 | "/. c #CF3321", 118 | "(. c #C32F1F", 119 | "_. c #7C1816", 120 | ":. c #7E1816", 121 | "<. c #DA3622", 122 | "[. c #E63A24", 123 | "}. c #EA3C24", 124 | "|. c #B0281D", 125 | "1. c #D63522", 126 | "2. c #E23923", 127 | "3. c #E53A23", 128 | "4. c #AB271C", 129 | "5. c #D93622", 130 | "6. c #811917", 131 | "7. c #97211A", 132 | "8. c #7C1716", 133 | "9. c #741515", 134 | "0. c #A8261C", 135 | "a. c #A2241B", 136 | "b. c #D43421", 137 | "c. c #D43521", 138 | "d. c #CC3220", 139 | "e. c #E93B24", 140 | "f. c #BC2D1E", 141 | " ", 142 | " ", 143 | " ", 144 | " ", 145 | " ", 146 | " ", 147 | " ", 148 | " . + @ ", 149 | " # $ % & * = - ", 150 | " ; > , ' ", 151 | " ) ! ~ ", 152 | " { ] ", 153 | " . ^ / ( _ : < [ & } $ | 1 ^ 2 ", 154 | " _ 3 4 $ 5 6 7 8 * 9 0 a b c d . . ^ $ 7 ", 155 | " e @ f 3 ~ g h i j k l m n o p ) _ q % r s ", 156 | " t ! u v # w x y z l A B s C D E ", 157 | " ^ | F G H E h I J K D L ", 158 | " 3 M N O P Q R u S S . T U ", 159 | " } 6 a ^ / f V W X Y 6 5 Z ( u ", 160 | " ` .Y ..M G +.{ @.#.x [ C u 2 ", 161 | " / $.# $ .Y ", 162 | " f %.&. . | $. ", 163 | " *.' = v @ +. ", 164 | " g &.&.=. $ -.;.>. ", 165 | " ,.,.0 y '. ).' 7 >. ", 166 | " !.!.~.{.] $ ].^./.k k ", 167 | " ~.E (.: T _.:.# C l <.[.!.!.}. ", 168 | " 7 |.].e G a 7 1.{.j 2.3.9 9 ", 169 | " ].K G 4.' a ;.&.(. #.j 5. ", 170 | " 6.% ) }.8 ] ", 171 | " >.;.e ", 172 | " G _ ( u ", 173 | " 7.t 8.R 9.> ", 174 | " f o +.' I m 0.D G a.].). ", 175 | " 7 b.5.x 1.[ 1.c.d.^.a. ", 176 | " * e.9 9 }.* [.1.f. ", 177 | " ", 178 | " ", 179 | " ", 180 | " "}; 181 | -------------------------------------------------------------------------------- /g2-0.40/src/X11/g2_X11.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #ifndef _G2_X11_H 19 | #define _G2_X11_H 20 | 21 | int g2_open_X11(int width, int height); 22 | 23 | int g2_open_X11X(int width, int height, 24 | int x, int y, 25 | char *window_name, char *icon_name, 26 | char *icon_data, 27 | int icon_width, int icon_height); 28 | 29 | #endif /* _G2_X11_H */ 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /g2-0.40/src/X11/g2_X11_P.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #ifndef _G2_X11_P_H 19 | #define _G2_X11_P_H 20 | 21 | #include 22 | 23 | typedef struct { 24 | Display *display; 25 | Window window; 26 | Window root; 27 | Colormap colormap; 28 | GC gc; 29 | 30 | unsigned long *inks; /* allocated colors*/ 31 | int NofInks; /* N of allocated colors */ 32 | int width; /* window dimensions */ 33 | int height; 34 | } g2_X11_device; 35 | 36 | 37 | int g2_X11_init_X11X(int pid, int width, int height, 38 | int xposition, int yposition, 39 | char *window_name, char *icon_name, 40 | char *icon_data, 41 | unsigned int icon_width, unsigned int icon_height); 42 | int g2_X11_delete(int pid, void *pdp); 43 | int g2_X11_clear(int pid, void *pdp); 44 | int g2_X11_flush(int pid, void *pdp); 45 | int g2_X11_ink(int pid, void *pdp, 46 | double red, double green, double blue); 47 | int g2_X11_clear_palette(int pid, void *pdp); 48 | int g2_X11_reset_palette(int pid, void *pdp); 49 | int g2_X11_set_background(int pid, void *pdp, int color); 50 | int g2_X11_pen(int pid, void *pdp, int color); 51 | int g2_X11_paper(int pid, void *pdp, int color); 52 | int g2_X11_set_line_width(int pid, void *pdp, int w); 53 | int g2_X11_set_dash(int pid, void *pdp, int n, int *data); 54 | int g2_X11_set_font_size(int pid, void *pdp, int size); 55 | int g2_X11_plot(int pid, void *pdp, int x, int y); 56 | int g2_X11_line(int pid, void *pdp, int x1, int y1, int x2, int y2); 57 | int g2_X11_poly_line(int pid, void *pdp, int N, int *p); 58 | int g2_X11_polygon(int pid, void *pdp, int N, int *p); 59 | int g2_X11_filled_polygon(int pid, void *pdp, int N, int *p); 60 | int g2_X11_triangle(int pid, void *pdp, 61 | int x1, int y1, 62 | int x2, int y2, 63 | int x3, int y3); 64 | int g2_X11_filled_triangle(int pid, void *pdp, int x1, int y1, 65 | int x2, int y2, 66 | int x3, int y3); 67 | int g2_X11_rectangle(int pid, void *pdp, int x1, int y1, int x2, int y2); 68 | int g2_X11_filled_rectangle(int pid, void *pdp, 69 | int x1, int y1, int x2, int y2); 70 | int g2_X11_arc(int pid, void *pdp, int x, int y, 71 | int r1, int r2, double a1, double a2); 72 | int g2_X11_filled_arc(int pid, void *pdp, int x, int y, 73 | int r1, int r2, double a1, double a2); 74 | int g2_X11_ellipse(int pid, void *pdp, int x, int y, int r1, int r2); 75 | int g2_X11_filled_ellipse(int pid, void *pdp, int x, int y, int r1, int r2); 76 | int g2_X11_draw_string(int pid, void *pdp, int x, int y, char *text); 77 | int g2_X11_image(int pid, int x, int y, int width, int height, int *pen_array); 78 | 79 | #endif /* _G2_X11_P_H */ 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /g2-0.40/src/X11/g2_X11_funix.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #ifndef _G2_X11_FUNIX_H 19 | #define _G2_X11_FUNIX_H 20 | 21 | #include "g2_X11_P.h" 22 | #include "g2_physical_device.h" 23 | 24 | 25 | const g2_funix_fun g2_X11_funix[] = { 26 | { g2_Delete, g2_X11_delete }, 27 | { g2_Ink, g2_X11_ink }, 28 | { g2_Pen, g2_X11_pen }, 29 | { g2_SetBackground, g2_X11_set_background }, 30 | { g2_ClearPalette, g2_X11_clear_palette }, 31 | { g2_SetLineWidth, g2_X11_set_line_width }, 32 | { g2_SetDash, g2_X11_set_dash }, 33 | { g2_SetFontSize, g2_X11_set_font_size }, 34 | { g2_Clear, g2_X11_clear }, 35 | { g2_Flush, g2_X11_flush }, 36 | { g2_Save, g2_X11_flush }, 37 | { g2_Plot, g2_X11_plot }, 38 | { g2_Line, g2_X11_line }, 39 | { g2_PolyLine, g2_X11_poly_line }, 40 | { g2_Polygon, g2_X11_polygon }, 41 | { g2_FilledPolygon, g2_X11_filled_polygon }, 42 | { g2_Rectangle, g2_X11_rectangle }, 43 | { g2_FilledRectangle, g2_X11_filled_rectangle }, 44 | { g2_Triangle, g2_X11_triangle }, 45 | { g2_FilledTriangle, g2_X11_filled_triangle }, 46 | { g2_Arc, g2_X11_arc }, 47 | { g2_FilledArc, g2_X11_filled_arc }, 48 | { g2_Ellipse, g2_X11_ellipse }, 49 | { g2_FilledEllipse, g2_X11_filled_ellipse }, 50 | { g2_Circle, NULL }, 51 | { g2_FilledCircle, NULL }, 52 | { g2_String, g2_X11_draw_string }, 53 | { g2_Image, NULL }, 54 | { g2_FUNIX_NULL, NULL } }; 55 | 56 | 57 | #endif /* _G2_X11_FUNIX_H */ 58 | -------------------------------------------------------------------------------- /g2-0.40/src/g2.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 3 | ** This file is part of the g2 library 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #ifndef _G2_H 19 | #define _G2_H 20 | 21 | #define G2_VERSION "0.40" 22 | 23 | #define G2LD g2_ld() 24 | 25 | enum QPshape { 26 | QPrect, 27 | QPcirc 28 | }; 29 | 30 | /* compatibility with old versions */ 31 | #define g2_draw_string(dev, x, y, text) g2_string((dev), (x), (y), (text)) 32 | 33 | 34 | 35 | int g2_open_vd(void); 36 | void g2_attach(int vd_dev, int dev); 37 | void g2_detach(int vd_dev, int dev); 38 | 39 | void g2_close(int dev); 40 | void g2_set_auto_flush(int dev, int on_off); 41 | void g2_flush(int dev); 42 | void g2_save(int dev); 43 | void g2_set_coordinate_system(int dev, double x_origin, double y_origin, 44 | double x_mul, double y_mul); 45 | 46 | int g2_ld(); 47 | void g2_set_ld(int dev); 48 | 49 | int g2_ink(int pd_dev, double red, double green, double blue); 50 | void g2_pen(int dev, int color); 51 | void g2_set_dash(int dev, int N, double *dashes); 52 | void g2_set_font_size(int dev, double size); 53 | void g2_set_line_width(int dev, double w); 54 | void g2_clear_palette(int dev); 55 | void g2_reset_palette(int dev); 56 | void g2_allocate_basic_colors(int dev); 57 | 58 | void g2_clear(int dev); 59 | void g2_set_background(int dev, int color); 60 | 61 | void g2_move(int dev, double x, double y); 62 | void g2_move_r(int dev, double dx, double dy); 63 | 64 | void g2_plot(int dev, double x, double y); 65 | void g2_plot_r(int dev, double dx, double dy); 66 | void g2_line(int dev, double x1, double y1, double x2, double y2); 67 | void g2_line_r(int dev, double dx, double dy); 68 | void g2_line_to(int dev, double x, double y); 69 | void g2_poly_line(int dev, int N_pt, double *points); 70 | void g2_triangle(int dev, double x1, double y1, 71 | double x2, double y2, 72 | double x3, double y3); 73 | void g2_filled_triangle(int dev, double x1, double y1, 74 | double x2, double y2, 75 | double x3, double y3); 76 | void g2_rectangle(int dev, double x1, double y1, double x2, double y2); 77 | void g2_filled_rectangle(int dev, double x1, double y1, double x2, double y2); 78 | void g2_polygon(int dev, int N_pt, double *points); 79 | void g2_filled_polygon(int dev, int N_pt, double *points); 80 | void g2_circle(int dev, double x, double y, double r); 81 | void g2_filled_circle(int dev, double x, double y, double r); 82 | void g2_ellipse(int dev, double x, double y, double r1, double r2); 83 | void g2_filled_ellipse(int dev, double x, double y, double r1, double r2); 84 | void g2_arc(int dev, 85 | double x, double y, 86 | double r1, double r2, 87 | double a1, double a2); 88 | void g2_filled_arc(int dev, double x, double y, 89 | double r1, double r2, 90 | double a1, double a2); 91 | void g2_string(int dev, double x, double y, char *text); 92 | void g2_image(int dev, double x, double y, int x_size, int y_size, int *pens); 93 | 94 | void g2_set_QP(int dev, double d, enum QPshape shape); 95 | void g2_plot_QP(int dev, double x, double y); 96 | 97 | 98 | /** Actualy private function, but... **/ 99 | int g2_device_exist(int dix); 100 | 101 | #endif /* _G2_H */ 102 | -------------------------------------------------------------------------------- /g2-0.40/src/g2_config.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #ifndef _G2_CONFIG_H 19 | #define _G2_CONFIG_H 20 | 21 | /* 22 | * 23 | * Some g2 defines 24 | * 25 | */ 26 | #define G2_X11_FONT "-*-times-medium-r-normal--%d-*-*-*-*-*-*-*" 27 | #define G2_PSFONT "/Times-Roman" 28 | #define WARNINGS 29 | 30 | 31 | #endif /* _G2_CONFIG_H */ 32 | -------------------------------------------------------------------------------- /g2-0.40/src/g2_control_pd.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #include 19 | #include 20 | #include 21 | 22 | #include "g2.h" 23 | #include "g2_device.h" 24 | #include "g2_physical_device.h" 25 | #include "g2_util.h" 26 | #include "g2_funix.h" 27 | 28 | 29 | 30 | /* 31 | * 32 | * Flush output 33 | * 34 | */ 35 | void g2_flush_pd(g2_physical_device *pd) 36 | { 37 | if(pd->ff[g2_Flush].fun!=NULL) { 38 | pd->ff[g2_Flush].fun(pd->pid, pd->pdp); 39 | } else { 40 | /* emulate ... with .... */ 41 | } 42 | } 43 | 44 | 45 | 46 | /* 47 | * 48 | * Save output 49 | * 50 | */ 51 | void g2_save_pd(g2_physical_device *pd) 52 | { 53 | if(pd->ff[g2_Save].fun!=NULL) { 54 | pd->ff[g2_Save].fun(pd->pid, pd->pdp); 55 | } else { 56 | /* emulate ... with .... */ 57 | } 58 | } 59 | 60 | 61 | 62 | /* 63 | * 64 | * Clear device 65 | * 66 | */ 67 | void g2_clear_pd(g2_physical_device *pd) 68 | { 69 | if(pd->ff[g2_Clear].fun!=NULL) { 70 | pd->ff[g2_Clear].fun(pd->pid, pd->pdp); 71 | } else { 72 | /* emulate ... with .... */ 73 | } 74 | } 75 | 76 | 77 | 78 | /* 79 | * 80 | * Set pen 81 | * 82 | */ 83 | void g2_pen_pd(g2_physical_device *pd, int color) 84 | { 85 | if(pd->ff[g2_Pen].fun!=NULL) { 86 | pd->ff[g2_Pen].fun(pd->pid, pd->pdp, color); 87 | } else { 88 | /* emulate ... with .... */ 89 | } 90 | } 91 | 92 | 93 | 94 | /* 95 | * 96 | * Set background color 97 | * 98 | */ 99 | void g2_set_background_pd(g2_physical_device *pd, int color) 100 | { 101 | if(pd->ff[g2_SetBackground].fun!=NULL) { 102 | pd->ff[g2_SetBackground].fun(pd->pid, pd->pdp, color); 103 | } else { 104 | /* emulate ... with .... */ 105 | } 106 | } 107 | 108 | 109 | 110 | /* 111 | * 112 | * Set ink 113 | * 114 | */ 115 | int g2_ink_pd(g2_physical_device *pd, double red, double green, double blue) 116 | { 117 | int rv=-1; 118 | 119 | if(pd->ff[g2_Ink].fun!=NULL) { 120 | rv=pd->ff[g2_Ink].fun(pd->pid, pd->pdp, 121 | red, green, blue); 122 | } else { 123 | /* emulate ... with .... */ 124 | } 125 | return rv; 126 | } 127 | 128 | 129 | 130 | 131 | /* 132 | * 133 | * Clear palette 134 | * 135 | */ 136 | void g2_clear_palette_pd(g2_physical_device *pd) 137 | { 138 | if(pd->ff[g2_ClearPalette].fun!=NULL) { 139 | pd->ff[g2_ClearPalette].fun(pd->pid, pd->pdp); 140 | } else { 141 | /* emulate ... with .... */ 142 | } 143 | } 144 | 145 | 146 | /* 147 | * 148 | * Allocate basic colors 149 | * 150 | */ 151 | void g2_allocate_basic_colors_pd(g2_physical_device *pd) 152 | { 153 | double ct[3]={0.0, 0.5, 1.0}; 154 | int r, g, b; 155 | 156 | if(pd->ff[g2_Ink].fun!=NULL) { 157 | pd->ff[g2_Ink].fun(pd->pid, pd->pdp, /* white */ 158 | 1.0, 1.0, 1.0); 159 | pd->ff[g2_Ink].fun(pd->pid, pd->pdp, /* black */ 160 | 0.0, 0.0, 0.0); 161 | for(r=0;r<3;r++) 162 | for(g=0;g<3;g++) 163 | for(b=0;b<3;b++) 164 | if((r==2 && g==2 && b==2) || 165 | (r==0 && g==0 && b==0)) 166 | continue; 167 | else 168 | pd->ff[g2_Ink].fun(pd->pid, pd->pdp, 169 | ct[r], ct[g], ct[b]); 170 | } 171 | } 172 | 173 | 174 | /* 175 | * 176 | * Set font size 177 | * 178 | */ 179 | void g2_set_font_size_pd(g2_physical_device *pd, double size) 180 | { 181 | int is; 182 | double ds; 183 | 184 | if(pd->ff[g2_SetFontSize].fun!=NULL) { 185 | switch(pd->coor_type) { 186 | case g2_IntCoor: 187 | is=dtoi(size*fabs(pd->a22)); /* to pd coordinates */ 188 | pd->ff[g2_SetFontSize].fun(pd->pid, pd->pdp, is); 189 | break; 190 | case g2_DoubleCoor: 191 | ds=size*fabs(pd->a22); /* to pd coordinates */ 192 | pd->ff[g2_SetFontSize].fun(pd->pid, pd->pdp, ds); 193 | break; 194 | } 195 | } else { 196 | /* emulate ... with .... */ 197 | } 198 | } 199 | 200 | 201 | 202 | /* 203 | * 204 | * Set line width 205 | * 206 | */ 207 | void g2_set_line_width_pd(g2_physical_device *pd, double w) 208 | { 209 | int iw; 210 | double dw; 211 | 212 | if(pd->ff[g2_SetLineWidth].fun!=NULL) { 213 | switch(pd->coor_type) { 214 | case g2_IntCoor: 215 | iw=dtoi(w*fabs(pd->a22)); /* to pd coordinates */ 216 | pd->ff[g2_SetLineWidth].fun(pd->pid, pd->pdp, iw); 217 | break; 218 | case g2_DoubleCoor: 219 | dw=w*fabs(pd->a22); /* to pd coordinates */ 220 | pd->ff[g2_SetLineWidth].fun(pd->pid, pd->pdp, dw); 221 | break; 222 | } 223 | } else { 224 | /* emulate ... with .... */ 225 | } 226 | } 227 | 228 | 229 | 230 | /* 231 | * 232 | * Set dash 233 | * 234 | */ 235 | void g2_set_dash_pd(g2_physical_device *pd, int N, double *dashes) 236 | { 237 | int j; 238 | double *dd=NULL; 239 | int *id=NULL; 240 | 241 | if(pd->ff[g2_SetDash].fun!=NULL) { 242 | switch(pd->coor_type) { 243 | case g2_IntCoor: 244 | if(dashes!=NULL) { 245 | id=g2_malloc(N*sizeof(int)); 246 | for(j=0;ja22)); 248 | pd->ff[g2_SetDash].fun(pd->pid, pd->pdp, N, id); 249 | g2_free(id); 250 | } else 251 | pd->ff[g2_SetDash].fun(pd->pid, pd->pdp, 0, NULL); 252 | break; 253 | case g2_DoubleCoor: 254 | if(dashes!=NULL) { 255 | dd=g2_malloc(N*sizeof(double)); 256 | for(j=0;ja22); 258 | pd->ff[g2_SetDash].fun(pd->pid, pd->pdp, N, dd); 259 | g2_free(dd); 260 | break; 261 | } else 262 | pd->ff[g2_SetDash].fun(pd->pid, pd->pdp, 0, NULL); 263 | } 264 | } else { 265 | /* emulate ... with .... */ 266 | } 267 | } 268 | -------------------------------------------------------------------------------- /g2-0.40/src/g2_control_pd.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #ifndef _G2_CONTROL_PD_H 19 | #define _G2_CONTROL_PD_H 20 | 21 | #include "g2_physical_device.h" 22 | 23 | void g2_flush_pd(g2_physical_device *pd); 24 | void g2_save_pd(g2_physical_device *pd); 25 | void g2_clear_pd(g2_physical_device *pd); 26 | void g2_pen_pd(g2_physical_device *pd, int color); 27 | void g2_set_background_pd(g2_physical_device *pd, int color); 28 | int g2_ink_pd(g2_physical_device *pd, double red, double green, double blue); 29 | void g2_clear_palette_pd(g2_physical_device *pd); 30 | void g2_allocate_basic_colors_pd(g2_physical_device *pd); 31 | void g2_set_font_size_pd(g2_physical_device *pd, double size); 32 | void g2_set_line_width_pd(g2_physical_device *pd, double w); 33 | void g2_set_dash_pd(g2_physical_device *pd, int N, double *dashes); 34 | 35 | #endif /* _G2_CONTROL_PD_H */ 36 | -------------------------------------------------------------------------------- /g2-0.40/src/g2_device.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #include 19 | 20 | #include "g2.h" 21 | #include "g2_device.h" 22 | #include "g2_physical_device.h" 23 | #include "g2_virtual_device.h" 24 | #include "g2_util.h" 25 | 26 | int __g2_last_device=-1; /* last acces. device (ld) */ 27 | 28 | 29 | static int g2_dev_size=0; /* size of devices array */ 30 | static g2_device *g2_dev=NULL; /* devices array */ 31 | 32 | static int g2_get_free_device(); 33 | static void g2_init_device(int dix); 34 | 35 | 36 | /* 37 | * 38 | * Register physical device 39 | * 40 | */ 41 | int g2_register_physical_device(int pid, 42 | void *pdp, 43 | g2_coor ct, 44 | const g2_funix_fun *ff, 45 | double a11, double a22, 46 | double b1, double b2) 47 | { 48 | int dix; 49 | 50 | dix=g2_get_free_device(); 51 | g2_init_device(dix); 52 | g2_dev[dix].t=g2_PD; 53 | g2_dev[dix].d.pd=g2_create_physical_device(pid, pdp, 54 | ct, ff, 55 | a11, a22, 56 | b1, b2); 57 | 58 | __g2_last_device=dix; 59 | return dix; 60 | } 61 | 62 | 63 | 64 | /* 65 | * 66 | * Register virtual device 67 | * 68 | */ 69 | int g2_register_virtual_device() 70 | { 71 | int dix; 72 | 73 | dix=g2_get_free_device(); 74 | g2_init_device(dix); 75 | g2_dev[dix].t=g2_VD; 76 | g2_dev[dix].d.vd=g2_create_virtual_device(); 77 | 78 | return dix; 79 | } 80 | 81 | 82 | /* 83 | * 84 | * Init device 85 | * 86 | */ 87 | void g2_init_device(int dix) 88 | { 89 | g2_dev[dix].t=g2_ILLEGAL; 90 | g2_dev[dix].dix=dix; 91 | g2_dev[dix].x=0.0; /* set cursor */ 92 | g2_dev[dix].y=0.0; 93 | g2_dev[dix].auto_flush=1; /* set auto flush */ 94 | g2_dev[dix].QPd=1.0; /* Quasi pixel spec. */ 95 | g2_dev[dix].QPshape=QPrect; 96 | } 97 | 98 | /* 99 | * 100 | * Return pointer to device dix 101 | * 102 | */ 103 | g2_device *g2_get_device_pointer(int dix) 104 | { 105 | if(dix<0 || dix>=g2_dev_size) 106 | return NULL; 107 | if(g2_dev[dix].t==g2_NDEV) 108 | return NULL; 109 | 110 | return &g2_dev[dix]; 111 | } 112 | 113 | 114 | /* 115 | * 116 | * Return device type 117 | * 118 | */ 119 | g2_device_type g2_get_device_type(int dix) 120 | { 121 | if(dix<0 || dix>=g2_dev_size) 122 | return g2_ILLEGAL; 123 | return g2_dev[dix].t; 124 | } 125 | 126 | 127 | /* 128 | * 129 | * 1 if device exist otherwise 0 130 | * 131 | */ 132 | int g2_device_exist(int dix) 133 | { 134 | if(dix<0 || dix>=g2_dev_size || 135 | g2_dev[dix].t==g2_ILLEGAL || g2_dev[dix].t==g2_NDEV) 136 | return 0; 137 | return 1; 138 | } 139 | 140 | 141 | /* 142 | * 143 | * Destroy device 144 | * 145 | */ 146 | void g2_destroy_device(int dix) 147 | { 148 | int i; 149 | 150 | for(i=0;i 19 | #include 20 | #include "g2.h" 21 | #include "g2_util.h" 22 | 23 | /* 24 | * 25 | * g2 Fortran Interface 26 | * 27 | */ 28 | #ifdef LINUX 29 | #define FIF(funame) funame ## __ 30 | #else 31 | #define FIF(funame) funame ## _ 32 | #endif 33 | 34 | #define F_REAL float /* everything is float (real) !!!!!!!!!!!!!! */ 35 | #define F_CHAR char /* only char is char */ 36 | #define F_CHAR_LENGTH int /* and char length is integer */ 37 | 38 | 39 | /**********************************************************/ 40 | 41 | #ifdef DO_PS 42 | 43 | #include "PS/g2_PS.h" 44 | 45 | F_REAL FIF(g2_open_ps)(F_CHAR *text, F_REAL *paper, F_REAL *orientation, 46 | F_CHAR_LENGTH length) 47 | { 48 | char *str; 49 | int rv; 50 | 51 | str=g2_malloc((length+1)*sizeof(char)); 52 | strncpy(str, text, length); 53 | str[length]='\0'; 54 | rv=g2_open_PS(str, dtoi(*paper), dtoi(*orientation)); 55 | g2_free(str); 56 | 57 | return (F_REAL)rv; 58 | } 59 | 60 | #endif /* DO_PS */ 61 | 62 | /**********************************************************/ 63 | 64 | #ifdef DO_X11 65 | 66 | #include "X11/g2_X11.h" 67 | 68 | F_REAL FIF(g2_open_x11)(F_REAL *width, F_REAL *height) 69 | { 70 | return (F_REAL)g2_open_X11(*width, *height); 71 | } 72 | 73 | /* g2_open_x11x will be implemented in next releases */ 74 | 75 | #endif /* DO_X11 */ 76 | 77 | /**********************************************************/ 78 | 79 | #ifdef DO_GIF 80 | 81 | #include "GIF/g2_GIF.h" 82 | 83 | F_REAL FIF(g2_open_gif)(F_CHAR *text, F_REAL *width, F_REAL *height, 84 | F_CHAR_LENGTH length) 85 | { 86 | char *str; 87 | int rv; 88 | 89 | str=g2_malloc((length+1)*sizeof(char)); 90 | strncpy(str, text, length); 91 | str[length]='\0'; 92 | 93 | rv=0; 94 | 95 | g2_free(str); 96 | 97 | return (F_REAL)rv; 98 | } 99 | 100 | #endif /* DO_GIF */ 101 | 102 | /**********************************************************/ 103 | 104 | 105 | F_REAL FIF(g2_open_vd)(void) 106 | { 107 | return (F_REAL)g2_open_vd(); 108 | } 109 | 110 | 111 | void FIF(g2_attach)(F_REAL *vd_dev, F_REAL *dev) 112 | { 113 | g2_attach(dtoi(*vd_dev), dtoi(*dev)); 114 | } 115 | 116 | 117 | void FIF(g2_detach)(F_REAL *vd_dev, F_REAL *dev) 118 | { 119 | g2_detach(dtoi(*vd_dev), dtoi(*dev)); 120 | } 121 | 122 | 123 | 124 | void FIF(g2_close)(F_REAL *dev) 125 | { 126 | g2_close(dtoi(*dev)); 127 | } 128 | 129 | 130 | void FIF(g2_set_auto_flush)(F_REAL *dev, F_REAL *on_off) 131 | { 132 | g2_set_auto_flush(dtoi(*dev), *on_off); 133 | } 134 | 135 | 136 | void FIF(g2_set_coordinate_system)(F_REAL *dev, 137 | F_REAL *x_origin, F_REAL *y_origin, 138 | F_REAL *x_mul, F_REAL *y_mul) 139 | { 140 | g2_set_coordinate_system(dtoi(*dev), 141 | *x_origin, *y_origin, 142 | *x_mul, *y_mul); 143 | } 144 | 145 | 146 | F_REAL FIF(g2_ld)(void) 147 | { 148 | return (F_REAL)g2_ld(); 149 | } 150 | 151 | 152 | void FIF(g2_set_ld)(F_REAL *dev) 153 | { 154 | g2_set_ld(dtoi(*dev)); 155 | } 156 | 157 | 158 | 159 | void FIF(g2_flush)(F_REAL *dev) 160 | { 161 | g2_flush(dtoi(*dev)); 162 | } 163 | 164 | 165 | void FIF(g2_save)(F_REAL *dev) 166 | { 167 | g2_save(dtoi(*dev)); 168 | } 169 | 170 | 171 | 172 | 173 | void FIF(g2_arc)(F_REAL *dev, F_REAL *x, F_REAL *y, 174 | F_REAL *r1, F_REAL *r2, F_REAL *a1, F_REAL *a2) 175 | { 176 | g2_arc(dtoi(*dev), *x, *y, *r1, *r2, *a1, *a2); 177 | } 178 | 179 | 180 | void FIF(g2_circle)(F_REAL *dev, F_REAL *x, F_REAL *y, F_REAL *r) 181 | { 182 | g2_circle(dtoi(*dev), *x, *y, *r); 183 | } 184 | 185 | 186 | void FIF(g2_clear)(F_REAL *dev) 187 | { 188 | g2_clear(dtoi(*dev)); 189 | } 190 | 191 | 192 | void FIF(g2_clear_palette)(F_REAL *dev) 193 | { 194 | g2_clear_palette(dtoi(*dev)); 195 | } 196 | 197 | 198 | void FIF(g2_string)(F_REAL *dev, F_REAL *x, F_REAL *y, F_CHAR *text, 199 | F_CHAR_LENGTH length) 200 | { 201 | char *str; 202 | str=g2_malloc((length+1)*sizeof(char)); 203 | strncpy(str, text, length); 204 | str[length]='\0'; 205 | g2_string(dtoi(*dev), *x, *y, str); 206 | g2_free(str); 207 | } 208 | 209 | 210 | void FIF(g2_ellipse)(F_REAL *dev, F_REAL *x, F_REAL *y, F_REAL *r1, F_REAL *r2) 211 | { 212 | g2_ellipse(dtoi(*dev), *x, *y, *r1, *r2); 213 | } 214 | 215 | 216 | void FIF(g2_filled_arc)(F_REAL *dev, F_REAL *x, F_REAL *y, 217 | F_REAL *r1, F_REAL *r2, 218 | F_REAL *a1, F_REAL *a2) 219 | { 220 | g2_filled_arc(dtoi(*dev), *x, *y, *r1, *r2, *a1, *a2); 221 | } 222 | 223 | 224 | void FIF(g2_filled_circle)(F_REAL *dev, F_REAL *x, F_REAL *y, F_REAL *r) 225 | { 226 | g2_filled_circle(dtoi(*dev), *x, *y, *r); 227 | } 228 | 229 | 230 | void FIF(g2_filled_ellipse)(F_REAL *dev, F_REAL *x, F_REAL *y, F_REAL *r1, F_REAL *r2) 231 | { 232 | g2_filled_ellipse(dtoi(*dev), *x, *y, *r1, *r2); 233 | } 234 | 235 | 236 | void FIF(g2_filled_triangle)(F_REAL *dev, F_REAL *x1, F_REAL *y1, 237 | F_REAL *x2, F_REAL *y2, 238 | F_REAL *x3, F_REAL *y3) 239 | { 240 | g2_filled_triangle(dtoi(*dev), *x1, *y1, *x2, *y2, *x3, *y3); 241 | } 242 | 243 | 244 | F_REAL FIF(g2_ink)(F_REAL *dev, F_REAL *red, F_REAL *green, F_REAL *blue) 245 | { 246 | return (F_REAL)g2_ink(dtoi(*dev), *red, *green, *blue); 247 | } 248 | 249 | 250 | void FIF(g2_line)(F_REAL *dev, F_REAL *x1, F_REAL *y1, F_REAL *x2, F_REAL *y2) 251 | { 252 | g2_line(dtoi(*dev), *x1, *y1, *x2, *y2); 253 | } 254 | 255 | 256 | void FIF(g2_poly_line)(F_REAL *dev, F_REAL N, F_REAL **points) 257 | { 258 | } 259 | 260 | 261 | void FIF(g2_polygon)(F_REAL *dev, F_REAL N, F_REAL **points) 262 | { 263 | } 264 | 265 | 266 | void FIF(g2_filled_polygon)(F_REAL *dev, F_REAL N, F_REAL **points) 267 | { 268 | } 269 | 270 | 271 | void FIF(g2_line_r)(F_REAL *dev, F_REAL *dx, F_REAL *dy) 272 | { 273 | g2_line_r(dtoi(*dev), *dx, *dy); 274 | } 275 | 276 | 277 | void FIF(g2_line_to)(F_REAL *dev, F_REAL *x, F_REAL *y) 278 | { 279 | g2_line_to(dtoi(*dev), *x, *y); 280 | } 281 | 282 | 283 | void FIF(g2_move)(F_REAL *dev, F_REAL *x, F_REAL *y) 284 | { 285 | g2_move(dtoi(*dev), *x, *y); 286 | } 287 | 288 | 289 | void FIF(g2_move_r)(F_REAL *dev, F_REAL *dx, F_REAL *dy) 290 | { 291 | g2_move_r(dtoi(*dev), *dx, *dy); 292 | } 293 | 294 | 295 | void FIF(g2_pen)(F_REAL *dev, F_REAL *color) 296 | { 297 | g2_pen(dtoi(*dev), dtoi(*color)); 298 | } 299 | 300 | 301 | void FIF(g2_plot)(F_REAL *dev, F_REAL *x, F_REAL *y) 302 | { 303 | g2_plot(dtoi(*dev), *x, *y); 304 | } 305 | 306 | 307 | void FIF(g2_plot_r)(F_REAL *dev, F_REAL *dx, F_REAL *dy) 308 | { 309 | g2_plot_r(dtoi(*dev), *dx, *dy); 310 | } 311 | 312 | 313 | void FIF(g2_rectangle)(F_REAL *dev, 314 | F_REAL *x1, F_REAL *y1, 315 | F_REAL *x2, F_REAL *y2) 316 | { 317 | g2_rectangle(dtoi(*dev), *x1, *y1, *x2, *y2); 318 | } 319 | 320 | 321 | void FIF(g2_filled_rectangle)(F_REAL *dev, 322 | F_REAL *x1, F_REAL *y1, 323 | F_REAL *x2, F_REAL *y2) 324 | { 325 | g2_filled_rectangle(dtoi(*dev), *x1, *y1, *x2, *y2); 326 | } 327 | 328 | 329 | void FIF(g2_reset_palette)(F_REAL *dev) 330 | { 331 | g2_reset_palette(dtoi(*dev)); 332 | } 333 | 334 | 335 | void FIF(g2_set_background)(F_REAL *dev, F_REAL *color) 336 | { 337 | g2_set_background(dtoi(*dev), *color); 338 | } 339 | 340 | 341 | void FIF(g2_set_dash)(F_REAL *dev, F_REAL *N, F_REAL **dashes) 342 | { 343 | } 344 | 345 | 346 | void FIF(g2_set_font_size)(F_REAL *dev, F_REAL *size) 347 | { 348 | g2_set_font_size(dtoi(*dev), *size); 349 | } 350 | 351 | 352 | void FIF(g2_set_line_width)(F_REAL *dev, F_REAL *w) 353 | { 354 | g2_set_line_width(dtoi(*dev), *w); 355 | } 356 | 357 | 358 | void FIF(g2_triangle)(F_REAL *dev, F_REAL *x1, F_REAL *y1, 359 | F_REAL *x2, F_REAL *y2, 360 | F_REAL *x3, F_REAL *y3) 361 | { 362 | g2_triangle(dtoi(*dev), *x1, *y1, *x2, *y2, *x3, *y3); 363 | } 364 | 365 | 366 | void FIF(g2_set_qp)(F_REAL *dev, F_REAL *d, F_REAL *shape) 367 | { 368 | g2_set_QP(dtoi(*dev), *d, *shape); 369 | } 370 | 371 | 372 | void FIF(g2_plot_qp)(F_REAL *dev, F_REAL *x, F_REAL *y) 373 | { 374 | g2_plot_QP(dtoi(*dev), *x, *y); 375 | } 376 | -------------------------------------------------------------------------------- /g2-0.40/src/g2_funix.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #ifndef _G2_FUNIX_H 19 | #define _G2_FUNIX_H 20 | 21 | /* 22 | * 23 | * FUNction IndeX enumeration 24 | * 25 | */ 26 | 27 | #define G2_N_FUNIX 29 /* WARNING !! */ 28 | /* number of funix excl. g2_FUNIX_NULL !!! */ 29 | 30 | typedef enum g2_funix { 31 | g2_FUNIX_NULL=-1, /* null funix (_don't_ _count_ in G2_N_FUNIX !!!!) */ 32 | 33 | g2_DoNothing=0, /* do nothing */ 34 | /* ... = */ 35 | 36 | g2_Delete, /* delete physical device */ 37 | /* ... = */ 38 | 39 | g2_Ink, /* set ink */ 40 | /* ... = (int)red, (int)green, (int)blue */ 41 | /* 0 < (red,green,blue) < 65535 (=0xFFFF) */ 42 | /* ret: color id(>=0), <0 if error */ 43 | 44 | g2_Pen, /* set pen */ 45 | /* ... = (int)pen */ 46 | 47 | g2_SetBackground, /* set background */ 48 | /* ... = (int)pen */ 49 | 50 | g2_ClearPalette, /* reset color pallete to default values */ 51 | /* ... = */ 52 | /* for list of default colors (0,31) see later */ 53 | 54 | g2_SetLineWidth, /* set line width (line, rectangle, ...) */ 55 | /* ... = (double)line width */ 56 | 57 | g2_SetDash, /* set line dash */ 58 | /* ... = (int)number of descr., (double*) bw list */ 59 | 60 | g2_SetFontSize, /* set font size */ 61 | /* ... = (double)font size */ 62 | 63 | g2_Clear, /* clear screen(X11), print page(PostScript), ... */ 64 | /* ... = */ 65 | 66 | g2_Flush, /* update output */ 67 | /* X11: Flush, PostScript: fflush, ... */ 68 | 69 | g2_Save, /* save output to device (e.g. file) */ 70 | /* X11: Flush, etc. */ 71 | 72 | g2_Plot, /* plot point */ 73 | /* ... = (double)x, (double)y */ 74 | 75 | g2_Line, /* draw line */ 76 | /* ... = (double)x1, (double)y1, 77 | (double)x2, (double)y2 */ 78 | 79 | g2_PolyLine, /* draw poly line */ 80 | /* ... = (int)N, 81 | (double*)dp 82 | dp[0]=x1, dp[1]=y1, 83 | ... 84 | dp[2*N-2]=xN, dp[2*N-1]=yN */ 85 | 86 | g2_Polygon, /* draw polygon */ 87 | /* ... = (int)N, 88 | (double*)dp 89 | dp[0]=x1, dp[1]=y1, 90 | ... 91 | dp[2*N-2]=xN, dp[2*N-1]=yN */ 92 | 93 | g2_FilledPolygon, /* draw filled polygon */ 94 | /* ... = (int)N, 95 | (double*)dp 96 | dp[0]=x1, dp[1]=y1, 97 | ... 98 | dp[2*N-2]=xN, dp[2*N-1]=yN */ 99 | 100 | g2_Rectangle, /* draw rectangle */ 101 | /* ... = (double)x1, (double)y1, 102 | (double)x2, (double)y2 */ 103 | 104 | g2_FilledRectangle, /* draw filled rectangle */ 105 | /* ... = (double)x1, (double)x1, 106 | (double)x2, (double)y2 */ 107 | 108 | g2_Triangle, /* draw triangle (should be faster as lines) */ 109 | /* ... = (double)x1, (double)y1, 110 | (double)x2, (double)y2, 111 | (double)x3, (double)y3 */ 112 | 113 | g2_FilledTriangle, /* draw filled triangle */ 114 | /* ... = (double)x1, (double)y1, 115 | (double)x2, (double)y2, 116 | (double)x3, (double)y3 */ 117 | 118 | g2_Arc, /* draw arc */ 119 | /* ... = (double)x, (double)y, 120 | (double)r1, (double)r2, 121 | (double)a1, (double)a2 */ 122 | 123 | g2_FilledArc, /* draw filled arc */ 124 | /* ... = (double)x, (double)y, 125 | (double)r1, (double)r2, 126 | (double)a1, (double)a2 */ 127 | 128 | g2_Ellipse, /* draw ellipse */ 129 | /* ... = (double)x, (double)y, 130 | (double)r1, (double)r2 */ 131 | 132 | g2_FilledEllipse, /* draw filled ellipse */ 133 | /* ... = (double)x, (double)y, 134 | (double)r1, (double)r2 */ 135 | 136 | g2_Circle, /* draw circle */ 137 | /* ... = (double)x, (double)y, 138 | (double)r */ 139 | 140 | g2_FilledCircle, /* draw filled circle */ 141 | /* ... = (double)x, (double)y, 142 | (double)r */ 143 | 144 | g2_String, /* draw string */ 145 | /* ... = (double)x, (double)y, (const char*)string */ 146 | 147 | g2_Image /* draw (pen) image */ 148 | /* ... = (double)x, (double)y, 149 | (int)x_size, (int)y_size, (int*)pen_array */ 150 | 151 | } g2_funix; 152 | 153 | 154 | #endif /* _G2_FUNIX_H */ 155 | -------------------------------------------------------------------------------- /g2-0.40/src/g2_graphic_pd.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #ifndef _G2_GRAPHIC_PD_H 19 | #define _G2_GRAPHIC_PD_H 20 | 21 | #include "g2_physical_device.h" 22 | #include "g2_funix.h" 23 | 24 | 25 | void g2_plot_pd(g2_physical_device *pd, double x, double y); 26 | void g2_line_pd(g2_physical_device *pd, 27 | double x1, double y1, double x2, double y2); 28 | void g2_poly_line_pd(g2_physical_device *pd, int N, double *points); 29 | void g2_triangle_pd(g2_physical_device *pd, 30 | double x1, double y1, 31 | double x2, double y2, 32 | double x3, double y3); 33 | void g2_filled_triangle_pd(g2_physical_device *pd, 34 | double x1, double y1, 35 | double x2, double y2, 36 | double x3, double y3); 37 | void g2_rectangle_pd(g2_physical_device *pd, 38 | double x1, double y1, double x2, double y2); 39 | void g2_filled_rectangle_pd(g2_physical_device *pd, 40 | double x1, double y1, double x2, double y2); 41 | void g2_polygon_pd(g2_physical_device *pd, int N, double *points); 42 | void g2_filled_polygon_pd(g2_physical_device *pd, int N, double *points); 43 | void g2_ellipse_pd(g2_physical_device *pd, 44 | double x, double y, double r1, double r2); 45 | void g2_filled_ellipse_pd(g2_physical_device *pd, 46 | double x, double y, double r1, double r2); 47 | void g2_circle_pd(g2_physical_device *pd, 48 | double x, double y, double r); 49 | void g2_filled_circle_pd(g2_physical_device *pd, 50 | double x, double y, double r); 51 | void g2_arc_pd(g2_physical_device *pd, 52 | double x, double y, 53 | double r1, double r2, 54 | double a1, double a2); 55 | void g2_filled_arc_pd(g2_physical_device *pd, 56 | double x, double y, 57 | double r1, double r2, 58 | double a1, double a2); 59 | void g2_string_pd(g2_physical_device *pd, 60 | double x, double y, char *text); 61 | void g2_image_pd(g2_physical_device *pd, 62 | double x, double y, int x_size, int y_size, int *pens); 63 | 64 | 65 | #endif /* _G2_GRAPHIC_PD_H */ 66 | -------------------------------------------------------------------------------- /g2-0.40/src/g2_physical_device.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #include 19 | #include 20 | #include "g2_physical_device.h" 21 | #include "g2_funix.h" 22 | #include "g2_util.h" 23 | 24 | 25 | g2_physical_device *g2_create_physical_device(int pid, 26 | void *pdp, 27 | g2_coor ct, 28 | const g2_funix_fun *ff, 29 | double a11, double a22, 30 | double b1, double b2) 31 | { 32 | g2_physical_device *rd; 33 | int i, j; 34 | 35 | rd=g2_malloc(sizeof(g2_physical_device)); 36 | 37 | rd->pid=pid; /* physical device id (handled by driver) */ 38 | rd->pdp=pdp; /* pointer to something */ 39 | rd->coor_type=ct; /* coord. type */ 40 | rd->a11=a11; /* device->physical device transformation */ 41 | rd->a22=a22; 42 | rd->b1=b1; 43 | rd->b2=b2; 44 | 45 | rd->x_origin=0.0; /* User coordinates specification */ 46 | rd->y_origin=0.0; 47 | rd->x_mul=1.0; 48 | rd->y_mul=1.0; 49 | 50 | rd->ff=g2_malloc(G2_N_FUNIX*sizeof(g2_funix_fun)); 51 | 52 | for(i=0;iff[i].fx=i; 54 | rd->ff[i].fun=NULL; 55 | for(j=0;ff[j].fx!=g2_FUNIX_NULL;j++) 56 | if(ff[j].fx==i) { 57 | rd->ff[i].fun = ff[j].fun; 58 | break; 59 | } 60 | } 61 | 62 | return rd; 63 | } 64 | 65 | 66 | /* 67 | * 68 | * Destroy physical device 69 | * 70 | */ 71 | void g2_destroy_physical_device(g2_physical_device *pd) 72 | { 73 | g2_free(pd->ff); 74 | g2_free(pd); 75 | } 76 | 77 | 78 | -------------------------------------------------------------------------------- /g2-0.40/src/g2_physical_device.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #ifndef _G2_PHYSICAL_DEVICE_H 19 | #define _G2_PHYSICAL_DEVICE_H 20 | 21 | #include "g2.h" 22 | #include "g2_funix.h" 23 | 24 | 25 | typedef enum _g2_coor { /* coord. type */ 26 | g2_IntCoor, g2_DoubleCoor 27 | } g2_coor; 28 | 29 | 30 | typedef struct _g2_funix_fun { /* funix--function paar */ 31 | g2_funix fx; /* function index */ 32 | int (*fun)(); /* pointer to function */ 33 | } g2_funix_fun; 34 | 35 | 36 | typedef struct _g2_physical_device { 37 | int pid; /* physical device id */ 38 | void *pdp; /* pointer to something in phys. dev. */ 39 | g2_coor coor_type; /* coordinate type */ 40 | g2_funix_fun *ff; /* list of funix-function pairs */ 41 | double a11, a22; /* coordinate transformation (ud->pd) */ 42 | double b1, b2; /* Ar + B */ 43 | 44 | double x_origin; /* User coordinates specification */ 45 | double y_origin; 46 | double x_mul; 47 | double y_mul; 48 | } g2_physical_device; 49 | 50 | 51 | 52 | g2_physical_device *g2_create_physical_device(int pid, 53 | void *pdp, 54 | g2_coor ct, 55 | const g2_funix_fun *ff, 56 | double a11, double a22, 57 | double b1, double b2); 58 | void g2_destroy_physical_device(g2_physical_device *pd); 59 | 60 | #endif /* _G2_PHYSICAL_DEVICE_H */ 61 | -------------------------------------------------------------------------------- /g2-0.40/src/g2_ui_device.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #include 19 | 20 | #include "g2.h" 21 | #include "g2_funix.h" 22 | #include "g2_device.h" 23 | 24 | 25 | /* 26 | * 27 | * Close and delete device 28 | * 29 | */ 30 | void g2_close(int dev) 31 | { 32 | g2_device *devp; 33 | 34 | if((devp=g2_get_device_pointer(dev))==NULL) { 35 | fprintf(stderr, "g2_close: Warning! No such device: %d\n", dev); 36 | return; 37 | } 38 | 39 | switch(devp->t) { 40 | case g2_PD: 41 | devp->d.pd->ff[g2_Delete].fun(devp->d.pd->pid, 42 | devp->d.pd->pdp); 43 | break; 44 | case g2_VD: 45 | while(devp->d.vd->N>0) /* close all devices */ 46 | g2_close(devp->d.vd->dix[devp->d.vd->N-1]); 47 | break; 48 | case g2_ILLEGAL: 49 | break; 50 | case g2_NDEV: 51 | break; 52 | } 53 | g2_destroy_device(dev); /* destroy device */ 54 | } 55 | 56 | 57 | /* 58 | * 59 | * Set auto flush mode 60 | * 61 | */ 62 | void g2_set_auto_flush(int dev, int on_off) 63 | { 64 | g2_device *devp; 65 | 66 | if((devp=g2_get_device_pointer(dev))==NULL) { 67 | fprintf(stderr, 68 | "g2_set_auto_flush: Warning! No such device: %d\n", dev); 69 | return; 70 | } 71 | 72 | devp->auto_flush=on_off; 73 | __g2_last_device=dev; 74 | } 75 | 76 | 77 | /* 78 | * 79 | * Set user coordinate system 80 | * 81 | */ 82 | void g2_set_coordinate_system(int dev, 83 | double x_origin, double y_origin, 84 | double x_mul, double y_mul) 85 | { 86 | g2_device *devp; 87 | int i; 88 | 89 | if(x_mul==0.0 || y_mul==0.0) { 90 | fprintf(stderr, 91 | "g2_set_coordinate_system: Error! Multiplicator can not be 0.0"); 92 | return; 93 | } 94 | 95 | if((devp=g2_get_device_pointer(dev))==NULL) { 96 | fprintf(stderr, 97 | "g2_set_coordinate_system: Warning! No such device: %d\n", 98 | dev); 99 | return; 100 | } 101 | 102 | switch(devp->t) { 103 | case g2_PD: 104 | devp->d.pd->x_origin=x_origin; 105 | devp->d.pd->y_origin=y_origin; 106 | devp->d.pd->x_mul=x_mul; 107 | devp->d.pd->y_mul=y_mul; 108 | break; 109 | case g2_VD: 110 | for(i=0;id.vd->N;i++) 111 | g2_set_coordinate_system(devp->d.vd->dix[i], 112 | x_origin, y_origin, 113 | x_mul, y_mul); 114 | break; 115 | case g2_ILLEGAL: 116 | break; 117 | case g2_NDEV: 118 | break; 119 | } 120 | __g2_last_device=dev; 121 | } 122 | 123 | 124 | 125 | /* 126 | * 127 | * Get last accessed device (lsd) 128 | * 129 | */ 130 | int g2_ld(void) 131 | { 132 | return __g2_last_device; 133 | } 134 | 135 | 136 | 137 | /* 138 | * 139 | * Set last accessed device (lsd) 140 | * 141 | */ 142 | void g2_set_ld(int dev) 143 | { 144 | if(!g2_device_exist(dev)) { 145 | fprintf(stderr, "g2_set_lsd: Warning! No such device: %d\n", dev); 146 | return; 147 | } 148 | __g2_last_device=dev; 149 | } 150 | -------------------------------------------------------------------------------- /g2-0.40/src/g2_ui_virtual_device.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #include 19 | 20 | #include "g2.h" 21 | #include "g2_device.h" 22 | #include "g2_virtual_device.h" 23 | #include "g2_util.h" 24 | 25 | 26 | /* 27 | * 28 | */ 29 | int g2_open_vd(void) 30 | { 31 | int dix; 32 | dix=g2_register_virtual_device(); 33 | __g2_last_device=dix; 34 | return dix; 35 | } 36 | 37 | 38 | /* 39 | * 40 | */ 41 | void g2_attach(int vd_dev, int dev) 42 | { 43 | g2_device *vd_devp, *devp; 44 | 45 | if((vd_devp=g2_get_device_pointer(vd_dev))==NULL) { 46 | fprintf(stderr, "g2_attach: No such device: %d\n", vd_dev); 47 | return; 48 | } 49 | 50 | if((devp=g2_get_device_pointer(dev))==NULL) { 51 | fprintf(stderr, "g2_attach: No such device: %d\n", dev); 52 | return; 53 | } 54 | 55 | if(vd_devp->t!=g2_VD) { 56 | fprintf(stderr, "g2_attach: Device %d is not virtual.\n", vd_dev); 57 | return; 58 | } 59 | 60 | if(devp->t==g2_VD) /* if virtual device */ 61 | if(g2_is_attached(dev, vd_dev)) { /* check recurency */ 62 | fprintf(stderr, 63 | "g2_attach: Device %d is already attached to %d.\n", 64 | dev, vd_dev); 65 | return; 66 | } 67 | 68 | vd_devp->d.vd->N++; 69 | vd_devp->d.vd->dix=g2_realloc(vd_devp->d.vd->dix, 70 | vd_devp->d.vd->N*sizeof(int)); 71 | 72 | vd_devp->d.vd->dix[vd_devp->d.vd->N-1]=dev; 73 | 74 | __g2_last_device=vd_dev; 75 | } 76 | 77 | 78 | /* 79 | * 80 | */ 81 | void g2_detach(int vd_dev, int dev) 82 | { 83 | g2_device *vd_devp; 84 | int i; 85 | 86 | if((vd_devp=g2_get_device_pointer(vd_dev))==NULL) { 87 | fprintf(stderr, "g2_detach: No such device: %d\n", vd_dev); 88 | return; 89 | } 90 | 91 | if(vd_devp->t!=g2_VD) { 92 | fprintf(stderr, "g2_detach: Device %d is not virtual.\n", vd_dev); 93 | return; 94 | } 95 | 96 | for(i=0;id.vd->N;i++) 97 | if(vd_devp->d.vd->dix[i]==dev) { 98 | if(vd_devp->d.vd->N>1) 99 | vd_devp->d.vd->dix[i]=vd_devp->d.vd->dix[vd_devp->d.vd->N-1]; 100 | vd_devp->d.vd->N--; 101 | if(vd_devp->d.vd->N!=0) 102 | vd_devp->d.vd->dix=g2_realloc(vd_devp->d.vd->dix, 103 | vd_devp->d.vd->N*sizeof(int)); 104 | return; 105 | } 106 | 107 | __g2_last_device=vd_dev; 108 | } 109 | 110 | -------------------------------------------------------------------------------- /g2-0.40/src/g2_util.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #include 19 | #include 20 | #include 21 | 22 | #include "g2_util.h" 23 | #include "g2_physical_device.h" 24 | 25 | 26 | /* 27 | * 28 | * Double to integer 29 | * 30 | */ 31 | int dtoi(double x) 32 | { 33 | return (int)(x+0.5); 34 | } 35 | 36 | 37 | 38 | /* 39 | * 40 | * Transform user coord. in phyisical device coord (int) 41 | * 42 | */ 43 | void g2_uc2pdc_int(g2_physical_device *pd, double x, double y, 44 | int *ix, int *iy) 45 | { 46 | double vx, vy; 47 | 48 | vx=pd->x_mul*x+pd->x_origin; 49 | vy=pd->y_mul*y+pd->y_origin; 50 | 51 | *ix = dtoi(pd->a11*vx + pd->b1); 52 | *iy = dtoi(pd->a22*vy + pd->b2); 53 | } 54 | 55 | 56 | /* 57 | * 58 | * Transform user coord. in phyisical device coord (double) 59 | * 60 | */ 61 | void g2_uc2pdc_double(g2_physical_device *pd, double x, double y, 62 | double *dx, double *dy) 63 | { 64 | double vx, vy; 65 | 66 | vx=pd->x_mul*x+pd->x_origin; 67 | vy=pd->y_mul*y+pd->y_origin; 68 | 69 | *dx = pd->a11*vx + pd->b1; 70 | *dy = pd->a22*vy + pd->b2; 71 | } 72 | 73 | 74 | /* 75 | * 76 | * Transform user size in phyisical device size (int) 77 | * 78 | */ 79 | void g2_us2pds_int(g2_physical_device *pd, double x, double y, 80 | int *ix, int *iy) 81 | { 82 | if(ix!=NULL) 83 | *ix=dtoi(x*fabs(pd->x_mul*pd->a11)); 84 | if(iy!=NULL) 85 | *iy=dtoi(y*fabs(pd->y_mul*pd->a22)); 86 | } 87 | 88 | 89 | /* 90 | * 91 | * Transform user size in phyisical device size (double) 92 | * 93 | */ 94 | void g2_us2pds_double(g2_physical_device *pd, double x, double y, 95 | double *dx, double *dy) 96 | { 97 | if(dx!=NULL) 98 | *dx=x*fabs(pd->x_mul*pd->a11); 99 | if(dy!=NULL) 100 | *dy=y*fabs(pd->y_mul*pd->a22); 101 | } 102 | 103 | 104 | /* 105 | * return a < b 106 | */ 107 | void g2_sort2_i(int *a, int *b) 108 | { 109 | if(*a>*b) { 110 | int t=*a; 111 | *a=*b; *b=t; 112 | } 113 | } 114 | 115 | void g2_sort2_d(double *a, double *b) 116 | { 117 | if(*a>*b) { 118 | double t=*a; 119 | *a=*b; *b=t; 120 | } 121 | } 122 | 123 | 124 | 125 | /* 126 | * 127 | * g2 malloc (with error message) 128 | * 129 | */ 130 | void *g2_malloc(size_t size) 131 | { 132 | void *rv; 133 | 134 | if((rv=malloc(size))==NULL) { 135 | fprintf(stderr, "g2_malloc: Can not allocate memory\n"); 136 | exit(-1); 137 | } 138 | 139 | return rv; 140 | } 141 | 142 | 143 | /* 144 | * 145 | * g2 realloc (with error message) 146 | * 147 | */ 148 | void *g2_realloc(void *p, size_t size) 149 | { 150 | void *rv; 151 | if((rv=realloc(p, size))==NULL) { 152 | fprintf(stderr, "g2_realloc: Can not allocate memory\n"); 153 | exit(-1); 154 | } 155 | return rv; 156 | } 157 | 158 | 159 | 160 | /* 161 | * 162 | * g2 free 163 | * 164 | */ 165 | void g2_free(void *p) 166 | { 167 | if(p!=NULL) 168 | free(p); 169 | } 170 | -------------------------------------------------------------------------------- /g2-0.40/src/g2_util.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #ifndef _G2_UTIL_H 19 | #define _G2_UTIL_H 20 | 21 | #include 22 | #include "g2_physical_device.h" 23 | 24 | int dtoi(double x); 25 | 26 | void g2_uc2pdc_int(g2_physical_device *pd, double x, double y, 27 | int *ix, int *iy); 28 | void g2_uc2pdc_double(g2_physical_device *pd, double x, double y, 29 | double *dx, double *dy); 30 | void g2_us2pds_int(g2_physical_device *pd, double x, double y, 31 | int *ix, int *iy); 32 | void g2_us2pds_double(g2_physical_device *pd, double x, double y, 33 | double *dx, double *dy); 34 | void g2_sort2_i(int *a, int *b); 35 | void g2_sort2_d(double *a, double *b); 36 | void *g2_malloc(size_t size); 37 | void *g2_realloc(void *p, size_t size); 38 | void g2_free(void *p); 39 | 40 | 41 | #endif /* _G2_UTIL_H */ 42 | -------------------------------------------------------------------------------- /g2-0.40/src/g2_virtual_device.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #include 19 | #include "g2_virtual_device.h" 20 | #include "g2_device.h" 21 | #include "g2_util.h" 22 | 23 | 24 | /* 25 | * 26 | */ 27 | g2_virtual_device *g2_create_virtual_device() 28 | { 29 | g2_virtual_device *rd; 30 | 31 | rd=g2_malloc(sizeof(g2_virtual_device)); 32 | rd->N=0; 33 | rd->dix=g2_malloc(sizeof(int)); /* later we use realloc */ 34 | return rd; 35 | } 36 | 37 | 38 | /* 39 | * 40 | */ 41 | void g2_destroy_virtual_device(g2_virtual_device *vd) 42 | { 43 | g2_free(vd->dix); 44 | g2_free(vd); 45 | } 46 | 47 | 48 | 49 | /* 50 | * Return 1 if dev is attached to vd 51 | */ 52 | int g2_is_attached(int vd, int dev) 53 | { 54 | g2_device *vdp, *devp; 55 | int i; 56 | 57 | if(vd==dev) 58 | return 1; 59 | 60 | if((devp=g2_get_device_pointer(dev))==NULL) 61 | return 0; 62 | 63 | if((vdp=g2_get_device_pointer(vd))==NULL) 64 | return 0; 65 | 66 | if(devp==vdp) 67 | return 1; 68 | 69 | if(vdp->t!=g2_VD) 70 | return 0; 71 | 72 | for(i=0;id.vd->N;i++) { 73 | if(vdp->d.vd->dix[i]==dev) 74 | return 1; 75 | if(g2_is_attached(vdp->d.vd->dix[i], dev)) 76 | return 1; 77 | } 78 | 79 | return 0; 80 | } 81 | 82 | -------------------------------------------------------------------------------- /g2-0.40/src/g2_virtual_device.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** This is part of the g2 library 3 | ** Copyright (C) 1998 Ljubomir Milanovic & Horst Wagner 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License (version 2) as 7 | ** published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ******************************************************************************/ 18 | #ifndef _G2_VIRTUAL_DEVICE_H 19 | #define _G2_VIRTUAL_DEVICE_H 20 | 21 | typedef struct _g2_virtual_device { 22 | int N; /* number of attached devices */ 23 | int *dix; /* index of attached devices */ 24 | } g2_virtual_device; 25 | 26 | 27 | g2_virtual_device *g2_create_virtual_device(); 28 | void g2_destroy_virtual_device(g2_virtual_device *vd); 29 | int g2_is_attached(int vd, int dev); 30 | 31 | #endif /* _G2_VIRTUAL_DEVICE_H */ 32 | -------------------------------------------------------------------------------- /install-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # install - install a program, script, or datafile 4 | # This comes from X11R5 (mit/util/scripts/install.sh). 5 | # 6 | # Copyright 1991 by the Massachusetts Institute of Technology 7 | # 8 | # Permission to use, copy, modify, distribute, and sell this software and its 9 | # documentation for any purpose is hereby granted without fee, provided that 10 | # the above copyright notice appear in all copies and that both that 11 | # copyright notice and this permission notice appear in supporting 12 | # documentation, and that the name of M.I.T. not be used in advertising or 13 | # publicity pertaining to distribution of the software without specific, 14 | # written prior permission. M.I.T. makes no representations about the 15 | # suitability of this software for any purpose. It is provided "as is" 16 | # without express or implied warranty. 17 | # 18 | # Calling this script install-sh is preferred over install.sh, to prevent 19 | # `make' implicit rules from creating a file called install from it 20 | # when there is no Makefile. 21 | # 22 | # This script is compatible with the BSD install script, but was written 23 | # from scratch. It can only install one file at a time, a restriction 24 | # shared with many OS's install programs. 25 | 26 | 27 | # set DOITPROG to echo to test this script 28 | 29 | # Don't use :- since 4.3BSD and earlier shells don't like it. 30 | doit="${DOITPROG-}" 31 | 32 | 33 | # put in absolute paths if you don't have them in your path; or use env. vars. 34 | 35 | mvprog="${MVPROG-mv}" 36 | cpprog="${CPPROG-cp}" 37 | chmodprog="${CHMODPROG-chmod}" 38 | chownprog="${CHOWNPROG-chown}" 39 | chgrpprog="${CHGRPPROG-chgrp}" 40 | stripprog="${STRIPPROG-strip}" 41 | rmprog="${RMPROG-rm}" 42 | mkdirprog="${MKDIRPROG-mkdir}" 43 | 44 | transformbasename="" 45 | transform_arg="" 46 | instcmd="$mvprog" 47 | chmodcmd="$chmodprog 0755" 48 | chowncmd="" 49 | chgrpcmd="" 50 | stripcmd="" 51 | rmcmd="$rmprog -f" 52 | mvcmd="$mvprog" 53 | src="" 54 | dst="" 55 | dir_arg="" 56 | 57 | while [ x"$1" != x ]; do 58 | case $1 in 59 | -c) instcmd="$cpprog" 60 | shift 61 | continue;; 62 | 63 | -d) dir_arg=true 64 | shift 65 | continue;; 66 | 67 | -m) chmodcmd="$chmodprog $2" 68 | shift 69 | shift 70 | continue;; 71 | 72 | -o) chowncmd="$chownprog $2" 73 | shift 74 | shift 75 | continue;; 76 | 77 | -g) chgrpcmd="$chgrpprog $2" 78 | shift 79 | shift 80 | continue;; 81 | 82 | -s) stripcmd="$stripprog" 83 | shift 84 | continue;; 85 | 86 | -t=*) transformarg=`echo $1 | sed 's/-t=//'` 87 | shift 88 | continue;; 89 | 90 | -b=*) transformbasename=`echo $1 | sed 's/-b=//'` 91 | shift 92 | continue;; 93 | 94 | *) if [ x"$src" = x ] 95 | then 96 | src=$1 97 | else 98 | # this colon is to work around a 386BSD /bin/sh bug 99 | : 100 | dst=$1 101 | fi 102 | shift 103 | continue;; 104 | esac 105 | done 106 | 107 | if [ x"$src" = x ] 108 | then 109 | echo "install: no input file specified" 110 | exit 1 111 | else 112 | true 113 | fi 114 | 115 | if [ x"$dir_arg" != x ]; then 116 | dst=$src 117 | src="" 118 | 119 | if [ -d $dst ]; then 120 | instcmd=: 121 | chmodcmd="" 122 | else 123 | instcmd=mkdir 124 | fi 125 | else 126 | 127 | # Waiting for this to be detected by the "$instcmd $src $dsttmp" command 128 | # might cause directories to be created, which would be especially bad 129 | # if $src (and thus $dsttmp) contains '*'. 130 | 131 | if [ -f $src -o -d $src ] 132 | then 133 | true 134 | else 135 | echo "install: $src does not exist" 136 | exit 1 137 | fi 138 | 139 | if [ x"$dst" = x ] 140 | then 141 | echo "install: no destination specified" 142 | exit 1 143 | else 144 | true 145 | fi 146 | 147 | # If destination is a directory, append the input filename; if your system 148 | # does not like double slashes in filenames, you may need to add some logic 149 | 150 | if [ -d $dst ] 151 | then 152 | dst="$dst"/`basename $src` 153 | else 154 | true 155 | fi 156 | fi 157 | 158 | ## this sed command emulates the dirname command 159 | dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` 160 | 161 | # Make sure that the destination directory exists. 162 | # this part is taken from Noah Friedman's mkinstalldirs script 163 | 164 | # Skip lots of stat calls in the usual case. 165 | if [ ! -d "$dstdir" ]; then 166 | defaultIFS=' 167 | ' 168 | IFS="${IFS-${defaultIFS}}" 169 | 170 | oIFS="${IFS}" 171 | # Some sh's can't handle IFS=/ for some reason. 172 | IFS='%' 173 | set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` 174 | IFS="${oIFS}" 175 | 176 | pathcomp='' 177 | 178 | while [ $# -ne 0 ] ; do 179 | pathcomp="${pathcomp}${1}" 180 | shift 181 | 182 | if [ ! -d "${pathcomp}" ] ; 183 | then 184 | $mkdirprog "${pathcomp}" 185 | else 186 | true 187 | fi 188 | 189 | pathcomp="${pathcomp}/" 190 | done 191 | fi 192 | 193 | if [ x"$dir_arg" != x ] 194 | then 195 | $doit $instcmd $dst && 196 | 197 | if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && 198 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && 199 | if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && 200 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi 201 | else 202 | 203 | # If we're going to rename the final executable, determine the name now. 204 | 205 | if [ x"$transformarg" = x ] 206 | then 207 | dstfile=`basename $dst` 208 | else 209 | dstfile=`basename $dst $transformbasename | 210 | sed $transformarg`$transformbasename 211 | fi 212 | 213 | # don't allow the sed command to completely eliminate the filename 214 | 215 | if [ x"$dstfile" = x ] 216 | then 217 | dstfile=`basename $dst` 218 | else 219 | true 220 | fi 221 | 222 | # Make a temp file name in the proper directory. 223 | 224 | dsttmp=$dstdir/#inst.$$# 225 | 226 | # Move or copy the file name to the temp name 227 | 228 | $doit $instcmd $src $dsttmp && 229 | 230 | trap "rm -f ${dsttmp}" 0 && 231 | 232 | # and set any options; do chmod last to preserve setuid bits 233 | 234 | # If any of these fail, we abort the whole thing. If we want to 235 | # ignore errors from any of these, just make sure not to ignore 236 | # errors from the above "$doit $instcmd $src $dsttmp" command. 237 | 238 | if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && 239 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && 240 | if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && 241 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && 242 | 243 | # Now rename the file to the real destination. 244 | 245 | $doit $rmcmd -f $dstdir/$dstfile && 246 | $doit $mvcmd $dsttmp $dstdir/$dstfile 247 | 248 | fi && 249 | 250 | 251 | exit 0 252 | -------------------------------------------------------------------------------- /missing: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Common stub for a few missing GNU programs while installing. 3 | # Copyright (C) 1996, 1997 Free Software Foundation, Inc. 4 | # Franc,ois Pinard , 1996. 5 | 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2, or (at your option) 9 | # any later version. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 19 | # 02111-1307, USA. 20 | 21 | if test $# -eq 0; then 22 | echo 1>&2 "Try \`$0 --help' for more information" 23 | exit 1 24 | fi 25 | 26 | case "$1" in 27 | 28 | -h|--h|--he|--hel|--help) 29 | echo "\ 30 | $0 [OPTION]... PROGRAM [ARGUMENT]... 31 | 32 | Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an 33 | error status if there is no known handling for PROGRAM. 34 | 35 | Options: 36 | -h, --help display this help and exit 37 | -v, --version output version information and exit 38 | 39 | Supported PROGRAM values: 40 | aclocal touch file \`aclocal.m4' 41 | autoconf touch file \`configure' 42 | autoheader touch file \`config.h.in' 43 | automake touch all \`Makefile.in' files 44 | bison create \`y.tab.[ch]', if possible, from existing .[ch] 45 | flex create \`lex.yy.c', if possible, from existing .c 46 | lex create \`lex.yy.c', if possible, from existing .c 47 | makeinfo touch the output file 48 | yacc create \`y.tab.[ch]', if possible, from existing .[ch]" 49 | ;; 50 | 51 | -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 52 | echo "missing - GNU libit 0.0" 53 | ;; 54 | 55 | -*) 56 | echo 1>&2 "$0: Unknown \`$1' option" 57 | echo 1>&2 "Try \`$0 --help' for more information" 58 | exit 1 59 | ;; 60 | 61 | aclocal) 62 | echo 1>&2 "\ 63 | WARNING: \`$1' is missing on your system. You should only need it if 64 | you modified \`acinclude.m4' or \`configure.in'. You might want 65 | to install the \`Automake' and \`Perl' packages. Grab them from 66 | any GNU archive site." 67 | touch aclocal.m4 68 | ;; 69 | 70 | autoconf) 71 | echo 1>&2 "\ 72 | WARNING: \`$1' is missing on your system. You should only need it if 73 | you modified \`configure.in'. You might want to install the 74 | \`Autoconf' and \`GNU m4' packages. Grab them from any GNU 75 | archive site." 76 | touch configure 77 | ;; 78 | 79 | autoheader) 80 | echo 1>&2 "\ 81 | WARNING: \`$1' is missing on your system. You should only need it if 82 | you modified \`acconfig.h' or \`configure.in'. You might want 83 | to install the \`Autoconf' and \`GNU m4' packages. Grab them 84 | from any GNU archive site." 85 | files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in` 86 | test -z "$files" && files="config.h" 87 | touch_files= 88 | for f in $files; do 89 | case "$f" in 90 | *:*) touch_files="$touch_files "`echo "$f" | 91 | sed -e 's/^[^:]*://' -e 's/:.*//'`;; 92 | *) touch_files="$touch_files $f.in";; 93 | esac 94 | done 95 | touch $touch_files 96 | ;; 97 | 98 | automake) 99 | echo 1>&2 "\ 100 | WARNING: \`$1' is missing on your system. You should only need it if 101 | you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'. 102 | You might want to install the \`Automake' and \`Perl' packages. 103 | Grab them from any GNU archive site." 104 | find . -type f -name Makefile.am -print | 105 | sed 's/\.am$/.in/' | 106 | while read f; do touch "$f"; done 107 | ;; 108 | 109 | bison|yacc) 110 | echo 1>&2 "\ 111 | WARNING: \`$1' is missing on your system. You should only need it if 112 | you modified a \`.y' file. You may need the \`Bison' package 113 | in order for those modifications to take effect. You can get 114 | \`Bison' from any GNU archive site." 115 | rm -f y.tab.c y.tab.h 116 | if [ $# -ne 1 ]; then 117 | eval LASTARG="\${$#}" 118 | case "$LASTARG" in 119 | *.y) 120 | SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` 121 | if [ -f "$SRCFILE" ]; then 122 | cp "$SRCFILE" y.tab.c 123 | fi 124 | SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` 125 | if [ -f "$SRCFILE" ]; then 126 | cp "$SRCFILE" y.tab.h 127 | fi 128 | ;; 129 | esac 130 | fi 131 | if [ ! -f y.tab.h ]; then 132 | echo >y.tab.h 133 | fi 134 | if [ ! -f y.tab.c ]; then 135 | echo 'main() { return 0; }' >y.tab.c 136 | fi 137 | ;; 138 | 139 | lex|flex) 140 | echo 1>&2 "\ 141 | WARNING: \`$1' is missing on your system. You should only need it if 142 | you modified a \`.l' file. You may need the \`Flex' package 143 | in order for those modifications to take effect. You can get 144 | \`Flex' from any GNU archive site." 145 | rm -f lex.yy.c 146 | if [ $# -ne 1 ]; then 147 | eval LASTARG="\${$#}" 148 | case "$LASTARG" in 149 | *.l) 150 | SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` 151 | if [ -f "$SRCFILE" ]; then 152 | cp "$SRCFILE" lex.yy.c 153 | fi 154 | ;; 155 | esac 156 | fi 157 | if [ ! -f lex.yy.c ]; then 158 | echo 'main() { return 0; }' >lex.yy.c 159 | fi 160 | ;; 161 | 162 | makeinfo) 163 | echo 1>&2 "\ 164 | WARNING: \`$1' is missing on your system. You should only need it if 165 | you modified a \`.texi' or \`.texinfo' file, or any other file 166 | indirectly affecting the aspect of the manual. The spurious 167 | call might also be the consequence of using a buggy \`make' (AIX, 168 | DU, IRIX). You might want to install the \`Texinfo' package or 169 | the \`GNU make' package. Grab either from any GNU archive site." 170 | file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` 171 | if test -z "$file"; then 172 | file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` 173 | file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` 174 | fi 175 | touch $file 176 | ;; 177 | 178 | *) 179 | echo 1>&2 "\ 180 | WARNING: \`$1' is needed, and you do not seem to have it handy on your 181 | system. You might have modified some files without having the 182 | proper tools for further handling them. Check the \`README' file, 183 | it often tells you about the needed prerequirements for installing 184 | this package. You may also peek at any GNU archive site, in case 185 | some other package would contain this missing \`$1' program." 186 | exit 1 187 | ;; 188 | esac 189 | 190 | exit 0 191 | -------------------------------------------------------------------------------- /mkinstalldirs: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # mkinstalldirs --- make directory hierarchy 3 | # Author: Noah Friedman 4 | # Created: 1993-05-16 5 | # Public domain 6 | 7 | # $Id: mkinstalldirs,v 1.13 1999/01/05 03:18:55 bje Exp $ 8 | 9 | errstatus=0 10 | 11 | for file 12 | do 13 | set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` 14 | shift 15 | 16 | pathcomp= 17 | for d 18 | do 19 | pathcomp="$pathcomp$d" 20 | case "$pathcomp" in 21 | -* ) pathcomp=./$pathcomp ;; 22 | esac 23 | 24 | if test ! -d "$pathcomp"; then 25 | echo "mkdir $pathcomp" 26 | 27 | mkdir "$pathcomp" || lasterr=$? 28 | 29 | if test ! -d "$pathcomp"; then 30 | errstatus=$lasterr 31 | fi 32 | fi 33 | 34 | pathcomp="$pathcomp/" 35 | done 36 | done 37 | 38 | exit $errstatus 39 | 40 | # mkinstalldirs ends here 41 | -------------------------------------------------------------------------------- /signal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * signal.c 3 | * 4 | * Copyright (c) 1999 Pekka Riikonen, priikone@poseidon.pspt.fi. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * 1999-08-21: By Pekka Riikonen 17 | * - much improved AM signal calculation 18 | * 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "signal.h" 28 | 29 | /* 30 | * Generates the AM signal. 31 | */ 32 | double *generate_am_signal(Signal *ps) 33 | { 34 | unsigned int x, y, i; 35 | double fc, ft, fp, A; 36 | double pi2, m, t, tmp1, tmp2; 37 | double *signal; 38 | 39 | /* 40 | * Monitor frequency's. 41 | * 42 | * Example line from XF86Config: 43 | * 44 | * Modeline "1152x864" 135 45 | * 1152 1464 1592 1776 46 | * 864 864 876 908 47 | * fp = 135 48 | * ft = tone frequency to be broadcasted 49 | * fc = carrier frequency 50 | */ 51 | fp = ps->o_fp * 1e6; /* Mhz */ 52 | ft = ps->o_tone; /* Tone (Hz) */ 53 | fc = ps->o_carr; /* Carrier (Hz) */ 54 | 55 | /* Settings and pre-calculations */ 56 | A = 255 / 4.0; /* amplitude */ 57 | m = 1.0; /* amplitude */ 58 | pi2 = (2 * M_PI); /* 2 * pi */ 59 | 60 | /* 61 | * Pre-calculate the AM signal. 62 | */ 63 | signal = (double *)malloc(sizeof(double) * 64 | (ps->o_res_x * ps->o_res_y)); 65 | i = 0; 66 | t = 0; 67 | for (y = 0; y < ps->o_res_y; y++) { 68 | tmp1 = cos(pi2 * t * ft / fp + M_PI); 69 | if (ps->o_square) 70 | tmp1 = (tmp1 < 0) ? -1 : 1; 71 | for (x = 0; x < ps->o_res_x; x++) { 72 | tmp2 = cos(pi2 * t * fc / fp); 73 | signal[i++] = A * tmp2 * (m + tmp1); 74 | t++; 75 | } 76 | t += ps->o_fh - ps->o_res_x; 77 | } 78 | 79 | return signal; 80 | } 81 | 82 | /* 83 | * Generates the FM signal. 84 | */ 85 | double *generate_fm_signal(Signal *ps) 86 | { 87 | 88 | return 0; 89 | } 90 | -------------------------------------------------------------------------------- /signal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * signal.h 3 | * 4 | * Copyright (c) 1999 Pekka Riikonen, priikone@poseidon.pspt.fi. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | */ 17 | 18 | #ifndef _SIGNAL_H 19 | #define _SIGNAL_H 20 | 21 | typedef struct { 22 | int o_fp; 23 | int o_fh; 24 | int o_fv; 25 | double o_tone; 26 | double o_carr; 27 | int o_res_x; 28 | int o_res_y; 29 | int o_square; 30 | } Signal; 31 | 32 | double *generate_am_signal(Signal *ps); 33 | double *generate_fm_signal(Signal *ps); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /tempest_am_X11.c: -------------------------------------------------------------------------------- 1 | /* 2 | * tempest_am_X11.c 3 | * 4 | * Copyright (c) 1999 Pekka Riikonen, priikone@poseidon.pspt.fi. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * 1999-08-15: By Patrice Lacroix 17 | * - image drawing 2 times faster (lot of room to improve 18 | * further!) 19 | * - image no more inverted vertically 20 | * 21 | * 1999-08-18: By Pekka Riikonen 22 | * - moved all the signal calculation to signal.c 23 | * - other minor code change and regrouping 24 | * 25 | */ 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include "g2-0.40/include/g2.h" 32 | #include "g2-0.40/include/g2_X11.h" 33 | 34 | #include "signal.h" 35 | #include "common.h" 36 | 37 | void usage(); 38 | void draw_signal(); 39 | int init_screen(); 40 | 41 | static int greyscale[256 + 1]; 42 | 43 | /* default command line options. */ 44 | static int o_fp = 135; 45 | static int o_fh = 1776; 46 | static int o_fv = 908; 47 | static double o_tone = 1000; 48 | static double o_carr = 12e6; 49 | static int o_res_x = 1024; 50 | static int o_res_y = 768; 51 | static int o_pgm = 0; 52 | static int o_square = 0; 53 | 54 | int main(int argc, char **argv) 55 | { 56 | int i; 57 | 58 | if (argc > 1) { 59 | for (i = 0; i < argc; i++) { 60 | if (!strcmp(argv[i], "-r")) { 61 | o_fp = atoi(argv[++i]); 62 | continue; 63 | } 64 | if (!strcmp(argv[i], "-h")) { 65 | o_fh = atoi(argv[++i]); 66 | continue; 67 | } 68 | if (!strcmp(argv[i], "-v")) { 69 | o_fv = atoi(argv[++i]); 70 | continue; 71 | } 72 | if (!strcmp(argv[i], "-t")) { 73 | o_tone = atof(argv[++i]); 74 | continue; 75 | } 76 | if (!strcmp(argv[i], "-c")) { 77 | o_carr = atof(argv[++i]); 78 | continue; 79 | } 80 | if (!strcmp(argv[i], "-s")) { 81 | o_res_x = atoi(argv[++i]); 82 | o_res_y = atoi(argv[++i]); 83 | continue; 84 | } 85 | if (!strcmp(argv[i], "-q")) { 86 | o_square = 1; 87 | continue; 88 | } 89 | if (!strcmp(argv[i], "-p")) { 90 | o_pgm = 1; 91 | continue; 92 | } 93 | if (!strcmp(argv[1], "-V")) 94 | usage(); 95 | } 96 | 97 | if (!o_fp || !o_fh || !o_fv || !o_tone || !o_carr 98 | || !o_res_x || !o_res_y) 99 | usage(); 100 | 101 | } 102 | 103 | fprintf(stderr, "Carrier frequency: %.4f MHz\n", (double)o_carr / 1e6); 104 | fprintf(stderr, " Tone frequency: %.2f Hz\n", (double)o_tone); 105 | 106 | if (o_pgm) 107 | generate_pgm(o_fp, o_fh, o_fv, o_tone, 108 | o_carr, o_res_x, o_res_y, o_square); 109 | else 110 | draw_signal(); 111 | 112 | return 0; 113 | } 114 | 115 | /* 116 | * Displays usage. 117 | */ 118 | void usage() 119 | { 120 | fprintf(stderr, "Usage: tempest_am_X11 [-rhvtcsV]\n"); 121 | fprintf(stderr, " -r Resolution clock rate (from XF86Config)\n"); 122 | fprintf(stderr, " -h Resolution horizontal total timing (from XF86Config)\n"); 123 | fprintf(stderr, " -v Resolution vertical total timing (from XF86Config)\n"); 124 | fprintf(stderr, " -t Tone frequency to broadcast (Hz)\n"); 125 | fprintf(stderr, " -c Carrier frequency to broadcast (Hz)\n"); 126 | fprintf(stderr, " -s Window size (eg. 1152 864) (default: 1024x768)\n"); 127 | fprintf(stderr, " -q Use square waves\n"); 128 | fprintf(stderr, " -p Generate PGM picture of the signal\n"); 129 | fprintf(stderr, " -V This message\n"); 130 | fprintf(stderr, "Version 1.0, (c) 1999 - 2001 priikone@poseidon.pspt.fi\n"); 131 | exit(0); 132 | } 133 | 134 | /* 135 | * Generates and shows the AM signal on screen. 136 | */ 137 | void draw_signal() 138 | { 139 | int i, sc; 140 | double R; 141 | Signal ns; 142 | double *signal; 143 | int *image, *p; 144 | 145 | ns.o_fp = o_fp; 146 | ns.o_fh = o_fh; 147 | ns.o_fv = o_fv; 148 | ns.o_tone = o_tone; 149 | ns.o_carr = o_carr; 150 | ns.o_res_x = o_res_x; 151 | ns.o_res_y = o_res_y; 152 | ns.o_square = o_square; 153 | 154 | signal = (double *)NULL; 155 | signal = generate_am_signal(&ns); 156 | 157 | /* Init the screen */ 158 | sc = init_screen(); 159 | 160 | srand((unsigned int)time(0)); 161 | i = 0; 162 | image = malloc((o_res_x * o_res_y) * sizeof(int)); 163 | p = image; 164 | for (i = 0; i < o_res_y * o_res_x; i++, p++) { 165 | R = 1 + (double) (1.0 * rand() / (RAND_MAX + 1.0)) - 1; 166 | *p = greyscale[(int)(127.5 + signal[i] + R)]; 167 | } 168 | g2_image(sc, 0, 0, o_res_x, o_res_y, image); 169 | 170 | getchar(); 171 | 172 | free(image); 173 | if (signal) 174 | free(signal); 175 | } 176 | 177 | /* 178 | * Initialises the screen. 179 | */ 180 | int init_screen() 181 | { 182 | int sc, i, color; 183 | double c = 0.0; 184 | 185 | sc = g2_open_X11(o_res_x, o_res_y); 186 | 187 | /* init greyscale palette */ 188 | for (i = 0; i < 255; i++) { 189 | color = g2_ink(sc, c, c, c); 190 | greyscale[i] = color; 191 | c += 1.0 / 255; 192 | } 193 | 194 | return sc; 195 | } 196 | -------------------------------------------------------------------------------- /tempest_am_svga.c: -------------------------------------------------------------------------------- 1 | /* 2 | * tempest_am_svga.c 3 | * 4 | * Copyright (c) 1999 Pekka Riikonen, priikone@poseidon.pspt.fi. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * 1999-08-18: By Pekka Riikonen 17 | * - moved all the signal calculation to signal.c 18 | * - other minor code change and regrouping 19 | * 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include "signal.h" 30 | #include "common.h" 31 | 32 | static void usage(); 33 | static void draw_signal(); 34 | static void init_screen(); 35 | static void supported_resos(); 36 | 37 | /* default command line options. These works 38 | for me but may not work for you. */ 39 | static int o_fp = 135; 40 | static int o_fh = 1776; 41 | static int o_fv = 908; 42 | static double o_tone = 1000; 43 | static double o_carr = 12000000; 44 | static int o_res_x = 1024; 45 | static int o_res_y = 768; 46 | static int o_res = 12; 47 | static int o_pgm = 0; 48 | static int o_square = 0; 49 | 50 | int main(int argc, char **argv) 51 | { 52 | int i; 53 | 54 | if (argc > 1) { 55 | for (i = 0; i < argc; i++) { 56 | if (!strcmp(argv[i], "-r")) { 57 | o_fp = atoi(argv[++i]); 58 | continue; 59 | } 60 | if (!strcmp(argv[i], "-h")) { 61 | o_fh = atoi(argv[++i]); 62 | continue; 63 | } 64 | if (!strcmp(argv[i], "-v")) { 65 | o_fv = atoi(argv[++i]); 66 | continue; 67 | } 68 | if (!strcmp(argv[i], "-t")) { 69 | o_tone = atof(argv[++i]); 70 | continue; 71 | } 72 | if (!strcmp(argv[i], "-c")) { 73 | o_carr = atof(argv[++i]); 74 | continue; 75 | } 76 | if (!strcmp(argv[i], "-s")) { 77 | o_res_x = atoi(argv[++i]); 78 | o_res_y = atoi(argv[++i]); 79 | continue; 80 | } 81 | if (!strcmp(argv[i], "-n")) { 82 | o_res = atoi(argv[++i]); 83 | continue; 84 | } 85 | if (!strcmp(argv[i], "-q")) { 86 | o_square = 1; 87 | continue; 88 | } 89 | if (!strcmp(argv[i], "-p")) { 90 | o_pgm = 1; 91 | continue; 92 | } 93 | if (!strcmp(argv[1], "-V")) 94 | usage(); 95 | } 96 | 97 | if (!o_fp || !o_fh || !o_fv || !o_tone || !o_carr 98 | || !o_res_x || !o_res_y || !o_res) 99 | usage(); 100 | } 101 | 102 | fprintf(stderr, "Carrier frequency: %.4f MHz\n", (double)o_carr / 1e6); 103 | fprintf(stderr, " Tone frequency: %.2f Hz\n", (double)o_tone); 104 | 105 | if (o_pgm) 106 | generate_pgm(o_fp, o_fh, o_fv, o_tone, 107 | o_carr, o_res_x, o_res_y, o_square); 108 | else 109 | draw_signal(); 110 | 111 | return 0; 112 | } 113 | 114 | /* 115 | * Displays usage. 116 | */ 117 | static void usage() 118 | { 119 | fprintf(stderr, "Usage: tempest_am_svga [-rhvtcsnV]\n"); 120 | fprintf(stderr, " -r Resolution clock rate (from XF86Config)\n"); 121 | fprintf(stderr, " -h Resolution horizontal total timing (from XF86Config)\n"); 122 | fprintf(stderr, " -v Resolution vertical total timing (from XF86Config)\n"); 123 | fprintf(stderr, " -t Tone frequency to broadcast (Hz)\n"); 124 | fprintf(stderr, " -c Carrier frequency to broadcast (Hz)\n"); 125 | fprintf(stderr, " -s Window size (eg. 1152 864) (default: 1024x768)\n"); 126 | fprintf(stderr, " -n SVGA library resolution number (see below) (default: 12)\n"); 127 | fprintf(stderr, " -q Use square waves\n"); 128 | fprintf(stderr, " -p Generate PGM picture of the signal\n"); 129 | fprintf(stderr, " -V This message\n"); 130 | fprintf(stderr, "Version 1.0, (c) 1999 - 2001 priikone@poseidon.pspt.fi\n"); 131 | fprintf(stderr, "\nNOTE: Monitor may not transmit the signal on low resolutions!\n"); 132 | supported_resos(); 133 | exit(0); 134 | } 135 | 136 | /* 137 | * Generates and shows the AM signal on screen. 138 | */ 139 | static void draw_signal() 140 | { 141 | int i, x, y; 142 | double R, p; 143 | Signal ns; 144 | double *signal; 145 | 146 | ns.o_fp = o_fp; 147 | ns.o_fh = o_fh; 148 | ns.o_fv = o_fv; 149 | ns.o_tone = o_tone; 150 | ns.o_carr = o_carr; 151 | ns.o_res_x = o_res_x; 152 | ns.o_res_y = o_res_y; 153 | ns.o_square = o_square; 154 | 155 | signal = (double *)NULL; 156 | signal = generate_am_signal(&ns); 157 | 158 | /* Init the screen */ 159 | init_screen(); 160 | 161 | srand((unsigned int)time(0)); 162 | i = 0; 163 | for (y = 0; y < o_res_y; y++) { 164 | for (x = 0; x < o_res_x; x++) { 165 | R = 1+(double) (1.0*rand() / (RAND_MAX+1.0)) - 1; 166 | p = ((double)127.5 + signal[i++]) + R; 167 | gl_setpixelrgb(x, y, (int)p, (int)p, (int)p); 168 | } 169 | } 170 | 171 | getchar(); 172 | 173 | if (signal) 174 | free(signal); 175 | } 176 | 177 | /* 178 | * Initialises the screen. 179 | */ 180 | static void init_screen() 181 | { 182 | int i; 183 | vga_modeinfo *modeinfo; 184 | 185 | vga_init(); 186 | 187 | if (!vga_hasmode(o_res)) { 188 | fprintf(stderr, "Video mode not supported by driver\n"); 189 | exit(1); 190 | } 191 | 192 | vga_setmodeX(); 193 | vga_setmode(o_res); 194 | modeinfo = vga_getmodeinfo(o_res); 195 | 196 | printf("Width: %d Height: %d Colors: %d\n", 197 | modeinfo->width, 198 | modeinfo->height, 199 | modeinfo->colors); 200 | printf("DisplayStartRange: %xh Maxpixels: %d Blit: %s\n", 201 | modeinfo->startaddressrange, 202 | modeinfo->maxpixels, 203 | modeinfo->haveblit ? "YES" : "NO"); 204 | 205 | gl_setcontextvga(o_res); 206 | vga_ext_set(VGA_CLUT8); 207 | 208 | for (i = 0; i < 255; i++) 209 | vga_setpalette(i + 1, i, i, i); 210 | } 211 | 212 | /* 213 | * Displays supported resolutions by video card. 214 | */ 215 | static void supported_resos() 216 | { 217 | int i; 218 | vga_modeinfo *modeinfo; 219 | 220 | for (i = 0; i < vga_lastmodenumber(); i++) { 221 | if (vga_hasmode(i)) { 222 | modeinfo = vga_getmodeinfo(i); 223 | 224 | if (modeinfo->colors == 256) 225 | fprintf(stderr, "%5d: %dx%dx%d\n", 226 | i, modeinfo->width, modeinfo->height, 227 | modeinfo->colors); 228 | } 229 | } 230 | } 231 | --------------------------------------------------------------------------------