Last active
September 8, 2016 02:05
-
-
Save bildepunkt/29bf0aa80ae828ec533ac78fd0bfead1 to your computer and use it in GitHub Desktop.
draw an archimedian spiral approximation (w/ cubic bezier curves) in iDraw/Graphic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// spiral.idplugin | |
function drawSegment (doc, radius, iterations) { | |
var path = [doc addPath] | |
var spread = radius / 4 | |
var c = 0.552284749 | |
[path addMoveTo:CGPointMake(radius, 0)] | |
while (--iterations) { | |
var oldRadius | |
[path addCurveTo:CGPointMake(0, radius) controlPoint1:CGPointMake(radius, radius * c) controlPoint2:CGPointMake(radius * c, radius)] | |
oldRadius = radius | |
radius += spread | |
[path addCurveTo:CGPointMake(-radius, 0) controlPoint1:CGPointMake(-radius * c, oldRadius) controlPoint2:CGPointMake(-radius, oldRadius * c)] | |
oldRadius = radius | |
radius += spread | |
[path addCurveTo:CGPointMake(0, -radius) controlPoint1:CGPointMake(-oldRadius, -radius * c) controlPoint2:CGPointMake(-oldRadius * c, -radius)] | |
oldRadius = radius | |
radius += spread | |
[path addCurveTo:CGPointMake(radius, 0) controlPoint1:CGPointMake(radius * c, -oldRadius) controlPoint2:CGPointMake(radius, -oldRadius * c)] | |
} | |
return path; | |
} | |
function init() { | |
var doc = [app activeDocument] | |
var path = drawSegment(doc, 16, 12) | |
[[doc activeLayer] addPathShape:path] | |
} | |
init() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment