예제 #1
0
파일: draw.go 프로젝트: dmuse/go.uik
func ClearPaint(gc draw2d.GraphicContext) {
	if true {
		gc.Clear()
		gc.SetFillColor(color.RGBA{155, 0, 0, 255})
		gc.Fill()
	}
}
예제 #2
0
파일: main.go 프로젝트: henkman/w32uptime
func (this ArrowButton) Paint(gc draw2d.GraphicContext) {
	gc.SetFillColor(color.RGBA{0x22, 0x22, 0x22, 0xFF})
	rect(gc, float64(this.X), float64(this.X+this.W), float64(this.Y), float64(this.Y+this.H))
	gc.Fill()
	gc.SetFillColor(color.RGBA{0xFF, 0x33, 0x33, 0xFF})
	arrow(gc, float64(this.X), float64(this.Y), float64(this.W), float64(this.H), this.Up)
	gc.Fill()
}
예제 #3
0
func (e *Entry) draw(gc draw2d.GraphicContext) {
	if e.textOffset+e.runeOffsets[e.cursor] < 5 {
		e.textOffset = 5 - e.runeOffsets[e.cursor]
	}
	if e.textOffset+e.runeOffsets[e.cursor] > e.Size.X-5 {
		e.textOffset = e.Size.X - 5 - e.runeOffsets[e.cursor]
	}

	gc.Clear()
	if e.HasKeyFocus {
		gc.SetFillColor(color.RGBA{150, 150, 150, 255})
		safeRect(gc, geom.Coord{0, 0}, e.Size)
		gc.Fill()
	}
	th := float64(e.textBuffer.Bounds().Max.Y - e.textBuffer.Bounds().Min.Y)
	gc.Save()
	gc.Translate(e.textOffset, 0)

	if e.selecting {
		start := e.runeOffsets[e.cursor]
		end := e.runeOffsets[e.selectCursor]
		if start > end {
			start, end = end, start
		}
		gc.SetFillColor(color.RGBA{200, 200, 200, 255})
		safeRect(gc, geom.Coord{start, 0}, geom.Coord{end, e.Size.Y})
		gc.Fill()
	}

	gc.Translate(0, (e.Size.Y-th)/2)

	gc.DrawImage(e.textBuffer)
	gc.Restore()
	if e.HasKeyFocus {
		un := time.Duration(time.Now().UnixNano())
		ms := un / time.Millisecond
		ms = ms % 750
		var intensity uint8 = 255
		if ms > 550 {
			diff := 650 - ms
			if diff < 0 {
				diff *= -1
			}
			intensity = uint8((diff * 255) / 200)
		}
		offset := float64(int(e.runeOffsets[e.cursor] + e.textOffset))
		gc.SetStrokeColor(color.RGBA{A: intensity})
		gc.MoveTo(offset, 0)
		gc.LineTo(offset, e.Size.Y)
		gc.Stroke()
		e.Invalidate(geom.Rect{
			Min: geom.Coord{offset - 1, 0},
			Max: geom.Coord{offset + 1, e.Size.Y},
		})
	}
}
예제 #4
0
파일: button.go 프로젝트: ajstarks/go.uik
func (b *Button) draw(gc draw2d.GraphicContext) {
	gc.SetStrokeColor(color.Black)
	if b.pressed {
		gc.SetFillColor(color.RGBA{150, 150, 150, 255})
	} else {
		gc.SetFillColor(color.White)
	}
	safeRect(gc, Coord{0, 0}, b.Size)
	gc.FillStroke()
}
예제 #5
0
파일: keygrab.go 프로젝트: henkman/go.uik
func (l *KeyGrab) draw(gc draw2d.GraphicContext) {
	gc.Clear()
	if l.HasKeyFocus {
		gc.SetFillColor(color.RGBA{150, 150, 150, 255})
		safeRect(gc, geom.Coord{0, 0}, l.Size)
		gc.FillStroke()
	}
	tw := float64(l.kbuf.Bounds().Max.X - l.kbuf.Bounds().Min.X)
	th := float64(l.kbuf.Bounds().Max.Y - l.kbuf.Bounds().Min.Y)
	gc.Translate((l.Size.X-tw)/2, (l.Size.Y-th)/2)
	gc.DrawImage(l.kbuf)
}
예제 #6
0
func drawPolygon(ctxt draw2d.GraphicContext, g *geos.Geometry, fillColor color.Color, strokeColor color.Color, width float64, scale func(x, y float64) (float64, float64)) {
	ctxt.SetFillColor(fillColor)
	ctxt.SetStrokeColor(strokeColor)
	ctxt.SetLineWidth(width)
	// exterior ring
	ring := geos.Must(g.ExteriorRing())
	cs, err := ring.coordSeq()
	if err != nil {
		log.Fatal(err)
	}
	lineCoordSeq(ctxt, cs, scale)
	ctxt.FillStroke()
	// interior rings...
}
예제 #7
0
파일: checkbox.go 프로젝트: henkman/go.uik
func (c *Checkbox) draw(gc draw2d.GraphicContext) {
	gc.Clear()
	if c.pressed {
		if c.pressHover {
			gc.SetFillColor(color.RGBA{200, 0, 0, 255})
		} else {
			gc.SetFillColor(color.RGBA{155, 0, 0, 255})
		}
	} else {
		gc.SetFillColor(color.RGBA{255, 0, 0, 255})
	}

	// Draw background rect
	x, y := gc.LastPoint()
	gc.MoveTo(0, 0)
	gc.LineTo(c.Size.X, 0)
	gc.LineTo(c.Size.X, c.Size.Y)
	gc.LineTo(0, c.Size.Y)
	gc.Close()
	gc.Fill()

	// Draw inner rect
	if c.state {
		gc.SetFillColor(color.Black)
		gc.MoveTo(5, 5)
		gc.LineTo(c.Size.X-5, 5)
		gc.LineTo(c.Size.X-5, c.Size.Y-5)
		gc.LineTo(5, c.Size.Y-5)
		gc.Close()
		gc.Fill()
	}

	gc.MoveTo(x, y)
}
예제 #8
0
func drawPoint(ctxt draw2d.GraphicContext, g *geos.Geometry, c color.Color, radius float64, scale func(x, y float64) (float64, float64)) {
	if c != nil {
		ctxt.SetFillColor(c)
	}
	x, err := g.X()
	if err != nil {
		log.Fatal(err)
	}
	y, err := g.Y()
	if err != nil {
		log.Fatal(err)
	}
	x, y = scale(x, y)
	ctxt.MoveTo(x, y)
	ctxt.ArcTo(x, y, radius, radius, 0, 2*math.Pi)
	ctxt.Fill()
}
예제 #9
0
파일: grid.go 프로젝트: KarateCode/go.uik
func (g *Grid) draw(gc draw2d.GraphicContext) {
	gc.Clear()
	gc.SetFillColor(color.RGBA{150, 150, 150, 255})
	safeRect(gc, geom.Coord{0, 0}, g.Size)
	gc.FillStroke()

	g.reflex()

	_, minXs, _ := g.hflex.constrain(g.Size.X)
	for _, x := range minXs[1:] {
		gc.MoveTo(x, 0)
		gc.LineTo(x, g.Size.Y)

	}
	_, minYs, _ := g.vflex.constrain(g.Size.Y)
	for _, y := range minYs[1:] {
		gc.MoveTo(0, y)
		gc.LineTo(g.Size.X, y)

	}
	gc.Stroke()
	// _, _, maxYs := g.vflex.constrain(g.Size.Y)
}
예제 #10
0
파일: grid.go 프로젝트: henkman/go.uik
func (g *Grid) draw(gc draw2d.GraphicContext) {
	gc.Clear()
	gc.SetFillColor(color.RGBA{150, 150, 150, 255})
	safeRect(gc, geom.Coord{0, 0}, g.Size)
	gc.FillStroke()
}
예제 #11
0
파일: main.go 프로젝트: henkman/w32uptime
func drawUptimes(gc draw2d.GraphicContext) {
	y, m, d := curTime.Add(Day * -6).Date()
	sday := time.Date(y, m, d, 0, 0, 0, 0, time.Local)
	eday := sday.Add(Day - time.Second)

	gc.SetFontSize(40)

	// draw frame
	gc.SetStrokeColor(color.RGBA{0x00, 0x00, 0x00, 0xff})
	rect(gc, BAR_START_X, BAR_START_X+BAR_WIDTH, BAR_START_Y, BAR_START_Y+2+float64(7*BAR_HEIGHT))
	gc.Stroke()

	u := 0
	for i := 0; i < 7; i++ {
		gc.MoveTo(FONT_START_X, FONT_START_Y+float64(i*BAR_HEIGHT))
		gc.SetStrokeColor(color.RGBA{0x00, 0x00, 0x00, 0xff})
		gc.FillString(sday.Weekday().String()[0:2])

		upday := make([]w32uptime.Uptime, 0)
		for e := u; e < len(uptimes); e++ {
			if uptimes[e].Start.After(eday) {
				u = e - 1
				if u < 0 {
					u = 0
				}
				break
			}

			if isUptimeInRange(sday, eday, uptimes[e]) {
				upday = append(upday, uptimes[e])
			}
		}

		gc.SetFillColor(color.RGBA{0xE0, 0xA6, 0x2C, 0xFF})
		if len(upday) > 0 {
			for e := 0; e < len(upday); e++ {
				ps, pe := 0, BAR_WIDTH

				if upday[e].Start.After(sday) {
					ps = timeToBarwidth(upday[e].Start)
				}

				if upday[e].End.Before(eday) {
					pe = timeToBarwidth(upday[e].End)
				}

				rect(gc, float64(BAR_START_X+ps), float64(BAR_START_X+pe), BAR_START_Y+1+float64(i*BAR_HEIGHT), BAR_START_Y+1+float64((i+1)*BAR_HEIGHT))
				gc.Fill()
			}
		}

		if i != 6 {
			gc.SetStrokeColor(color.RGBA{0x00, 0x00, 0x00, 0xff})
			gc.MoveTo(BAR_START_X, BAR_START_Y+float64((i+1)*BAR_HEIGHT))
			gc.LineTo(BAR_START_X+BAR_WIDTH, BAR_START_Y+float64((i+1)*BAR_HEIGHT))
			gc.Close()
			gc.Stroke()
		}

		sday = sday.Add(Day)
		eday = sday.Add(Day - time.Second)
	}

	// middle line
	gc.SetStrokeColor(color.RGBA{0x00, 0x00, 0x00, 0xff})
	gc.MoveTo(BAR_START_X+BAR_WIDTH/2, BAR_START_Y+1)
	gc.LineTo(BAR_START_X+BAR_WIDTH/2, BAR_START_Y+1+float64(7*BAR_HEIGHT))
	gc.Close()
	gc.Stroke()
}
예제 #12
0
파일: main.go 프로젝트: henkman/w32uptime
func drawBackground(gc draw2d.GraphicContext) {
	gc.SetFillColor(color.RGBA{0xFF, 0xFF, 0xFF, 0xFF})
	gc.Clear()
}
예제 #13
0
파일: main.go 프로젝트: henkman/w32uptime
func drawInfoarea(gc draw2d.GraphicContext) {
	gc.SetFontSize(20)
	gc.SetFillColor(color.RGBA{0xFF, 0xFF, 0xFF, 0xFF})
	gc.MoveTo(BAR_START_X, IA_START_Y)
	gc.FillString(curTime.Add(Day*-7).Format(DATE_FORMAT) + " - " + curTime.Format(DATE_FORMAT))
}
예제 #14
0
func gordon(gc draw2d.GraphicContext, x, y, w, h float64) {
	h23 := (h * 2) / 3

	blf := color.RGBA{0, 0, 0, 0xff}
	wf := color.RGBA{0xff, 0xff, 0xff, 0xff}
	nf := color.RGBA{0x8B, 0x45, 0x13, 0xff}
	brf := color.RGBA{0x8B, 0x45, 0x13, 0x99}
	brb := color.RGBA{0x8B, 0x45, 0x13, 0xBB}

	gc.MoveTo(x, y+h)
	gc.CubicCurveTo(x, y+h, x+w/2, y-h, x+w, y+h)
	gc.Close()
	gc.SetFillColor(brb)
	gc.Fill()
	draw2d.RoundRect(gc, x, y+h, x+w, y+h+h, 10, 10)
	gc.Fill()
	draw2d.Circle(gc, x, y+h, w/12) // left ear
	gc.SetFillColor(brf)
	gc.Fill()
	draw2d.Circle(gc, x, y+h, w/12-10)
	gc.SetFillColor(nf)
	gc.Fill()

	draw2d.Circle(gc, x+w, y+h, w/12) // right ear
	gc.SetFillColor(brf)
	gc.Fill()
	draw2d.Circle(gc, x+w, y+h, w/12-10)
	gc.SetFillColor(nf)
	gc.Fill()

	draw2d.Circle(gc, x+w/3, y+h23, w/9) // left eye
	gc.SetFillColor(wf)
	gc.Fill()
	draw2d.Circle(gc, x+w/3+10, y+h23, w/10-10)
	gc.SetFillColor(blf)
	gc.Fill()
	draw2d.Circle(gc, x+w/3+15, y+h23, 5)
	gc.SetFillColor(wf)
	gc.Fill()

	draw2d.Circle(gc, x+w-w/3, y+h23, w/9) // right eye
	gc.Fill()
	draw2d.Circle(gc, x+w-w/3+10, y+h23, w/10-10)
	gc.SetFillColor(blf)
	gc.Fill()
	draw2d.Circle(gc, x+w-(w/3)+15, y+h23, 5)
	gc.SetFillColor(wf)
	gc.Fill()

	gc.SetFillColor(wf)
	draw2d.RoundRect(gc, x+w/2-w/8, y+h+30, x+w/2-w/8+w/8, y+h+30+w/6, 5, 5) // left tooth
	gc.Fill()
	draw2d.RoundRect(gc, x+w/2, y+h+30, x+w/2+w/8, y+h+30+w/6, 5, 5) // right tooth
	gc.Fill()

	draw2d.Ellipse(gc, x+(w/2), y+h+30, w/6, w/12) // snout
	gc.SetFillColor(nf)
	gc.Fill()
	draw2d.Ellipse(gc, x+(w/2), y+h+10, w/10, w/12) // nose
	gc.SetFillColor(blf)
	gc.Fill()

}