本文整理汇总了Golang中github.com/andew42/brightlight/framebuffer.Segment类的典型用法代码示例。如果您正苦于以下问题:Golang Segment类的具体用法?Golang Segment怎么用?Golang Segment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Segment类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: animateNextFrame
func (sc *staticColour) animateNextFrame(frameCount int, frame framebuffer.Segment) {
if frameCount == 0 {
for s := uint(0); s < frame.Len(); s++ {
frame.Set(s, sc.colour)
}
}
}
示例2: animateNextFrame
func (s *sweetshop) animateNextFrame(frameCount int, frame framebuffer.Segment) {
if time.Now().Sub(s.changeTime) > 0 {
// Set next change time
s.changeTime = time.Now().Add(s.period)
// Refresh the random colours
for i := uint(0); i < frame.Len(); i++ {
frame.Set(i, framebuffer.NewRgbFromInt(rand.Int()&(1<<24-1)))
}
}
}
示例3: animateNextFrame
func (s *christmas) animateNextFrame(frameCount int, frame framebuffer.Segment) {
// Time to change lights
if time.Now().Sub(s.changeTime) > 0 {
s.changeTime = time.Now().Add(s.period)
// Move on to next light colour
if s.nextColour == uint(len(s.lightColours))-1 {
s.nextColour = 0
} else {
s.nextColour++
}
// Set each LED appropriately
off := framebuffer.NewRgbFromInt(0)
for i := uint(0); i < frame.Len(); i++ {
// Which colour index should this be
c := (i / s.lightSize) % uint(len(s.lightColours))
// Either turn colour on or turn LED off
if c == s.nextColour {
frame.Set(i, s.lightColours[s.nextColour])
} else {
frame.Set(i, off)
}
}
}
}
示例4: animateNextFrame
func (p *pulse) animateNextFrame(frameCount int, frame framebuffer.Segment) {
if p.up {
if p.val != 255 {
p.val++
} else {
p.up = false
p.val--
}
} else {
if p.val != 0 {
p.val--
} else {
p.up = true
p.val++
}
}
colour := framebuffer.NewRgb(p.val, p.val, p.val)
for s := uint(0); s < frame.Len(); s++ {
frame.Set(s, colour)
}
}
示例5: animateNextFrame
func (c *candle) animateNextFrame(frameCount int, frame framebuffer.Segment) {
// Yellow
r := byte(rand.Intn(120) + 135)
frame.Set(0, framebuffer.NewRgb(r, r, 0))
// Red
r = byte(rand.Intn(120) + 135)
frame.Set(1, framebuffer.NewRgb(r, 0, 0))
// Yellow
r = byte(rand.Intn(120) + 135)
frame.Set(2, framebuffer.NewRgb(r, r, 0))
}
示例6: animateNextFrame
func (r *rainbow) animateNextFrame(frameCount int, frame framebuffer.Segment) {
hue := r.startDegree
hueIncrement := 360.0 / float32(frame.Len())
for i := uint(0); i < frame.Len(); i++ {
frame.Set(i, framebuffer.NewRgbFromHsl(uint(hue), 100, 50))
hue += hueIncrement
}
r.startDegree += r.degreesPerFrame
if r.startDegree > 360 {
r.startDegree -= 360
}
}
示例7: animateNextFrame
func (c *cylon) animateNextFrame(frameCount int, frame framebuffer.Segment) {
frame.Set(c.pos, framebuffer.NewRgb(0, 0, 0))
if c.dir {
if c.pos == frame.Len()-1 {
c.dir = false
} else {
c.pos++
}
} else {
if c.pos == 0 {
c.dir = true
} else {
c.pos--
}
}
frame.Set(c.pos, framebuffer.NewRgb(255, 0, 0))
}
示例8: animateNextFrame
func (r *runner) animateNextFrame(frameCount int, frame framebuffer.Segment) {
frame.Set(r.pos, framebuffer.NewRgb(0, 0, 0))
r.pos = nextPos(r.pos, frame.Len())
frame.Set(r.pos, r.colour)
}