Skip to content

Commit

Permalink
v1.7.1
Browse files Browse the repository at this point in the history
Polyglot notebook extension for FlipBook and Image display
  • Loading branch information
pgrit committed Jan 6, 2025
1 parent fd4df57 commit d380f7a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
9 changes: 3 additions & 6 deletions FlipBookExample.dib
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ First, we load the SimpleImageIO package and output the required JavaScript code
#!csharp

#r "nuget: SimpleImageIO"
// #r "./SimpleImageIO/bin/Debug/net9.0/SimpleImageIO.dll"
using SimpleImageIO;
HTML(FlipBook.Header)

#!markdown

Expand All @@ -29,20 +26,20 @@ var blue = new RgbImage(600, 400);
blue.Fill(0.03f, 0.3f, 0.7f);
blue[50,50] = new(100,200,10);

HTML(FlipBook.New + ("blue", blue) + ("red", red))
FlipBook.New + ("blue", blue) + ("red", red)

#!markdown

You can save the output to a static .html page via the `Save(filename)` utility method.

#!csharp

(FlipBook.New + ("blue", blue) + ("red", red)).Save("test.html")
FlipBook.New.Add("blue", blue).Add("red", red).Save("test.html")

#!markdown

The size of the FlipBook can be specified as an argument to the constructor, as done below, or via the Resize() method of the fluent API.

#!csharp

HTML(new FlipBook(900, 800) + ("blue", blue) + ("red", red))
new FlipBook(900, 800) + ("blue", blue) + ("red", red)
6 changes: 5 additions & 1 deletion SimpleImageIO/SimpleImageIO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Title>Simple Image IO</Title>
<Description>A very simple C# wrapper to read and write various HDR and LDR image file formats.</Description>
<PackageId>SimpleImageIO</PackageId>
<Version>1.7.0</Version>
<Version>1.7.1</Version>
<Copyright>(c) Pascal Grittmann</Copyright>
<RepositoryUrl>https://github.com/pgrit/SimpleImageIO</RepositoryUrl>

Expand Down Expand Up @@ -40,6 +40,10 @@
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<None Include="extension.dib" Pack="true" PackagePath="interactive-extensions/dotnet" />
</ItemGroup>

<!-- Each additional platform requires an entry here, to copy the corresponding native binaries -->
<ItemGroup>
<!-- Copy to the intended location for the nuget package -->
Expand Down
10 changes: 10 additions & 0 deletions SimpleImageIO/extension.dib
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!csharp

using SimpleImageIO;
HTML(FlipBook.Header).Display();
Microsoft.DotNet.Interactive.Formatting.Formatter.Register<FlipBook>((flip, writer) => writer.Write(flip.ToString()), "text/html");

Microsoft.DotNet.Interactive.Formatting.Formatter.Register<SimpleImageIO.Image>((img, writer) => {
string desc = img.ToString() + $", {img.Width}x{img.Height}, {img.NumChannels} channels (Memory Address: {img.DataPointer})<br>";
writer.Write(desc + FlipBook.New.Add("image", img).ToString());
}, "text/html");

0 comments on commit d380f7a

Please sign in to comment.