Add g2_draw_line_aa
This commit is contained in:
@@ -2289,6 +2289,10 @@ void iron_g2_draw_line(f32 x0, f32 y0, f32 x1, f32 y1, f32 strength) {
|
||||
arm_g2_draw_line(x0, y0, x1, y1, strength);
|
||||
}
|
||||
|
||||
void iron_g2_draw_line_aa(f32 x0, f32 y0, f32 x1, f32 y1, f32 strength) {
|
||||
arm_g2_draw_line_aa(x0, y0, x1, y1, strength);
|
||||
}
|
||||
|
||||
void iron_g2_draw_string(string_t *text, f32 x, f32 y) {
|
||||
arm_g2_draw_string(text, x, y);
|
||||
}
|
||||
|
||||
@@ -266,12 +266,7 @@ void ui_draw_link(float x1, float y1, float x2, float y2, bool highlight) {
|
||||
int c = highlight ? c1 : c2;
|
||||
arm_g2_set_color(ui_color(ui_color_r(c), ui_color_g(c), ui_color_b(c), 210));
|
||||
if (current->ops->theme->LINK_STYLE == UI_LINK_STYLE_LINE) {
|
||||
arm_g2_draw_line(x1, y1, x2, y2, 1.0);
|
||||
arm_g2_set_color(ui_color(ui_color_r(c), ui_color_g(c), ui_color_b(c), 150)); // AA
|
||||
arm_g2_draw_line(x1 + 0.5, y1, x2 + 0.5, y2, 1.0);
|
||||
arm_g2_draw_line(x1 - 0.5, y1, x2 - 0.5, y2, 1.0);
|
||||
arm_g2_draw_line(x1, y1 + 0.5, x2, y2 + 0.5, 1.0);
|
||||
arm_g2_draw_line(x1, y1 - 0.5, x2, y2 - 0.5, 1.0);
|
||||
arm_g2_draw_line_aa(x1, y1, x2, y2, 1.0);
|
||||
}
|
||||
else if (current->ops->theme->LINK_STYLE == UI_LINK_STYLE_CUBIC_BEZIER) {
|
||||
float x[] = { x1, x1 + fabs(x1 - x2) / 2.0, x2 - fabs(x1 - x2) / 2.0, x2 };
|
||||
|
||||
@@ -596,6 +596,37 @@ void arm_g2_draw_line(float x0, float y0, float x1, float y1, float strength) {
|
||||
arm_g2_fill_triangle(p2.x, p2.y, p1.x, p1.y, p3.x, p3.y);
|
||||
}
|
||||
|
||||
static uint8_t _g2_color_r(uint32_t color) {
|
||||
return (color & 0x00ff0000) >> 16;
|
||||
}
|
||||
|
||||
static uint8_t _g2_color_g(uint32_t color) {
|
||||
return (color & 0x0000ff00) >> 8;
|
||||
}
|
||||
|
||||
static uint8_t _g2_color_b(uint32_t color) {
|
||||
return (color & 0x000000ff);
|
||||
}
|
||||
|
||||
static uint8_t _g2_color_a(uint32_t color) {
|
||||
return (color) >> 24;
|
||||
}
|
||||
|
||||
static uint32_t _g2_color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
|
||||
return (a << 24) | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
|
||||
void arm_g2_draw_line_aa(float x0, float y0, float x1, float y1, float strength) {
|
||||
arm_g2_draw_line(x0, y0, x1, y1, strength);
|
||||
uint32_t _color = g2_color;
|
||||
arm_g2_set_color(_g2_color(_g2_color_r(g2_color), _g2_color_g(g2_color), _g2_color_b(g2_color), 150));
|
||||
arm_g2_draw_line(x0 + 0.5, y0, x1 + 0.5, y1, strength);
|
||||
arm_g2_draw_line(x0 - 0.5, y0, x1 - 0.5, y1, strength);
|
||||
arm_g2_draw_line(x0, y0 + 0.5, x1, y1 + 0.5, strength);
|
||||
arm_g2_draw_line(x0, y0 - 0.5, x1, y1 - 0.5, strength);
|
||||
arm_g2_set_color(_color);
|
||||
}
|
||||
|
||||
void arm_g2_text_set_rect_verts(float btlx, float btly, float tplx, float tply, float tprx, float tpry, float btrx, float btry) {
|
||||
int base_idx = (text_buffer_index - text_buffer_start) * 6 * 4;
|
||||
text_rect_verts[base_idx + 0] = btlx;
|
||||
|
||||
@@ -43,6 +43,7 @@ void arm_g2_fill_triangle(float x0, float y0, float x1, float y1, float x2, floa
|
||||
void arm_g2_fill_rect(float x, float y, float width, float height);
|
||||
void arm_g2_draw_rect(float x, float y, float width, float height, float strength);
|
||||
void arm_g2_draw_line(float x0, float y0, float x1, float y1, float strength);
|
||||
void arm_g2_draw_line_aa(float x0, float y0, float x1, float y1, float strength);
|
||||
void arm_g2_draw_string(const char *text, float x, float y);
|
||||
void arm_g2_end(void);
|
||||
void arm_g2_set_color(uint32_t color);
|
||||
|
||||
@@ -119,6 +119,10 @@ function g2_draw_line(x0: f32, y0: f32, x1: f32, y1: f32, strength: f32 = 1.0) {
|
||||
iron_g2_draw_line(x0, y0, x1, y1, strength);
|
||||
}
|
||||
|
||||
function g2_draw_line_aa(x0: f32, y0: f32, x1: f32, y1: f32, strength: f32 = 1.0) {
|
||||
iron_g2_draw_line_aa(x0, y0, x1, y1, strength);
|
||||
}
|
||||
|
||||
function g2_fill_triangle(x0: f32, y0: f32, x1: f32, y1: f32, x2: f32, y2: f32) {
|
||||
iron_g2_fill_triangle(x0, y0, x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
@@ -320,6 +320,7 @@ declare function iron_g2_fill_triangle(x0: f32, y0: f32, x1: f32, y1: f32, x2: f
|
||||
declare function iron_g2_fill_rect(x: f32, y: f32, width: f32, height: f32): void;
|
||||
declare function iron_g2_draw_rect(x: f32, y: f32, width: f32, height: f32, strength: f32): void;
|
||||
declare function iron_g2_draw_line(x0: f32, y0: f32, x1: f32, y1: f32, strength: f32): void;
|
||||
declare function iron_g2_draw_line_aa(x0: f32, y0: f32, x1: f32, y1: f32, strength: f32): void;
|
||||
declare function iron_g2_draw_string(text: string, x: f32, y: f32): void;
|
||||
declare function iron_g2_set_font(font: any, size: i32): void;
|
||||
declare function iron_g2_font_init(blob: buffer_t, font_index: i32): any;
|
||||
|
||||
Reference in New Issue
Block a user