// Draw draws the entry.
164099
func (e *Entry) Draw(p *Painter) {
	style := "entry"
	if e.IsFocused() {
		style += ".focused"
	}
	p.WithStyle(style, func(p *Painter) {
		s := e.Size()
		e.text.SetMaxWidth(s.X)

		text := e.visibleText()

		p.FillRect(0, 0, s.X, 1)

		switch e.echoMode {
		case EchoModeNormal:
			p.DrawText(0, 0, text)
		case EchoModePassword:
			p.DrawText(0, 0, strings.Repeat("*", len(text)))
		}

		if e.IsFocused() {
			var off int
			if e.echoMode != EchoModeNoEcho {
				off = e.text.CursorPos().X - e.offset
			}
			p.DrawCursor(off, 0)
		}
	})
}
1188108
func (g *Game) Draw(method Method) error {
	switch method {
	case ThreefoldRepetition:
		if g.numOfRepitions() < 3 {
			return errors.New("chess: draw by ThreefoldRepetition requires at least three repetitions of the current board state")
		}
	case FiftyMoveRule:
		if g.pos.halfMoveClock < 100 {
			return fmt.Errorf("chess: draw by FiftyMoveRule requires the half move clock to be at 100 or greater but is %d", g.pos.halfMoveClock)
		}
	case DrawOffer:
	default:
		return fmt.Errorf("chess: unsupported draw method %s", method.String())
	}
	g.outcome = Draw
	g.method = method
	return nil
}
101776
func (b *Button) Draw(screen tcell.Screen) {
	// Draw the box.
	borderColor := b.borderColor
	backgroundColor := b.backgroundColor
	if b.focus.HasFocus() {
		b.backgroundColor = b.backgroundColorActivated
		b.borderColor = b.labelColorActivated
		defer func() {
			b.borderColor = borderColor
		}()
	}
	b.Box.Draw(screen)
	b.backgroundColor = backgroundColor

	// Draw label.
	x, y, width, height := b.GetInnerRect()
	if width > 0 && height > 0 {
		y = y + height/2
		labelColor := b.labelColor
		if b.focus.HasFocus() {
			labelColor = b.labelColorActivated
		}
		Print(screen, b.label, x, y, width, AlignCenter, labelColor)
	}
}
1110049
func (t *TextBar) Draw() {

	t.initialize()
	if t.changed {
		t.layout()
	}
	w, h := t.view.Size()
	for y := 0; y < h; y++ {
		for x := 0; x < w; x++ {
			t.view.SetContent(x, y, ' ', nil, t.style)
		}
	}

	// Draw in reverse order -- if we clip, we will clip at the
	// right side.
	t.right.Draw()
	t.center.Draw()
	t.left.Draw()
}
753380
func (b *StatusBar) Draw(p *Painter) {
	p.WithStyle("statusbar", func(p *Painter) {
		p.FillRect(0, 0, b.Size().X, 1)
		p.DrawText(0, 0, b.text)
		p.DrawText(b.Size().X-stringWidth(b.permText), 0, b.permText)
	})
}
191034
func (s *StyledBox) Draw(p *tui.Painter) {
	p.WithStyle(s.Style, func(p *tui.Painter) {
		s.Box.Draw(p)
	})
}
916143
func (vs *VertexSlice) Draw() {
	vs.va.draw(vs.i, vs.j)
}
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)
			}
		}
	*/
}
1004680
func (p *Painter) DrawHorizontalLine(x1, x2, y int) {
	for x := x1; x < x2; x++ {
		p.DrawRune(x, y, '─')
	}
}
1201307
func (p *Painter) DrawCursor(x, y int) {
	wp := p.mapLocalToWorld(image.Point{x, y})
	p.surface.SetCursor(wp.X, wp.Y)
}
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)
		}
	}
}
8625
func (b bitboard) Draw() string {
	s := "\n A B C D E F G H\n"
	for r := 7; r >= 0; r-- {
		s += Rank(r).String()
		for f := 0; f < numOfSquaresInRow; f++ {
			sq := getSquare(File(f), Rank(r))
			if b.Occupied(sq) {
				s += "1"
			} else {
				s += "0"
			}
			s += " "
		}
		s += "\n"
	}
	return s
}
442389
func (b *Button) Draw(p *Painter) {
	style := "button"
	if b.IsFocused() {
		style += ".focused"
	}
	p.WithStyle(style, func(p *Painter) {
		lines := strings.Split(b.text, "\n")
		for i, line := range lines {
			p.FillRect(0, i, b.Size().X, 1)
			p.DrawText(0, i, line)
		}
	})
}
623798
func draw() {
	gl.Clear(gl.COLOR_BUFFER_BIT)
	gl.Enable(gl.BLEND)
	gl.Enable(gl.POINT_SMOOTH)
	gl.Enable(gl.LINE_SMOOTH)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	gl.LoadIdentity()

	gl.Begin(gl.LINES)
	gl.Color3f(.2, .2, .2)
	for i := range staticLines {
		x := staticLines[i].GetAsSegment().A.X
		y := staticLines[i].GetAsSegment().A.Y
		gl.Vertex3f(float32(x), float32(y), 0)
		x = staticLines[i].GetAsSegment().B.X
		y = staticLines[i].GetAsSegment().B.Y
		gl.Vertex3f(float32(x), float32(y), 0)
	}
	gl.End()

	gl.Color4f(.3, .3, 1, .8)
	// draw balls
	for _, ball := range balls {
		gl.PushMatrix()
		pos := ball.Body.Position()
		rot := ball.Body.Angle() * chipmunk.DegreeConst
		gl.Translatef(float32(pos.X), float32(pos.Y), 0.0)
		gl.Rotatef(float32(rot), 0, 0, 1)
		drawCircle(float64(ballRadius), 60)
		gl.PopMatrix()
	}
}
295775
func (d Sierra24A) Draw(dst draw.Image, r image.Rectangle, src image.Image, sp image.Point) {
	pd, ok := dst.(*image.Paletted)
	if !ok {
		// dither211 currently requires a palette
		draw.Draw(dst, r, src, sp, draw.Src)
		return
	}
	// intersect r with both dst and src bounds, fix up sp.
	ir := r.Intersect(pd.Bounds()).
		Intersect(src.Bounds().Add(r.Min.Sub(sp)))
	if ir.Empty() {
		return // no work to do.
	}
	sp = ir.Min.Sub(r.Min)
	// get subimage of src
	sr := ir.Add(sp)
	if !sr.Eq(src.Bounds()) {
		s, ok := src.(interface {
			SubImage(image.Rectangle) image.Image
		})
		if !ok {
			// dither211 currently works on whole images
			draw.Draw(dst, r, src, sp, draw.Src)
			return
		}
		src = s.SubImage(sr)
	}
	// dither211 currently returns a new image, or nil if dithering not
	// possible.
	if s := dither211(src, pd.Palette); s != nil {
		src = s
	}
	// this avoids any problem of src dst overlap but it would usually
	// work to render directly into dst.  todo.
	draw.Draw(dst, r, src, image.Point{}, draw.Src)
}
1145220
func (c *Context) DrawElements(mode, count, typ, offset int) {
	c.Call("drawElements", mode, count, typ, offset)
}
1257279
func DrawRaw(x, y int, text string) int {
	var i int
	for i, line := range Splitlines(text) {
		Write(x, y+i, line, TEXTCOLOR, BG)
	}
	return y + i
}