siteIcon

Snowman Challenge

Kent P, 2022

Your browser does not support HTML5 Canvas

Notes:

Several different functions were used to draw various aspects of the drawing.

Note that the sky was created with a TNTGradient and that the weird TNTSpetal (sector-petal)furnished the snowflakes.

Features:
Design Scale:

Canvas size:

Comments:

We are particularly pleased with the randomly-placed flakes:

function drawFlakes(n){
    var flakeCenter;
    var h, k;
    var myFlake;
    var rmax, rotn;
    var numRays;
    var largestRaySize = 2;
    var smallestRaySize = .5;
    var ratio;
    lightGrayStroke.setStrokeLineWidth(.1);
    
    for(var i = 1; i <=n; i++){
        h = Math.random()*(XMAX-XMIN) + XMIN;
        k = Math.random()*(YMAX-YMIN) + YMIN;
        rmax = Math.random()*(largestRaySize - smallestRaySize) + smallestRaySize;
        numRays = Math.round(Math.random()*(10-6) + 6);
        ratio = Math.random()*(.9 - .3) + .3;
        if(numRays % 2 == 1) numRays++;
        rotn = Math.random()*360;
        flakeCenter = new TNTPoint(h,k);
        myFlake =new TNTSpetal(flakeCenter, rmax, numRays, white, lightGrayStroke, ratio, rotn);
        myFlake.drawTNTSpetal(context);
    }//end loop
}//end drawFlakes