Skip to content

Instantly share code, notes, and snippets.

@Sov-trotter
Last active Jun 12, 2021
Embed
What would you like to do?
test_layers.jl
using Revise, Javis, Animations, Colors
function ground(args...)
background("white")
sethue("black")
end
function ground2(args...)
background("orange")
sethue("blue")
end
video = Video(600, 600)
Background(1:70, ground)
function object(p = O, color = "black")
sethue(color)
circle(p, 5, :fill)
return p
end
function path!(points, pos, color)
sethue(color)
push!(points, pos) # add pos to points
circle.(points, 2, :fill) # draws a circle for each point using broadcasting
end
function connector(p1, p2, color)
sethue(color)
line(p1, p2, :stroke)
end
path_of_red = Point[]
path_of_blue = Point[]
function ground1(args...)
background("black")
sethue("white")
end
l1 = @Javis.Layer 20:60 300 300 Point(10, 100) begin
# Background(1:40, ground1)
red_ball = Object(1:40, (args...) -> object(O, "red"), Point(50, 0))
act!(red_ball, Action(anim_rotate_around(2π, O)))
blue_ball = Object(1:40, (args...) -> object(O, "blue"), Point(100, 40))
act!(blue_ball, Action(anim_rotate_around(2π, 0.0, red_ball)))
connect =
Object(1:40, (args...) -> connector(pos(red_ball), pos(blue_ball), "black"))
path_ofRed = Object(1:40, (args...) -> path!(path_of_red, pos(red_ball), "red"))
path_ofBlue =
Object(1:40, (args...) -> path!(path_of_blue, pos(blue_ball), "blue"))
end
act!(l1, Action(10:35, disappear(:fade)))
Javis.show_layer_frame(61:70, 36:40, l1)
Javis.show_layer_frame(61:69, 36, l1)
function ground2(args...)
background("orange")
sethue("blue")
end
l4 = Javis.@Layer 5:20 200 200 Point(-50, 50) begin
Background(1:14, ground2)
rball = Object(1:14, (args...) -> object(O, "black"), Point(50, 0))
act!(rball, Action(anim_translate(Point(100,-100))))
end
render(video, pathname = "layer_test.gif")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment