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

gg: add scaling to draw_convex_poly (#11276)

This commit is contained in:
Benjamin Stigsen 2021-08-23 12:38:29 +02:00 committed by GitHub
parent f87a638ddc
commit 76205cff2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -640,16 +640,16 @@ pub fn (ctx &Context) draw_convex_poly(points []f32, c gx.Color) {
sgl.c4b(c.r, c.g, c.b, c.a) sgl.c4b(c.r, c.g, c.b, c.a)
sgl.begin_triangle_strip() sgl.begin_triangle_strip()
x0 := points[0] x0 := points[0] * ctx.scale
y0 := points[1] y0 := points[1] * ctx.scale
for i in 1 .. (len / 2 + 1) { for i in 1 .. (len / 2 + 1) {
sgl.v2f(x0, y0) sgl.v2f(x0, y0)
sgl.v2f(points[i * 4 - 2], points[i * 4 - 1]) sgl.v2f(points[i * 4 - 2] * ctx.scale, points[i * 4 - 1] * ctx.scale)
sgl.v2f(points[i * 4], points[i * 4 + 1]) sgl.v2f(points[i * 4] * ctx.scale, points[i * 4 + 1] * ctx.scale)
} }
if len % 2 == 0 { if len % 2 == 0 {
sgl.v2f(points[2 * len - 2], points[2 * len - 1]) sgl.v2f(points[2 * len - 2] * ctx.scale, points[2 * len - 1] * ctx.scale)
} }
sgl.end() sgl.end()
} }