// mobileDraw runs once per frame. RunIteration for the other backends
551943
func mobileDraw(defaultScene Scene) {
	if !initalized {
		var ctx mgl.Context
		ctx, worker = mgl.NewContext()
		Gl = gl.NewContext(ctx)
	}
	<-drawEvent
	defer func() {
		drawDone <- struct{}{}
	}()

	if !initalized {
		RunPreparation(defaultScene)
		ticker = time.NewTicker(time.Duration(int(time.Second) / opts.FPSLimit))
		initalized = true
	}

	select {
	case <-ticker.C:
	case <-resetLoopTicker:
		ticker.Stop()
		ticker = time.NewTicker(time.Duration(int(time.Second) / opts.FPSLimit))
	}
	Time.Tick()
	if !opts.HeadlessMode {
		Input.update()
	}
	// Then update the world and all Systems
	currentUpdater.Update(Time.Delta())
	Input.Mouse.Action = Neutral
}
461762
func (a *Application) SetAfterDrawFunc(handler func(screen tcell.Screen)) *Application {
	a.afterDraw = handler
	return a
}
760717
func drawCondFmtDataBar(p int, ct string, format *formatConditional) *xlsxCfRule {
	return &xlsxCfRule{
		Priority: p + 1,
		Type:     validType[format.Type],
		DataBar: &xlsxDataBar{
			Cfvo:  []*xlsxCfvo{{Type: format.MinType}, {Type: format.MaxType}},
			Color: []*xlsxColor{{RGB: getPaletteColor(format.BarColor)}},
		},
	}
}
521480
func RunIteration() {
	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	select {
	case drawEvent <- struct{}{}:
		for {
			select {
			case <-worker.WorkAvailable():
				worker.DoWork()
			case <-drawDone:
				return
			}
		}
	case <-time.After(500 * time.Millisecond):
		return
	}
}
949761
func (d draw) LineSeries(r Renderer, canvasBox Box, xrange, yrange Range, style Style, vs ValuesProvider) {
	if vs.Len() == 0 {
		return
	}

	cb := canvasBox.Bottom
	cl := canvasBox.Left

	v0x, v0y := vs.GetValues(0)
	x0 := cl + xrange.Translate(v0x)
	y0 := cb - yrange.Translate(v0y)

	yv0 := yrange.Translate(0)

	var vx, vy float64
	var x, y int

	if style.ShouldDrawStroke() && style.ShouldDrawFill() {
		style.GetFillOptions().WriteDrawingOptionsToRenderer(r)
		r.MoveTo(x0, y0)
		for i := 1; i < vs.Len(); i++ {
			vx, vy = vs.GetValues(i)
			x = cl + xrange.Translate(vx)
			y = cb - yrange.Translate(vy)
			r.LineTo(x, y)
		}
		r.LineTo(x, util.Math.MinInt(cb, cb-yv0))
		r.LineTo(x0, util.Math.MinInt(cb, cb-yv0))
		r.LineTo(x0, y0)
		r.Fill()
	}

	if style.ShouldDrawStroke() {
		style.GetStrokeOptions().WriteDrawingOptionsToRenderer(r)

		r.MoveTo(x0, y0)
		for i := 1; i < vs.Len(); i++ {
			vx, vy = vs.GetValues(i)
			x = cl + xrange.Translate(vx)
			y = cb - yrange.Translate(vy)
			r.LineTo(x, y)
		}
		r.Stroke()
	}

	if style.ShouldDrawDot() {
		defaultDotWidth := style.GetDotWidth()

		style.GetDotOptions().WriteDrawingOptionsToRenderer(r)
		for i := 0; i < vs.Len(); i++ {
			vx, vy = vs.GetValues(i)
			x = cl + xrange.Translate(vx)
			y = cb - yrange.Translate(vy)

			dotWidth := defaultDotWidth
			if style.DotWidthProvider != nil {
				dotWidth = style.DotWidthProvider(xrange, yrange, i, vx, vy)
			}

			if style.DotColorProvider != nil {
				dotColor := style.DotColorProvider(xrange, yrange, i, vx, vy)

				r.SetFillColor(dotColor)
				r.SetStrokeColor(dotColor)
			}

			r.Circle(dotWidth, x, y)
			r.FillStroke()
		}
	}
}
795219
func NewDrawable(p image.Image) draw.Image {
	r := p.Bounds()
	if _, ok := p.(*image.Uniform); ok {
		r = image.Rect(0, 0, 1, 1)
	}
	return NewDrawableSize(p, r)
}
432125
func DrawElementsInstanced(mode uint32, count int32, xtype uint32, indices unsafe.Pointer, instancecount int32) {
	C.glowDrawElementsInstanced(gpDrawElementsInstanced, (C.GLenum)(mode), (C.GLsizei)(count), (C.GLenum)(xtype), indices, (C.GLsizei)(instancecount))
}
1065169
func (dest *Destination) implicitWithdraw(newPath *Path) {
	found := -1
	for i, path := range dest.knownPathList {
		if newPath.NoImplicitWithdraw() {
			continue
		}
		// Here we just check if source is same and not check if path
		// version num. as newPaths are implicit withdrawal of old
		// paths and when doing RouteRefresh (not EnhancedRouteRefresh)
		// we get same paths again.
		if newPath.GetSource().Equal(path.GetSource()) && newPath.GetNlri().PathIdentifier() == path.GetNlri().PathIdentifier() {
			log.WithFields(log.Fields{
				"Topic": "Table",
				"Key":   dest.GetNlri().String(),
				"Path":  path,
			}).Debug("Implicit withdrawal of old path, since we have learned new path from the same peer")

			found = i
			newPath.GetNlri().SetPathLocalIdentifier(path.GetNlri().PathLocalIdentifier())
			break
		}
	}
	if found != -1 {
		dest.knownPathList = append(dest.knownPathList[:found], dest.knownPathList[found+1:]...)
	}
}
1097423
func (f *Flex) Draw(screen tcell.Screen) {
	f.Box.Draw(screen)

	// Calculate size and position of the items.

	// Do we use the entire screen?
	if f.fullScreen {
		width, height := screen.Size()
		f.SetRect(0, 0, width, height)
	}

	// How much space can we distribute?
	x, y, width, height := f.GetInnerRect()
	var proportionSum int
	distSize := width
	if f.direction == FlexRow {
		distSize = height
	}
	for _, item := range f.items {
		if item.FixedSize > 0 {
			distSize -= item.FixedSize
		} else {
			proportionSum += item.Proportion
		}
	}

	// Calculate positions and draw items.
	pos := x
	if f.direction == FlexRow {
		pos = y
	}
	for _, item := range f.items {
		size := item.FixedSize
		if size <= 0 {
			size = distSize * item.Proportion / proportionSum
			distSize -= size
			proportionSum -= item.Proportion
		}
		if item.Item != nil {
			if f.direction == FlexColumn {
				item.Item.SetRect(pos, y, size, height)
			} else {
				item.Item.SetRect(x, pos, width, size)
			}
		}
		pos += size

		if item.Item != nil {
			if item.Item.GetFocusable().HasFocus() {
				defer item.Item.Draw(screen)
			} else {
				item.Item.Draw(screen)
			}
		}
	}
}
1044545
func (g *Gui) draw(v *View) error {
	if g.Cursor {
		if curview := g.currentView; curview != nil {
			vMaxX, vMaxY := curview.Size()
			if curview.cx < 0 {
				curview.cx = 0
			} else if curview.cx >= vMaxX {
				curview.cx = vMaxX - 1
			}
			if curview.cy < 0 {
				curview.cy = 0
			} else if curview.cy >= vMaxY {
				curview.cy = vMaxY - 1
			}

			gMaxX, gMaxY := g.Size()
			cx, cy := curview.x0+curview.cx+1, curview.y0+curview.cy+1
			if cx >= 0 && cx < gMaxX && cy >= 0 && cy < gMaxY {
				termbox.SetCursor(cx, cy)
			} else {
				termbox.HideCursor()
			}
		}
	} else {
		termbox.HideCursor()
	}

	v.clearRunes()
	if err := v.draw(); err != nil {
		return err
	}
	return nil
}
1214969
func baseShader(c *Canvas) {
	gs := &glShader{
		vf: defaultCanvasVertexFormat,
		vs: baseCanvasVertexShader,
		fs: baseCanvasFragmentShader,
	}

	gs.setUniform("uTransform", &gs.uniformDefaults.transform)
	gs.setUniform("uColorMask", &gs.uniformDefaults.colormask)
	gs.setUniform("uBounds", &gs.uniformDefaults.bounds)
	gs.setUniform("uTexBounds", &gs.uniformDefaults.texbounds)

	c.shader = gs
}
644446
func (win *Window) GroupEnd() {
	panelEnd(win.ctx, win)
	win.parent.usingSub = false

	// immediate drawing
	win.parent.cmds.Commands = append(win.parent.cmds.Commands, win.cmds.Commands...)
}
65785
func (f *File) drawScatterChart(formatSet *formatChart) *cPlotArea {
	return &cPlotArea{
		ScatterChart: &cCharts{
			ScatterStyle: &attrValString{
				Val: "smoothMarker", // line,lineMarker,marker,none,smooth,smoothMarker
			},
			VaryColors: &attrValBool{
				Val: false,
			},
			Ser:   f.drawChartSeries(formatSet),
			DLbls: f.drawChartDLbls(formatSet),
			AxID: []*attrValInt{
				{Val: 754001152},
				{Val: 753999904},
			},
		},
		CatAx: f.drawPlotAreaCatAx(formatSet),
		ValAx: f.drawPlotAreaValAx(formatSet),
	}
}
496535
func (window *Window) GLGetDrawableSize() (w, h int32) {
	var _w, _h C.int
	C.SDL_GL_GetDrawableSize(window.cptr(), &_w, &_h)
	return int32(_w), int32(_h)
}
1330626
func (f *File) drawChartSeriesDPt(i int, formatSet *formatChart) []*cDPt {
	dpt := []*cDPt{{
		IDx:      &attrValInt{Val: i},
		Bubble3D: &attrValBool{Val: false},
		SpPr: &cSpPr{
			SolidFill: &aSolidFill{
				SchemeClr: &aSchemeClr{Val: "accent" + strconv.Itoa(i+1)},
			},
			Ln: &aLn{
				W:   25400,
				Cap: "rnd",
				SolidFill: &aSolidFill{
					SchemeClr: &aSchemeClr{Val: "lt" + strconv.Itoa(i+1)},
				},
			},
			Sp3D: &aSp3D{
				ContourW: 25400,
				ContourClr: &aContourClr{
					SchemeClr: &aSchemeClr{Val: "lt" + strconv.Itoa(i+1)},
				},
			},
		},
	}}
	chartSeriesDPt := map[string][]*cDPt{Area: nil, AreaStacked: nil, AreaPercentStacked: nil, Area3D: nil, Area3DStacked: nil, Area3DPercentStacked: nil, Bar: nil, BarStacked: nil, BarPercentStacked: nil, Bar3DClustered: nil, Bar3DStacked: nil, Bar3DPercentStacked: nil, Col: nil, ColStacked: nil, ColPercentStacked: nil, Col3DClustered: nil, Col3D: nil, Col3DStacked: nil, Col3DPercentStacked: nil, Doughnut: nil, Line: nil, Pie: dpt, Pie3D: dpt, Radar: nil, Scatter: nil}
	return chartSeriesDPt[formatSet.Type]
}
700313
func (rr *rasterRenderer) Stroke() {
	rr.gc.SetStrokeColor(rr.s.StrokeColor)
	rr.gc.SetLineWidth(rr.s.StrokeWidth)
	rr.gc.SetLineDash(rr.s.StrokeDashArray, 0)
	rr.gc.Stroke()
}
592329
func (f *File) addDrawingShape(sheet, drawingXML, cell string, formatSet *formatShape) error {
	fromCol, fromRow, err := CellNameToCoordinates(cell)
	if err != nil {
		return err
	}
	colIdx := fromCol - 1
	rowIdx := fromRow - 1

	textUnderlineType := map[string]bool{
		"none":            true,
		"words":           true,
		"sng":             true,
		"dbl":             true,
		"heavy":           true,
		"dotted":          true,
		"dottedHeavy":     true,
		"dash":            true,
		"dashHeavy":       true,
		"dashLong":        true,
		"dashLongHeavy":   true,
		"dotDash":         true,
		"dotDashHeavy":    true,
		"dotDotDash":      true,
		"dotDotDashHeavy": true,
		"wavy":            true,
		"wavyHeavy":       true,
		"wavyDbl":         true,
	}

	width := int(float64(formatSet.Width) * formatSet.Format.XScale)
	height := int(float64(formatSet.Height) * formatSet.Format.YScale)

	colStart, rowStart, _, _, colEnd, rowEnd, x2, y2 :=
		f.positionObjectPixels(sheet, colIdx, rowIdx, formatSet.Format.OffsetX, formatSet.Format.OffsetY,
			width, height)
	content, cNvPrID := f.drawingParser(drawingXML)
	twoCellAnchor := xdrCellAnchor{}
	twoCellAnchor.EditAs = formatSet.Format.Positioning
	from := xlsxFrom{}
	from.Col = colStart
	from.ColOff = formatSet.Format.OffsetX * EMU
	from.Row = rowStart
	from.RowOff = formatSet.Format.OffsetY * EMU
	to := xlsxTo{}
	to.Col = colEnd
	to.ColOff = x2 * EMU
	to.Row = rowEnd
	to.RowOff = y2 * EMU
	twoCellAnchor.From = &from
	twoCellAnchor.To = &to
	shape := xdrSp{
		NvSpPr: &xdrNvSpPr{
			CNvPr: &xlsxCNvPr{
				ID:   cNvPrID,
				Name: "Shape " + strconv.Itoa(cNvPrID),
			},
			CNvSpPr: &xdrCNvSpPr{
				TxBox: true,
			},
		},
		SpPr: &xlsxSpPr{
			PrstGeom: xlsxPrstGeom{
				Prst: formatSet.Type,
			},
		},
		Style: &xdrStyle{
			LnRef:     setShapeRef(formatSet.Color.Line, 2),
			FillRef:   setShapeRef(formatSet.Color.Fill, 1),
			EffectRef: setShapeRef(formatSet.Color.Effect, 0),
			FontRef: &aFontRef{
				Idx: "minor",
				SchemeClr: &attrValString{
					Val: "tx1",
				},
			},
		},
		TxBody: &xdrTxBody{
			BodyPr: &aBodyPr{
				VertOverflow: "clip",
				HorzOverflow: "clip",
				Wrap:         "none",
				RtlCol:       false,
				Anchor:       "t",
			},
		},
	}
	if len(formatSet.Paragraph) < 1 {
		formatSet.Paragraph = []formatShapeParagraph{
			{
				Font: formatFont{
					Bold:      false,
					Italic:    false,
					Underline: "none",
					Family:    "Calibri",
					Size:      11,
					Color:     "#000000",
				},
				Text: " ",
			},
		}
	}
	for _, p := range formatSet.Paragraph {
		u := p.Font.Underline
		_, ok := textUnderlineType[u]
		if !ok {
			u = "none"
		}
		text := p.Text
		if text == "" {
			text = " "
		}
		paragraph := &aP{
			R: &aR{
				RPr: aRPr{
					I:       p.Font.Italic,
					B:       p.Font.Bold,
					Lang:    "en-US",
					AltLang: "en-US",
					U:       u,
					Sz:      p.Font.Size * 100,
					Latin:   &aLatin{Typeface: p.Font.Family},
					SolidFill: &aSolidFill{
						SrgbClr: &attrValString{
							Val: strings.Replace(strings.ToUpper(p.Font.Color), "#", "", -1),
						},
					},
				},
				T: text,
			},
			EndParaRPr: &aEndParaRPr{
				Lang: "en-US",
			},
		}
		shape.TxBody.P = append(shape.TxBody.P, paragraph)
	}
	twoCellAnchor.Sp = &shape
	twoCellAnchor.ClientData = &xdrClientData{
		FLocksWithSheet:  formatSet.Format.FLocksWithSheet,
		FPrintsWithSheet: formatSet.Format.FPrintsWithSheet,
	}
	content.TwoCellAnchor = append(content.TwoCellAnchor, &twoCellAnchor)
	f.Drawings[drawingXML] = content
	return err
}