I am not sure of the usefulness of this model. Actually, we have already noLoop() and redraw() although the latter might be deprecated and I couldn't make it work outside of an event.
Anyway, the interest of draw() is that it is called at regular intervals, making the pulse of your sketch. If you don't want to use it, you would need to make your own drawing loop or something.
I made a little demo sketch showing we can do what you wanted, and perhaps even more (animation), using the current paradigm. It might seem too complex, but it isn't, I just wanted to make it nicely object oriented and structured.
It is late, I just dump the code, if you have any question, just ask!
DrawingInSequence.pde -
Code://ArrayList<Drawer> drawers = new ArrayList<Drawer>();
ArrayList drawers = new ArrayList();
Drawer currentDrawer;
int currentDrawerIdx;
int currentDuration;
interface Drawer
{
public void Draw();
public int GetDuration();
public void SetDuration(int d);
}
abstract class DefaultDrawer implements Drawer
{
protected int m_duration = 10;
public abstract void Draw();
//@Override
public int GetDuration()
{
return m_duration;
}
//@Override
public void SetDuration(int d)
{
m_duration = d;
}
}
class Texter extends DefaultDrawer
{
private String m_message;
private int m_color;
public Texter(int d, String m, int c)
{
m_duration = d;
m_message = m;
m_color = c;
}
//@Override
public void Draw()
{
background(0);
textAlign(CENTER);
fill(m_color);
noStroke();
// Suppose textFont() have been called
text(m_message, width / 2, height / 2);
}
}
void setup()
{
size(800, 800);
PFont f = createFont("Arial", 48);
textFont(f);
smooth();
drawers.add(new Texter(7, "Demonstrating drawing in sequence", #FF1100));
drawers.add(new Texter(5, "Fill With Circles 1", #AA8800));
drawers.add(new FillWithCircles(250, 222));
drawers.add(new Texter(5, "Pulsating Circles", #BB7700));
Drawer dr = new PulsatingCircles();
dr.SetDuration(30);
drawers.add(dr);
drawers.add(new Texter(5, "Fill With Circles 2", #CC6600));
drawers.add(new FillWithCircles(350, 333));
drawers.add(new Texter(10, "END", #FF0000));
}
void draw()
{
currentDrawer = (Drawer) drawers.get(currentDrawerIdx);
currentDrawer.Draw();
int time = millis() / 1000;
if (time - currentDuration > currentDrawer.GetDuration())
{
currentDrawerIdx++;
currentDuration = time;
if (currentDrawerIdx == drawers.size())
{
noLoop();
}
}
}
Drawers.pde -
Code:// Just reusing two old sketches
class FillWithCircles extends DefaultDrawer
{
int MIN_RAD = 10;
int MAX_RAD = 100;
int m_circleNb;
int m_radius;
FillWithCircles(int radius, int circleNb)
{
m_radius = radius;
m_circleNb = circleNb;
}
//@Override
void Draw()
{
background(255);
noStroke();
int centerX = width / 2;
int centerY = height / 2;
for (int i = 0; i < m_circleNb; i++)
{
float d = random(0, m_radius - MIN_RAD);
float a = random(0, TWO_PI);
float x = centerX + d * cos(a);
float y = centerY + d * sin(a);
float r = random(MIN_RAD, min(MAX_RAD, m_radius - d));
color c = lerpColor(#00FF00, #0000FF, (1 + cos(a))/2);
fill(c);
ellipse(x, y, r * 2, r * 2);
}
}
}
class PulsatingCircles extends DefaultDrawer
{
int rMove = +5;
int slowDown = 1;
int minRadius = 5, maxRadius = 100;
int radius = minRadius;
int xPos = 200;
int yPos = 200;
color c1 = #005599, c2 = #00AA99;
PulsatingCircles() {}
//@Override
void Draw()
{
background(240);
fill(lerpColor(c1, c2, (float) radius / (float) maxRadius));
ellipse(xPos, yPos, radius, radius);
if (frameCount % slowDown == 0)
{
radius += rMove;
if (radius > maxRadius)
rMove = -1;
else if (radius < minRadius)
rMove = +1;
}
}
}
[EDIT] Finally I make Texter to extend DefaultDrawer (ex. Imager).