2
0
mirror of https://github.com/raylib-cs/raylib-cs synced 2025-06-30 19:03:42 -04:00

Update enum/color names to match C# naming convention (#224)

This commit is contained in:
Danil
2024-01-18 21:00:57 +02:00
committed by GitHub
parent 2a1889403d
commit 70d86837d4
123 changed files with 1843 additions and 1847 deletions

View File

@ -69,34 +69,34 @@ public class BackgroundScrolling
// Draw background image twice
// NOTE: Texture is scaled twice its size
DrawTextureEx(background, new Vector2(scrollingBack, 20), 0.0f, 2.0f, Color.WHITE);
DrawTextureEx(background, new Vector2(scrollingBack, 20), 0.0f, 2.0f, Color.White);
DrawTextureEx(
background,
new Vector2(background.Width * 2 + scrollingBack, 20),
0.0f,
2.0f,
Color.WHITE
Color.White
);
// Draw midground image twice
DrawTextureEx(midground, new Vector2(scrollingMid, 20), 0.0f, 2.0f, Color.WHITE);
DrawTextureEx(midground, new Vector2(midground.Width * 2 + scrollingMid, 20), 0.0f, 2.0f, Color.WHITE);
DrawTextureEx(midground, new Vector2(scrollingMid, 20), 0.0f, 2.0f, Color.White);
DrawTextureEx(midground, new Vector2(midground.Width * 2 + scrollingMid, 20), 0.0f, 2.0f, Color.White);
// Draw foreground image twice
DrawTextureEx(foreground, new Vector2(scrollingFore, 70), 0.0f, 2.0f, Color.WHITE);
DrawTextureEx(foreground, new Vector2(scrollingFore, 70), 0.0f, 2.0f, Color.White);
DrawTextureEx(
foreground,
new Vector2(foreground.Width * 2 + scrollingFore, 70),
0.0f,
2.0f,
Color.WHITE
Color.White
);
DrawText("BACKGROUND SCROLLING & PARALLAX", 10, 10, 20, Color.RED);
DrawText("BACKGROUND SCROLLING & PARALLAX", 10, 10, 20, Color.Red);
int x = screenWidth - 330;
int y = screenHeight - 20;
DrawText("(c) Cyberpunk Street Environment by Luis Zuno (@ansimuz)", x, y, 10, Color.RAYWHITE);
DrawText("(c) Cyberpunk Street Environment by Luis Zuno (@ansimuz)", x, y, 10, Color.RayWhite);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -47,7 +47,7 @@ public class BlendModes
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KeyboardKey.KEY_SPACE))
if (IsKeyPressed(KeyboardKey.Space))
{
if ((int)blendMode >= (blendCountMax - 1))
{
@ -63,42 +63,42 @@ public class BlendModes
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
int bgX = screenWidth / 2 - bgTexture.Width / 2;
int bgY = screenHeight / 2 - bgTexture.Height / 2;
DrawTexture(bgTexture, bgX, bgY, Color.WHITE);
DrawTexture(bgTexture, bgX, bgY, Color.White);
// Apply the blend mode and then draw the foreground texture
BeginBlendMode(blendMode);
int fgX = screenWidth / 2 - fgTexture.Width / 2;
int fgY = screenHeight / 2 - fgTexture.Height / 2;
DrawTexture(fgTexture, fgX, fgY, Color.WHITE);
DrawTexture(fgTexture, fgX, fgY, Color.White);
EndBlendMode();
// Draw the texts
DrawText("Press SPACE to change blend modes.", 310, 350, 10, Color.GRAY);
DrawText("Press SPACE to change blend modes.", 310, 350, 10, Color.Gray);
switch (blendMode)
{
case BlendMode.BLEND_ALPHA:
DrawText("Current: BLEND_ALPHA", (screenWidth / 2) - 60, 370, 10, Color.GRAY);
case BlendMode.Alpha:
DrawText("Current: BLEND_ALPHA", (screenWidth / 2) - 60, 370, 10, Color.Gray);
break;
case BlendMode.BLEND_ADDITIVE:
DrawText("Current: BLEND_ADDITIVE", (screenWidth / 2) - 60, 370, 10, Color.GRAY);
case BlendMode.Additive:
DrawText("Current: BLEND_ADDITIVE", (screenWidth / 2) - 60, 370, 10, Color.Gray);
break;
case BlendMode.BLEND_MULTIPLIED:
DrawText("Current: BLEND_MULTIPLIED", (screenWidth / 2) - 60, 370, 10, Color.GRAY);
case BlendMode.Multiplied:
DrawText("Current: BLEND_MULTIPLIED", (screenWidth / 2) - 60, 370, 10, Color.Gray);
break;
case BlendMode.BLEND_ADD_COLORS:
DrawText("Current: BLEND_ADD_COLORS", (screenWidth / 2) - 60, 370, 10, Color.GRAY);
case BlendMode.AddColors:
DrawText("Current: BLEND_ADD_COLORS", (screenWidth / 2) - 60, 370, 10, Color.Gray);
break;
default:
break;
}
string text = "(c) Cyberpunk Street Environment by Luis Zuno (@ansimuz)";
DrawText(text, screenWidth - 330, screenHeight - 20, 10, Color.GRAY);
DrawText(text, screenWidth - 330, screenHeight - 20, 10, Color.Gray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -53,7 +53,7 @@ public class Bunnymark
{
// Update
//----------------------------------------------------------------------------------
if (IsMouseButtonDown(MouseButton.MOUSE_LEFT_BUTTON))
if (IsMouseButtonDown(MouseButton.Left))
{
// Create more bunnies
for (int i = 0; i < 100; i++)
@ -98,7 +98,7 @@ public class Bunnymark
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
for (int i = 0; i < bunniesCount; i++)
{
@ -111,9 +111,9 @@ public class Bunnymark
DrawTexture(texBunny, (int)bunnies[i].Position.X, (int)bunnies[i].Position.Y, bunnies[i].Color);
}
DrawRectangle(0, 0, screenWidth, 40, Color.BLACK);
DrawText($"bunnies: {bunniesCount}", 120, 10, 20, Color.GREEN);
DrawText($"batched draw calls: {1 + bunniesCount / MAX_BATCH_ELEMENTS}", 320, 10, 20, Color.MAROON);
DrawRectangle(0, 0, screenWidth, 40, Color.Black);
DrawText($"bunnies: {bunniesCount}", 120, 10, 20, Color.Green);
DrawText($"batched draw calls: {1 + bunniesCount / MAX_BATCH_ELEMENTS}", 320, 10, 20, Color.Maroon);
DrawFPS(10, 10);

View File

@ -27,14 +27,14 @@ public class DrawTiled
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(ConfigFlags.FLAG_WINDOW_RESIZABLE);
SetConfigFlags(ConfigFlags.ResizableWindow);
InitWindow(screenWidth, screenHeight, "raylib [textures] example - Draw part of a texture tiled");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Texture2D texPattern = LoadTexture("resources/patterns.png");
// Makes the texture smoother when upscaled
SetTextureFilter(texPattern, TextureFilter.TEXTURE_FILTER_TRILINEAR);
SetTextureFilter(texPattern, TextureFilter.Trilinear);
// Coordinates for all patterns inside the texture
Rectangle[] recPattern = new[] {
@ -49,16 +49,16 @@ public class DrawTiled
// Setup colors
Color[] colors = new[]
{
Color.BLACK,
Color.MAROON,
Color.ORANGE,
Color.BLUE,
Color.PURPLE,
Color.BEIGE,
Color.LIME,
Color.RED,
Color.DARKGRAY,
Color.SKYBLUE
Color.Black,
Color.Maroon,
Color.Orange,
Color.Blue,
Color.Purple,
Color.Beige,
Color.Lime,
Color.Red,
Color.DarkGray,
Color.SkyBlue
};
Rectangle[] colorRec = new Rectangle[colors.Length];
@ -96,7 +96,7 @@ public class DrawTiled
screenHeight = GetScreenHeight();
// Handle mouse
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON))
if (IsMouseButtonPressed(MouseButton.Left))
{
Vector2 mouse = GetMousePosition();
@ -130,11 +130,11 @@ public class DrawTiled
// Handle keys
// Change scale
if (IsKeyPressed(KeyboardKey.KEY_UP))
if (IsKeyPressed(KeyboardKey.Up))
{
scale += 0.25f;
}
if (IsKeyPressed(KeyboardKey.KEY_DOWN))
if (IsKeyPressed(KeyboardKey.Down))
{
scale -= 0.25f;
}
@ -148,17 +148,17 @@ public class DrawTiled
}
// Change rotation
if (IsKeyPressed(KeyboardKey.KEY_LEFT))
if (IsKeyPressed(KeyboardKey.Left))
{
rotation -= 25.0f;
}
if (IsKeyPressed(KeyboardKey.KEY_RIGHT))
if (IsKeyPressed(KeyboardKey.Right))
{
rotation += 25.0f;
}
// Reset
if (IsKeyPressed(KeyboardKey.KEY_SPACE))
if (IsKeyPressed(KeyboardKey.Space))
{
rotation = 0.0f;
scale = 1.0f;
@ -168,7 +168,7 @@ public class DrawTiled
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// Draw the tiled area
Rectangle source = recPattern[activePattern];
@ -181,39 +181,39 @@ public class DrawTiled
DrawTextureTiled(texPattern, source, dest, Vector2.Zero, rotation, scale, colors[activeCol]);
// Draw options
Color color = ColorAlpha(Color.LIGHTGRAY, 0.5f);
Color color = ColorAlpha(Color.LightGray, 0.5f);
DrawRectangle(MarginSize, MarginSize, OptWidth - MarginSize, screenHeight - 2 * MarginSize, color);
DrawText("Select Pattern", 2 + MarginSize, 30 + MarginSize, 10, Color.BLACK);
DrawTexture(texPattern, 2 + MarginSize, 40 + MarginSize, Color.BLACK);
DrawText("Select Pattern", 2 + MarginSize, 30 + MarginSize, 10, Color.Black);
DrawTexture(texPattern, 2 + MarginSize, 40 + MarginSize, Color.Black);
DrawRectangle(
2 + MarginSize + (int)recPattern[activePattern].X,
40 + MarginSize + (int)recPattern[activePattern].Y,
(int)recPattern[activePattern].Width,
(int)recPattern[activePattern].Height,
ColorAlpha(Color.DARKBLUE, 0.3f)
ColorAlpha(Color.DarkBlue, 0.3f)
);
DrawText("Select Color", 2 + MarginSize, 10 + 256 + MarginSize, 10, Color.BLACK);
DrawText("Select Color", 2 + MarginSize, 10 + 256 + MarginSize, 10, Color.Black);
for (int i = 0; i < colors.Length; i++)
{
DrawRectangleRec(colorRec[i], colors[i]);
if (activeCol == i)
{
DrawRectangleLinesEx(colorRec[i], 3, ColorAlpha(Color.WHITE, 0.5f));
DrawRectangleLinesEx(colorRec[i], 3, ColorAlpha(Color.White, 0.5f));
}
}
DrawText("Scale (UP/DOWN to change)", 2 + MarginSize, 80 + 256 + MarginSize, 10, Color.BLACK);
DrawText($"{scale}x", 2 + MarginSize, 92 + 256 + MarginSize, 20, Color.BLACK);
DrawText("Scale (UP/DOWN to change)", 2 + MarginSize, 80 + 256 + MarginSize, 10, Color.Black);
DrawText($"{scale}x", 2 + MarginSize, 92 + 256 + MarginSize, 20, Color.Black);
DrawText("Rotation (LEFT/RIGHT to change)", 2 + MarginSize, 122 + 256 + MarginSize, 10, Color.BLACK);
DrawText($"{rotation} degrees", 2 + MarginSize, 134 + 256 + MarginSize, 20, Color.BLACK);
DrawText("Rotation (LEFT/RIGHT to change)", 2 + MarginSize, 122 + 256 + MarginSize, 10, Color.Black);
DrawText($"{rotation} degrees", 2 + MarginSize, 134 + 256 + MarginSize, 20, Color.Black);
DrawText("Press [SPACE] to reset", 2 + MarginSize, 164 + 256 + MarginSize, 10, Color.DARKBLUE);
DrawText("Press [SPACE] to reset", 2 + MarginSize, 164 + 256 + MarginSize, 10, Color.DarkBlue);
// Draw FPS
DrawText($"{GetFPS()}", 2 + MarginSize, 2 + MarginSize, 20, Color.BLACK);
DrawText($"{GetFPS()}", 2 + MarginSize, 2 + MarginSize, 20, Color.Black);
EndDrawing();
//----------------------------------------------------------------------------------
}

View File

@ -38,13 +38,13 @@ public class ImageDrawing
// Draw one image over the other with a scaling of 1.5f
Rectangle src = new(0, 0, cat.Width, cat.Height);
ImageDraw(ref parrots, cat, src, new Rectangle(30, 40, cat.Width * 1.5f, cat.Height * 1.5f), Color.WHITE);
ImageDraw(ref parrots, cat, src, new Rectangle(30, 40, cat.Width * 1.5f, cat.Height * 1.5f), Color.White);
ImageCrop(ref parrots, new Rectangle(0, 50, parrots.Width, parrots.Height - 100));
// Draw on the image with a few image draw methods
ImageDrawPixel(ref parrots, 10, 10, Color.RAYWHITE);
ImageDrawCircle(ref parrots, 10, 10, 5, Color.RAYWHITE);
ImageDrawRectangle(ref parrots, 5, 20, 10, 10, Color.RAYWHITE);
ImageDrawPixel(ref parrots, 10, 10, Color.RayWhite);
ImageDrawCircle(ref parrots, 10, 10, 5, Color.RayWhite);
ImageDrawRectangle(ref parrots, 5, 20, 10, 10, Color.RayWhite);
UnloadImage(cat);
@ -52,7 +52,7 @@ public class ImageDrawing
Font font = LoadFont("resources/fonts/custom_jupiter_crash.png");
// Draw over image using custom font
ImageDrawTextEx(ref parrots, font, "PARROTS & CAT", new Vector2(300, 230), font.BaseSize, -2, Color.WHITE);
ImageDrawTextEx(ref parrots, font, "PARROTS & CAT", new Vector2(300, 230), font.BaseSize, -2, Color.White);
// Unload custom spritefont (already drawn used on image)
UnloadFont(font);
@ -74,17 +74,17 @@ public class ImageDrawing
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
int x = screenWidth / 2 - texture.Width / 2;
int y = screenHeight / 2 - texture.Height / 2;
DrawTexture(texture, x, y - 40, Color.WHITE);
DrawRectangleLines(x, y - 40, texture.Width, texture.Height, Color.DARKGRAY);
DrawTexture(texture, x, y - 40, Color.White);
DrawRectangleLines(x, y - 40, texture.Width, texture.Height, Color.DarkGray);
DrawText("We are drawing only one texture from various images composed!", 240, 350, 10, Color.DARKGRAY);
DrawText("We are drawing only one texture from various images composed!", 240, 350, 10, Color.DarkGray);
string text = "Source images have been cropped, scaled, flipped and copied one over the other.";
DrawText(text, 90, 370, 10, Color.DARKGRAY);
DrawText(text, 90, 370, 10, Color.DarkGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -26,10 +26,10 @@ public class ImageGeneration
InitWindow(screenWidth, screenHeight, "raylib [textures] example - procedural images generation");
Image verticalGradient = GenImageGradientLinear(screenWidth, screenHeight, 0, Color.RED, Color.BLUE);
Image horizontalGradient = GenImageGradientLinear(screenWidth, screenHeight, 90, Color.RED, Color.BLUE);
Image radialGradient = GenImageGradientRadial(screenWidth, screenHeight, 0.0f, Color.WHITE, Color.BLACK);
Image isChecked = GenImageChecked(screenWidth, screenHeight, 32, 32, Color.RED, Color.BLUE);
Image verticalGradient = GenImageGradientLinear(screenWidth, screenHeight, 0, Color.Red, Color.Blue);
Image horizontalGradient = GenImageGradientLinear(screenWidth, screenHeight, 90, Color.Red, Color.Blue);
Image radialGradient = GenImageGradientRadial(screenWidth, screenHeight, 0.0f, Color.White, Color.Black);
Image isChecked = GenImageChecked(screenWidth, screenHeight, 32, 32, Color.Red, Color.Blue);
Image whiteNoise = GenImageWhiteNoise(screenWidth, screenHeight, 0.5f);
Image cellular = GenImageCellular(screenWidth, screenHeight, 32);
@ -58,7 +58,7 @@ public class ImageGeneration
{
// Update
//----------------------------------------------------------------------------------
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON) || IsKeyPressed(KeyboardKey.KEY_RIGHT))
if (IsMouseButtonPressed(MouseButton.Left) || IsKeyPressed(KeyboardKey.Right))
{
// Cycle between the textures
currentTexture = (currentTexture + 1) % NumTextures;
@ -68,33 +68,33 @@ public class ImageGeneration
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawTexture(textures[currentTexture], 0, 0, Color.WHITE);
DrawTexture(textures[currentTexture], 0, 0, Color.White);
DrawRectangle(30, 400, 325, 30, ColorAlpha(Color.SKYBLUE, 0.5f));
DrawRectangleLines(30, 400, 325, 30, ColorAlpha(Color.WHITE, 0.5f));
DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL TEXTURES", 40, 410, 10, Color.WHITE);
DrawRectangle(30, 400, 325, 30, ColorAlpha(Color.SkyBlue, 0.5f));
DrawRectangleLines(30, 400, 325, 30, ColorAlpha(Color.White, 0.5f));
DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL TEXTURES", 40, 410, 10, Color.White);
switch (currentTexture)
{
case 0:
DrawText("VERTICAL GRADIENT", 560, 10, 20, Color.RAYWHITE);
DrawText("VERTICAL GRADIENT", 560, 10, 20, Color.RayWhite);
break;
case 1:
DrawText("HORIZONTAL GRADIENT", 540, 10, 20, Color.RAYWHITE);
DrawText("HORIZONTAL GRADIENT", 540, 10, 20, Color.RayWhite);
break;
case 2:
DrawText("RADIAL GRADIENT", 580, 10, 20, Color.LIGHTGRAY);
DrawText("RADIAL GRADIENT", 580, 10, 20, Color.LightGray);
break;
case 3:
DrawText("CHECKED", 680, 10, 20, Color.RAYWHITE);
DrawText("CHECKED", 680, 10, 20, Color.RayWhite);
break;
case 4:
DrawText("Color.WHITE NOISE", 640, 10, 20, Color.RED);
DrawText("Color.WHITE NOISE", 640, 10, 20, Color.Red);
break;
case 5:
DrawText("CELLULAR", 670, 10, 20, Color.RAYWHITE);
DrawText("CELLULAR", 670, 10, 20, Color.RayWhite);
break;
default:
break;

View File

@ -45,16 +45,16 @@ public class ImageLoading
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawTexture(
texture,
screenWidth / 2 - texture.Width / 2,
screenHeight / 2 - texture.Height / 2,
Color.WHITE
Color.White
);
DrawText("this IS a texture loaded from an image!", 300, 370, 10, Color.GRAY);
DrawText("this IS a texture loaded from an image!", 300, 370, 10, Color.Gray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -55,7 +55,7 @@ public class ImageProcessing
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Image imageOrigin = LoadImage("resources/parrots.png");
ImageFormat(ref imageOrigin, PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8A8);
ImageFormat(ref imageOrigin, PixelFormat.UncompressedR8G8B8A8);
Texture2D texture = LoadTextureFromImage(imageOrigin);
Image imageCopy = ImageCopy(imageOrigin);
@ -87,7 +87,7 @@ public class ImageProcessing
{
mouseHoverRec = i;
if (IsMouseButtonReleased(MouseButton.MOUSE_LEFT_BUTTON))
if (IsMouseButtonReleased(MouseButton.Left))
{
currentProcess = (ImageProcess)i;
textureReload = true;
@ -101,7 +101,7 @@ public class ImageProcessing
}
// Keyboard toggle group logic
if (IsKeyPressed(KeyboardKey.KEY_DOWN))
if (IsKeyPressed(KeyboardKey.Down))
{
currentProcess++;
if ((int)currentProcess > (NumProcesses - 1))
@ -111,7 +111,7 @@ public class ImageProcessing
textureReload = true;
}
else if (IsKeyPressed(KeyboardKey.KEY_UP))
else if (IsKeyPressed(KeyboardKey.Up))
{
currentProcess--;
if (currentProcess < 0)
@ -136,7 +136,7 @@ public class ImageProcessing
ImageColorGrayscale(ref imageCopy);
break;
case ImageProcess.ColorTint:
ImageColorTint(ref imageCopy, Color.GREEN);
ImageColorTint(ref imageCopy, Color.Green);
break;
case ImageProcess.ColorInvert:
ImageColorInvert(ref imageCopy);
@ -172,20 +172,20 @@ public class ImageProcessing
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText("IMAGE PROCESSING:", 40, 30, 10, Color.DARKGRAY);
DrawText("IMAGE PROCESSING:", 40, 30, 10, Color.DarkGray);
// Draw rectangles
for (int i = 0; i < NumProcesses; i++)
{
DrawRectangleRec(toggleRecs[i], (i == (int)currentProcess) ? Color.SKYBLUE : Color.LIGHTGRAY);
DrawRectangleRec(toggleRecs[i], (i == (int)currentProcess) ? Color.SkyBlue : Color.LightGray);
DrawRectangleLines(
(int)toggleRecs[i].X,
(int)toggleRecs[i].Y,
(int)toggleRecs[i].Width,
(int)toggleRecs[i].Height,
(i == (int)currentProcess) ? Color.BLUE : Color.GRAY
(i == (int)currentProcess) ? Color.Blue : Color.Gray
);
int labelX = (int)(toggleRecs[i].X + toggleRecs[i].Width / 2);
@ -194,14 +194,14 @@ public class ImageProcessing
(int)(labelX - MeasureText(processText[i], 10) / 2),
(int)toggleRecs[i].Y + 11,
10,
(i == (int)currentProcess) ? Color.DARKBLUE : Color.DARKGRAY
(i == (int)currentProcess) ? Color.DarkBlue : Color.DarkGray
);
}
int x = screenWidth - texture.Width - 60;
int y = screenHeight / 2 - texture.Height / 2;
DrawTexture(texture, x, y, Color.WHITE);
DrawRectangleLines(x, y, texture.Width, texture.Height, Color.BLACK);
DrawTexture(texture, x, y, Color.White);
DrawRectangleLines(x, y, texture.Width, texture.Height, Color.Black);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -38,7 +38,7 @@ public class ImageText
new Vector2(20, 20),
font.BaseSize,
0,
Color.WHITE
Color.White
);
// Image converted to texture, uploaded to GPU memory (VRAM)
@ -60,7 +60,7 @@ public class ImageText
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyDown(KeyboardKey.KEY_SPACE))
if (IsKeyDown(KeyboardKey.Space))
{
showFont = true;
}
@ -73,23 +73,23 @@ public class ImageText
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
if (!showFont)
{
// Draw texture with text already drawn inside
DrawTextureV(texture, position, Color.WHITE);
DrawTextureV(texture, position, Color.White);
// Draw text directly using sprite font
Vector2 textPosition = new(position.X + 20, position.Y + 20 + 280);
DrawTextEx(font, "[Parrots font drawing]", textPosition, font.BaseSize, 0, Color.WHITE);
DrawTextEx(font, "[Parrots font drawing]", textPosition, font.BaseSize, 0, Color.White);
}
else
{
DrawTexture(font.Texture, screenWidth / 2 - font.Texture.Width / 2, 50, Color.BLACK);
DrawTexture(font.Texture, screenWidth / 2 - font.Texture.Width / 2, 50, Color.Black);
}
DrawText("PRESS SPACE to SEE USED SPRITEFONT ", 290, 420, 10, Color.DARKGRAY);
DrawText("PRESS SPACE to SEE USED SPRITEFONT ", 290, 420, 10, Color.DarkGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -39,16 +39,16 @@ public class LogoRaylibTexture
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawTexture(
texture,
screenWidth / 2 - texture.Width / 2,
screenHeight / 2 - texture.Height / 2,
Color.WHITE
Color.White
);
DrawText("this IS a texture!", 360, 370, 10, Color.GRAY);
DrawText("this IS a texture!", 360, 370, 10, Color.Gray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -29,29 +29,29 @@ public class MousePainting
// Colours to choose from
Color[] colors = new Color[] {
Color.RAYWHITE,
Color.YELLOW,
Color.GOLD,
Color.ORANGE,
Color.PINK,
Color.RED,
Color.MAROON,
Color.GREEN,
Color.LIME,
Color.DARKGREEN,
Color.SKYBLUE,
Color.BLUE,
Color.DARKBLUE,
Color.PURPLE,
Color.VIOLET,
Color.DARKPURPLE,
Color.BEIGE,
Color.BROWN,
Color.DARKBROWN,
Color.LIGHTGRAY,
Color.GRAY,
Color.DARKGRAY,
Color.BLACK
Color.RayWhite,
Color.Yellow,
Color.Gold,
Color.Orange,
Color.Pink,
Color.Red,
Color.Maroon,
Color.Green,
Color.Lime,
Color.DarkGreen,
Color.SkyBlue,
Color.Blue,
Color.DarkBlue,
Color.Purple,
Color.Violet,
Color.DarkPurple,
Color.Beige,
Color.Brown,
Color.DarkBrown,
Color.LightGray,
Color.Gray,
Color.DarkGray,
Color.Black
};
// Define colorsRecs data (for every rectangle)
@ -94,11 +94,11 @@ public class MousePainting
Vector2 mousePos = GetMousePosition();
// Move between colors with keys
if (IsKeyPressed(KeyboardKey.KEY_RIGHT))
if (IsKeyPressed(KeyboardKey.Right))
{
colorSelected++;
}
else if (IsKeyPressed(KeyboardKey.KEY_LEFT))
else if (IsKeyPressed(KeyboardKey.Left))
{
colorSelected--;
}
@ -126,7 +126,7 @@ public class MousePainting
}
}
if ((colorMouseHover >= 0) && IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON))
if ((colorMouseHover >= 0) && IsMouseButtonPressed(MouseButton.Left))
{
colorSelected = colorMouseHover;
colorSelectedPrev = colorSelected;
@ -144,7 +144,7 @@ public class MousePainting
brushSize = 50;
}
if (IsKeyPressed(KeyboardKey.KEY_C))
if (IsKeyPressed(KeyboardKey.C))
{
// Clear render texture to clear color
BeginTextureMode(target);
@ -152,7 +152,7 @@ public class MousePainting
EndTextureMode();
}
if (IsMouseButtonDown(MouseButton.MOUSE_LEFT_BUTTON))
if (IsMouseButtonDown(MouseButton.Left))
{
// Paint circle into render texture
// NOTE: To avoid discontinuous circles, we could store
@ -165,7 +165,7 @@ public class MousePainting
EndTextureMode();
}
else if (IsMouseButtonDown(MouseButton.MOUSE_RIGHT_BUTTON))
else if (IsMouseButtonDown(MouseButton.Right))
{
colorSelected = 0;
@ -195,8 +195,8 @@ public class MousePainting
// Image saving logic
// NOTE: Saving painted texture to a default named image
if ((btnSaveMouseHover && IsMouseButtonReleased(MouseButton.MOUSE_LEFT_BUTTON)) ||
IsKeyPressed(KeyboardKey.KEY_S))
if ((btnSaveMouseHover && IsMouseButtonReleased(MouseButton.Left)) ||
IsKeyPressed(KeyboardKey.S))
{
Image image = LoadImageFromTexture(target.Texture);
ImageFlipVertical(ref image);
@ -220,16 +220,16 @@ public class MousePainting
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
Rectangle source = new(0, 0, target.Texture.Width, -target.Texture.Height);
DrawTextureRec(target.Texture, source, new Vector2(0, 0), Color.WHITE);
DrawTextureRec(target.Texture, source, new Vector2(0, 0), Color.White);
// Draw drawing circle for reference
if (mousePos.Y > 50)
{
if (IsMouseButtonDown(MouseButton.MOUSE_RIGHT_BUTTON))
if (IsMouseButtonDown(MouseButton.Right))
{
DrawCircleLines((int)mousePos.X, (int)mousePos.Y, brushSize, colors[colorSelected]);
}
@ -240,8 +240,8 @@ public class MousePainting
}
// Draw top panel
DrawRectangle(0, 0, GetScreenWidth(), 50, Color.RAYWHITE);
DrawLine(0, 50, GetScreenWidth(), 50, Color.LIGHTGRAY);
DrawRectangle(0, 0, GetScreenWidth(), 50, Color.RayWhite);
DrawLine(0, 50, GetScreenWidth(), 50, Color.LightGray);
// Draw color selection rectangles
for (int i = 0; i < colors.Length; i++)
@ -249,11 +249,11 @@ public class MousePainting
DrawRectangleRec(colorsRecs[i], colors[i]);
}
DrawRectangleLines(10, 10, 30, 30, Color.LIGHTGRAY);
DrawRectangleLines(10, 10, 30, 30, Color.LightGray);
if (colorMouseHover >= 0)
{
DrawRectangleRec(colorsRecs[colorMouseHover], ColorAlpha(Color.WHITE, 0.6f));
DrawRectangleRec(colorsRecs[colorMouseHover], ColorAlpha(Color.White, 0.6f));
}
Rectangle rec = new(
@ -262,18 +262,18 @@ public class MousePainting
colorsRecs[colorSelected].Width + 4,
colorsRecs[colorSelected].Height + 4
);
DrawRectangleLinesEx(rec, 2, Color.BLACK);
DrawRectangleLinesEx(rec, 2, Color.Black);
// Draw save image button
DrawRectangleLinesEx(btnSaveRec, 2, btnSaveMouseHover ? Color.RED : Color.BLACK);
DrawText("SAVE!", 755, 20, 10, btnSaveMouseHover ? Color.RED : Color.BLACK);
DrawRectangleLinesEx(btnSaveRec, 2, btnSaveMouseHover ? Color.Red : Color.Black);
DrawText("SAVE!", 755, 20, 10, btnSaveMouseHover ? Color.Red : Color.Black);
// Draw save image message
if (showSaveMessage)
{
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), ColorAlpha(Color.RAYWHITE, 0.8f));
DrawRectangle(0, 150, GetScreenWidth(), 80, Color.BLACK);
DrawText("IMAGE SAVED: my_amazing_texture_painting.png", 150, 180, 20, Color.RAYWHITE);
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), ColorAlpha(Color.RayWhite, 0.8f));
DrawRectangle(0, 150, GetScreenWidth(), 80, Color.Black);
DrawText("IMAGE SAVED: my_amazing_texture_painting.png", 150, 180, 20, Color.RayWhite);
}
EndDrawing();

View File

@ -50,7 +50,7 @@ public class NpatchDrawing
Top = 40,
Right = 12,
Bottom = 12,
Layout = NPatchLayout.NPATCH_NINE_PATCH
Layout = NPatchLayout.NinePatch
};
NPatchInfo ninePatchInfo2 = new NPatchInfo
{
@ -59,7 +59,7 @@ public class NpatchDrawing
Top = 16,
Right = 16,
Bottom = 16,
Layout = NPatchLayout.NPATCH_NINE_PATCH
Layout = NPatchLayout.NinePatch
};
// A horizontal 3-patch (NPT_3PATCH_HORIZONTAL) changes its sizes along the x axis only
@ -70,7 +70,7 @@ public class NpatchDrawing
Top = 8,
Right = 8,
Bottom = 8,
Layout = NPatchLayout.NPATCH_THREE_PATCH_HORIZONTAL
Layout = NPatchLayout.ThreePatchHorizontal
};
// A vertical 3-patch (NPT_3PATCH_VERTICAL) changes its sizes along the y axis only
@ -81,7 +81,7 @@ public class NpatchDrawing
Top = 6,
Right = 6,
Bottom = 6,
Layout = NPatchLayout.NPATCH_THREE_PATCH_VERTICAL
Layout = NPatchLayout.ThreePatchVertical
};
SetTargetFPS(60);
@ -114,20 +114,20 @@ public class NpatchDrawing
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// Draw the n-patches
DrawTextureNPatch(nPatchTexture, ninePatchInfo2, dstRec2, origin, 0.0f, Color.WHITE);
DrawTextureNPatch(nPatchTexture, ninePatchInfo1, dstRec1, origin, 0.0f, Color.WHITE);
DrawTextureNPatch(nPatchTexture, h3PatchInfo, dstRecH, origin, 0.0f, Color.WHITE);
DrawTextureNPatch(nPatchTexture, v3PatchInfo, dstRecV, origin, 0.0f, Color.WHITE);
DrawTextureNPatch(nPatchTexture, ninePatchInfo2, dstRec2, origin, 0.0f, Color.White);
DrawTextureNPatch(nPatchTexture, ninePatchInfo1, dstRec1, origin, 0.0f, Color.White);
DrawTextureNPatch(nPatchTexture, h3PatchInfo, dstRecH, origin, 0.0f, Color.White);
DrawTextureNPatch(nPatchTexture, v3PatchInfo, dstRecV, origin, 0.0f, Color.White);
// Draw the source texture
DrawRectangleLines(5, 88, 74, 266, Color.BLUE);
DrawTexture(nPatchTexture, 10, 93, Color.WHITE);
DrawText("TEXTURE", 15, 360, 10, Color.DARKGRAY);
DrawRectangleLines(5, 88, 74, 266, Color.Blue);
DrawTexture(nPatchTexture, 10, 93, Color.White);
DrawText("TEXTURE", 15, 360, 10, Color.DarkGray);
DrawText("Move the mouse to stretch or shrink the n-patches", 10, 20, 20, Color.DARKGRAY);
DrawText("Move the mouse to stretch or shrink the n-patches", 10, 20, 20, Color.DarkGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -60,7 +60,7 @@ public class ParticlesBlending
float gravity = 3.0f;
Texture2D smoke = LoadTexture("resources/spark_flame.png");
BlendMode blending = BlendMode.BLEND_ALPHA;
BlendMode blending = BlendMode.Alpha;
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@ -102,15 +102,15 @@ public class ParticlesBlending
}
}
if (IsKeyPressed(KeyboardKey.KEY_SPACE))
if (IsKeyPressed(KeyboardKey.Space))
{
if (blending == BlendMode.BLEND_ALPHA)
if (blending == BlendMode.Alpha)
{
blending = BlendMode.BLEND_ADDITIVE;
blending = BlendMode.Additive;
}
else
{
blending = BlendMode.BLEND_ALPHA;
blending = BlendMode.Alpha;
}
}
//----------------------------------------------------------------------------------
@ -118,7 +118,7 @@ public class ParticlesBlending
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.DARKGRAY);
ClearBackground(Color.DarkGray);
BeginBlendMode(blending);
@ -145,15 +145,15 @@ public class ParticlesBlending
EndBlendMode();
DrawText("PRESS SPACE to CHANGE BLENDING MODE", 180, 20, 20, Color.BLACK);
DrawText("PRESS SPACE to CHANGE BLENDING MODE", 180, 20, 20, Color.Black);
if (blending == BlendMode.BLEND_ALPHA)
if (blending == BlendMode.Alpha)
{
DrawText("ALPHA BLENDING", 290, screenHeight - 40, 20, Color.BLACK);
DrawText("ALPHA BLENDING", 290, screenHeight - 40, 20, Color.Black);
}
else
{
DrawText("ADDITIVE BLENDING", 280, screenHeight - 40, 20, Color.RAYWHITE);
DrawText("ADDITIVE BLENDING", 280, screenHeight - 40, 20, Color.RayWhite);
}
EndDrawing();

View File

@ -81,11 +81,11 @@ public class Polygon
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText("Textured Polygon", 20, 20, 20, Color.DARKGRAY);
DrawText("Textured Polygon", 20, 20, 20, Color.DarkGray);
Vector2 center = new(screenWidth / 2, screenHeight / 2);
DrawTexturePoly(texture, center, positions, texcoords, positions.Length, Color.WHITE);
DrawTexturePoly(texture, center, positions, texcoords, positions.Length, Color.White);
EndDrawing();
//----------------------------------------------------------------------------------
@ -116,7 +116,7 @@ public class Polygon
Rlgl.SetTexture(texture.Id);
// Texturing is only supported on RL_QUADS
Rlgl.Begin(DrawMode.QUADS);
Rlgl.Begin(DrawMode.Quads);
Rlgl.Color4ub(tint.R, tint.G, tint.B, tint.A);

View File

@ -33,7 +33,7 @@ public class RawData
"resources/fudesumi.raw",
384,
512,
PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8A8,
PixelFormat.UncompressedR8G8B8A8,
0
);
Texture2D fudesumi = LoadTextureFromImage(fudesumiRaw);
@ -51,11 +51,11 @@ public class RawData
{
if (((x / 32 + y / 32) / 1) % 2 == 0)
{
pixels[y * width + x] = Color.ORANGE;
pixels[y * width + x] = Color.Orange;
}
else
{
pixels[y * width + x] = Color.GOLD;
pixels[y * width + x] = Color.Gold;
}
}
}
@ -66,7 +66,7 @@ public class RawData
Data = pixels,
Width = width,
Height = height,
Format = PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8A8,
Format = PixelFormat.UncompressedR8G8B8A8,
Mipmaps = 1,
};
Texture2D checkedTex = LoadTextureFromImage(checkedIm);
@ -84,18 +84,18 @@ public class RawData
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
int x = screenWidth / 2 - checkedTex.Width / 2;
int y = screenHeight / 2 - checkedTex.Height / 2;
DrawTexture(checkedTex, x, y, ColorAlpha(Color.WHITE, 0.5f));
DrawTexture(fudesumi, 430, -30, Color.WHITE);
DrawTexture(checkedTex, x, y, ColorAlpha(Color.White, 0.5f));
DrawTexture(fudesumi, 430, -30, Color.White);
DrawText("CHECKED TEXTURE ", 84, 85, 30, Color.BROWN);
DrawText("GENERATED by CODE", 72, 148, 30, Color.BROWN);
DrawText("and RAW IMAGE LOADING", 46, 210, 30, Color.BROWN);
DrawText("CHECKED TEXTURE ", 84, 85, 30, Color.Brown);
DrawText("GENERATED by CODE", 72, 148, 30, Color.Brown);
DrawText("and RAW IMAGE LOADING", 46, 210, 30, Color.Brown);
DrawText("(c) Fudesumi sprite by Eiden Marsal", 310, screenHeight - 20, 10, Color.BROWN);
DrawText("(c) Fudesumi sprite by Eiden Marsal", 310, screenHeight - 20, 10, Color.Brown);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -64,11 +64,11 @@ public class SpriteAnim
frameRec.X = (float)currentFrame * (float)scarfy.Width / 6;
}
if (IsKeyPressed(KeyboardKey.KEY_RIGHT))
if (IsKeyPressed(KeyboardKey.Right))
{
framesSpeed++;
}
else if (IsKeyPressed(KeyboardKey.KEY_LEFT))
else if (IsKeyPressed(KeyboardKey.Left))
{
framesSpeed--;
}
@ -79,34 +79,34 @@ public class SpriteAnim
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawTexture(scarfy, 15, 40, Color.WHITE);
DrawRectangleLines(15, 40, scarfy.Width, scarfy.Height, Color.LIME);
DrawTexture(scarfy, 15, 40, Color.White);
DrawRectangleLines(15, 40, scarfy.Width, scarfy.Height, Color.Lime);
DrawRectangleLines(
15 + (int)frameRec.X,
40 + (int)frameRec.Y,
(int)frameRec.Width,
(int)frameRec.Height,
Color.RED
Color.Red
);
DrawText("FRAME SPEED: ", 165, 210, 10, Color.DARKGRAY);
DrawText($"{framesSpeed:2F} FPS", 575, 210, 10, Color.DARKGRAY);
DrawText("PRESS RIGHT/LEFT KEYS to CHANGE SPEED!", 290, 240, 10, Color.DARKGRAY);
DrawText("FRAME SPEED: ", 165, 210, 10, Color.DarkGray);
DrawText($"{framesSpeed:2F} FPS", 575, 210, 10, Color.DarkGray);
DrawText("PRESS RIGHT/LEFT KEYS to CHANGE SPEED!", 290, 240, 10, Color.DarkGray);
for (int i = 0; i < MaxFrameSpeed; i++)
{
if (i < framesSpeed)
{
DrawRectangle(250 + 21 * i, 205, 20, 20, Color.RED);
DrawRectangle(250 + 21 * i, 205, 20, 20, Color.Red);
}
DrawRectangleLines(250 + 21 * i, 205, 20, 20, Color.MAROON);
DrawRectangleLines(250 + 21 * i, 205, 20, 20, Color.Maroon);
}
// Draw part of the texture
DrawTextureRec(scarfy, frameRec, position, Color.WHITE);
DrawText("(c) Scarfy sprite by Eiden Marsal", screenWidth - 200, screenHeight - 20, 10, Color.GRAY);
DrawTextureRec(scarfy, frameRec, position, Color.White);
DrawText("(c) Scarfy sprite by Eiden Marsal", screenWidth - 200, screenHeight - 20, 10, Color.Gray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -67,7 +67,7 @@ public class SpriteButton
// Check button state
if (CheckCollisionPointRec(mousePoint, btnBounds))
{
if (IsMouseButtonDown(MouseButton.MOUSE_LEFT_BUTTON))
if (IsMouseButtonDown(MouseButton.Left))
{
btnState = 2;
}
@ -76,7 +76,7 @@ public class SpriteButton
btnState = 1;
}
if (IsMouseButtonReleased(MouseButton.MOUSE_LEFT_BUTTON))
if (IsMouseButtonReleased(MouseButton.Left))
{
btnAction = true;
}
@ -99,10 +99,10 @@ public class SpriteButton
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// Draw button frame
DrawTextureRec(button, sourceRec, new Vector2(btnBounds.X, btnBounds.Y), Color.WHITE);
DrawTextureRec(button, sourceRec, new Vector2(btnBounds.X, btnBounds.Y), Color.White);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -62,7 +62,7 @@ public class SpriteExplosion
//----------------------------------------------------------------------------------
// Check for mouse button pressed and activate explosion (if not active)
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON) && !active)
if (IsMouseButtonPressed(MouseButton.Left) && !active)
{
position = GetMousePosition();
active = true;
@ -105,12 +105,12 @@ public class SpriteExplosion
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// Draw explosion required frame rectangle
if (active)
{
DrawTextureRec(explosion, frameRec, position, Color.WHITE);
DrawTextureRec(explosion, frameRec, position, Color.White);
}
EndDrawing();

View File

@ -57,19 +57,19 @@ public class SrcRecDstRec
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// NOTE: Using DrawTexturePro() we can easily rotate and scale the part of the texture we draw
// sourceRec defines the part of the texture we use for drawing
// destRec defines the rectangle where our texture part will fit (scaling it to fit)
// origin defines the point of the texture used as reference for rotation and scaling
// rotation defines the texture rotation (using origin as rotation point)
DrawTexturePro(scarfy, sourceRec, destRec, origin, rotation, Color.WHITE);
DrawTexturePro(scarfy, sourceRec, destRec, origin, rotation, Color.White);
DrawLine((int)destRec.X, 0, (int)destRec.X, screenHeight, Color.GRAY);
DrawLine(0, (int)destRec.Y, screenWidth, (int)destRec.Y, Color.GRAY);
DrawLine((int)destRec.X, 0, (int)destRec.X, screenHeight, Color.Gray);
DrawLine(0, (int)destRec.Y, screenWidth, (int)destRec.Y, Color.Gray);
DrawText("(c) Scarfy sprite by Eiden Marsal", screenWidth - 200, screenHeight - 20, 10, Color.GRAY);
DrawText("(c) Scarfy sprite by Eiden Marsal", screenWidth - 200, screenHeight - 20, 10, Color.Gray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -34,12 +34,12 @@ public unsafe class TexturedCurve
const int screenWidth = 800;
const int screenHeight = 450;
SetConfigFlags(ConfigFlags.FLAG_VSYNC_HINT | ConfigFlags.FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlags.VSyncHint | ConfigFlags.Msaa4xHint);
InitWindow(screenWidth, screenHeight, "raylib [textures] examples - textured curve");
// Load the road texture
texRoad = LoadTexture("resources/road.png");
SetTextureFilter(texRoad, TextureFilter.TEXTURE_FILTER_BILINEAR);
SetTextureFilter(texRoad, TextureFilter.Bilinear);
// Setup the curve
curveStartPosition = new Vector2(80, 100);
@ -63,14 +63,14 @@ public unsafe class TexturedCurve
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawTexturedCurve();
DrawCurve();
DrawText("Drag points to move curve, press SPACE to show/hide base curve", 10, 10, 10, Color.DARKGRAY);
DrawText($"Curve width: {curveWidth} (Use + and - to adjust)", 10, 30, 10, Color.DARKGRAY);
DrawText($"Curve segments: {curveSegments} (Use LEFT and RIGHT to adjust)", 10, 50, 10, Color.DARKGRAY);
DrawText("Drag points to move curve, press SPACE to show/hide base curve", 10, 10, 10, Color.DarkGray);
DrawText($"Curve width: {curveWidth} (Use + and - to adjust)", 10, 30, 10, Color.DarkGray);
DrawText($"Curve segments: {curveSegments} (Use LEFT and RIGHT to adjust)", 10, 50, 10, Color.DarkGray);
EndDrawing();
//----------------------------------------------------------------------------------
@ -96,44 +96,44 @@ public unsafe class TexturedCurve
curveStartPositionTangent,
curveEndPositionTangent,
2,
Color.BLUE
Color.Blue
);
}
// Draw the various control points and highlight where the mouse is
DrawLineV(curveStartPosition, curveStartPositionTangent, Color.SKYBLUE);
DrawLineV(curveEndPosition, curveEndPositionTangent, Color.PURPLE);
DrawLineV(curveStartPosition, curveStartPositionTangent, Color.SkyBlue);
DrawLineV(curveEndPosition, curveEndPositionTangent, Color.Purple);
Vector2 mouse = GetMousePosition();
if (CheckCollisionPointCircle(mouse, curveStartPosition, 6))
{
DrawCircleV(curveStartPosition, 7, Color.YELLOW);
DrawCircleV(curveStartPosition, 7, Color.Yellow);
}
DrawCircleV(curveStartPosition, 5, Color.RED);
DrawCircleV(curveStartPosition, 5, Color.Red);
if (CheckCollisionPointCircle(mouse, curveStartPositionTangent, 6))
{
DrawCircleV(curveStartPositionTangent, 7, Color.YELLOW);
DrawCircleV(curveStartPositionTangent, 7, Color.Yellow);
}
DrawCircleV(curveStartPositionTangent, 5, Color.MAROON);
DrawCircleV(curveStartPositionTangent, 5, Color.Maroon);
if (CheckCollisionPointCircle(mouse, curveEndPosition, 6))
{
DrawCircleV(curveEndPosition, 7, Color.YELLOW);
DrawCircleV(curveEndPosition, 7, Color.Yellow);
}
DrawCircleV(curveEndPosition, 5, Color.GREEN);
DrawCircleV(curveEndPosition, 5, Color.Green);
if (CheckCollisionPointCircle(mouse, curveEndPositionTangent, 6))
{
DrawCircleV(curveEndPositionTangent, 7, Color.YELLOW);
DrawCircleV(curveEndPositionTangent, 7, Color.Yellow);
}
DrawCircleV(curveEndPositionTangent, 5, Color.DARKGREEN);
DrawCircleV(curveEndPositionTangent, 5, Color.DarkGreen);
}
static void UpdateCurve()
{
// If the mouse is not down, we are not editing the curve so clear the selection
if (!IsMouseButtonDown(MouseButton.MOUSE_LEFT_BUTTON))
if (!IsMouseButtonDown(MouseButton.Left))
{
return;
}
@ -219,7 +219,7 @@ public unsafe class TexturedCurve
// Draw the segment as a quad
Rlgl.SetTexture(texRoad.Id);
Rlgl.Begin(DrawMode.QUADS);
Rlgl.Begin(DrawMode.Quads);
Rlgl.Color4ub(255, 255, 255, 255);
Rlgl.Normal3f(0.0f, 0.0f, 1.0f);
@ -247,17 +247,17 @@ public unsafe class TexturedCurve
static void UpdateOptions()
{
if (IsKeyPressed(KeyboardKey.KEY_SPACE))
if (IsKeyPressed(KeyboardKey.Space))
{
showCurve = !showCurve;
}
// Update with
if (IsKeyPressed(KeyboardKey.KEY_EQUAL))
if (IsKeyPressed(KeyboardKey.Equal))
{
curveWidth += 2;
}
if (IsKeyPressed(KeyboardKey.KEY_MINUS))
if (IsKeyPressed(KeyboardKey.Minus))
{
curveWidth -= 2;
}
@ -268,11 +268,11 @@ public unsafe class TexturedCurve
}
// Update segments
if (IsKeyPressed(KeyboardKey.KEY_LEFT))
if (IsKeyPressed(KeyboardKey.Left))
{
curveSegments -= 2;
}
if (IsKeyPressed(KeyboardKey.KEY_RIGHT))
if (IsKeyPressed(KeyboardKey.Right))
{
curveSegments += 2;
}

View File

@ -50,13 +50,13 @@ public class ToImage
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
int x = screenWidth / 2 - texture.Width / 2;
int y = screenHeight / 2 - texture.Height / 2;
DrawTexture(texture, x, y, Color.WHITE);
DrawTexture(texture, x, y, Color.White);
DrawText("this IS a texture loaded from an image!", 300, 370, 10, Color.GRAY);
DrawText("this IS a texture loaded from an image!", 300, 370, 10, Color.Gray);
EndDrawing();
//----------------------------------------------------------------------------------