Render¶
Compile and render a Layer or Figure with the selected backend.
Figure scene settings supply camera, lighting, environment, and output
intent only when config is omitted. An explicit Config overrides the
complete Figure-derived Config; backend keyword arguments override their
corresponding backend-facing settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Layer | Figure
|
Layer tree or declarative Figure to render. |
required |
config
|
Config | None
|
Explicit invocation configuration, or Figure/default settings. |
None
|
filename
|
Path | str | None
|
Main output path; WebGL rewrites non-HTML suffixes to HTML. |
None
|
backend
|
BackendName | None
|
|
None
|
**kwargs
|
Any
|
Backend-specific options such as WebGL |
{}
|
Returns:
| Type | Description |
|---|---|
RenderResult
|
RenderResult with the backend, primary path/image, and output manifest. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If backend-specific keyword arguments are unknown. |
Examples:
>>> import hakowan as hkw
>>> result = hkw.render(hkw.layer("mesh.obj"), filename="viewer.html")
>>> result.path
PosixPath('viewer.html')
Source code in hakowan/render/__init__.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
RenderResult¶
hkw.render() returns a RenderResult bundling the in-memory image (Mitsuba),
the main output path, and the manifest of all files produced (including per-pass
sidecars).
The outcome of a :func:render call.
Attributes:
| Name | Type | Description |
|---|---|---|
backend |
BackendName
|
Name of the backend that produced this result. |
outputs |
dict[str, Path | str]
|
Manifest mapping |
image |
Any
|
The in-memory rendered image when the backend produces one
(Mitsuba); |
path |
Path | None
|
The main output path when written to disk; |
The object is also a :pep:519 path-like (__fspath__), so it can be
passed straight to open(), :class:~pathlib.Path, etc. when a main
output file was written.
Source code in hakowan/render/__init__.py
__fspath__()
¶
Return the main output path for os.PathLike consumers.
Raises:
| Type | Description |
|---|---|
TypeError
|
If rendering produced no file path. |
Source code in hakowan/render/__init__.py
Related Functions¶
set_default_backend¶
Set the default rendering backend for subsequent render calls.
import hakowan as hkw
# Set Blender as default
hkw.set_default_backend("blender")
# All subsequent renders will use Blender unless overridden
hkw.render(layer, filename="output.png")
Set the default rendering backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
BackendName
|
Backend name. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If backend is not registered. |
Source code in hakowan/backends/__init__.py
list_backends¶
List all available rendering backends.
import hakowan as hkw
backends = hkw.list_backends()
print(backends)
# Output: ['blender', 'mitsuba', 'webgl']
List the rendering backends whose dependencies are installed.
Availability is probed without importing the heavy backend modules.