掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
Tcanvasで円を描くには? (ID:18902)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
興味ある話題なのですが、質問者さんからの補填が無さそうですね・・・ Ellipseは恐らくミッチェナーのアルゴリズムを使っており、円の軌跡が通る一番近いドットを塗りつぶしていくのでギザギザします。 junkiさんのレスで全てのような気がしますが、 VCLのみで(?)滑らかっぽい円を描く方法を挙げときます。 円、直線ぐらいまでならこれで応用できます。 procedure TForm1.Button1Click(Sender: TObject); var xs,ys,xe,ye ,xi,yi:Integer; xc,yc,xd,yd,wd,hd,rd,dis :Double; IC : array of array of Integer; P : PByteArray; wi,hi :Integer; begin rd := 111.3; //半径 wd := 0.7; //円の芯の太さ(アンチエリアシングしない部分) hd := 0.9; //アンチエリアシングする部分の幅 // ____/‾‾\____ // hd 2wd hd xc := 200.5; //中心 yc := 250.7; //中心 xs := round (xc - rd - wd -hd -1); xe := round (xc + rd + wd +hd +1); ys := round (yc - rd - wd -hd -1); ye := round (yc + rd + wd +hd +1); SetLength( IC , xe-xs+2, ye-ys+2); for yi := ys to ye do begin for xi := xs to xe do begin IC[yi-ys, xi-xs] := 255; end; end; for yi := ys to ye do begin for xi := xs to xe do begin dis := sqrt(Sqr(xi - xc)+Sqr(yi - yc)) ; if dis > rd then //外側 begin if dis < rd + wd then //芯 IC[yi-ys, xi-xs] := 0 else if dis < rd + wd + hd then IC[yi-ys, xi-xs] := round((dis - rd - wd)*255/hd); end else //内側 begin if dis > rd - wd then //芯 IC[yi-ys, xi-xs] := 0 else if dis > rd - wd - hd then IC[yi-ys, xi-xs] := 255-round((dis - rd + wd + hd)*255/hd); end; end; end; //イメージにコピー Image1.Picture.Bitmap.Width := xe+1; Image1.Picture.Bitmap.Height:= ye+1; Image1.Picture.Bitmap.PixelFormat := pf24bit; for yi := ys to ye do begin P := Image1.Picture.Bitmap.ScanLine[yi]; for xi := xs to xe do begin P[xi*3 ] := IC[yi-ys,xi-xs]; P[xi*3+1] := IC[yi-ys,xi-xs]; P[xi*3+2] := IC[yi-ys,xi-xs]; end; end; Image1.Canvas.Ellipse(0,0,220,220); //比較用 end;
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.