程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> Delphi編程實現3D圖形修飾技術(4)

Delphi編程實現3D圖形修飾技術(4)

編輯:Delphi

利用以上子程序就可實現一些3D效果,實現的算法就是利用循環語句作畫,至於語句為什麼要這樣寫,這是我通過多次試驗調試出來的,正因為如此該算法不可能很完善,您可以對此改進作出更完美的效果。

最後,利用上面提供的子程序就可完成上圖所示的界面編制,其程序代碼如下:

procedure TForm2.FormPaint(Sender: TObject);
begin
 draw_bk(Form2,60,60,255);//畫藍色漸變背景
 draw_roll(Form2,0,0,640,480,250,200,100,10);
 //畫邊框周圍銅柱
 with Image1 do draw_rect(Form2,left,top,width,height, 250,200,100,10,1,1); //畫圖片框
 with Panel1 do draw_rect(Form2,left,top,width,height, 250,238,238,10,1,1);
 with Panel2 do draw_rect(Form2,left,top,width,height, 250,238,238,10,1,1);
 with Panel3 do draw_rect(Form2,left,top,width,height, 250,238,238,10,1,1);
 with Panel4 do draw_rect(Form2,left,top,width,height, 250,238,238,10,1,1);
 with Panel5 do draw_rect(Form2,left,top,width,height, 250,238,238,10,1,1);
 with Panel6 do draw_rect(Form2,left,top,width,height, 250,238,238,10,1,1);
 with Panel7 do draw_rect(Form2,left,top,width,height, 250,238,238,10,1,1);
 with Panel8 do draw_rect(Form2,left,top,width,height, 250,238,238,10,1,1);
 with Panel9 do draw_rect(Form2,left,top,width,height, 250,238,238,10,1,1);
 with Panel10 do draw_rect(Form2,left,top,width,height, 250,238,238,10,1,1);
 with Panel11 do draw_rect(Form2,left,top,width, height*2+2,250,238,238,10,1,1);
 with Panel13 do draw_rect(Form2,left,top,width,height, 250,238,238,10,1,1);
 with Panel14 do draw_rect(Form2,left,top,width,height, 250,238,238,10,1,1);
 with Panel16 do draw_rect(Form2,left,top,width,height, 250,238,238,10,1,1);
 //以上畫鍵盤
 with sele_fun do draw_rect(Form2,left,top,width,height, 250,238,238,10,1,1);
 with Panel15 do draw_rect(Form2,left,top,222,height, 250,238,238,10,1,1);
 with Panel15 do draw_rect(Form2,left-11,top-11,242, 350,250,258,238,10,1,1);
 draw_sroll(Form2,291,5,0,470,250,200,100,12);
 with gd do draw_rect(Form2,left,top,width,height, 250,238,238,10,1,1);
 with gk do draw_rect(Form2,left,top,width,height, 250,238,238,10,1,1);
end;

本文帶有源程序,該程序在Delphi 6.0下調試通過,無需擴展控件支持,純軟件方式實現,在界面設計上具有很大的靈活性,與圖片界面相比有其方便性,並且制作出來的界面有自己鮮明的特色。

結束語

本文闡述了不借助OpenGL和Direct3D圖形庫自己編程實現3D效果的方法,給出了實現一個鍵盤界面的完整源代碼。在工作中究竟使用什麼來實現3D和其它效果,要看工作性質而定,例如開發圖形效果表現豐富的游戲軟件,就要用到OpenGL或Direct3D技術,至於一些行業應用和工具軟件一般使用手工編程改善一下界面效果即可,就像上面的代碼,將比使用圖形庫的程序大大節省資源,而且易維護、易管理、兼容性也好。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved