Coder Social home page Coder Social logo

emilerolley / vg Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dbuenzli/vg

0.0 0.0 0.0 1.66 MB

Declarative 2D vector graphics for OCaml

Home Page: http://erratique.ch/software/vg

License: ISC License

OCaml 99.18% Standard ML 0.11% HTML 0.71%

vg's Introduction

Emile Rolley

Human with a particular interest in strongly typed programming languages and the open-source, trying to have a meaningful impact πŸ’š
Gitlab 🦊 β€’ Mail πŸ“¨ β€’ LinkedIn πŸ”—


Tip

I'm available to work on a new project, so don't hesitate to contact me if you're interested.

Currently, I'm doing voluntary work on:

  • πŸ›οΈ Publicodes, a declarative language for modeling complex business domains by breaking them down into simple elementary rules.
  • πŸ₯₯ EkoFest, a lightweight and efficient web app for calculating the carbon footprint of events.

I previously worked on:

  • βš–οΈ Catala, a programming language toolchain used to derive correct-by-construction and transparent implementations from legislative texts.
  • 🌍 Nos Gestes Climat, the ADEME official carbon footprint simulator.

vg's People

Contributors

art-w avatar dbuenzli avatar hhugo avatar monstasat avatar

vg's Issues

Optimize algorithms

For now list are used by default but this certainly not be the most performant approach.

  • Improve the even-odd rule algorithm by implementing the scanline algorithm.
    • first attempt
    • needs to be fixed
    • manage imbricated paths

    With the scanline algorithm implementation, the performance is drastically better than cairo. However, the result is less precise that the previous implementation.

Line stroking bug (modulo y coords?)

let stroked_rect1 =
  let r =
    P.empty |> P.sub (v 0.25 0.25) |> P.line (v 1. 0.25) |> P.line (v 1. 1.)
  in
  I.cut
    ~area:(`O { P.o with P.width = 0.01 })
    r
    (I.const (Color.v 0.2 0.2 0.8 1.))

is rendered into:

Screenshot from 2021-08-09 11-55-14

Setup tests

Require #3 to be done.

In order to test the renderer, a simple program allowing to compare the results of Vgr_ba and other implemented renderers such as Vgr_cairo should be implemented.

At first, it could only generate two PNG images that I can compare manually.
Then, it could be interesting to automatize the comparison as it could be used in the learn-ocaml at the end.

Find out how to manage the view and the size.

  • Determine if a point is in the view = need to be render.
  • Determine how to scale point coordinates (done with the [state.scaling] value).
  • Determine how to y-flip coordinates in order to correspond to the [Vg] coordinate representation.

Refactor the internal path representation

Currently, internal paths are rasterized as soon as possible in the set_path function: each points of path are stored. But, in order to manage transformations, a sub path should only be a list of end points of lines which could be rasterized with the bresenham_line function when the path needs to be strokes or filled.

How to

Before calling r_fill or r_stroke in r_cut, calculates all points by using the bresenham_line function.

TODOs

Refactor:

  • the stroking function
  • close
  • line_to
  • move_to
  • curve_to
  • the filling function
  • perfomance issues
  • last cleaning

Improve filling algorithms

Filling a simple square with the even-odd rule on an image of 955x590 took 4s. It is x2 with two intricated squares.
=> Not usable.

  • Calculates the fitting box to iterate through instead of the whole bitmap.

Implement the r_cut function

Implement r_cut.

For this, following functions must be implemented:

  • val stroke : r_state -> r_state (for now, fixed with 1-pixel width)
  • val fill : r_state -> r_state
  • val even_odd_rule
  • val non_zero_rule
  • val clip : r_state -> r_state (needed for the Cut image)

Setup the architecture

Create the Vgr_bitmap module and implement main functions (according to the Vg.Vgr module) with failwith where is needed to compile.

Implement the set_path function

Implement set_path (see #1).

For this, following functions must be implemented:

  • val move_to : r_state -> float -> float -> r_state
  • val line_to : r_state -> float -> float -> r_state
  • val close_path : r_state -> r_state
  • val bezier_curve_to : r_state -> float -> float -> float -> float -> float -> float -> r_state
  • val quadratic_curve_to : r_state -> float -> float -> float -> float -> r_state

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.