commit 3df2764aaa40153d842dd1b7bb37e56f6ca6f3ef
parent f67d7dfa3cd618a91acdc47d3fc13703d28135da
Author: Adam <[email protected]>
Date: Tue, 28 Apr 2020 21:50:36 -0500
new drawFunction for default and paw
Diffstat:
2 files changed, 34 insertions(+), 38 deletions(-)
diff --git a/src/ComputerscareDrolyPaw.cpp b/src/ComputerscareDrolyPaw.cpp
@@ -222,6 +222,8 @@ struct DrolyPaw : Module {
frameIndex = 0;
}
};
+namespace rack {
+namespace widget {
struct NoClearWidget : FramebufferWidget {
NoClearWidget() {
FramebufferWidget();
@@ -309,6 +311,10 @@ struct DrolyPawDisplay : FramebufferWidget {
}
draw.drawLines(pts.get(), polyVals, colors, thicknesses);
}
+ else if( mode==3) {
+ //number,-dTHickness,dAngle,dColor (passed to sincolor)
+ draw.drawLines(20,3,0.1);
+ }
else {
int nx = (mode * 17) % 10;
int ny = (mode * 11 + 3) % 10;
@@ -360,36 +366,7 @@ struct DrolyPawDisplay : FramebufferWidget {
nvgReset(vg);
}
};
-struct DrolyGLDisplay : OpenGlWidget {
- DrolyPaw *module;
- DrolyGLDisplay() {
-
- }
-
- void drawFramebuffer() override {
- float a = module->bufferX[0][0];
- float b = module->bufferX[1][0];
-
- float c = module->bufferX[2][0];
-
- glViewport(0.0, 0.0, fbSize.x, fbSize.y);
- glClearColor(a * 2, b * 2, c * 2, 1.0);
- //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(a, fbSize.x, 0.0, fbSize.y, -1.0, 1.0);
-
- glBegin(GL_TRIANGLES);
- glColor3f(a / 10, b / 10, c / 10);
- glVertex3f(fbSize.x / 2 + b * 10, fbSize.y / 2 + c * 10, a * 10);
- glColor3f(0, 1, 0);
- glVertex3f(fbSize.x / 2 + c * 10, 0, 0);
- glColor3f(0, 0, 1);
- glVertex3f(0, fbSize.y / 2 + b * 10, 0);
- glEnd();
- }
-};
+}}
struct DrolyPawWidget : ModuleWidget {
@@ -406,14 +383,6 @@ struct DrolyPawWidget : ModuleWidget {
}
{
- DrolyGLDisplay *gl = new DrolyGLDisplay();
- gl->module = module;
- gl->box.pos = Vec(0, 0);
- gl->box.size = Vec(box.size.x, box.size.y);
- //addChild(gl);
- }
-
- {
DrolyPawDisplay *display = new DrolyPawDisplay();
display->module = module;
display->box.pos = Vec(0, 0);
diff --git a/src/drawFunctions.hpp b/src/drawFunctions.hpp
@@ -104,6 +104,33 @@ struct DrawHelper {
nvgStroke(vg);
nvgRestore(vg);
}
+ drawLines(int n, float dThickness,float dTheta,float dColor=0.1) {
+ nvgSave(vg);
+ // nvgBeginPath(vg);
+
+ //nvgMoveTo(vg, 0,0);
+ float initialThick=20.f;
+ float radius=100;
+ for (unsigned int i = 0; i < n; i++) {
+ float thickness=initialThick-dThickness*i/n;
+ NVGcolor color = sincolor(dColor*i/n);
+ float angle = dTheta*i/n*2*M_PI;
+ nvgBeginPath(vg);
+ nvgStrokeColor(vg, color);
+ nvgStrokeWidth(vg, thickness);
+
+ float x0=100*cosf(angle);
+ float y0 = 100*sinf(angle);
+ float x1 = 100*cosf(angle+M_PI);
+ float y1 = 100*sinf(angle+M_PI);
+
+ nvgMoveTo(vg,x0,y0);
+ nvgLineTo(vg,x1,y1);
+ nvgClosePath(vg);
+ nvgStroke(vg);
+ }
+ nvgRestore(vg);
+ }
void drawField(std::vector<Vec> points, NVGcolor strokeColor=BLACK,float length=4,float thickness=1.f) {
unsigned int n = points.size();
nvgSave(vg);