Hi,
thats actually much easier. it is just like drawing a circle but modulating its radius using a sin wave.
ofApp.h
#pragma once
#include "ofMain.h"
#include "ofxGui.h"
class ofApp : public ofBaseApp{
public:
void setup();
void draw();
ofxPanel gui;
ofParameter<int> numPoints;
ofParameter<float> radius, modulationDepth, leftModMultiplier, rightModMultiplier;
};
ofApp.cpp
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
gui.setup();
//number of points that will make the circle
gui.add(numPoints.set("numPoints",1000,0,1000));
//the initial radius of the circle
gui.add(radius.set("radius",300, 0,500));
// how much you will modulate the radius.
gui.add(modulationDepth.set("modulationDepth",50,0,500));
// multiplier for the left side modulation
gui.add(leftModMultiplier.set("leftModMultiplier",6,0,20));
// multiplier for the right side modulation
gui.add(rightModMultiplier.set("rightModMultiplier",10,0,20));
ofSetCircleResolution(100);
}
//--------------------------------------------------------------
void ofApp::draw(){
ofMesh m;
m.setMode(OF_PRIMITIVE_LINE_STRIP);
ofBackground(255);
glm::vec3 center(ofGetWidth()/2, ofGetHeight()/2, 0);
for(int i = 0; i < numPoints; i++){
float angle = ofMap(i, 0, numPoints, 0, glm::two_pi<float>());
float mod;
if(i > numPoints/2){
mod = sin(ofMap(i, 0, numPoints, 0, glm::pi<float>()*leftModMultiplier));
}else{
mod = cos(ofMap(i, 0, numPoints, 0, glm::pi<float>()*rightModMultiplier));
}
float modRadius = radius + modulationDepth * mod;
m.addVertex(glm::vec3(sin(angle) * modRadius, cos(angle) * modRadius,0)+ center);
}
ofSetColor(0);
m. draw();
//the following is just to draw the gray circles.
ofPushStyle();
ofNoFill();
ofSetColor(127);
ofDrawCircle(center, radius);
ofDrawCircle(center, radius + modulationDepth);
ofDrawCircle(center, radius - modulationDepth);
ofPopStyle();
gui.draw();
}
you’ll have to change the radius and modulationdepth for the right side to make it look the same as the reference drawing.
best