当前位置: 首页>>代码示例>>Golang>>正文


Golang Segment.Set方法代码示例

本文整理汇总了Golang中github.com/andew42/brightlight/framebuffer.Segment.Set方法的典型用法代码示例。如果您正苦于以下问题:Golang Segment.Set方法的具体用法?Golang Segment.Set怎么用?Golang Segment.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/andew42/brightlight/framebuffer.Segment的用法示例。


在下文中一共展示了Segment.Set方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: 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)
			}
		}
	}
}
开发者ID:andew42,项目名称:brightlight,代码行数:29,代码来源:christmas.go

示例2: 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)
		}
	}
}
开发者ID:andew42,项目名称:brightlight,代码行数:8,代码来源:staticcolour.go

示例3: 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)))
		}
	}
}
开发者ID:andew42,项目名称:brightlight,代码行数:13,代码来源:sweetshop.go

示例4: 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
	}
}
开发者ID:andew42,项目名称:brightlight,代码行数:13,代码来源:rainbow.go

示例5: 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))
}
开发者ID:andew42,项目名称:brightlight,代码行数:20,代码来源:cylon.go

示例6: 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)
	}
}
开发者ID:andew42,项目名称:brightlight,代码行数:23,代码来源:pulse.go

示例7: 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))
}
开发者ID:andew42,项目名称:brightlight,代码行数:12,代码来源:candle.go

示例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)
}
开发者ID:andew42,项目名称:brightlight,代码行数:6,代码来源:runner.go


注:本文中的github.com/andew42/brightlight/framebuffer.Segment.Set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。