// Place text at the given x and y coordinate.
// fg is the foreground color, while bg is the background color.
498136
func Write(x int, y int, text string, fg termbox.Attribute, bg termbox.Attribute) {
	//runeCount := utf8.RuneCountInString(text)
	pos := x
	for _, r := range text {
		termbox.SetCell(pos, y, r, fg, bg)
		pos++
	}
}
940119
func (gp *GoPdf) SetTextColor(r uint8, g uint8, b uint8) {
	rgb := Rgb{
		r: r,
		g: g,
		b: b,
	}
	gp.curr.setTextColor(rgb)
}
781030
func (as *Step) AddText(text string) bool {
	as.Text = append(as.Text, text)
	return true
}
358249
func Add(bg image.Image, fg image.Image) *image.RGBA {
	dst := blend(bg, fg, func(c0, c1 fcolor.RGBAF64) fcolor.RGBAF64 {
		r := c0.R + c1.R
		g := c0.G + c1.G
		b := c0.B + c1.B

		c2 := fcolor.RGBAF64{R: r, G: g, B: b, A: c1.A}
		return alphaComp(c0, c2)
	})

	return dst
}
136615
func AddTo(sp *svg.SVG, x, y, width, height int, font string, fontsize int, background color.RGBA) *SvgGraphics {
	s := New(sp, width, height, font, fontsize, background)
	s.tx, s.ty = x, y
	return s
}
803832
func (*DefaultScene) Setup(u engo.Updater) {
	w, _ := u.(*ecs.World)

	common.SetBackground(color.White)
	w.AddSystem(&common.RenderSystem{})
	w.AddSystem(&TypingSystem{})

	fnt := &common.Font{
		URL:  "Roboto-Regular.ttf",
		FG:   color.Black,
		Size: 64,
	}
	err := fnt.CreatePreloaded()
	if err != nil {
		panic(err)
	}

	label1 := MyLabel{BasicEntity: ecs.NewBasic()}
	label1.RenderComponent.Drawable = common.Text{
		Font: fnt,
		Text: "Start Typing to add text!",
	}

	for _, system := range w.Systems() {
		switch sys := system.(type) {
		case *common.RenderSystem:
			sys.Add(&label1.BasicEntity, &label1.RenderComponent, &label1.SpaceComponent)
		}
	}
}
325879
func (c *BoxChart) Plot(g Graphics) {
	// layout
	layout := layout(g, c.Title, c.XRange.Label, c.YRange.Label,
		c.XRange.TicSetting.Hide || c.XRange.TicSetting.HideLabels,
		c.YRange.TicSetting.Hide || c.YRange.TicSetting.HideLabels,
		&c.Key)
	width, height := layout.Width, layout.Height
	topm, leftm := layout.Top, layout.Left
	numxtics, numytics := layout.NumXtics, layout.NumYtics
	// fontwidth, fontheight, _ := g.FontMetrics(DataStyle{})

	g.Begin()

	c.XRange.Setup(numxtics, numxtics+2, width, leftm, false)
	c.YRange.Setup(numytics, numytics+1, height, topm, true)

	if c.Title != "" {
		drawTitle(g, c.Title, elementStyle(c.Options, TitleElement))
	}

	g.XAxis(c.XRange, topm+height, topm, c.Options)
	g.YAxis(c.YRange, leftm, leftm+width, c.Options)

	yf := c.YRange.Data2Screen
	nan := math.NaN()
	for _, data := range c.Data {
		// Samples
		nums := len(data.Samples)
		bw := width / (2*nums - 1)

		boxes := make([]Box, len(data.Samples))
		for i, d := range data.Samples {
			x := float64(c.XRange.Data2Screen(d.X))
			// DebugLogger.Printf("Q1=%.2f  Q3=%.3f", d.Q1, d.Q3)
			q1, q3 := float64(yf(d.Q1)), float64(yf(d.Q3))
			med, avg := nan, nan
			high, low := nan, nan
			if !math.IsNaN(d.Med) {
				med = float64(yf(d.Med))
			}
			if !math.IsNaN(d.Avg) {
				avg = float64(yf(d.Avg))
			}
			if !math.IsNaN(d.High) {
				high = float64(yf(d.High))
			}
			if !math.IsNaN(d.Low) {
				low = float64(yf(d.Low))
			}

			outliers := make([]float64, len(d.Outliers))
			for j, ol := range d.Outliers {
				outliers[j] = float64(c.YRange.Data2Screen(ol))
			}
			boxes[i].X = x
			boxes[i].Q1 = q1
			boxes[i].Q3 = q3
			boxes[i].Med = med
			boxes[i].Avg = avg
			boxes[i].High = high
			boxes[i].Low = low
			boxes[i].Outliers = outliers
		}
		g.Boxes(boxes, bw, data.Style)
	}

	if !c.Key.Hide {
		g.Key(layout.KeyX, layout.KeyY, c.Key, c.Options)
	}

	g.End()
}
224933
func BgBrightCyan(arg interface{}) Value {
	if val, ok := arg.(Value); ok {
		return val.BgBrightCyan()
	}
	return value{value: arg, color: BrightBg | CyanBg}
}
834146
func (f *Font) TextDimensions(text string) (int, int, int) {
	fnt := f.TTF
	size := f.Size
	var (
		totalWidth  = fixed.Int26_6(0)
		totalHeight = fixed.Int26_6(size)
		maxYBearing = fixed.Int26_6(0)
	)
	fupe := fixed.Int26_6(fnt.FUnitsPerEm())

	for _, char := range text {
		idx := fnt.Index(char)
		hm := fnt.HMetric(fupe, idx)
		vm := fnt.VMetric(fupe, idx)
		g := truetype.GlyphBuf{}
		err := g.Load(fnt, fupe, idx, font.HintingNone)
		if err != nil {
			log.Println(err)
			return 0, 0, 0
		}
		totalWidth += hm.AdvanceWidth

		yB := (vm.TopSideBearing * fixed.Int26_6(size)) / fupe
		if yB > maxYBearing {
			maxYBearing = yB
		}
		dY := (vm.AdvanceHeight * fixed.Int26_6(size)) / fupe
		if dY > totalHeight {
			totalHeight = dY
		}
	}

	// Scale to actual pixel size
	totalWidth *= fixed.Int26_6(size)
	totalWidth /= fupe

	return int(totalWidth), int(totalHeight), int(maxYBearing)
}
1284107
func (t *Text) SetPosition(v mgl32.Vec2) {
	// transform to orthographic coordinates ranged -1 to 1 for the shader
	t.finalPosition[0] = v.X() / (t.Font.WindowWidth / 2)
	t.finalPosition[1] = v.Y() / (t.Font.WindowHeight / 2)
	if gltext.IsDebug {
		t.BoundingBox.finalPosition[0] = v.X() / (t.Font.WindowWidth / 2)
		t.BoundingBox.finalPosition[1] = v.Y() / (t.Font.WindowHeight / 2)
	}
	t.Position = v
}
260918
func (m *Monitor) Position() (x, y float64) {
	var xi, yi int
	mainthread.Call(func() {
		xi, yi = m.monitor.GetPos()
	})
	x = float64(xi)
	y = float64(yi)
	return
}
1069193
func (*DefaultScene) Setup(u engo.Updater) {
	w, _ := u.(*ecs.World)

	common.SetBackground(color.White)
	w.AddSystem(&common.RenderSystem{})

	// Adding KeyboardScroller so we can actually see the difference between the HUD and non-HUD text
	w.AddSystem(common.NewKeyboardScroller(scrollSpeed, engo.DefaultHorizontalAxis, engo.DefaultVerticalAxis))
	w.AddSystem(&common.MouseZoomer{zoomSpeed})

	fnt := &common.Font{
		URL:  "Roboto-Regular.ttf",
		FG:   color.Black,
		Size: 64,
	}
	err := fnt.CreatePreloaded()
	if err != nil {
		panic(err)
	}

	label1 := MyLabel{BasicEntity: ecs.NewBasic()}
	label1.RenderComponent.Drawable = common.Text{
		Font: fnt,
		Text: "Hello world !",
	}
	label1.SetShader(common.HUDShader)

	label2 := MyLabel{BasicEntity: ecs.NewBasic()}
	label2.RenderComponent.Drawable = common.Text{
		Font:          fnt,
		Text:          "This may also be text\nwhich includes a newline. ",
		LineSpacing:   0.5,
		LetterSpacing: 0.15,
	}

	for _, system := range w.Systems() {
		switch sys := system.(type) {
		case *common.RenderSystem:
			sys.Add(&label1.BasicEntity, &label1.RenderComponent, &label1.SpaceComponent)
			sys.Add(&label2.BasicEntity, &label2.RenderComponent, &label2.SpaceComponent)
		}
	}
}
1227907
func (c *ScatterChart) AddFunc(name string, f func(float64) float64, plotstyle PlotStyle, style Style) {
	if plotstyle.undefined() {
		plotstyle = PlotStyleLines
	}
	if style.empty() {
		style = AutoStyle(len(c.Data), false)
	}

	scd := ScatterChartData{Name: name, PlotStyle: plotstyle, Style: style, Samples: nil, Func: f}
	c.Data = append(c.Data, scd)
	if name != "" {
		ke := KeyEntry{Text: name, PlotStyle: plotstyle, Style: style}
		c.Key.Entries = append(c.Key.Entries, ke)
	}
}
1066037
func (rgc *RasterGraphicContext) FillStringAt(text string, x, y float64) (cursor float64, err error) {
	cursor, err = rgc.CreateStringPath(text, x, y)
	rgc.Fill()
	return
}
712956
func RGB(r, g, b float64) RGBA {
	return RGBA{r, g, b, 1}
}
1168068
func (v *ComboBox) AppendText(text string) {
	deprecated_since(2, 24, 0, "gtk_combo_box_append_text()")
	ptr := C.CString(text)
	defer cfree(ptr)
	C.gtk_combo_box_append_text(COMBO_BOX(v), gstring(ptr))
}
43401
func (tb *TextBuf) Rect(x, y, w, h int, style int, fill rune) {
	style = style % len(Edge)

	if h < 0 {
		h = -h
		y -= h
	}
	if w < 0 {
		w = -w
		x -= w
	}

	tb.Put(x, y, Edge[style][0])
	tb.Put(x+w, y, Edge[style][1])
	tb.Put(x, y+h, Edge[style][2])
	tb.Put(x+w, y+h, Edge[style][3])
	for i := 1; i < w; i++ {
		tb.Put(x+i, y, '-')
		tb.Put(x+i, y+h, '-')
	}
	for i := 1; i < h; i++ {
		tb.Put(x+w, y+i, '|')
		tb.Put(x, y+i, '|')
		if fill > 0 {
			for j := x + 1; j < x+w; j++ {
				tb.Put(j, y+i, fill)
			}
		}
	}
}