Esempio n. 1
0
        private string PatternAndTransformation(ICanvasRenderingContext2D ctx)
        {
            // create new image object to use as pattern
            IImageData img = new ImageData();
            img.src = @"wallpaper.png";

            // create pattern
            object ptrn = ctx.createPattern(img, "repeat");
            ctx.translate(50, 0);
            ctx.rotate(Math.PI*2/(6));
            ctx.fillStyle = ptrn;
            ctx.fillRect(0, 0, 150, 150);
            return @"Originals\Images\PatternAndTransformation.png";
        }
Esempio n. 2
0
        private string sample21(ICanvasRenderingContext2D ctx)
        {
            ctx.translate(75, 75);

            for (int i = 1; i < 6; i++)
            {
                // Loop through rings (from inside to out)
                ctx.save();
                ctx.fillStyle = "rgb(" + (51*i) + "," + (255 - 51*i) + ",255)";

                for (int j = 0; j < i*6; j++)
                {
                    // draw individual dots
                    ctx.rotate((float) Math.PI*2/(i*6));
                    ctx.beginPath();
                    ctx.arc(0, i*12.5F, 5, 0, Math.PI*2, true);
                    ctx.fill();
                    ctx.commit();
                }

                ctx.restore();
            }
            return @"Originals\Transformations\sample21.png";
        }
Esempio n. 3
0
 private void drawStar(ICanvasRenderingContext2D ctx, int r)
 {
     ctx.save();
     ctx.beginPath();
     ctx.moveTo(r, 0);
     for (int i = 0; i < 9; i++)
     {
         ctx.rotate(Math.PI/5);
         if (i%2 == 0)
         {
             ctx.lineTo((r/0.525731)*0.200811, 0);
         }
         else
         {
             ctx.lineTo(r, 0);
         }
     }
     ctx.closePath();
     ctx.fill();
     ctx.restore();
 }