Question about Javis.jl

There is a pull request to make the live viewer work in Jupyter:

I’m not sure whether there is an even easier way to simply play the gif in Jupyter. Maybe one can a markdown cell which simply shows the gif? I haven’t used Jupyter for a long time.

1 Like

As a test I modified the program to appear the orbits of the Earth, moon and sun as in scratch simulation in the link: on Scratch (mit.edu). Do you have any tips on how I can improve it?

using Javis

function ground(args...)
    background("white") # canvas background
    sethue("black") # pen color
end

function object(p=O, color="black")
    sethue(color)
    circle(p, 25, :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

myvideo = Video(500, 500)

path_of_red = Point[]
path_of_blue = Point[]

Background(1:70, ground)
yellow_ball = Object(1:70, (args...)->object(O, "yellow"), Point(0,0))
red_ball = Object(1:70, (args...)->object(O, "red"), Point(200,0))
act!(red_ball, Action(anim_rotate_around(2π, O)))
blue_ball = Object(1:70, (args...)->object(O, "blue"), Point(150,30))
act!(blue_ball, Action(anim_rotate_around(24π, red_ball)))
Object(1:70, (args...)->path!(path_of_red, pos(red_ball), "red"))
Object(1:70, (args...)->path!(path_of_blue, pos(blue_ball), "blue"))

render(myvideo; pathname="tutorial_1.gif")

```

I switched 1:70 to 1:200 and the result was much better. I also modified myvideo = Video(700, 700)

7 Likes

Hey @adeil - this is wonderful and congrats on the animation! Alongside @Wikunia, I am the other co-creator of Javis. It’s amazing that you are using this for your students and it’d be great to hear more about what you are working on.

We have an active user community located on the Julia Zulip that you can join here once you make a Zulip account: https://julialang.zulipchat.com/#narrow/stream/253420-javis There, you could ask additional questions about Javis if you have them or ask additional questions. Take care and all the best - we hope that Javis provides a useful tool for you and your students! ~tcp

1 Like

Hi, @TheCedarPrince! Be happy that you liked the changes. Before the pandemic COVID-19, I already taught Python classes to my students, but since July I have been planning my classes for 2021 with Julia in mind. I was looking for a package to replace VPython and I liked Javis.jl. Thanks for the recommendation from the community. I already logged in.

Looks good. I would probably slow it down even further and maybe use a black background to represent space. :smiley:

1 Like
using Javis

function ground(args...)
    background("black") # canvas background
    sethue("black") # pen color
end

function object(p=O, color="black")
    sethue(color)
    circle(p, 25, :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

myvideo = Video(700, 700)

path_of_red = Point[]
path_of_blue = Point[]

Background(1:500, ground)
yellow_ball = Object(1:500, (args...)->object(O, "yellow"), Point(0,0))
red_ball = Object(1:500, (args...)->object(O, "red"), Point(200,0))
act!(red_ball, Action(anim_rotate_around(2π, O)))
blue_ball = Object(1:500, (args...)->object(O, "blue"), Point(150,30))
act!(blue_ball, Action(anim_rotate_around(24π, red_ball)))
Object(1:500, (args...)->path!(path_of_red, pos(red_ball), "red"))
Object(1:500, (args...)->path!(path_of_blue, pos(blue_ball), "blue"))

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

6 Likes

It was just a test, but I ended up liking the result. I changed the colors of the astros to finish the animation. Thank you to all of you who have contributed. @cormullion @Wikunia @TheCedarPrince

7 Likes

Earth is flat? And so is moon and sun? I knew it is true! :+1: :wink:

3 Likes

And they have all the same size :slight_smile:

2 Likes

@oheil and @Wikunia, learning from you. Thanks!

7 Likes