diff --git a/examples/error-scene/main.go b/examples/error-scene/main.go index c071953c..02de8666 100644 --- a/examples/error-scene/main.go +++ b/examples/error-scene/main.go @@ -13,10 +13,10 @@ func main() { // go to an unknown scene controller.ErrorScene = "error" controller.AddScene("typo", scene.Scene{Start: func(ctx *scene.Context) { - ctx.DrawStack.Draw(render.NewStrText("Real scene", 100, 100)) + ctx.DrawStack.Draw(render.NewText("Real scene", 100, 100)) }}) controller.AddScene("error", scene.Scene{Start: func(ctx *scene.Context) { - ctx.DrawStack.Draw(render.NewStrText("Error scene", 100, 100)) + ctx.DrawStack.Draw(render.NewText("Error scene", 100, 100)) }}) controller.Init("typpo") diff --git a/examples/joystick-viz/main.go b/examples/joystick-viz/main.go index cfa42bf6..2d185d91 100644 --- a/examples/joystick-viz/main.go +++ b/examples/joystick-viz/main.go @@ -242,7 +242,7 @@ func main() { latestInput := new(string) *latestInput = "Latest Input: None" ctx.DrawStack.Draw(render.NewStrPtrText(latestInput, 10, 460), 4) - ctx.DrawStack.Draw(render.NewStrText("Space to Vibrate", 10, 440), 4) + ctx.DrawStack.Draw(render.NewText("Space to Vibrate", 10, 440), 4) ctx.EventHandler.GlobalBind(event.InputChange, func(_ event.CID, payload interface{}) int { input := payload.(oak.InputType) switch input { diff --git a/examples/keyboard-test/main.go b/examples/keyboard-test/main.go index 59cd56e9..52fae470 100644 --- a/examples/keyboard-test/main.go +++ b/examples/keyboard-test/main.go @@ -15,7 +15,7 @@ var keys = map[rune]struct{}{} func main() { oak.AddScene("keyboard-test", scene.Scene{Start: func(*scene.Context) { - kRenderable := render.NewStrText("", 40, 40) + kRenderable := render.NewText("", 40, 40) render.Draw(kRenderable, 0) event.GlobalBind(key.Down, func(_ event.CID, k interface{}) int { kValue := k.(key.Event) diff --git a/examples/screenopts/main.go b/examples/screenopts/main.go index 03ed3023..d1b0b9bd 100644 --- a/examples/screenopts/main.go +++ b/examples/screenopts/main.go @@ -17,7 +17,7 @@ const ( func main() { oak.AddScene("demo", scene.Scene{Start: func(*scene.Context) { - txt := render.NewStrText("Press F to toggle fullscreen. Press B to toggle borderless.", 50, 50) + txt := render.NewText("Press F to toggle fullscreen. Press B to toggle borderless.", 50, 50) render.Draw(txt) borderless := borderlessAtStart diff --git a/examples/titlescreen-demo/main.go b/examples/titlescreen-demo/main.go index f6c2bf92..9cda7718 100644 --- a/examples/titlescreen-demo/main.go +++ b/examples/titlescreen-demo/main.go @@ -40,7 +40,7 @@ func main() { oak.AddScene("titlescreen", scene.Scene{Start: func(ctx *scene.Context) { //create text saying titlescreen in placeholder position - titleText := render.NewStrText("titlescreen", 0, 0) + titleText := render.NewText("titlescreen", 0, 0) //center text along both axes center(ctx, titleText, Both) @@ -49,7 +49,7 @@ func main() { render.Draw(titleText) //do the same for the text with button instuctions, but this time Y position is not a placeholder (X still is) - instructionText := render.NewStrText("press Enter to start, or press Q to quit", 0, float64(ctx.Window.Height()*3/4)) + instructionText := render.NewText("press Enter to start, or press Q to quit", 0, float64(ctx.Window.Height()*3/4)) //this time we only center the X axis, otherwise it would overlap titleText center(ctx, instructionText, X) render.Draw(instructionText) @@ -80,7 +80,7 @@ func main() { //we have to get the visual part specificaly, and not the whole thing. render.Draw(player.R) - controlsText := render.NewStrText("WASD to move, ESC to return to titlescreen", 5, 20) + controlsText := render.NewText("WASD to move, ESC to return to titlescreen", 5, 20) //we draw the text on layer 1 (instead of the default layer 0) //because we want it to show up above the player render.Draw(controlsText, 1) diff --git a/examples/zooming/main.go b/examples/zooming/main.go index 0f3836e4..8ad6fb16 100644 --- a/examples/zooming/main.go +++ b/examples/zooming/main.go @@ -20,7 +20,7 @@ var ( func main() { oak.AddScene("demo", scene.Scene{Start: func(*scene.Context) { - render.Draw(render.NewStrText("Controls: Arrow keys", 500, 440)) + render.Draw(render.NewText("Controls: Arrow keys", 500, 440)) // Get an image that we will illustrate zooming with later s, err := render.LoadSprite("assets", filepath.Join("raw", "mona-lisa.jpg")) diff --git a/render/defaultfont.go b/render/defaultfont.go index 6b077d23..cd16f13c 100644 --- a/render/defaultfont.go +++ b/render/defaultfont.go @@ -9,8 +9,8 @@ import ( // so storing the result and calling these functions on the stored Font is // recommended in cases where performance is a concern. -// NewText creates a text element using the default font. -func NewText(str fmt.Stringer, x, y float64) *Text { +// NewStringerText creates a text element using the default font and a stringer. +func NewStringerText(str fmt.Stringer, x, y float64) *Text { return DefaultFont().NewStringerText(str, x, y) } @@ -20,8 +20,8 @@ func NewIntText(str *int, x, y float64) *Text { return DefaultFont().NewIntText(str, x, y) } -// NewStrText is a helper to take in a string instead of a Stringer for NewText -func NewStrText(str string, x, y float64) *Text { +// NewText is a helper to create a text element with the default font and a string. +func NewText(str string, x, y float64) *Text { return DefaultFont().NewText(str, x, y) } diff --git a/render/defaultfont_test.go b/render/defaultfont_test.go index d83d8b12..7338d696 100644 --- a/render/defaultfont_test.go +++ b/render/defaultfont_test.go @@ -6,11 +6,11 @@ import ( func TestLegacyFont(t *testing.T) { initTestFont() - if NewText(dummyStringer{}, 0, 0) == nil { - t.Fatalf("NewText failed") + if NewStringerText(dummyStringer{}, 0, 0) == nil { + t.Fatalf("NewStringerText failed") } - if NewStrText("text", 0, 0) == nil { - t.Fatalf("NewStrText failed") + if NewText("text", 0, 0) == nil { + t.Fatalf("NewText failed") } if NewIntText(new(int), 0, 0) == nil { t.Fatalf("NewIntText failed")