I do prefer the curious machine with a mood and an attitude too (hum, as long as it doesn't start drinking heavily and seeing criters...), since by its mere structure it is more slanted to be a performance artist rather than a drawing technician.
Some scavenged code somewhere to do shading with concentric circles, found in AS220.
void drawCurve(float x, float y, float fx, float fy, float cx, float cy) {
// Draw a Quadratic Bezier curve from (x, y) to (fx, fy) using control pt
// (cx, cy)
float xt=0;
float yt=0;
for (float t=0; t<=1; t+=.0025) {
xt = pow((1-t),2) *x + 2*t*(1-t)*cx+ pow(t,2)*fx;
yt = pow((1-t),2) *y + 2*t*(1-t)*cy+ pow(t,2)*fy;
moveTo(xt, yt);
}
}
void drawCircle(int centerx, int centery, int radius) {
// Estimate a circle using 20 arc Bezier curve segments
int segments =20;
int angle1 = 0;
int midpoint=0;
moveTo(centerx+radius, centery);
for (float angle2=360/segments; angle2<=360; angle2+=360/segments) {
midpoint = angle1+(angle2-angle1)/2;
float startx=centerx+radius*cos(rads(angle1));
float starty=centery+radius*sin(rads(angle1));
float endx=centerx+radius*cos(rads(angle2));
float endy=centery+radius*sin(rads(angle2));
int t1 = rads(angle1)*1000 ;
int t2 = rads(angle2)*1000;
int t3 = angle1;
int t4 = angle2;
drawCurve(startx,starty,endx,endy,
centerx+2*(radius*cos(rads(midpoint))-.25*(radius*cos(rads(angle1)))-.25*(radius*cos(rads(angle2)))),
centery+2*(radius*sin(rads(midpoint))-.25*(radius*sin(rads(angle1)))-.25*(radius*sin(rads(angle2))))
);
angle1=angle2;
}
}
void drawCircles(int number, int centerx, int centery, int r) {
// Draw a certain number of concentric circles at the given center with
// radius r
int dr=0;
if (number > 0) {
dr = r/number;
for (int k=0; k<number; k++) {
drawCircle(centerx, centery, r);
r=r-dr;
}
}
}
Have you tried it? you have some circle stuff commented out in the firmware...
optimizing the polargraph as a mere plotter would require some changes to the comm protocol, maybe a queue...
how many Ks is the accelstepper library eating?
|