5 #include <Multimedia/SDX.h>
6 #include <Multimedia/Color.h>
7 #include <Multimedia/Image.h>
8 #include <Multimedia/Font.h>
9 #include <Utility/VariadicStream.h>
10 #include <Framework/Shape.h>
11 #include <Framework/Camera.h>
23 void operator =(
const Drawing& src){}
27 static void RGBACulculate(
const Color &色 )
38 SDL_SetRenderDrawColor
49 static void MakeCircle(SDL_Renderer* renderer,
int x1,
int y1,
int x2,
int y2)
58 SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
59 SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0);
60 SDL_RenderClear(renderer);
61 SDL_SetRenderDrawColor(renderer,255,255,255,255);
63 dx = x2 - x1 < 0 ? x1 - x2 : x2 - x1;
64 dy = y2 - y1 < 0 ? y1 - y2 : y2 - y1;
78 SDL_RenderDrawLine(renderer, xa + x2, -yb + y1,xa + x2, yb + y2);
79 SDL_RenderDrawLine(renderer, ya + x2, -xb + y1, ya + x2, xb + y2);
80 SDL_RenderDrawLine(renderer, -ya + x1, -xb + y1, -ya + x1, xb + y2);
81 SDL_RenderDrawLine(renderer, -xa + x1, -yb + y1, -xa + x1, yb + y2);
93 static Image& GetCircle(
const Color &描画色,
const Rect &矩形 = {0,0,0,0},
int 太さ = 0)
98 const int CIRCLE_SIZE = 512;
102 circleA.
Make(CIRCLE_SIZE, CIRCLE_SIZE);
103 circleB.
Make(CIRCLE_SIZE, CIRCLE_SIZE);
104 circleC.
Make(CIRCLE_SIZE, CIRCLE_SIZE);
135 太さ = std::max(太さ * CIRCLE_SIZE * 2 /
int(矩形.GetW() + 矩形.GetH()), 2);
148 circleA.
Draw({ 0, 0 });
150 circleA.
DrawExtend({ 太さ, 太さ , CIRCLE_SIZE - 太さ*2 , CIRCLE_SIZE - 太さ*2 });
152 circleA.
SetColor({255-alpha,255-alpha,255-alpha});
153 circleA.
Draw({ 0, 0 });
155 circleA.
DrawExtend({ 太さ, 太さ , CIRCLE_SIZE - 太さ*2, CIRCLE_SIZE - 太さ*2 });
183 static void GetTriangle(
const Color &描画色,
const Point &中心座標 = {0,0},
int 辺の長さ = 0,
double 角度 = 0,
int 太さ = 0)
189 const int WSIZE = 173*2;
190 const int HSIZE = 200*2;
194 imageA.
Make(WSIZE, HSIZE);
195 imageB.
Make(WSIZE, HSIZE);
196 imageC.
Make(WSIZE, HSIZE);
212 for (
int y = 0; y < HSIZE/2; ++y)
214 int x = WSIZE * y * 2 / HSIZE;
229 const double 拡大率 = double(辺の長さ) / HSIZE;
234 imageA.
DrawRotateAxis({ 中心座標.x ,中心座標.y}, { WSIZE/3, HSIZE/2 }, 拡大率, 角度);
238 太さ = std::max(太さ * WSIZE* 2 / (辺の長さ), 2);
251 imageA.
Draw({ 0, 0 });
253 imageA.
DrawExtend({ 太さ/2, 太さ , WSIZE - 太さ*3/2, HSIZE - 太さ*2 });
255 imageA.
SetColor({ 255 - alpha, 255 - alpha, 255 - alpha });
256 imageA.
Draw({ 0, 0 });
258 imageA.
DrawExtend({ 太さ/2, 太さ , WSIZE - 太さ*3/2, HSIZE - 太さ*2 });
265 imageB.
DrawRotateAxis({ 中心座標.x, 中心座標.y }, { WSIZE / 3, HSIZE / 2 }, 拡大率, 角度);
272 imageC.
DrawRotateAxis({ 中心座標.x, 中心座標.y }, { WSIZE / 3, HSIZE / 2 }, 拡大率, 角度);
276 imageB.
DrawRotateAxis({ 中心座標.x, 中心座標.y }, { WSIZE / 3, HSIZE / 2 }, 拡大率, 角度);
286 static Font defaultFont;
291 static void SetDefaultFont(
const char* フォント名,
int 大きさ,
int 行間 = 0 ,
bool 高品質レンダリング =
true)
330 image.
Make(256, 256);
340 double rateX = std::sqrt((終点.
x - 始点.
x)*(終点.
x - 始点.
x) + (終点.
y - 始点.
y) * (終点.
y - 始点.
y));
342 double angle = std::atan2( 終点.
y - 始点.
y , 終点.
x - 始点.
x);
345 image.
DrawRotateAxis({ (始点.
x + 終点.
x)/2, (始点.
y + 終点.
y)/2 }, { 128, 128 }, rateX/256, rateY/256, angle);
375 if (円形.
radius <= 0){
return; }
394 GetCircle(色).
DrawExtend({ 中心.
x - 幅 / 2, 中心.
y - 高さ / 2, (double)幅, (
double)高さ });
398 GetCircle(色, { 中心.
x - 幅 / 2, 中心.
y - 高さ / 2, 幅, 高さ }, 太さ);
405 for (
unsigned int a = 0; a < 頂点.size() ; ++a)
407 if (a == 頂点.size() - 1)
427 GetTriangle(描画色, 中心座標, 辺の長さ, 角度);
431 GetTriangle(描画色, 中心座標, 辺の長さ, 角度, 太さ);
bool Draw(const Point &座標, const Color &描画色, const VariadicStream &描画する文字列, bool 反転フラグ=false) const override
文字を描画.
Definition: Font.h:615
SDL_Texture * Make(int 幅, int 高さ)
空のイメージを作成.
Definition: Image.h:120
int GetGreen() const
緑の要素を取得.
Definition: Color.h:36
矩形を表す図形クラス.
Definition: Rect.h:22
static Image * GetTarget()
描画先Imageを取得.
Definition: Screen.h:55
double y
座標
Definition: Point.h:26
static void Pixel(const Point &座標, const Color &色)
指定座標に点を描画.
Definition: Drawing.h:436
bool DrawRotateAxis(const Point &座標, const Point &回転軸座標, double 拡大率, double 角度, bool 反転フラグ=false) const override
回転軸、角度、拡大率を指定して描画.
Definition: Image.h:244
Color rgba
描画輝度とα値
Definition: Renderer.h:53
bool DrawExtend(const Rect &描画領域, bool 反転フラグ=false) const override
指定矩形内に描画.
Definition: Image.h:201
double GetTop() const
上端のY座標を取得.
Definition: Rect.h:124
int GetBlue() const
青の要素を取得.
Definition: Color.h:42
リソースを読み込まずに描画を行う関数群.
Definition: Drawing.h:17
double GetLeft() const
左端のX座標を取得.
Definition: Rect.h:118
static void Circle(const Circle &円形, const Color &色, int 太さ=0)
中心と半径を指定して円を描画.
Definition: Drawing.h:373
SDL_Rect TransRect(const SDL_Rect &変換前矩形) const
領域を画面上のどこに相当するか変換.
Definition: Camera.h:102
double x
座標
Definition: Circle.h:23
static void Line(const Point &始点, const Point &終点, const Color &色, int 太さ=1)
始点と終点を結ぶ直線を描画.
Definition: Drawing.h:297
点を表す図形クラス.
Definition: Point.h:22
BlendMode blendMode
描画モード
Definition: Renderer.h:51
static void String(const Point &座標, const Color &色, const VariadicStream &描画する文字列)
文字を描画.
Definition: Drawing.h:463
TrueTypeFontとBMPFontをまとめて扱うクラス.
Definition: Font.h:25
double TransX(double X座標変換前) const
カメラの位置と拡大率に応じてX座標を変換.
Definition: Camera.h:84
static Renderer * GetRenderer()
アクティブなRendererを取得.
Definition: Screen.h:33
double y
座標
Definition: Circle.h:24
double TransY(double Y座標変換前) const
カメラの位置と拡大率に応じてY座標を変換.
Definition: Camera.h:90
static bool SetTarget(Image *描画対象=nullptr)
描画先を変更.
Definition: Screen.h:48
static void Triangle(const Point &中心座標, int 辺の長さ, double 角度, const Color &描画色, int 太さ=0)
正三角形を描画.
Definition: Drawing.h:423
static const Color White
白 [RGB]255,255,255
Definition: Color.h:81
画像データを表すクラス.
Definition: Image.h:17
色を表すクラス.
Definition: Color.h:11
bool Load(const char *フォント名, int 大きさ, int 行間=0, bool 高品質レンダリングフラグ=true)
フォントを作成する.
Definition: Font.h:183
SDL_Texture * GetHandle() const
ハンドルを取得.
Definition: Image.h:175
static const Color Black
黒 [RGB]0,0,0
Definition: Color.h:78
bool Release()
イメージをメモリから開放.
Definition: Image.h:109
static SDL_Renderer * GetHandle()
スクリーンハンドルを取得.
Definition: Screen.h:26
static Camera * Get()
現在アクティブなカメラを取得.
Definition: Camera.h:57
static void SetDrawMode(const Color &輝度+α値=Color::White, BlendMode ブレンドモード=BlendMode::Alpha)
描画輝度と描画モードをまとめて設定
Definition: Screen.h:100
int GetRed() const
赤の要素を取得.
Definition: Color.h:30
可変数引数な文字列を処理するクラス.
Definition: VariadicStream.h:25
static void ImageFile(const Point &座標, const char *ファイル名, bool 透過フラグ=true)
画像を一時的にメモリに読み込んで描画.
Definition: Drawing.h:454
double x
座標
Definition: Point.h:25
static void Set(Camera *アクティブにするCamera=nullptr)
現在アクティブなカメラを設定.
Definition: Camera.h:63
static void Polygon(std::vector< Point > 頂点, const Color &色, int 太さ=1)
頂点を指定して多角形を描画.
Definition: Drawing.h:403
void SetColor(const Color &描画色)
描画色を指定.
Definition: Image.h:316
int GetAlpha() const
透明度を取得.
Definition: Color.h:48
static Font & GetFont()
デフォルトのフォントを取得する.
Definition: Drawing.h:284
円を表す図形クラス.
Definition: Circle.h:20
bool Draw(const Point &座標, bool 反転フラグ=false) const override
指定座標に描画.
Definition: Image.h:181
static void SetDefaultFont(const char *フォント名, int 大きさ, int 行間=0, bool 高品質レンダリング=true)
デフォルトのフォントを設定する.
Definition: Drawing.h:291
double GetW() const override
幅を取得.
Definition: Rect.h:107
static void Rect(const Rect &領域, const Color &色, bool 塗りつぶしフラグ=true)
左上の座標と大きさを指定して矩形を描画.
Definition: Drawing.h:350
double GetH() const override
高さを取得.
Definition: Rect.h:112
double radius
半径
Definition: Circle.h:25
static void Oval(const Point &中心, int 幅, int 高さ, const Color &色, int 太さ=0)
中心と外接する四角形の大きさを指定して楕円を描画.
Definition: Drawing.h:390