Javis Animation Cosmic Dance with 3 planets

I am using Javis and try to modify the cosmic dance with 3 planets, I want to ask how to make the second connection that draw different color, I set it but it only painted the last color “#f9e8b3

here is my code:

using Javis

function ground(args...)
    background("black")
    sethue("white")
end

frames = 1000

myvideo = Video(730, 730)
Background(1:frames, ground)

# Distance from the sun (in miles): Earth = 93 000 000, Venus = 67 000 000, Mars = 142 000 000
# Diameter: Earth = 12742 km, Venus = 12102 km, Mars = 6792 km
vanille = Object(1:frames, JCircle(O, 12.7, color = "pink", action = :fill), Point(200, 0))
caldraz = Object(1:frames, JCircle(O, 12.1, color = "orange", action = :fill), Point(144, 0))
lasthrim = Object(1:frames, JCircle(O, 6.7, color = "red", action = :fill), Point(305, 0))

vanille_orbit = Object(@JShape begin
    sethue(color)
    setdash(edge)
    circle(O, 200, action)
end color = "white" action = :stroke edge = "solid")

caldraz_orbit = Object(@JShape begin
    sethue(color)
    setdash(edge)
    circle(O, 144, action)
end color = "white" action = :stroke edge = "solid")

lasthrim_orbit = Object(@JShape begin
    sethue(color)
    setdash(edge)
    circle(O, 305, action)
end color = "white" action = :stroke edge = "solid")

# We need the planets to revolve according to their time periods.
# Mars completes its one revolution in 687 days
# Earth completes its one revolution in 365 days and Venus does that in 224.7 days.
# Hence, we need to multiply (224.7/365) so that the time period matches properly i.e.,
# When earth completes its full revolution, Venus has done (224.7/365) th of its revolution.
act!(vanille, Action(anim_rotate_around(12.5 * 2π * (224.7 / 365), O)))
act!(caldraz, Action(anim_rotate_around(12.5 * 2π , O)))
act!(lasthrim, Action(anim_rotate_around(12.5 * 2π * (224.7 / 687), O)))

connection1 = [] # To store the connectors
Object(@JShape begin
    sethue(color)
    push!(connection1, [p1, p2])
    map(x -> line(x[1], x[2], :stroke), connection1)
end connection1 = connection1 p1 = pos(vanille) p2 = pos(caldraz) color = "#ceeab7")

connection = [] # To store the connectors
Object(@JShape begin
    sethue(color)
    push!(connection2, [p2, p3])
    map(x -> line(x[1], x[2], :stroke), connection2)
end connection2 = connection2 p2 = pos(caldraz) p3 = pos(lasthrim) color = "#f9e8b3")

render(myvideo; pathname = "vcl_dance.gif")
2 Likes

Perhaps try named colors rather than hex strings? (Just a guess, I don’t really know much about Javis. )

1 Like

Hey @Ved_Mahajan and @arsh , I know we translated this a bit ago to using the new JShape syntax. Don’t have time at the moment but could look a bit later after work. Wanted to cc you all!

@Freya_the_Goddess , will try to see what is going on ASAP!

Hi @Freya_the_Goddess I think the problem is you are reinitializing the connection variable if you use two different ones, say connection1 and connection2 for each of the planet pair connections the colors should work correctly!

And the result looks very good :slight_smile:

3 Likes

Yes I was just thinking the same as you respond. It works now. Thanks @gpucce

1 Like