Skip to content

Instantly share code, notes, and snippets.

@hugohadfield
Created November 16, 2018 18:10
Show Gist options
  • Select an option

  • Save hugohadfield/e20edb6feb1cec8fbcb692b378dd358a to your computer and use it in GitHub Desktop.

Select an option

Save hugohadfield/e20edb6feb1cec8fbcb692b378dd358a to your computer and use it in GitHub Desktop.
WorkingJavascriptRender.ipynb
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@enkimute
Copy link
Copy Markdown

enkimute commented Nov 16, 2018

try this one :

  • from unpkg try not to version lock ganja unless that's what you really want
  • this is untested :D
from IPython.display import Javascript
from clifford.tools.g3c import *
from clifford.tools.g3c.GAOnline import *
objects = [random_line() for i in range(10)]
input_json = str(draw_objects_ganja(objects, color=int('AA000000', 16), print_scene=False))
js = """
require.config({paths: {Algebra: 'https://unpkg.com/ganja.js'}});
require(['Algebra'],A=>element.append(A(4,1,()=>this.graph(
  JSON.parse("""+input_json+""").map(x=>x.length==32?new Element(x):x),
  {gl:1,conformal:1,grid:1,width:'50vw',height:'50vh'}
))));
"""
Javascript(js)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment