ズームはうまく出来る様にした。そうして、ズームイン限定を消した

このコミットが含まれているのは:
守矢諏訪子 2024-05-02 22:33:34 +09:00
コミット a952724296
2個のファイルの変更9行の追加20行の削除

ファイルの表示

@ -5,6 +5,7 @@
* 「Q」キーを押すと、終了する様に
* サイズ変更の修正
* Pixivからダウンロード出来る様に
* ズーム機能性の追加
# 0.4.0
* URLから画像ファイルを開ける様に

28
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);