mirror of
https://github.com/maaslalani/confetty.git
synced 2024-11-21 23:26:40 +00:00
export spawn
This commit is contained in:
parent
70c180fb36
commit
fe126ff4df
@ -36,7 +36,7 @@ type model struct {
|
|||||||
system *simulation.System
|
system *simulation.System
|
||||||
}
|
}
|
||||||
|
|
||||||
func spawn(width, height int) []simulation.Particle {
|
func Spawn(width, height int) []simulation.Particle {
|
||||||
particles := []simulation.Particle{}
|
particles := []simulation.Particle{}
|
||||||
for i := 0; i < numParticles; i++ {
|
for i := 0; i < numParticles; i++ {
|
||||||
x := float64(width / 2)
|
x := float64(width / 2)
|
||||||
@ -66,7 +66,7 @@ func InitialModel() model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return model{system: &simulation.System{
|
return model{system: &simulation.System{
|
||||||
Particles: spawn(width, height),
|
Particles: Spawn(width, height),
|
||||||
Frame: simulation.Frame{
|
Frame: simulation.Frame{
|
||||||
Width: width,
|
Width: width,
|
||||||
Height: height,
|
Height: height,
|
||||||
@ -88,7 +88,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
case "ctrl+c", "q":
|
case "ctrl+c", "q":
|
||||||
return m, tea.Quit
|
return m, tea.Quit
|
||||||
}
|
}
|
||||||
m.system.Particles = spawn(m.system.Frame.Width, m.system.Frame.Height)
|
m.system.Particles = Spawn(m.system.Frame.Width, m.system.Frame.Height)
|
||||||
return m, nil
|
return m, nil
|
||||||
case frameMsg:
|
case frameMsg:
|
||||||
m.system.Update()
|
m.system.Update()
|
||||||
|
@ -37,7 +37,7 @@ type model struct {
|
|||||||
system *simulation.System
|
system *simulation.System
|
||||||
}
|
}
|
||||||
|
|
||||||
func spawn(width, height int) []simulation.Particle {
|
func Spawn(width, height int) []simulation.Particle {
|
||||||
color := lipgloss.Color(array.Sample(colors))
|
color := lipgloss.Color(array.Sample(colors))
|
||||||
v := float64(rand.Intn(10) + 20.0)
|
v := float64(rand.Intn(10) + 20.0)
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ func InitialModel() model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return model{system: &simulation.System{
|
return model{system: &simulation.System{
|
||||||
Particles: spawn(width, height),
|
Particles: Spawn(width, height),
|
||||||
Frame: simulation.Frame{
|
Frame: simulation.Frame{
|
||||||
Width: width,
|
Width: width,
|
||||||
Height: height,
|
Height: height,
|
||||||
@ -90,7 +90,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
case "ctrl+c", "q":
|
case "ctrl+c", "q":
|
||||||
return m, tea.Quit
|
return m, tea.Quit
|
||||||
}
|
}
|
||||||
m.system.Particles = spawn(m.system.Frame.Width, m.system.Frame.Height)
|
m.system.Particles = Spawn(m.system.Frame.Width, m.system.Frame.Height)
|
||||||
return m, nil
|
return m, nil
|
||||||
case frameMsg:
|
case frameMsg:
|
||||||
m.system.Update()
|
m.system.Update()
|
||||||
|
Loading…
Reference in New Issue
Block a user