examples/2048: make tiles have rounded corners (#7763)
parent
b6136f9f8f
commit
480d78de2e
|
@ -649,7 +649,7 @@ fn (app &App) draw_tiles() {
|
||||||
toffset := app.ui.tile_size + app.ui.padding_size
|
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
|
tiles_size := min(app.ui.window_width, app.ui.window_height) - app.ui.border_size * 2
|
||||||
// Draw the padding around the tiles
|
// 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
|
// Draw the actual tiles
|
||||||
for y in 0 .. 4 {
|
for y in 0 .. 4 {
|
||||||
for x in 0 .. 4 {
|
for x in 0 .. 4 {
|
||||||
|
@ -665,7 +665,7 @@ fn (app &App) draw_tiles() {
|
||||||
th := tw // square tiles, w == h
|
th := tw // square tiles, w == h
|
||||||
xoffset := xstart + app.ui.padding_size + x * toffset + (app.ui.tile_size - tw) / 2
|
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
|
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
|
if tidx != 0 { // 0 == blank spot
|
||||||
xpos := xoffset + tw / 2
|
xpos := xoffset + tw / 2
|
||||||
ypos := yoffset + th / 2
|
ypos := yoffset + th / 2
|
||||||
|
@ -962,6 +962,7 @@ fn main() {
|
||||||
bg_color: app.theme.bg_color
|
bg_color: app.theme.bg_color
|
||||||
width: default_window_width
|
width: default_window_width
|
||||||
height: default_window_height
|
height: default_window_height
|
||||||
|
sample_count: 8 // higher quality curves
|
||||||
create_window: true
|
create_window: true
|
||||||
window_title: window_title
|
window_title: window_title
|
||||||
frame_fn: frame
|
frame_fn: frame
|
||||||
|
|
|
@ -54,6 +54,7 @@ pub:
|
||||||
// wait_events bool // set this to true for UIs, to save power
|
// wait_events bool // set this to true for UIs, to save power
|
||||||
fullscreen bool
|
fullscreen bool
|
||||||
scale f32 = 1.0
|
scale f32 = 1.0
|
||||||
|
sample_count int
|
||||||
// vid needs this
|
// vid needs this
|
||||||
// init_text bool
|
// init_text bool
|
||||||
font_path string
|
font_path string
|
||||||
|
@ -253,6 +254,7 @@ pub fn new_context(cfg Config) &Context {
|
||||||
html5_canvas_name: cfg.window_title.str
|
html5_canvas_name: cfg.window_title.str
|
||||||
width: cfg.width
|
width: cfg.width
|
||||||
height: cfg.height
|
height: cfg.height
|
||||||
|
sample_count: cfg.sample_count
|
||||||
high_dpi: true
|
high_dpi: true
|
||||||
fullscreen: cfg.fullscreen
|
fullscreen: cfg.fullscreen
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue