Skip to content

Commit

Permalink
V0.8 (#100)
Browse files Browse the repository at this point in the history
* Remove version dependency

* Start new API

* Add style

* Add base curve

* Add circle

* Begin svg impl

* Remove algebr

* Add test for image

* Add rosace ex

* Add curve in tosvg, add add examples

* PDF so far

* Review macro

* Fix dessin-pdf image size

* Add anchor

* Add pdf image

* bottom_left
Co-authored-by: Olivier Lemoine <[email protected]>

* Tmp text

* WYP
Co-authored-by: Olivier Lemoine <[email protected]>

* Add arcs and thick arcs

* Fix arc end control

* Start documentation

* Fix style size

* Fix arc

* Add tests and start rework export API

* Impl exporter for SVG

* Fix rectangle empty size

* Start work on PDF exporter

* WIP

Co-authored-by: Olivier Lemoine <[email protected]>

* Start documenting

* Add more doc

* bump dependencies
partial fix textbox
Co-authored-by: Olivier Lemoine <[email protected]>

* Add tests for anchor

* Update readme

* Add readme for crates.io

* Update version

* Add readme for create.io

* Bump versions

* Fix image placement on svgs

* Bump versions

* Add auto escaping < and > for svg

* Add custom font for SVG + font name

* Add text rotation

* Update links to doc

* fix typo rbg instead of rgb
add a macro allowing styling after tranform to a shape
use is rename var to avoid linter issues
Co-authored-by: Olivier Lemoine <[email protected]>

* Add textbox vertical align

* Update macro engine

* Add vertical layout

* Impl Texbox as Layout

* Fix warnings

* Add extend for curve

* Fix bounding box join and intersect

* Update README.md

* Bump versions

* Fix erased type

* Fix group bounding-box

* Add derive macro

* Hotfix style into shape

* Add failing test

* Fix varible as argument for if and for

* add some test
add const generic regular polygones
Co-authored-by: Olivier Lemoine <[email protected]>

* Add doc

* Fix bounding box being square of the result if the shape had a transform

Co-authored-by: Olivier Lemoine <[email protected]>

* Impl default-font

* Fix svg viewport

* Add scafolding for dessin-image

* Test with dynamic shape

* Add dynamic

* fix curve bounding box not applying local transform

Co-authored-by: Olivier Lemoine <[email protected]>

* potential fix of autocenter

* Add dynamic ref

* Remove builtin fonts for now

* Fix SVG Auto bounding box

* Start impl dessin-image

* Add Fit component

* Add metadata

* Use raqote as Image rasterizer

* Add metadata to layout

* Add back local_transform to textbox

* Clean Option<BoundingBox>

* Start adding missing doc

* Add some and into_some derive macro

* Clean text to use derive macro

* Fix local_bounding_box of text

* Fixing tests and set default width of TextBox to inf

* Add test for textbox

* Bump version to 0.8.14-pre

* Add optionnal args

* Fix rotation computation

* Remove test file

* Add let guard

* Add Padding

* Add documentation for crates.io

* Start working on pdf export with printpdf 0.6 (#73)

* bump all dependencies

* add export_curve implementation to pdf
partial text export to pdf missing font handling and position control

* manage font in struct

* pdf: add support for translation and rotation

---------

Co-authored-by: francois morillon <[email protected]>

* Remove .idea

* Update actions

* New proc-macro (#83)

* New proc-macro

* Start converting example + fix erased type should actualy be a shape

* Fix style creation + add back optional styled shape. Continue translating to new macro

* Fix tests compilation

* Continue updating doc

* Fix tests

---------

Co-authored-by: oli <[email protected]>

* Fix github actions + Fix 432 example

* Update rust.yml

* Fix #71 svg rotation + tweak proc-macro (#84)

* Add a couple very simple examples and two contribs (#85)

* Co-authored-by: francois-deadalus <[email protected]>

* add red_circle_with_macro and red_circle_without_macro in exemples

* correct error in red_circle_without_macro helped by François and Olivier

* Same as before

* add green rectangle with and without macro + blue blue triangle with macro and the unfinished without macro

* Add any_triangle, right_angle and yellow_thick with and without macro example, plus, triangle in the contrib

* add arc with and without macro, plus, rewrite triangle in contrib

* Add orange_octogon with and whithout macro

* add diamond_with_macro, textbox with and without macro and diamond in contrib

* fmt

* use octogon in the octogon example

* rename Triangle_test to Triangle

---------

Co-authored-by: francois morillon <[email protected]>

* Bump version

* Add rust fmt to github action

* Fix compile error

* Add option to run all examples

* Add depreciation context to old dessin macro

* Add test from examples

* Add new examples (#86)

Add examples with both macro

* Remove trait for dessin svg (#87)

* Co-authored-by: francois-deadalus <[email protected]>

* remove trait for dessin.SVG

* Should corrects errors

* Fix last small issues

---------

Co-authored-by: Olivier Lemoine <[email protected]>

* Corrects padding issues

Co-authored-by: Olivier Lemoine <[email protected]>

* Corrects padding (#88)

* Corrects padding issues

Co-authored-by: Olivier Lemoine <[email protected]>

* Add an examples for padding named purple_padding

* Corrects a little mistake in padding.rs

* Add some comments and do some corrections

* It should work

* Corrects the test problem

---------

Co-authored-by: Olivier Lemoine <[email protected]>

* Update rust.yml

* Bump version

* Remove dependency from once_cell (#90)

* ugly weap

* Better font management (#91)

* Corrects padding issues

Co-authored-by: Olivier Lemoine <[email protected]>

* Weap

* Better weap

* Better font management without rebase

* Corrects padding issues

Co-authored-by: Olivier Lemoine <[email protected]>

* Weap

* Better weap

* Better font management without rebase

* Change svg for each example

* Changes after feedback

* possible improvements

* corect error

* change some svg

* Update example outputs

* Renaming stuff

---------

Co-authored-by: Math/Nuba <[email protected]>

* Better weap

* big weap

* Use new macro (#93)

* Corrects padding issues

Co-authored-by: Olivier Lemoine <[email protected]>

* Translate all old macro use to new macro

* Corrects padding issues

Co-authored-by: Olivier Lemoine <[email protected]>

* Translate all old macro use to new macro

* Corrects padding issues

Co-authored-by: Olivier Lemoine <[email protected]>

* Translate all old macro use to new macro

* Corrects padding issues

Co-authored-by: Olivier Lemoine <[email protected]>

* Translate all old macro use to new macro

* should work now

* Changes remainig old macro uses

* Translate all old macro use to new macro

* Corrects padding issues

Co-authored-by: Olivier Lemoine <[email protected]>

* Corrects padding issues

Co-authored-by: Olivier Lemoine <[email protected]>

* should work now

* Corrects padding issues

Co-authored-by: Olivier Lemoine <[email protected]>

* Changes remainig old macro uses

* after the weap, it should works now

* Add some more docs

---------

Co-authored-by: Olivier Lemoine <[email protected]>

* Bump version

* Use Palette on examples

* ugly weap

* Better weap

* big weap

* Use Palette on examples

* Correct errors and change svg

* Correct errors

* correct test error

* Correct examples errors

* Should work

* Update examples

* Correct dessin-svg
svg chang wanted :
-yellow_thick_arc : show transparency
-right_angle_triangle : show transparency
-red_circle
-purple_padding : move to purple color
-green_rectangle

* Erase old rgb

* Same as before

* Update examples

* Better font management for pdf (#95)

* weap

* weap du tu doc problem

* Better font management before rebase

* erase some coments

* erase some coment

* Resolve conversation problems

* Add suggestion and it should work

* Remove coments

* Remove trait for dessin pdf (#96)

* weap

* weap du tu doc problem

* Better font management before rebase

* erase some coments

* erase some coment

* Resolve conversation problems

* Add suggestion and it should work

* first try to remove trait in dessin-pdf

* Remove comments, should work

---------

Co-authored-by: Olivier Lemoine <[email protected]>

* fix macro dessin2 for if let case of ambiguous match of a stuct patern

* Remove panic in dessin pdf   issues #97 (#98)

* Update README.md

* weap

* weap du tu doc problem

* Better font management before rebase

* erase some coments

* erase some coment

* Resolve conversation problems

* Add suggestion and it should work

* first try to remove trait in dessin-pdf

* Remove comments, should work

* weap

* It worked for pdf, just him

* Now, it also works for svg and png

* Remove the panic in the dessin-pdf lib, it should work

* Correcting test errors

* start to cleanup

---------

Co-authored-by: Olivier Lemoine <[email protected]>
Co-authored-by: Francois Morillon <[email protected]>

* Update pngs

* Use palette for colors (#94)

* Corrects padding issues

Co-authored-by: Olivier Lemoine <[email protected]>

* ugly weap

* Better weap

* big weap

* Use Palette on examples

* ugly weap

* Better weap

* big weap

* Use Palette on examples

* Correct errors and change svg

* Correct errors

* correct test error

* Correct examples errors

* Should work

* Update examples

* Correct dessin-svg
svg chang wanted :
-yellow_thick_arc : show transparency
-right_angle_triangle : show transparency
-red_circle
-purple_padding : move to purple color
-green_rectangle

* Erase old rgb

* Same as before

* Update examples

---------

Co-authored-by: Olivier Lemoine <[email protected]>
Co-authored-by: Olivier Lemoine <[email protected]>

* Update macro (use * instead of ! for style) and fmt

* First draft dessin-dioxus

* Update README.md

* Fmt

* Use derive Shape for Style

* Update dependencies

* Update pipeline

* [dessin-dioxus] Add none to fill

* [dessin] Add PartialEq to Shape

* Update version, before publishing 0.8.0

* Update READMEs

* Update main README

* Remove deprecated macro `dessin`, and replace it with `dessin2`

* Some formting

* Fmt

---------

Co-authored-by: François Morillon <[email protected]>
Co-authored-by: morillon fançois <[email protected]>
Co-authored-by: Math/Nuba <[email protected]>
Co-authored-by: Math/Nuba <[email protected]>
Co-authored-by: Francois Morillon <[email protected]>
Co-authored-by: Math/Nuba <[email protected]>
  • Loading branch information
7 people authored Feb 26, 2025
1 parent 6533193 commit 07e5141
Show file tree
Hide file tree
Showing 138 changed files with 9,333 additions and 3,352 deletions.
41 changes: 28 additions & 13 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
name: Rust

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
push:

env:
CARGO_TERM_COLOR: always
CARGO_TERM_COLOR: always

jobs:
build:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install fonts
run: sudo apt install -y pkg-config libfreetype6-dev libfontconfig1-dev
- name: Run tests
run: cargo test --verbose

runs-on: ubuntu-latest
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Format
run: cargo fmt

steps:
- uses: actions/checkout@v2
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install fonts
run: sudo apt install -y pkg-config libfreetype6-dev libfontconfig1-dev
- name: Copy current shape dir
run: cp -r examples/out examples/out-current
- name: Execute all examples
run: ./run-all-examples.sh
- name: Compare the 2 directories
run: diff examples/out-current examples/out
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
Cargo.lock
.DS_Store
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug",
"program": "${workspaceFolder}/<executable file>",
"args": [],
"cwd": "${workspaceFolder}"
}
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix"
}
24 changes: 23 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
[workspace]
resolver = "2"
members = [
# Export
"dessin",
"dessin-svg",
"dessin-pdf",
"dessin-image",
"dessin-dioxus",
"dessin-macros",

members = ["dessin", "dessin-svg", "dessin-pdf", "examples/svg-pdf"]
# Internal
"examples",
]

[workspace.package]
version = "0.8.0"
license = "MIT"
edition = "2021"
repository = "https://github.com/432-Technologies/dessin"
keywords = ["dessin", "drawing", "pdf", "svg", "image", "layout"]
authors = [
"Olivier Lemoine <[email protected]>",
"François Morillon <[email protected]>",
]
105 changes: 65 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,72 @@
# [Dessin](https://docs.rs/dessin/)
# [dessin](https://docs.rs/dessin/)

**Try out the new [API](https://github.com/432-Technologies/dessin/tree/v0.8-pre)**
Generate complex drawing for PDF, SVG, images and Dioxus !

Generate complex drawing for PDF, SVG, and many more to come !

### How ?

First, let's create a drawing and give it a bunch of things.
``` rust
let mut drawing = Drawing::empty().with_canvas_size(vec2(100., 100.));

drawing.add(
Text::new("Hello World".to_owned())
.at(vec2(50., 50.))
)
.add(
Line::from(vec2(0., 0.)).to(vec2(100., 100.))
)
.add(
Circle::new()
.at(vec2(50., 50.)).with_radius(10.)
)
.add(
Image::new(ImageFormat::PNG(include_bytes!("../rustacean-flat-happy.png").to_vec()))
.at(vec2(50., 50.))
.with_size(vec2(10., 10.))
);
```
We can even add sub drawings to our drawing.
``` rust
let other_drawing = Drawing::empty()
.with_canvas_size(vec2(210., 297.))
.add(
EmbeddedDrawing::new(drawing)
.at(vec2(100., 100.))
.with_size(vec2(10., 10.))
);
## Getting started

First of all, add `dessin` to build beautiful drawings !

```bash
cargo add dessin
```

Then, we export our drawing to [PDF](https://docs.rs/dessin-pdf/), [SVG](https://docs.rs/dessin-svg/), PNG, etc.
``` rust
use dessin_svg::ToSVG;
Then, and either/or `dessin-svg`, `dessin-pdf`, `dessin-image` or `dessin-dioxus` depending of the export you need.

### Crates

- [dessin](./dessin/README.md): the main composing logic
- [dessin-macros](./dessin-macros/README.md): the macros `dessin!()` and `#[derive(Shape)]`
- [dessin-svg](./dessin-svg/README.md): the SVG exporter
- [dessin-pdf](./dessin-pdf/README.md): the PDF exporter
- [dessin-image](./dessin-image/README.md): the image exporter
- [dessin-dioxus](./dessin-dioxus/README.md): the Dioxus exporter

### Overview

```rust
use dessin::prelude::*;
use palette::{named, Srgb};
// We also reexport palette, in case you need it
// use dessin::palette::{named, Srgb};

#[derive(Default, Shape)]
struct MyShape {
text: String,
}
impl MyShape {
fn say_this(&mut self, what: &str) {
self.text = format!("{} And check this out: `{what}`", self.text);
}
}
impl From<MyShape> for Shape {
fn from(MyShape { text }: MyShape) -> Self {
dessin!(*Text(fill = Srgb::<f32>::from_format(named::RED).into_linear(), { text })).into()
}
}

fn main() {
let dessin = dessin!(for x in 0..10 {
let radius = x as f32 * 10.;

dessin!([
*Circle(
fill = Srgb::<f32>::from_format(named::RED).into_linear(),
{ radius },
translate = [x as f32 * 5., 10.],
),
*Text(fill = Srgb::<f32>::from_format(named::BLACK).into_linear(), font_size = 10., text = "Hi !",),
])
});

let dessin = dessin!([
{ dessin }(scale = [2., 2.]),
MyShape(say_this = "Hello world"),
]);

// let svg = dessin_svg::to_string(&dessin).unwrap();
// let pdf = dessin_pdf::to_string(&dessin).unwrap();
// Etc...
}

let svg = drawing.to_svg().unwrap();
dbg!(svg);
```
2 changes: 0 additions & 2 deletions algebr/.gitignore

This file was deleted.

10 changes: 0 additions & 10 deletions algebr/Cargo.toml

This file was deleted.

21 changes: 0 additions & 21 deletions algebr/LICENSE

This file was deleted.

5 changes: 0 additions & 5 deletions algebr/README.md

This file was deleted.

46 changes: 0 additions & 46 deletions algebr/src/angle.rs

This file was deleted.

5 changes: 0 additions & 5 deletions algebr/src/lib.rs

This file was deleted.

Loading

0 comments on commit 07e5141

Please sign in to comment.