How to render real-time animations in Polyglot Notebook using C#? #4135
-
|
I am using .NET Polyglot Notebook (C#). I want to render animations (not static images) inside a notebook cell — What I have tried:
What I want:
Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
One approach is to use the Here's an example: using Microsoft.DotNet.Interactive.Formatting;
var display = "".Display("text/html");
foreach (var color in new[]{"red", "green", "yellow", "blue", "black"})
{
var html = $"""<p style="background-color:{color}">{color}!</p>""".ToHtmlContent();
display.Update(html);
await Task.Delay(750);
} |
Beta Was this translation helpful? Give feedback.
-
|
@jonsequitur Thankyou |
Beta Was this translation helpful? Give feedback.
One approach is to use the
Updatemethod on theMicrosoft.DotNet.Interactive.DisplayedValueinstance returned by theDisplayextension method. This will work but the refresh rate will be pretty low. You can also use JavaScript libraries directly if you want to use proper animation APIs.Here's an example: