ILNumerics Web Examples
In order to improve your learning experience we have created an Interactive Web Component for all code examples within the online documentation, and ILView, an interactive 3D viewer for ILNumerics.
Learn more about:
The code examples show their corresponding result above the code:
Play around with the C# code! Simply change the expressions and press the Play Button to let the component generate a new output. If you wish to generate the output in a different Output Format, select the format from the output format drop down list. Currently supported are: PNG, JPG and SVG; WebGL and EXE coming soon. Read the notes about SVG at the end of this page.
Share your Ideas!
The Permalink Button in each code component allows you to share the current state of the code including all your changes and to come back to it at any later point.
Differences between Web Component and Forms Applications
Windows.Forms applications commonly utilize Windows.Forms ILPanel as host for arbitrary scenes. The code to setup a scene is usually placed within the Windows.Forms ilPanel1_Load handler function. During setup, the scene is assembled and assigned to the ILPanel.Scene property for rendering:
Alternatively, the default scene ILPanel.Scene can directly be used for rendering which saves the step of creating you own ILScene.
In contrast to that there is no ILPanel in the web component. There is no form and no application either. In fact, we utilize a GDI driver for offscreen scene rendering and generate the scene on the fly.
The creation and setup of the ILScene however is identical. But in order to determine the correct scene for rendering, the web code component follows a simple convention: it displays the object which is generated by the last expression of the code snippet. To display a scene we only have to make sure that the scene is the return value of the last expression:
Keep that difference in mind when transfering code examples between web components and your Windows.Forms applications:
The web code component does not utilize a function like obligatory for Windows.Forms Applications. The setup of the scene is identical; but while the scene data are assigned to ILPanel.Scene for application development, in the web code component the scene is 'returned' as last expression result.
Errors produced by the compilation step are displayed above the code – instead of the result. Read the error messages, fix the code and try again by pressing the play button!
Output Type SVG
The web code component currently supports the following output types: PNG, JPG and SVG. Like always, each format comes with its own advantages and disadvantages. Disadvantages for pixel formats include the fixed pixel size. Simple 2D plots (line plots, contour plots) commonly look much better in a vector format like SVG.
SVG on the other hand is inherently designed for 2D output. When rendering complex 3D scenes, SVG introduces its own disadvantages:
- Complex filled 3D objects may produce considerably large file sizes.
- It may take a longer time to create them as well as to render them.
- Most browser engines experience problems rendering huge SVG files.
- SVG does always antialias edges between filled areas. For adjacent areas this may introduce rendering artifacts due to edges being visible.
ILNumerics does its best to circumvent these disadvantages. However, consider using one of the other formats if you encounter any of the above problems with SVG.
In order to give full access to our visualization examples, we have created ILView – a lightweight 3D viewer and interactive REPL for ILNumerics. It allows the visualization of arbitrary 3D scenes in a small and lightweight .NET application.
ILView is a .NET application. It runs on all supporting platforms for .NET CLR 4.0 or mono. We have tried to keep the GUI as simple as possible, in order to minimize platform specific issues. The initial state of the GUI does not use any fancy docking windows or the like. It runs unmmodified on all major Windows and Linux distributions without further dependencies.
To download ILView, chose EXE as output format of any example in the visualization section of our documentation and push the green play button. The current scene and ILView will be downloaded to your local machine.
Further scenes can be fetched from arbitrary URIs, provided as ILC# (permalinks from the official ILNumerics project site) or interactively defined.
ILView is provided as is. No guarantees are made by ILNumerics that it serves a specific purpose or functions in any 'correct' way! This is free software (GPL) - no support is given for it.
ILView comes with a C# interactive console that can be used to modify 3D scenes interactively. Furthermore it's a general computing REPL for the evaluation of arbitrary computational expressions.
The C# Interactive Console (REPL) allows the evaluation of arbitrary C# expressions on the fly. That means: It accepts individual valid expressions without the need to wrap them in a full class context. Just enter the expressions in the command line, and they will be wrapped by the compiler and executed. A text output displays the result immediately on the command line.
The evaluation is triggered when the Enter key is pressed. Multiple lines are spanned by pressing Space + Enter together. The Up key iteratively steps through the entries in the list of earlier expressions history. A (by now yet limited) set of code completions is provided automatically while entering expressions. Marking of text areas, copy and paste of text is working the regular way. The use of a trailing semicolon ';' is optional.
The C# Interactive Console allows arbitrary modifications to the scene being displayed in the main window. It exposes the panel of the main window via the Panel property and may be used to alter any property of the panel, including the Panel.Scene:
Of course, all regular C# expressions are allowed, which reference any .NET type or namespace. By default, the following namespaces are included:
More namespaces can be included at any point (and not necessarily at the beginning of the session) on the command line. Furthermore, all members of the ILNumerics.ILMath class are directly accessible, without the need to specify the ILMath class. All common rules for writing functions and handling arrays in ILNumerics apply:
ILView on GitHub
ILView is intended as community project: Learn more at the official ILView GitHub Repository!
ILView Video Tutorial
Check out our video tutorial for ILView: