add flag for smooth transitions

This commit is contained in:
filifa 2024-09-04 20:04:47 -05:00
parent a53928ef5e
commit 2b8eaeee49
2 changed files with 9 additions and 6 deletions

View File

@ -27,6 +27,7 @@ import (
var preset string
var scriptPath string
var transition bool
type script []string
@ -68,9 +69,9 @@ func handleWindowEvent(event *sdl.WindowEvent, m *milkDropWindow) {
func handleKeyboardEvent(event *sdl.KeyboardEvent, m *milkDropWindow) {
scancode := event.Keysym.Scancode
if event.Type == sdl.KEYDOWN && scancode == sdl.SCANCODE_RIGHT && event.Repeat == 0 {
m.nextPreset()
m.nextPreset(transition)
} else if event.Type == sdl.KEYDOWN && scancode == sdl.SCANCODE_LEFT && event.Repeat == 0 {
m.prevPreset()
m.prevPreset(transition)
}
}
@ -167,6 +168,8 @@ func init() {
// Cobra also supports local flags, which will only run
// when this action is called directly.
rootCmd.Flags().BoolVarP(&transition, "transition", "t", false, "smoothly transition between presets")
rootCmd.Flags().StringVarP(&preset, "preset", "p", "", "preset file to use")
rootCmd.Flags().StringVarP(&scriptPath, "script", "s", "", "script file to use")

View File

@ -51,14 +51,14 @@ func (m *milkDropWindow) setupPresets(presets []string) {
}
}
func (m *milkDropWindow) nextPreset() {
func (m *milkDropWindow) nextPreset(smooth bool) {
m.preset = m.preset.Next()
m.loadPreset(true)
m.loadPreset(smooth)
}
func (m *milkDropWindow) prevPreset() {
func (m *milkDropWindow) prevPreset(smooth bool) {
m.preset = m.preset.Prev()
m.loadPreset(true)
m.loadPreset(smooth)
}
func newMilkDropWindow(width, height int32, presets []string) (*milkDropWindow, error) {