Chaos game: Difference between revisions
Content added Content deleted
(Replaced "bitmap" and "bresenham" with "imageman".) |
|||
Line 1,496: | Line 1,496: | ||
==={{header|Writing result into an image}}=== |
==={{header|Writing result into an image}}=== |
||
{{libheader|imageman}} |
|||
We use the module “bitmap” from the task “Bitmap”, the module “bresenham” from the task “Bitmap/Bresenham's line algorithm” and the module “ppm_write” from the task “Bitmap/Write a PPM file”. |
|||
<lang Nim> |
<lang Nim>import math |
||
⚫ | |||
import bresenham |
|||
import ppm_write |
|||
import math |
|||
import random |
import random |
||
⚫ | |||
const |
const |
||
Line 1,548: | Line 1,545: | ||
const |
const |
||
Iterations = 50_000 |
Iterations = 50_000 |
||
Black = ColorRGBU [byte 0, 0, 0] |
|||
⚫ | |||
White = ColorRGBU [byte 255, 255, 255] |
|||
⚫ | |||
# Points in image coordinates. |
# Points in image coordinates. |
||
Line 1,558: | Line 1,557: | ||
randomize() |
randomize() |
||
var image = initImage[ColorRGBU](Width, Height) |
|||
image.fill(Black) |
image.fill(Black) |
||
Line 1,575: | Line 1,574: | ||
p = ((p.x + T[idx].x) / 2, (p.y + T[idx].y) / 2) |
p = ((p.x + T[idx].x) / 2, (p.y + T[idx].y) / 2) |
||
image. |
image.savePNG("chaos_game.png")</lang> |
||
=={{header|PARI/GP}}== |
=={{header|PARI/GP}}== |