Peripheral drift illusion: Difference between revisions

Content added Content deleted
m (julia example)
(docs)
Line 11: Line 11:
=={{header|Julia}}==
=={{header|Julia}}==
Line color tables taken from the Wren example.
Line color tables taken from the Wren example.
<lang julia>using Gtk, Colors, Cairo
<lang juliausing Gtk, Colors, Cairo


function CodepenApp()
function CodepenApp()
# left-top, top-right, right-bottom, bottom-left
# signifies the white edges on the blue squares
LT, TR, RB, BL = 1, 2, 3, 4
LT, TR, RB, BL = 1, 2, 3, 4
edges = [
edges = [
Line 35: Line 35:
[B, W, W, B],
[B, W, W, B],
[B, B, W, W]]
[B, B, W, W]]
win = GtkWindow("Peripheral drift illusion", 230, 230) |> (can = GtkCanvas())

win = GtkWindow("Peripheral drift illusion", 230, 230)
can = GtkCanvas()
push!(win, can)
set_gtk_property!(can, :expand, true)

@guarded draw(can) do widget
@guarded draw(can) do widget
ctx = Gtk.getgc(can)
ctx = Gtk.getgc(can)
Line 52: Line 47:
rectangle(ctx, 0, 0, 250, 250)
rectangle(ctx, 0, 0, 250, 250)
fill(ctx)
fill(ctx)
set_line_width(ctx, 2)
for x in 1:12
for x in 1:12
px = 18 + x * 14
px = 18 + x * 14
Line 60: Line 56:
fill(ctx)
fill(ctx)
carray = colors[edges[y][x]]
carray = colors[edges[y][x]]
set_line_width(ctx, 2)
line(px, py, px + 9, py, carray[1])
line(px, py, px + 9, py, carray[1])
line(px + 9, py, px + 9, py + 9, carray[2])
line(px + 9, py, px + 9, py + 9, carray[2])
Line 79: Line 74:
CodepenApp()
CodepenApp()
</lang>
</lang>



=={{header|Phix}}==
=={{header|Phix}}==