Today, a post of technology and activities.
A Google search for making a parabola brought me to a nice quick article on making a parabola-looking curved line on eHow.com, but for a quick half-day project I am needing to draw a perfect and scalable vector.
Attached is a simple script to run in Adobe Illustrator that was hand-typed to build what is needed for my project. Some convenient Javascript prompts are included to make it easy to use.
In illustrator, press Ctrl+F12 on Windows or Cmd+F12 on Mac or click File > Scripts > Other script and load the file, then read and follow the prompts.
Click here to download a helpful script for Adobe Illustrator to build a parabola
Here are two parabolas made with this script:
Pingback: How to Make Parabolas in Illustrator | Technology - Popular Question & Answer
Thanks…just what I was looking for. This is very handy!
Legend! Thank you so much. <3
ps.. 'Surprised there are not more comments after 3 years. How many downloads in this period all-told?
I’ve made it a little more useful for those who want more control over what are the parameters of the parabola:
alert(“The parabola will be generated according to this equation. \ny = a * (x – xOffset)^2 + b * (x – xOffset) + yOffset”);
xpos = parseFloat(prompt(“X offset”, “0”));
ypos = parseFloat(prompt(“Y offset”, “0”));
a = parseFloat(prompt(“Coefficient a”, “1”));
b = parseFloat(prompt(“Coefficient b”, “0”));
xstart = parseFloat(prompt(“First Value of X”, “-0.5”));
xend = parseFloat(prompt(“Last Value of X”, “0.5”));
steps = parseFloat(prompt(“How many steps should be there?”, 100) );
scale = parseFloat(prompt(“What should be the scale”, 400));
strokewidth = 1;
drawParabola(xpos, ypos, a, b, xstart, xend, steps, strokewidth, scale);
redraw();
function drawParabola(xpos, ypos, a, b, xstart, xend, steps, strokewidth, scale)
{
var increment = (xend -xstart) / steps;
var myDoc = app.activeDocument;//.documents.add();
var myParabolaPath = myDoc.pathItems.add();
myParabolaPath.stroked = true;
myParabolaPath.strokeWidth = strokewidth;
myParabolaPath.filled = false;
if (xstart > xend)
{
var tx = xstart;
xstart = xend;
xend = tx;
}
var newPoint;
for (i = xstart; i <= xend; i+= increment)
{
newPoint = myParabolaPath.pathPoints.add();
var x_ = i + xpos;
newPoint.anchor = [x_ * scale, (a * i* i + b * i + ypos) * scale];
newPoint.leftDirection = newPoint.anchor;
newPoint.rightDirection = newPoint.anchor;
newPoint.pointType = PointType.CORNER;
}
}
I got the script installed in Illustrator (CC), but when I run it and plug in values, nothing happens. I’m also not sure exactly what the values are that I should put in…but I just used the defaults, and nothing is produced. Any suggestions?