Update C sources, add new functions
This commit is contained in:
parent
e6a1abb290
commit
a6d36a3699
98 changed files with 7964 additions and 2985 deletions
|
@ -19,8 +19,8 @@ func main() {
|
|||
parrots := raylib.LoadImage("parrots.png") // Load image in CPU memory (RAM)
|
||||
|
||||
// Draw one image over the other with a scaling of 1.5f
|
||||
raylib.ImageDraw(parrots, cat, raylib.NewRectangle(0, 0, cat.Width, cat.Height), raylib.NewRectangle(30, 40, int32(float32(cat.Width)*1.5), int32(float32(cat.Height)*1.5)))
|
||||
raylib.ImageCrop(parrots, raylib.NewRectangle(0, 50, parrots.Width, parrots.Height-100)) // Crop resulting image
|
||||
raylib.ImageDraw(parrots, cat, raylib.NewRectangle(0, 0, float32(cat.Width), float32(cat.Height)), raylib.NewRectangle(30, 40, float32(cat.Width)*1.5, float32(cat.Height)*1.5))
|
||||
raylib.ImageCrop(parrots, raylib.NewRectangle(0, 50, float32(parrots.Width), float32(parrots.Height-100))) // Crop resulting image
|
||||
|
||||
raylib.UnloadImage(cat) // Unload image from RAM
|
||||
|
||||
|
|
|
@ -35,17 +35,17 @@ func main() {
|
|||
|
||||
raylib.InitWindow(screenWidth, screenHeight, "raylib [textures] example - image processing")
|
||||
|
||||
image := raylib.LoadImage("parrots.png") // Loaded in CPU memory (RAM)
|
||||
raylib.ImageFormat(image, int32(raylib.UncompressedR8g8b8a8)) // Format image to RGBA 32bit (required for texture update)
|
||||
texture := raylib.LoadTextureFromImage(image) // Image converted to texture, GPU memory (VRAM)
|
||||
image := raylib.LoadImage("parrots.png") // Loaded in CPU memory (RAM)
|
||||
raylib.ImageFormat(image, raylib.UncompressedR8g8b8a8) // Format image to RGBA 32bit (required for texture update)
|
||||
texture := raylib.LoadTextureFromImage(image) // Image converted to texture, GPU memory (VRAM)
|
||||
|
||||
currentProcess := None
|
||||
textureReload := false
|
||||
|
||||
selectRecs := make([]raylib.Rectangle, numProcesses)
|
||||
|
||||
for i := int32(0); i < numProcesses; i++ {
|
||||
selectRecs[i] = raylib.NewRectangle(40, 50+32*i, 150, 30)
|
||||
for i := 0; i < numProcesses; i++ {
|
||||
selectRecs[i] = raylib.NewRectangle(40, 50+32*float32(i), 150, 30)
|
||||
}
|
||||
|
||||
raylib.SetTargetFPS(60)
|
||||
|
@ -114,12 +114,12 @@ func main() {
|
|||
for i := 0; i < numProcesses; i++ {
|
||||
if i == currentProcess {
|
||||
raylib.DrawRectangleRec(selectRecs[i], raylib.SkyBlue)
|
||||
raylib.DrawRectangleLines(selectRecs[i].X, selectRecs[i].Y, selectRecs[i].Width, selectRecs[i].Height, raylib.Blue)
|
||||
raylib.DrawText(processText[i], selectRecs[i].X+selectRecs[i].Width/2-raylib.MeasureText(processText[i], 10)/2, selectRecs[i].Y+11, 10, raylib.DarkBlue)
|
||||
raylib.DrawRectangleLines(int32(selectRecs[i].X), int32(selectRecs[i].Y), int32(selectRecs[i].Width), int32(selectRecs[i].Height), raylib.Blue)
|
||||
raylib.DrawText(processText[i], int32(selectRecs[i].X+selectRecs[i].Width/2)-raylib.MeasureText(processText[i], 10)/2, int32(selectRecs[i].Y)+11, 10, raylib.DarkBlue)
|
||||
} else {
|
||||
raylib.DrawRectangleRec(selectRecs[i], raylib.LightGray)
|
||||
raylib.DrawRectangleLines(selectRecs[i].X, selectRecs[i].Y, selectRecs[i].Width, selectRecs[i].Height, raylib.Gray)
|
||||
raylib.DrawText(processText[i], selectRecs[i].X+selectRecs[i].Width/2-raylib.MeasureText(processText[i], 10)/2, selectRecs[i].Y+11, 10, raylib.DarkGray)
|
||||
raylib.DrawRectangleLines(int32(selectRecs[i].X), int32(selectRecs[i].Y), int32(selectRecs[i].Width), int32(selectRecs[i].Height), raylib.Gray)
|
||||
raylib.DrawText(processText[i], int32(selectRecs[i].X+selectRecs[i].Width/2)-raylib.MeasureText(processText[i], 10)/2, int32(selectRecs[i].Y)+11, 10, raylib.DarkGray)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@ func main() {
|
|||
|
||||
raylib.InitWindow(screenWidth, screenHeight, "raylib [textures] example - image text drawing")
|
||||
|
||||
// TTF SpriteFont loading with custom generation parameters
|
||||
// TTF Font loading with custom generation parameters
|
||||
var fontChars int32
|
||||
font := raylib.LoadSpriteFontEx("fonts/KAISG.ttf", 64, 0, &fontChars)
|
||||
font := raylib.LoadFontEx("fonts/KAISG.ttf", 64, 0, &fontChars)
|
||||
|
||||
parrots := raylib.LoadImage("parrots.png") // Load image in CPU memory (RAM)
|
||||
|
||||
|
@ -56,7 +56,7 @@ func main() {
|
|||
}
|
||||
|
||||
raylib.UnloadTexture(texture)
|
||||
raylib.UnloadSpriteFont(font)
|
||||
raylib.UnloadFont(font)
|
||||
|
||||
raylib.CloseWindow()
|
||||
}
|
||||
|
|
|
@ -95,8 +95,8 @@ func main() {
|
|||
if mouseTail[i].Active {
|
||||
raylib.DrawTexturePro(
|
||||
smoke,
|
||||
raylib.NewRectangle(0, 0, smoke.Width, smoke.Height),
|
||||
raylib.NewRectangle(int32(mouseTail[i].Position.X), int32(mouseTail[i].Position.Y), smoke.Width*int32(mouseTail[i].Size), smoke.Height*int32(mouseTail[i].Size)),
|
||||
raylib.NewRectangle(0, 0, float32(smoke.Width), float32(smoke.Height)),
|
||||
raylib.NewRectangle(mouseTail[i].Position.X, mouseTail[i].Position.Y, float32(smoke.Width)*mouseTail[i].Size, float32(smoke.Height)*mouseTail[i].Size),
|
||||
raylib.NewVector2(float32(smoke.Width)*mouseTail[i].Size/2, float32(smoke.Height)*mouseTail[i].Size/2),
|
||||
mouseTail[i].Rotation,
|
||||
raylib.Fade(mouseTail[i].Color, mouseTail[i].Alpha),
|
||||
|
|
|
@ -21,8 +21,8 @@ func main() {
|
|||
scarfy := raylib.LoadTexture("scarfy.png") // Texture loading
|
||||
|
||||
position := raylib.NewVector2(350.0, 280.0)
|
||||
frameRec := raylib.NewRectangle(0, 0, scarfy.Width/6, scarfy.Height)
|
||||
currentFrame := int32(0)
|
||||
frameRec := raylib.NewRectangle(0, 0, float32(scarfy.Width/6), float32(scarfy.Height))
|
||||
currentFrame := float32(0)
|
||||
|
||||
framesCounter := 0
|
||||
framesSpeed := 8 // Number of spritesheet frames shown by second
|
||||
|
@ -40,7 +40,7 @@ func main() {
|
|||
currentFrame = 0
|
||||
}
|
||||
|
||||
frameRec.X = currentFrame * scarfy.Width / 6
|
||||
frameRec.X = currentFrame * float32(scarfy.Width) / 6
|
||||
}
|
||||
|
||||
if raylib.IsKeyPressed(raylib.KeyRight) {
|
||||
|
@ -61,7 +61,7 @@ func main() {
|
|||
|
||||
raylib.DrawTexture(scarfy, 15, 40, raylib.White)
|
||||
raylib.DrawRectangleLines(15, 40, scarfy.Width, scarfy.Height, raylib.Lime)
|
||||
raylib.DrawRectangleLines(15+frameRec.X, 40+frameRec.Y, frameRec.Width, frameRec.Height, raylib.Red)
|
||||
raylib.DrawRectangleLines(15+int32(frameRec.X), 40+int32(frameRec.Y), int32(frameRec.Width), int32(frameRec.Height), raylib.Red)
|
||||
|
||||
raylib.DrawText("FRAME SPEED: ", 165, 210, 10, raylib.DarkGray)
|
||||
raylib.DrawText(fmt.Sprintf("%02d FPS", framesSpeed), 575, 210, 10, raylib.DarkGray)
|
||||
|
|
|
@ -13,14 +13,14 @@ func main() {
|
|||
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
||||
scarfy := raylib.LoadTexture("scarfy.png") // Texture loading
|
||||
|
||||
frameWidth := scarfy.Width / 7
|
||||
frameHeight := scarfy.Height
|
||||
frameWidth := float32(scarfy.Width) / 7
|
||||
frameHeight := float32(scarfy.Height)
|
||||
|
||||
// NOTE: Source rectangle (part of the texture to use for drawing)
|
||||
sourceRec := raylib.NewRectangle(0, 0, int32(frameWidth), int32(frameHeight))
|
||||
sourceRec := raylib.NewRectangle(0, 0, frameWidth, frameHeight)
|
||||
|
||||
// NOTE: Destination rectangle (screen rectangle where drawing part of texture)
|
||||
destRec := raylib.NewRectangle(screenWidth/2, screenHeight/2, frameWidth*2, frameHeight*2)
|
||||
destRec := raylib.NewRectangle(float32(screenWidth)/2, float32(screenHeight)/2, frameWidth*2, frameHeight*2)
|
||||
|
||||
// NOTE: Origin of the texture (rotation/scale point), it's relative to destination rectangle size
|
||||
origin := raylib.NewVector2(float32(frameWidth), float32(frameHeight))
|
||||
|
@ -45,8 +45,8 @@ func main() {
|
|||
// rotation defines the texture rotation (using origin as rotation point)
|
||||
raylib.DrawTexturePro(scarfy, sourceRec, destRec, origin, rotation, raylib.White)
|
||||
|
||||
raylib.DrawLine(destRec.X, 0, destRec.X, screenHeight, raylib.Gray)
|
||||
raylib.DrawLine(0, destRec.Y, screenWidth, destRec.Y, raylib.Gray)
|
||||
raylib.DrawLine(int32(destRec.X), 0, int32(destRec.X), screenHeight, raylib.Gray)
|
||||
raylib.DrawLine(0, int32(destRec.Y), screenWidth, int32(destRec.Y), raylib.Gray)
|
||||
|
||||
raylib.DrawText("(c) Scarfy sprite by Eiden Marsal", screenWidth-200, screenHeight-20, 10, raylib.Gray)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue