Handy Graphic for Handy Graphic Version 0.5 2008-06-09 1 Handy Graphic Handy Graphic C Handy Graphic Handy Graphic Mac OS X Handy Graphic HgDisplayer Handy Graphic HgDisplayer 2 Handy Graphic 1 Handy Graphic #include <stdio.h> #include <handy.h> /* Handy Graphic */ int main(void) { HgOpen(600, 400); /* */ HgCircle(300, 150, 120); /* (300, 150) 120 */ getchar(); /* */ } return 0; /* */ 1: 600 120 400 150 300 (a) (b) 2: 1
600 400 (300, 150) 120 getchar() 2 3 4 HgBox(x, y, w, h) (x, y), w, h #include <stdio.h> #include <handy.h> int main(void) { int i; double w, h; } HgOpen(500, 400); w = 100; h = 40; for (i = 1; i <= 15; i++) { w -= 4; h += 4; HgBox(i * 28, i * 20, w, h); } getchar(); return 0; 3: 4: 3 1 3 draw.c Handy Graphic hgcc $ a.out $ hgcc draw.c cc gcc $ hgcc -Wall -o draw draw.c draw $./draw HgDisplayer HgDisplayer HgDisplayer 2
HgDisplayer HgDisplayer HgDisplayer Handy Graphic 4 4.1 int HgOpen(double w, double h) : w,h: w, h 4.2 int HgSetWidth(double t) : t: 4.3 hgcolor 1 1: HG_WHITE HG_RED HG_CYAN HG_BLACK HG_GREEN HG_ORANGE HG_GRAY HG_BLUE HG_PINK HG_LGRAY HG_YELLOW HG_MAGENTA HG_DGRAY HG_PURPLE HG_BROWN 3
int HgSetColor(hgcolor clr) : clr: int HgSetPaintColor(hgcolor clr) : clr: 4.4 HgDisplayer 2 int HgEncoding(int coding) : coding: 3 int HgSetFont(hgfont font, double size) : font: size: 2: 3: HG_UTF8_CODE HG_JIS_CODE HG_SJIS_CODE HG_EUCJP_CODE UTF-8 JIS JIS EUC HG_T HG_TI HG_TB HG_TBI HG_H HG_HI HG_HB HG_HBI HG_C HG_CI HG_CB HG_CBI HG_M HG_MB HG_G HG_GB 5 5.1 HgLine() (x 0, y 0 ) (x 1, y 1 ) 4
int HgLine(double x0, double y0, double x1, double y1) : x0,y0: x1,y1: 5.2 int HgCircle(double x, double y, double r) : x,y: r: int HgCircleFill(double x, double y, double r, int stroke) : x,y: r: stroke: HgCircle() (x, y) r HgCircleFill() (x, y) r HgSet- PaintColor() stroke 0 0 1 r 0.0 5.3 int HgBox(double x, double y, double w, double h) : x,y: w,h: int HgBoxFill(double x, double y, double w, double h, int stroke) : x,y: w,h: stroke: HgBox() (x, y) w h HgBoxFill() (x, y) w h HgSetPaintColor() stroke 0 0 1 w 0.0, h 0.0 5.4 int HgText(double x, double y, const char *str,...) : x,y: str: 5
HgText() (x, y) str C printf() 5.5 int HgClear(void) 6 Handy Graphic 6.1 hgcolor (RGB) hgcolor HgGray(double g) : g: : hgcolor HgRGB(double r, double g, double b) : r: g: b: : HgGray() g 0.0 g 1.0 0.0 1.0 HgRGB() 0.0 x 1.0 r g b HgRGB(1.0, 0.0, 0.0) HgRGB(0.8, 0.8, 1.0) 6.2 HgLine() int HgMoveTo(double x, double y) : x,y: 6
int HgLineTo(double x, double y) : x,y: HgLine() (x 1, y 1 ) 6.3 int HgLines(int n, const double *xp, const double *yp) : n: xp,yp: x y n x y xp yp int HgPolygon(int n, const double *xp, const double *yp) : n: xp,yp: x y int HgPolygonFill(int n, const double *xp, const double *yp, int stroke) : n: xp,yp: x y stroke: HgPolygon() HgPolygonFill() stroke 0 6.4 int HgArc(double x, double y, double r, double a0, double a1) : x,y: r: a0: a1: HgArc() (x, y) r a0 a1 x 90 π/2 C 7
int HgFan(double x, double y, double r, double a0, double a1) : x,y: r: a0,a1: int HgFanFill(double x, double y, double r, double a0, double a1, int stroke) : x,y: r: a0,a1: stroke: HgFanFill() stroke 0 6.5 (0, 0) int HgCoordinate(double sx, double sy, double scale) : sx, sy: scale: sx, sy scale 2.0 0.5 1/2 1/10000 100000 6.6 PDF HgDisplayer int HgSave(const char *str) : str: str.pdf 8
7 7.1 HgOpen() Handy Graphic int HgWOpen(double x, double y, double w, double h) : x,y: w,h: : 0 : id -1: id id 0 HgWOpen() id 0 HgWOpen() void HgScreenSize(double *width, double *height) : width, height: width height 7.2 HgWOpen() id HgLine() HgWLine() HgWLine() id int HgLine(double x0, double y0, double x1, double y1) int HgWLine(int wid, double x0, double y0, double x1, double y1) Hg HgW id id id 0 9
7.3 int HgClose(void) HgWClose() HgCloseAll() int HgWClose(int wid) : wid: id void HgCloseAll(void) 7.4 HgDisplayer HgSetTitle() HgWSetTitle() str C printf() int HgSetTitle(const char *str,...) : str: int HgWSetTitle(int wid, const char *str,...) : wid: id str: 8 GUI Handy Graphic HgDisplayer 10
8.1 int HgGetChar(void) : 0 : -1: A a 97 A A 65 4 int HgWGetChar(int wid) : wid: id : 0 : -1: HgGetChar() HgWGetChar() HgGetChar() HgWGetChar() 8.2 HgEventMask() HgEvent() HgGetChar() HgWGetChar() 4: 5: HG_U_ARROW HG_MOUSE_DOWN HG_D_ARROW HG_KEY_DOWN HG_L_ARROW HG_R_ARROW 8.2 HgEventMask() HgWEventMask() int HgEventMask(unsigned int mask) : mask: 5 OR 11
HG_MOUSE_DOWN (HG_MOUSE_DOWN HG_KEY_DOWN) hgevent *HgEvent(void) : NULL: NULL : hgevent HgEventMask() NULL typedef struct { unsigned long type; /* */ int wid; /* id */ double x; /* (x, y) = */ double y; int count; unsigned int modkey; unsigned int ch; /* */ } hgevent; type 5 wid id (x, y) ch HgEventMask() 8.3 void HgTransWtoA(double wx, double wy, double *ax, double *ay) : wx, wy: ax, ay: void HgTransAtoW(double ax, double ay, double *wx, double *wy) : wx, wy: ax, ay: HgCoordinate() HgTransWtoA() HgTransAtoW() HgTransWtoA() 12
id HgWTransWtoA() HgWTransAtoW() 8.4 Handy Graphic 0.5 0.5 void msleep(double msec) : msec: 13
HgOpen(wd,hg) HgWOpen(x,y,wd,hg) 4.1,7.1 HgClose() HgWClose(w) 7.3 HgCloseAll() 7.3 HgSetTitle(str,...) HgWSetTitle(w,str,...) 7.4 HgScreenSize(wp,hp) 7.1 HgSetWidth(t) HgWSetWidth(w,t) 4.2 HgGray(g) 6.1 RGB HgRGB(r,g,b) 6.1 HgSetColor(c) HgWSetColor(w,c) 4.3 HgSetPaintColor(c) HgWSetPaintColor(w,c) 4.3 HgEncoding(code) 4.4 HgSetFont(f,sz) HgWSetFont(w,f,sz) 4.4 HgLine(x0,y0,x1,y1) HgWLine(w,x0,y0,x1,y1) 5.1 HgMoveTo(x,y) HgWMoveTo(w,x,y) 6.2 HgLineTo(x,y) HgWLineTo(w,x,y) 6.2 HgCircle(x,y,r) HgWCircle(w,x,y,r) 5.2 HgCircleFill(x,y,r,s) HgWCircleFill(w,x,y,r,s) 5.2 HgArc(x,y,r,a0,a1) HgWArc(w,x,y,r,a0,a1) 6.4 HgFan(x,y,r,a0,a1) HgWFan(w,x,y,r,a0,a1) 6.4 HgFanFill(x,y,r,a0,a1,s) HgWFanFill(w,x,y,r,a0,a1,s) 6.4 HgBox(x,y,wd,hg) HgWBox(w,x,y,wd,hg) 5.3 HgBoxFill(x,y,w,h,s) HgWBoxFill(w,x,y,wd,hg,s) 5.3 HgText(x,y,str,...) HgWText(w,x,y,str,...) 5.4 HgLines(n,x,y) HgWLines(w,n,x,y) 6.3 HgPolygon(n,x,y) HgWPolygon(w,n,x,y) 6.3 HgPolygonFill(n,x,y,s) HgWPolygonFill(w,n,x,y,s) 6.3 HgClear() HgWClear(w) 5.5 HgSave(file) HgWSave(w,file) 6.6 HgCoordinate(x,y,sc) HgWCoordinate(w,x,y,sc) 6.5 HgTransWtoA(wx,wy,ax,ay) HgWTransWtoA(w,wx,wy,ax,ay) 8.3 HgTransAtoW(ax,ay,wx,wy) HgWTransAtoW(w,ax,ay,wx,wy) 8.3 HgGetChar() HgWGetChar(w) 8.1 HgEventMask(m) HgWEventMask(w,m) 8.2 HgEvent() 8.2 14