# Javis Animation Cosmic Dance with 3 planets

**URL:** <https://discourse.julialang.org/t/javis-animation-cosmic-dance-with-3-planets/83458>\
**Category:** General Usage\
**Created:** [June 28, 2022, 1:14pm UTC](https://discourse.julialang.org/t/javis-animation-cosmic-dance-with-3-planets/83458 "2022-06-28T13:14:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [June 28, 2022, 1:14pm UTC](https://discourse.julialang.org/t/javis-animation-cosmic-dance-with-3-planets/83458/1 "2022-06-28T13:14:55Z")

</div>

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:

```julia
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")

```

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [June 28, 2022, 1:35pm UTC](https://discourse.julialang.org/t/javis-animation-cosmic-dance-with-3-planets/83458/2 "2022-06-28T13:35:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![TheCedarPrince](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thecedarprince/32/17323_2.png) [@TheCedarPrince](https://discourse.julialang.org/u/TheCedarPrince)\
**Post date:** [June 28, 2022, 1:57pm UTC](https://discourse.julialang.org/t/javis-animation-cosmic-dance-with-3-planets/83458/3 "2022-06-28T13:57:20Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![TheCedarPrince](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thecedarprince/32/17323_2.png) [@TheCedarPrince](https://discourse.julialang.org/u/TheCedarPrince)\
**Post date:** [June 28, 2022, 1:58pm UTC](https://discourse.julialang.org/t/javis-animation-cosmic-dance-with-3-planets/83458/4 "2022-06-28T13:58:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gpucce](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gpucce/32/21995_2.png) [@gpucce](https://discourse.julialang.org/u/gpucce)\
**Post date:** [June 28, 2022, 3:15pm UTC](https://discourse.julialang.org/t/javis-animation-cosmic-dance-with-3-planets/83458/5 "2022-06-28T15:15:37Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [June 28, 2022, 3:42pm UTC](https://discourse.julialang.org/t/javis-animation-cosmic-dance-with-3-planets/83458/6 "2022-06-28T15:42:19Z")

</div>

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