Update C sources, add new functions and rename package to
This commit is contained in:
parent
391c25482d
commit
08aa518a46
156 changed files with 34542 additions and 19573 deletions
|
@ -8,35 +8,35 @@ func main() {
|
|||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
raylib.InitWindow(screenWidth, screenHeight, "raylib [text] example - bmfont and ttf sprite fonts loading")
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [text] example - bmfont and ttf sprite fonts loading")
|
||||
|
||||
msgBm := "THIS IS AN AngelCode SPRITE FONT"
|
||||
msgTtf := "THIS SPRITE FONT has been GENERATED from a TTF"
|
||||
|
||||
// NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
|
||||
fontBm := raylib.LoadFont("fonts/bmfont.fnt") // BMFont (AngelCode)
|
||||
fontTtf := raylib.LoadFont("fonts/pixantiqua.ttf") // TTF font
|
||||
fontBm := rl.LoadFont("fonts/bmfont.fnt") // BMFont (AngelCode)
|
||||
fontTtf := rl.LoadFont("fonts/pixantiqua.ttf") // TTF font
|
||||
|
||||
fontPosition := raylib.Vector2{}
|
||||
fontPosition := rl.Vector2{}
|
||||
|
||||
fontPosition.X = float32(screenWidth)/2 - raylib.MeasureTextEx(fontBm, msgBm, float32(fontBm.BaseSize), 0).X/2
|
||||
fontPosition.X = float32(screenWidth)/2 - rl.MeasureTextEx(fontBm, msgBm, float32(fontBm.BaseSize), 0).X/2
|
||||
fontPosition.Y = float32(screenHeight)/2 - float32(fontBm.BaseSize)/2 - 80
|
||||
|
||||
raylib.SetTargetFPS(60)
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !raylib.WindowShouldClose() {
|
||||
raylib.BeginDrawing()
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.BeginDrawing()
|
||||
|
||||
raylib.ClearBackground(raylib.RayWhite)
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
raylib.DrawTextEx(fontBm, msgBm, fontPosition, float32(fontBm.BaseSize), 0, raylib.Maroon)
|
||||
raylib.DrawTextEx(fontTtf, msgTtf, raylib.NewVector2(75.0, 240.0), float32(fontTtf.BaseSize)*0.8, 2, raylib.Lime)
|
||||
rl.DrawTextEx(fontBm, msgBm, fontPosition, float32(fontBm.BaseSize), 0, rl.Maroon)
|
||||
rl.DrawTextEx(fontTtf, msgTtf, rl.NewVector2(75.0, 240.0), float32(fontTtf.BaseSize)*0.8, 2, rl.Lime)
|
||||
|
||||
raylib.EndDrawing()
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
raylib.UnloadFont(fontBm) // AngelCode Font unloading
|
||||
raylib.UnloadFont(fontTtf) // TTF Font unloading
|
||||
rl.UnloadFont(fontBm) // AngelCode Font unloading
|
||||
rl.UnloadFont(fontTtf) // TTF Font unloading
|
||||
|
||||
raylib.CloseWindow()
|
||||
rl.CloseWindow()
|
||||
}
|
||||
|
|
|
@ -10,32 +10,32 @@ func main() {
|
|||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
raylib.InitWindow(screenWidth, screenHeight, "raylib [text] example - bmfont unordered loading and drawing")
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [text] example - bmfont unordered loading and drawing")
|
||||
|
||||
// NOTE: Using chars outside the [32..127] limits!
|
||||
// NOTE: If a character is not found in the font, it just renders a space
|
||||
msg := "ASCII extended characters:\n¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆ\nÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæ\nçèéêëìíîïðñòóôõö÷øùúûüýþÿ"
|
||||
|
||||
// NOTE: Loaded font has an unordered list of characters (chars in the range 32..255)
|
||||
font := raylib.LoadFont("fonts/pixantiqua.fnt") // BMFont (AngelCode)
|
||||
font := rl.LoadFont("fonts/pixantiqua.fnt") // BMFont (AngelCode)
|
||||
|
||||
raylib.SetTargetFPS(60)
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !raylib.WindowShouldClose() {
|
||||
raylib.BeginDrawing()
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.BeginDrawing()
|
||||
|
||||
raylib.ClearBackground(raylib.RayWhite)
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
raylib.DrawText("Font name: PixAntiqua", 40, 50, 20, raylib.Gray)
|
||||
raylib.DrawText(fmt.Sprintf("Font base size: %d", font.BaseSize), 40, 80, 20, raylib.Gray)
|
||||
raylib.DrawText(fmt.Sprintf("Font chars number: %d", font.CharsCount), 40, 110, 20, raylib.Gray)
|
||||
rl.DrawText("Font name: PixAntiqua", 40, 50, 20, rl.Gray)
|
||||
rl.DrawText(fmt.Sprintf("Font base size: %d", font.BaseSize), 40, 80, 20, rl.Gray)
|
||||
rl.DrawText(fmt.Sprintf("Font chars number: %d", font.CharsCount), 40, 110, 20, rl.Gray)
|
||||
|
||||
raylib.DrawTextEx(font, msg, raylib.NewVector2(40, 180), float32(font.BaseSize), 0, raylib.Maroon)
|
||||
rl.DrawTextEx(font, msg, rl.NewVector2(40, 180), float32(font.BaseSize), 0, rl.Maroon)
|
||||
|
||||
raylib.EndDrawing()
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
raylib.UnloadFont(font) // AngelCode Font unloading
|
||||
rl.UnloadFont(font) // AngelCode Font unloading
|
||||
|
||||
raylib.CloseWindow()
|
||||
rl.CloseWindow()
|
||||
}
|
||||
|
|
|
@ -10,29 +10,29 @@ func main() {
|
|||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
raylib.InitWindow(screenWidth, screenHeight, "raylib [text] example - text formatting")
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [text] example - text formatting")
|
||||
|
||||
score := 100020
|
||||
hiscore := 200450
|
||||
lives := 5
|
||||
|
||||
raylib.SetTargetFPS(60)
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !raylib.WindowShouldClose() {
|
||||
raylib.BeginDrawing()
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.BeginDrawing()
|
||||
|
||||
raylib.ClearBackground(raylib.RayWhite)
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
raylib.DrawText(fmt.Sprintf("Score: %08d", score), 200, 80, 20, raylib.Red)
|
||||
rl.DrawText(fmt.Sprintf("Score: %08d", score), 200, 80, 20, rl.Red)
|
||||
|
||||
raylib.DrawText(fmt.Sprintf("HiScore: %08d", hiscore), 200, 120, 20, raylib.Green)
|
||||
rl.DrawText(fmt.Sprintf("HiScore: %08d", hiscore), 200, 120, 20, rl.Green)
|
||||
|
||||
raylib.DrawText(fmt.Sprintf("Lives: %02d", lives), 200, 160, 40, raylib.Blue)
|
||||
rl.DrawText(fmt.Sprintf("Lives: %02d", lives), 200, 160, 40, rl.Blue)
|
||||
|
||||
raylib.DrawText(fmt.Sprintf("Elapsed Time: %02.02f ms", raylib.GetFrameTime()*1000), 200, 220, 20, raylib.Black)
|
||||
rl.DrawText(fmt.Sprintf("Elapsed Time: %02.02f ms", rl.GetFrameTime()*1000), 200, 220, 20, rl.Black)
|
||||
|
||||
raylib.EndDrawing()
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
raylib.CloseWindow()
|
||||
rl.CloseWindow()
|
||||
}
|
||||
|
|
|
@ -10,17 +10,17 @@ func main() {
|
|||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
raylib.InitWindow(screenWidth, screenHeight, "raylib [text] example - raylib fonts")
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [text] example - raylib fonts")
|
||||
|
||||
fonts := make([]raylib.Font, maxFonts)
|
||||
fonts[0] = raylib.LoadFont("fonts/alagard.png")
|
||||
fonts[1] = raylib.LoadFont("fonts/pixelplay.png")
|
||||
fonts[2] = raylib.LoadFont("fonts/mecha.png")
|
||||
fonts[3] = raylib.LoadFont("fonts/setback.png")
|
||||
fonts[4] = raylib.LoadFont("fonts/romulus.png")
|
||||
fonts[5] = raylib.LoadFont("fonts/pixantiqua.png")
|
||||
fonts[6] = raylib.LoadFont("fonts/alpha_beta.png")
|
||||
fonts[7] = raylib.LoadFont("fonts/jupiter_crash.png")
|
||||
fonts := make([]rl.Font, maxFonts)
|
||||
fonts[0] = rl.LoadFont("fonts/alagard.png")
|
||||
fonts[1] = rl.LoadFont("fonts/pixelplay.png")
|
||||
fonts[2] = rl.LoadFont("fonts/mecha.png")
|
||||
fonts[3] = rl.LoadFont("fonts/setback.png")
|
||||
fonts[4] = rl.LoadFont("fonts/romulus.png")
|
||||
fonts[5] = rl.LoadFont("fonts/pixantiqua.png")
|
||||
fonts[6] = rl.LoadFont("fonts/alpha_beta.png")
|
||||
fonts[7] = rl.LoadFont("fonts/jupiter_crash.png")
|
||||
|
||||
messages := []string{
|
||||
"ALAGARD FONT designed by Hewett Tsoi",
|
||||
|
@ -34,13 +34,13 @@ func main() {
|
|||
}
|
||||
|
||||
spacings := []float32{2, 4, 8, 4, 3, 4, 4, 1}
|
||||
positions := make([]raylib.Vector2, maxFonts)
|
||||
positions := make([]rl.Vector2, maxFonts)
|
||||
|
||||
var i int32
|
||||
for i = 0; i < maxFonts; i++ {
|
||||
x := screenWidth/2 - int32(raylib.MeasureTextEx(fonts[i], messages[i], float32(fonts[i].BaseSize*2), spacings[i]).X/2)
|
||||
x := screenWidth/2 - int32(rl.MeasureTextEx(fonts[i], messages[i], float32(fonts[i].BaseSize*2), spacings[i]).X/2)
|
||||
y := 60 + fonts[i].BaseSize + 45*i
|
||||
positions[i] = raylib.NewVector2(float32(x), float32(y))
|
||||
positions[i] = rl.NewVector2(float32(x), float32(y))
|
||||
}
|
||||
|
||||
// Small Y position corrections
|
||||
|
@ -48,27 +48,27 @@ func main() {
|
|||
positions[4].Y += 2
|
||||
positions[7].Y -= 8
|
||||
|
||||
colors := []raylib.Color{raylib.Maroon, raylib.Orange, raylib.DarkGreen, raylib.DarkBlue, raylib.DarkPurple, raylib.Lime, raylib.Gold, raylib.DarkBrown}
|
||||
colors := []rl.Color{rl.Maroon, rl.Orange, rl.DarkGreen, rl.DarkBlue, rl.DarkPurple, rl.Lime, rl.Gold, rl.DarkBrown}
|
||||
|
||||
raylib.SetTargetFPS(60)
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !raylib.WindowShouldClose() {
|
||||
raylib.BeginDrawing()
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.BeginDrawing()
|
||||
|
||||
raylib.ClearBackground(raylib.RayWhite)
|
||||
raylib.DrawText("free fonts included with raylib", 250, 20, 20, raylib.DarkGray)
|
||||
raylib.DrawLine(220, 50, 590, 50, raylib.DarkGray)
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
rl.DrawText("free fonts included with raylib", 250, 20, 20, rl.DarkGray)
|
||||
rl.DrawLine(220, 50, 590, 50, rl.DarkGray)
|
||||
|
||||
for i = 0; i < maxFonts; i++ {
|
||||
raylib.DrawTextEx(fonts[i], messages[i], positions[i], float32(fonts[i].BaseSize*2), spacings[i], colors[i])
|
||||
rl.DrawTextEx(fonts[i], messages[i], positions[i], float32(fonts[i].BaseSize*2), spacings[i], colors[i])
|
||||
}
|
||||
|
||||
raylib.EndDrawing()
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
for i = 0; i < maxFonts; i++ {
|
||||
raylib.UnloadFont(fonts[i])
|
||||
rl.UnloadFont(fonts[i])
|
||||
}
|
||||
|
||||
raylib.CloseWindow()
|
||||
rl.CloseWindow()
|
||||
}
|
||||
|
|
|
@ -8,45 +8,45 @@ func main() {
|
|||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
raylib.InitWindow(screenWidth, screenHeight, "raylib [text] example - sprite fonts usage")
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [text] example - sprite fonts usage")
|
||||
|
||||
msg1 := "THIS IS A custom SPRITE FONT..."
|
||||
msg2 := "...and this is ANOTHER CUSTOM font..."
|
||||
msg3 := "...and a THIRD one! GREAT! :D"
|
||||
|
||||
// NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
|
||||
font1 := raylib.LoadFont("fonts/custom_mecha.png") // Font loading
|
||||
font2 := raylib.LoadFont("fonts/custom_alagard.png") // Font loading
|
||||
font3 := raylib.LoadFont("fonts/custom_jupiter_crash.png") // Font loading
|
||||
font1 := rl.LoadFont("fonts/custom_mecha.png") // Font loading
|
||||
font2 := rl.LoadFont("fonts/custom_alagard.png") // Font loading
|
||||
font3 := rl.LoadFont("fonts/custom_jupiter_crash.png") // Font loading
|
||||
|
||||
var fontPosition1, fontPosition2, fontPosition3 raylib.Vector2
|
||||
var fontPosition1, fontPosition2, fontPosition3 rl.Vector2
|
||||
|
||||
fontPosition1.X = float32(screenWidth)/2 - raylib.MeasureTextEx(font1, msg1, float32(font1.BaseSize), -3).X/2
|
||||
fontPosition1.X = float32(screenWidth)/2 - rl.MeasureTextEx(font1, msg1, float32(font1.BaseSize), -3).X/2
|
||||
fontPosition1.Y = float32(screenHeight)/2 - float32(font1.BaseSize)/2 - 80
|
||||
|
||||
fontPosition2.X = float32(screenWidth)/2 - raylib.MeasureTextEx(font2, msg2, float32(font2.BaseSize), -2).X/2
|
||||
fontPosition2.X = float32(screenWidth)/2 - rl.MeasureTextEx(font2, msg2, float32(font2.BaseSize), -2).X/2
|
||||
fontPosition2.Y = float32(screenHeight)/2 - float32(font2.BaseSize)/2 - 10
|
||||
|
||||
fontPosition3.X = float32(screenWidth)/2 - raylib.MeasureTextEx(font3, msg3, float32(font3.BaseSize), 2).X/2
|
||||
fontPosition3.X = float32(screenWidth)/2 - rl.MeasureTextEx(font3, msg3, float32(font3.BaseSize), 2).X/2
|
||||
fontPosition3.Y = float32(screenHeight)/2 - float32(font3.BaseSize)/2 + 50
|
||||
|
||||
raylib.SetTargetFPS(60)
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !raylib.WindowShouldClose() {
|
||||
raylib.BeginDrawing()
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.BeginDrawing()
|
||||
|
||||
raylib.ClearBackground(raylib.RayWhite)
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
raylib.DrawTextEx(font1, msg1, fontPosition1, float32(font1.BaseSize), -3, raylib.White)
|
||||
raylib.DrawTextEx(font2, msg2, fontPosition2, float32(font2.BaseSize), -2, raylib.White)
|
||||
raylib.DrawTextEx(font3, msg3, fontPosition3, float32(font3.BaseSize), 2, raylib.White)
|
||||
rl.DrawTextEx(font1, msg1, fontPosition1, float32(font1.BaseSize), -3, rl.White)
|
||||
rl.DrawTextEx(font2, msg2, fontPosition2, float32(font2.BaseSize), -2, rl.White)
|
||||
rl.DrawTextEx(font3, msg3, fontPosition3, float32(font3.BaseSize), 2, rl.White)
|
||||
|
||||
raylib.EndDrawing()
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
raylib.UnloadFont(font1) // Font unloading
|
||||
raylib.UnloadFont(font2) // Font unloading
|
||||
raylib.UnloadFont(font3) // Font unloading
|
||||
rl.UnloadFont(font1) // Font unloading
|
||||
rl.UnloadFont(font2) // Font unloading
|
||||
rl.UnloadFont(font3) // Font unloading
|
||||
|
||||
raylib.CloseWindow()
|
||||
rl.CloseWindow()
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ func main() {
|
|||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
raylib.InitWindow(screenWidth, screenHeight, "raylib [text] example - ttf loading")
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [text] example - ttf loading")
|
||||
|
||||
msg := "TTF Font"
|
||||
|
||||
|
@ -19,94 +19,94 @@ func main() {
|
|||
fontChars := int32(0)
|
||||
|
||||
// TTF Font loading with custom generation parameters
|
||||
font := raylib.LoadFontEx("fonts/KAISG.ttf", 96, 0, &fontChars)
|
||||
font := rl.LoadFontEx("fonts/KAISG.ttf", 96, 0, &fontChars)
|
||||
|
||||
// Generate mipmap levels to use trilinear filtering
|
||||
// NOTE: On 2D drawing it won't be noticeable, it looks like FILTER_BILINEAR
|
||||
raylib.GenTextureMipmaps(&font.Texture)
|
||||
rl.GenTextureMipmaps(&font.Texture)
|
||||
|
||||
fontSize := font.BaseSize
|
||||
fontPosition := raylib.NewVector2(40, float32(screenHeight)/2+50)
|
||||
textSize := raylib.Vector2{}
|
||||
fontPosition := rl.NewVector2(40, float32(screenHeight)/2+50)
|
||||
textSize := rl.Vector2{}
|
||||
|
||||
raylib.SetTextureFilter(font.Texture, raylib.FilterPoint)
|
||||
rl.SetTextureFilter(font.Texture, rl.FilterPoint)
|
||||
currentFontFilter := 0 // FilterPoint
|
||||
|
||||
count := int32(0)
|
||||
droppedFiles := make([]string, 0)
|
||||
|
||||
raylib.SetTargetFPS(60)
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !raylib.WindowShouldClose() {
|
||||
for !rl.WindowShouldClose() {
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
fontSize += raylib.GetMouseWheelMove() * 4.0
|
||||
fontSize += rl.GetMouseWheelMove() * 4.0
|
||||
|
||||
// Choose font texture filter method
|
||||
if raylib.IsKeyPressed(raylib.KeyOne) {
|
||||
raylib.SetTextureFilter(font.Texture, raylib.FilterPoint)
|
||||
if rl.IsKeyPressed(rl.KeyOne) {
|
||||
rl.SetTextureFilter(font.Texture, rl.FilterPoint)
|
||||
currentFontFilter = 0
|
||||
} else if raylib.IsKeyPressed(raylib.KeyTwo) {
|
||||
raylib.SetTextureFilter(font.Texture, raylib.FilterBilinear)
|
||||
} else if rl.IsKeyPressed(rl.KeyTwo) {
|
||||
rl.SetTextureFilter(font.Texture, rl.FilterBilinear)
|
||||
currentFontFilter = 1
|
||||
} else if raylib.IsKeyPressed(raylib.KeyThree) {
|
||||
} else if rl.IsKeyPressed(rl.KeyThree) {
|
||||
// NOTE: Trilinear filter won't be noticed on 2D drawing
|
||||
raylib.SetTextureFilter(font.Texture, raylib.FilterTrilinear)
|
||||
rl.SetTextureFilter(font.Texture, rl.FilterTrilinear)
|
||||
currentFontFilter = 2
|
||||
}
|
||||
|
||||
textSize = raylib.MeasureTextEx(font, msg, float32(fontSize), 0)
|
||||
textSize = rl.MeasureTextEx(font, msg, float32(fontSize), 0)
|
||||
|
||||
if raylib.IsKeyDown(raylib.KeyLeft) {
|
||||
if rl.IsKeyDown(rl.KeyLeft) {
|
||||
fontPosition.X -= 10
|
||||
} else if raylib.IsKeyDown(raylib.KeyRight) {
|
||||
} else if rl.IsKeyDown(rl.KeyRight) {
|
||||
fontPosition.X += 10
|
||||
}
|
||||
|
||||
// Load a dropped TTF file dynamically (at current fontSize)
|
||||
if raylib.IsFileDropped() {
|
||||
droppedFiles = raylib.GetDroppedFiles(&count)
|
||||
if rl.IsFileDropped() {
|
||||
droppedFiles = rl.GetDroppedFiles(&count)
|
||||
|
||||
if count == 1 { // Only support one ttf file dropped
|
||||
raylib.UnloadFont(font)
|
||||
font = raylib.LoadFontEx(droppedFiles[0], fontSize, 0, &fontChars)
|
||||
raylib.ClearDroppedFiles()
|
||||
rl.UnloadFont(font)
|
||||
font = rl.LoadFontEx(droppedFiles[0], fontSize, 0, &fontChars)
|
||||
rl.ClearDroppedFiles()
|
||||
}
|
||||
}
|
||||
|
||||
raylib.BeginDrawing()
|
||||
rl.BeginDrawing()
|
||||
|
||||
raylib.ClearBackground(raylib.RayWhite)
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
raylib.DrawText("Use mouse wheel to change font size", 20, 20, 10, raylib.Gray)
|
||||
raylib.DrawText("Use KEY_RIGHT and KEY_LEFT to move text", 20, 40, 10, raylib.Gray)
|
||||
raylib.DrawText("Use 1, 2, 3 to change texture filter", 20, 60, 10, raylib.Gray)
|
||||
raylib.DrawText("Drop a new TTF font for dynamic loading", 20, 80, 10, raylib.DarkGray)
|
||||
rl.DrawText("Use mouse wheel to change font size", 20, 20, 10, rl.Gray)
|
||||
rl.DrawText("Use KEY_RIGHT and KEY_LEFT to move text", 20, 40, 10, rl.Gray)
|
||||
rl.DrawText("Use 1, 2, 3 to change texture filter", 20, 60, 10, rl.Gray)
|
||||
rl.DrawText("Drop a new TTF font for dynamic loading", 20, 80, 10, rl.DarkGray)
|
||||
|
||||
raylib.DrawTextEx(font, msg, fontPosition, float32(fontSize), 0, raylib.Black)
|
||||
rl.DrawTextEx(font, msg, fontPosition, float32(fontSize), 0, rl.Black)
|
||||
|
||||
// TODO: It seems texSize measurement is not accurate due to chars offsets...
|
||||
//raylib.DrawRectangleLines(int32(fontPosition.X), int32(fontPosition.Y), int32(textSize.X), int32(textSize.Y), raylib.Red)
|
||||
//rl.DrawRectangleLines(int32(fontPosition.X), int32(fontPosition.Y), int32(textSize.X), int32(textSize.Y), rl.Red)
|
||||
|
||||
raylib.DrawRectangle(0, screenHeight-80, screenWidth, 80, raylib.LightGray)
|
||||
raylib.DrawText(fmt.Sprintf("Font size: %02.02f", float32(fontSize)), 20, screenHeight-50, 10, raylib.DarkGray)
|
||||
raylib.DrawText(fmt.Sprintf("Text size: [%02.02f, %02.02f]", textSize.X, textSize.Y), 20, screenHeight-30, 10, raylib.DarkGray)
|
||||
raylib.DrawText("CURRENT TEXTURE FILTER:", 250, 400, 20, raylib.Gray)
|
||||
rl.DrawRectangle(0, screenHeight-80, screenWidth, 80, rl.LightGray)
|
||||
rl.DrawText(fmt.Sprintf("Font size: %02.02f", float32(fontSize)), 20, screenHeight-50, 10, rl.DarkGray)
|
||||
rl.DrawText(fmt.Sprintf("Text size: [%02.02f, %02.02f]", textSize.X, textSize.Y), 20, screenHeight-30, 10, rl.DarkGray)
|
||||
rl.DrawText("CURRENT TEXTURE FILTER:", 250, 400, 20, rl.Gray)
|
||||
|
||||
if currentFontFilter == 0 {
|
||||
raylib.DrawText("POINT", 570, 400, 20, raylib.Black)
|
||||
rl.DrawText("POINT", 570, 400, 20, rl.Black)
|
||||
} else if currentFontFilter == 1 {
|
||||
raylib.DrawText("BILINEAR", 570, 400, 20, raylib.Black)
|
||||
rl.DrawText("BILINEAR", 570, 400, 20, rl.Black)
|
||||
} else if currentFontFilter == 2 {
|
||||
raylib.DrawText("TRILINEAR", 570, 400, 20, raylib.Black)
|
||||
rl.DrawText("TRILINEAR", 570, 400, 20, rl.Black)
|
||||
}
|
||||
|
||||
raylib.EndDrawing()
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
raylib.UnloadFont(font) // Font unloading
|
||||
rl.UnloadFont(font) // Font unloading
|
||||
|
||||
raylib.ClearDroppedFiles() // Clear internal buffers
|
||||
rl.ClearDroppedFiles() // Clear internal buffers
|
||||
|
||||
raylib.CloseWindow()
|
||||
rl.CloseWindow()
|
||||
}
|
||||
|
|
|
@ -8,24 +8,24 @@ func main() {
|
|||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
raylib.InitWindow(screenWidth, screenHeight, "raylib [text] example - text writing anim")
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [text] example - text writing anim")
|
||||
|
||||
message := "This sample illustrates a text writing\nanimation effect! Check it out! ;)"
|
||||
length := len(message)
|
||||
|
||||
framesCounter := 0
|
||||
|
||||
raylib.SetTargetFPS(60)
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !raylib.WindowShouldClose() {
|
||||
for !rl.WindowShouldClose() {
|
||||
// Update
|
||||
if raylib.IsKeyDown(raylib.KeySpace) {
|
||||
if rl.IsKeyDown(rl.KeySpace) {
|
||||
framesCounter += 8
|
||||
} else {
|
||||
framesCounter++
|
||||
}
|
||||
|
||||
if raylib.IsKeyPressed(raylib.KeyEnter) {
|
||||
if rl.IsKeyPressed(rl.KeyEnter) {
|
||||
framesCounter = 0
|
||||
}
|
||||
|
||||
|
@ -34,17 +34,17 @@ func main() {
|
|||
}
|
||||
|
||||
// Draw
|
||||
raylib.BeginDrawing()
|
||||
rl.BeginDrawing()
|
||||
|
||||
raylib.ClearBackground(raylib.RayWhite)
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
raylib.DrawText(message[0:framesCounter/10], 210, 160, 20, raylib.Maroon)
|
||||
rl.DrawText(message[0:framesCounter/10], 210, 160, 20, rl.Maroon)
|
||||
|
||||
raylib.DrawText("PRESS [ENTER] to RESTART!", 240, 260, 20, raylib.LightGray)
|
||||
raylib.DrawText("PRESS [SPACE] to SPEED UP!", 239, 300, 20, raylib.LightGray)
|
||||
rl.DrawText("PRESS [ENTER] to RESTART!", 240, 260, 20, rl.LightGray)
|
||||
rl.DrawText("PRESS [SPACE] to SPEED UP!", 239, 300, 20, rl.LightGray)
|
||||
|
||||
raylib.EndDrawing()
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
raylib.CloseWindow()
|
||||
rl.CloseWindow()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue