5 #include <Multimedia/SDX.h>
6 #include <Multimedia/Screen.h>
7 #include <Multimedia/Loading.h>
8 #include <Multimedia/IDrawable.h>
9 #include <Framework/Shape.h>
10 #include <Framework/Camera.h>
23 SDL_Texture* handle =
nullptr;
24 Color color = { 255, 255, 255 ,255};
27 void RGBACulculate()
const
33 SDL_SetTextureAlphaMod(handle, color.
GetAlpha());
41 SDL_SetTextureColorMod
69 Image(SDL_Texture* 画像ハンドル,
int 幅,
int 高さ):
83 bool Load(
const char *ファイル名)
85 if (Loading::isLoading)
91 if (this->handle !=
nullptr){
return false; }
93 SDL_Surface* temp = IMG_Load(ファイル名);
95 if (temp ==
nullptr)
return false;
104 SDL_FreeSurface(temp);
105 return (handle !=
nullptr);
111 if (this->handle !=
nullptr)
113 SDL_DestroyTexture(handle);
120 SDL_Texture*
Make(
int 幅,
int 高さ)
124 handle = SDL_CreateTexture(
Screen::GetHandle(), 0, SDL_TEXTUREACCESS_TARGET, 幅, 高さ);
137 this->handle = 元イメージ.handle;
138 part.x = (int)コピー領域.
x;
139 part.y = (
int)コピー領域.
y;
140 part.w = (int)コピー領域.
GetW();
141 part.h = (int)コピー領域.
GetH();
150 return Clone({part.x,part.y,part.w,part.h}, is反転);
181 bool Draw(
const Point &座標,
bool 反転フラグ =
false)
const override
183 SDL_Rect temp = { (int)座標.
x, (
int)座標.
y, part.w, part.h };
193 return !SDL_RenderCopyEx(
Screen::GetHandle(), handle, &part, &temp, 0,
nullptr, SDL_RendererFlip::SDL_FLIP_HORIZONTAL);
203 SDL_Rect temp = { (int)描画領域.
x, (
int)描画領域.
y, (int)描画領域.
GetW(), (int)描画領域.
GetH() };
211 if (temp.w < 0 || temp.h < 0)
219 static SDL_Point point = { 0, 0 };
220 return !SDL_RenderCopyEx(
Screen::GetHandle(), handle, &part, &temp, 0, &point, SDL_RendererFlip::SDL_FLIP_HORIZONTAL);
229 bool DrawRotate(
const Point &座標,
double 拡大率,
double 角度,
bool 反転フラグ =
false)
const override
231 const int wbuf = int(part.w*拡大率);
232 const int hbuf = int(part.h*拡大率);
233 SDL_Rect temp = { (int)座標.
x - wbuf / 2, (
int)座標.
y - hbuf / 2, wbuf, hbuf };
241 return !SDL_RenderCopyEx(
Screen::GetHandle(), handle, &part, &temp, 角度 * 180 /
PAI,
nullptr, SDL_RendererFlip(反転フラグ));
251 const int wbuf = int(part.w*拡大率X);
252 const int hbuf = int(part.h*拡大率Y);
253 SDL_Rect temp = { (int)座標.
x - wbuf / 2, (
int)座標.
y - hbuf / 2, wbuf, hbuf };
254 SDL_Point point = { int(回転軸座標.
x*拡大率X), int(回転軸座標.
y*拡大率Y) };
264 return !SDL_RenderCopyEx(
Screen::GetHandle(), handle, &part, &temp, 角度 * 180 /
PAI, &point, SDL_RendererFlip(反転フラグ));
270 SDL_Rect temp = { (int)描画先座標.
x, (
int)描画先座標.
y, (int)描画元領域.
GetW(), (int)描画元領域.
GetH() };
271 SDL_Rect part = { (int)描画元領域.
x + this->part.x, (
int)描画元領域.
y + this->part.y, (int)描画元領域.
GetW(), (int)描画元領域.
GetH() };
279 return !SDL_RenderCopyEx(
Screen::GetHandle(), handle, &part, &temp, 0,
nullptr, SDL_RendererFlip(反転フラグ));
285 SDL_Rect temp = { (int)描画先領域.
x, (
int)描画先領域.
y, (int)描画先領域.
GetW(), (int)描画先領域.
GetH() };
286 SDL_Rect part = { (int)描画元領域.
x + this->part.x, (
int)描画元領域.
y + this->part.y, (int)描画元領域.
GetW(), (int)描画元領域.
GetH() };
294 if (temp.w < 0 || temp.h < 0)
300 return !SDL_RenderCopyEx(
Screen::GetHandle(), handle, &part, &temp, 0,
nullptr, SDL_RendererFlip(反転フラグ));
SDL_Texture * Copy(const Image &元イメージ, const Rect &コピー領域)
別のImageの一部をコピーして、Imageを初期化.
Definition: Image.h:135
const double PAI
円周率
Definition: SDX.h:26
double y
起点座標
Definition: Rect.h:26
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
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
bool DrawPart(const Point &描画先座標, const Rect &描画元領域, bool 反転フラグ=false) const override
指定した一部分を描画.
Definition: Image.h:268
int GetBlue() const
青の要素を取得.
Definition: Color.h:42
リソースを読み込まずに描画を行う関数群.
Definition: Drawing.h:17
SDL_Rect TransRect(const SDL_Rect &変換前矩形) const
領域を画面上のどこに相当するか変換.
Definition: Camera.h:102
点を表す図形クラス.
Definition: Point.h:22
BlendMode blendMode
描画モード
Definition: Renderer.h:51
Image(const char *ファイル名)
画像をメモリへ読み込む.
Definition: Image.h:56
Image(int 幅, int 高さ)
空のイメージを作成.
Definition: Image.h:77
static Renderer * GetRenderer()
アクティブなRendererを取得.
Definition: Screen.h:33
bool DrawRotate(const Point &座標, double 拡大率, double 角度, bool 反転フラグ=false) const override
角度、拡大率を指定して描画.
Definition: Image.h:229
void SetColor(int 赤, int 緑, int 青, int α値=255)
色の各要素を設定.
Definition: Color.h:24
static bool SetTarget(Image *描画対象=nullptr)
描画先を変更.
Definition: Screen.h:48
double x
起点座標
Definition: Rect.h:25
画像データを表すクラス.
Definition: Image.h:17
色を表すクラス.
Definition: Color.h:11
Image Clone(const Rect &コピー領域, bool is反転=false) const
Imageの一部から別Imageを作成.
Definition: Image.h:155
static void AddLoading(std::function< void(void)> &&読み込み関数)
非同期読み込み処理に追加.
Definition: Loading.h:96
int GetHeight() const
高さを取得.
Definition: Image.h:310
int GetWidth() const
幅を取得.
Definition: Image.h:304
SDL_Texture * GetHandle() const
ハンドルを取得.
Definition: Image.h:175
描画可能なクラスのインターフェース.
Definition: IDrawable.h:14
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
Image(SDL_Texture *画像ハンドル, int 幅, int 高さ)
SDL_TextureからImageを作成.
Definition: Image.h:69
double zoom
拡大率、マイナスになると描画が狂う
Definition: Camera.h:45
double x
座標
Definition: Point.h:25
複数のImageをまとめるクラス.
Definition: ImagePack.h:17
static void Set(Camera *アクティブにするCamera=nullptr)
現在アクティブなカメラを設定.
Definition: Camera.h:63
void SetColor(const Color &描画色)
描画色を指定.
Definition: Image.h:316
int GetAlpha() const
透明度を取得.
Definition: Color.h:48
bool DrawPartExtend(const Rect &描画先領域, const Rect &描画元領域, bool 反転フラグ=false) const
指定した一部分を描画.
Definition: Image.h:283
bool Draw(const Point &座標, bool 反転フラグ=false) const override
指定座標に描画.
Definition: Image.h:181
bool Load(const char *ファイル名)
画像をメモリへ読み込む.
Definition: Image.h:83
Image(const Image &コピー元, const Rect &コピー領域)
別のImageの一部をコピーして、Imageを初期化.
Definition: Image.h:63
double GetW() const override
幅を取得.
Definition: Rect.h:107
bool DrawRotateAxis(const Point &座標, const Point &回転軸座標, double 拡大率X, double 拡大率Y, double 角度, bool 反転フラグ=false) const override
回転軸、角度、拡大率を縦横別に指定して描画.
Definition: Image.h:249
double GetH() const override
高さを取得.
Definition: Rect.h:112
Image Clone(bool is反転=false) const
同じImageを作成.
Definition: Image.h:148