LoginSignup
0
0

円を描画する

Posted at

関連記事

開発環境

  • Windows11
  • Visual Studio 2022
  • DXライブラリ Ver3.24d

円の描画

DrawCircle関数を使用すると円を描画することができます。これは特定の座標に1ピクセルを描画するDrawPixel関数の機能を拡張したようなもので、指定された座標を中心として円が表示されます。

#include "DxLib.h"

int WINAPI WinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpcmdLine, _In_ int nCmdShow )
{
    // ウィンドウモード
    ChangeWindowMode( TRUE );

    // DXライブラリの初期化
    if( DxLib_Init() == -1 )
    {
        // -1ならエラーとして終了
        return 0;
    }

    // 円を描画
    DrawCircle( 100, 100, 50, 0xFFFFFF, TRUE );

    // プログラムの一時停止
    WaitKey();

    // DXライブラリの破棄
    DxLib_End();

    return 0;
}

実行結果

引数は以下の通りです。

定義
int DrawCircle( int x, int y, int r, unsigned int Color, int FillFlag );
引数 説明
int x 描画する円のX座標
int y 描画する円のY座標
int r 描画する円の半径
unsigned int Color 描画する円の色
int FillFlag 塗りつぶしフラグ

色の指定や塗りつぶしの有無は、矩形を描画する際の方法と同様です。指定した色で円を一色で塗りつぶすことができ、塗りつぶしフラグをFALSEに設定することで、円の輪郭のみ描画することもできます。

// 円を描画
DrawCircle( 100, 100, 50, 0xFFFF00, TRUE );
DrawCircle( 250, 100, 50, 0x00FFFF, FALSE );

参考

0
0
1

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