Jump to content

Munching squares: Difference between revisions

Line 728:
 
=={{header|Julia}}==
<lang julia>using Gtk, Colors, PerceptualColourMapsCairo
 
function munchingsquares(ctx, w, h)
extent = min(max(w, h), 256)
colors = cmap("R1", N=extent)
for i in 1:2:w-2, j in 1:2:h-2
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))
fill(ctx)
end
end
const can = @GtkCanvas()
const win = GtkWindow(can, "Munching Squares", 720512, 360512)
 
@guarded draw(can) do widget
ctx = getgc(can)
for ix in 10:2:w-2255, jy in 1:20:h-2255
h = height(can)
set_source_rgb(ctx, abs(255 - x - y) / 255, ((255 - x) ⊻ y) / 255, (x ⊻ (255 - y)) / 255)
w = width(can)
munchingsquares circle(ctx, w2x, 2y, h2)
fill(ctx)
end
end
 
show(can)
const cond = Condition()
4,105

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.