2D Graphic Seed-head Patterns
Site Map Feedback
Seed Head
Up Fern Mandelbrot Parity SeedHead
To draw a seed-head on the PixelBlock, mix in the CSeedHeadStencil class below and define the Disc abstract method to use CCircleStencil::Disc:
This class uses the 'Golden Ratio' to create a picture of a Seed-head. The algorithm can be altered to draw other natural objects: Sunflower Seeds, Dandelion, Fir Cone, Pineapple etc.
#include <math.h>

class CSeedHeadStencil {
  virtual void Disc(WORD xCenter, WORD yCenter, WORD Radius, DWORD Colour) =0; // Antialiased, Filled apart from centre pixel:
public:
  CSeedHeadStencil() {}
  void Seeds(WORD x0, WORD y0, DWORD Colour, short SeedRadius=6, int Seeds=987) { // Seeds should be a number from the Fibonacci series
    const double  PI=3.1415926535897932384626433832795;
    const double Phi=1.6180339887498948482045868343656; // The Golden Ratio
    const double  dA=Phi/PI;
    double Angle= dA;
    for(int Seed=Seeds; Seed--; Angle+=(Phi-1)*2*PI) { // Move 0.618 of a circle round each time
      double r=sqrt(Seed)*SeedRadius*dA; // Position Radius is sqrt of the seed number scaled to suit SeedRadius
      Disc(x0+(WORD)(0.5+r*cos(Angle)), y0+(WORD)(0.5+r*sin(Angle)), SeedRadius-SeedRadius*Seed/Seeds, Colour);
    }
  }
};

The following image is drawn live according the these settings:
Seeds
0 Red Spirals
0 Blue Spirals
If you're using a PC, click the drop-list once to see the list, then again to close it - then use your keyboard up and down arrows to scan through the values. This browser doesn't support the canvas element :-(
It's like the top of a fir cone!

Here's a 3D version:
Dome
Then to create full spheres:
Golf Ball

You can mix in as many 'Stencils' as you like to provide all the primitives you need.

The Colours, Drawing and Effects sections have further extensions.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.