📄 draw.h
字号:
/* deltas */ DSUBF = 4, /* expiry ages */ SUBFAGE = 10000, CACHEAGE = 10000};struct Cachefont{ Rune min; /* lowest rune value to be taken from subfont */ Rune max; /* highest rune value+1 to be taken from subfont */ int offset; /* position in subfont of character at min */ char *name; /* stored in font */ char *subfontname; /* to access subfont */};struct Cacheinfo{ ushort x; /* left edge of bits */ uchar width; /* width of baseline */ schar left; /* offset of baseline */ Rune value; /* value of character at this slot in cache */ ushort age;};struct Cachesubf{ ulong age; /* for replacement */ Cachefont *cf; /* font info that owns us */ Subfont *f; /* attached subfont */};struct Font{ char *name; Display *display; short height; /* max height of image, interline spacing */ short ascent; /* top of image to baseline */ short width; /* widest so far; used in caching only */ short nsub; /* number of subfonts */ ulong age; /* increasing counter; used for LRU */ int maxdepth; /* maximum depth of all loaded subfonts */ int ncache; /* size of cache */ int nsubf; /* size of subfont list */ Cacheinfo *cache; Cachesubf *subf; Cachefont **sub; /* as read from file */ Image *cacheimage;};#define Dx(r) ((r).max.x-(r).min.x)#define Dy(r) ((r).max.y-(r).min.y)/* * One of a kind */extern int mousescrollsize(int);/* * Image management */extern Image* _allocimage(Image*, Display*, Rectangle, ulong, int, ulong, int, int);extern Image* allocimage(Display*, Rectangle, ulong, int, ulong);extern uchar* bufimage(Display*, int);extern int bytesperline(Rectangle, int);extern void closedisplay(Display*);extern void drawerror(Display*, char*);extern int flushimage(Display*, int);extern int freeimage(Image*);extern int _freeimage1(Image*);extern int geninitdraw(char*, void(*)(Display*, char*), char*, char*, char*, int);extern int initdraw(void(*)(Display*, char*), char*, char*);extern int newwindow(char*);extern Display* initdisplay(char*, char*, void(*)(Display*, char*));extern int loadimage(Image*, Rectangle, uchar*, int);extern int cloadimage(Image*, Rectangle, uchar*, int);extern int getwindow(Display*, int);extern int gengetwindow(Display*, char*, Image**, Screen**, int);extern Image* readimage(Display*, int, int);extern Image* creadimage(Display*, int, int);extern int unloadimage(Image*, Rectangle, uchar*, int);extern int wordsperline(Rectangle, int);extern int writeimage(int, Image*, int);extern Image* namedimage(Display*, char*);extern int nameimage(Image*, char*, int);extern Image* allocimagemix(Display*, ulong, ulong);/* * Colors */extern void readcolmap(Display*, RGB*);extern void writecolmap(Display*, RGB*);extern ulong setalpha(ulong, uchar);/* * Windows */extern Screen* allocscreen(Image*, Image*, int);extern Image* _allocwindow(Image*, Screen*, Rectangle, int, ulong);extern Image* allocwindow(Screen*, Rectangle, int, ulong);extern void bottomnwindows(Image**, int);extern void bottomwindow(Image*);extern int freescreen(Screen*);extern Screen* publicscreen(Display*, int, ulong);extern void topnwindows(Image**, int);extern void topwindow(Image*);extern int originwindow(Image*, Point, Point);/* * Geometry */extern Point Pt(int, int);extern Rectangle Rect(int, int, int, int);extern Rectangle Rpt(Point, Point);extern Point addpt(Point, Point);extern Point subpt(Point, Point);extern Point divpt(Point, int);extern Point mulpt(Point, int);extern int eqpt(Point, Point);extern int eqrect(Rectangle, Rectangle);extern Rectangle insetrect(Rectangle, int);extern Rectangle rectaddpt(Rectangle, Point);extern Rectangle rectsubpt(Rectangle, Point);extern Rectangle canonrect(Rectangle);extern int rectXrect(Rectangle, Rectangle);extern int rectinrect(Rectangle, Rectangle);extern void combinerect(Rectangle*, Rectangle);extern int rectclip(Rectangle*, Rectangle);extern int ptinrect(Point, Rectangle);extern void replclipr(Image*, int, Rectangle);extern int drawreplxy(int, int, int); /* used to be drawsetxy */extern Point drawrepl(Rectangle, Point);extern int rgb2cmap(int, int, int);extern int cmap2rgb(int);extern int cmap2rgba(int);extern void icossin(int, int*, int*);extern void icossin2(int, int, int*, int*);/* * Graphics */extern void draw(Image*, Rectangle, Image*, Image*, Point);extern void drawop(Image*, Rectangle, Image*, Image*, Point, Drawop);extern void gendraw(Image*, Rectangle, Image*, Point, Image*, Point);extern void gendrawop(Image*, Rectangle, Image*, Point, Image*, Point, Drawop);extern void line(Image*, Point, Point, int, int, int, Image*, Point);extern void lineop(Image*, Point, Point, int, int, int, Image*, Point, Drawop);extern void poly(Image*, Point*, int, int, int, int, Image*, Point);extern void polyop(Image*, Point*, int, int, int, int, Image*, Point, Drawop);extern void fillpoly(Image*, Point*, int, int, Image*, Point);extern void fillpolyop(Image*, Point*, int, int, Image*, Point, Drawop);extern Point string(Image*, Point, Image*, Point, Font*, char*);extern Point stringop(Image*, Point, Image*, Point, Font*, char*, Drawop);extern Point stringn(Image*, Point, Image*, Point, Font*, char*, int);extern Point stringnop(Image*, Point, Image*, Point, Font*, char*, int, Drawop);extern Point runestring(Image*, Point, Image*, Point, Font*, Rune*);extern Point runestringop(Image*, Point, Image*, Point, Font*, Rune*, Drawop);extern Point runestringn(Image*, Point, Image*, Point, Font*, Rune*, int);extern Point runestringnop(Image*, Point, Image*, Point, Font*, Rune*, int, Drawop);extern Point stringbg(Image*, Point, Image*, Point, Font*, char*, Image*, Point);extern Point stringbgop(Image*, Point, Image*, Point, Font*, char*, Image*, Point, Drawop);extern Point stringnbg(Image*, Point, Image*, Point, Font*, char*, int, Image*, Point);extern Point stringnbgop(Image*, Point, Image*, Point, Font*, char*, int, Image*, Point, Drawop);extern Point runestringbg(Image*, Point, Image*, Point, Font*, Rune*, Image*, Point);extern Point runestringbgop(Image*, Point, Image*, Point, Font*, Rune*, Image*, Point, Drawop);extern Point runestringnbg(Image*, Point, Image*, Point, Font*, Rune*, int, Image*, Point);extern Point runestringnbgop(Image*, Point, Image*, Point, Font*, Rune*, int, Image*, Point, Drawop);extern Point _string(Image*, Point, Image*, Point, Font*, char*, Rune*, int, Rectangle, Image*, Point, Drawop);extern Point stringsubfont(Image*, Point, Image*, Subfont*, char*);extern int bezier(Image*, Point, Point, Point, Point, int, int, int, Image*, Point);extern int bezierop(Image*, Point, Point, Point, Point, int, int, int, Image*, Point, Drawop);extern int bezspline(Image*, Point*, int, int, int, int, Image*, Point);extern int bezsplineop(Image*, Point*, int, int, int, int, Image*, Point, Drawop);extern int bezsplinepts(Point*, int, Point**);extern int fillbezier(Image*, Point, Point, Point, Point, int, Image*, Point);extern int fillbezierop(Image*, Point, Point, Point, Point, int, Image*, Point, Drawop);extern int fillbezspline(Image*, Point*, int, int, Image*, Point);extern int fillbezsplineop(Image*, Point*, int, int, Image*, Point, Drawop);extern void ellipse(Image*, Point, int, int, int, Image*, Point);extern void ellipseop(Image*, Point, int, int, int, Image*, Point, Drawop);extern void fillellipse(Image*, Point, int, int, Image*, Point);extern void fillellipseop(Image*, Point, int, int, Image*, Point, Drawop);extern void arc(Image*, Point, int, int, int, Image*, Point, int, int);extern void arcop(Image*, Point, int, int, int, Image*, Point, int, int, Drawop);extern void fillarc(Image*, Point, int, int, Image*, Point, int, int);extern void fillarcop(Image*, Point, int, int, Image*, Point, int, int, Drawop);extern void border(Image*, Rectangle, int, Image*, Point);extern void borderop(Image*, Rectangle, int, Image*, Point, Drawop);/* * Font management */extern Font* openfont(Display*, char*);extern Font* buildfont(Display*, char*, char*);extern void freefont(Font*);extern Font* mkfont(Subfont*, Rune);extern int cachechars(Font*, char**, Rune**, ushort*, int, int*, char**);extern void agefont(Font*);extern Subfont* allocsubfont(char*, int, int, int, Fontchar*, Image*);extern Subfont* lookupsubfont(Display*, char*);extern void installsubfont(char*, Subfont*);extern void uninstallsubfont(Subfont*);extern void freesubfont(Subfont*);extern Subfont* readsubfont(Display*, char*, int, int);extern Subfont* readsubfonti(Display*, char*, int, Image*, int);extern int writesubfont(int, Subfont*);extern void _unpackinfo(Fontchar*, uchar*, int);extern Point stringsize(Font*, char*);extern int stringwidth(Font*, char*);extern int stringnwidth(Font*, char*, int);extern Point runestringsize(Font*, Rune*);extern int runestringwidth(Font*, Rune*);extern int runestringnwidth(Font*, Rune*, int);extern Point strsubfontwidth(Subfont*, char*);extern int loadchar(Font*, Rune, Cacheinfo*, int, int, char**);extern char* subfontname(char*, char*, int);extern Subfont* _getsubfont(Display*, char*);extern Subfont* getdefont(Display*);extern void lockdisplay(Display*);extern void unlockdisplay(Display*);extern int drawlsetrefresh(ulong, int, void*, void*);/* * Predefined */extern uchar defontdata[];extern int sizeofdefont;extern Point ZP;extern Rectangle ZR;/* * Set up by initdraw() */extern Font *font;extern int _cursorfd;extern int _drawdebug; /* set to 1 to see errors from flushimage */extern void _setdrawop(Display*, Drawop);#define BGSHORT(p) (((p)[0]<<0) | ((p)[1]<<8))#define BGLONG(p) ((BGSHORT(p)<<0) | (BGSHORT(p+2)<<16))#define BPSHORT(p, v) ((p)[0]=(v), (p)[1]=((v)>>8))#define BPLONG(p, v) (BPSHORT(p, (v)), BPSHORT(p+2, (v)>>16))/* * Compressed image file parameters and helper routines */#define NMATCH 3 /* shortest match possible */#define NRUN (NMATCH+31) /* longest match possible */#define NMEM 1024 /* window size */#define NDUMP 128 /* maximum length of dump */#define NCBLOCK 6000 /* size of compressed blocks */extern void _twiddlecompressed(uchar*, int);extern int _compblocksize(Rectangle, int);/* XXX backwards helps; should go */extern ulong drawld2chan[];extern void drawsetdebug(int);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -