예제 #1
0
파일: shape.go 프로젝트: juanman2/dot-emacs
func newRasterPlay() *rasterPlay {
	obj := new(rasterPlay)
	obj.points = make([]rpoint, 0, 100) // expansion later
	obj.moved = make(chan moveEvent)
	obj.raster.SetFill(&image.Uniform{image.AlphaMultiply(blue, 0x8000)})
	obj.c = canvas.NewCanvas(nil, cvs.Bbox())
	obj.colValue = values.NewValue(nil)
	obj.colValue.Set(image.Black)
	obj.HandlerItem = obj.c
	obj.c.AddItem(&obj.raster)
	go obj.listener()
	return obj
}
예제 #2
0
파일: bounce.go 프로젝트: zxpbenson/rog-go
func sliderProc() {
	val := values.NewValue(float64(0.0), nil)
	window.AddItem(canvas.NewSlider(image.Rect(10, 10, 100, 40), image.White, blue, val))
	window.AddItem(canvas.NewSlider(image.Rect(15, 35, 100, 70), image.White, setAlpha(red, 128), val))
	window.Flush()
	rval := values.Transform(val, values.UnitFloat64ToRangedFloat64(0.001e9, 0.1e9))
	timeText := canvas.NewText(
		image.Pt(10, 80), canvas.N|canvas.W, "", defaultFont(), 12, values.Transform(rval, values.Float64Multiply(1e-6).Combine(values.Float64ToString("%6.2gms", "%gms"))))
	window.AddItem(timeText)
	g := rval.Getter()
	for {
		x, ok := g.Get()
		if !ok {
			break
		}
		sleepTime = time.Duration(x.(float64))
	}
}
예제 #3
0
파일: shape.go 프로젝트: juanman2/dot-emacs
func (obj *rasterPlay) AddPoint(new bool, p image.Point) {
	value := values.NewValue(p)
	cp := NewControlPoint(value, obj.colValue)
	n := len(obj.points)
	obj.points = obj.points[0 : n+1]
	obj.points[n] = rpoint{new, pixel2fixPoint(p)}
	go func() {
		for xp := range value.Iter() {
			obj.moved <- moveEvent{n, xp.(image.Point)}
		}
	}()
	obj.c.Atomically(func(flush canvas.FlushFunc) {
		r := obj.raster.Bbox()
		obj.makeOutline()
		flush(r, nil)
		flush(obj.raster.Bbox(), nil)
	})
	obj.c.AddItem(cp)
}