画格子图,并在每个格子中按照自己的意愿填充不同的颜色 神啊,那位大哥帮我写一段代码,要求在form上或者image上画出格子图,并能根据自己的要求在不同的格子中填充不同的颜色,please,急用~,要多少分您开个价!谢谢了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ColorGrd, ExtCtrls, StdCtrls;type TForm1 = class(TForm) Shape1: TShape; Shape2: TShape; Shape3: TShape; ColorGrid1: TColorGrid; Shape4: TShape; Shape5: TShape; Shape6: TShape; Shape7: TShape; Shape8: TShape; Shape9: TShape; procedure ColorGrid1Change(Sender: TObject); procedure Shape1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); private InColor:TColor; { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.ColorGrid1Change(Sender: TObject);begin InColor:=ColorGrid1.ForegroundColor;end;procedure TForm1.Shape1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);begin Tshape(sender).Brush.Color:=InColor;end;end.保存为unit1.pas 你可以动态生成shape,演示还够用 首先你要能画出格子,如果能达到这个功能,那填充颜色还有何难,画每个格子都有他的Rect,然后上色就行了Canvas.Brush.Color TCanvas.RectangleTCanvas.Brush.ColorTCanvas.Pen.ColorTCanvas.Pen.Width procedure TForm1.btn1Click(Sender: TObject);var rec: TRect; i,j: Integer;begin rec.Left := img1.Left; rec.Top := img1.Top; rec.Right := rec.Left + img1.Width; rec.Bottom := rec.top + img1.Height; i := rec.Left; while i < rec.Right do begin j := rec.Top; while j < rec.Bottom do begin Canvas.Brush.Color := 你要的色; Canvas.Rectangle(i,j,i+10,j+10); Inc(j,10); end; Inc(i,10); end;end;测试通过.将img1分成若干的小格子,并按你的要求填色这样都还写不来,你就没搞了 chart 的简单问题 Delphi调用EXCEL问题? delphi中怎么做到for each x in objs 哪个大哥能帮我弄个简单的数据访问程序啊? rollback可以套用嘛? 用DELPHI写的WEB程序为什么在我的WEB服务器上? 请问怎样与远程DB2连接? 在線等候,請問在Delphi中怎樣調存儲過存呢? delphi label自动换行的问题 在编辑修改时,dbEdit或dbmemo 不能输入 怎样用Delphi做个简单的英语单词连线游戏软件? 中控F7 开发包
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ColorGrd, ExtCtrls, StdCtrls;type
TForm1 = class(TForm)
Shape1: TShape;
Shape2: TShape;
Shape3: TShape;
ColorGrid1: TColorGrid;
Shape4: TShape;
Shape5: TShape;
Shape6: TShape;
Shape7: TShape;
Shape8: TShape;
Shape9: TShape;
procedure ColorGrid1Change(Sender: TObject);
procedure Shape1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
InColor:TColor;
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.ColorGrid1Change(Sender: TObject);
begin
InColor:=ColorGrid1.ForegroundColor;
end;procedure TForm1.Shape1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Tshape(sender).Brush.Color:=InColor;
end;end.
保存为unit1.pas 你可以动态生成shape,演示还够用
TCanvas.Brush.Color
TCanvas.Pen.Color
TCanvas.Pen.Width
var
rec: TRect;
i,j: Integer;
begin
rec.Left := img1.Left;
rec.Top := img1.Top;
rec.Right := rec.Left + img1.Width;
rec.Bottom := rec.top + img1.Height; i := rec.Left;
while i < rec.Right do
begin
j := rec.Top;
while j < rec.Bottom do
begin
Canvas.Brush.Color := 你要的色;
Canvas.Rectangle(i,j,i+10,j+10);
Inc(j,10);
end;
Inc(i,10);
end;
end;测试通过.将img1分成若干的小格子,并按你的要求填色
这样都还写不来,你就没搞了