From a95272429641c472645f36ecf0abcb61e0a8f2a3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=AB=8F=E8=A8=AA=E5=AD=90?= Date: Thu, 2 May 2024 22:33:34 +0900 Subject: [PATCH] =?utf8?q?=E3=82=BA=E3=83=BC=E3=83=A0=E3=81=AF=E3=81=86?= =?utf8?q?=E3=81=BE=E3=81=8F=E5=87=BA=E6=9D=A5=E3=82=8B=E6=A7=98=E3=81=AB?= =?utf8?q?=E3=81=97=E3=81=9F=E3=80=82=E3=81=9D=E3=81=86=E3=81=97=E3=81=A6?= =?utf8?q?=E3=80=81=E3=82=BA=E3=83=BC=E3=83=A0=E3=82=A4=E3=83=B3=E9=99=90?= =?utf8?q?=E5=AE=9A=E3=82=92=E6=B6=88=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + main.c | 28 ++++++++-------------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90001ee..87fdb63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * 「Q」キーを押すと、終了する様に * サイズ変更の修正 * Pixivからダウンロード出来る様に +* ズーム機能性の追加 # 0.4.0 * URLから画像ファイルを開ける様に diff --git a/main.c b/main.c index 2205a2c..52b5f83 100644 --- a/main.c +++ b/main.c @@ -90,32 +90,18 @@ void windowevent(SDL_Event e) { // 画像のサイズが変わった場合 float newWidth = (float)imgWidth * zoom; float newHeight = (float)imgHeight * zoom; - float minLimit = 50.0f; - float maxLimitW = (screenWidth - 20); - float maxLimitH = (screenHeight - 20); // 画像は50x50以下じゃ駄目 - if (newWidth < minLimit && newWidth < minLimit) { + if (newWidth < minLimit || newHeight < minLimit) { newWidth = minLimit; newHeight = minLimit; - } else if (newWidth < minLimit && newHeight >= minLimit) { + } else if (newWidth < minLimit & newHeight >= minLimit) { newWidth = minLimit; } else if (newWidth >= minLimit && newHeight < minLimit) { newHeight = minLimit; } - // 大きすぎの場合もふざけんな - // TODO: 大きすぎの場合は、ズームインを辞める様にして - if (newWidth >= maxLimitW && newHeight >= maxLimitH) { - newHeight = (screenHeight * aspectRatio) - 20; - newWidth = (screenWidth * aspectRatio) - 20; - } else if (newWidth >= maxLimitW && newHeight < maxLimitH) { - newWidth = (screenWidth * aspectRatio) - 20; - } else if (newWidth < maxLimitW && newHeight >= maxLimitH) { - newHeight = (screenHeight * aspectRatio) - 20; - } - // テキスチャーのレンダーリングサイズの設定 SDL_RenderClear(renderer); @@ -176,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); -- 2.43.0