| 1 |
{ Make a simple image with radial gradient (middle of the image is yellow, |
| 2 |
borders are blue). } |
| 3 |
|
| 4 |
function main() |
| 5 |
result := image(100, 100, 3); |
| 6 |
|
| 7 |
{ y = maximum distance of image pixel from the middle of the image. } |
| 8 |
y := sqrt(sqr(image_width(result)/2) + |
| 9 |
sqr(image_height(result)/2)); |
| 10 |
|
| 11 |
for (i, 0, image_width(result) - 1, |
| 12 |
for (j, 0, image_height(result) - 1, |
| 13 |
{ x = number between 0...1 corresponding to distance of (i, j) |
| 14 |
from image middle. } |
| 15 |
x := sqrt(sqr(i - image_width(result)/2) + |
| 16 |
sqr(j - image_height(result)/2)) / y; |
| 17 |
image_set_color(result, i, j, |
| 18 |
vector(1, 1, 0) * x + |
| 19 |
vector(0, 0, 1) * (1-x)))) |