Sha256: 80a058ffbfed31104647547b7b9156dde4db1d226d6ce7b61fb07c6468409dd6
Contents?: true
Size: 982 Bytes
Versions: 11
Compression:
Stored size: 982 Bytes
Contents
package toxi.processing; import toxi.geom.Line2D; import toxi.geom.ReadonlyVec2D; import toxi.geom.Vec2D; /** * {@link Line2DRenderModifier} implementation to draw a dashed line with * customizable step length. */ public class DashedLineModifier implements Line2DRenderModifier { /** * */ public float length; /** * Constructs a new instance * * @param length * step length */ public DashedLineModifier(float length) { this.length = length; } /** * * @param gfx * @param a * @param b */ @Override public void apply(ToxiclibsSupport gfx, ReadonlyVec2D a, ReadonlyVec2D b) { int i = 0; Vec2D prev = null; for (Vec2D p : new Line2D(a, b).splitIntoSegments(null, length, true)) { if (i % 2 == 0) { prev = p; } else { gfx.line(prev, p); } i++; } } }
Version data entries
11 entries across 11 versions & 1 rubygems