gg: add draw_empty_triangle() (#12804)

pull/12814/head
Benjamin Stigsen 2021-12-12 18:41:27 +01:00 committed by GitHub
parent 8c1c70db04
commit ab6e93394f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -266,6 +266,20 @@ pub fn (mut ctx Context) set_bg_color(c gx.Color) {
f32(c.a) / 255.0) f32(c.a) / 255.0)
} }
pub fn (ctx &Context) draw_empty_triangle(x f32, y f32, x2 f32, y2 f32, x3 f32, y3 f32, c gx.Color) {
if c.a != 255 {
sgl.load_pipeline(ctx.timage_pip)
}
sgl.c4b(c.r, c.g, c.b, c.a)
sgl.begin_line_strip()
sgl.v2f(x * ctx.scale, y * ctx.scale)
sgl.v2f(x2 * ctx.scale, y2 * ctx.scale)
sgl.v2f(x3 * ctx.scale, y3 * ctx.scale)
sgl.v2f(x * ctx.scale, y * ctx.scale)
sgl.end()
}
[inline] [inline]
pub fn (ctx &Context) draw_square(x f32, y f32, s f32, c gx.Color) { pub fn (ctx &Context) draw_square(x f32, y f32, s f32, c gx.Color) {
ctx.draw_rect(x, y, s, s, c) ctx.draw_rect(x, y, s, s, c)