FlowPlotPy 0.9.0__cp310-cp310-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
flowplot/__init__.py ADDED
@@ -0,0 +1,22 @@
1
+ from importlib import resources
2
+
3
+ from . import _flowplot
4
+ from ._flowplot import Plot, getCompleteJson, get_complete_json
5
+
6
+
7
+ def _default_font_resource():
8
+ return resources.files(__package__).joinpath("fonts", "Inter.ttf")
9
+
10
+
11
+ def plot(path):
12
+ plot_obj = _flowplot.plot(path)
13
+ with resources.as_file(_default_font_resource()) as font_path:
14
+ plot_obj.set_default_font(str(font_path))
15
+ return plot_obj
16
+
17
+ __all__ = [
18
+ "Plot",
19
+ "getCompleteJson",
20
+ "get_complete_json",
21
+ "plot",
22
+ ]
Binary file
Binary file
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Manwe314
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,336 @@
1
+ Metadata-Version: 2.2
2
+ Name: FlowPlotPy
3
+ Version: 0.9.0
4
+ Summary: Python bindings for the FlowPlot plotting library
5
+ Author: FlowPlot contributors
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Manwe314
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Classifier: Development Status :: 3 - Alpha
29
+ Classifier: Intended Audience :: Developers
30
+ Classifier: Intended Audience :: Science/Research
31
+ Classifier: License :: OSI Approved :: MIT License
32
+ Classifier: Programming Language :: C++
33
+ Classifier: Programming Language :: Python :: 3
34
+ Classifier: Programming Language :: Python :: 3.10
35
+ Classifier: Programming Language :: Python :: 3.11
36
+ Classifier: Programming Language :: Python :: 3.12
37
+ Classifier: Programming Language :: Python :: 3.13
38
+ Classifier: Topic :: Scientific/Engineering :: Visualization
39
+ Requires-Python: >=3.10
40
+ Provides-Extra: numpy
41
+ Requires-Dist: numpy>=1.23; extra == "numpy"
42
+ Description-Content-Type: text/markdown
43
+
44
+ # FlowPlot
45
+
46
+ FlowPlot is a header-only plotting library that:
47
+
48
+ - compiles a JSON template into an internal spec
49
+ - binds runtime data (`withData("dataset.field", ...)`)
50
+ - resolves layout/axes/layers into a render command stream
51
+ - optionally rasterizes to PNG with the built-in CPU renderer
52
+
53
+ It supports scatter and histogram layers, automatic axis-domain inference, legends/titles, and pluggable text measurement/layout through `ITextEngine`.
54
+ Text styling supports font family, numeric weight, and style (`normal`, `italic`, `oblique`).
55
+
56
+ ## Quick Start
57
+
58
+ ### 1. Create a template (`ScatterTemplate.json`)
59
+
60
+ ```json
61
+ {
62
+ "version": "1.0",
63
+ "fonts": [
64
+ {
65
+ "family": "Inter",
66
+ "weight": 400,
67
+ "style": "normal",
68
+ "path": "/absolute/path/to/Inter-Regular.ttf"
69
+ },
70
+ {
71
+ "family": "Inter",
72
+ "weight": 700,
73
+ "style": "normal",
74
+ "path": "/absolute/path/to/Inter-Bold.ttf"
75
+ }
76
+ ],
77
+ "figure": {
78
+ "width": 1200,
79
+ "height": 800,
80
+ "title": {
81
+ "visible": true,
82
+ "text": "Scatter Plot",
83
+ "fontFamily": "Inter",
84
+ "fontWeight": 700,
85
+ "fontStyle": "normal"
86
+ }
87
+ },
88
+ "datasets": [
89
+ {
90
+ "name": "main",
91
+ "schema": {
92
+ "x": "number",
93
+ "y": "number"
94
+ }
95
+ }
96
+ ],
97
+ "panels": [
98
+ {
99
+ "layers": [
100
+ {
101
+ "type": "scatter",
102
+ "dataset": "main",
103
+ "mapping": {
104
+ "x": { "field": "x" },
105
+ "y": { "field": "y" }
106
+ }
107
+ }
108
+ ]
109
+ }
110
+ ]
111
+ }
112
+ ```
113
+
114
+ ### 2. Render from C++
115
+
116
+ ```cpp
117
+ #define FLOW_PLOT_RENDERER
118
+ #define FLOW_PLOT_IMPLEMENTATION
119
+ #define FLOW_PLOT_DEFAULT_FONT_PATH "./FacultyGlyphic-Regular.ttf"
120
+ #include "FlowPlot_Mega.hpp"
121
+
122
+ #include <vector>
123
+
124
+ int main()
125
+ {
126
+ std::vector<int> x{1, 2, 3, 4, 5};
127
+ std::vector<int> y{3, 4, 1, 4, 6};
128
+
129
+ FlowPlot::plot("./ScatterTemplate.json")
130
+ .withData("main.x", x)
131
+ .withData("main.y", y)
132
+ .writePng("./out.png");
133
+ }
134
+ ```
135
+
136
+ ### 3. Compile
137
+
138
+ ```bash
139
+ g++ -std=c++20 -I. -IFlowPlot main.cpp -o plot
140
+ ```
141
+
142
+ ## Public API
143
+
144
+ - `FlowPlot::plot(path)` loads template JSON (`.json` extension optional).
145
+ - `PlotBuilder::set("path.to.prop", value)` mutates template JSON before compile.
146
+ - `value` supports: `int`, `float`, `double`, `bool`, `const char*`, `std::string`, `std::string_view`.
147
+ - `PlotBuilder::setJsonRaw("path.to.prop", jsonText)` sets a property from raw JSON text (object/array/primitive).
148
+ - `PlotBuilder::withData("dataset.field", std::span<const T>)`
149
+ - `PlotBuilder::withData("dataset.field", const std::vector<T>&)`
150
+ - `PlotBuilder::useTextEngine(engine)` injects a custom text engine.
151
+ - `PlotBuilder::getCommands()` returns `RenderPlot` (resolved command stream).
152
+ - `PlotBuilder::writePng(path)` (only when `FLOW_PLOT_RENDERER` is enabled).
153
+ - `FlowPlot::registerFonts(textEngine, templateJsonText)` registers every root-level `fonts[]` entry with an `ITextEngine`.
154
+ - `FlowPlot::getCompleteJson(templateJsonText, pretty = true)` (only when `FLOW_PLOT_COMPLETE_JSON` is enabled).
155
+
156
+ ## Defines
157
+
158
+ ### Required in specific modes
159
+
160
+ - `FLOW_PLOT_RENDERER`
161
+ - Enables renderer integration (`CpuRenderer`, `StbTextEngine`, `PlotBuilder::writePng`).
162
+ - Define before including headers (or pass as compiler define).
163
+
164
+ - `FLOW_PLOT_IMPLEMENTATION`
165
+ - Required in exactly one translation unit if you use built-in stb implementations.
166
+ - Without this (and without external stb implementation), renderer builds can compile but will fail to link when stb symbols are needed.
167
+
168
+ ### Optional
169
+
170
+ - `FLOW_PLOT_DEFAULT_FONT_PATH`
171
+ - String literal path to a default TTF file auto-registered by `StbTextEngine`.
172
+ - `PlotBuilder::writePng` and renderer-enabled `PlotBuilder::getCommands` auto-create a fallback `StbTextEngine` if none is set; this default font path makes that work out of the box.
173
+
174
+ - `FLOW_PLOT_COMPLETE_JSON`
175
+ - Enables full-template normalization helper: `getCompleteJson(templateJsonText, pretty)`.
176
+
177
+ - `FLOW_PLOT_STB_EXTERNAL_IMPLEMENTATION`
178
+ - Use when you provide stb implementations externally.
179
+ - Disables FlowPlot’s internal stb implementation emission.
180
+
181
+ ### Internal (do not set manually)
182
+
183
+ Examples: `FLOW_PLOT_HPP_INCLUDED`, `FLOW_PLOT_RENDERER_HPP_INCLUDED`, `FLOW_PLOT_DEFINED_STBTT_IMPLEMENTATION`, etc.
184
+
185
+ ## Template Schema (Overview)
186
+
187
+ Root object:
188
+
189
+ - `version` (`"1.0"`)
190
+ - `fonts` optional array of font variants
191
+ - `figure`
192
+ - `datasets`
193
+ - `layout`
194
+ - `panels`
195
+
196
+ ### `fonts`
197
+
198
+ Optional root-level font manifest. Each entry describes one concrete font face:
199
+
200
+ ```json
201
+ {
202
+ "family": "Inter",
203
+ "weight": 400,
204
+ "style": "normal",
205
+ "path": "/absolute/path/to/Inter-Regular.ttf"
206
+ }
207
+ ```
208
+
209
+ - `family`: family name referenced by text specs.
210
+ - `weight`: numeric font weight, usually `100..900`.
211
+ - `style`: `normal`, `italic`, or `oblique`.
212
+ - `path`: absolute path to a `.ttf`/`.ttc` font file.
213
+
214
+ The built-in fallback `StbTextEngine` automatically registers these entries for `writePng()` and renderer-enabled `getCommands()`. Custom text engines can opt in by calling `FlowPlot::registerFonts(engine, templateJsonText)`.
215
+
216
+ ### `figure`
217
+
218
+ Includes width/height/dpi/background/padding/title/legends.
219
+
220
+ ### `datasets`
221
+
222
+ Each dataset has:
223
+
224
+ - `name`
225
+ - `schema` map where values are `number`, `string`, or `boolean`
226
+
227
+ Runtime data binding uses:
228
+
229
+ - `withData("datasetName.fieldName", data)`
230
+
231
+ ### `panels`
232
+
233
+ Each panel has:
234
+
235
+ - style/frame/title
236
+ - axes: `xAxis`, `yAxis`, `xSecondary`, `ySecondary`
237
+ - `layers`
238
+
239
+ ### `layers`
240
+
241
+ Common layer fields:
242
+
243
+ - `type`: `scatter` or `histogram`
244
+ - `dataset`: dataset name
245
+ - `axisData`: `{ "x": "primary|secondary|null", "y": "primary|secondary|null" }`
246
+ - `mapping`, `style`, `stats`, `config`
247
+
248
+ Scatter mapping (important fields):
249
+
250
+ - `mapping.x.field` (required)
251
+ - `mapping.y.field` (required)
252
+ - optional: `mapping.color.field`, `mapping.size.field`, `mapping.label.field`
253
+
254
+ Histogram mapping (important fields):
255
+
256
+ - `mapping.data.field` (required)
257
+ - `mapping.data.axis`: `"x"` or `"y"` (which axis receives input data)
258
+ - optional color field/mapping
259
+
260
+ Notes:
261
+
262
+ - If no layer contributes data to an axis and no explicit `min/max` is provided, axis domain falls back to `0..1`.
263
+ - You must define panels/layers/mappings if you want automatic domain inference from data.
264
+
265
+ ## Renderer Pipeline
266
+
267
+ High-level flow:
268
+
269
+ 1. Template JSON -> compiled spec
270
+ 2. Spec + data views -> bound IR
271
+ 3. Bound IR + text metrics -> resolved IR
272
+ 4. Resolved IR -> `RenderPlot` command stream
273
+ 5. `CpuRenderer` rasterizes commands to RGBA8 image / PNG
274
+
275
+ Command variants include:
276
+
277
+ - `BoxCommand`
278
+ - `PolylineCommand`
279
+ - `TextCommand`
280
+ - `MarkersCommand`
281
+ - clip stack commands (`PushClipRectCommand`, `PopClipRectCommand`)
282
+
283
+ ## Text Engine Pluggability
284
+
285
+ `ITextEngine` is pluggable for text metrics/layout:
286
+
287
+ - `registerFont(...)`
288
+ - `hasFont(...)`
289
+ - `measureText(...)`
290
+ - `layoutText(...)`
291
+
292
+ Built-in `StbTextEngine` provides UTF-8 layout and glyph bitmap raster support used by the CPU renderer.
293
+
294
+ Important current behavior:
295
+
296
+ - `resolvePlotIR` needs a text engine for auto-sized text boxes.
297
+ - `PlotBuilder::writePng` and renderer-enabled `PlotBuilder::getCommands` auto-fall back to `StbTextEngine` when no engine is explicitly set.
298
+ - The fallback `StbTextEngine` automatically registers root `fonts[]` entries before resolving text.
299
+ - If no default font is available, `writePng` throws with guidance (`useTextEngine(...)` or set `FLOW_PLOT_DEFAULT_FONT_PATH`).
300
+ - Font lookup uses `family + weight + style`, with fallback to normal style/default weight/default family where possible.
301
+ - Non-`StbTextEngine` custom engines can drive measurement/layout, but glyph rasterization in the built-in renderer is currently specialized for `StbTextEngine`.
302
+
303
+ ## Header Options
304
+
305
+ You can use modular headers (`FlowPlot/FlowPlot.hpp`) or one of four generated amalgamated headers.
306
+
307
+ Regenerate all amalgamated variants with:
308
+
309
+ ```bash
310
+ python3 tools/generate_flowplot_mega.py
311
+ ```
312
+
313
+ Generated outputs:
314
+
315
+ - `FlowPlot_Mega_Core.hpp`
316
+ - Inlines FlowPlot headers only.
317
+ - Leaves RapidJSON and stb external (`-IFlowPlot` needed for bundled deps).
318
+ - `FlowPlot_Mega_Stb.hpp`
319
+ - Inlines FlowPlot + stb headers.
320
+ - Leaves RapidJSON external (`-IFlowPlot` needed for bundled deps).
321
+ - `FlowPlot_Mega_Json.hpp`
322
+ - Inlines FlowPlot + used RapidJSON subset.
323
+ - Leaves stb external (`-IFlowPlot` needed only if renderer/stb paths are used).
324
+ - `FlowPlot_Mega.hpp`
325
+ - Inlines FlowPlot + used RapidJSON subset + stb.
326
+ - Fully self-contained single header (copy one file and include it).
327
+
328
+ All variants support the same feature macros and runtime API.
329
+
330
+ ## JSON Backend
331
+
332
+ FlowPlot uses RapidJSON. The JSON-inlined mega variants include only the RapidJSON subset reachable from FlowPlot's actual include usage.
333
+
334
+ ## Documentation Status
335
+
336
+ This is a temporary README. FlowPlot will get full documentation and a pre-v1.0.0 release soon.
@@ -0,0 +1,7 @@
1
+ flowplot/__init__.py,sha256=2DpS_1Y1jwgu5EXhA1xZ7fCnQAeyZRSxNtpoNcvEBb8,524
2
+ flowplot/_flowplot.cp310-win_amd64.pyd,sha256=sBPFe8SnV5whIbSUeVJ2oSYRN7-Og78PV07QODXJqC0,646144
3
+ flowplot/fonts/Inter.ttf,sha256=C-I5nqkl8fg_-XR2R2HamGDsUHQu0ppdTB_9DFx6w6g,874708
4
+ flowplotpy-0.9.0.dist-info/METADATA,sha256=fDT9xJ7ycPj-BpaGOhkFoE7Puya09cQBkaBT3SxxklQ,10883
5
+ flowplotpy-0.9.0.dist-info/WHEEL,sha256=rs4XyvYyY8p6GzRLerHjRm6wNH1QAkDMf7SSChBeqNk,106
6
+ flowplotpy-0.9.0.dist-info/LICENSE,sha256=mpGwczbyUj695hGQNlPZcN9ZG0Sp3iLy7H9A5lamIo0,1086
7
+ flowplotpy-0.9.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: scikit-build-core 0.12.2
3
+ Root-Is-Purelib: false
4
+ Tag: cp310-cp310-win_amd64
5
+