// Draw draws this primitive onto the screen.
427280
func (l *List) Draw(screen tcell.Screen) {
	l.Box.Draw(screen)

	// Determine the dimensions.
	x, y, width, height := l.GetInnerRect()
	bottomLimit := y + height

	// Do we show any shortcuts?
	var showShortcuts bool
	for _, item := range l.items {
		if item.Shortcut != 0 {
			showShortcuts = true
			x += 4
			width -= 4
			break
		}
	}

	// Adjust offset to keep the current selection in view.
	if l.currentItem < l.offset {
		l.offset = l.currentItem
	} else if l.showSecondaryText {
		if 2*(l.currentItem-l.offset) >= height-1 {
			l.offset = (2*l.currentItem + 3 - height) / 2
		}
	} else {
		if l.currentItem-l.offset >= height {
			l.offset = l.currentItem + 1 - height
		}
	}

	// Draw the list items.
	for index, item := range l.items {
		if index < l.offset {
			continue
		}

		if y >= bottomLimit {
			break
		}

		// Shortcuts.
		if showShortcuts && item.Shortcut != 0 {
			Print(screen, fmt.Sprintf("(%s)", string(item.Shortcut)), x-5, y, 4, AlignRight, l.shortcutColor)
		}

		// Main text.
		Print(screen, item.MainText, x, y, width, AlignLeft, l.mainTextColor)

		// Background color of selected text.
		if index == l.currentItem && (!l.selectedFocusOnly || l.HasFocus()) {
			textWidth := width
			if !l.highlightFullLine {
				if w := TaggedStringWidth(item.MainText); w < textWidth {
					textWidth = w
				}
			}

			for bx := 0; bx < textWidth; bx++ {
				m, c, style, _ := screen.GetContent(x+bx, y)
				fg, _, _ := style.Decompose()
				if fg == l.mainTextColor {
					fg = l.selectedTextColor
				}
				style = style.Background(l.selectedBackgroundColor).Foreground(fg)
				screen.SetContent(x+bx, y, m, c, style)
			}
		}

		y++

		if y >= bottomLimit {
			break
		}

		// Secondary text.
		if l.showSecondaryText {
			Print(screen, item.SecondaryText, x, y, width, AlignLeft, l.secondaryTextColor)
			y++
		}
	}
}
1853
func (self *Block) Draw(buf *Buffer) {
	if self.Border {
		self.drawBorder(buf)
	}
	buf.SetString(
		self.Title,
		self.TitleStyle,
		image.Pt(self.Min.X+2, self.Min.Y),
	)
}
987513
func drawProperty(win *Window, style *nstyle.Property, bounds, labelrect rect.Rect, ws nstyle.WidgetStates, name string) {
	out := &win.cmds
	font := win.ctx.Style.Font

	if style.DrawBegin != nil {
		style.DrawBegin(out)
	}
	if style.DrawEnd != nil {
		defer style.DrawEnd(out)
	}
	if style.Draw != nil {
		style.Draw(out, style, bounds.Rectangle(), labelrect.Rectangle(), ws, name, font)
		return
	}

	var text textWidget
	var background *nstyle.Item

	// select correct background and text color
	if ws&nstyle.WidgetStateActive != 0 {
		background = &style.Active
		text.Text = style.LabelActive
	} else if ws&nstyle.WidgetStateHovered != 0 {
		background = &style.Hover
		text.Text = style.LabelHover
	} else {
		background = &style.Normal
		text.Text = style.LabelNormal
	}

	// draw background
	if background.Type == nstyle.ItemImage {
		out.DrawImage(bounds, background.Data.Image)
		text.Background = color.RGBA{0, 0, 0, 0}
	} else {
		text.Background = background.Data.Color
		out.FillRect(bounds, style.Rounding, style.BorderColor)
		out.FillRect(shrinkRect(bounds, style.Border), style.Rounding, background.Data.Color)
	}

	// draw label
	widgetText(out, labelrect, name, &text, "CC", font)
	return
}
535180
func (b *Box) Draw(p *Painter) {
	style := "box"
	if b.IsFocused() {
		style += ".focused"
	}

	p.WithStyle(style, func(p *Painter) {

		sz := b.Size()

		if b.border {
			p.WithStyle(style+".border", func(p *Painter) {
				p.DrawRect(0, 0, sz.X, sz.Y)
			})
			p.WithStyle(style, func(p *Painter) {
				p.WithMask(image.Rect(0, 0, sz.X-1, 1), func(p *Painter) {
					p.DrawText(1, 0, b.title)
				})
			})
			p.FillRect(1, 1, sz.X-2, sz.Y-2)
			p.Translate(1, 1)
			defer p.Restore()
		} else {
			p.FillRect(0, 0, sz.X, sz.Y)
		}

		var off image.Point
		for _, child := range b.children {
			switch b.Alignment() {
			case Horizontal:
				p.Translate(off.X, 0)
			case Vertical:
				p.Translate(0, off.Y)
			}

			p.WithMask(image.Rectangle{
				Min: image.ZP,
				Max: child.Size(),
			}, func(p *Painter) {
				child.Draw(p)
			})

			p.Restore()

			off = off.Add(child.Size())
		}
	})
}
974412
func (l *List) Draw(p *Painter) {
	for i, item := range l.items {
		style := "list.item"
		if i == l.selected-l.pos {
			style += ".selected"
		}
		p.WithStyle(style, func(p *Painter) {
			p.FillRect(0, i, l.Size().X, 1)
			p.DrawText(0, i, item)
		})
	}
}
1137255
func (g *GIFT) Draw(dst draw.Image, src image.Image) {
	if len(g.Filters) == 0 {
		copyimage(dst, src, &g.Options)
		return
	}

	first, last := 0, len(g.Filters)-1
	var tmpIn image.Image
	var tmpOut draw.Image

	for i, f := range g.Filters {
		if i == first {
			tmpIn = src
		} else {
			tmpIn = tmpOut
		}

		if i == last {
			tmpOut = dst
		} else {
			tmpOut = createTempImage(f.Bounds(tmpIn.Bounds()))
		}

		f.Draw(tmpOut, tmpIn, &g.Options)
	}
}
72778
func drawScrollbar(win *Window, state nstyle.WidgetStates, style *nstyle.Scrollbar, bounds, scroll rect.Rect) {
	out := &win.cmds
	if style.DrawBegin != nil {
		style.DrawBegin(out)
	}
	if style.DrawEnd != nil {
		defer style.DrawEnd(out)
	}
	if style.Draw != nil {
		style.Draw(out, state, style, bounds.Rectangle(), scroll.Rectangle())
		return
	}

	/* select correct colors/images to draw */
	var background *nstyle.Item
	var cursorstyle *nstyle.Item
	if state&nstyle.WidgetStateActive != 0 {
		background = &style.Active
		cursorstyle = &style.CursorActive
	} else if state&nstyle.WidgetStateHovered != 0 {
		background = &style.Hover
		cursorstyle = &style.CursorHover
	} else {
		background = &style.Normal
		cursorstyle = &style.CursorNormal
	}

	/* draw background */
	if background.Type == nstyle.ItemColor {
		out.FillRect(bounds, style.Rounding, style.BorderColor)
		out.FillRect(shrinkRect(bounds, style.Border), style.Rounding, background.Data.Color)
	} else {
		out.DrawImage(bounds, background.Data.Image)
	}

	/* draw cursor */
	if cursorstyle.Type == nstyle.ItemImage {
		out.DrawImage(scroll, cursorstyle.Data.Image)
	} else {
		out.FillRect(scroll, style.Rounding, cursorstyle.Data.Color)
	}
	return
}
30466
func (self line) draw(cell Cell, buf *Buffer) {
	isLeftOf := func(p1, p2 image.Point) bool {
		return p1.X <= p2.X
	}
	isTopOf := func(p1, p2 image.Point) bool {
		return p1.Y <= p2.Y
	}
	p1, p2 := self.P1, self.P2
	buf.SetCell(NewCell('*', cell.Style), self.P2)
	width, height := self.size()
	if width > height { // paint left to right
		if !isLeftOf(p1, p2) {
			p1, p2 = p2, p1
		}
		flip := 1.0
		if !isTopOf(p1, p2) {
			flip = -1.0
		}
		for x := p1.X; x <= p2.X; x++ {
			ratio := float64(height) / float64(width)
			factor := float64(x - p1.X)
			y := ratio * factor * flip
			buf.SetCell(cell, image.Pt(x, int(RoundFloat64(y))+p1.Y))
		}
	} else { // paint top to bottom
		if !isTopOf(p1, p2) {
			p1, p2 = p2, p1
		}
		flip := 1.0
		if !isLeftOf(p1, p2) {
			flip = -1.0
		}
		for y := p1.Y; y <= p2.Y; y++ {
			ratio := float64(width) / float64(height)
			factor := float64(y - p1.Y)
			x := ratio * factor * flip
			buf.SetCell(cell, image.Pt(int(RoundFloat64(x))+p1.X, y))
		}
	}
}
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)
}
188440
func (p *Painter) DrawRune(x, y int, r rune) {
	wp := p.mapLocalToWorld(image.Point{x, y})
	if (p.mask.Min.X <= wp.X) && (wp.X < p.mask.Max.X) && (p.mask.Min.Y <= wp.Y) && (wp.Y < p.mask.Max.Y) {
		p.surface.SetCell(wp.X, wp.Y, r, p.style)
	}
}
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)
}
497325
func (d *Drawer) Draw(t Target) {
	d.lazyInit()

	if d.Triangles == nil {
		return
	}

	dt := d.targets[t]
	if dt == nil {
		dt = &drawerTarget{
			pics: make(map[Picture]TargetPicture),
		}
		d.targets[t] = dt
	}

	if dt.tris == nil {
		dt.tris = t.MakeTriangles(d.Triangles)
		dt.clean = true
	}

	if !dt.clean {
		dt.tris.SetLen(d.Triangles.Len())
		dt.tris.Update(d.Triangles)
		dt.clean = true
	}

	if d.Picture == nil {
		dt.tris.Draw()
		return
	}

	pic := dt.pics[d.Picture]
	if pic == nil {
		pic = t.MakePicture(d.Picture)
		dt.pics[d.Picture] = pic
	}

	pic.Draw(dt.tris)
}
1168011
func (l *BasicLayout) DrawScreen(state *Peco, options *DrawOptions) {
	if pdebug.Enabled {
		g := pdebug.Marker("BasicLayout.DrawScreen")
		defer g.End()
	}

	perPage := l.linesPerPage()

	if err := l.CalculatePage(state, perPage); err != nil {
		return
	}

	l.DrawPrompt(state)
	l.list.Draw(state, l, perPage, options)

	if err := l.screen.Flush(); err != nil {
		return
	}
}
785052
func (e *TextEdit) Draw(p *Painter) {
	style := "entry"
	if e.IsFocused() {
		style += ".focused"
	}
	p.WithStyle(style, func(p *Painter) {
		s := e.Size()
		e.text.SetMaxWidth(s.X)

		lines := e.text.SplitByLine()
		for i, line := range lines {
			p.FillRect(0, i, s.X, 1)
			p.DrawText(0, i, line)
		}
		if e.IsFocused() {
			pos := e.text.CursorPos()
			p.DrawCursor(pos.X, pos.Y)
		}
	})
}
1145220
func (c *Context) DrawElements(mode, count, typ, offset int) {
	c.Call("drawElements", mode, count, typ, offset)
}
996432
func (d draw) Box(r Renderer, b Box, s Style) {
	s.GetFillAndStrokeOptions().WriteToRenderer(r)
	defer r.ResetStyle()

	r.MoveTo(b.Left, b.Top)
	r.LineTo(b.Right, b.Top)
	r.LineTo(b.Right, b.Bottom)
	r.LineTo(b.Left, b.Bottom)
	r.LineTo(b.Left, b.Top)
	r.FillStroke()
}