Shortcuts
FluxRender.shortcuts
as_vector_field
A mathematical decorator that automatically converts a standard Python function into a fully initialized VectorField entity.
It accepts any number of keyword arguments that the underlying VectorField constructor supports, passing them directly to the instance.
Example
Source code in FluxRender/shortcuts.py
create_workspace
create_workspace(resolution: Tuple[int, int] = (1200, 800), x_range: Tuple[float, float] = (-4, 4), y_range: Tuple[float, float] = (-4, 4), window_title: str = 'FluxRender Visualization') -> cr.Scene
Creates a fully configured scene with a ready-to-use coordinate system, axes, and a highly aesthetic double-grid overlay.
This is an advanced factory function designed to eliminate boilerplate code for users who want a professional workspace out of the box.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resolution
|
tuple[int, int]
|
The dimensions of the application window in pixels. (Default: (1200, 800)) |
(1200, 800)
|
x_range
|
tuple[float, float]
|
The mathematical boundaries of the X-axis. (Default: (-4, 4)) |
(-4, 4)
|
y_range
|
tuple[float, float]
|
The mathematical boundaries of the Y-axis. (Default: (-4, 4)) |
(-4, 4)
|
window_title
|
str
|
The title displayed on the application window. (Default: "FluxRender Visualization") |
'FluxRender Visualization'
|
Returns:
| Name | Type | Description |
|---|---|---|
scene |
Scene
|
A fully initialized scene object containing the coordinate system, double grid, and axes, ready for vector fields or particle systems to be added. |
Example
import FluxRender as fr
import numpy as np
workspace = fr.create_workspace()
def swirling_vortex(x, y):
vector_dx = np.sin(y) * x
vector_dy = np.cos(x) * y
return vector_dx, vector_dy
vector_field = fr.VectorField(swirling_vortex)
particles = fr.ParticleSystem(swirling_vortex)
workspace.add(particles, vector_field)
workspace.run()
Source code in FluxRender/shortcuts.py
quick_simulate
Instantly generates and runs a complete, interactive simulation from a single vector function.
This function is the ultimate high-level wrapper. It sets up a standard workspace, injects both a vector field and a particle system based on the provided mathematical function, generates an interactive UI menu for property switching, and starts the render loop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vec_function
|
callable
|
The mathematical function defining the vector field (e.g., f(x, y, t)). |
required |
resolution
|
tuple[int, int]
|
The dimensions of the application window in pixels. (Default: (1200, 800)) |
(1200, 800)
|
Returns:
| Name | Type | Description |
|---|---|---|
scene |
Scene
|
The fully constructed scene. Returned immediately if auto_run is False. |
Example
Source code in FluxRender/shortcuts.py
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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |