static struct sprite_trans * trans_mul(struct sprite_trans *a, struct sprite_trans *b, struct sprite_trans *t, struct matrix *tmp_matrix) { if (b == NULL) { return a; } *t = *a; if (t->mat == NULL) { t->mat = b->mat; } else if (b->mat) { matrix_mul(tmp_matrix, t->mat, b->mat); t->mat = tmp_matrix; } if (t->color == 0xffffffff) { t->color = b->color; } else if (b->color != 0xffffffff) { t->color = color_mul(t->color, b->color); } if (t->additive == 0) { t->additive = b->additive; } else if (b->additive != 0) { t->additive = color_add(t->additive, b->additive); } if (t->program == PROGRAM_DEFAULT) { t->program = b->program; } return t; }
void label_draw(const char *str, struct pack_label * l, struct srt *srt, const struct sprite_trans *arg) { shader_texture(Tex); uint32_t color; if (arg->color == 0xffffffff) { color = l->color; } else if (l->color == 0xffffffff){ color = arg->color; } else { color = color_mul(l->color, arg->color); } char utf8[7]; int i; int ch = 0, w = 0, cy = 0, pre = 0; for (i=0; str[i];) { int unicode; uint8_t c = (uint8_t)str[i]; if ((c&0x80) == 0) { unicode = copystr(utf8,str+i,1); i+=1; } else if ((c&0xe0) == 0xc0) { unicode = copystr(utf8,str+i,2); i+=2; } else if ((c&0xf0) == 0xe0) { unicode = copystr(utf8,str+i,3); i+=3; } else if ((c&0xf8) == 0xf0) { unicode = copystr(utf8,str+i,4); i+=4; } else if ((c&0xfc) == 0xf8) { unicode = copystr(utf8,str+i,5); i+=5; } else { unicode = copystr(utf8,str+i,6); i+=6; } w += draw_size(unicode, utf8, l->size); if (ch == 0) { ch = draw_height(unicode, utf8, l->size); } if(w > l->width || unicode == '\n') { draw_line(str, l, srt, arg, color, cy, w, pre, i); cy += ch; pre = i; w = 0; ch = 0; } } draw_line(str, l, srt, arg, color, cy, w, pre, i); }
uint32_t label_get_color(struct pack_label * l, const struct sprite_trans *arg) { uint32_t color; if (arg->color == 0xffffffff) { color = l->color; } else if (l->color == 0xffffffff){ color = arg->color; } else { color = color_mul(l->color, arg->color); } return color; }
static void draw_line(const struct rich_text *rich, struct pack_label * l, struct srt *srt, const struct sprite_trans *arg, uint32_t color, int cy, int w, int start, int end, int *pre_char_cnt, float space_scale) { const char *str = rich->text; float cx; int j; int size = l->size; if (l->auto_scale != 0 && w > l->width) { float scale = l->width * 1.0f / w; size = scale * size; cy = cy + (l->size - size) / 2; w = l->width; } switch (l->align) { case LABEL_ALIGN_LEFT: cx = 0.0; break; case LABEL_ALIGN_RIGHT: cx = l->width - w; break; case LABEL_ALIGN_CENTER: cx = (l->width - w)/2; break; } int char_cnt = 0; for (j=start; j<end;) { int unicode; char_cnt++; int len = unicode_len(str[j]); unicode = get_unicode(str+j, len); j+=len; if(unicode != '\n') { uint32_t field_color = get_rich_field_color(rich, *pre_char_cnt+char_cnt); if (field_color == 0) { field_color = color; } else { field_color = color_mul(field_color, color | 0xffffff); } cx+=(draw_utf8(unicode, cx, cy, size, srt, field_color, arg, l->edge) + l->space_w)*space_scale; } } *pre_char_cnt += char_cnt; }
void draw_difficulty_menu(MenuData *menu) { draw_main_menu_bg(menu, 0, 0, 0.05, "menu/mainmenubg", "stage1/cirnobg"); draw_menu_title(menu, "Select Difficulty"); Color c = diff_color; r_color(color_mul(&c, RGBA(0.07, 0.07, 0.07, 0.7))); r_mat_push(); r_mat_translate(SCREEN_W/2, SCREEN_H/2,0); r_mat_rotate_deg(4*menu->drawdata[0]-4,0,0,1); r_mat_push(); r_mat_scale(SCREEN_W*1.5,120,1); r_shader_standard_notex(); r_draw_quad(); r_mat_pop(); r_color3(1,1,1); r_shader("text_default"); float amp = menu->cursor/2.; float shake = 0.3*amp*menu->frames; text_draw(menu->entries[menu->cursor].name, &(TextParams) { .pos = { 120+15*menu->drawdata[0]+amp*sin(shake), -12+amp*cos(1.57*shake) }, });
Color Color::__mul__(const Color& c1) { Color r; color_mul(&r.c_, &c_, &c1.c_); return r; }