Skip to content

Commit

Permalink
Minification fixed, minor error corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
Chlumsky committed Apr 28, 2016
1 parent 61d3929 commit 143767c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ and pseudo-distance fields, its primary purpose is to generate multi-channel dis
using a method I have developed. Unlike monochrome distance fields, they have the ability
to reproduce sharp corners almost perfectly by utilizing all three color channels.

The following sequence of images demonstrates the improvement in image quality.
The following comparison demonstrates the improvement in image quality.

![demo-msdf16](https://cloud.githubusercontent.com/assets/18639794/14770355/14cda9f8-0a70-11e6-8346-2bd14b5b832f.png)
![demo-sdf16](https://cloud.githubusercontent.com/assets/18639794/14770360/20c51156-0a70-11e6-8f03-ed7632d07997.png)
Expand Down Expand Up @@ -89,12 +89,12 @@ in order to generate a distance field. Please note that all classes and function
or `CubicEdge`. You can construct them from two endpoints and 0 to 2 Bézier control points.
- Normalize the shape using its `normalize` method and assign colors to edges if you need a multi-channel SDF.
This can be performed automatically using the `edgeColoringSimple` heuristic, or manually by setting each edge's
`color` member. Keep in mind that at least two color channels must be turned on in each edge, and the color should
only change at corners.
`color` member. Keep in mind that at least two color channels must be turned on in each edge, and iff two edges meet
at a sharp corner, they must only have one channel in common.
- Call `generateSDF`, `generatePseudoSDF`, or `generateMSDF` to generate a distance field into a floating point
`Bitmap` object. This can then be worked with further or saved to a file using `saveBmp` or `savePng`.
- You may also render an image from the distance field using `renderSDF`. Consider calling `simulate8bit`
on the distance field beforehand to simulate the standard 8 bits/pixel image format.
on the distance field beforehand to simulate the standard 8 bits/channel image format.

Example:
```c++
Expand Down Expand Up @@ -163,7 +163,7 @@ The text shape description has the following syntax.
- Points in a contour are separated with semicolons.
- The last point of each contour must be equal to the first, or the symbol `#` can be used, which represents the first point.
- There can be an edge segment specification between any two points, also separated by semicolons.
This can include the edge's color (`c`, `m`, or `y`) and/or one or two curve control points inside parentheses.
This can include the edge's color (`c`, `m`, `y` or `w`) and/or one or two Bézier curve control points inside parentheses.

For example,
```
Expand Down
8 changes: 4 additions & 4 deletions core/render-sdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static float distVal(float dist, double pxRange) {

void renderSDF(Bitmap<float> &output, const Bitmap<float> &sdf, double pxRange) {
int w = output.width(), h = output.height();
pxRange *= (w+h)/(sdf.width()+sdf.height());
pxRange *= (double) (w+h)/(sdf.width()+sdf.height());
for (int y = 0; y < h; ++y)
for (int x = 0; x < w; ++x) {
float s = sample(sdf, Point2((x+.5)/w, (y+.5)/h));
Expand All @@ -49,7 +49,7 @@ void renderSDF(Bitmap<float> &output, const Bitmap<float> &sdf, double pxRange)

void renderSDF(Bitmap<FloatRGB> &output, const Bitmap<float> &sdf, double pxRange) {
int w = output.width(), h = output.height();
pxRange *= (w+h)/(sdf.width()+sdf.height());
pxRange *= (double) (w+h)/(sdf.width()+sdf.height());
for (int y = 0; y < h; ++y)
for (int x = 0; x < w; ++x) {
float s = sample(sdf, Point2((x+.5)/w, (y+.5)/h));
Expand All @@ -62,7 +62,7 @@ void renderSDF(Bitmap<FloatRGB> &output, const Bitmap<float> &sdf, double pxRang

void renderSDF(Bitmap<float> &output, const Bitmap<FloatRGB> &sdf, double pxRange) {
int w = output.width(), h = output.height();
pxRange *= (w+h)/(sdf.width()+sdf.height());
pxRange *= (double) (w+h)/(sdf.width()+sdf.height());
for (int y = 0; y < h; ++y)
for (int x = 0; x < w; ++x) {
FloatRGB s = sample(sdf, Point2((x+.5)/w, (y+.5)/h));
Expand All @@ -72,7 +72,7 @@ void renderSDF(Bitmap<float> &output, const Bitmap<FloatRGB> &sdf, double pxRang

void renderSDF(Bitmap<FloatRGB> &output, const Bitmap<FloatRGB> &sdf, double pxRange) {
int w = output.width(), h = output.height();
pxRange *= (w+h)/(sdf.width()+sdf.height());
pxRange *= (double) (w+h)/(sdf.width()+sdf.height());
for (int y = 0; y < h; ++y)
for (int x = 0; x < w; ++x) {
FloatRGB s = sample(sdf, Point2((x+.5)/w, (y+.5)/h));
Expand Down
3 changes: 2 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

/*
* MULTI-CHANNEL SIGNED DISTANCE FIELD GENERATOR v1.0 (2016-04-24) - standalone console program
* MULTI-CHANNEL SIGNED DISTANCE FIELD GENERATOR v1.0 (2016-04-28) - standalone console program
* --------------------------------------------------------------------------------------------
* A utility by Viktor Chlumsky, (c) 2014 - 2016
*
Expand Down Expand Up @@ -78,6 +78,7 @@ static bool parseAngle(double &value, const char *arg) {
return true;
if (result == 2 && (c1 == 'd' || c1 == 'D')) {
value = M_PI*value/180;
return true;
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion msdfgen-ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#pragma once

/*
* MULTI-CHANNEL SIGNED DISTANCE FIELD GENERATOR v1.0 (2016-04-24) - extensions
* MULTI-CHANNEL SIGNED DISTANCE FIELD GENERATOR v1.0 (2016-04-28) - extensions
* ----------------------------------------------------------------------------
* A utility by Viktor Chlumsky, (c) 2014 - 2016
*
Expand Down
Binary file modified msdfgen.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion msdfgen.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#pragma once

/*
* MULTI-CHANNEL SIGNED DISTANCE FIELD GENERATOR v1.0 (2016-04-24)
* MULTI-CHANNEL SIGNED DISTANCE FIELD GENERATOR v1.0 (2016-04-28)
* ---------------------------------------------------------------
* A utility by Viktor Chlumsky, (c) 2014 - 2016
*
Expand Down

0 comments on commit 143767c

Please sign in to comment.