Skip to content

narslan/blendend

Repository files navigation

blendend

Blendend logo

This project provides Elixir bindings to Blend2D .

  • blendend is currently in experimental stage. But most of the functionalities have been already implemented.

  • Blend2D's rendering engine from plain Elixir.

  • Composable drawing pipeline: Canvas, Path, Matrix2D, Text, Style modules.

  • A DSL (Blendend.Draw) for concise scripts.

  • Support for PNG/QOI export.

Requirements

  • The latest Blend2D built and installed on your system
  • A C++ toolchain (a C++ compiler + cmake)

Quick build of Blend2D:

git clone https://github.com/blend2d/blend2d
cd blend2d
git clone https://github.com/asmjit/asmjit 3rdparty/asmjit
mkdir build && cd build
cmake ..
make -j$(nproc)
sudo make install

Install in your project

def deps do
  [
    {:blendend, github: "narslan/blendend"}
  ]
end

Then:

mix deps.get
mix compile

Quick start

blendend is meant to feel like a sketchbook: open a canvas, write a few lines, get pixels back. After adding the dependency and compiling, you can start an IEx session or drop a script anywhere in your project. The Blendend.Draw DSL keeps things terse so you can focus on shapes and color rather than boilerplate.

Below, we draw a single white line and write it to disk. Change the block to add circles, text, gradients, or any of the other helpers in Blendend.Draw.

use Blendend.Draw

draw 200, 200, "priv/basic_line.png" do
  line 0, 100, 200, 100, stroke: rgb(255, 255, 255)
end

For a richer starting point, clone the blendend_playground repo and run it to browse and tweak the bundled examples in the browser.

Playground

There is a separate web playground for live editing and rendering, and for browsing the bundled examples: blendend_playground.

Gallery

Adorable tiger (vector tracing)
Vector tiger head with dynamic strokes
Flower waves (blur effect)
Layered flower waves with blur
Function plot
Sine and cosine waves on axes
Blendend logo (path flattening)
Rainbow Blendend logo with noisy stroke outlines
Color burn gradients
Grid of gradients with burn blend

Licenses

  • This project is released under the MIT License (see LICENSE).
  • blend2d is licensed under the zlib license.
  • priv/fonts/Alegreya-Regular.otf is distributed under the SIL Open Font License.
  • The burn grid demo and flower waves (which are available in blendend_playground) is adapted from takawo's original p5.js sketch (https://openprocessing.org/user/6533) and shared under the Creative Commons BY-NC-SA 3.0 license (https://creativecommons.org/licenses/by-nc-sa/3.0/).

About

Elixir bindings for blend2d rendering engine

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages