Coder Social home page Coder Social logo

verg's People

Contributors

alexandruica avatar

Stargazers

 avatar

Watchers

 avatar

verg's Issues

Provide enum(s) for canvas conversions

An enum that would probably contain options for:

  • RGBA
  • RGB
  • CMYK
    We should also provide some options regarding the color space, so possibly another enum for:
  • Gamma(value)
  • Possibly others (not a high priority)

Refactor the shape API

Currently a Shape is a Vec<Primitive>, and it's not ideal. We should make an API that kind of looks like turtle:

Shape {
    start: (0, 0),
    data: vec![
        LineTo{ 120, 350 },
        QuadraticTo { ... },
    ],
}

Add support for affine transformations

Path drawing operations and gradients should take an additional matrix that describes affine transformations (like rotation, scaling and translation).

Some refactoring

It would be a good idea to refactor some stuff, mainly:

  • Provide a few default colors in color.rs (for a start, the ones used in the integration tests should be enough)
  • Remove unused stuff in geometry.rs. Since I've changed the drawing algorithm for rendering lines, a lot of stuff in geometry.rs is left there unused, all of that should be removed
  • In canvas.rs there are a lot of functions that are unused: remove them. Also, draw_shape is a bit of a mess, it would probably a good idea to separate the code for rendering lines and the code for filling

Add sRGB color space support

This could be added as a simple post-processing effect callback that takes pixels as input. That would allow a custom processing effect really easily. All calculations of colors (for example: gradients) will be done in linear space, only when saving the image will this callback be applied.

Automatically verify the test suite

Currently the tests are only run, they are not "checked" for validity automatically. I'd want to run SHA-1 (or something like it) on the resulting image of every test and save it. After that, every test would check its hash against the saved one, checking if it's the same. This way I can track changes in the library that affect rendering.

Fix Cubic Bezier evaluation

Currently the third term in the Cubic Bezier curve expansion is not computed correctly (should be t * t not t * 2.0.

Support custom alpha blending

Currently the alpha blending method is hardcoded to 1 - src.alpha, it would be great if the library would provide a few blending functions (like the Porter-Duff ones), and allow for a custom blending function as well.

Write more tests

We should test more thoroughly. We should probably add tests with more complex polygons:

  • A hexagon at the very least
  • A glass of water with a lemon, something like this one
  • A boat, maybe like this one
  • Render some glyphs, similar to what I've done here, maybe write verg and possibly use rustybuzz for shaping (unlikely)

Render a simple triangle

Follow the algorithm presented here and render a simple triangle for the start. Maybe add a post-processing ability to take into account color spaces. Ideally we should also take into account alpha compositing but it's ok if it's not fully correct for now.

Add support for Bézier curves

It should be pretty easy to port what I've done here, since the algorithm powering it is identical to the one used in verg. I could also borrow the glyph renderer and write some tests that use glyphs.

Simplify the interface and implementation

Pay a bit less attention to details like integer overflow and not allocating at all. It's not that they aren't useful, but it would take a lot more time than I would want to if I want to take everything into consideration.

Project setup

  • Make a main branch which will be the branch where all changes will be progressively merged into
  • Document the commit structure(maybe even provide a sample hook that checks commit formatting), PR/issue templates, branch naming, git workflow
  • Set up rust with cargo
  • Set up actions for automatic checking of formatting, running clippy, code coverage, running tests
  • Set up documentation generation

Reuse a `Vec` for `intersect_line_with_grid()` to avoid needless reallocations

Currently, in intersect_line_with_grid() we create new Vecs on_horizontals and on_verticals each time we call the function. That's not needed, we could just reuse a Vec in canvas that grows as it's needed (or, of course, we could give it a big capacity from the beginning and we could avoid reallocating at all!).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.