// Circle draws a circle of the specified radius around each Pushed point. If the thickness is 0,
// the circle will be filled, otherwise a circle outline of the specified thickness will be drawn.
492285
func (imd *IMDraw) Circle(radius, thickness float64) {
	if thickness == 0 {
		imd.fillEllipseArc(pixel.V(radius, radius), 0, 2*math.Pi)
	} else {
		imd.outlineEllipseArc(pixel.V(radius, radius), 0, 2*math.Pi, thickness, false)
	}
}
1302659
func (p *Padder) Draw(painter *Painter) {
	painter.Translate(p.padding.X, p.padding.Y)
	defer painter.Restore()

	p.widget.Draw(painter)
}
406429
func (g *Grid) Draw(p *Painter) {
	s := g.Size()

	if g.hasBorder {
		border := 1

		// Draw outmost border.
		p.DrawRect(0, 0, s.X, s.Y)

		// Draw column dividers.
		var coloff int
		for i := 0; i < g.cols-1; i++ {
			x := g.colWidths[i] + coloff + border
			p.DrawVerticalLine(x, 0, s.Y-1)
			p.DrawRune(x, 0, '┬')
			p.DrawRune(x, s.Y-1, '┴')
			coloff = x
		}

		// Draw row dividers.
		var rowoff int
		for j := 0; j < g.rows-1; j++ {
			y := g.rowHeights[j] + rowoff + border
			p.DrawHorizontalLine(0, s.X-1, y)
			p.DrawRune(0, y, '├')
			p.DrawRune(s.X-1, y, '┤')
			rowoff = y
		}

		// Polish the intersections.
		rowoff = 0
		for j := 0; j < g.rows-1; j++ {
			y := g.rowHeights[j] + rowoff + border
			coloff = 0
			for i := 0; i < g.cols-1; i++ {
				x := g.colWidths[i] + coloff + border
				p.DrawRune(x, y, '┼')
				coloff = x
			}
			rowoff = y
		}
	}

	// Draw cell content.
	for i := 0; i < g.cols; i++ {
		for j := 0; j < g.rows; j++ {
			pos := image.Point{i, j}
			wp := g.mapCellToLocal(pos)

			if w, ok := g.cells[pos]; ok {
				p.Translate(wp.X, wp.Y)
				p.WithMask(image.Rectangle{
					Min: image.ZP,
					Max: w.Size(),
				}, func(p *Painter) {
					w.Draw(p)
				})
				p.Restore()
			}
		}
	}
}
753173
func (circle *CircleShape) update(xf transform.Transform) AABB {
	//global center of the circle
	center := xf.TransformVect(circle.Position)
	circle.Tc = center
	rv := vect.Vect{circle.Radius, circle.Radius}

	return AABB{
		vect.Sub(center, rv),
		vect.Add(center, rv),
	}
}
469022
def drawCircle(self, center, radius):
        
        if not radius > 1e-5:
            raise ValueError("radius must be postive")
        center = Point(center)
        p1 = center - (radius, 0)
        return self.drawSector(center, p1, 360, fullSector=False)
1022044
func drawCircle(radius float64, sides int) {
	gl.Begin(gl.LINE_LOOP)
	for a := 0.0; a < 2*math.Pi; a += (2 * math.Pi / float64(sides)) {
		gl.Vertex2d(math.Sin(a)*radius, math.Cos(a)*radius)
	}
	gl.Vertex3f(0, 0, 0)
	gl.End()
}
907628
func (c *InputModal) Draw() {
	if c.isVisible {
		// First blank out the area we'll be putting the modal
		FillWithChar(' ', c.x, c.y, c.x+c.width, c.y+c.height, c.fg, c.bg)
		nextY := c.y + 1
		// The title
		if c.title != "" {
			if len(c.title) > c.width {
				diff := c.width - len(c.title)
				DrawStringAtPoint(c.title[:len(c.title)+diff-1], c.x+1, nextY, c.fg, c.bg)
			} else {
				DrawStringAtPoint(c.title, c.x+1, nextY, c.fg, c.bg)
			}
			nextY++
			FillWithChar('-', c.x+1, nextY, c.x+c.width-1, nextY, c.fg, c.bg)
			nextY++
		}
		if c.text != "" {
			DrawStringAtPoint(c.text, c.x+1, nextY, c.fg, c.bg)
			nextY++
		}
		c.input.SetY(nextY)
		c.input.Draw()
		nextY += 3
		if c.showHelp {
			helpString := " (ENTER) to Accept. (ESC) to Cancel. "
			helpX := (c.x + c.width - len(helpString)) - 1
			DrawStringAtPoint(helpString, helpX, nextY, c.fg, c.bg)
		}
		if c.bordered {
			// Now draw the border
			DrawBorder(c.x, c.y, c.x+c.width, c.y+c.height, c.fg, c.bg)
		}
	}
}
854672
func (g *drawer) Draw(s string, size int, bg *color.RGBA) image.Image {
	// draw the background
	dst := image.NewRGBA(image.Rect(0, 0, size, size))
	draw.Draw(dst, dst.Bounds(), &image.Uniform{bg}, image.ZP, draw.Src)

	// draw the text
	drawer := &font.Drawer{
		Dst:  dst,
		Src:  image.White,
		Face: g.face,
	}

	// font index
	fi := g.font.Index([]rune(s)[0])

	// glyph example: http://www.freetype.org/freetype2/docs/tutorial/metrics.png
	var gbuf truetype.GlyphBuf
	var err error
	fsize := fixed.Int26_6(g.fontSize * g.dpi * (64.0 / 72.0))
	err = gbuf.Load(g.font, fsize, fi, font.HintingFull)
	if err != nil {
		// fixme
		drawer.DrawString("")
		return dst
	}

	// center
	dY := int((size - int(gbuf.Bounds.Max.Y-gbuf.Bounds.Min.Y)>>6) / 2)
	dX := int((size - int(gbuf.Bounds.Max.X-gbuf.Bounds.Min.X)>>6) / 2)
	y := int(gbuf.Bounds.Max.Y>>6) + dY
	x := 0 - int(gbuf.Bounds.Min.X>>6) + dX

	drawer.Dot = fixed.Point26_6{
		X: fixed.I(x),
		Y: fixed.I(y),
	}
	drawer.DrawString(s)

	return dst
}
859996
func Geometry(g orb.Geometry, proj orb.Projection) orb.Geometry {
	if g == nil {
		return nil
	}

	switch g := g.(type) {
	case orb.Point:
		return Point(g, proj)
	case orb.MultiPoint:
		return MultiPoint(g, proj)
	case orb.LineString:
		return LineString(g, proj)
	case orb.MultiLineString:
		return MultiLineString(g, proj)
	case orb.Ring:
		return Ring(g, proj)
	case orb.Polygon:
		return Polygon(g, proj)
	case orb.MultiPolygon:
		return MultiPolygon(g, proj)
	case orb.Collection:
		return Collection(g, proj)
	case orb.Bound:
		return Bound(g, proj)
	}

	panic("geometry type not supported")
}
883095
func (t T) Circle(center kml.Coordinate, radius, maxErr float64) []kml.Coordinate {
	numVertices := int(math.Ceil(math.Pi / math.Acos((radius-maxErr)/(radius+maxErr))))
	cs := make([]kml.Coordinate, numVertices+1)
	for i := 0; i < numVertices; i++ {
		cs[i] = t.Offset(center, radius, 360*float64(i)/float64(numVertices))
	}
	cs[numVertices] = cs[0]
	return cs
}
1007481
func DrawBox(r *Box, extrude bool) *Rect {
	x := r.frame.X
	y := r.frame.Y
	width := r.frame.W
	height := r.frame.H
	FG1 := BOXLIGHT
	FG2 := BOXDARK
	if !extrude {
		FG1 = BOXDARK
		FG2 = BOXLIGHT
	}
	WriteRune(x, y, TLCHAR, FG1, BOXBG)
	Write(x+1, y, RepeatRune(HCHAR, width-2), FG1, BOXBG)
	WriteRune(x+width-1, y, TRCHAR, FG1, BOXBG)
	for i := y + 1; i < y+height; i++ {
		WriteRune(x, i, VCHAR, FG1, BOXBG)
		Write(x+1, i, RepeatRune(' ', width-2), FG1, BOXBG)
		WriteRune(x+width-1, i, VCHAR2, FG2, BOXBG)
	}
	WriteRune(x, y+height-1, BLCHAR, FG1, BOXBG)
	Write(x+1, y+height-1, RepeatRune(HCHAR2, width-2), FG2, BOXBG)
	WriteRune(x+width-1, y+height-1, BRCHAR, FG2, BOXBG)
	return &Rect{x, y, width, height}
}
1355842
func (c *Label) Draw() {
	maxWidth := c.width
	maxHeight := c.height
	x, y := c.x, c.y
	startX := c.x
	startY := c.y
	if c.bordered {
		DrawBorder(c.x, c.y, c.x+c.GetWidth(), c.y+c.height, c.fg, c.bg)
		maxWidth--
		maxHeight--
		x++
		y++
		startX++
		startY++
	}

	DrawStringAtPoint(c.value, x, y, c.fg, c.bg)
}
1311604
func (i *AlertModal) Draw() {
	// First blank out the area we'll be putting the modal
	FillWithChar(' ', i.x, i.y, i.x+i.width, i.y+i.height, i.fg, i.bg)
	// Now draw the border
	DrawBorder(i.x, i.y, i.x+i.width, i.y+i.height, i.fg, i.bg)

	nextY := i.y + 1
	// The title
	if i.title != "" {
		DrawStringAtPoint(i.title, i.x+1, nextY, i.fg, i.bg)
		nextY++
		FillWithChar('-', i.x+1, nextY, i.x+i.width-1, nextY, i.fg, i.bg)
		nextY++
	}
	if i.text != "" {
		DrawStringAtPoint(i.text, i.x+1, nextY, i.fg, i.bg)
	}
	nextY += 2
	if i.showHelp {
		helpString := "Press Enter to Continue"
		helpX := (i.x + i.width) - len(helpString) - 1
		DrawStringAtPoint(helpString, helpX, nextY, i.fg, i.bg)
	}
}
615046
func (self circle) at(phi float64) image.Point {
	x := self.X + int(RoundFloat64(xStretch*self.radius*math.Cos(phi)))
	y := self.Y + int(RoundFloat64(self.radius*math.Sin(phi)))
	return image.Point{X: x, Y: y}
}
498279
func C(center Vec, radius float64) Circle {
	return Circle{
		Center: center,
		Radius: radius,
	}
}
1201307
func (p *Painter) DrawCursor(x, y int) {
	wp := p.mapLocalToWorld(image.Point{x, y})
	p.surface.SetCursor(wp.X, wp.Y)
}
814439
func (c *ProgressBar) Draw() {
	// For now, just draw a [####  ] bar
	// TODO: make this more advanced
	useFg := c.fg
	if c.colorized {
		if c.GetPercent() < 10 {
			useFg = termbox.ColorRed
		} else if c.GetPercent() < 50 {
			useFg = termbox.ColorYellow
		} else {
			useFg = termbox.ColorGreen
		}
	}
	drawX, drawY := c.x, c.y
	fillWidth, fillHeight := c.width-2, c.height
	DrawStringAtPoint("[", drawX, drawY, c.fg, c.bg)
	numFull := int(float64(fillWidth) * float64(c.progress) / float64(c.total))
	FillWithChar(c.fullChar, drawX+1, drawY, drawX+1+numFull, drawY+(fillHeight-1), useFg, c.bg)
	DrawStringAtPoint("]", drawX+c.width-1, drawY, c.fg, c.bg)

	/*
		drawX, drawY := c.x, c.y
		drawWidth, drawHeight := c.width, c.height
		if c.bordered {
			if c.height == 1 && c.width > 2 {
				// Just using [ & ] for the border
				DrawStringAtPoint("[", drawX, drawY, c.fg, c.bg)
				DrawStringAtPoint("]", drawX+c.width-1, drawY, c.fg, c.bg)
				drawX++
				drawWidth -= 2
			} else if c.height >= 3 {
				DrawBorder(drawX, drawY, drawX+c.width, drawY+c.height, c.fg, c.bg)
				drawX++
				drawY++
				drawWidth -= 2
				drawHeight -= 2
			}
		}

		// Figure out how many chars are full
		numFull := drawWidth * (c.progress / c.total)
		switch c.alignment {
		case AlignRight: // TODO: Fill from right to left
		case AlignCenter: // TODO: Fill from middle out
		default: // Fill from left to right
			FillWithChar(c.fullChar, drawX, drawY, drawX+numFull, drawY+(drawHeight-1), c.fg, c.bg)
			if numFull < drawWidth {
				FillWithChar(c.emptyChar, drawX+numFull, drawY, drawX+drawWidth-1, drawY+(drawHeight-1), c.fg, c.bg)
			}
		}
	*/
}