Img4Dat 2.0.0
=============

Img4Dat converts a bitmap into an LDraw pattern: the image is reduced to a few
colors, the color borders are traced as paths, and the areas are triangulated
and saved as an LDraw .dat file.


Requirements
------------
- Windows 10 or 11 (64 bit)
- Microsoft .NET 10 Desktop Runtime (x64)
  https://dotnet.microsoft.com/download/dotnet/10.0
  Choose ".NET Desktop Runtime" for Windows x64. If it is missing, Windows
  shows a message with a download link when Img4Dat is started.


Installation
------------
Unzip the archive into a folder of your choice and start Img4Dat.exe.
Nothing is installed. Settings and log files are written next to the program
(Settings.xml, Logs\), so use a folder where you have write access.


Quick start
-----------
1. Open Image...      Load the picture (BMP, PNG, JPG, GIF, TIFF).
2. Colors             Right-click into the source image (left) to add a color
                      to the palette. The quantized image (right) shows the
                      result. Enter the LDraw color number in each palette
                      button. Pencil, Fill and Re-quantize fix single pixels
                      or areas. Undo with Ctrl+U (image).
3. Find Paths         Traces the borders between the colors.
4. Edit the graph     Select points (click, Ctrl+click, drag a rectangle) and
                      use the tools above the graph: add, delete, merge points,
                      points on a line or circle, circular arc, Bezier curve,
                      peak. Undo with Ctrl+Z (graph).
5. Template           Choose the part the pattern is placed on (second toolbar
                      row), then "Fit" or adjust X, Y and Scale.
6. Triangulate & Save (Ctrl+S)
                      Creates the triangles and saves the LDraw pattern file.

Graphs can be saved and loaded (Save Graph / Load Graph) to continue later.


Templates
---------
Templates are LDraw files in the Templates folder next to the program.
Triangles (type 3 lines) describe the surface the pattern lies on; additional
type 2 lines mark hard edges. Optional line:
  0 !IMG4DAT PLANE x y z   view direction onto the pattern surface, pointing
                           from the viewer to the part (LDraw: -Y is up), e.g.
                           0 0 1 front (default), 0 1 0 top (tiles),
                           0 0 -1 back, 1 0 0 left side, -1 0 0 right side,
                           0 1 1 a 45° slope seen perpendicularly.
A template first appears centered and fitted to the image.
Edges where two template triangles meet at an angle cut the pattern, so no
pattern triangle spans a fold.


Output
------
The pattern file contains the header lines
  0 !LDRAW_ORG Unofficial_Pattern
  0 !LICENSE Licensed under CC BY 4.0 : see CAreadme.txt
Please complete title, author, category and keywords before submitting a
pattern to the LDraw Parts Tracker.


Acknowledgements
----------------
The algorithms in Img4Dat were strongly inspired by the documentation of two
excellent projects:
- Potrace by Peter Selinger – "Potrace: a polygon-based tracing algorithm"
  (path tracing and polygon simplification), https://potrace.sourceforge.net/
- Triangle by Jonathan Richard Shewchuk – "Triangle: Engineering a 2D Quality
  Mesh Generator and Delaunay Triangulator" (constrained triangulation),
  https://www.cs.cmu.edu/~quake/triangle.html
Img4Dat is an independent implementation and contains no code from these
projects. Many thanks to their authors.


License
-------
See LICENSE.txt and THIRD-PARTY-NOTICES.txt.
