Watch
2
0
Fork
You've already forked raylib-cs
0

chore: rebase to main with translation ports

This commit is contained in:
tiger tiger tiger 2026-07-17 07:49:07 +02:00
commit 8024c6ac40
134 changed files with 15456 additions and 10650 deletions

View file

@ -1,11 +1,15 @@
/*******************************************************************************************
*
* raylib [shapes] example - Colors palette
* raylib [shapes] example - colors palette
*
* This example has been created using raylib 2.5 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* Example complexity rating: [] 2/4
*
* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5)
* Example originally created with raylib 1.0, last time updated with raylib 2.5
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
* Copyright (c) 2014-2025 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@ -14,72 +18,80 @@ using static Raylib_cs.Raylib;
namespace Examples.Shapes;
public class ColorsPalette
public partial class ColorsPalette : IExample
{
public static int Main()
private const int screenWidth = 800;
private const int screenHeight = 450;
public const int MaxColorsCount = 21; // Number of colors available
public string Name => "Shapes / Colors Palette";
public string Title => "raylib [shapes] example - colors palette";
private Color[] colors;
private string[] colorNames;
private Rectangle[] colorsRecs;
private int[] colorState;
private Vector2 mousePoint;
public void Init()
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - colors palette");
Color[] colors = new[]
colors = new[]
{
Color.DarkGray,
Color.Maroon,
Color.Orange,
Color.DarkGreen,
Color.DarkBlue,
Color.DarkPurple,
Color.DarkBrown,
Color.Gray,
Color.Red,
Color.Gold,
Color.Lime,
Color.Blue,
Color.Violet,
Color.Brown,
Color.LightGray,
Color.Pink,
Color.Yellow,
Color.Green,
Color.SkyBlue,
Color.Purple,
Color.Beige
};
Color.DarkGray,
Color.Maroon,
Color.Orange,
Color.DarkGreen,
Color.DarkBlue,
Color.DarkPurple,
Color.DarkBrown,
Color.Gray,
Color.Red,
Color.Gold,
Color.Lime,
Color.Blue,
Color.Violet,
Color.Brown,
Color.LightGray,
Color.Pink,
Color.Yellow,
Color.Green,
Color.SkyBlue,
Color.Purple,
Color.Beige
};
string[] colorNames = new[]
colorNames = new[]
{
"DARKGRAY",
"MAROON",
"ORANGE",
"DARKGREEN",
"DARKBLUE",
"DARKPURPLE",
"DARKBROWN",
"GRAY",
"RED",
"GOLD",
"LIME",
"BLUE",
"VIOLET",
"BROWN",
"LIGHTGRAY",
"PINK",
"YELLOW",
"GREEN",
"SKYBLUE",
"PURPLE",
"BEIGE"
};
"DARKGRAY",
"MAROON",
"ORANGE",
"DARKGREEN",
"DARKBLUE",
"DARKPURPLE",
"DARKBROWN",
"GRAY",
"RED",
"GOLD",
"LIME",
"BLUE",
"VIOLET",
"BROWN",
"LIGHTGRAY",
"PINK",
"YELLOW",
"GREEN",
"SKYBLUE",
"PURPLE",
"BEIGE"
};
// Rectangles array
Rectangle[] colorsRecs = new Rectangle[colors.Length];
colorsRecs = new Rectangle[colors.Length];
// Fills colorsRecs data (for every rectangle)
for (int i = 0; i < colorsRecs.Length; i++)
for (var i = 0; i < colorsRecs.Length; i++)
{
colorsRecs[i].X = 20 + 100 * (i % 7) + 10 * (i % 7);
colorsRecs[i].Y = 80 + 100 * (i / 7) + 10 * (i / 7);
@ -88,82 +100,101 @@ public class ColorsPalette
}
// Color state: 0-DEFAULT, 1-MOUSE_HOVER
int[] colorState = new int[colors.Length];
colorState = new int[colors.Length];
Vector2 mousePoint = new(0.0f, 0.0f);
mousePoint = new(0.0f, 0.0f);
}
SetTargetFPS(60);
public void Update()
{
// Update
//----------------------------------------------------------------------------------
mousePoint = GetMousePosition();
for (var i = 0; i < colors.Length; i++)
{
if (CheckCollisionPointRec(mousePoint, colorsRecs[i]))
{
colorState[i] = 1;
}
else
{
colorState[i] = 0;
}
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RayWhite);
DrawText("raylib colors palette", 28, 42, 20, Color.Black);
DrawText(
"press SPACE to see all colors",
GetScreenWidth() - 180,
GetScreenHeight() - 40,
10,
Color.Gray
);
for (var i = 0; i < colorsRecs.Length; i++) // Draw all rectangles
{
DrawRectangleRec(colorsRecs[i], Fade(colors[i], colorState[i] != 0 ? 0.6f : 1.0f));
if (IsKeyDown(KeyboardKey.Space) || colorState[i] != 0)
{
DrawRectangle(
(int)colorsRecs[i].X,
(int)(colorsRecs[i].Y + colorsRecs[i].Height - 26),
(int)colorsRecs[i].Width,
20,
Color.Black
);
DrawRectangleLinesEx(colorsRecs[i], 6, Fade(Color.Black, 0.3f));
DrawText(
colorNames[i],
(int)(colorsRecs[i].X + colorsRecs[i].Width - MeasureText(colorNames[i], 10) - 12),
(int)(colorsRecs[i].Y + colorsRecs[i].Height - 20),
10,
colors[i]
);
}
}
EndDrawing();
//----------------------------------------------------------------------------------
}
public void Unload()
{
}
public static int Main()
{
// Initialization
//--------------------------------------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - colors palette");
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
var game = new ColorsPalette();
game.Init();
// Main game loop
while (!WindowShouldClose())
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
mousePoint = GetMousePosition();
for (int i = 0; i < colors.Length; i++)
{
if (CheckCollisionPointRec(mousePoint, colorsRecs[i]))
{
colorState[i] = 1;
}
else
{
colorState[i] = 0;
}
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RayWhite);
DrawText("raylib colors palette", 28, 42, 20, Color.Black);
DrawText(
"press SPACE to see all colors",
GetScreenWidth() - 180,
GetScreenHeight() - 40,
10,
Color.Gray
);
// Draw all rectangles
for (int i = 0; i < colorsRecs.Length; i++)
{
DrawRectangleRec(colorsRecs[i], ColorAlpha(colors[i], colorState[i] != 0 ? 0.6f : 1.0f));
if (IsKeyDown(KeyboardKey.Space) || colorState[i] != 0)
{
DrawRectangle(
(int)colorsRecs[i].X,
(int)(colorsRecs[i].Y + colorsRecs[i].Height - 26),
(int)colorsRecs[i].Width,
20,
Color.Black
);
DrawRectangleLinesEx(colorsRecs[i], 6, ColorAlpha(Color.Black, 0.3f));
DrawText(
colorNames[i],
(int)(colorsRecs[i].X + colorsRecs[i].Width - MeasureText(colorNames[i], 10) - 12),
(int)(colorsRecs[i].Y + colorsRecs[i].Height - 20),
10,
colors[i]
);
}
}
EndDrawing();
//----------------------------------------------------------------------------------
game.Update();
}
game.Unload();
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow();
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
}