Skip to content

Instantly share code, notes, and snippets.

@AM-R
Created May 4, 2018 16:53
Show Gist options
  • Save AM-R/3666b4d3468218196f0528f2bf421963 to your computer and use it in GitHub Desktop.
Save AM-R/3666b4d3468218196f0528f2bf421963 to your computer and use it in GitHub Desktop.
url = window.location.host
sub = url.split('.')
path = window.location.pathname.split('/')
console.log(path[2])
if sub[1] == 'ada'
# and path[2] == undefined
$(".www.index").ready ->
width = 700
height = 700
speed = -1e-2
start = Date.now()
sphere = type: 'Sphere'
projection = d3.geo.orthographic().scale(width / 2.1).translate([
width / 2
height / 2
]).precision(.5)
graticule = d3.geo.graticule()
$('#planet').empty()
canvas = d3.select('div#planet').append('canvas').attr('width', width).attr('height', height)
context = canvas.node().getContext('2d')
path = d3.geo.path().projection(projection).context(context)
d3.json '<%= asset_path("planet_world.json") %>', (error, topo) ->
if error
throw error
land = topojson.feature(topo, topo.objects.land)
grid = graticule()
d3.timer ->
context.clearRect 0, 0, width, height
projection.rotate([
speed * (Date.now() - start)
-15
]).clipAngle 90
context.beginPath()
path sphere
context.lineWidth = 0
context.strokeStyle = 'transparent'
context.stroke()
context.fillStyle = 'transparent'
context.fill()
projection.clipAngle 180
context.beginPath()
path land
context.fillStyle = '#ddd'
context.fill()
context.beginPath()
path grid
context.lineWidth = .5
context.strokeStyle = 'rgba(111,111,111,0.2)'
context.stroke()
projection.clipAngle 90
context.beginPath()
path land
context.fillStyle = '#888'
context.fill()
context.lineWidth = 0
context.strokeStyle = 'transparent'
context.stroke()
return
return
d3.select(self.frameElement).style 'height', height + 'px'
else
alert('1')
$('#planet').empty()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment