CANVAS畫線屬性是否有不填滿? |
答題得分者是:taishyang
|
dean
一般會員 ![]() ![]() 發表:24 回覆:60 積分:21 註冊:2003-08-23 發送簡訊給我 |
各位前輩好:
小弟希望在一張圖片中得兩點劃一矩形,而只是希望兩點所形成的矩形有邊框,但不要填滿顏色而覆蓋到原本的圖片,但小弟看HELP與站上搜尋都沒有類似討論,而其中在DELPHI有找到一篇,但似乎也沒有解答!
http://delphi.ktop.com.tw/topic.php?topic_id=45175 Image1->Canvas->Rectangle(x1, y1 , x2, y2 );
這是畫矩形的寫法,可是CANVAS其他的屬性如STYLE與MODE,都不是是否填滿的屬性!若用MODE=true/false則是填滿黑色或白色,且邊框顏色也不見!
請問該如何利用CANVAS指畫出邊框而不要填滿內容?謝謝 **我很想學,但又很不懂,所以一直問蠢問題,希望不要不屑我的問題,嘻嘻嘻**
|
taishyang
站務副站長 ![]() ![]() ![]() ![]() ![]() ![]() 發表:377 回覆:5490 積分:4563 註冊:2002-10-08 發送簡訊給我 |
|
dean
一般會員 ![]() ![]() 發表:24 回覆:60 積分:21 註冊:2003-08-23 發送簡訊給我 |
引言: Image1->Canvas->Brush->Style=bsClear; Image1->Canvas->Rectangle(50,50,100,100);[/code]的確可以耶! 可是同樣方法,我用在PEN卻不行! Image1->Canvas->Pen->Style = bsClear; 卻不是只有邊框呢? WHY? 而且邊框的顏色要這樣設定: Image1->Canvas->Pen->Color = clRed; Image1->Canvas->Brush->Style = bsClear; [/code] 明明就是BRUSH,卻不能用BRUSH的COLOR,要用PEN才行,怪! **我很想學,但又很不懂,所以一直問蠢問題,希望不要不屑我的問題,嘻嘻嘻** |
taishyang
站務副站長 ![]() ![]() ![]() ![]() ![]() ![]() 發表:377 回覆:5490 積分:4563 註冊:2002-10-08 發送簡訊給我 |
|
dean
一般會員 ![]() ![]() 發表:24 回覆:60 積分:21 註冊:2003-08-23 發送簡訊給我 |
A brush style determines what pattern the canvas uses to fill shapes. It lets you specify various ways to combine the brushs color with any colors already on the canvas. The predefined styles include solid color, no color, and various line and hatch patterns. To change the style of a brush, set its Style property to one of the predefined values: bsSolid, bsClear, bsHorizontal, bsVertical, bsFDiagonal, bsBDiagonal, bsCross, or bsDiagCross. This example sets brush styles by sharing a click-event handler for a set of eight brush-style buttons. All eight buttons are selected, the Object Inspector|Events|OnClick is set, and the OnClick handler is named SetBrushStyle. Here is the handler code: void __fastcallTForm1::SetBrushStyle(TObject *Sender) { if (Sender == SolidBrush) Canvas->Brush->Style = bsSolid; else if (Sender == ClearBrush) Canvas->Brush->Style = bsClear; else if (Sender == HorizontalBrush) Canvas->Brush->Style = bsHorizontal; else if (Sender == VerticalBrush) Canvas->Brush->Style = bsVertical; else if (Sender == FDiagonalBrush) Canvas->Brush->Style = bsFDiagonal; else if (Sender == BDiagonalBrush) Canvas->Brush->Style = bsBDiagonal; else if (Sender == CrossBrush) Canvas->Brush->Style = bsCross; else if (Sender == DiagCrossBrush) Canvas->Brush->Style = bsDiagCross; } The above event handler code could be further reduced by putting the brush style constants into the Tag properties of the brush style buttons. Then this event code would be something like: void __fastcallTForm1::SetBrushStyle(TObject *Sender) { if (Sender->InheritsFrom (__classid(TSpeedButton)) Canvas->Brush->Style = (TBrushStyle) ((TSpeedButton *)Sender)->Tag; }**我很想學,但又很不懂,所以一直問蠢問題,希望不要不屑我的問題,嘻嘻嘻** |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |