Munching squares: Difference between revisions
Content added Content deleted
(→{{header|Julia}}: update) |
|||
Line 728: | Line 728: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
<lang julia>using Gtk, |
<lang julia>using Gtk, Cairo |
||
function munchingsquares(ctx, w, h) |
|||
extent = min(max(w, h), 256) |
|||
colors = cmap("R1", N=extent) |
|||
⚫ | |||
rectangle(ctx, i, j, i + 2, j + 2) |
|||
c = colors[((UInt(i) ^ UInt(j)) % extent) + 1] |
|||
set_source_rgb(ctx, red(c), blue(c), green(c)) |
|||
⚫ | |||
⚫ | |||
end |
|||
const can = @GtkCanvas() |
const can = @GtkCanvas() |
||
const win = GtkWindow(can, "Munching Squares", |
const win = GtkWindow(can, "Munching Squares", 512, 512) |
||
@guarded draw(can) do widget |
@guarded draw(can) do widget |
||
ctx = getgc(can) |
ctx = getgc(can) |
||
⚫ | |||
h = height(can) |
|||
set_source_rgb(ctx, abs(255 - x - y) / 255, ((255 - x) ⊻ y) / 255, (x ⊻ (255 - y)) / 255) |
|||
w = width(can) |
|||
circle(ctx, 2x, 2y, 2) |
|||
⚫ | |||
⚫ | |||
end |
end |
||
show(can) |
show(can) |
||
const cond = Condition() |
const cond = Condition() |