Overview
Comment: | Make scale relative instead of absolute. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
e3b3bcfe2000a9b9031305882726bb51 |
User & Date: | js on 2012-08-28 19:43:09 |
Other Links: | manifest | tags |
Context
2012-08-28
| ||
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 | |
17:50 | Add many new methods to OGKBitmap. check-in: f2278e46ca user: js tags: trunk | |
Changes
Modified src/OGKBitmap.m from [0e51e0ab6e] to [4f0798e904].
︙ | ︙ | |||
128 129 130 131 132 133 134 | } - (void)drawAtPosition: (of_point_t)position scale: (of_dimension_t)scale { al_draw_scaled_bitmap(bitmap, 0, 0, al_get_bitmap_width(bitmap), al_get_bitmap_height(bitmap), position.x, position.y, | | > | > | > | > | | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | } - (void)drawAtPosition: (of_point_t)position scale: (of_dimension_t)scale { al_draw_scaled_bitmap(bitmap, 0, 0, al_get_bitmap_width(bitmap), al_get_bitmap_height(bitmap), 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 region: (of_rectangle_t)region { al_draw_bitmap_region(bitmap, region.origin.x, region.origin.y, region.size.width, region.size.height, position.x, position.y, 0); } - (void)drawAtPosition: (of_point_t)position region: (of_rectangle_t)region scale: (of_dimension_t)scale { al_draw_scaled_bitmap(bitmap, 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 tint: (ogk_color_t)tint { al_draw_tinted_bitmap(bitmap, ogk_color_to_allegro(tint), position.x, position.y, 0); } - (void)drawAtPosition: (of_point_t)position scale: (of_dimension_t)scale tint: (ogk_color_t)tint { al_draw_tinted_scaled_bitmap(bitmap, ogk_color_to_allegro(tint), 0, 0, al_get_bitmap_width(bitmap), al_get_bitmap_height(bitmap), 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 region: (of_rectangle_t)region tint: (ogk_color_t)tint { al_draw_tinted_bitmap_region(bitmap, ogk_color_to_allegro(tint), region.origin.x, region.origin.y, region.size.width, region.size.height, position.x, position.y, 0); } - (void)drawAtPosition: (of_point_t)position region: (of_rectangle_t)region scale: (of_dimension_t)scale tint: (ogk_color_t)tint { 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 |
Modified tests/TestMain.m from [2b37607de0] to [4d353693fc].
︙ | ︙ | |||
69 70 71 72 73 74 75 | of_log(@"Mouse moved: X=%.f(%.f) Y=%.f(%.f) WX=%.f(%.f) WY=%.f(%.f)", event.cursor.x, event.deltaCursor.x, event.cursor.y, event.deltaCursor.y, event.wheel.x, event.deltaWheel.x, event.wheel.y, event.deltaWheel.y); position = event.cursor; | | > | | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | of_log(@"Mouse moved: X=%.f(%.f) Y=%.f(%.f) WX=%.f(%.f) WY=%.f(%.f)", event.cursor.x, event.deltaCursor.x, event.cursor.y, event.deltaCursor.y, event.wheel.x, event.deltaWheel.x, event.wheel.y, event.deltaWheel.y); position = event.cursor; scale = of_dimension( (bitmap.size.width + event.wheel.x) / bitmap.size.width, (bitmap.size.height + event.wheel.y) / bitmap.size.height); } - (void)mouseButtonWasPressed: (OGKMouseButtonPressedEvent*)event display: (OGKDisplay*)display { of_log(@"Mouse button was pressed: %d (X=%.f Y=%.f WX=%.f WY=%.f)", event.button, event.cursor.x, event.cursor.y, |
︙ | ︙ | |||
129 130 131 132 133 134 135 | [eventQueue registerDisplay: display]; [eventQueue registerKeyboard]; [eventQueue registerMouse]; bitmap = [[OGKBitmap alloc] initWithFile: @"test.bmp"]; position = of_point(display.size.width / 2, display.size.height / 2); | | | 130 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 |