No description
Find a file
2015-10-02 13:56:20 -05:00
data an example shape from opengl docs, may be instructive for testing different winding rules 2015-10-02 13:56:20 -05:00
.gitignore fixu 2015-08-19 19:53:52 -05:00
dashing.c move part of implementation to separate source file 2015-08-20 09:51:23 -05:00
dashing.h no need to trim line twice 2015-08-21 13:53:44 -05:00
LICENSE.md initial commit 2015-08-19 19:53:52 -05:00
main.c fix doubled percent signs 2015-08-21 13:54:18 -05:00
Makefile move part of implementation to separate source file 2015-08-20 09:51:23 -05:00
parse_numbers.h move part of implementation to separate source file 2015-08-20 09:51:23 -05:00
README.md move part of implementation to separate source file 2015-08-20 09:51:23 -05:00

dashing - a library for autocad-style hatch patterns

License: permissive (zlib); see source files for additional details.

On my core i5, it runs at over 1 million dashes per second.

Example image

API

All items are in namespace dashing. Most are in dashing.h, except as noted.

struct Point: Has double-precision x and y coordinates.

struct Segment: A line segment defined by two endpoints. Segments are used both to define the boundary of the region to hatch, and to express the coordinates of the individual dots and dashes in the resulting hatch.

HatchPattern::FromFile(std::istream fi, double scale): Read an autocad-style hatch pattern file from an opened stream

HatchPattern::FromFile(const char *filename, double scale): Read an autocad-style hatch pattern from the named file

xyhatch(const HatchPattern&, It start, It end, Cb cb): Iterators start..end define a range of segments, which must define a set of closed contours. For each dash or dot in the resulting hatch, Cb is called with the output segment.

xyhatch(const HatchPattern&, const C &segments, Cb cb): The container C holds segments which must define a set of closed contours. For each dash or dot in the resulting hatch, Cb is called with the output segment.

parse_numbers(std::string line): Read a comma and/or space-separated sequence of numbers into a vector

Other items in the header files are implementation details.

Demo program

The demo program, which compiles to dashing with make, reads a dash pattern file and a segment list file and produces a svg file on the output which visualizes the result of the hatch operation.

A segment list file consists of a closed contour on each line specified as a series of x,y coordinates. For instance, this segment list is a simple box:

-100 -100 100 -100 100 100 -100 100

The first point is -100 -100.

It accepts several commandline parameters:

-b: Benchmark mode: print only the number of dashes that would have been
    generated

-j: Apply a jitter to all coordinaes in the segment list file

-s: scale the dash pattern file by a given factor