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

examples/2048: make tiles have rounded corners (#7763)

This commit is contained in:
spaceface 2021-01-01 12:04:51 +01:00 committed by GitHub
parent b6136f9f8f
commit 480d78de2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -649,7 +649,7 @@ fn (app &App) draw_tiles() {
toffset := app.ui.tile_size + app.ui.padding_size
tiles_size := min(app.ui.window_width, app.ui.window_height) - app.ui.border_size * 2
// Draw the padding around the tiles
app.gg.draw_rect(xstart, ystart, tiles_size, tiles_size, app.theme.padding_color)
app.gg.draw_rounded_rect(xstart, ystart, tiles_size / 2, tiles_size / 2, tiles_size / 24, app.theme.padding_color)
// Draw the actual tiles
for y in 0 .. 4 {
for x in 0 .. 4 {
@ -665,7 +665,7 @@ fn (app &App) draw_tiles() {
th := tw // square tiles, w == h
xoffset := xstart + app.ui.padding_size + x * toffset + (app.ui.tile_size - tw) / 2
yoffset := ystart + app.ui.padding_size + y * toffset + (app.ui.tile_size - th) / 2
app.gg.draw_rect(xoffset, yoffset, tw, th, tile_color)
app.gg.draw_rounded_rect(xoffset, yoffset, tw / 2, th / 2, tw / 8, tile_color)
if tidx != 0 { // 0 == blank spot
xpos := xoffset + tw / 2
ypos := yoffset + th / 2
@ -962,6 +962,7 @@ fn main() {
bg_color: app.theme.bg_color
width: default_window_width
height: default_window_height
sample_count: 8 // higher quality curves
create_window: true
window_title: window_title
frame_fn: frame

View File

@ -54,6 +54,7 @@ pub:
// wait_events bool // set this to true for UIs, to save power
fullscreen bool
scale f32 = 1.0
sample_count int
// vid needs this
// init_text bool
font_path string
@ -253,6 +254,7 @@ pub fn new_context(cfg Config) &Context {
html5_canvas_name: cfg.window_title.str
width: cfg.width
height: cfg.height
sample_count: cfg.sample_count
high_dpi: true
fullscreen: cfg.fullscreen
}