// Created by Gregg Buntin private void DrawImage() { int sizeX = Convert.ToInt32(tbX.Text); // this is the X (width) of the image int sizeY = Convert.ToInt32(tbY.Text); // this is the Y (height) of the image int halfX = sizeX / 2; int halfY = sizeY / 2; calculatedImage = new Bitmap(sizeX, sizeY); Color tempColor = new Color(); double num = Convert.ToDouble(tbDec.Text); // This is where you plug in the Decimal value for (int Y = -(halfY); Y < 1; Y++) { int Y2 = Y * Y; for (int X = -(halfX); X < 1; X++) { tempColor = Color.White; double tempR = Math.Pow((Y2 + (X * X)), num); double R = (10000000 - tempR) / 2; int intR = Convert.ToInt32(R); double roundR = Math.Truncate(R); if (roundR != intR) tempColor = Color.Black; int X1 = X + halfX; int Y1 = Y + halfY; calculatedImage.SetPixel(X1, Y1, tempColor); calculatedImage.SetPixel(sizeX - 2 - X1, Y1, tempColor); calculatedImage.SetPixel(X1, sizeY - 2 - Y1, tempColor); calculatedImage.SetPixel(sizeX - 2 - X1, sizeY - 2 - Y1, tempColor); } // for X } // for Y pbImage.Image = calculatedImage; } // method DrawImage
Sunday, March 26, 2017
Calculated Image
A billion years ago I found a one liner in a magazine and it made a pretty cool image. Recently I found it again and thought it would be cool to try it on a modern computer. Below is the algorithm I came up with. Just drop a Picture Box onto a form, add an X, Y and Decimal (from .2 to .9):
Subscribe to:
Posts (Atom)