SilkRay 2025.1.2
dotnet add package SilkRay --version 2025.1.2
NuGet\Install-Package SilkRay -Version 2025.1.2
<PackageReference Include="SilkRay" Version="2025.1.2" />
<PackageVersion Include="SilkRay" Version="2025.1.2" />
<PackageReference Include="SilkRay" />
paket add SilkRay --version 2025.1.2
#r "nuget: SilkRay, 2025.1.2"
#:package SilkRay@2025.1.2
#addin nuget:?package=SilkRay&version=2025.1.2
#tool nuget:?package=SilkRay&version=2025.1.2
SilkRay
A C# implementation of core Raylib functions using Silk.NET OpenGL bindings. SilkRay provides a Raylib-compatible 2D graphics API for cross-platform game development and graphics programming.
Overview
SilkRay provides a familiar Raylib-style API for 2D graphics programming in C# using modern Silk.NET libraries. It implements core 2D functionality including window management, shape drawing, input handling, camera system, and text rendering with full NativeAOT support.
Features
2D Graphics Core
- Window management (
InitWindow
,CloseWindow
,WindowShouldClose
) - Drawing lifecycle (
BeginDrawing
,EndDrawing
,ClearBackground
) - Screen properties (
GetScreenWidth
,GetScreenHeight
) - Timing functions (
GetTime
,GetFrameTime
,GetFPS
) - Monitor information (
GetMonitorWidth
,GetMonitorHeight
,GetMonitorName
)
2D Shape Drawing
- Pixels:
DrawPixel
,DrawPixelV
- Lines:
DrawLine
,DrawLineV
,DrawLineEx
- Rectangles:
DrawRectangle
,DrawRectangleV
,DrawRectangleRec
,DrawRectangleLines
,DrawRectanglePro
- Circles:
DrawCircle
,DrawCircleV
,DrawCircleLines
- Triangles:
DrawTriangle
2D Input System
- Keyboard:
IsKeyDown
,IsKeyPressed
,IsKeyReleased
,GetKeyPressed
,GetCharPressed
- Mouse:
IsMouseButtonDown
,IsMouseButtonPressed
,IsMouseButtonReleased
,GetMousePosition
,GetMouseWheelMove
- Gamepad:
IsGamepadAvailable
,IsGamepadButtonDown
,GetGamepadAxisMovement
- Cursor:
ShowCursor
,HideCursor
,SetMouseCursor
2D Camera System
- Camera2D: Complete camera with target, offset, rotation, and zoom
- Coordinate conversion:
GetScreenToWorld2D
,GetWorldToScreen2D
- Camera matrix:
BeginMode2D
,EndMode2D
2D Text Rendering
- Text drawing:
DrawText
,DrawTextEx
- Font loading:
LoadFont
,UnloadFont
- Text measurement:
MeasureText
,MeasureTextEx
Data Structures
Color
- RGBA color with predefined constants (UPPERCASE naming)Vector2
- 2D vector math operationsRectangle
- Rectangle structure for boundsCamera2D
- 2D camera with transformation matrix
Quick Start
using static SilkRay.Core;
using static SilkRay.Shapes;
using static SilkRay.Text;
// Initialize 2D window
InitWindow(800, 450, "My SilkRay 2D App");
SetTargetFPS(60);
// Main loop
while (!WindowShouldClose())
{
BeginDrawing();
ClearBackground(RAYWHITE);
// Draw 2D shapes
DrawRectangle(100, 100, 200, 100, RED);
DrawCircle(400, 200, 50, BLUE);
DrawLine(0, 0, 800, 450, GREEN);
DrawText("Hello SilkRay 2D!", 10, 10, 20, BLACK);
EndDrawing();
}
CloseWindow();
Installation
NuGet Package
dotnet add package SilkRay
From Source
git clone https://github.com/AliasBLACK/SilkRay.git
cd SilkRay
dotnet build
Examples
Comprehensive example projects are available in a separate repository:
Repository: https://github.com/AliasBLACK/SilkRayExamples
- BasicShapes - Core 2D shape drawing and animation
- MouseInput - Complete mouse input handling with trails and cursors
- GamepadInput - Gamepad support with analog sticks and buttons
- Camera2D - 2D camera system with zoom, rotation, and following
All examples support NativeAOT compilation for optimal 2D performance.
Building
Regular Build
dotnet restore
dotnet build
NativeAOT Build (Recommended for 2D games)
dotnet publish -c Release -r win-x64 --self-contained
Dependencies
- Silk.NET.OpenGL (2.22.0)
- Silk.NET.Windowing (2.22.0)
- Silk.NET.Input (2.22.0)
- Silk.NET.Windowing.Glfw (2.22.0)
- Silk.NET.Input.Glfw (2.22.0)
- FontStashSharp (for text rendering)
- TextCopy (for clipboard operations)
- StbImageSharp (for image loading)
- .NET 8.0
Architecture
- RaylibCore.cs - Core window, input, and utility functions
- RaylibCoreRenderer.cs - OpenGL rendering backend using Silk.NET
- RaylibCoreShader.cs - Shader program management for 2D rendering
- RaylibShapes.cs - 2D shape drawing functions
- RaylibText.cs - Font loading and text rendering
- RaylibTextures.cs - Texture and image operations
2D Focus
SilkRay is specifically designed for 2D graphics and game development:
- 2D Rendering: Optimized for 2D shape drawing and sprite rendering
- 2D Input: Complete keyboard, mouse, and gamepad input handling
- 2D Camera: Full 2D camera system with transformations
- 2D Text: Font loading and text rendering with FontStashSharp
- Cross-platform: Windows, macOS, and Linux support
- NativeAOT: Full compatibility for optimal 2D performance
Performance
- NativeAOT Compatible: Zero-cost abstractions with ahead-of-time compilation
- 2D Optimized: Efficient batch rendering for shapes and sprites
- Memory Efficient: Minimal allocations in 2D rendering hot paths
- Cross-platform: Uses OpenGL for consistent 2D performance across platforms
License
This project is provided as-is for educational and development purposes.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- FontStashSharp.PlatformAgnostic (>= 1.4.1)
- Silk.NET.GLFW (>= 2.22.0)
- Silk.NET.Input (>= 2.22.0)
- Silk.NET.Input.Glfw (>= 2.22.0)
- Silk.NET.OpenGL (>= 2.22.0)
- Silk.NET.Windowing (>= 2.22.0)
- Silk.NET.Windowing.Glfw (>= 2.22.0)
- StbImageSharp (>= 2.30.15)
- TextCopy (>= 6.2.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Updated README with correct Color naming convention (UPPERCASE) and comprehensive 2D feature documentation