fmt: fix alignment of struct init fields (#22025)

This commit is contained in:
yuyi 2024-08-11 14:11:24 +08:00 committed by GitHub
parent 99da5726db
commit c51d30bf53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
671 changed files with 18817 additions and 18787 deletions

View file

@ -21,12 +21,12 @@ pub fn (mut window Window) draw(_ voidptr) {
window.ctx.begin()
myconfig := gg.DrawImageConfig{
img: &window.image
img_id: window.image.id
img: &window.image
img_id: window.image.id
img_rect: gg.Rect{
x: 400 - window.image.width / 2
y: 300 - window.image.height / 2
width: window.image.width
x: 400 - window.image.width / 2
y: 300 - window.image.height / 2
width: window.image.width
height: window.image.height
}
rotation: f32(window.ctx.frame)
@ -42,7 +42,7 @@ pub fn (mut window Window) draw(_ voidptr) {
x: myconfig.img_rect.x + f32(math.sin(f32(window.ctx.frame) / 10.0) * 60)
y: myconfig.img_rect.y + f32(math.cos(f32(window.ctx.frame) / 10.0) * 60)
}
color: gx.Color{255, 0, 0, 255}
color: gx.Color{255, 0, 0, 255}
effect: .add
})
@ -54,7 +54,7 @@ pub fn (mut window Window) draw(_ voidptr) {
x: myconfig.img_rect.x + f32(math.sin(f32(window.ctx.frame) / 10.0) * 80)
y: myconfig.img_rect.y + f32(math.cos(f32(window.ctx.frame) / 10.0) * 80)
}
color: gx.Color{0, 255, 0, 255}
color: gx.Color{0, 255, 0, 255}
effect: .add
})
@ -66,7 +66,7 @@ pub fn (mut window Window) draw(_ voidptr) {
x: myconfig.img_rect.x + f32(math.sin(f32(window.ctx.frame) / 10.0) * 100)
y: myconfig.img_rect.y + f32(math.cos(f32(window.ctx.frame) / 10.0) * 100)
}
color: gx.Color{0, 0, 255, 255}
color: gx.Color{0, 0, 255, 255}
effect: .add
})
@ -78,7 +78,7 @@ pub fn (mut window Window) draw(_ voidptr) {
x: 50
y: 0
}
color: gx.Color{255, 0, 0, 255}
color: gx.Color{255, 0, 0, 255}
effect: .add
})
@ -89,7 +89,7 @@ pub fn (mut window Window) draw(_ voidptr) {
x: 50
y: 50
}
color: gx.Color{0, 255, 0, 255}
color: gx.Color{0, 255, 0, 255}
effect: .add
})
@ -100,7 +100,7 @@ pub fn (mut window Window) draw(_ voidptr) {
x: 50
y: 100
}
color: gx.Color{0, 0, 255, 255}
color: gx.Color{0, 0, 255, 255}
effect: .add
})
@ -112,12 +112,12 @@ fn main() {
window.ctx = gg.new_context(
window_title: 'Additive colors & image rotation'
width: 800
height: 600
user_data: window
bg_color: gx.gray
width: 800
height: 600
user_data: window
bg_color: gx.gray
// FNs
init_fn: window.init
init_fn: window.init
frame_fn: window.draw
)

View file

@ -33,14 +33,14 @@ mut:
fn main() {
mut app := &App{}
app.gg = gg.new_context(
width: win_width
height: win_height
width: win_width
height: win_height
create_window: true
window_title: 'Arcs and Slices'
user_data: app
bg_color: bg_color
frame_fn: on_frame
event_fn: on_event
window_title: 'Arcs and Slices'
user_data: app
bg_color: bg_color
frame_fn: on_frame
event_fn: on_event
)
app.gg.run()
}

View file

@ -14,12 +14,12 @@ mut:
fn main() {
mut app := &App{}
app.gg = gg.new_context(
bg_color: gx.rgb(174, 198, 255)
width: 600
height: 400
bg_color: gx.rgb(174, 198, 255)
width: 600
height: 400
window_title: 'Cubic Bézier curve'
frame_fn: frame
user_data: app
frame_fn: frame
user_data: app
)
app.gg.run()
}

View file

@ -34,12 +34,12 @@ fn main() {
anim: &Anim{}
}
app.gg = gg.new_context(
bg_color: gx.rgb(174, 198, 255)
width: 600
height: 400
bg_color: gx.rgb(174, 198, 255)
width: 600
height: 400
window_title: 'Animated cubic Bézier curve'
frame_fn: frame
user_data: app
frame_fn: frame
user_data: app
)
app.gg.run()
}

View file

@ -6,10 +6,10 @@ import sokol.sapp
fn main() {
mut ctx := gg.new_context(
bg_color: gx.white
bg_color: gx.white
window_title: 'Cursor'
frame_fn: frame
init_fn: init
frame_fn: frame
init_fn: init
)
ctx.run()
}

View file

@ -37,12 +37,12 @@ fn main() {
fn rain(mut app App) {
app.ctx = gg.new_context(
bg_color: gx.rgb(0, 0, 0)
width: app.screen_size.width
height: app.screen_size.height
user_data: app
bg_color: gx.rgb(0, 0, 0)
width: app.screen_size.width
height: app.screen_size.height
user_data: app
window_title: 'Digital Rain'
init_fn: fn (mut app App) {
init_fn: fn (mut app App) {
gg.toggle_fullscreen()
}
event_fn: fn (event &gg.Event, mut app App) {
@ -99,9 +99,9 @@ fn vprintln(msg string) {
fn calc_sizes(mut app App) {
app.screen_size = gg.window_size()
app.ctx.set_text_cfg(gx.TextCfg{
size: font_size
size: font_size
color: gx.green
mono: true
mono: true
})
// figure out how big character is in pixels
// Pad it or it looks too squashed
@ -139,7 +139,7 @@ fn draw_rain_column(rc RainColumn, app App) {
}
at_head := i == rc.head - 1
cfg := gx.TextCfg{
size: font_size
size: font_size
color: gg.Color{
r: if at_head { u8(255) } else { 0 }
g: 255
@ -163,8 +163,8 @@ fn draw_rain_column(rc RainColumn, app App) {
fn random_rain_column(max_col int, max_height int) RainColumn {
min_len := 6
mut rc := RainColumn{
col: rand.int_in_range(0, max_col) or { 0 }
len: rand.int_in_range(min_len, max_height / 4 * 3) or { min_len }
col: rand.int_in_range(0, max_col) or { 0 }
len: rand.int_in_range(min_len, max_height / 4 * 3) or { min_len }
drops: []u8{cap: max_height}
}
for _ in 0 .. max_height {

View file

@ -19,17 +19,17 @@ fn main() {
mut font_path := os.resource_abs_path(os.join_path('..', 'assets', 'fonts', 'RobotoMono-Regular.ttf'))
mut app := &App{}
app.gg = gg.new_context(
bg_color: gx.rgb(174, 198, 255)
width: 600
height: 400
bg_color: gx.rgb(174, 198, 255)
width: 600
height: 400
window_title: 'Drag and drop'
frame_fn: frame
font_path: font_path
user_data: app
event_fn: my_event_manager
frame_fn: frame
font_path: font_path
user_data: app
event_fn: my_event_manager
// drag & drop
enable_dragndrop: true
max_dropped_files: max_files
enable_dragndrop: true
max_dropped_files: max_files
max_dropped_file_path_length: 2048
)
app.gg.run()
@ -52,7 +52,7 @@ fn frame(mut app App) {
mut txt_conf := gx.TextCfg{
color: gx.black
align: .left
size: int(text_size * app.gg.scale + 0.5)
size: int(text_size * app.gg.scale + 0.5)
}
app.gg.draw_text(12, 12, text, txt_conf)

View file

@ -28,12 +28,12 @@ fn main() {
pixels: pixels
}
app.gg = gg.new_context(
bg_color: gx.rgb(174, 198, 255)
width: 100
height: 100
bg_color: gx.rgb(174, 198, 255)
width: 100
height: 100
window_title: 'Set Pixels'
frame_fn: frame
user_data: app
frame_fn: frame
user_data: app
)
app.gg.run()
}

View file

@ -63,14 +63,14 @@ fn main() {
app.buf << []int{len: width, init: 36} // white fire base
app.gg = gg.new_context(
event_fn: event
frame_fn: frame
init_fn: retile
event_fn: event
frame_fn: frame
init_fn: retile
window_title: 'Fire Animation'
user_data: app
bg_color: palette[0]
width: win_width
height: win_height
user_data: app
bg_color: palette[0]
width: win_width
height: win_height
)
app.gg.run()
}

View file

@ -75,8 +75,8 @@ fn (mut state AppState) update() {
for start := 0; start < pheight; start += chunk_height {
chunk_channel <- MandelChunk{
cview: cview
ymin: start
ymax: start + chunk_height
ymin: start
ymax: start + chunk_height
}
nchunks++
}
@ -225,17 +225,17 @@ fn graphics_keydown(code gg.KeyCode, mod gg.Modifier, mut state AppState) {
fn main() {
mut state := &AppState{}
state.gg = gg.new_context(
width: 800
height: 600
width: 800
height: 600
create_window: true
window_title: 'The Mandelbrot Set'
init_fn: graphics_init
frame_fn: graphics_frame
click_fn: graphics_click
move_fn: graphics_move
keydown_fn: graphics_keydown
scroll_fn: graphics_scroll
user_data: state
window_title: 'The Mandelbrot Set'
init_fn: graphics_init
frame_fn: graphics_frame
click_fn: graphics_click
move_fn: graphics_move
keydown_fn: graphics_keydown
scroll_fn: graphics_scroll
user_data: state
)
spawn state.update()
state.gg.run()

View file

@ -47,10 +47,10 @@ fn frame(mut ctx gg.Context) {
fn main() {
mut ctx := gg.new_context(
window_title: 'Many Thousands of Circles'
bg_color: gx.black
width: 600
height: 400
frame_fn: frame
bg_color: gx.black
width: 600
height: 400
frame_fn: frame
)
ctx.run()
}

View file

@ -2,13 +2,13 @@ import gg
gg.start(
window_title: 'Hello'
bg_color: gg.Color{240, 240, 128, 255}
width: 320
height: 240
frame_fn: fn (ctx &gg.Context) {
bg_color: gg.Color{240, 240, 128, 255}
width: 320
height: 240
frame_fn: fn (ctx &gg.Context) {
ctx.begin()
ctx.draw_text(40, 100, 'GG frame: ${ctx.frame:06}',
size: 30
size: 30
color: gg.Color{50, 50, 255, 255}
)
ctx.show_fps()

View file

@ -76,15 +76,15 @@ fn main() {
// setting values of app
app.gg = gg.new_context(
bg_color: gx.black // background color
width: window_width // window width
height: window_height // window height
bg_color: gx.black // background color
width: window_width // window width
height: window_height // window height
create_window: true // this will create a different window
window_title: 'A* Path finding algorithm visusalizer' // title of the window
frame_fn: frame // this is frame function update the frame
event_fn: on_event // it calls on every event
init_fn: init_images // run at start of application
user_data: app // store user data
window_title: 'A* Path finding algorithm visusalizer' // title of the window
frame_fn: frame // this is frame function update the frame
event_fn: on_event // it calls on every event
init_fn: init_images // run at start of application
user_data: app // store user data
)
mut grid := initialise_grid() // initialize the grid variable and populate the matrix with each cell as empty
app.grid = grid // set grid to app attribute so you can access it by just passing app variable or with method of app
@ -244,15 +244,15 @@ fn initialise_grid() [][]Cell {
for i := 0; i < nrows; i++ {
for j := 0; j < nrows; j++ {
grid[i][j] = &Cell{
row: i
col: j
row: i
col: j
width: gap
pos: &Point{
pos: &Point{
x: j * gap
y: i * gap
}
color: gx.white
flag: 0
flag: 0
}
}
}
@ -331,7 +331,7 @@ fn astar_path_finding(mut app App, mut grid [][]Cell, start Point, end Point) {
f_score[start.x][start.y] = g_score[start.x][start.y] + hf(start, end)
priority_queue.insert(&Node{
f_score: f_score[start.x][start.y]
cell: &Point{
cell: &Point{
x: start.x
y: start.y
}
@ -362,8 +362,8 @@ fn astar_path_finding(mut app App, mut grid [][]Cell, start Point, end Point) {
if !(neighbor.x == start.x && neighbor.y == start.y) {
priority_queue.insert(&Node{
f_score: g_score[neighbor.x][neighbor.y] + hf(neighbor, end)
cell: neighbor
count: curr_node.count + 1
cell: neighbor
count: curr_node.count + 1
})
came_from[neighbor.x][neighbor.y] = curr_pos
set_cell_type(mut grid, neighbor.x, neighbor.y, 'open')

View file

@ -5,11 +5,11 @@ import gx
fn main() {
mut context := gg.new_context(
bg_color: gx.rgb(174, 198, 255)
width: 600
height: 400
bg_color: gx.rgb(174, 198, 255)
width: 600
height: 400
window_title: 'Polygons'
frame_fn: frame
frame_fn: frame
)
context.run()
}

View file

@ -50,13 +50,13 @@ fn graphics_frame(mut state AppState) {
fn main() {
mut state := &AppState{}
state.gg = gg.new_context(
width: 800
height: 600
width: 800
height: 600
create_window: true
window_title: 'Random Static'
init_fn: graphics_init
frame_fn: graphics_frame
user_data: state
window_title: 'Random Static'
init_fn: graphics_init
frame_fn: graphics_frame
user_data: state
)
spawn state.update()
state.gg.run()

View file

@ -67,14 +67,14 @@ fn main() {
font_path = 'fonts/RobotoMono-Regular.ttf'
}
app.gg = gg.new_context(
width: win_width
height: win_height
width: win_width
height: win_height
create_window: true
window_title: 'Raven text'
user_data: app
bg_color: bg_color
frame_fn: frame
font_path: font_path // window_user_ptr: ctx
window_title: 'Raven text'
user_data: app
bg_color: bg_color
frame_fn: frame
font_path: font_path // window_user_ptr: ctx
// native_rendering: true
)
app.gg.run()

View file

@ -55,13 +55,13 @@ fn main() {
calc_deltas(mut app)
app.ctx = gg.new_context(
user_data: &app
user_data: &app
window_title: 'Raycaster Demo'
width: 1024
height: 512
bg_color: gx.gray
frame_fn: draw
event_fn: handle_events
width: 1024
height: 512
bg_color: gx.gray
frame_fn: draw
event_fn: handle_events
)
app.ctx.run()
@ -217,7 +217,7 @@ fn draw_rays_and_walls(app App) {
wall_offset := max_wall_height / 2 - wall_height / 2
app.ctx.draw_line_with_config(step * line_thickeness + offset_3d_view, wall_offset,
step * line_thickeness + offset_3d_view, wall_offset + wall_height, gg.PenConfig{
color: color
color: color
thickness: line_thickeness
})
// step to next ray angle

View file

@ -16,14 +16,14 @@ mut:
fn main() {
mut app := &App{}
app.gg = gg.new_context(
bg_color: gx.white
width: win_width
height: win_height
bg_color: gx.white
width: win_width
height: win_height
create_window: true
window_title: 'Rectangles'
frame_fn: frame
user_data: app
init_fn: init_images
window_title: 'Rectangles'
frame_fn: frame
user_data: app
init_fn: init_images
)
mut logo_path := os.resource_abs_path(os.join_path('..', 'assets', 'logo.png'))
app.image = app.gg.create_image(logo_path)!.id

View file

@ -43,12 +43,12 @@ fn main() {
mut window := &Window{}
window.ctx = gg.new_context(
window_title: 'Rotating V logo'
bg_color: gx.light_green
width: 800
height: 800
user_data: window
init_fn: window.init
frame_fn: window.draw
bg_color: gx.light_green
width: 800
height: 800
user_data: window
init_fn: window.init
frame_fn: window.draw
)
window.ctx.run()
}

View file

@ -8,12 +8,12 @@ fn main() {
scount := os.args[1] or { '2' }.int()
println('> sample count: ${scount}')
mut ctx := gg.new_context(
bg_color: gx.white
bg_color: gx.white
window_title: 'sample_count: ${scount}'
width: 320
height: 240
width: 320
height: 240
sample_count: scount
frame_fn: fn (mut ctx gg.Context) {
frame_fn: fn (mut ctx gg.Context) {
ctx.begin()
ctx.draw_rounded_rect_empty(110, 70, 100, 100, 10, gx.blue)
ctx.draw_circle_empty(160, 120, 100, gx.red)

View file

@ -19,11 +19,11 @@ mut k := 497
mut scale := 200
gg.start(
window_title: 'Spirograph'
bg_color: background
width: 900
height: 950
bg_color: background
width: 900
height: 950
sample_count: 2
frame_fn: fn [mut k, mut scale] (mut ctx gg.Context) {
frame_fn: fn [mut k, mut scale] (mut ctx gg.Context) {
wsize := gg.window_size()
ctx.begin()
ctx.draw_rect_filled(0, 0, wsize.width, wsize.height, gg.Color{10, 1, 30, 60})

View file

@ -43,18 +43,18 @@ mut:
fn main() {
mut app := &App{
stars: []Star{len: max_stars}
stars: []Star{len: max_stars}
v_letters: []VLetter{len: max_v_letters}
}
app.gg = gg.new_context(
bg_color: gx.black
width: win_width
height: win_height
bg_color: gx.black
width: win_width
height: win_height
create_window: true
window_title: 'Star Vield'
frame_fn: frame
init_fn: init_images
user_data: app
window_title: 'Star Vield'
frame_fn: frame
init_fn: init_images
user_data: app
)
for i in 0 .. max_stars {
app.stars[i].x = rand.f32_in_range(-200.0, 200.0) or { -200.0 }

View file

@ -24,14 +24,14 @@ mut:
fn main() {
mut app := &App{}
app.gg = gg.new_context(
width: win_width
height: win_height
width: win_width
height: win_height
create_window: true
window_title: 'Counter'
user_data: app
bg_color: bg_color
frame_fn: frame
init_fn: init
window_title: 'Counter'
user_data: app
bg_color: bg_color
frame_fn: frame
init_fn: init
)
app.gg.run()
}