This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Shortest GUI program written in Golang. | |
// It displays a window and exits after 5 seconds. | |
package main | |
import ( | |
"time" | |
"golang.org/x/exp/shiny/driver" | |
"golang.org/x/exp/shiny/screen" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FS0:\EFI\ubuntu\shimx64.efi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (bt *BlinkyTape) playPattern(p Pattern, delay time.Duration) { | |
bt.clear() | |
L: | |
for _, frame := range p { | |
bt.setFrame(frame) | |
if err := bt.render(); err != nil { | |
log.Fatalf("render error: %s\n", err) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (bt *BlinkyTape) animation(p Pattern, repeat int, delay time.Duration) { | |
bt.status = Running | |
L: | |
for i := 0; repeat < 0 || i < repeat; i++ { | |
select { | |
case <-bt.stop: | |
break L | |
default: | |
go bt.playPattern(p, delay) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (bt *BlinkyTape) animation(p Pattern, repeat int, delay time.Duration) { | |
bt.status = Running | |
innerLoop := func() bool { | |
select { | |
case <-bt.stop: | |
return false | |
default: | |
go bt.playPattern(p, delay) | |
<-bt.next |
NewerOlder