Esempio n. 1
0
func fnPaint(ev *ui.PaintEvent, w *ui.Widget) {
	p := ui.NewPainter()
	defer p.Close()
	p.Begin(w)
	p.DrawPoint(ui.Pt(10, 10))
	p.DrawLine(ui.Pt(10, 10), ui.Pt(100, 100))
	p.End()
}
Esempio n. 2
0
func drawPlace(e *ui.PaintEvent, w *ui.Widget) {
	p := ui.NewPainter()
	defer p.Close()
	p.Begin(w)

	pen := ui.NewPen()
	pen.SetColor(color.RGBA{0, 0, 0, 0})

	ft := p.Font()
	ft.SetPixelSize(CELL_WIDTH * 8 / 10)
	p.SetFont(ft)
	for i := 0; i <= len(placeCells); i++ {
		if i%3 == 0 {
			pen.SetWidth(3)
		} else {
			pen.SetWidth(1)
		}
		p.SetPen(pen)
		p.DrawLine(ui.Pt(0, i*CELL_WIDTH), ui.Pt(9*CELL_WIDTH, i*CELL_WIDTH))
		p.DrawLine(ui.Pt(i*CELL_WIDTH, 0), ui.Pt(i*CELL_WIDTH, 9*CELL_WIDTH))
	}

	var pt ui.Point
	for y := 0; y < 9; y++ {
		for x := 0; x < 9; x++ {
			if placeCells[y][x].num != 0 {
				pt.X = x*CELL_WIDTH + 4 // TODO display position adjustment
				pt.Y = (y+1)*CELL_WIDTH - 4
				if placeCells[y][x].kind == CELL_KIND_ERROR {
					pen.SetColor(color.RGBA{255, 0, 0, 0})
				} else if placeCells[y][x].kind == CELL_KIND_FIXED {
					pen.SetColor(color.RGBA{0, 0, 0, 0})
				} else {
					pen.SetColor(color.RGBA{0, 0, 255, 0})
				}
				p.SetPen(pen)
				p.DrawText(pt, fmt.Sprintf("%c", placeCells[y][x].num+'0'))
			}
		}
	}
	if cursorx != -1 {
		var rc ui.Rect
		pen.SetColor(color.RGBA{200, 0, 0, 0})
		pen.SetWidth(3)

		p.SetPen(pen)
		rc.X = cursorx * CELL_WIDTH
		rc.Y = cursory * CELL_WIDTH
		rc.Width = CELL_WIDTH
		rc.Height = CELL_WIDTH
		p.DrawRect(rc)
	}
	p.End()
}
Esempio n. 3
0
func (p *MyWidget) paintEvent(e *ui.PaintEvent) {
	paint := ui.NewPainter()
	defer paint.Close()

	paint.Begin(p)
	paint.SetFont(p.font)
	paint.DrawLines(p.line)
	paint.SetFont(p.font)
	paint.DrawText(ui.Pt(100, 100), "draw test")
	for _, v := range p.lines {
		//paint.DrawLines(v)
		paint.DrawPolyline(v)
	}
	paint.End()
	runtime.GC()
}