Overview
Comment: | Add methods for drawing rotated. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
8577d195c49ede3274ad28c1a972122d |
User & Date: | js on 2012-08-28 19:48:53 |
Other Links: | manifest | tags |
Context
2012-08-28
| ||
20:00 | Add OGKCharacterTypedEvent. check-in: 1f8de6b2e2 user: js tags: trunk | |
19:48 | Add methods for drawing rotated. check-in: 8577d195c4 user: js tags: trunk | |
19:43 | Make scale relative instead of absolute. check-in: e3b3bcfe20 user: js tags: trunk | |
Changes
Modified src/OGKBitmap.h from [a481d3b08b] to [56964e67d2].
︙ | ︙ | |||
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #include <allegro5/allegro.h> #import <ObjFW/ObjFW.h> typedef struct ogk_color_t { float red, green, blue, alpha; } ogk_color_t; static OF_INLINE ogk_color_t ogk_color(float red, float green, float blue, float alpha) { ogk_color_t color = { red, green, blue, alpha}; return color; } extern ogk_color_t OGK_COLOR_BLACK; @interface OGKBitmap: OFObject { ALLEGRO_BITMAP *bitmap; } | > > > > > > > > > > > > > | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | #include <allegro5/allegro.h> #import <ObjFW/ObjFW.h> typedef struct ogk_color_t { float red, green, blue, alpha; } ogk_color_t; typedef struct ogk_rotation_t { of_point_t center; float angle; } ogk_rotation_t; static OF_INLINE ogk_color_t ogk_color(float red, float green, float blue, float alpha) { ogk_color_t color = { red, green, blue, alpha}; return color; } static OF_INLINE ogk_rotation_t ogk_rotation(float x, float y, float angle) { ogk_rotation_t rotation = { of_point(x, y), angle }; return rotation; } extern ogk_color_t OGK_COLOR_BLACK; @interface OGKBitmap: OFObject { ALLEGRO_BITMAP *bitmap; } |
︙ | ︙ | |||
63 64 65 66 67 68 69 70 71 72 | tint: (ogk_color_t)tint; - (void)drawAtPosition: (of_point_t)position region: (of_rectangle_t)region tint: (ogk_color_t)tint; - (void)drawAtPosition: (of_point_t)position region: (of_rectangle_t)region scale: (of_dimension_t)scale tint: (ogk_color_t)tint; - (ALLEGRO_BITMAP*)OGK_allegroBitmap; @end | > > > > > > > > > > > > | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | tint: (ogk_color_t)tint; - (void)drawAtPosition: (of_point_t)position region: (of_rectangle_t)region tint: (ogk_color_t)tint; - (void)drawAtPosition: (of_point_t)position region: (of_rectangle_t)region scale: (of_dimension_t)scale tint: (ogk_color_t)tint; - (void)drawAtPosition: (of_point_t)position rotation: (ogk_rotation_t)rotation; - (void)drawAtPosition: (of_point_t)position scale: (of_dimension_t)scale rotation: (ogk_rotation_t)rotation; - (void)drawAtPosition: (of_point_t)position rotation: (ogk_rotation_t)rotation tint: (ogk_color_t)tint; - (void)drawAtPosition: (of_point_t)position scale: (of_dimension_t)scale rotation: (ogk_rotation_t)rotation tint: (ogk_color_t)tint; - (ALLEGRO_BITMAP*)OGK_allegroBitmap; @end |
Modified src/OGKBitmap.m from [4f0798e904] to [fe85b4a420].
︙ | ︙ | |||
186 187 188 189 190 191 192 193 194 195 196 197 198 | { al_draw_tinted_scaled_bitmap(bitmap, ogk_color_to_allegro(tint), region.origin.x, region.origin.y, region.size.width, region.size.height, position.x, position.y, scale.width * al_get_bitmap_width(bitmap), scale.height * al_get_bitmap_height(bitmap), 0); } - (ALLEGRO_BITMAP*)OGK_allegroBitmap { return bitmap; } @end | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | { al_draw_tinted_scaled_bitmap(bitmap, ogk_color_to_allegro(tint), region.origin.x, region.origin.y, region.size.width, region.size.height, position.x, position.y, scale.width * al_get_bitmap_width(bitmap), scale.height * al_get_bitmap_height(bitmap), 0); } - (void)drawAtPosition: (of_point_t)position rotation: (ogk_rotation_t)rotation { al_draw_rotated_bitmap(bitmap, rotation.center.x, rotation.center.y, position.x, position.y, rotation.angle, 0); } - (void)drawAtPosition: (of_point_t)position scale: (of_dimension_t)scale rotation: (ogk_rotation_t)rotation { al_draw_scaled_rotated_bitmap(bitmap, rotation.center.x, rotation.center.y, position.x, position.y, scale.width, scale.height, rotation.angle, 0); } - (void)drawAtPosition: (of_point_t)position rotation: (ogk_rotation_t)rotation tint: (ogk_color_t)tint { al_draw_tinted_rotated_bitmap(bitmap, ogk_color_to_allegro(tint), rotation.center.x, rotation.center.y, position.x, position.y, rotation.angle, 0); } - (void)drawAtPosition: (of_point_t)position scale: (of_dimension_t)scale rotation: (ogk_rotation_t)rotation tint: (ogk_color_t)tint { al_draw_tinted_scaled_rotated_bitmap(bitmap, ogk_color_to_allegro(tint), rotation.center.x, rotation.center.y, position.x, position.y, scale.width, scale.height, rotation.angle, 0); } - (ALLEGRO_BITMAP*)OGK_allegroBitmap { return bitmap; } @end |
Modified tests/TestMain.h from [79738436b7] to [2166ed5054].
︙ | ︙ | |||
28 29 30 31 32 33 34 35 36 37 | { OGKDisplay *display; OGKEventQueue *eventQueue; OGKBitmap *bitmap; of_point_t position; of_dimension_t scale; BOOL running; ogk_color_t tint; } @end | > | 28 29 30 31 32 33 34 35 36 37 38 | { OGKDisplay *display; OGKEventQueue *eventQueue; OGKBitmap *bitmap; of_point_t position; of_dimension_t scale; BOOL running; ogk_rotation_t rotation; ogk_color_t tint; } @end |
Modified tests/TestMain.m from [4d353693fc] to [d6c7c983df].
︙ | ︙ | |||
47 48 49 50 51 52 53 54 55 56 57 58 59 60 | break; case OGK_KEY_B: tint = ogk_color(0.5, 0.5, 1, 0); break; case OGK_KEY_N: tint = ogk_color(1, 1, 1, 0); break; case OGK_KEY_Q: running = NO; break; } } - (void)keyWasReleased: (OGKKeyReleaseEvent*)event | > > > > > > | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | break; case OGK_KEY_B: tint = ogk_color(0.5, 0.5, 1, 0); break; case OGK_KEY_N: tint = ogk_color(1, 1, 1, 0); break; case OGK_KEY_LEFT: rotation.angle -= M_PI / 128; break; case OGK_KEY_RIGHT: rotation.angle += M_PI / 128; break; case OGK_KEY_Q: running = NO; break; } } - (void)keyWasReleased: (OGKKeyReleaseEvent*)event |
︙ | ︙ | |||
100 101 102 103 104 105 106 107 108 109 110 111 112 113 | } - (void)draw { [OGKBitmap clearToColor: OGK_COLOR_BLACK]; [bitmap drawAtPosition: position scale: scale tint: tint]; [display update]; } - (void)applicationDidFinishLaunching { ogk_display_flags_t flags = | > | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | } - (void)draw { [OGKBitmap clearToColor: OGK_COLOR_BLACK]; [bitmap drawAtPosition: position scale: scale rotation: rotation tint: tint]; [display update]; } - (void)applicationDidFinishLaunching { ogk_display_flags_t flags = |
︙ | ︙ | |||
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | [eventQueue registerDisplay: display]; [eventQueue registerKeyboard]; [eventQueue registerMouse]; bitmap = [[OGKBitmap alloc] initWithFile: @"test.bmp"]; position = of_point(display.size.width / 2, display.size.height / 2); scale = of_dimension(1, 1); tint = ogk_color(1, 1, 1, 0); for (running = YES; running;) { @autoreleasepool { [self handleEvents]; [self draw]; } } } @end | > > | 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | [eventQueue registerDisplay: display]; [eventQueue registerKeyboard]; [eventQueue registerMouse]; bitmap = [[OGKBitmap alloc] initWithFile: @"test.bmp"]; position = of_point(display.size.width / 2, display.size.height / 2); scale = of_dimension(1, 1); rotation = ogk_rotation(bitmap.size.width / 2, bitmap.size.height / 2, 0); tint = ogk_color(1, 1, 1, 0); for (running = YES; running;) { @autoreleasepool { [self handleEvents]; [self draw]; } } } @end |