SilkRay 2025.1.2

dotnet add package SilkRay --version 2025.1.2
                    
NuGet\Install-Package SilkRay -Version 2025.1.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SilkRay" Version="2025.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SilkRay" Version="2025.1.2" />
                    
Directory.Packages.props
<PackageReference Include="SilkRay" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SilkRay --version 2025.1.2
                    
#r "nuget: SilkRay, 2025.1.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SilkRay@2025.1.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SilkRay&version=2025.1.2
                    
Install as a Cake Addin
#tool nuget:?package=SilkRay&version=2025.1.2
                    
Install as a Cake Tool

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 operations
  • Rectangle - Rectangle structure for bounds
  • Camera2D - 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

  1. BasicShapes - Core 2D shape drawing and animation
  2. MouseInput - Complete mouse input handling with trails and cursors
  3. GamepadInput - Gamepad support with analog sticks and buttons
  4. 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
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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2025.1.2 273 9/16/2025
2025.1.1 274 9/16/2025
2025.1.0 272 9/16/2025

Updated README with correct Color naming convention (UPPERCASE) and comprehensive 2D feature documentation