Never too old to learn.

Pascal graph单元

Posted on By Andy Zhu

graph是pascal内置的一个绘图单元,且简单易用(除了速度慢了点就没有什么缺点了)

graph的优势:graph即使其他窗口叠在了它上面,也不需要重绘

  • procedure Arc (坐标X,坐标Y;Integer;开始角度,结束角度,半径; Word);画弧
  • procedure Bar(坐标x1,坐标y1,坐标x2,坐标y2: Integer);画一个已填充的正方形
  • procedure Bar3D(坐标x1,坐标y1,坐标x2,坐标y2:Integer;高:Word;有没有顶:Boolean);画立方体
  • procedure Circle(坐标X,坐标Y:Integer;半径:Word);画圆
  • procedure ClearDevice;把指示器移到(0,0),用背景颜色去清屏,准备输出
  • procedure ClearViewPort;把填充颜色变为背景色,把指示器移到(0,0)
  • procedure CloseGraph关掉图象(garph)模式
  • procedure DetectGraph(var 驱动器,模式:Integer);检查硬件和找出用哪个驱动器和模式
  • procedure DrawPoly(点数: Word; var 坐标:PolyPoints);画多边形
  • procedure Ellipse(坐标X,坐标Y:Integer;开始角度,结束角度:Word;半径1,半径2:Word);画椭圆
  • procedure FillEllipse(坐标X,坐标Y:Integer;半径1,半径2: Word);画一个已填充的椭圆
  • procedure FillPoly(点数: Word; var 坐标:PolyPoints);画一个已填充的多边形
  • procedure FloodFill(坐标X,坐标Y:Integer;边界颜色: Word);填充一个边界的区域
  • procedure GetArcCoords(var 记录变量: ArcCoordsType);得到上一次画弧时的开始坐标,结束坐标和圆心坐标
  • procedure GetAspectRatio(var 比例X,例Y:Word);得到屏幕高宽的比例
  • function GetBkColor: Word;返回当前的背景颜色
  • function GetColor: Word;得到当前的画图颜色
  • function GetDefaultPalette(var 记录变量: PaletteType);得到默认的颜色记录
  • function GetDriverName: string;得到驱动器的名字
  • procedure GetFillPattern(var 记录变量: FillPatternType);得到填充的模式
  • procedure GetFillSettings(var 记录变量: FillSettingsType);得到填充的设置
  • function GetGraphMode: Integer;得到图形的模式
  • procedure GetImage(坐标x1,坐标y1,坐标x2,坐标y2:Integer;var 位图:pointer);把一个指定区域里的一小片图象保存在缓冲器里
  • procedure GetLineSettings(var 记录变量: LineSettingsType);得到线的设置
  • function GetMaxColor: Word;得到最大的颜色
  • function GetMaxMode: Integer;得到最大的模式
  • function GetMaxX: Integer;得到最大的X坐标
  • function GetMaxY: Integer;得到最大的Y坐标
  • function GetModeName(模式序号: Integer): string;得到模式名
  • procedure GetModeRange(图象驱动:Integer; var 最小模式,最大模式:Integer);得到模式范围
  • procedure GetPalette(var 记录变量: PaletteType);得到当前的颜色记录
  • function GetPaletteSize: Integer;得到屏幕中颜色记录的尺寸
  • function GetPixel(坐标X,坐标Y: Integer): Word;得到(X,Y)的颜色
  • procedure GetTextSettings(var 记录变量: TextSettingsType);得到文字设置
  • procedure GetViewSettings(var ViewPort: ViewPortType);得到显示设置
  • function GetX: Integer;得到当前指示器的X坐标
  • function GetY: Integer;得到当前指示器的Y坐标
  • procedure GraphDefaults;把graph的所有设置变为原始状态
  • function GraphErrorMsg(错误号: Integer): string;返回指定错误号的信息
  • function GraphResult: Integer;返回最后一次画图时的错误号
  • function ImageSize(坐标x1,坐标y1,坐标x2,坐标y2:坐标Integer):坐标Word;返回一片区域储存所许的字节数
  • procedure InitGraph(var 驱动器:Integer;var 模式:Integer;到驱动器的路径:string);graph初始化
  • procedure Line(坐标x1,坐标y1,坐标x2,坐标y2:Integer);画线
  • procedure LineRel(坐标Dx,坐标Dy:Integer);画一条到指示器的线,坐标是对于指示器为(0,0)来说的
  • procedure LineTo(坐标X,坐标Y:Integer);画一条到指示器的线
  • procedure MoveRel(坐标Dx,坐标Dy: Integer);把指示器依到(Dx,Dy),坐标是对于指示器为(0,0)来说的
  • procedure MoveTo(坐标X,坐标Y: Integer);把指示器依到(x,y)
  • procedure OutText(字符串: string);在指示器位置上输出字符串
  • procedure OutTextXY(坐标X,坐标Y: Integer;字符串: string);在(x,y)位置输出字符串
  • procedure PieSlice(坐标X,坐标Y:Integer;开始角度,结束角度,半径:Word);画一个已填充的扇形
  • procedure PutImage(坐标X,坐标Y:Integer;var 位图:pointer;BitBlt:Word);把一个图象显示到显示器上,BitBlt处可为NormalPut,XORPut或者NotPut
  • procedure PutPixel(坐标X,坐标Y: Integer;颜色: Word);在(X,Y)上显示一个1*1的正方形
  • procedure Rectangle(坐标x1,坐标y1,坐标x2,坐标y2: Integer);画正方形
  • procedure RestoreCrtMode;恢复到刚初始化时的状态
  • procedure Sector(坐标x,坐标y:Integer;开始角度,结束角度,半径X,半径Y:Word);画一个已填充的椭圆部分
  • procedure SetActivePage(Page: Word);设置当前画图所在的页
  • procedure SetAllPalette(var Palette);把所有颜色设置变为特定的
  • procedure SetBkColor(颜色: Word);设置背景颜色
  • procedure SetColor(颜色: Word);设置颜色
  • procedure SetFillPattern(记录变量: FillPatternType;颜色:Word);设置填充颜色模式
  • procedure SetFillStyle(模式: ord;颜色: Word);设置填充颜色风格
  • procedure SetLineStyle(线风格:Word;模式:Word;厚度:Word);设置线的风格
  • procedure SetPalette(颜色序号:Word;颜色:Shortint);设置调色版
  • procedure SetTextStyle(字体,方向:Word;大小:Word);设置文字风格
  • procedure SetVisualPage(Page: Word);设置当前显示的页
  • procedure SetWriteMode(写字模式: Integer);设置写字模式
  • function TextHeight(字符串: string): Word;文字的高
  • function TextWidth(TextString: string): Word;文字的宽

用法:

uses graph;
var
    gd,gm:integer;
begin
    gm:=detect;//侦查窗口模式
    initgraph(gd,gt,'');//初始化
    //画图
    closegraph;//关闭窗口
end.