Julia set: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 203: | Line 203: | ||
=={{header|C sharp|C#}}== |
=={{header|C sharp|C#}}== |
||
{{trans|Python}} |
|||
<lang csharp>using System.Drawing; |
|||
// Note: You have to add the System.Drawing assembly |
|||
// (right-click "references," Add Reference, Assemblies, Framework, |
|||
// System.Drawing, OK) |
|||
namespace RosettaJuliaSet |
|||
{ |
|||
class Program |
|||
{ |
|||
static void Main(string[] args) |
|||
{ |
|||
const int w = 800; |
|||
const int h = 600; |
|||
const int zoom = 1; |
|||
const int maxiter = 255; |
|||
const int moveX = 0; |
|||
const int moveY = 0; |
|||
var bitmap = new Bitmap(w, h); |
|||
double cX = -0.7; |
|||
double cY = 0.27015; |
|||
double zx, zy, tmp; |
|||
int i; |
|||
for (int x = 0; x < w; x++) |
|||
{ |
|||
for (int y = 0; y < h; y++) |
|||
{ |
|||
zx = 1.5 * (x - w / 2) / (0.5 * zoom * w) + moveX; |
|||
zy = 1.0 * (y - h / 2) / (0.5 * zoom * h) + moveY; |
|||
i = maxiter; |
|||
while (zx * zx + zy * zy < 4 && i > 1) |
|||
{ |
|||
tmp = zx * zx - zy * zy + cX; |
|||
zy = 2.0 * zx * zy + cY; |
|||
zx = tmp; |
|||
i -= 1; |
|||
} |
|||
var c = Color.FromArgb((i >> 5) * 36, (i >> 3 & 7) * 36, (i & 3) * 85); |
|||
bitmap.SetPixel(x, y, c); |
|||
} |
|||
} |
|||
bitmap.Save("julia-set.png"); |
|||
} |
|||
} |
|||
} |
|||
</lang> |
|||
=={{header|COBOL}}== |
=={{header|COBOL}}== |