Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more documentation with examples #67

Open
Makogan opened this issue Apr 9, 2023 · 2 comments
Open

Add more documentation with examples #67

Makogan opened this issue Apr 9, 2023 · 2 comments

Comments

@Makogan
Copy link

Makogan commented Apr 9, 2023

It would be helpful to have a few more small examples. One thing in particular would be how to add multiple objects. Like a square and a circle, both with different stroke styles.

As it stands one might thing that the way to do this would be:

let front = square(start, size);
    let path = Path::new()
        .set("fill", "none")
        .set("stroke", "black")
        .set("stroke-width", 3)
        .set("d", front);

    let back = Data::new()
        .move_to((start.0 - size / 5, start.1 + size / 5))
        .line_by((0, size))
        .line_by((size, 0))
        .line_by((0, -size))
        .close();

    let other_path = Path::new()
        .set("fill", "none")
        .set("stroke", "black")
        .set("stroke-width", 3)
        .set("d", back);

    path.add(other_path)
    ```
    
    But no svg renderer accepts that as a valid output, they render only one of the 2 boxess.
@jdvfx
Copy link

jdvfx commented Apr 18, 2023

Have a look at this repo:
https://github.com/Lakret/gir/blob/master/mazes/src/draw.rs
They're using into_iter().fold() to add paths from a Vec of Path into the document.

@IvanUkhov
Copy link
Member

Yes, indeed the documentation is sparse. The assumption here is that the user is familiar with the format and knows what combines with what and how. The example you gave breaks against the rules (at least, I have not see nesting paths in paths), which are not enforced by the crate.

In any case, the format will probably not be explained here; it does not feel to belong. One could show more examples, but they will not be exhaustive, and one would run into problems still if there is no prior knowledge of the format.

@IvanUkhov IvanUkhov reopened this Jul 25, 2023
@IvanUkhov IvanUkhov changed the title More examples/documentation Add more documentation with examples Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants