Giter Club home page Giter Club logo

sdfer's Introduction

README

sdfer 1.0

Copyright 2021 Nils Jonas Norberg [email protected]

License: MIT ( https://opensource.org/licenses/mit )

What is this repository for?

  • Generate SDF images (used for anti-aliased icons, text and more)
  • Written in c/c++ with care for memory-access patterns
  • Linear time over number of pixels

Here are some examples:

Spread=2, extends the edge 2 pixels inside/outside

./sdfer -d=1 -s=2 test_images/square.png
Input image Output image

Spread=8

./sdfer -d=1 -s=8 test_images/square.png
Input image Output image

How do I get set up?

(For Windows, install Msys2, also the executable becomes "sdfer.exe")

  1. clone ok_sdf and this repo locally
git clone https://github.com/j-norberg/ok_sdf.git
git clone https://github.com/j-norberg/sdfer.git

cd sdfer
  1. make
make
  1. run internal tests
./sdfer --test

Options

-t=127 Threshhold When the input-image is read, the threshold-value determines what pixel is considered a part of the masked image. Defaults to 127, can be between 0 and 254 inclusive.

-i Invert When the input-image is read, anything above the threshold-value is considered part of the masked image. When -i is active the result is inverted, so anything above the threshold is considered outside.

-p Pad When the pad-option is active, the input-image is enlarged with the spread-amount in every direction, this ensures that the full fade-out will be present in the out-image, and not cut off.

-s=100 Spread The signed distance field will extend this far (in pixels). For use with font-shapes or similar usage, lower number will give you better resolution, but for a larger value can enable more advanced features (blur, shadow, outlines)

-d=2 Downsample This option allow you to down-sample the output-image. This is common to increase the fidelity of angles in shapes.

-c Crop This options will look at the output image and crop it so that the fade touches the edges in each direction.

Known limits: a. image-dimensions b. output format 8-bits (limits useful range of spread)

Contribution guidelines

  • please report bugs (include test image)

Dependencies

sdfer relies on my "ok_sdf" library and requires that it's a sibling of this project in the filesystem.

sdfer relies on stb_image and stb_image_write (included in src/dep)

sdfer's People

Contributors

j-norberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.