Merging
Added new extension "byte.Lerp". Added new extension "Log" for "TraceLogLevel". Constructors on Color no longer just truncate the float value, but also round it (+ 0.5f). New static method on Color, "Color.Lerp". Added static method "FromHSV" to Color. Added new getter method "GetHSV" on Color. Added index security on the FilePathList indexer. Merged Rectangle extensions with the type itself as read-only methods. Merged Image extensions with the type itself. Merged Texture2D extensions with the type itself. New file "Raymath.Utils" with some useful methods taken from Unity. Added "MoveTowards" extensions to RaylibExtensions. Added "TranslateLocal" and "TranslateGlobal" to Transform. Added "Load", "Export", "ExportAsCode", "Format", "Crop", and "Unload" shortcut methods to Wave. Added "IsValid" property to Wave, Texture2D, Sound, Shader, RenderTexture2D, Music, Image, Model, Material, Font, and AudioStream. Added "IsPlaying" and "IsProcessed" properties to AudioStream. Added "Load", "Play", "Stop", "Pause", "Resume", "SetBufferSizeDefault", "SetPan", "SetPitch", "SetVolume", and "Unload" shortcut methods to AudioStream. Added "Load", "Export", and "Unload" methods to AutomationEventList. Added "Default" property to Font. Added "Load", "GetMaterial", "GetTexture", "SetTexture", "SetShader", and "Unload" methods to material. Added "Draw", "DrawInstanced", "Export", "ExportAsCode", "Upload", and "Unload" methods to Mesh. Added "Load", "LoadFromMesh", "Unload", and a lot of "Draw" overloads. Added "Load", "Play", "Pause", "Stop", "SetPan", "SetPitch", "SetVolume", "Seek", and "Unload" methods to Music. Added "Load" and "Unload" methods to RenderTexture2D. Added "Load", "LoadFromMemory", "GetLocationAttrib", "SetValue", "SetTexture", "SetMatrix", and "Unload" methods to Shader. Removed unnecessary "partial" declarations.
This commit is contained in:
parent
9811c0d129
commit
b84a0d4f12
31 changed files with 1090 additions and 395 deletions
|
|
@ -134,7 +134,7 @@ public enum PixelFormat
|
|||
/// Image, pixel data stored in CPU memory (RAM)
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public unsafe partial struct Image
|
||||
public unsafe struct Image
|
||||
{
|
||||
/// <summary>
|
||||
/// Image raw data
|
||||
|
|
@ -164,11 +164,117 @@ public unsafe partial struct Image
|
|||
/// <summary>
|
||||
/// Get width and height packed in a Vector2
|
||||
/// </summary>
|
||||
public Vector2 Dimensions
|
||||
public readonly Vector2 Dimensions => new Vector2(Width, Height);
|
||||
public readonly CBool IsValid => Raylib.IsImageValid(this);
|
||||
|
||||
public static Image Load(string fileName)
|
||||
{
|
||||
get
|
||||
return Raylib.LoadImage(fileName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an image from text using the default font
|
||||
/// </summary>
|
||||
public static Image CreateFromText(string text, int fontSize, Color color)
|
||||
{
|
||||
return Raylib.ImageText(text, fontSize, color);
|
||||
}
|
||||
|
||||
public static Image CreateFromText(Font font, string text, int fontSize, float spacing, Color color)
|
||||
{
|
||||
return Raylib.ImageTextEx(font, text, fontSize, spacing, color);
|
||||
}
|
||||
|
||||
public static Image LoadFromMemory(string fileType, byte[] data)
|
||||
{
|
||||
return Raylib.LoadImageFromMemory(fileType, data);
|
||||
}
|
||||
|
||||
public static Image LoadFromTexture(Texture2D texture)
|
||||
{
|
||||
return Raylib.LoadImageFromTexture(texture);
|
||||
}
|
||||
|
||||
public static Image LoadRaw(string fileName, int width, int height, PixelFormat format, int headerSize)
|
||||
{
|
||||
return Raylib.LoadImageRaw(fileName, width, height, format, headerSize);
|
||||
}
|
||||
|
||||
public readonly void Unload()
|
||||
{
|
||||
Raylib.UnloadImage(this);
|
||||
}
|
||||
|
||||
public readonly unsafe Color[] GetPalette(int maxPaletteSize)
|
||||
{
|
||||
int colorCount = 0;
|
||||
Color* colors = Raylib.LoadImagePalette(this, maxPaletteSize, &colorCount);
|
||||
Color[] palette = new Color[colorCount];
|
||||
for (int i = 0; i < colorCount; i++)
|
||||
{
|
||||
return new Vector2(Width, Height);
|
||||
palette[i] = colors[i];
|
||||
}
|
||||
Raylib.UnloadImagePalette(colors);
|
||||
return palette;
|
||||
}
|
||||
|
||||
public static Image LoadFromScreen()
|
||||
{
|
||||
return Raylib.LoadImageFromScreen();
|
||||
}
|
||||
|
||||
public void DrawLine(Vector2 start, Vector2 end, Color color)
|
||||
{
|
||||
Raylib.ImageDrawLineV(ref this, start, end, color);
|
||||
}
|
||||
|
||||
public void DrawLine(Vector2 start, Vector2 end, int thickness, Color color)
|
||||
{
|
||||
Raylib.ImageDrawLineEx(ref this, start, end, thickness, color);
|
||||
}
|
||||
|
||||
public void DrawCircle(Vector2 position, float radius, Color color)
|
||||
{
|
||||
Raylib.ImageDrawCircle(ref this, (int)position.X, (int)position.Y, (int)radius, color);
|
||||
}
|
||||
|
||||
public void DrawRectangle(Rectangle rectangle, Color color)
|
||||
{
|
||||
Raylib.ImageDrawRectangleRec(ref this, rectangle, color);
|
||||
}
|
||||
|
||||
public void DrawText(string text, Vector2 position, int fontSize, Color color)
|
||||
{
|
||||
Raylib.ImageDrawText(ref this, text, (int)position.X, (int)position.Y, fontSize, color);
|
||||
}
|
||||
|
||||
public void DrawText(Font font, string text, Vector2 position, int fontSize, float spacing, Color color)
|
||||
{
|
||||
Raylib.ImageDrawTextEx(ref this, font, text, position, fontSize, spacing, color);
|
||||
}
|
||||
|
||||
public unsafe void DrawCircleLines(Vector2 position, float radius, Color color)
|
||||
{
|
||||
Raylib.ImageDrawCircleLinesV(ref this, position, (int)radius, color);
|
||||
}
|
||||
|
||||
public void DrawTriangle(Vector2 p1, Vector2 p2, Vector2 p3, Color color)
|
||||
{
|
||||
Raylib.ImageDrawTriangle(ref this, p1, p2, p3, color);
|
||||
}
|
||||
|
||||
public void DrawTriangle(Vector2 p1, Vector2 p2, Vector2 p3, Color c1, Color c2, Color c3)
|
||||
{
|
||||
Raylib.ImageDrawTriangleEx(ref this, p1, p2, p3, c1, c2, c3);
|
||||
}
|
||||
|
||||
public void DrawRectangleLines(Rectangle rectangle, Color color)
|
||||
{
|
||||
Raylib.ImageDrawRectangleLines(ref this, rectangle, 1, color);
|
||||
}
|
||||
|
||||
public void DrawRectangleLines(Rectangle rectangle, int thickness, Color color)
|
||||
{
|
||||
Raylib.ImageDrawRectangleLines(ref this, rectangle, thickness, color);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue