For Seminar
Dependencies: GR-PEACH_video GraphicsFramework R_BSP mbed-rtos mbed
Fork of RGA_HelloWorld by
rga_func.cpp@7:b007a4342314, 2016-09-08 (annotated)
- Committer:
- ShinjiYamano
- Date:
- Thu Sep 08 05:23:27 2016 +0000
- Revision:
- 7:b007a4342314
- Parent:
- 6:43a00280a595
For Seminar (Rev.2)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
1050186 | 0:84e4649e7707 | 1 | /* |
1050186 | 0:84e4649e7707 | 2 | Permission is hereby granted, free of charge, to any person obtaining a copy |
1050186 | 0:84e4649e7707 | 3 | of this software and associated documentation files (the "Software"), to deal |
1050186 | 0:84e4649e7707 | 4 | in the Software without restriction, including without limitation the rights |
1050186 | 0:84e4649e7707 | 5 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
1050186 | 0:84e4649e7707 | 6 | copies of the Software, and to permit persons to whom the Software is |
1050186 | 0:84e4649e7707 | 7 | furnished to do so, subject to the following conditions: |
1050186 | 0:84e4649e7707 | 8 | |
1050186 | 0:84e4649e7707 | 9 | The above copyright notice and this permission notice shall be included in |
1050186 | 0:84e4649e7707 | 10 | all copies or substantial portions of the Software. |
1050186 | 0:84e4649e7707 | 11 | |
1050186 | 0:84e4649e7707 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
1050186 | 0:84e4649e7707 | 13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
1050186 | 0:84e4649e7707 | 14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
1050186 | 0:84e4649e7707 | 15 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
1050186 | 0:84e4649e7707 | 16 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
1050186 | 0:84e4649e7707 | 17 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
1050186 | 0:84e4649e7707 | 18 | THE SOFTWARE. |
1050186 | 0:84e4649e7707 | 19 | */ |
1050186 | 0:84e4649e7707 | 20 | |
1050186 | 0:84e4649e7707 | 21 | #include "mbed.h" |
1050186 | 0:84e4649e7707 | 22 | #include "rga_func.h" |
ShinjiYamano | 6:43a00280a595 | 23 | #include "BinaryImage_RZ_A1H.h" |
1050186 | 0:84e4649e7707 | 24 | |
1050186 | 1:a07212e32dcb | 25 | #define ZOOM_SRC_CENTER_X (IMAGE_WIDTH_ZOOM_FUNC / 2) |
1050186 | 1:a07212e32dcb | 26 | #define ZOOM_SRC_CENTER_Y (IMAGE_HEIGHT_ZOOM_FUNC / 2) |
1050186 | 0:84e4649e7707 | 27 | |
dkato | 2:c7faef0ef374 | 28 | #define CRYSTAL_DIAMETER (93) |
1050186 | 0:84e4649e7707 | 29 | |
1050186 | 0:84e4649e7707 | 30 | Canvas2D_ContextClass canvas2d; |
1050186 | 0:84e4649e7707 | 31 | |
1050186 | 0:84e4649e7707 | 32 | static animation_timing_function_t* accelerator; |
1050186 | 0:84e4649e7707 | 33 | |
1050186 | 0:84e4649e7707 | 34 | void Set_RGAObject(frame_buffer_t* frmbuf_info) { |
1050186 | 0:84e4649e7707 | 35 | errnum_t err; |
1050186 | 0:84e4649e7707 | 36 | Canvas2D_ContextConfigClass config; |
1050186 | 0:84e4649e7707 | 37 | |
1050186 | 0:84e4649e7707 | 38 | config.frame_buffer = frmbuf_info; |
1050186 | 0:84e4649e7707 | 39 | canvas2d = R_RGA_New_Canvas2D_ContextClass(config); |
1050186 | 0:84e4649e7707 | 40 | err = R_OSPL_GetErrNum(); |
1050186 | 0:84e4649e7707 | 41 | if (err != 0) { |
1050186 | 0:84e4649e7707 | 42 | printf("Line %d, error %d\n", __LINE__, err); |
1050186 | 0:84e4649e7707 | 43 | while (1); |
1050186 | 0:84e4649e7707 | 44 | } |
1050186 | 0:84e4649e7707 | 45 | } |
1050186 | 0:84e4649e7707 | 46 | |
dkato | 2:c7faef0ef374 | 47 | void RGA_Func_DrawTopScreen(frame_buffer_t* frmbuf_info) { |
dkato | 2:c7faef0ef374 | 48 | /* Clear */ |
dkato | 2:c7faef0ef374 | 49 | canvas2d.clearRect(0, 0, frmbuf_info->width, frmbuf_info->height); |
1050186 | 0:84e4649e7707 | 50 | |
1050186 | 0:84e4649e7707 | 51 | /* Draw a image */ |
1050186 | 0:84e4649e7707 | 52 | canvas2d.drawImage(TopScrn_jpg_File, 0, 0); |
1050186 | 0:84e4649e7707 | 53 | |
1050186 | 0:84e4649e7707 | 54 | /* Complete drawing */ |
1050186 | 0:84e4649e7707 | 55 | R_GRAPHICS_Finish(canvas2d.c_LanguageContext); |
1050186 | 0:84e4649e7707 | 56 | } |
1050186 | 0:84e4649e7707 | 57 | |
dkato | 2:c7faef0ef374 | 58 | void RGA_Func_DrawRectangle(frame_buffer_t* frmbuf_info, draw_rectangle_pos_t * pos, int pos_num) { |
dkato | 2:c7faef0ef374 | 59 | int cnt; |
dkato | 2:c7faef0ef374 | 60 | |
dkato | 2:c7faef0ef374 | 61 | /* Clear */ |
dkato | 2:c7faef0ef374 | 62 | canvas2d.clearRect(0, 0, frmbuf_info->width, frmbuf_info->height); |
dkato | 2:c7faef0ef374 | 63 | |
dkato | 2:c7faef0ef374 | 64 | /* Draw description */ |
dkato | 2:c7faef0ef374 | 65 | canvas2d.drawImage(decs_swipe_jpg_File, 230, 400); |
dkato | 2:c7faef0ef374 | 66 | |
dkato | 2:c7faef0ef374 | 67 | /* Draw rectangle */ |
dkato | 2:c7faef0ef374 | 68 | for (cnt = 0; cnt < pos_num; cnt++) { |
dkato | 2:c7faef0ef374 | 69 | canvas2d.fillStyle = pos->style; |
dkato | 2:c7faef0ef374 | 70 | canvas2d.fillRect(pos->x, pos->y, pos->w, pos->h); |
dkato | 2:c7faef0ef374 | 71 | pos++; |
dkato | 2:c7faef0ef374 | 72 | } |
dkato | 2:c7faef0ef374 | 73 | |
dkato | 2:c7faef0ef374 | 74 | /* Draw return button */ |
1050186 | 0:84e4649e7707 | 75 | canvas2d.drawImage(RetBtn_jpg_File, 640, 10); |
1050186 | 0:84e4649e7707 | 76 | |
1050186 | 0:84e4649e7707 | 77 | /* Complete drawing */ |
1050186 | 0:84e4649e7707 | 78 | R_GRAPHICS_Finish(canvas2d.c_LanguageContext); |
1050186 | 0:84e4649e7707 | 79 | } |
1050186 | 0:84e4649e7707 | 80 | |
dkato | 2:c7faef0ef374 | 81 | void RGA_Func_DrawImage(frame_buffer_t* frmbuf_info, int x, int y) { |
dkato | 2:c7faef0ef374 | 82 | int draw_pos_x = x - (CRYSTAL_DIAMETER / 2); |
dkato | 2:c7faef0ef374 | 83 | int draw_pos_y = y - (CRYSTAL_DIAMETER / 2); |
dkato | 2:c7faef0ef374 | 84 | |
1050186 | 0:84e4649e7707 | 85 | /* Clear */ |
1050186 | 0:84e4649e7707 | 86 | canvas2d.clearRect(0, 0, frmbuf_info->width, frmbuf_info->height); |
1050186 | 0:84e4649e7707 | 87 | |
dkato | 2:c7faef0ef374 | 88 | /* Draw description */ |
dkato | 2:c7faef0ef374 | 89 | canvas2d.drawImage(decs_swipe_jpg_File, 230, 400); |
1050186 | 0:84e4649e7707 | 90 | |
1050186 | 0:84e4649e7707 | 91 | /* Draw the first image */ |
1050186 | 0:84e4649e7707 | 92 | canvas2d.drawImage(Flower_jpg_File, 100, 100); |
dkato | 2:c7faef0ef374 | 93 | |
1050186 | 0:84e4649e7707 | 94 | /* Draw the second image */ |
1050186 | 0:84e4649e7707 | 95 | if ((frmbuf_info->pixel_format == PIXEL_FORMAT_ARGB8888) || (frmbuf_info->pixel_format == PIXEL_FORMAT_XRGB8888)) { |
dkato | 2:c7faef0ef374 | 96 | canvas2d.drawImage(Crystal_png_ARGB8888, draw_pos_x, draw_pos_y); |
1050186 | 0:84e4649e7707 | 97 | } else if (frmbuf_info->pixel_format != PIXEL_FORMAT_YUV422) { |
dkato | 2:c7faef0ef374 | 98 | canvas2d.drawImage(Crystal_png_ARGB4444, draw_pos_x, draw_pos_y); |
1050186 | 0:84e4649e7707 | 99 | } else { |
dkato | 2:c7faef0ef374 | 100 | canvas2d.drawImage(Crystal_png_File, draw_pos_x, draw_pos_y); |
1050186 | 0:84e4649e7707 | 101 | } |
1050186 | 0:84e4649e7707 | 102 | |
dkato | 2:c7faef0ef374 | 103 | /* Draw return button */ |
dkato | 2:c7faef0ef374 | 104 | canvas2d.drawImage(RetBtn_jpg_File, 640, 10); |
dkato | 2:c7faef0ef374 | 105 | |
1050186 | 0:84e4649e7707 | 106 | /* Complete drawing */ |
1050186 | 0:84e4649e7707 | 107 | R_GRAPHICS_Finish(canvas2d.c_LanguageContext); |
1050186 | 0:84e4649e7707 | 108 | } |
1050186 | 0:84e4649e7707 | 109 | |
1050186 | 0:84e4649e7707 | 110 | void RGA_Func_Dissolve(frame_buffer_t* frmbuf_info, float32_t global_alpha) { |
1050186 | 0:84e4649e7707 | 111 | /* Dissolve = Fade Out + Fade In */ |
1050186 | 0:84e4649e7707 | 112 | /* Clear */ |
1050186 | 0:84e4649e7707 | 113 | canvas2d.clearRect(0, 0, frmbuf_info->width, frmbuf_info->height); |
dkato | 2:c7faef0ef374 | 114 | |
dkato | 2:c7faef0ef374 | 115 | /* Draw description */ |
dkato | 2:c7faef0ef374 | 116 | canvas2d.drawImage(decs_swipe_side_jpg_File, 140, 400); |
dkato | 2:c7faef0ef374 | 117 | |
1050186 | 0:84e4649e7707 | 118 | /* fade Out */ |
1050186 | 0:84e4649e7707 | 119 | canvas2d.globalAlpha = 1.0f - global_alpha; |
1050186 | 0:84e4649e7707 | 120 | canvas2d.drawImage(Flower_jpg_File, 100, 100); |
dkato | 2:c7faef0ef374 | 121 | |
1050186 | 0:84e4649e7707 | 122 | /* fade In */ |
1050186 | 0:84e4649e7707 | 123 | canvas2d.globalAlpha = global_alpha; |
1050186 | 0:84e4649e7707 | 124 | canvas2d.drawImage(Landscape_jpg_File, 100, 100); |
1050186 | 0:84e4649e7707 | 125 | |
1050186 | 0:84e4649e7707 | 126 | canvas2d.globalAlpha = 1.0f; |
dkato | 2:c7faef0ef374 | 127 | |
dkato | 2:c7faef0ef374 | 128 | /* Draw return button */ |
dkato | 2:c7faef0ef374 | 129 | canvas2d.drawImage(RetBtn_jpg_File, 640, 10); |
dkato | 2:c7faef0ef374 | 130 | |
1050186 | 0:84e4649e7707 | 131 | /* Complete drawing */ |
1050186 | 0:84e4649e7707 | 132 | R_GRAPHICS_Finish(canvas2d.c_LanguageContext); |
1050186 | 0:84e4649e7707 | 133 | } |
1050186 | 0:84e4649e7707 | 134 | |
1050186 | 0:84e4649e7707 | 135 | void RGA_Func_Scroll(frame_buffer_t* frmbuf_info, int src_width_pos) { |
1050186 | 0:84e4649e7707 | 136 | /* Clear */ |
1050186 | 0:84e4649e7707 | 137 | canvas2d.clearRect(0, 0, frmbuf_info->width, frmbuf_info->height); |
dkato | 2:c7faef0ef374 | 138 | |
dkato | 2:c7faef0ef374 | 139 | /* Draw description */ |
dkato | 2:c7faef0ef374 | 140 | canvas2d.drawImage(decs_swipe_side_jpg_File, 140, 400); |
dkato | 2:c7faef0ef374 | 141 | |
1050186 | 0:84e4649e7707 | 142 | /* Scroll from left to right */ |
1050186 | 0:84e4649e7707 | 143 | canvas2d.drawImage(Landscape_wide_jpg_File, |
1050186 | 0:84e4649e7707 | 144 | /* src */ src_width_pos, 25, IMG_DRAW_WIDTH, IMG_DRAW_HEIGHT, |
1050186 | 0:84e4649e7707 | 145 | /* dst */ 100, 100, IMG_DRAW_WIDTH, IMG_DRAW_HEIGHT); |
1050186 | 0:84e4649e7707 | 146 | |
dkato | 2:c7faef0ef374 | 147 | /* Draw return button */ |
dkato | 2:c7faef0ef374 | 148 | canvas2d.drawImage(RetBtn_jpg_File, 640, 10); |
dkato | 2:c7faef0ef374 | 149 | |
1050186 | 0:84e4649e7707 | 150 | /* Complete drawing */ |
1050186 | 0:84e4649e7707 | 151 | R_GRAPHICS_Finish(canvas2d.c_LanguageContext); |
1050186 | 0:84e4649e7707 | 152 | } |
1050186 | 0:84e4649e7707 | 153 | |
1050186 | 0:84e4649e7707 | 154 | void RGA_Func_Zoom(frame_buffer_t* frmbuf_info, int src_height_pos) { |
1050186 | 0:84e4649e7707 | 155 | /* Clear */ |
1050186 | 0:84e4649e7707 | 156 | canvas2d.clearRect(0, 0, frmbuf_info->width, frmbuf_info->height); |
dkato | 2:c7faef0ef374 | 157 | |
dkato | 2:c7faef0ef374 | 158 | /* Draw description */ |
dkato | 2:c7faef0ef374 | 159 | canvas2d.drawImage(decs_swipe_side_jpg_File, 140, 400); |
dkato | 2:c7faef0ef374 | 160 | |
1050186 | 0:84e4649e7707 | 161 | /* Zoom out */ |
1050186 | 0:84e4649e7707 | 162 | canvas2d.drawImage(Landscape_wide_jpg_File, |
1050186 | 0:84e4649e7707 | 163 | /* src X */ ZOOM_SRC_CENTER_X - (src_height_pos * IMG_DRAW_WIDTH / IMG_DRAW_HEIGHT), |
1050186 | 0:84e4649e7707 | 164 | /* src Y */ ZOOM_SRC_CENTER_Y - src_height_pos, |
1050186 | 0:84e4649e7707 | 165 | /* src W */ src_height_pos * 2 * IMG_DRAW_WIDTH / IMG_DRAW_HEIGHT, |
1050186 | 0:84e4649e7707 | 166 | /* src H */ src_height_pos * 2, |
1050186 | 0:84e4649e7707 | 167 | /* dst */ 100, 100, IMG_DRAW_WIDTH, IMG_DRAW_HEIGHT); |
1050186 | 0:84e4649e7707 | 168 | |
dkato | 2:c7faef0ef374 | 169 | /* Draw return button */ |
dkato | 2:c7faef0ef374 | 170 | canvas2d.drawImage(RetBtn_jpg_File, 640, 10); |
dkato | 2:c7faef0ef374 | 171 | |
1050186 | 0:84e4649e7707 | 172 | /* Complete drawing */ |
1050186 | 0:84e4649e7707 | 173 | R_GRAPHICS_Finish(canvas2d.c_LanguageContext); |
1050186 | 0:84e4649e7707 | 174 | } |
1050186 | 0:84e4649e7707 | 175 | |
1050186 | 0:84e4649e7707 | 176 | void RGA_Func_Rotation(frame_buffer_t* frmbuf_info, graphics_matrix_float_t image_angle) { |
1050186 | 0:84e4649e7707 | 177 | /* Rotate the image to the right */ |
1050186 | 0:84e4649e7707 | 178 | /* Clear */ |
1050186 | 0:84e4649e7707 | 179 | canvas2d.clearRect(0, 0, frmbuf_info->width, frmbuf_info->height); |
dkato | 2:c7faef0ef374 | 180 | |
dkato | 2:c7faef0ef374 | 181 | /* Draw description */ |
dkato | 2:c7faef0ef374 | 182 | canvas2d.drawImage(decs_swipe_side_jpg_File, 140, 400); |
dkato | 2:c7faef0ef374 | 183 | |
1050186 | 0:84e4649e7707 | 184 | /* Move to drawing position */ |
1050186 | 0:84e4649e7707 | 185 | canvas2d.translate((100 + (IMG_DRAW_WIDTH / 2)), (100 + (IMG_DRAW_HEIGHT / 2))); |
dkato | 2:c7faef0ef374 | 186 | |
1050186 | 0:84e4649e7707 | 187 | /* Rotate */ |
1050186 | 0:84e4649e7707 | 188 | canvas2d.rotate(image_angle * (3.14159 / 180)); |
dkato | 2:c7faef0ef374 | 189 | |
1050186 | 0:84e4649e7707 | 190 | /* Move to center to rotate */ |
1050186 | 0:84e4649e7707 | 191 | canvas2d.translate((-IMG_DRAW_WIDTH / 2), (-IMG_DRAW_HEIGHT / 2)); |
1050186 | 0:84e4649e7707 | 192 | canvas2d.drawImage(Flower_jpg_File, 0, 0); |
1050186 | 0:84e4649e7707 | 193 | canvas2d.setTransform(1, 0, 0, 1, 0, 0); |
1050186 | 0:84e4649e7707 | 194 | |
dkato | 2:c7faef0ef374 | 195 | /* Draw return button */ |
dkato | 2:c7faef0ef374 | 196 | canvas2d.drawImage(RetBtn_jpg_File, 640, 10); |
dkato | 2:c7faef0ef374 | 197 | |
1050186 | 0:84e4649e7707 | 198 | /* Complete drawing */ |
1050186 | 0:84e4649e7707 | 199 | R_GRAPHICS_Finish(canvas2d.c_LanguageContext); |
1050186 | 0:84e4649e7707 | 200 | } |
1050186 | 0:84e4649e7707 | 201 | |
dkato | 2:c7faef0ef374 | 202 | void RGA_Func_Accelerate(frame_buffer_t* frmbuf_info, int animation_timing, float32_t relative_pos) { |
1050186 | 0:84e4649e7707 | 203 | /* Do accelerated motion from right to left */ |
1050186 | 0:84e4649e7707 | 204 | int position; |
1050186 | 0:84e4649e7707 | 205 | |
1050186 | 0:84e4649e7707 | 206 | /* Clear */ |
1050186 | 0:84e4649e7707 | 207 | canvas2d.clearRect(0, 0, frmbuf_info->width, frmbuf_info->height); |
dkato | 2:c7faef0ef374 | 208 | |
dkato | 2:c7faef0ef374 | 209 | if (relative_pos == 0.0f) { |
dkato | 2:c7faef0ef374 | 210 | switch (animation_timing) { |
dkato | 2:c7faef0ef374 | 211 | case ANIMATION_TIMING_EASE: |
dkato | 2:c7faef0ef374 | 212 | R_Get_AnimationTimingFunction("ease", &accelerator); |
dkato | 2:c7faef0ef374 | 213 | break; |
dkato | 2:c7faef0ef374 | 214 | case ANIMATION_TIMING_LINEAR: |
dkato | 2:c7faef0ef374 | 215 | R_Get_AnimationTimingFunction("linear", &accelerator); |
dkato | 2:c7faef0ef374 | 216 | break; |
dkato | 2:c7faef0ef374 | 217 | case ANIMATION_TIMING_EASE_IN: |
dkato | 2:c7faef0ef374 | 218 | R_Get_AnimationTimingFunction("ease-in", &accelerator); |
dkato | 2:c7faef0ef374 | 219 | break; |
dkato | 2:c7faef0ef374 | 220 | case ANIMATION_TIMING_EASE_OUT: |
dkato | 2:c7faef0ef374 | 221 | R_Get_AnimationTimingFunction("ease-out", &accelerator); |
dkato | 2:c7faef0ef374 | 222 | break; |
dkato | 2:c7faef0ef374 | 223 | case ANIMATION_TIMING_EASE_IN_OUT: |
dkato | 2:c7faef0ef374 | 224 | default: |
dkato | 2:c7faef0ef374 | 225 | R_Get_AnimationTimingFunction("ease-in-out", &accelerator); |
dkato | 2:c7faef0ef374 | 226 | break; |
dkato | 2:c7faef0ef374 | 227 | } |
dkato | 2:c7faef0ef374 | 228 | } |
dkato | 2:c7faef0ef374 | 229 | |
dkato | 2:c7faef0ef374 | 230 | /* Draw rectangle */ |
dkato | 2:c7faef0ef374 | 231 | canvas2d.fillStyle = "#0000FF"; /* blue */ |
dkato | 2:c7faef0ef374 | 232 | switch (animation_timing) { |
dkato | 2:c7faef0ef374 | 233 | case ANIMATION_TIMING_EASE: |
dkato | 2:c7faef0ef374 | 234 | canvas2d.fillRect(17, 420, 136, 10); |
dkato | 2:c7faef0ef374 | 235 | break; |
dkato | 2:c7faef0ef374 | 236 | case ANIMATION_TIMING_LINEAR: |
dkato | 2:c7faef0ef374 | 237 | canvas2d.fillRect(173, 420, 136, 10); |
dkato | 2:c7faef0ef374 | 238 | break; |
dkato | 2:c7faef0ef374 | 239 | case ANIMATION_TIMING_EASE_IN: |
dkato | 2:c7faef0ef374 | 240 | canvas2d.fillRect(330, 420, 136, 10); |
dkato | 2:c7faef0ef374 | 241 | break; |
dkato | 2:c7faef0ef374 | 242 | case ANIMATION_TIMING_EASE_OUT: |
dkato | 2:c7faef0ef374 | 243 | canvas2d.fillRect(487, 420, 136, 10); |
dkato | 2:c7faef0ef374 | 244 | break; |
dkato | 2:c7faef0ef374 | 245 | case ANIMATION_TIMING_EASE_IN_OUT: |
dkato | 2:c7faef0ef374 | 246 | default: |
dkato | 2:c7faef0ef374 | 247 | canvas2d.fillRect(644, 420, 136, 10); |
dkato | 2:c7faef0ef374 | 248 | break; |
dkato | 2:c7faef0ef374 | 249 | } |
dkato | 2:c7faef0ef374 | 250 | |
dkato | 2:c7faef0ef374 | 251 | /* Draw button */ |
dkato | 2:c7faef0ef374 | 252 | canvas2d.drawImage(animetion_timing_jpg_File, 0, 370); |
dkato | 2:c7faef0ef374 | 253 | |
1050186 | 0:84e4649e7707 | 254 | position = R_ANIMATION_TIMING_FUNCTION_GetValue(accelerator, relative_pos, 550.0f, 10.0f); |
1050186 | 0:84e4649e7707 | 255 | canvas2d.drawImage(Flower_jpg_File, position, 100); |
1050186 | 0:84e4649e7707 | 256 | |
dkato | 2:c7faef0ef374 | 257 | /* Draw return button */ |
dkato | 2:c7faef0ef374 | 258 | canvas2d.drawImage(RetBtn_jpg_File, 640, 10); |
dkato | 2:c7faef0ef374 | 259 | |
1050186 | 0:84e4649e7707 | 260 | /* Complete drawing */ |
1050186 | 0:84e4649e7707 | 261 | R_GRAPHICS_Finish(canvas2d.c_LanguageContext); |
1050186 | 0:84e4649e7707 | 262 | } |
ShinjiYamano | 4:99ff10b59637 | 263 | |
ShinjiYamano | 4:99ff10b59637 | 264 | void RGA_Func_Training(frame_buffer_t* frmbuf_info, int animation_timing, float32_t relative_pos) { |
ShinjiYamano | 4:99ff10b59637 | 265 | /* Do accelerated motion from right to left */ |
ShinjiYamano | 4:99ff10b59637 | 266 | int position = 100; |
ShinjiYamano | 4:99ff10b59637 | 267 | r8g8b8a8_t fillColor; |
ShinjiYamano | 4:99ff10b59637 | 268 | uint8_t alpha; |
ShinjiYamano | 4:99ff10b59637 | 269 | |
ShinjiYamano | 4:99ff10b59637 | 270 | /* 回転角度 */ |
ShinjiYamano | 7:b007a4342314 | 271 | const float32_t angle = (float32_t)(relative_pos * 3.14159 * 2.0); |
ShinjiYamano | 4:99ff10b59637 | 272 | |
ShinjiYamano | 4:99ff10b59637 | 273 | /* Clear */ |
ShinjiYamano | 4:99ff10b59637 | 274 | canvas2d.clearRect(0, 0, frmbuf_info->width, frmbuf_info->height); |
ShinjiYamano | 4:99ff10b59637 | 275 | |
ShinjiYamano | 4:99ff10b59637 | 276 | /* programing area 1 ------------------------------------------------*/ |
ShinjiYamano | 4:99ff10b59637 | 277 | |
ShinjiYamano | 4:99ff10b59637 | 278 | |
ShinjiYamano | 4:99ff10b59637 | 279 | |
ShinjiYamano | 4:99ff10b59637 | 280 | |
ShinjiYamano | 4:99ff10b59637 | 281 | /*---------------------------------------------------------------------*/ |
ShinjiYamano | 4:99ff10b59637 | 282 | |
ShinjiYamano | 4:99ff10b59637 | 283 | /*---------------------------------------------------------------------*/ |
ShinjiYamano | 4:99ff10b59637 | 284 | /* 画像の描画 (Section: 6.9.1.29) */ |
ShinjiYamano | 4:99ff10b59637 | 285 | canvas2d.drawImage(Landscape_wide_jpg_File, 100, 100); |
ShinjiYamano | 4:99ff10b59637 | 286 | /*---------------------------------------------------------------------*/ |
ShinjiYamano | 4:99ff10b59637 | 287 | |
ShinjiYamano | 4:99ff10b59637 | 288 | /* programing area 2 ------------------------------------------------*/ |
ShinjiYamano | 4:99ff10b59637 | 289 | |
ShinjiYamano | 4:99ff10b59637 | 290 | |
ShinjiYamano | 4:99ff10b59637 | 291 | |
ShinjiYamano | 4:99ff10b59637 | 292 | /*---------------------------------------------------------------------*/ |
ShinjiYamano | 4:99ff10b59637 | 293 | |
ShinjiYamano | 4:99ff10b59637 | 294 | |
ShinjiYamano | 4:99ff10b59637 | 295 | /* Draw return button */ |
ShinjiYamano | 4:99ff10b59637 | 296 | canvas2d.drawImage(RetBtn_jpg_File, 640, 10); |
ShinjiYamano | 4:99ff10b59637 | 297 | |
ShinjiYamano | 4:99ff10b59637 | 298 | /* Complete drawing */ |
ShinjiYamano | 4:99ff10b59637 | 299 | R_GRAPHICS_Finish(canvas2d.c_LanguageContext); |
ShinjiYamano | 4:99ff10b59637 | 300 | } |
ShinjiYamano | 4:99ff10b59637 | 301 | |
ShinjiYamano | 4:99ff10b59637 | 302 | #ifdef NEVER_COMES_HERE |
ShinjiYamano | 4:99ff10b59637 | 303 | /* 画像の描画 (Section: 6.9.1.29) */ |
ShinjiYamano | 4:99ff10b59637 | 304 | canvas2d.drawImage(g_sample0_jpg_File, 100, 100); |
ShinjiYamano | 4:99ff10b59637 | 305 | |
ShinjiYamano | 4:99ff10b59637 | 306 | /* matrix operation */ |
ShinjiYamano | 4:99ff10b59637 | 307 | /* 原点中心で回転処理 */ |
ShinjiYamano | 4:99ff10b59637 | 308 | canvas2d.rotate(angle); |
ShinjiYamano | 4:99ff10b59637 | 309 | |
ShinjiYamano | 4:99ff10b59637 | 310 | /* 原点が左上の画像に対して、画像の中心が原点となるように平行移動 */ |
ShinjiYamano | 4:99ff10b59637 | 311 | canvas2d.translate((-IMG_DRAW_WIDTH / 2), (-IMG_DRAW_HEIGHT / 2)); |
ShinjiYamano | 4:99ff10b59637 | 312 | |
ShinjiYamano | 4:99ff10b59637 | 313 | /* 希望する位置への移動 */ |
ShinjiYamano | 4:99ff10b59637 | 314 | canvas2d.translate((100 + (IMG_DRAW_WIDTH / 2)), (100 + (IMG_DRAW_HEIGHT / 2))); |
ShinjiYamano | 4:99ff10b59637 | 315 | |
ShinjiYamano | 4:99ff10b59637 | 316 | /* 拡大縮小 */ |
ShinjiYamano | 4:99ff10b59637 | 317 | canvas2d.scale(relative_pos * 1.2, relative_pos * 1.2); |
ShinjiYamano | 4:99ff10b59637 | 318 | |
ShinjiYamano | 4:99ff10b59637 | 319 | /* マトリクスの初期化 */ |
ShinjiYamano | 4:99ff10b59637 | 320 | canvas2d.setTransform(1, 0, 0, 1, 0, 0); |
ShinjiYamano | 4:99ff10b59637 | 321 | |
ShinjiYamano | 4:99ff10b59637 | 322 | /* animation */ |
ShinjiYamano | 4:99ff10b59637 | 323 | /* アニメーション時の位置取得 */ |
ShinjiYamano | 4:99ff10b59637 | 324 | R_Get_AnimationTimingFunction("ease-in-out", &accelerator); |
ShinjiYamano | 4:99ff10b59637 | 325 | position = R_ANIMATION_TIMING_FUNCTION_GetValue(accelerator, relative_pos, 550.0f, 10.0f); |
ShinjiYamano | 4:99ff10b59637 | 326 | |
ShinjiYamano | 4:99ff10b59637 | 327 | /* 背景色の設定 */ |
ShinjiYamano | 4:99ff10b59637 | 328 | /* 色の指定例: その他は http://www.colordic.org/ |
ShinjiYamano | 4:99ff10b59637 | 329 | 赤 緑 青 |
ShinjiYamano | 4:99ff10b59637 | 330 | 白: 255, 255, 255 |
ShinjiYamano | 4:99ff10b59637 | 331 | 黒: 0, 0, 0 |
ShinjiYamano | 4:99ff10b59637 | 332 | 赤: 255, 0, 0 |
ShinjiYamano | 4:99ff10b59637 | 333 | */ |
ShinjiYamano | 4:99ff10b59637 | 334 | fillColor.u.Alpha = 255; |
ShinjiYamano | 4:99ff10b59637 | 335 | fillColor.u.Red = 255; |
ShinjiYamano | 4:99ff10b59637 | 336 | fillColor.u.Green = 255; |
ShinjiYamano | 4:99ff10b59637 | 337 | fillColor.u.Blue = 255; |
ShinjiYamano | 4:99ff10b59637 | 338 | R_GRAPHICS_SetBackgroundColor(canvas2d.c_LanguageContext, fillColor); |
ShinjiYamano | 4:99ff10b59637 | 339 | |
ShinjiYamano | 4:99ff10b59637 | 340 | /* alpha blending */ |
ShinjiYamano | 4:99ff10b59637 | 341 | /* アルファ値の設定 */ |
ShinjiYamano | 4:99ff10b59637 | 342 | alpha = (uint8_t) (relative_pos * (float32_t)ACCELERATE_MAX_NUM) + 15; |
ShinjiYamano | 4:99ff10b59637 | 343 | R_GRAPHICS_SetGlobalAlpha(canvas2d.c_LanguageContext, alpha); |
ShinjiYamano | 4:99ff10b59637 | 344 | |
ShinjiYamano | 4:99ff10b59637 | 345 | #endif |