Browse Source

Minification fixed, minor error corrections

Viktor Chlumský 9 years ago
parent
commit
143767c7ef
6 changed files with 13 additions and 12 deletions
  1. 5 5
      README.md
  2. 4 4
      core/render-sdf.cpp
  3. 2 1
      main.cpp
  4. 1 1
      msdfgen-ext.h
  5. BIN
      msdfgen.exe
  6. 1 1
      msdfgen.h

+ 5 - 5
README.md

@@ -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
 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.
 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-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)
 ![demo-sdf16](https://cloud.githubusercontent.com/assets/18639794/14770360/20c51156-0a70-11e6-8f03-ed7632d07997.png)
@@ -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.
    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.
  - 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
    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
  - 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`.
    `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`
  - 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:
 Example:
 ```c++
 ```c++
@@ -163,7 +163,7 @@ The text shape description has the following syntax.
  - Points in a contour are separated with semicolons.
  - 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.
  - 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.
  - 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,
 For example,
 ```
 ```

+ 4 - 4
core/render-sdf.cpp

@@ -39,7 +39,7 @@ static float distVal(float dist, double pxRange) {
 
 
 void renderSDF(Bitmap<float> &output, const Bitmap<float> &sdf, double pxRange) {
 void renderSDF(Bitmap<float> &output, const Bitmap<float> &sdf, double pxRange) {
     int w = output.width(), h = output.height();
     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 y = 0; y < h; ++y)
         for (int x = 0; x < w; ++x) {
         for (int x = 0; x < w; ++x) {
             float s = sample(sdf, Point2((x+.5)/w, (y+.5)/h));
             float s = sample(sdf, Point2((x+.5)/w, (y+.5)/h));
@@ -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) {
 void renderSDF(Bitmap<FloatRGB> &output, const Bitmap<float> &sdf, double pxRange) {
     int w = output.width(), h = output.height();
     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 y = 0; y < h; ++y)
         for (int x = 0; x < w; ++x) {
         for (int x = 0; x < w; ++x) {
             float s = sample(sdf, Point2((x+.5)/w, (y+.5)/h));
             float s = sample(sdf, Point2((x+.5)/w, (y+.5)/h));
@@ -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) {
 void renderSDF(Bitmap<float> &output, const Bitmap<FloatRGB> &sdf, double pxRange) {
     int w = output.width(), h = output.height();
     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 y = 0; y < h; ++y)
         for (int x = 0; x < w; ++x) {
         for (int x = 0; x < w; ++x) {
             FloatRGB s = sample(sdf, Point2((x+.5)/w, (y+.5)/h));
             FloatRGB s = sample(sdf, Point2((x+.5)/w, (y+.5)/h));
@@ -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) {
 void renderSDF(Bitmap<FloatRGB> &output, const Bitmap<FloatRGB> &sdf, double pxRange) {
     int w = output.width(), h = output.height();
     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 y = 0; y < h; ++y)
         for (int x = 0; x < w; ++x) {
         for (int x = 0; x < w; ++x) {
             FloatRGB s = sample(sdf, Point2((x+.5)/w, (y+.5)/h));
             FloatRGB s = sample(sdf, Point2((x+.5)/w, (y+.5)/h));

+ 2 - 1
main.cpp

@@ -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
  * A utility by Viktor Chlumsky, (c) 2014 - 2016
  *
  *
@@ -78,6 +78,7 @@ static bool parseAngle(double &value, const char *arg) {
         return true;
         return true;
     if (result == 2 && (c1 == 'd' || c1 == 'D')) {
     if (result == 2 && (c1 == 'd' || c1 == 'D')) {
         value = M_PI*value/180;
         value = M_PI*value/180;
+        return true;
     }
     }
     return false;
     return false;
 }
 }

+ 1 - 1
msdfgen-ext.h

@@ -2,7 +2,7 @@
 #pragma once
 #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
  * A utility by Viktor Chlumsky, (c) 2014 - 2016
  *
  *

BIN
msdfgen.exe


+ 1 - 1
msdfgen.h

@@ -2,7 +2,7 @@
 #pragma once
 #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
  * A utility by Viktor Chlumsky, (c) 2014 - 2016
  *
  *