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

Update Raylib.Utils

This commit is contained in:
MrScautHD 2023-11-19 13:34:27 +01:00
commit 10d7df07d3
2 changed files with 79 additions and 9 deletions

View file

@ -1336,7 +1336,7 @@ public static unsafe partial class Raylib
/// <summary>Load image from SVG file data or string with specified size</summary> /// <summary>Load image from SVG file data or string with specified size</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Image LoadImageSvg(char *fileNameOrString, int width, int height); public static extern Image LoadImageSvg(sbyte* fileName, int width, int height);
/// <summary>Load image sequence from file (frames appended to image.data)</summary> /// <summary>Load image sequence from file (frames appended to image.data)</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -1368,7 +1368,7 @@ public static unsafe partial class Raylib
/// <summary>Export image to memory buffer</summary> /// <summary>Export image to memory buffer</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern char* ExportImageToMemory(Image image, char *fileType, int *fileSize); public static extern char* ExportImageToMemory(Image image, sbyte* fileType, int *fileSize);
/// <summary>Export image as code file defining an array of bytes</summary> /// <summary>Export image as code file defining an array of bytes</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]

View file

@ -83,6 +83,15 @@ public static unsafe partial class Raylib
return GetShaderLocationAttrib(shader, str1.AsPointer()); return GetShaderLocationAttrib(shader, str1.AsPointer());
} }
/// <summary>Unload random values sequence</summary>
public static void UnloadRandomSequence(out int sequence)
{
fixed (int* p = &sequence)
{
UnloadRandomSequence(p);
}
}
/// <summary>Takes a screenshot of current screen (saved a .png)</summary> /// <summary>Takes a screenshot of current screen (saved a .png)</summary>
public static void TakeScreenshot(string fileName) public static void TakeScreenshot(string fileName)
{ {
@ -119,6 +128,13 @@ public static unsafe partial class Raylib
return LoadImageRaw(str1.AsPointer(), width, height, format, headerSize); return LoadImageRaw(str1.AsPointer(), width, height, format, headerSize);
} }
/// <summary>Load image sequence from file (frames appended to image.data)</summary>
public static Image LoadImageSvg(string fileName, int width, int height)
{
using var str1 = fileName.ToAnsiBuffer();
return LoadImageSvg(str1.AsPointer(), width, height);
}
/// <summary>Load image sequence from file (frames appended to image.data)</summary> /// <summary>Load image sequence from file (frames appended to image.data)</summary>
public static Image LoadImageAnim(string fileName, out int frames) public static Image LoadImageAnim(string fileName, out int frames)
{ {
@ -571,6 +587,15 @@ public static unsafe partial class Raylib
} }
} }
/// <summary>Rotate image by input angle in degrees (-359 to 359)</summary>
public static void ImageRotate(ref Image image, int degrees)
{
fixed (Image* p = &image)
{
ImageRotate(p, degrees);
}
}
/// <summary>Rotate image clockwise 90deg</summary> /// <summary>Rotate image clockwise 90deg</summary>
public static void ImageRotateCW(ref Image image) public static void ImageRotateCW(ref Image image)
{ {
@ -840,12 +865,12 @@ public static unsafe partial class Raylib
} }
/// <summary>Load font from file with extended parameters</summary> /// <summary>Load font from file with extended parameters</summary>
public static Font LoadFontEx(string fileName, int fontSize, int[] fontChars, int glyphCount) public static Font LoadFontEx(string fileName, int fontSize, int[] codepoints, int codepointCount)
{ {
using var str1 = fileName.ToAnsiBuffer(); using var str1 = fileName.ToAnsiBuffer();
fixed (int* p = fontChars) fixed (int* p = codepoints)
{ {
return LoadFontEx(str1.AsPointer(), fontSize, p, glyphCount); return LoadFontEx(str1.AsPointer(), fontSize, p, codepointCount);
} }
} }
@ -856,14 +881,14 @@ public static unsafe partial class Raylib
string fileType, string fileType,
byte[] fileData, byte[] fileData,
int fontSize, int fontSize,
int[] fontChars, int[] codepoints,
int glyphCount int codepointCount
) )
{ {
using var fileTypeNative = fileType.ToAnsiBuffer(); using var fileTypeNative = fileType.ToAnsiBuffer();
fixed (byte* fileDataNative = fileData) fixed (byte* fileDataNative = fileData)
{ {
fixed (int* fontCharsNative = fontChars) fixed (int* fontCharsNative = codepoints)
{ {
Font font = LoadFontFromMemory( Font font = LoadFontFromMemory(
fileTypeNative.AsPointer(), fileTypeNative.AsPointer(),
@ -871,7 +896,7 @@ public static unsafe partial class Raylib
fileData.Length, fileData.Length,
fontSize, fontSize,
fontCharsNative, fontCharsNative,
glyphCount codepointCount
); );
return font; return font;
@ -979,6 +1004,51 @@ public static unsafe partial class Raylib
} }
} }
/// <summary>Draw spline: Linear, minimum 2 points</summary>
public static void DrawSplineLinear(Vector2[] points, int pointCount, float thick, Color color)
{
fixed (Vector2* p = points)
{
DrawSplineLinear(p, pointCount, thick, color);
}
}
/// <summary>Draw spline: B-Spline, minimum 4 points</summary>
public static void DrawSplineBasis(Vector2[] points, int pointCount, float thick, Color color)
{
fixed (Vector2* p = points)
{
DrawSplineBasis(p, pointCount, thick, color);
}
}
/// <summary>Draw spline: Catmull-Rom, minimum 4 points</summary>
public static void DrawSplineCatmullRom(Vector2[] points, int pointCount, float thick, Color color)
{
fixed (Vector2* p = points)
{
DrawSplineCatmullRom(p, pointCount, thick, color);
}
}
/// <summary>Draw spline: Quadratic Bezier, minimum 3 points (1 control point): [p1, c2, p3, c4...]</summary>
public static void DrawSplineBezierQuadratic(Vector2[] points, int pointCount, float thick, Color color)
{
fixed (Vector2* p = points)
{
DrawSplineBezierQuadratic(p, pointCount, thick, color);
}
}
/// <summary>Draw spline: Cubic Bezier, minimum 4 points (2 control points): [p1, c2, c3, p4, c5, c6...]</summary>
public static void DrawSplineBezierCubic(Vector2[] points, int pointCount, float thick, Color color)
{
fixed (Vector2* p = points)
{
DrawSplineBezierCubic(p, pointCount, thick, color);
}
}
/// <summary>Draw text (using default font)</summary> /// <summary>Draw text (using default font)</summary>
public static void DrawText(string text, int posX, int posY, int fontSize, Color color) public static void DrawText(string text, int posX, int posY, int fontSize, Color color)
{ {