掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
Direct2D PathGeometryのCreate方法を教えてください (ID:49362)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
自作した procedure CustomPolyline(points: array of TD2Dpoint2F); というルーチンが期待通りに動作しないということですよね ? 僭越ではありますが,そういう時のすごい技をお教え致します. それは「新規にプロジェクトを作成」して,その関数だけをテストするプログラムを書いてテストします. この方法は,私が長年 Delphi を使っていて苦労の末に編み出した「技」です. 今回,特別に公開するものです. 例えば以下のようにします. こうすると,以下のコードをコピペして,他の方もテスト可能になるというスゴイ「技」なのです. implementation {$R *.dfm} uses Direct2D, D2D1; procedure CustomPolyline(points: array of TD2Dpoint2F); var iFact : Id2D1Factory; crv : ID2D1pathgeometry; isink : ID2D1GeometrySink; hr : Hresult; Lcanvas : Tdirect2dCanvas; begin iFact := D2DFactory(); if length(points) = 0 then exit; hr := Ifact.CreatePathGeometry(crv); if not succeeded(hr) then exit; hr := crv.open(isink); if not succeeded(hr) then exit; isink.SetFillMode(D2D1_FILL_MODE_WINDING); isink.BeginFigure(points[0],D2D1_FIGURE_BEGIN_FILLED); isink.AddLines(@points[1],length(points)-1); isink.EndFigure(D2D1_FIGURE_END_Closed); isink.Close; LCanvas := TDirect2DCanvas.Create(Form1.Canvas, Form1.canvas.clipRect); // LCanvas := TDirect2DCanvas.Create(bmp.Canvas, bmp.canvas.clipRect); with LCanvas do begin BeginDraw; drawgeometry(crv); ENdDraw; end; LCanvas.Free; end; procedure TForm1.Button1Click(Sender: TObject); var LPoints : array of TD2Dpoint2F; begin SetLength(LPoints, 3); LPoints[0].x := 30.0; LPoints[0].y := 30.0; LPoints[1].x := 150; LPoints[1].y := 80.0; LPoints[2].x := 80.0; LPoints[2].y := 130.0; CustomPolyline(LPoints); end;
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.