Skip to content

Instantly share code, notes, and snippets.

IDENTIFICATION DIVISION.
PROGRAM-ID. chgmaker.
DATE-WRITTEN. 1/28/2013.
* AUTHOR Dr_Legacy
* REMARKS reddit dailyprogrammer challenge #119
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
DATA DIVISION.
@odiseo42
odiseo42 / README.md
Created February 20, 2014 17:06 — forked from mbostock/.block

This example demonstrates how to create a gradient that follows a stroke. This technique is sometimes used to indicate directionality along a curved edge, such as with hierarchical edge bundling.

To start, take any SVG path element and uniformly sample points along the path using getPointAtLength. (This method can also be used for path tweening.) Then, for each segment between adjacent points, compute the miter joint via line-line intersection. Lastly fill each segment by interpolating the start and end colors, here green to red, using the normalized length t along the path. Although each segment is a constant color, there are many segments to give the appearance of a continuous gradient.

This example uses a thin stroke in addition to filling the segments. This avoids antialiasing artifacts due to most