예제 #1
0
func (v *mappingView) drawChannels(context *cairo.Context, r image.Rectangle) {
	for _, a := range v.arch {
		for _, pr := range a.Processes() {
			for _, c := range pr.UserObj().OutChannels() {
				link := c.Link()
				lpr := link.Process()
				la := lpr.Arch()
				if la.Name() != a.Name() {
					var a2 graph.ArchIf
					for _, a2 = range v.arch {
						if a2.UserObj() == la {
							break
						}
					}
					p1 := a.ChannelPort(c)
					p2 := a2.ChannelPort(link)
					if p1 == nil || p2 == nil {
						log.Printf("mappingView.drawChannels error: invalid nil port (%s - %s).\n", a.Name(), la.Name())
						continue
					}
					r, g, b, _ := graph.ColorOption(graph.NormalLine)
					context.SetLineWidth(2)
					context.SetSourceRGB(r, g, b)
					pos1 := p1.Position().Add(image.Point{5, 5})
					pos2 := p2.Position().Add(image.Point{5, 5})
					graph.DrawLine(context, pos1, pos2)
				}
			}
		}
	}
}
예제 #2
0
파일: ui.go 프로젝트: juanfgs/checkers
// draw the piece on the canvas
func (self *MainWindow) DrawSelector(cr *cairo.Context, x, y float64) {

	cr.SetSourceRGBA(0.2, 0.8, 0.2, 0.8)
	cr.SetLineWidth(5)
	cr.Rectangle(x*self.tileWidth, y*self.tileHeight, self.tileWidth, self.tileHeight)
	cr.Stroke()

}