gosu 1.4.6 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/COPYING +2 -1
- data/dependencies/SDL/include/SDL3/SDL.h +91 -0
- data/dependencies/SDL/include/SDL3/SDL_assert.h +710 -0
- data/dependencies/SDL/include/SDL3/SDL_asyncio.h +550 -0
- data/dependencies/SDL/include/SDL3/SDL_atomic.h +692 -0
- data/dependencies/SDL/include/SDL3/SDL_audio.h +2382 -0
- data/dependencies/SDL/include/SDL3/SDL_begin_code.h +553 -0
- data/dependencies/SDL/include/{SDL_bits.h → SDL3/SDL_bits.h} +47 -27
- data/dependencies/SDL/include/{SDL_blendmode.h → SDL3/SDL_blendmode.h} +59 -55
- data/dependencies/SDL/include/SDL3/SDL_camera.h +535 -0
- data/dependencies/SDL/include/SDL3/SDL_clipboard.h +331 -0
- data/dependencies/SDL/include/{close_code.h → SDL3/SDL_close_code.h} +9 -8
- data/dependencies/SDL/include/{SDL_types.h → SDL3/SDL_copying.h} +2 -9
- data/dependencies/SDL/include/SDL3/SDL_cpuinfo.h +374 -0
- data/dependencies/SDL/include/SDL3/SDL_dialog.h +343 -0
- data/dependencies/SDL/include/SDL3/SDL_dlopennote.h +234 -0
- data/dependencies/SDL/include/{SDL_egl.h → SDL3/SDL_egl.h} +11 -8
- data/dependencies/SDL/include/SDL3/SDL_endian.h +645 -0
- data/dependencies/SDL/include/SDL3/SDL_error.h +226 -0
- data/dependencies/SDL/include/SDL3/SDL_events.h +1651 -0
- data/dependencies/SDL/include/SDL3/SDL_filesystem.h +537 -0
- data/dependencies/SDL/include/SDL3/SDL_gamepad.h +1657 -0
- data/dependencies/SDL/include/SDL3/SDL_gpu.h +4637 -0
- data/dependencies/SDL/include/SDL3/SDL_guid.h +106 -0
- data/dependencies/SDL/include/SDL3/SDL_haptic.h +1461 -0
- data/dependencies/SDL/include/SDL3/SDL_hidapi.h +571 -0
- data/dependencies/SDL/include/SDL3/SDL_hints.h +5041 -0
- data/dependencies/SDL/include/SDL3/SDL_init.h +508 -0
- data/dependencies/SDL/include/SDL3/SDL_intrin.h +410 -0
- data/dependencies/SDL/include/SDL3/SDL_iostream.h +1379 -0
- data/dependencies/SDL/include/SDL3/SDL_joystick.h +1385 -0
- data/dependencies/SDL/include/SDL3/SDL_keyboard.h +615 -0
- data/dependencies/SDL/include/SDL3/SDL_keycode.h +348 -0
- data/dependencies/SDL/include/SDL3/SDL_loadso.h +145 -0
- data/dependencies/SDL/include/{SDL_locale.h → SDL3/SDL_locale.h} +40 -24
- data/dependencies/SDL/include/SDL3/SDL_log.h +541 -0
- data/dependencies/SDL/include/SDL3/SDL_main.h +704 -0
- data/dependencies/SDL/include/SDL3/SDL_main_impl.h +149 -0
- data/dependencies/SDL/include/{SDL_messagebox.h → SDL3/SDL_messagebox.h} +85 -48
- data/dependencies/SDL/include/{SDL_metal.h → SDL3/SDL_metal.h} +29 -29
- data/dependencies/SDL/include/{SDL_misc.h → SDL3/SDL_misc.h} +13 -12
- data/dependencies/SDL/include/SDL3/SDL_mouse.h +813 -0
- data/dependencies/SDL/include/SDL3/SDL_mutex.h +1117 -0
- data/dependencies/SDL/include/SDL3/SDL_oldnames.h +1339 -0
- data/dependencies/SDL/include/{SDL_opengl.h → SDL3/SDL_opengl.h} +1247 -278
- data/dependencies/SDL/include/{SDL_opengl_glext.h → SDL3/SDL_opengl_glext.h} +5 -1
- data/dependencies/SDL/include/{SDL_opengles.h → SDL3/SDL_opengles.h} +6 -7
- data/dependencies/SDL/include/{SDL_opengles2.h → SDL3/SDL_opengles2.h} +10 -11
- data/dependencies/SDL/include/SDL3/SDL_pen.h +198 -0
- data/dependencies/SDL/include/SDL3/SDL_pixels.h +1441 -0
- data/dependencies/SDL/include/{SDL_test_log.h → SDL3/SDL_platform.h} +25 -26
- data/dependencies/SDL/include/SDL3/SDL_platform_defines.h +497 -0
- data/dependencies/SDL/include/{SDL_power.h → SDL3/SDL_power.h} +40 -20
- data/dependencies/SDL/include/SDL3/SDL_process.h +441 -0
- data/dependencies/SDL/include/SDL3/SDL_properties.h +572 -0
- data/dependencies/SDL/include/SDL3/SDL_rect.h +528 -0
- data/dependencies/SDL/include/SDL3/SDL_render.h +3034 -0
- data/dependencies/SDL/include/SDL3/SDL_revision.h +56 -0
- data/dependencies/SDL/include/{SDL_scancode.h → SDL3/SDL_scancode.h} +60 -68
- data/dependencies/SDL/include/SDL3/SDL_sensor.h +321 -0
- data/dependencies/SDL/include/SDL3/SDL_stdinc.h +6186 -0
- data/dependencies/SDL/include/SDL3/SDL_storage.h +686 -0
- data/dependencies/SDL/include/SDL3/SDL_surface.h +1769 -0
- data/dependencies/SDL/include/SDL3/SDL_system.h +840 -0
- data/dependencies/SDL/include/{SDL_test.h → SDL3/SDL_test.h} +16 -22
- data/dependencies/SDL/include/{SDL_test_assert.h → SDL3/SDL_test_assert.h} +27 -34
- data/dependencies/SDL/include/{SDL_test_common.h → SDL3/SDL_test_common.h} +109 -52
- data/dependencies/SDL/include/{SDL_test_compare.h → SDL3/SDL_test_compare.h} +22 -14
- data/dependencies/SDL/include/{SDL_test_crc32.h → SDL3/SDL_test_crc32.h} +27 -30
- data/dependencies/SDL/include/{SDL_test_font.h → SDL3/SDL_test_font.h} +50 -49
- data/dependencies/SDL/include/{SDL_test_fuzzer.h → SDL3/SDL_test_fuzzer.h} +64 -79
- data/dependencies/SDL/include/{SDL_test_harness.h → SDL3/SDL_test_harness.h} +47 -30
- data/dependencies/SDL/include/SDL3/SDL_test_log.h +83 -0
- data/dependencies/SDL/include/{SDL_test_md5.h → SDL3/SDL_test_md5.h} +21 -28
- data/dependencies/SDL/include/{SDL_test_memory.h → SDL3/SDL_test_memory.h} +19 -16
- data/dependencies/SDL/include/SDL3/SDL_thread.h +602 -0
- data/dependencies/SDL/include/SDL3/SDL_time.h +249 -0
- data/dependencies/SDL/include/SDL3/SDL_timer.h +454 -0
- data/dependencies/SDL/include/SDL3/SDL_touch.h +184 -0
- data/dependencies/SDL/include/SDL3/SDL_tray.h +544 -0
- data/dependencies/SDL/include/SDL3/SDL_version.h +198 -0
- data/dependencies/SDL/include/SDL3/SDL_video.h +3497 -0
- data/dependencies/SDL/include/SDL3/SDL_vulkan.h +287 -0
- data/dependencies/SDL/lib/x64/libSDL3.dll.a +0 -0
- data/dependencies/SDL/lib/x86/libSDL3.dll.a +0 -0
- data/dependencies/SDL_sound/SDL3_sound/SDL_sound.h +755 -0
- data/dependencies/SDL_sound/SDL_sound.c +136 -215
- data/dependencies/SDL_sound/SDL_sound_aiff.c +55 -54
- data/dependencies/SDL_sound/SDL_sound_au.c +32 -32
- data/dependencies/SDL_sound/SDL_sound_coreaudio.c +24 -41
- data/dependencies/SDL_sound/SDL_sound_flac.c +32 -12
- data/dependencies/SDL_sound/SDL_sound_internal.h +33 -48
- data/dependencies/SDL_sound/SDL_sound_modplug.c +21 -29
- data/dependencies/SDL_sound/SDL_sound_mp3.c +35 -13
- data/dependencies/SDL_sound/SDL_sound_raw.c +14 -15
- data/dependencies/SDL_sound/SDL_sound_shn.c +82 -82
- data/dependencies/SDL_sound/SDL_sound_voc.c +30 -30
- data/dependencies/SDL_sound/SDL_sound_vorbis.c +34 -25
- data/dependencies/SDL_sound/SDL_sound_wav.c +86 -82
- data/dependencies/SDL_sound/dr_flac.h +1890 -1301
- data/dependencies/SDL_sound/dr_mp3.h +1098 -660
- data/dependencies/SDL_sound/libmodplug/fastmix.c +1 -1
- data/dependencies/SDL_sound/libmodplug/libmodplug.h +5 -4
- data/dependencies/SDL_sound/libmodplug/load_ams.c +6 -3
- data/dependencies/SDL_sound/libmodplug/load_dsm.c +2 -1
- data/dependencies/SDL_sound/libmodplug/load_mt2.c +2 -2
- data/dependencies/SDL_sound/libmodplug/modplug.h +2 -1
- data/dependencies/SDL_sound/libmodplug/snd_fx.c +3 -3
- data/dependencies/SDL_sound/libmodplug/sndfile.c +3 -0
- data/dependencies/SDL_sound/libmodplug/sndmix.c +7 -3
- data/dependencies/SDL_sound/stb_vorbis.h +397 -342
- data/dependencies/mojoAL/AL/alc.h +2 -2
- data/dependencies/mojoAL/mojoal.c +2120 -1885
- data/dependencies/stb/stb_image.h +1190 -1379
- data/dependencies/stb/stb_image_write.h +329 -129
- data/dependencies/stb/stb_truetype.h +304 -60
- data/dependencies/utf8proc/utf8proc.c +133 -75
- data/dependencies/utf8proc/utf8proc.h +131 -50
- data/dependencies/utf8proc/utf8proc_data.h +16213 -15658
- data/ext/gosu-ffi/extconf.rb +103 -0
- data/ext/gosu-ffi/gosu-ffi.def +467 -0
- data/ffi/Gosu.cpp +330 -0
- data/ffi/Gosu.h +84 -0
- data/ffi/Gosu_Channel.cpp +62 -0
- data/ffi/Gosu_Channel.h +17 -0
- data/ffi/Gosu_Color.cpp +176 -0
- data/ffi/Gosu_Color.h +31 -0
- data/ffi/Gosu_Constants.cpp +334 -0
- data/ffi/Gosu_FFI.h +34 -0
- data/ffi/Gosu_FFI_internal.h +160 -0
- data/ffi/Gosu_Font.cpp +97 -0
- data/ffi/Gosu_Font.h +32 -0
- data/ffi/Gosu_Image.cpp +239 -0
- data/ffi/Gosu_Image.h +71 -0
- data/ffi/Gosu_Sample.cpp +29 -0
- data/ffi/Gosu_Sample.h +14 -0
- data/ffi/Gosu_Song.cpp +69 -0
- data/ffi/Gosu_Song.h +18 -0
- data/ffi/Gosu_TextInput.cpp +94 -0
- data/ffi/Gosu_TextInput.h +25 -0
- data/ffi/Gosu_Window.cpp +314 -0
- data/ffi/Gosu_Window.h +78 -0
- data/include/Gosu/Audio.hpp +6 -11
- data/include/Gosu/Bitmap.hpp +38 -53
- data/include/Gosu/Buffer.hpp +54 -0
- data/include/Gosu/Color.hpp +29 -36
- data/include/Gosu/Directories.hpp +25 -28
- data/include/Gosu/Drawable.hpp +58 -0
- data/include/Gosu/Font.hpp +6 -5
- data/include/Gosu/Fwd.hpp +4 -6
- data/include/Gosu/Gosu.hpp +5 -5
- data/include/Gosu/Graphics.hpp +53 -61
- data/include/Gosu/GraphicsBase.hpp +1 -11
- data/include/Gosu/Image.hpp +12 -15
- data/include/Gosu/Math.hpp +50 -72
- data/include/Gosu/Transform.hpp +32 -0
- data/include/Gosu/Utility.hpp +77 -1
- data/include/Gosu/Version.hpp +2 -2
- data/include/Gosu/Window.hpp +15 -9
- data/lib/SDL3.dll +0 -0
- data/lib/gosu/channel.rb +50 -0
- data/lib/gosu/color.rb +173 -0
- data/lib/gosu/compat.rb +130 -17
- data/lib/gosu/constants.rb +386 -0
- data/lib/gosu/ffi.rb +269 -0
- data/lib/gosu/font.rb +62 -0
- data/lib/gosu/gl_tex_info.rb +33 -0
- data/lib/gosu/gosu.rb +250 -0
- data/lib/gosu/image.rb +179 -0
- data/lib/gosu/numeric.rb +17 -0
- data/lib/gosu/preview.rb +6 -6
- data/lib/gosu/sample.rb +25 -0
- data/lib/gosu/song.rb +57 -0
- data/lib/gosu/text_input.rb +83 -0
- data/lib/gosu/window.rb +249 -0
- data/lib/gosu.rb +29 -8
- data/lib64/SDL3.dll +0 -0
- data/rdoc/gosu.rb +2 -2
- data/src/Audio.cpp +30 -24
- data/src/AudioFile.hpp +5 -4
- data/src/AudioFileAudioToolbox.cpp +8 -8
- data/src/AudioFileSDLSound.cpp +12 -15
- data/src/BinPacker.cpp +188 -0
- data/src/BinPacker.hpp +55 -0
- data/src/Bitmap.cpp +172 -143
- data/src/BitmapIO.cpp +60 -86
- data/src/Buffer.cpp +150 -0
- data/src/ClipRectStack.cpp +38 -0
- data/src/ClipRectStack.hpp +17 -83
- data/src/Color.cpp +75 -80
- data/src/Directories.cpp +47 -0
- data/src/DirectoriesUIKit.cpp +50 -0
- data/src/DrawOp.hpp +20 -18
- data/src/DrawOpQueue.hpp +27 -33
- data/src/Drawable.cpp +95 -0
- data/src/EmptyDrawable.hpp +38 -0
- data/src/FPS.cpp +31 -0
- data/src/Font.cpp +104 -74
- data/src/GosuGLView.cpp +13 -11
- data/src/GosuViewController.cpp +2 -10
- data/src/Graphics.cpp +86 -145
- data/src/GraphicsImpl.hpp +14 -68
- data/src/Image.cpp +41 -35
- data/src/Input.cpp +73 -78
- data/src/Macro.cpp +46 -29
- data/src/Macro.hpp +23 -17
- data/src/MarkupParser.cpp +5 -5
- data/src/Math.cpp +48 -22
- data/src/OffScreenTarget.cpp +47 -50
- data/src/OffScreenTarget.hpp +13 -11
- data/src/OpenGLContext.cpp +116 -0
- data/src/OpenGLContext.hpp +41 -0
- data/src/RenderState.hpp +49 -71
- data/src/Resolution.cpp +65 -53
- data/src/TexChunk.cpp +35 -80
- data/src/TexChunk.hpp +44 -35
- data/src/Text.cpp +1 -1
- data/src/TextBuilder.cpp +35 -21
- data/src/TextBuilder.hpp +6 -9
- data/src/TextInput.cpp +9 -9
- data/src/Texture.cpp +62 -80
- data/src/Texture.hpp +25 -23
- data/src/TiledDrawable.cpp +149 -0
- data/src/TiledDrawable.hpp +47 -0
- data/src/TimingApple.cpp +1 -1
- data/src/Transform.cpp +45 -50
- data/src/TransformStack.hpp +16 -16
- data/src/TrueTypeFont.cpp +59 -51
- data/src/TrueTypeFont.hpp +6 -7
- data/src/TrueTypeFontApple.cpp +28 -19
- data/src/TrueTypeFontUnix.cpp +39 -32
- data/src/TrueTypeFontWin.cpp +30 -30
- data/src/Utility.cpp +113 -37
- data/src/UtilityWin.cpp +49 -0
- data/src/Window.cpp +121 -151
- data/src/WindowUIKit.cpp +14 -14
- metadata +165 -118
- data/dependencies/SDL/include/SDL.h +0 -233
- data/dependencies/SDL/include/SDL_assert.h +0 -320
- data/dependencies/SDL/include/SDL_atomic.h +0 -415
- data/dependencies/SDL/include/SDL_audio.h +0 -1500
- data/dependencies/SDL/include/SDL_clipboard.h +0 -141
- data/dependencies/SDL/include/SDL_config.h +0 -331
- data/dependencies/SDL/include/SDL_cpuinfo.h +0 -594
- data/dependencies/SDL/include/SDL_endian.h +0 -348
- data/dependencies/SDL/include/SDL_error.h +0 -163
- data/dependencies/SDL/include/SDL_events.h +0 -1166
- data/dependencies/SDL/include/SDL_filesystem.h +0 -149
- data/dependencies/SDL/include/SDL_gamecontroller.h +0 -1074
- data/dependencies/SDL/include/SDL_gesture.h +0 -117
- data/dependencies/SDL/include/SDL_guid.h +0 -100
- data/dependencies/SDL/include/SDL_haptic.h +0 -1341
- data/dependencies/SDL/include/SDL_hidapi.h +0 -451
- data/dependencies/SDL/include/SDL_hints.h +0 -2569
- data/dependencies/SDL/include/SDL_joystick.h +0 -1066
- data/dependencies/SDL/include/SDL_keyboard.h +0 -353
- data/dependencies/SDL/include/SDL_keycode.h +0 -358
- data/dependencies/SDL/include/SDL_loadso.h +0 -115
- data/dependencies/SDL/include/SDL_log.h +0 -404
- data/dependencies/SDL/include/SDL_main.h +0 -275
- data/dependencies/SDL/include/SDL_mouse.h +0 -465
- data/dependencies/SDL/include/SDL_mutex.h +0 -471
- data/dependencies/SDL/include/SDL_name.h +0 -33
- data/dependencies/SDL/include/SDL_pixels.h +0 -644
- data/dependencies/SDL/include/SDL_platform.h +0 -261
- data/dependencies/SDL/include/SDL_quit.h +0 -58
- data/dependencies/SDL/include/SDL_rect.h +0 -376
- data/dependencies/SDL/include/SDL_render.h +0 -1919
- data/dependencies/SDL/include/SDL_revision.h +0 -7
- data/dependencies/SDL/include/SDL_rwops.h +0 -841
- data/dependencies/SDL/include/SDL_sensor.h +0 -322
- data/dependencies/SDL/include/SDL_shape.h +0 -155
- data/dependencies/SDL/include/SDL_stdinc.h +0 -830
- data/dependencies/SDL/include/SDL_surface.h +0 -997
- data/dependencies/SDL/include/SDL_system.h +0 -623
- data/dependencies/SDL/include/SDL_syswm.h +0 -386
- data/dependencies/SDL/include/SDL_test_images.h +0 -78
- data/dependencies/SDL/include/SDL_test_random.h +0 -115
- data/dependencies/SDL/include/SDL_thread.h +0 -464
- data/dependencies/SDL/include/SDL_timer.h +0 -222
- data/dependencies/SDL/include/SDL_touch.h +0 -150
- data/dependencies/SDL/include/SDL_version.h +0 -204
- data/dependencies/SDL/include/SDL_video.h +0 -2150
- data/dependencies/SDL/include/SDL_vulkan.h +0 -215
- data/dependencies/SDL/include/begin_code.h +0 -187
- data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
- data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
- data/dependencies/SDL_sound/SDL_sound.h +0 -725
- data/ext/gosu/extconf.rb +0 -119
- data/include/Gosu/IO.hpp +0 -254
- data/include/Gosu/ImageData.hpp +0 -53
- data/include/Gosu/Inspection.hpp +0 -7
- data/lib/SDL2.dll +0 -0
- data/lib/gosu/patches.rb +0 -66
- data/lib/gosu/run.rb +0 -20
- data/lib/gosu/swig_patches.rb +0 -110
- data/lib64/SDL2.dll +0 -0
- data/src/BlockAllocator.cpp +0 -131
- data/src/BlockAllocator.hpp +0 -32
- data/src/DirectoriesApple.cpp +0 -69
- data/src/DirectoriesUnix.cpp +0 -46
- data/src/DirectoriesWin.cpp +0 -65
- data/src/EmptyImageData.hpp +0 -52
- data/src/FileUnix.cpp +0 -99
- data/src/FileWin.cpp +0 -88
- data/src/IO.cpp +0 -60
- data/src/Iconv.hpp +0 -51
- data/src/Inspection.cpp +0 -27
- data/src/LargeImageData.cpp +0 -215
- data/src/LargeImageData.hpp +0 -39
- data/src/Log.hpp +0 -19
- data/src/RubyGosu.cxx +0 -13100
- data/src/RubyGosu.h +0 -49
- data/src/WinUtility.cpp +0 -61
- data/src/WinUtility.hpp +0 -27
- /data/dependencies/SDL/include/{SDL_opengles2_gl2.h → SDL3/SDL_opengles2_gl2.h} +0 -0
- /data/dependencies/SDL/include/{SDL_opengles2_gl2ext.h → SDL3/SDL_opengles2_gl2ext.h} +0 -0
- /data/dependencies/SDL/include/{SDL_opengles2_gl2platform.h → SDL3/SDL_opengles2_gl2platform.h} +0 -0
- /data/dependencies/SDL/include/{SDL_opengles2_khrplatform.h → SDL3/SDL_opengles2_khrplatform.h} +0 -0
data/include/Gosu/Math.hpp
CHANGED
|
@@ -1,96 +1,74 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
-
#include <
|
|
4
|
-
|
|
5
|
-
// Portability: Define M_PI, which MSVC's <cmath> does not do by default.
|
|
6
|
-
#if !defined(M_PI) && !defined(SWIG)
|
|
7
|
-
#define M_PI 3.14159265358979323846264338327950288
|
|
8
|
-
#endif
|
|
3
|
+
#include <numbers>
|
|
9
4
|
|
|
10
5
|
namespace Gosu
|
|
11
6
|
{
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
/// Returns a double value between min (inclusive) and max (exclusive).
|
|
8
|
+
/// This function returns random values based on a uniform distribution.
|
|
9
|
+
/// @throw std::invalid_argument if min >= max
|
|
14
10
|
double random(double min, double max);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
inline double
|
|
11
|
+
|
|
12
|
+
/// Translates between 360° degrees (as used by Gosu) and radians, but does not change the
|
|
13
|
+
/// origin from the top to the right.
|
|
14
|
+
inline double degrees_to_radians(double angle)
|
|
19
15
|
{
|
|
20
|
-
return
|
|
16
|
+
return angle * std::numbers::pi / 180;
|
|
21
17
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
|
|
19
|
+
/// Translates between 360° degrees (as used by Gosu) and radians, but does not change the
|
|
20
|
+
/// origin from the right to the top.
|
|
21
|
+
inline double radians_to_degrees(double angle)
|
|
25
22
|
{
|
|
26
|
-
return angle * 180 /
|
|
23
|
+
return angle * 180 / std::numbers::pi;
|
|
27
24
|
}
|
|
28
25
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
inline double
|
|
26
|
+
/// Translates between Gosu's 360° angle system, where 0 is at the top, and radians, where 0 is
|
|
27
|
+
/// to the right.
|
|
28
|
+
inline double radians_to_angle(double angle)
|
|
32
29
|
{
|
|
33
|
-
return angle
|
|
30
|
+
return radians_to_degrees(angle) + 90;
|
|
34
31
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
|
|
33
|
+
/// Translates between Gosu's 360° angle system, where 0 is at the top, and radians, where 0 is
|
|
34
|
+
/// to the right.
|
|
35
|
+
inline double angle_to_radians(double angle)
|
|
38
36
|
{
|
|
39
|
-
return angle
|
|
37
|
+
return degrees_to_radians(angle - 90);
|
|
40
38
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
|
|
40
|
+
/// Returns the horizontal distance between the origin and the point to
|
|
41
|
+
/// which you would get if you moved radius pixels in the direction
|
|
42
|
+
/// specified by angle.
|
|
43
|
+
/// @param angle Angle in degrees where 0.0 means upwards.
|
|
46
44
|
double offset_x(double angle, double radius);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
|
|
46
|
+
/// Returns the vertical distance between the origin and the point to
|
|
47
|
+
/// which you would get if you moved radius pixels in the direction
|
|
48
|
+
/// specified by angle.
|
|
49
|
+
/// @param angle Angle in degrees where 0.0 means upwards.
|
|
51
50
|
double offset_y(double angle, double radius);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
|
|
52
|
+
/// Returns the angle from the first point to the second point in degrees, where 0.0 points up.
|
|
53
|
+
/// Returns "fallback" if both points are equal.
|
|
54
|
+
double angle(double from_x, double from_y, double to_x, double to_y, double fallback = 0);
|
|
55
|
+
|
|
56
|
+
/// Returns the smallest angle that can be added to angle1 to get to angle2.
|
|
57
|
+
/// The result can be negative if counter-clockwise movement is shorter.
|
|
57
58
|
double angle_diff(double angle1, double angle2);
|
|
58
|
-
|
|
59
|
+
|
|
60
|
+
/// Normalizes an angle to fit into the range [0; 360[.
|
|
59
61
|
double normalize_angle(double angle);
|
|
60
|
-
|
|
61
|
-
//! Returns value * value.
|
|
62
|
-
template<typename T>
|
|
63
|
-
T square(T value)
|
|
64
|
-
{
|
|
65
|
-
return value * value;
|
|
66
|
-
}
|
|
67
62
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
/// Returns (value-min) % (max-min) + min, where % always has a positive
|
|
64
|
+
/// result for max > min. This means that max is exclusive.
|
|
65
|
+
/// @throw std::invalid_argument if min >= max
|
|
71
66
|
int wrap(int value, int min, int max);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
float wrap(float value, float min, float max);
|
|
76
|
-
//! Returns (value-min) % (max-min) + min, where % always has a positive
|
|
77
|
-
//! result for max > min. The results are undefined for max <= min.
|
|
78
|
-
//! Note: This means that max is exclusive.
|
|
67
|
+
/// Returns (value-min) % (max-min) + min, where % always has a positive
|
|
68
|
+
/// result for max > min. This means that max is exclusive.
|
|
69
|
+
/// @throw std::invalid_argument if min >= max
|
|
79
70
|
double wrap(double value, double min, double max);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
inline double distance_sqr(double x1, double y1, double x2, double y2)
|
|
83
|
-
{
|
|
84
|
-
return square(x1 - x2) + square(y1 - y2);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
//! Returns the distance between two points.
|
|
71
|
+
|
|
72
|
+
/// Returns the distance between two points.
|
|
88
73
|
double distance(double x1, double y1, double x2, double y2);
|
|
89
|
-
|
|
90
|
-
//! Placeholder for std::lerp, will be removed when Gosu requires C++20.
|
|
91
|
-
template<typename T>
|
|
92
|
-
T lerp(T a, T b, double t = 0.5)
|
|
93
|
-
{
|
|
94
|
-
return a * (1.0 - t) + b * t;
|
|
95
|
-
}
|
|
96
74
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <array>
|
|
4
|
+
|
|
5
|
+
namespace Gosu
|
|
6
|
+
{
|
|
7
|
+
/// Describes an affine transformation that can be temporarily applied to everything on the
|
|
8
|
+
/// screen using the Gosu::Graphics::transform() method.
|
|
9
|
+
struct Transform
|
|
10
|
+
{
|
|
11
|
+
/// The 4x4 transformation matrix in row-major order: matrix[row * 4 + column].
|
|
12
|
+
std::array<double, 16> matrix;
|
|
13
|
+
|
|
14
|
+
/// Applies this transform to the given point.
|
|
15
|
+
void apply(double& x, double& y) const;
|
|
16
|
+
|
|
17
|
+
[[nodiscard]] static Transform translate(double x, double y);
|
|
18
|
+
[[nodiscard]] static Transform rotate(double angle);
|
|
19
|
+
[[nodiscard]] static Transform scale(double factor);
|
|
20
|
+
[[nodiscard]] static Transform scale(double scale_x, double scale_y);
|
|
21
|
+
/// This helper is supposed to be used on the return value of rotate() or scale() in order
|
|
22
|
+
/// to set the center around which to rotate/scale. It will not have any effect on the
|
|
23
|
+
/// return value of translate().
|
|
24
|
+
[[nodiscard]] Transform around(double around_x, double around_y) const;
|
|
25
|
+
|
|
26
|
+
/// Performs a matrix multiplication that has the effect of "concatenating" transforms.
|
|
27
|
+
/// The left-hand side will be applied to a point before the right-hand side.
|
|
28
|
+
Transform operator*(const Transform& rhs) const;
|
|
29
|
+
|
|
30
|
+
bool operator==(const Transform&) const = default;
|
|
31
|
+
};
|
|
32
|
+
}
|
data/include/Gosu/Utility.hpp
CHANGED
|
@@ -1,14 +1,33 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
+
#include <Gosu/Platform.hpp>
|
|
4
|
+
#include <functional>
|
|
3
5
|
#include <string>
|
|
6
|
+
#include <string_view>
|
|
4
7
|
#include <vector>
|
|
5
8
|
|
|
6
9
|
namespace Gosu
|
|
7
10
|
{
|
|
8
|
-
|
|
11
|
+
/// Converts a UTF-8 string to composed UTC-4, i.e. to a list of Unicode codepoints.
|
|
12
|
+
///
|
|
13
|
+
/// This is not quite as good as splitting a string into graphemes. For example, the "family of
|
|
14
|
+
/// four" Emoji is actually composed of seven(!) codepoints. But because Gosu's text rendering
|
|
15
|
+
/// facilities have no support for multi-codepoint graphemes, Gosu::Font and related classes are
|
|
16
|
+
/// based on codepoints.
|
|
17
|
+
///
|
|
18
|
+
/// This method will silently skip over invalid UTF-8 sequences.
|
|
19
|
+
std::u32string utf8_to_composed_utc4(std::string_view utf8);
|
|
20
|
+
|
|
21
|
+
#ifdef GOSU_IS_WIN
|
|
22
|
+
/// Converts UTF-8 to UTF-16, as it is used in "UNICODE" Windows APIs.
|
|
23
|
+
std::wstring utf8_to_utf16(const std::string& utf8);
|
|
24
|
+
/// Converts UTF-16 to UTF-8.
|
|
25
|
+
std::string utf16_to_utf8(const std::wstring& utf16);
|
|
26
|
+
#endif
|
|
9
27
|
|
|
10
28
|
/// Returns true if the filename has the given extension.
|
|
11
29
|
/// The comparison is case-insensitive, but you must pass the extension in lower case.
|
|
30
|
+
/// If the extension does not start with a dot, then it will be implied.
|
|
12
31
|
bool has_extension(std::string_view filename, std::string_view extension);
|
|
13
32
|
|
|
14
33
|
/// Returns the user's preferred user_languages/locales, e.g. {"en_US", "de_DE", "ja"}.
|
|
@@ -17,6 +36,25 @@ namespace Gosu
|
|
|
17
36
|
/// typically the first language in the returned array that your game supports.
|
|
18
37
|
std::vector<std::string> user_languages();
|
|
19
38
|
|
|
39
|
+
class [[nodiscard]] Cleanup
|
|
40
|
+
{
|
|
41
|
+
std::function<void()> m_action;
|
|
42
|
+
|
|
43
|
+
public:
|
|
44
|
+
explicit Cleanup(std::function<void()> action);
|
|
45
|
+
~Cleanup();
|
|
46
|
+
// Move-constructible, but not copyable or assignable.
|
|
47
|
+
Cleanup(Cleanup&&) noexcept;
|
|
48
|
+
Cleanup(const Cleanup&) = delete;
|
|
49
|
+
Cleanup& operator=(const Cleanup&) = delete;
|
|
50
|
+
Cleanup& operator=(Cleanup&&) = delete;
|
|
51
|
+
|
|
52
|
+
void perform();
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
Cleanup finally(std::function<void()> action);
|
|
56
|
+
|
|
57
|
+
/// Base class to quickly make a type non-copyable/non-movable. Same as boost::noncopyable.
|
|
20
58
|
class Noncopyable
|
|
21
59
|
{
|
|
22
60
|
protected:
|
|
@@ -30,4 +68,42 @@ namespace Gosu
|
|
|
30
68
|
Noncopyable(Noncopyable&& other) = delete;
|
|
31
69
|
Noncopyable& operator=(Noncopyable&& other) = delete;
|
|
32
70
|
};
|
|
71
|
+
|
|
72
|
+
/// An int-based rectangle class, mostly for internal use.
|
|
73
|
+
struct Rect
|
|
74
|
+
{
|
|
75
|
+
int x = 0, y = 0;
|
|
76
|
+
int width = 0, height = 0;
|
|
77
|
+
|
|
78
|
+
int right() const { return x + width; }
|
|
79
|
+
int bottom() const { return y + height; }
|
|
80
|
+
|
|
81
|
+
bool empty() const { return width <= 0 || height <= 0; }
|
|
82
|
+
|
|
83
|
+
/// A little factory helper to make it clear that we are passing "width" and "height",
|
|
84
|
+
/// not "right" and "bottom".
|
|
85
|
+
static Rect xywh(int x, int y, int width, int height)
|
|
86
|
+
{
|
|
87
|
+
return Rect { .x = x, .y = y, .width = width, .height = height };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/// Returns a Rect that starts at the origin and uses T::width() and T::height() as its
|
|
91
|
+
/// extents.
|
|
92
|
+
template <typename T> static Rect covering(const T& object)
|
|
93
|
+
{
|
|
94
|
+
return Rect { .x = 0, .y = 0, .width = object.width(), .height = object.height() };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
bool overlaps(const Rect& other) const;
|
|
98
|
+
bool contains(const Rect& other) const;
|
|
99
|
+
|
|
100
|
+
/// Makes sure that this rectangle does not exceed the bounding box.
|
|
101
|
+
/// @param adjust_x If the rectangle origin will be moved to the right by this operation,
|
|
102
|
+
/// then the pointed-to int (if any) will be adjusted by the same amount.
|
|
103
|
+
/// @param adjust_y If the rectangle origin will be moved down by this operation,
|
|
104
|
+
/// then the pointed-to int (if any) will be adjusted by the same amount.
|
|
105
|
+
void clip_to(const Rect& bounding_box, int* adjust_x = nullptr, int* adjust_y = nullptr);
|
|
106
|
+
|
|
107
|
+
bool operator==(const Rect&) const = default;
|
|
108
|
+
};
|
|
33
109
|
}
|
data/include/Gosu/Version.hpp
CHANGED
data/include/Gosu/Window.hpp
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
#include <memory>
|
|
8
8
|
#include <string>
|
|
9
9
|
|
|
10
|
+
struct SDL_Window;
|
|
11
|
+
|
|
10
12
|
namespace Gosu
|
|
11
13
|
{
|
|
12
14
|
enum WindowFlags
|
|
@@ -124,45 +126,49 @@ namespace Gosu
|
|
|
124
126
|
/// method will be called several times.
|
|
125
127
|
virtual void drop(const std::string& filename) {}
|
|
126
128
|
|
|
127
|
-
// Ignore when SWIG is wrapping this class for Ruby/Gosu.
|
|
128
|
-
#ifndef SWIG
|
|
129
129
|
// Callbacks for touch events. So far these are only used on iOS.
|
|
130
130
|
virtual void touch_began(Touch touch) {}
|
|
131
131
|
virtual void touch_moved(Touch touch) {}
|
|
132
132
|
virtual void touch_ended(Touch touch) {}
|
|
133
133
|
virtual void touch_cancelled(Touch touch) {}
|
|
134
134
|
|
|
135
|
-
const
|
|
136
|
-
|
|
135
|
+
const Viewport& viewport() const;
|
|
136
|
+
Viewport& viewport();
|
|
137
137
|
|
|
138
138
|
const Input& input() const;
|
|
139
139
|
Input& input();
|
|
140
|
-
#endif
|
|
141
140
|
|
|
142
141
|
#ifdef GOSU_IS_IPHONE
|
|
143
142
|
void* uikit_window() const;
|
|
144
143
|
#endif
|
|
144
|
+
|
|
145
|
+
#ifndef GOSU_IS_IPHONE
|
|
146
|
+
SDL_Window* sdl_window() const;
|
|
147
|
+
#endif
|
|
145
148
|
};
|
|
146
149
|
|
|
150
|
+
/// Returns the current framerate.
|
|
151
|
+
int fps();
|
|
152
|
+
|
|
147
153
|
/// Returns the width (in pixels) of a screen.
|
|
148
154
|
/// @param window The result describes the screen on which the window is shown, or the
|
|
149
155
|
/// primary screen if no window is given.
|
|
150
|
-
int screen_width(Window* window = nullptr);
|
|
156
|
+
int screen_width(const Window* window = nullptr);
|
|
151
157
|
|
|
152
158
|
/// Returns the height (in pixels) of the user's primary screen.
|
|
153
159
|
/// @param window The result describes the screen on which the window is shown, or the
|
|
154
160
|
/// primary screen if no window is given.
|
|
155
|
-
int screen_height(Window* window = nullptr);
|
|
161
|
+
int screen_height(const Window* window = nullptr);
|
|
156
162
|
|
|
157
163
|
/// Returns the maximum width (in 'points') that is available for a non-fullscreen Window.
|
|
158
164
|
/// All windows larger than this size will automatically be shrunk to fit.
|
|
159
165
|
/// @param window The result describes the screen on which the window is shown, or the
|
|
160
166
|
/// primary screen if no window is given.
|
|
161
|
-
int available_width(Window* window = nullptr);
|
|
167
|
+
int available_width(const Window* window = nullptr);
|
|
162
168
|
|
|
163
169
|
/// Returns the maximum height (in 'points') that is available for a non-fullscreen Window.
|
|
164
170
|
/// All windows larger than this size will automatically be shrunk to fit.
|
|
165
171
|
/// @param window The result describes the screen on which the window is shown, or the
|
|
166
172
|
/// primary screen if no window is given.
|
|
167
|
-
int available_height(Window* window = nullptr);
|
|
173
|
+
int available_height(const Window* window = nullptr);
|
|
168
174
|
}
|
data/lib/SDL3.dll
ADDED
|
Binary file
|
data/lib/gosu/channel.rb
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
module Gosu
|
|
2
|
+
class Channel
|
|
3
|
+
def initialize(pointer)
|
|
4
|
+
@managed_pointer = FFI::AutoPointer.new(pointer, GosuFFI.method(:Gosu_Channel_destroy))
|
|
5
|
+
self
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def __pointer
|
|
9
|
+
@managed_pointer
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def playing?
|
|
13
|
+
GosuFFI.check_last_error(GosuFFI.Gosu_Channel_playing(__pointer))
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def pause
|
|
17
|
+
GosuFFI.Gosu_Channel_pause(__pointer)
|
|
18
|
+
GosuFFI.check_last_error
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def paused?
|
|
22
|
+
GosuFFI.check_last_error(GosuFFI.Gosu_Channel_paused(__pointer))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def resume
|
|
26
|
+
GosuFFI.Gosu_Channel_resume(__pointer)
|
|
27
|
+
GosuFFI.check_last_error
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def stop
|
|
31
|
+
GosuFFI.Gosu_Channel_stop(__pointer)
|
|
32
|
+
GosuFFI.check_last_error
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def volume=(double)
|
|
36
|
+
GosuFFI.Gosu_Channel_set_volume(__pointer, double)
|
|
37
|
+
GosuFFI.check_last_error
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def speed=(double)
|
|
41
|
+
GosuFFI.Gosu_Channel_set_speed(__pointer, double)
|
|
42
|
+
GosuFFI.check_last_error
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def pan=(double)
|
|
46
|
+
GosuFFI.Gosu_Channel_set_pan(__pointer, double)
|
|
47
|
+
GosuFFI.check_last_error
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
data/lib/gosu/color.rb
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
module Gosu
|
|
2
|
+
class Color
|
|
3
|
+
include Comparable
|
|
4
|
+
|
|
5
|
+
# Gosu::Color is stored as an unsigned int in C
|
|
6
|
+
# this is used for {Gosu::Image#to_blob} and {Gosu::Image.from_blob}
|
|
7
|
+
SIZEOF = 4
|
|
8
|
+
|
|
9
|
+
# The OpenGL texture format (always GL_RGBA) of {Gosu::Image#to_blob} and {Gosu::Image.from_blob}.
|
|
10
|
+
GL_FORMAT = 0x1908
|
|
11
|
+
|
|
12
|
+
def self.argb(*args)
|
|
13
|
+
Gosu::Color.new(*args)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.rgba(*args)
|
|
17
|
+
case args.size
|
|
18
|
+
when 1
|
|
19
|
+
rgba = args.first
|
|
20
|
+
alpha = (rgba & 0xff) << 24
|
|
21
|
+
rgb = (rgba >> 8) & 0xff_ffff
|
|
22
|
+
Gosu::Color.new(alpha | rgb)
|
|
23
|
+
when 4
|
|
24
|
+
r, g, b, a = args
|
|
25
|
+
Gosu::Color.new(a, r, g, b)
|
|
26
|
+
else
|
|
27
|
+
raise ArgumentError
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.rgb(r, g, b)
|
|
32
|
+
Gosu::Color.new(255, r, g, b)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.from_ahsv(alpha, h, s, v)
|
|
36
|
+
__color = GosuFFI.Gosu_Color_create_from_ahsv(alpha.clamp(0.0, 255.0), h % 360.0, s.clamp(0.0, 1.0), v.clamp(0.0, 1.0))
|
|
37
|
+
GosuFFI.check_last_error
|
|
38
|
+
Gosu::Color.new(__color)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.from_hsv(h, s, v)
|
|
42
|
+
__color = GosuFFI.Gosu_Color_create_from_hsv(h % 360.0, s.clamp(0.0, 1.0), v.clamp(0.0, 1.0))
|
|
43
|
+
GosuFFI.check_last_error
|
|
44
|
+
Gosu::Color.new(__color)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def initialize(*args)
|
|
48
|
+
case args.size
|
|
49
|
+
when 1
|
|
50
|
+
@__color = GosuFFI.Gosu_Color_create(args.first)
|
|
51
|
+
GosuFFI.check_last_error
|
|
52
|
+
when 4
|
|
53
|
+
@__color = GosuFFI.Gosu_Color_create_argb(args[0].clamp(0, 255), args[1].clamp(0, 255), args[2].clamp(0, 255), args[3].clamp(0, 255))
|
|
54
|
+
GosuFFI.check_last_error
|
|
55
|
+
else
|
|
56
|
+
raise ArgumentError
|
|
57
|
+
end
|
|
58
|
+
self
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def alpha
|
|
62
|
+
GosuFFI.check_last_error(GosuFFI.Gosu_Color_alpha(@__color))
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def alpha=(value)
|
|
66
|
+
@__color = GosuFFI.check_last_error(GosuFFI.Gosu_Color_set_alpha(@__color, value.clamp(0, 255)))
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def red
|
|
70
|
+
GosuFFI.check_last_error(GosuFFI.Gosu_Color_red(@__color))
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def red=(value)
|
|
74
|
+
@__color = GosuFFI.check_last_error(GosuFFI.Gosu_Color_set_red(@__color, value.clamp(0, 255)))
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def green
|
|
78
|
+
GosuFFI.check_last_error(GosuFFI.Gosu_Color_green(@__color))
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def green=(value)
|
|
82
|
+
@__color = GosuFFI.check_last_error(GosuFFI.Gosu_Color_set_green(@__color, value.clamp(0, 255)))
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def blue
|
|
86
|
+
GosuFFI.check_last_error(GosuFFI.Gosu_Color_blue(@__color))
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def blue=(value)
|
|
90
|
+
@__color = GosuFFI.check_last_error(GosuFFI.Gosu_Color_set_blue(@__color, value.clamp(0, 255)))
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def value
|
|
94
|
+
GosuFFI.check_last_error(GosuFFI.Gosu_Color_value(@__color))
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def value=(value)
|
|
98
|
+
@__color = GosuFFI.check_last_error(GosuFFI.Gosu_Color_set_value(@__color, value.clamp(0.0, 1.0)))
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def saturation
|
|
102
|
+
GosuFFI.check_last_error(GosuFFI.Gosu_Color_saturation(@__color))
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def saturation=(value)
|
|
106
|
+
@__color = GosuFFI.check_last_error(GosuFFI.Gosu_Color_set_saturation(@__color, value.clamp(0.0, 1.0)))
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def hue
|
|
110
|
+
GosuFFI.check_last_error(GosuFFI.Gosu_Color_hue(@__color))
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def hue=(value)
|
|
114
|
+
@__color = GosuFFI.check_last_error(GosuFFI.Gosu_Color_set_hue(@__color, value % 360.0))
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def bgr
|
|
118
|
+
GosuFFI.check_last_error(GosuFFI.Gosu_Color_bgr(@__color))
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def abgr
|
|
122
|
+
GosuFFI.check_last_error(GosuFFI.Gosu_Color_abgr(@__color))
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def argb
|
|
126
|
+
GosuFFI.check_last_error(GosuFFI.Gosu_Color_argb(@__color))
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def with_alpha(alpha)
|
|
130
|
+
color = dup
|
|
131
|
+
color.alpha = alpha
|
|
132
|
+
color
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def gl
|
|
136
|
+
@__color
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def to_i
|
|
140
|
+
@__color
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def <=>(other)
|
|
144
|
+
if other.is_a? Color
|
|
145
|
+
to_i <=> other.to_i
|
|
146
|
+
elsif other.is_a? Numeric
|
|
147
|
+
to_i <=> other
|
|
148
|
+
else
|
|
149
|
+
nil
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
alias hash gl
|
|
154
|
+
|
|
155
|
+
def eql?(other)
|
|
156
|
+
self == other
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# Frozen so that e.g. Color::RED.alpha = 128 cannot change the constant globally.
|
|
160
|
+
# (Gosu 1.x and older used a separate class, ImmutableColor, for the same purpose.)
|
|
161
|
+
NONE = Gosu::Color.argb(0x00_000000).freeze
|
|
162
|
+
BLACK = Gosu::Color.argb(0xff_000000).freeze
|
|
163
|
+
GRAY = Gosu::Color.argb(0xff_808080).freeze
|
|
164
|
+
WHITE = Gosu::Color.argb(0xff_ffffff).freeze
|
|
165
|
+
AQUA = Gosu::Color.argb(0xff_00ffff).freeze
|
|
166
|
+
RED = Gosu::Color.argb(0xff_ff0000).freeze
|
|
167
|
+
GREEN = Gosu::Color.argb(0xff_00ff00).freeze
|
|
168
|
+
BLUE = Gosu::Color.argb(0xff_0000ff).freeze
|
|
169
|
+
YELLOW = Gosu::Color.argb(0xff_ffff00).freeze
|
|
170
|
+
FUCHSIA = Gosu::Color.argb(0xff_ff00ff).freeze
|
|
171
|
+
CYAN = Gosu::Color.argb(0xff_00ffff).freeze
|
|
172
|
+
end
|
|
173
|
+
end
|