![](https://www.capochiani.cloud/sturmundweb/wp-content/uploads/sites/4/2024/07/butterfl.jpg)
Drawing a Butterfly
Well, hi everyone
I decided to start again with tutorial I left back years ago.
But i think it’s a good way to start talking again.
So, I want to present my own building Iwrote this morning: how to draw a butterfly with parametric plot. It’s a weekendTutorial. And see this approach using painting. Because is always the first one immediate.
That’s right.
It has been an horrible week.
Now, let’s go back and foreward.
The first function is the one for controlling the x: Call the first one – horizontal
function butterflyX (u) [ I don’t know anything about math, you know. And I take it as well as possible. More or less,it could be like this:
var dumbo = math.exp(1);
return Math.sin(u) * Math.pow (dumbo, Math.cos(u)) – 2*Math.cos(4*u) – Math.pow(Math.sin(u/12.),5));
]
The second function is the one for controlling the other way y:
If we analize it the difference
function butterflyY (u) [
var dumbo = math.exp(1);
return Math.cos(u) * Math.pow (dumbo, Math.cos(u)) – 2*Math.cos(4*u) – Math.pow(Math.sin(u/12.),5));
]
The part I prefer is starting draw. Set 3 variables
var uMin = 0;
var uMax = 20*Math.PI;
var uSamples = 2000;
The third function is the one for controlling the graphic display: I choose
So: define the var
var myPlot = makePlot();
And define the function to draw it.
function GraphicDisplay() [
Graphic.draw(myPlot); //draw up-down-up //
]
Go deep inside
function makePlot() [ //draw updownup //
var graphic = Graphic.make();
graphic.color (1,1,0);
graphic.lineStrip(); //add a linestrip
var u = uMin; //add vertex data
var uInc = (uMax-uMin) / uSamples;
for(var i = 0; i<= uSamples; ixx)[
graphic.xy(butterflyx(u), butterflyY(u));
u += uInc;
]
return graphic;
]