Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gg: fix #19470 - draw_rounded_rect_empty #19552

Merged
merged 3 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions vlib/gg/draw.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,11 @@ pub fn (ctx &Context) draw_rounded_rect_empty(x f32, y f32, w f32, h f32, radius
sgl.v2f(rtx + r, rty)
sgl.v2f(rtx + r, rby)
// bottom
sgl.v2f(lbx, lby + r)
sgl.v2f(rbx, rby + r)
sgl.v2f(lbx, lby + r - 1)
sgl.v2f(rbx, rby + r - 1)
// left
sgl.v2f(sx, lty)
sgl.v2f(sx, lby)
sgl.v2f(sx + 1, lty)
sgl.v2f(sx + 1, lby)
sgl.end()
}

Expand Down
34 changes: 34 additions & 0 deletions vlib/gg/testdata/draw_rounded_rect_empty.vv
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module main

import gg
import gx

fn main() {
mut context := gg.new_context(
width: 325
height: 275
window_title: 'Rounded Rectangles'
frame_fn: frame
)
context.run()
}

fn frame(mut ctx gg.Context) {
ctx.begin()
// these should be rounded rectangles
ctx.draw_rounded_rect_empty(10, 10, 50, 100, 5, gx.blue)
ctx.draw_rounded_rect_empty(25, 25, 50, 100, 15, gx.yellow)
ctx.draw_rounded_rect_empty(50, 50, 50, 100, 50, gx.red)
ctx.draw_rounded_rect_empty(75, 75, 50, 100, 100, gx.green)
ctx.draw_rounded_rect_empty(100, 100, 50, 100, 1000, gx.white)
ctx.draw_rounded_rect_empty(110, 10, 100, 50, 5, gx.blue)
ctx.draw_rounded_rect_empty(125, 25, 100, 50, 15, gx.yellow)
ctx.draw_rounded_rect_empty(150, 50, 100, 50, 50, gx.red)
ctx.draw_rounded_rect_empty(175, 75, 100, 50, 100, gx.green)
ctx.draw_rounded_rect_empty(200, 100, 100, 50, 1000, gx.white)
// this should be a perfect circle
ctx.draw_rounded_rect_empty(10, 200, 50, 50, 1000, gx.magenta)
// this should be a perfect square
ctx.draw_rounded_rect_empty(250, 200, 50, 50, 0, gx.cyan)
ctx.end()
}
Loading