-
Notifications
You must be signed in to change notification settings - Fork 94
/
3D_Earth_rotation_animation.rb
54 lines (44 loc) · 1.01 KB
/
3D_Earth_rotation_animation.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# To run this code, make sure you have the ruby-processing gem installed (gem install ruby-processing).
require 'ruby-processing'
class EarthRotationSketch < Processing::App
def setup
size(800, 800)
background(255)
@frame = 0
@map = nil
frame_rate(60)
no_loop
end
def draw
background(255)
@map = create_map unless @map
draw_map(@frame)
@frame += 2
@frame = 0 if @frame >= 360
end
def create_map
Basemap.new(self)
end
def draw_map(frame)
@map.lon_0 = frame
@map.draw_coastlines(color: color(128))
@map.bluemarble
text('3D Earth Rotation', 10, height - 20)
end
end
class Basemap
attr_accessor :app, :lon_0
def initialize(app)
@app = app
@lon_0 = 0
end
def draw_coastlines(options = {})
app.stroke(options[:color])
app.no_fill
# draw coastlines logic goes here
end
def bluemarble
# display the Blue Marble image logic goes here
end
end
EarthRotationSketch.new(title: '3D Earth Rotation', width: 800, height: 800)