Skip to content

Commit 8af6237

Browse files
authored
gg: fix width and height in draw_rounded_rect primitive (#9926)
1 parent e05da04 commit 8af6237

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

examples/2048/2048.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ fn (app &App) draw_tiles() {
623623
toffset := app.ui.tile_size + app.ui.padding_size
624624
tiles_size := mu.min(app.ui.window_width, app.ui.window_height) - app.ui.border_size * 2
625625
// Draw the padding around the tiles
626-
app.gg.draw_rounded_rect(xstart, ystart, tiles_size / 2, tiles_size / 2, tiles_size / 24,
626+
app.gg.draw_rounded_rect(xstart, ystart, tiles_size, tiles_size, tiles_size / 24,
627627
app.theme.padding_color)
628628
// Draw the actual tiles
629629
for y in 0 .. 4 {
@@ -640,7 +640,7 @@ fn (app &App) draw_tiles() {
640640
th := tw // square tiles, w == h
641641
xoffset := xstart + app.ui.padding_size + x * toffset + (app.ui.tile_size - tw) / 2
642642
yoffset := ystart + app.ui.padding_size + y * toffset + (app.ui.tile_size - th) / 2
643-
app.gg.draw_rounded_rect(xoffset, yoffset, tw / 2, th / 2, tw / 8, tile_color)
643+
app.gg.draw_rounded_rect(xoffset, yoffset, tw, th, tw / 8, tile_color)
644644
if tidx != 0 { // 0 == blank spot
645645
xpos := xoffset + tw / 2
646646
ypos := yoffset + th / 2

vlib/gg/gg.v

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ pub fn (ctx &Context) draw_rounded_rect(x f32, y f32, w f32, h f32, radius f32,
611611
sgl.v2f(lx, ly)
612612
}
613613
// right top
614-
mut rx := nx + 2 * width - r
614+
mut rx := nx + width - r
615615
mut ry := ny + r
616616
for i in rt .. int(segments) {
617617
theta = 2 * f32(math.pi) * f32(i) / segments
@@ -622,7 +622,7 @@ pub fn (ctx &Context) draw_rounded_rect(x f32, y f32, w f32, h f32, radius f32,
622622
}
623623
// right bottom
624624
mut rbx := rx
625-
mut rby := ny + 2 * height - r
625+
mut rby := ny + height - r
626626
for i in rb .. lb {
627627
theta = 2 * f32(math.pi) * f32(i) / segments
628628
xx = r * math.cosf(theta)
@@ -632,7 +632,7 @@ pub fn (ctx &Context) draw_rounded_rect(x f32, y f32, w f32, h f32, radius f32,
632632
}
633633
// left bottom
634634
mut lbx := lx
635-
mut lby := ny + 2 * height - r
635+
mut lby := ny + height - r
636636
for i in lb .. lt {
637637
theta = 2 * f32(math.pi) * f32(i) / segments
638638
xx = r * math.cosf(theta)
@@ -678,7 +678,7 @@ pub fn (ctx &Context) draw_empty_rounded_rect(x f32, y f32, w f32, h f32, radius
678678
sgl.v2f(xx + lx, yy + ly)
679679
}
680680
// right top
681-
mut rx := nx + 2 * width - r
681+
mut rx := nx + width - r
682682
mut ry := ny + r
683683
for i in rt .. int(segments) {
684684
theta = 2 * f32(math.pi) * f32(i) / segments
@@ -688,7 +688,7 @@ pub fn (ctx &Context) draw_empty_rounded_rect(x f32, y f32, w f32, h f32, radius
688688
}
689689
// right bottom
690690
mut rbx := rx
691-
mut rby := ny + 2 * height - r
691+
mut rby := ny + height - r
692692
for i in rb .. lb {
693693
theta = 2 * f32(math.pi) * f32(i) / segments
694694
xx = r * math.cosf(theta)
@@ -697,7 +697,7 @@ pub fn (ctx &Context) draw_empty_rounded_rect(x f32, y f32, w f32, h f32, radius
697697
}
698698
// left bottom
699699
mut lbx := lx
700-
mut lby := ny + 2 * height - r
700+
mut lby := ny + height - r
701701
for i in lb .. lt {
702702
theta = 2 * f32(math.pi) * f32(i) / segments
703703
xx = r * math.cosf(theta)

0 commit comments

Comments
 (0)