1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

gg: set_pixels() (#11236)

This commit is contained in:
Benjamin Stigsen
2021-08-20 00:14:25 +02:00
committed by GitHub
parent a440b43630
commit 70a658a265
2 changed files with 60 additions and 0 deletions

View File

@ -268,6 +268,27 @@ pub fn (ctx &Context) set_pixel(x f32, y f32, c gx.Color) {
ctx.draw_square(x, y, 1, c)
}
pub fn (ctx &Context) set_pixels(points []f32, c gx.Color) {
assert points.len % 2 == 0
len := points.len / 2
if c.a != 255 {
sgl.load_pipeline(ctx.timage_pip)
}
sgl.c4b(c.r, c.g, c.b, c.a)
sgl.begin_quads()
for i in 0 .. len {
x, y := points[i * 2], points[i * 2 + 1]
sgl.v2f(x * ctx.scale, y * ctx.scale)
sgl.v2f((x + 1) * ctx.scale, y * ctx.scale)
sgl.v2f((x + 1) * ctx.scale, (y + 1) * ctx.scale)
sgl.v2f(x * ctx.scale, (y + 1) * ctx.scale)
}
sgl.end()
}
pub fn (ctx &Context) draw_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)