# ofLine and perlin noise

Hi,

I am trying to implement perlin noise on a line.

I’ve divided 2 vector’s length with sample point that I want and re draw it for each section as much as sample point divided.

``````    void testApp::lifeStream( ofVec3f vec1, ofVec3f vec2, int stepsize ){
// perlin noise obj
msa::Perlin pNoise2( OCCTAVE, FREQ, AMPLITUDE, ofRandom(123) );
// front line keep
ofLine( vec1, vec2 * 1/stepsize + pNoise2.get(1, 2, 3) );

vec1 = vec2 * 1/stepsize + pNoise2.get(1, 2, 3);
for (int i = 2; i < stepsize; i++) {
msa::Perlin pNoise( OCCTAVE, FREQ, AMPLITUDE, ofRandom(0, i+123) );
ofLine( vec1, vec2 * i/stepsize + pNoise.get(5 * i, 5 * i) );
vec1 = vec2 * i/stepsize + pNoise.get(5 * i, 5 * i);
}
// end line keep
ofLine( vec1, vec2 );
}
``````

and then added perlin noise to it with ofxMSAPerlin but I am wondering if that is write way to create noised line in OF?

Hey @fkkcloud, what exactly are you trying to achieve with applying perlin noise to a line? I’m a little confused by the fact that you change your seed value on every iteration of your `for` loop. That appears to me like it would defeat the purpose of using perlin noise?

As for drawing lines that are composed of many line segments - have you used `ofPolyline` before (doc page)? It would allow you to draw curved line segments (using `curveTo(...)`) instead of only being able to only draw straight line segments with `ofLine`.

It also has methods like `getPointAtPercent(...)` and `getPointAtLength(...)` that would allow you to sample evenly along your `ofPolyline`. The way that you are using `stepsize` doesn’t appear to guarantee that you would be sampling your line evenly between `vec1` and `vec2` (unless when you call `lifeStream`, you are setting your `stepsize` to be the euclidean distance between `vec1` and `vec2`).

1 Like

Hey, So I am feeling much better with `ofPolyLine()` instead of drawing each segment with `ofLine()`!