Colour pinstripe/Display: Difference between revisions
Content deleted Content added
Line 542: | Line 542: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
<lang julia> |
<lang julia>using Gtk, Graphics, Colors |
||
using Gtk, Graphics, Colors |
|||
function drawline(ctx, |
function drawline(ctx, p1, p2, color) |
||
move_to(ctx, p1.x, p1.y) |
|||
p = first(lin) |
|||
⚫ | |||
set_source(ctx, color) |
set_source(ctx, color) |
||
⚫ | |||
for i = 2:length(lin) |
|||
p = lin[i] |
|||
line_to(ctx, p.x, p.y) |
|||
end |
|||
stroke(ctx) |
stroke(ctx) |
||
end |
end |
||
const can = @GtkCanvas() |
const can = @GtkCanvas() |
||
const win = GtkWindow(can, "Colour pinstripe/Display", 500, 500) |
const win = GtkWindow(can, "Colour pinstripe/Display", 500, 500) |
||
const colors = [colorant"black", colorant"red", colorant"green", colorant"blue", |
const colors = [colorant"black", colorant"red", colorant"green", colorant"blue", |
||
colorant"magenta", colorant"cyan", colorant"yellow", colorant"white"] |
colorant"magenta", colorant"cyan", colorant"yellow", colorant"white"] |
||
Line 571: | Line 563: | ||
deltaw = 1.0 |
deltaw = 1.0 |
||
for (i, x) in enumerate(0:deltaw:w) |
for (i, x) in enumerate(0:deltaw:w) |
||
drawline(ctx, |
drawline(ctx, Point(x, 0.25*h), Point(x, 0), colors[i % numcolors + 1]) |
||
end |
end |
||
for (i, x) in enumerate(0:deltaw*2:w) |
for (i, x) in enumerate(0:deltaw*2:w) |
||
drawline(ctx, |
drawline(ctx, Point(x, 0.5*h), Point(x, 0.25*h), colors[i % numcolors + 1]) |
||
end |
end |
||
for (i, x) in enumerate(0:deltaw*3:w) |
for (i, x) in enumerate(0:deltaw*3:w) |
||
drawline(ctx, |
drawline(ctx, Point(x, 0.75*h), Point(x, 0.5*h), colors[i % numcolors + 1]) |
||
end |
end |
||
for (i, x) in enumerate(0:deltaw*4:w) |
for (i, x) in enumerate(0:deltaw*4:w) |
||
drawline(ctx, |
drawline(ctx, Point(x, h), Point(x, 0.75*h), colors[i % numcolors + 1]) |
||
end |
end |
||
end |
end |
||
function app(wn, cn) |
|||
show(cn) |
|||
if !isinteractive() |
|||
⚫ | |||
⚫ | |||
⚫ | |||
end |
|||
⚫ | |||
end |
|||
show(can) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
</lang> |
</lang> |
||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |