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:
21
vlib/gg/gg.v
21
vlib/gg/gg.v
@ -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)
|
||||
|
Reference in New Issue
Block a user