Skip to content

Commit

Permalink
Image api fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
andybak committed Apr 12, 2024
1 parent 26ef2a0 commit ce18925
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions Assets/Scripts/API/Lua/Wrappers/ImageApiWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TiltBrush
{
[LuaDocsDescription("A reference image widget")]
[LuaDocsDescription("An image widget")]
[MoonSharpUserData]
public class ImageApiWrapper
{
Expand Down Expand Up @@ -72,11 +72,34 @@ public float scale
set => transform = TrTransform.TRS(transform.translation, transform.rotation, value);
}

[LuaDocsDescription("Imports an image widget based on the specified location")]
[LuaDocsDescription("Whether the widget is visible or not")]
public bool visible
{
get => _ImageWidget.IsHiding();
set => _ImageWidget.Show(value);
}

[LuaDocsDescription("The aspect ration of the image")]
public float aspect => _ImageWidget.ReferenceImage.ImageAspect;

[LuaDocsDescription("The filename of the image")]
public string filename => _ImageWidget.FileName;

[LuaDocsDescription("Get a pixel color from the image")]
[LuaDocsExample(@"myColor = myImage:GetPixel(10, 20)")]
[LuaDocsParameter("x", "The x coordinate of the pixel")]
[LuaDocsParameter("x", "The y coordinate of the pixel")]
[LuaDocsReturnValue("The pixel color")]
public ColorApiWrapper GetPixel(int x, int y)
{
return new ColorApiWrapper(_ImageWidget.ReferenceImage.FullSize.GetPixel(x, y));
}

[LuaDocsDescription("Imports an image widget based on the specified filename")]
[LuaDocsExample(@"Image:Import(""test.png"")")]
[LuaDocsParameter("location", "The location of the image")]
[LuaDocsParameter("filename", "The filename of the image")]
[LuaDocsReturnValue("The imported image widget")]
public static ImageApiWrapper Import(string location) => new(ApiMethods.ImportImage(location));
public static ImageApiWrapper Import(string filename) => new(ApiMethods.ImportImage(filename));

[LuaDocsDescription("Selects the image widget")]
[LuaDocsExample(@"myImage:Select()")]
Expand Down

0 comments on commit ce18925

Please sign in to comment.