コミットを比較
5 コミット
047bcda708
...
8c0d4ecc84
作成者 | SHA1 | 日付 |
---|---|---|
守矢諏訪子 | 8c0d4ecc84 | |
守矢諏訪子 | a952724296 | |
守矢諏訪子 | f79a52ed85 | |
守矢諏訪子 | 681692740f | |
守矢諏訪子 | 9bd753c5d4 |
|
@ -5,6 +5,7 @@
|
|||
* 「Q」キーを押すと、終了する様に
|
||||
* サイズ変更の修正
|
||||
* Pixivからダウンロード出来る様に
|
||||
* ズーム機能性の追加
|
||||
|
||||
# 0.4.0
|
||||
* URLから画像ファイルを開ける様に
|
||||
|
|
52
main.c
52
main.c
|
@ -18,6 +18,9 @@ int screenHeight;
|
|||
int init = 0;
|
||||
SDL_Rect renderQuad;
|
||||
|
||||
// ズーム
|
||||
float zoom = 1.0f;
|
||||
|
||||
const char* sofname = "mivfx";
|
||||
const char* version = "0.5.0";
|
||||
|
||||
|
@ -71,6 +74,45 @@ void windowevent(SDL_Event e) {
|
|||
} else if (e.key.keysym.sym == SDLK_a) {
|
||||
// GIFアニメーションの停止・続き、0.6.0から追加する予定
|
||||
}
|
||||
} else if (e.type == SDL_MOUSEWHEEL) {
|
||||
// TODO: ノートパソコンでおかしくなる
|
||||
float zoomSpeed = 0.1f;
|
||||
if (e.wheel.y > 0) {
|
||||
zoom += zoomSpeed;
|
||||
} else if (e.wheel.y < 0) {
|
||||
zoom -= zoomSpeed;
|
||||
}
|
||||
|
||||
if (zoom < 0.1f) {
|
||||
zoom = 0.1f;
|
||||
}
|
||||
|
||||
// 画像のサイズが変わった場合
|
||||
float newWidth = (float)imgWidth * zoom;
|
||||
float newHeight = (float)imgHeight * zoom;
|
||||
float minLimit = 50.0f;
|
||||
|
||||
// 画像は50x50以下じゃ駄目
|
||||
if (newWidth < minLimit || newHeight < minLimit) {
|
||||
newWidth = minLimit;
|
||||
newHeight = minLimit;
|
||||
} else if (newWidth < minLimit & newHeight >= minLimit) {
|
||||
newWidth = minLimit;
|
||||
} else if (newWidth >= minLimit && newHeight < minLimit) {
|
||||
newHeight = minLimit;
|
||||
}
|
||||
|
||||
// テキスチャーのレンダーリングサイズの設定
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
renderQuad.w = (int)newWidth;
|
||||
renderQuad.h = (int)newHeight;
|
||||
renderQuad.x = (windowWidth - renderQuad.w) / 2;
|
||||
renderQuad.y = (windowHeight - renderQuad.h) / 2;
|
||||
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderCopy(renderer, texture, NULL, &renderQuad);
|
||||
SDL_RenderPresent(renderer);
|
||||
} else if (e.type == SDL_WINDOWEVENT && e.window.event == SDL_WINDOWEVENT_RESIZED) {
|
||||
// ウィンドウのサイズが変わった場合
|
||||
int newWidth = e.window.data1;
|
||||
|
@ -120,18 +162,20 @@ void windowevent(SDL_Event e) {
|
|||
(imgWidth >= (screenWidth - 100)) &&
|
||||
imgHeight >= (screenHeight - 100)
|
||||
) {
|
||||
imgWidth -= (screenWidth * 3);
|
||||
imgHeight -= (screenHeight * 3);
|
||||
imgWidth = (screenWidth - 100);
|
||||
imgHeight = (screenHeight - 100);
|
||||
} else if (
|
||||
(imgWidth >= (screenWidth - 100)) &&
|
||||
imgHeight <= (screenHeight - 100)
|
||||
) {
|
||||
imgWidth -= (screenWidth * 3);
|
||||
imgWidth = (screenWidth - 100);
|
||||
imgHeight = (imgWidth * aspectRatio);
|
||||
} else if (
|
||||
(imgWidth <= (screenWidth - 100)) &&
|
||||
imgHeight >= (screenHeight - 100)
|
||||
) {
|
||||
imgHeight -= (screenHeight * 3);
|
||||
imgHeight = (screenHeight - 100);
|
||||
imgWidth = (imgHeight * aspectRatio);
|
||||
}
|
||||
|
||||
SDL_RenderCopy(renderer, texture, NULL, &renderQuad);
|
||||
|
|
読み込み中…
新しいイシューから参照