我公布一个现在做的画图函数代码,希望对大家有所帮助。
{TODO -oXQ: 画图主函数}
{
函数功能: 按照给定的参数画图形
创建时间: 2003-03-05
参 数: 1:画布;2:起始点;3:终止点;4:形状标识;5:画笔颜色;6:画笔模式;7:画笔类型;8:线宽度;9:画刷类型;10:画刷颜色
修 改: 2003-03-18 加入画布颜色控制填充线条颜色,加入画线类型
2003-03-20 参数改变,形成结构体
}
Procedure TDrawShape.Paint_Rect(Shape_Struct:TShape_Record);
var
X1,X2,Y1,Y2:integer;
begin
with Shape_Struct.OwnImage.Canvas do
begin
with Shape_Struct do
begin
Pen.Color := Pen_Color;
Pen.Mode := Pen_Mode;
Pen.Style := Pen_Style;
Pen.Width := Pen_LineSize;
Brush.Style := Brush_Style;
if(Brush_Style <> bsClear) then
begin
Brush.Color := Brush_Color; //画网格线需要
end;
case ImageShape of
1: //画直线
begin
MoveTo(bpt.X,bpt.Y);
LineTo(ept.X,ept.Y);
end;
2: //画矩形
begin
Rectangle(bpt.X,bpt.Y,ept.X,ept.Y);
end;
3: //画椭圆
begin
Ellipse(bpt.X,bpt.Y,ept.X,ept.Y);
end;
4: //画圆角矩形
begin
RoundRect(bpt.X,bpt.Y,ept.X,ept.Y,20,20);
end;
5: //画多边形
begin
LineTo(bpt.X,bpt.Y);
LineTo(ept.X,ept.Y);
end;
6: //描点
begin
MoveTo(bpt.X,bpt.Y);
LineTo(ept.X,ept.Y);
//Pixels[bpt.X,bpt.Y]:= PenColor;
end;
7: //画笔功能
begin
MoveTo(bpt.X,bpt.Y);
Pen.Mode := pmCopy;
LineTo(ept.X,ept.Y);
end;
8: //橡皮擦功能
begin
Pen.Color := clWhite;
Pen.Mode := pmCopy;
Pen.Width := 5;
LineTo(ept.X,ept.Y);
end;
9: //画圆弧形
begin
X1 := (bpt.X + 2*ept.X) div 3;
X2 := (ept.X + 2*bpt.X) div 3;
Y1 := (bpt.Y + 2*ept.Y) div 3;
Y2 := (ept.Y + 2*bpt.Y) div 3;
Arc(bpt.X,bpt.Y,X1,Y1,X2,Y2,ept.X,ept.Y);
end;
10: //画控件
begin
end;
end;
end;
end;
end;