I thought that Drawing() set the canvas size, how would I change it form default (also notice that the top MWE works and is the same size canvas and squares).
I’m not familiar with global scope however, could you go into more on this?
using Luxor
let
@svg begin
tiling = Tiler(600, 600, 8, 8)
sethue("black")
for (pos, n) in tiling
if isodd(tiling.currentrow + tiling.currentcol)
box(pos, tiling.tilewidth, tiling.tileheight, :fillstroke)
else
box(pos, tiling.tilewidth, tiling.tileheight, :stroke)
end
end
end 600 600 "/tmp/chessboard.svg"
end
It works I get the if then statement. What if I want to combine components as functions?
function build_body()
@svg begin
sethue("Purple")
ellipse(2,1,200,50,:fill)
sethue("Black")
ellipse(1,1,200,50,:stroke)
sethue("Purple")
ellipse(40,-6,130,66,:fill)
sethue("black")
ellipse(40,-6,130,66,:stroke)
sethue("blue")
ellipse(18,-23,60,26,:fill)
sethue("purple")
rect(-100,1,205,26,:fill)
sethue("black")
rect(-99,1,205,26,:stroke)
end
end
function build_wheel(x,y)
@svg begin
sethue("black")
circle(x,y,28,:fill)
sethue("grey")
circle(x,y,18,:fill)
end
end
function build_car()
build_body()
build_wheel(5,15)
build_wheel(100,15)
end
build_car()
using Luxor
function build_body()
sethue("Purple")
ellipse(2,1,200,50,:fill)
sethue("Black")
ellipse(1,1,200,50,:stroke)
sethue("Purple")
ellipse(40,-6,130,66,:fill)
sethue("black")
ellipse(40,-6,130,66,:stroke)
sethue("blue")
ellipse(18,-23,60,26,:fill)
sethue("purple")
rect(-100,1,205,26,:fill)
sethue("black")
rect(-99,1,205,26,:stroke)
end
function build_wheel(x,y)
sethue("black")
circle(x,y,28,:fill)
sethue("grey")
circle(x,y,18,:fill)
end
function build_car()
build_body()
build_wheel(5,15)
build_wheel(100,15)
end
@svg begin
build_car()
end 500 500 "/tmp/car.svg"
sure, I did intend to move the front wheels further forward. I’m not sure if luxor.jl allows creating an object that follows the cursor, but I thought I saw something like that in the GMT.jl documentatation.
Interesting, I was working on Visualisation and interactivity for Pluto, so if I could do this in HTML with the bind command, or in JavaScript, that should work too.