diff --git a/Cargo.lock b/Cargo.lock index ff7e72e..a2d33c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -309,7 +309,7 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "avenger" -version = "0.0.2-a0" +version = "0.0.2" dependencies = [ "image", "lyon_path", @@ -332,7 +332,7 @@ dependencies = [ [[package]] name = "avenger-python" -version = "0.0.2-a0" +version = "0.0.2" dependencies = [ "avenger", "avenger-vega", @@ -346,7 +346,7 @@ dependencies = [ [[package]] name = "avenger-vega" -version = "0.0.2-a0" +version = "0.0.2" dependencies = [ "avenger", "cfg-if", @@ -367,7 +367,7 @@ dependencies = [ [[package]] name = "avenger-vega-test-data" -version = "0.0.2-a0" +version = "0.0.2" dependencies = [ "pollster", "serde_json", @@ -376,7 +376,7 @@ dependencies = [ [[package]] name = "avenger-wgpu" -version = "0.0.2-a0" +version = "0.0.2" dependencies = [ "avenger", "avenger-glyphon", diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1e88845 --- /dev/null +++ b/LICENSE @@ -0,0 +1,11 @@ +Copyright 2024 Jon Mease + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/README.md b/README.md index b0b074a..55a5f44 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ chart = alt.Chart(source).mark_circle(size=60).encode( ) chart ``` -![cars_scatter.png](doc%2Fimages%2Fcars_scatter.png) +![cars_scatter](https://github.com/jonmmease/avenger/assets/15064365/d661e142-c7c5-4816-a375-49a73985bb6d) Or, convert the chart to a PNG rendered by Avenger: @@ -46,7 +46,7 @@ There aren't currently many advantages to using Avenger to render Altar charts t One advantage is that Avenger's text rendering support is based on [COSMIC Text](https://github.com/pop-os/cosmic-text), which supports emoji (unlike resvg's text handling). For example, here is the result of rendering the emoji example from https://altair-viz.github.io/gallery/isotype_emoji.html using Avenger: -![isotype_emoji.png](doc%2Fimages%2Fisotype_emoji.png) +![isotype_emoji](https://github.com/jonmmease/avenger/assets/15064365/91a1db89-9bdd-46f3-b540-c7d7bcaac3c2) # Try it out from Rust Avenger is written in Rust, and may be used directly from Rust. diff --git a/avenger-python/Cargo.toml b/avenger-python/Cargo.toml index 00126e2..f27ab1e 100644 --- a/avenger-python/Cargo.toml +++ b/avenger-python/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "avenger-python" -version = "0.0.2-a0" +version = "0.0.2" edition = "2021" license = "BSD-3-Clause" description = "Python API to Avenger visualization framework" @@ -17,17 +17,17 @@ pollster = "0.3" [dependencies.avenger] path = "../avenger" features = [ "pyo3",] -version = "0.0.2-a0" +version = "0.0.2" [dependencies.avenger-vega] path = "../avenger-vega" features = [ "pyo3",] -version = "0.0.2-a0" +version = "0.0.2" [dependencies.avenger-wgpu] path = "../avenger-wgpu" features = [ "pyo3",] -version = "0.0.2-a0" +version = "0.0.2" [dependencies.pyo3] workspace = true diff --git a/avenger-python/LICENSE b/avenger-python/LICENSE new file mode 100644 index 0000000..1e88845 --- /dev/null +++ b/avenger-python/LICENSE @@ -0,0 +1,11 @@ +Copyright 2024 Jon Mease + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/avenger-python/README.md b/avenger-python/README.md new file mode 100644 index 0000000..edce01a --- /dev/null +++ b/avenger-python/README.md @@ -0,0 +1,49 @@ +# Avenger: A visualization engine and renderer +Avenger is an early stage prototype of a new foundational rendering library for information visualization (InfoVis) systems. Avenger defines a 2D scenegraph representation tailored to the needs of InfoVis systems. To start with, the initial application of Avenger is to serve as an alternative, GPU accelerated, rendering backend for Vega visualizations. + +# Try it out in Python with Vega-Altair +The `avenger` Python package provides a [custom Altair renderer](https://altair-viz.github.io/user_guide/custom_renderers.html) named `avenger-png`. This renderer relies on vl-convert to extract the vega scenegraph corresponding to a chart and then uses Avenger to render the chart to a static PNG image. + +First, install altair, vega-datasets, avenger, and vl-convert-python +``` +pip install -U altair vega_datasets avenger "vl-convert-python>=1.2.3" +``` + +Then import Altair and activate the `avenger-png` renderer + +```python +import altair as alt +alt.renderers.enable('avenger-png', scale=1) +``` + +Then create and display an Altair chart as usual: + +```python +import altair as alt +from vega_datasets import data + +source = data.cars() + +chart = alt.Chart(source).mark_circle(size=60).encode( + x='Horsepower', + y='Miles_per_Gallon', + color='Origin', +) +chart +``` +![cars_scatter](https://github.com/jonmmease/avenger/assets/15064365/d661e142-c7c5-4816-a375-49a73985bb6d) + +Or, convert the chart to a PNG rendered by Avenger: + +```python +import avenger +png = avenger.altair_utils.chart_to_png(chart, scale=1) +with open("scatter.png", "wb") as f: + f.write(png) +``` +## Comparison to vl-convert +There aren't currently many advantages to using Avenger to render Altar charts to PNG as compared with vl-convert, which performs rendering using [resvg](https://github.com/RazrFalcon/resvg). Performance is generally comparable, though Avenger can be a bit faster for charts with a large number of symbol instances. + +One advantage is that Avenger's text rendering support is based on [COSMIC Text](https://github.com/pop-os/cosmic-text), which supports emoji (unlike resvg's text handling). For example, here is the result of rendering the emoji example from https://altair-viz.github.io/gallery/isotype_emoji.html using Avenger: + +![isotype_emoji](https://github.com/jonmmease/avenger/assets/15064365/91a1db89-9bdd-46f3-b540-c7d7bcaac3c2) diff --git a/avenger-python/pyproject.toml b/avenger-python/pyproject.toml index 5a1ad64..6589f27 100644 --- a/avenger-python/pyproject.toml +++ b/avenger-python/pyproject.toml @@ -1,6 +1,9 @@ [project] name = "avenger" -version = "0.0.2-a0" +version = "0.0.2" +readme = "README.md" +description = "A Visualization Engine and Renderer" +license = {file = "LICENSE"} [build-system] requires = [ "maturin>=1.1.0,<2",] diff --git a/avenger-vega-test-data/Cargo.toml b/avenger-vega-test-data/Cargo.toml index 773e012..feb682a 100644 --- a/avenger-vega-test-data/Cargo.toml +++ b/avenger-vega-test-data/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "avenger-vega-test-data" -version = "0.0.2-a0" +version = "0.0.2" edition = "2021" [dependencies] diff --git a/avenger-vega/Cargo.toml b/avenger-vega/Cargo.toml index 45ded3b..f5256cc 100644 --- a/avenger-vega/Cargo.toml +++ b/avenger-vega/Cargo.toml @@ -1,27 +1,36 @@ [package] name = "avenger-vega" -version = "0.0.2-a0" +version = "0.0.2" edition = "2021" description = "Utilities for importing Vega scenegraphs into Avenger" license = "BSD-3-Clause" [features] image-request = [ "reqwest",] -svg = ["resvg", "usvg", "tiny-skia"] +svg = [ "resvg", "usvg", "tiny-skia",] [dependencies] cfg-if = "1" csscolorparser = "0.6.2" -resvg = { version="0.38.0", optional = true } -usvg = { version="0.38.0", optional = true} -tiny-skia = { version="0.11.3", optional = true} + +[dependencies.resvg] +version = "0.38.0" +optional = true + +[dependencies.usvg] +version = "0.38.0" +optional = true + +[dependencies.tiny-skia] +version = "0.11.3" +optional = true [dependencies.lazy_static] workspace = true [dependencies.avenger] path = "../avenger" -version = "0.0.2-a0" +version = "0.0.2" [dependencies.thiserror] workspace = true diff --git a/avenger-wgpu/Cargo.toml b/avenger-wgpu/Cargo.toml index ef89456..8479164 100644 --- a/avenger-wgpu/Cargo.toml +++ b/avenger-wgpu/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "avenger-wgpu" -version = "0.0.2-a0" +version = "0.0.2" edition = "2021" description = "WGPU rendering engine for the Avenger visualization framework" license = "BSD-3-Clause" @@ -32,7 +32,7 @@ rstest = "0.18.2" [dependencies.avenger] path = "../avenger" -version = "0.0.2-a0" +version = "0.0.2" [dependencies.thiserror] workspace = true @@ -57,8 +57,8 @@ workspace = true [dev-dependencies.avenger-vega] path = "../avenger-vega" -features = [ "image-request", "svg"] -version = "0.0.2-a0" +features = [ "image-request", "svg",] +version = "0.0.2" [dev-dependencies.serde_json] version = "1.0.111" diff --git a/avenger/Cargo.toml b/avenger/Cargo.toml index 0f82c31..43c31f9 100644 --- a/avenger/Cargo.toml +++ b/avenger/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "avenger" -version = "0.0.2-a0" +version = "0.0.2" edition = "2021" description = "A visualization engine and renderer" license = "BSD-3-Clause" diff --git a/examples/scatter-panning/Cargo.lock b/examples/scatter-panning/Cargo.lock index 7052701..71cba49 100644 --- a/examples/scatter-panning/Cargo.lock +++ b/examples/scatter-panning/Cargo.lock @@ -131,7 +131,7 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "avenger" -version = "0.0.2-a0" +version = "0.0.2" dependencies = [ "image", "lyon_path", @@ -153,7 +153,7 @@ dependencies = [ [[package]] name = "avenger-vega" -version = "0.0.2-a0" +version = "0.0.2" dependencies = [ "avenger", "cfg-if", @@ -169,7 +169,7 @@ dependencies = [ [[package]] name = "avenger-wgpu" -version = "0.0.2-a0" +version = "0.0.2" dependencies = [ "avenger", "avenger-glyphon", diff --git a/examples/wgpu-winit/Cargo.lock b/examples/wgpu-winit/Cargo.lock index 807601d..93b1b9e 100644 --- a/examples/wgpu-winit/Cargo.lock +++ b/examples/wgpu-winit/Cargo.lock @@ -131,7 +131,7 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "avenger" -version = "0.0.2-a0" +version = "0.0.2" dependencies = [ "image", "lyon_path", @@ -141,7 +141,7 @@ dependencies = [ [[package]] name = "avenger-vega" -version = "0.0.2-a0" +version = "0.0.2" dependencies = [ "avenger", "cfg-if", @@ -157,7 +157,7 @@ dependencies = [ [[package]] name = "avenger-wgpu" -version = "0.0.2-a0" +version = "0.0.2" dependencies = [ "avenger", "bytemuck", diff --git a/pixi.toml b/pixi.toml index 15dc63e..4b9916d 100644 --- a/pixi.toml +++ b/pixi.toml @@ -8,6 +8,7 @@ platforms = ["osx-arm64"] [tasks] dev-py = { cmd = ["maturin", "develop", "-m", "avenger-python/Cargo.toml", "--release"]} +build-py = { cmd = ["maturin", "build", "-m", "avenger-python/Cargo.toml", "--sdist", "--release"]} bump-version = { cmd = ["python", "automation/bump_version.py"] } [tasks.publish-rs]