LoginSignup
0
0

More than 5 years have passed since last update.

C++ Builder XE4, 10.2 Tokyo > TCanvas > Arcを描く

Last updated at Posted at 2017-03-28
動作環境
C++ Builder XE4
RAD Studio 10.2 Tokyo Update 2 (追記: 2017/12/28)

Arcを描きたくなった。

TCanvas.Arc Method

Use Arc to draw an elliptically curved line with the current Pen. The arc traverses the perimeter of an ellipse that is bounded by the points (X1,Y1) and (X2,Y2). The arc is drawn following the perimeter of the ellipse, counterclockwise, from the starting point to the ending point. The starting point is defined by the intersection of the ellipse and a line defined by the center of the ellipse and (X3,Y3). The ending point is defined by the intersection of the ellipse and a line defined by the center of the ellipse and (X4, Y4).

何を言っているのかさっぱり。
文章で書くよりは図の1つでも掲載すれば、閲覧者の理解は早まると思う。

Unit1.cpp
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
    TRect R = GetClientRect();
    //          X1      Y1     X2       Y2        X3       Y3     X4      Y4
    this->Canvas->Arc(R.Left, R.Top, R.Right, R.Bottom, R.Right, R.Top, R.Left, R.Top);
}
//---------------------------------------------------------------------------

とりあえず図示した。

qiita.png

  • Arcのサイズは1,2の点で指定
  • 開始位置は3で指定
  • そこから反時計回りに
  • 終了位置4まで弧を描く
  • 弧が切れるのは、楕円(もしくは円)の中心(c)と3の点の交差点
    • 終了点も同様 (cと4の交差点)

qiita.png

これを少し変更すれば、Pie Chartのoverlapping機能付きグラフが完成するだろう。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0