In [30]:
import almond.interpreter.api._
val html = DisplayData.html("<div> Hello World </div>")
Out[30]:
import almond.interpreter.api._

html: DisplayData = DisplayData(
  Map("text/html" -> "<div> Hello World </div>"),
  Map(),
  None
)
In [31]:
display(html)
Hello World
In [32]:
import scala.concurrent._
implicit val ec = ExecutionContext.global
Out[32]:
import scala.concurrent._

ec: ExecutionContextExecutor = scala.concurrent.impl.ExecutionContextImpl@27acfb19
In [32]:
Future(diplay(html))
cmd32.sc:1: not found: value diplay
val res32 = Future(diplay(html))
                   ^Compilation Failed
Compilation Failed
In [ ]:

In [3]:
val svgText = """<svg version="1.1"
     baseProfile="full"
     width="300" height="200"
     xmlns="http://www.w3.org/2000/svg">

  <rect width="100%" height="100%" fill="red" />

  <circle cx="150" cy="100" r="80" fill="green" />

  <text x="150" y="125" font-size="60" text-anchor="middle" fill="white">SVG</text>

</svg>"""
Out[3]:
svgText: String = """<svg version="1.1"
     baseProfile="full"
     width="300" height="200"
     xmlns="http://www.w3.org/2000/svg">

  <rect width="100%" height="100%" fill="red" />

  <circle cx="150" cy="100" r="80" fill="green" />

  <text x="150" y="125" font-size="60" text-anchor="middle" fill="white">SVG</text>

</svg>"""
In [4]:
val svg = DisplayData.svg(svgText)
Out[4]:
svg: DisplayData = DisplayData(
  Map(
    "image/svg+xml" -> """<svg version="1.1"
     baseProfile="full"
     width="300" height="200"
     xmlns="http://www.w3.org/2000/svg">

  <rect width="100%" height="100%" fill="red" />

  <circle cx="150" cy="100" r="80" fill="green" />

  <text x="150" y="125" font-size="60" text-anchor="middle" fill="white">SVG</text>

</svg>"""
  ),
  Map(),
  None
)
In [5]:
display(svg)
SVG
In [6]:
val latex = DisplayData.latex("x^2 + y^2 = 1")
Out[6]:
latex: DisplayData = DisplayData(
  Map("text/latex" -> "x^2 + y^2 = 1"),
  Map(),
  None
)
In [7]:
display(latex)
x^2 + y^2 = 1
In [8]:
import $ivy.`io.github.siddhartha-gadgil::provingground-core-jvm:0.1.0`
Downloading https://repo1.maven.org/maven2/io/github/siddhartha-gadgil/provingground-core-jvm_2.12/0.1.0/provingground-core-jvm_2.12-0.1.0.pom
Downloading https://repo1.maven.org/maven2/io/github/siddhartha-gadgil/provingground-core-jvm_2.12/0.1.0/provingground-core-jvm_2.12-0.1.0.pom.sha1
Downloaded https://repo1.maven.org/maven2/io/github/siddhartha-gadgil/provingground-core-jvm_2.12/0.1.0/provingground-core-jvm_2.12-0.1.0.pom
Downloaded https://repo1.maven.org/maven2/io/github/siddhartha-gadgil/provingground-core-jvm_2.12/0.1.0/provingground-core-jvm_2.12-0.1.0.pom.sha1
Downloading https://repo1.maven.org/maven2/io/github/siddhartha-gadgil/provingground-core-jvm_2.12/0.1.0/
Downloaded https://repo1.maven.org/maven2/io/github/siddhartha-gadgil/provingground-core-jvm_2.12/0.1.0/
Downloading https://repo1.maven.org/maven2/io/github/siddhartha-gadgil/provingground-core-jvm_2.12/0.1.0/provingground-core-jvm_2.12-0.1.0.jar
Downloading https://repo1.maven.org/maven2/io/github/siddhartha-gadgil/provingground-core-jvm_2.12/0.1.0/provingground-core-jvm_2.12-0.1.0.jar.sha1
Downloaded https://repo1.maven.org/maven2/io/github/siddhartha-gadgil/provingground-core-jvm_2.12/0.1.0/provingground-core-jvm_2.12-0.1.0.jar.sha1
https://repo1.maven.org/maven2/io/github/siddhartha-gadgil/provingground-core… 

https://repo1.maven.org/maven2/io/github/siddhartha-gadgil/pro… (4.69 %, 261582…

Downloaded https://repo1.maven.org/maven2/io/github/siddhartha-gadgil/provingground-core-jvm_2.12/0.1.0/provingground-core-jvm_2.12-0.1.0.jar
Downloading https://repo1.maven.org/maven2/io/github/siddhartha-gadgil/provingground-core-jvm_2.12/0.1.0/provingground-core-jvm_2.12-0.1.0-sources.jar.sha1
Downloading https://repo1.maven.org/maven2/io/github/siddhartha-gadgil/provingground-core-jvm_2.12/0.1.0/provingground-core-jvm_2.12-0.1.0-sources.jar
Downloaded https://repo1.maven.org/maven2/io/github/siddhartha-gadgil/provingground-core-jvm_2.12/0.1.0/provingground-core-jvm_2.12-0.1.0-sources.jar.sha1
Downloaded https://repo1.maven.org/maven2/io/github/siddhartha-gadgil/provingground-core-jvm_2.12/0.1.0/provingground-core-jvm_2.12-0.1.0-sources.jar
Out[8]:
import $ivy.$                                                          
In [9]:
import provingground._, interface._
Out[9]:
import provingground._, interface._
In [10]:
val cvs = new SvgPlot(400, 200)
val plot = cvs
Out[10]:
cvs: SvgPlot = provingground.interface.SvgPlot@60d9adde
plot: SvgPlot = provingground.interface.SvgPlot@60d9adde
In [11]:
val ax = cvs.plot(cvs.axes)
Out[11]:
ax: xml.Elem = <svg width="400" height="200"><line x1="0" y1="100" x2="400" y2="100" stroke="blue" stroke-width="2"/><line x1="200" y1="200" x2="200" y2="0" stroke="blue" stroke-width="2"/></svg>
In [12]:
display(DisplayData.html(ax.toString))
In [13]:
val svgAx = DisplayData.svg(s"""<svg version="1.1"
     baseProfile="full"
     width="300" height="200"
     xmlns="http://www.w3.org/2000/svg">$ax</svg>""")
Out[13]:
svgAx: DisplayData = DisplayData(
  Map(
    "image/svg+xml" -> """<svg version="1.1"
     baseProfile="full"
     width="300" height="200"
     xmlns="http://www.w3.org/2000/svg"><svg width="400" height="200"><line x1="0" y1="100" x2="400" y2="100" stroke="blue" stroke-width="2"/><line x1="200" y1="200" x2="200" y2="0" stroke="blue" stroke-width="2"/></svg></svg>"""
  ),
  Map(),
  None
)
In [14]:
display(svgAx)
In [15]:
plot.yval(0)
Out[15]:
res14: Int = 100
In [16]:
plot.axes
Out[16]:
res15: List[xml.Elem] = List(
  <line x1="0" y1="100" x2="400" y2="100" stroke="blue" stroke-width="2"/>,
  <line x1="200" y1="200" x2="200" y2="0" stroke="blue" stroke-width="2"/>
)
In [17]:
import cvs._
Out[17]:
import cvs._
In [18]:
axes
Out[18]:
res17: List[xml.Elem] = List(
  <line x1="0" y1="100" x2="400" y2="100" stroke="blue" stroke-width="2"/>,
  <line x1="200" y1="200" x2="200" y2="0" stroke="blue" stroke-width="2"/>
)
In [ ]:

In [19]:
val pl = polyline((0, 0), (100, 100), (200, 100))
Out[19]:
pl: xml.Elem = <polyline points="200,100 300,0 400,0"/>
In [20]:
display(DisplayData.html(plot(pl).toString))
In [21]:
val point = (1 to 100) map ((x) => (x : Double, math.max(x, 50): Double))
Out[21]:
point: collection.immutable.IndexedSeq[(Double, Double)] = Vector(
  (1.0, 50.0),
  (2.0, 50.0),
  (3.0, 50.0),
  (4.0, 50.0),
  (5.0, 50.0),
  (6.0, 50.0),
  (7.0, 50.0),
  (8.0, 50.0),
  (9.0, 50.0),
  (10.0, 50.0),
  (11.0, 50.0),
  (12.0, 50.0),
  (13.0, 50.0),
  (14.0, 50.0),
  (15.0, 50.0),
  (16.0, 50.0),
  (17.0, 50.0),
  (18.0, 50.0),
  (19.0, 50.0),
  (20.0, 50.0),
  (21.0, 50.0),
  (22.0, 50.0),
  (23.0, 50.0),
  (24.0, 50.0),
  (25.0, 50.0),
  (26.0, 50.0),
  (27.0, 50.0),
  (28.0, 50.0),
  (29.0, 50.0),
  (30.0, 50.0),
  (31.0, 50.0),
  (32.0, 50.0),
  (33.0, 50.0),
  (34.0, 50.0),
  (35.0, 50.0),
  (36.0, 50.0),
  (37.0, 50.0),
  (38.0, 50.0),
...
In [22]:
val g = graph(point)
Out[22]:
g: Seq[xml.Elem] = Vector(
  <line x1="201" y1="50" x2="202" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="202" y1="50" x2="203" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="203" y1="50" x2="204" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="204" y1="50" x2="205" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="205" y1="50" x2="206" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="206" y1="50" x2="207" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="207" y1="50" x2="208" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="208" y1="50" x2="209" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="209" y1="50" x2="210" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="210" y1="50" x2="211" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="211" y1="50" x2="212" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="212" y1="50" x2="213" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="213" y1="50" x2="214" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="214" y1="50" x2="215" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="215" y1="50" x2="216" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="216" y1="50" x2="217" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="217" y1="50" x2="218" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="218" y1="50" x2="219" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="219" y1="50" x2="220" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="220" y1="50" x2="221" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="221" y1="50" x2="222" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="222" y1="50" x2="223" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="223" y1="50" x2="224" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="224" y1="50" x2="225" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="225" y1="50" x2="226" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="226" y1="50" x2="227" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="227" y1="50" x2="228" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="228" y1="50" x2="229" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="229" y1="50" x2="230" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="230" y1="50" x2="231" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="231" y1="50" x2="232" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="232" y1="50" x2="233" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="233" y1="50" x2="234" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="234" y1="50" x2="235" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="235" y1="50" x2="236" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="236" y1="50" x2="237" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="237" y1="50" x2="238" y2="50" stroke="blue" stroke-width="2"/>,
  <line x1="238" y1="50" x2="239" y2="50" stroke="blue" stroke-width="2"/>,
...
In [23]:
val pg = plot(g)
Out[23]:
pg: xml.Elem = <svg width="400" height="200"><line x1="201" y1="50" x2="202" y2="50" stroke="blue" stroke-width="2"/><line x1="202" y1="50" x2="203" y2="50" stroke="blue" stroke-width="2"/><line x1="203" y1="50" x2="204" y2="50" stroke="blue" stroke-width="2"/><line x1="204" y1="50" x2="205" y2="50" stroke="blue" stroke-width="2"/><line x1="205" y1="50" x2="206" y2="50" stroke="blue" stroke-width="2"/><line x1="206" y1="50" x2="207" y2="50" stroke="blue" stroke-width="2"/><line x1="207" y1="50" x2="208" y2="50" stroke="blue" stroke-width="2"/><line x1="208" y1="50" x2="209" y2="50" stroke="blue" stroke-width="2"/><line x1="209" y1="50" x2="210" y2="50" stroke="blue" stroke-width="2"/><line x1="210" y1="50" x2="211" y2="50" stroke="blue" stroke-width="2"/><line x1="211" y1="50" x2="212" y2="50" stroke="blue" stroke-width="2"/><line x1="212" y1="50" x2="213" y2="50" stroke="blue" stroke-width="2"/><line x1="213" y1="50" x2="214" y2="50" stroke="blue" stroke-width="2"/><line x1="214" y1="50" x2="215" y2="50" stroke="blue" stroke-width="2"/><line x1="215" y1="50" x2="216" y2="50" stroke="blue" stroke-width="2"/><line x1="216" y1="50" x2="217" y2="50" stroke="blue" stroke-width="2"/><line x1="217" y1="50" x2="218" y2="50" stroke="blue" stroke-width="2"/><line x1="218" y1="50" x2="219" y2="50" stroke="blue" stroke-width="2"/><line x1="219" y1="50" x2="220" y2="50" stroke="blue" stroke-width="2"/><line x1="220" y1="50" x2="221" y2="50" stroke="blue" stroke-width="2"/><line x1="221" y1="50" x2="222" y2="50" stroke="blue" stroke-width="2"/><line x1="222" y1="50" x2="223" y2="50" stroke="blue" stroke-width="2"/><line x1="223" y1="50" x2="224" y2="50" stroke="blue" stroke-width="2"/><line x1="224" y1="50" x2="225" y2="50" stroke="blue" stroke-width="2"/><line x1="225" y1="50" x2="226" y2="50" stroke="blue" stroke-width="2"/><line x1="226" y1="50" x2="227" y2="50" stroke="blue" stroke-width="2"/><line x1="227" y1="50" x2="228" y2="50" stroke="blue" stroke-width="2"/><line x1="228" y1="50" x2="229" y2="50" stroke="blue" stroke-width="2"/><line x1="229" y1="50" x2="230" y2="50" stroke="blue" stroke-width="2"/><line x1="230" y1="50" x2="231" y2="50" stroke="blue" stroke-width="2"/><line x1="231" y1="50" x2="232" y2="50" stroke="blue" stroke-width="2"/><line x1="232" y1="50" x2="233" y2="50" stroke="blue" stroke-width="2"/><line x1="233" y1="50" x2="234" y2="50" stroke="blue" stroke-width="2"/><line x1="234" y1="50" x2="235" y2="50" stroke="blue" stroke-width="2"/><line x1="235" y1="50" x2="236" y2="50" stroke="blue" stroke-width="2"/><line x1="236" y1="50" x2="237" y2="50" stroke="blue" stroke-width="2"/><line x1="237" y1="50" x2="238" y2="50" stroke="blue" stroke-width="2"/><line x1="238" y1="50" x2="239" y2="50" stroke="blue" stroke-width="2"/><line x1="239" y1="50" x2="240" y2="50" stroke="blue" stroke-width="2"/><line x1="240" y1="50" x2="241" y2="50" stroke="blue" stroke-width="2"/><line x1="241" y1="50" x2="242" y2="50" stroke="blue" stroke-width="2"/><line x1="242" y1="50" x2="243" y2="50" stroke="blue" stroke-width="2"/><line x1="243" y1="50" x2="244" y2="50" stroke="blue" stroke-width...
In [24]:
val svgPg = DisplayData.svg(s"""<svg version="1.1"
     baseProfile="full"
     width="300" height="200"
     xmlns="http://www.w3.org/2000/svg">$pg</svg>""")
Out[24]:
svgPg: DisplayData = DisplayData(
  Map(
    "image/svg+xml" -> """<svg version="1.1"
     baseProfile="full"
     width="300" height="200"
     xmlns="http://www.w3.org/2000/svg"><svg width="400" height="200"><line x1="201" y1="50" x2="202" y2="50" stroke="blue" stroke-width="2"/><line x1="202" y1="50" x2="203" y2="50" stroke="blue" stroke-width="2"/><line x1="203" y1="50" x2="204" y2="50" stroke="blue" stroke-width="2"/><line x1="204" y1="50" x2="205" y2="50" stroke="blue" stroke-width="2"/><line x1="205" y1="50" x2="206" y2="50" stroke="blue" stroke-width="2"/><line x1="206" y1="50" x2="207" y2="50" stroke="blue" stroke-width="2"/><line x1="207" y1="50" x2="208" y2="50" stroke="blue" stroke-width="2"/><line x1="208" y1="50" x2="209" y2="50" stroke="blue" stroke-width="2"/><line x1="209" y1="50" x2="210" y2="50" stroke="blue" stroke-width="2"/><line x1="210" y1="50" x2="211" y2="50" stroke="blue" stroke-width="2"/><line x1="211" y1="50" x2="212" y2="50" stroke="blue" stroke-width="2"/><line x1="212" y1="50" x2="213" y2="50" stroke="blue" stroke-width="2"/><line x1="213" y1="50" x2="214" y2="50" stroke="blue" stroke-width="2"/><line x1="214" y1="50" x2="215" y2="50" stroke="blue" stroke-width="2"/><line x1="215" y1="50" x2="216" y2="50" stroke="blue" stroke-width="2"/><line x1="216" y1="50" x2="217" y2="50" stroke="blue" stroke-width="2"/><line x1="217" y1="50" x2="218" y2="50" stroke="blue" stroke-width="2"/><line x1="218" y1="50" x2="219" y2="50" stroke="blue" stroke-width="2"/><line x1="219" y1="50" x2="220" y2="50" stroke="blue" stroke-width="2"/><line x1="220" y1="50" x2="221" y2="50" stroke="blue" stroke-width="2"/><line x1="221" y1="50" x2="222" y2="50" stroke="blue" stroke-width="2"/><line x1="222" y1="50" x2="223" y2="50" stroke="blue" stroke-width="2"/><line x1="223" y1="50" x2="224" y2="50" stroke="blue" stroke-width="2"/><line x1="224" y1="50" x2="225" y2="50" stroke="blue" stroke-width="2"/><line x1="225" y1="50" x2="226" y2="50" stroke="blue" stroke-width="2"/><line x1="226" y1="50" x2="227" y2="50" stroke="blue" stroke-width="2"/><line x1="227" y1="50" x2="228" y2="50" stroke="blue" stroke-width="2"/><line x1="228" y1="50" x2="229" y2="50" stroke="blue" stroke-width="2"/><line x1="229" y1="50" x2="230" y2="50" stroke="blue" stroke-width="2"/><line x1="230" y1="50" x2="231" y2="50" stroke="blue" stroke-width="2"/><line x1="231" y1="50" x2="232" y2="50" stroke="blue" stroke-width="2"/><line x1="232" y1="50" x2="233" y2="50" stroke="blue" stroke-width="2"/><line x1="233" y1="50" x2="234" y2="50" stroke="blue" stroke-width="2"/><line x1="234" y1="50" x2="235" y2="50" stroke="blue" stroke-width="2"/><line x1="235" y1="50" x2="236" y2="50" stroke="blue" stroke-width="2"/><line x1="236" y1="50" x2="237" y2="50" stroke="blue" stroke-width="2"/><line x1="237" y1="50" x2="238" y2="50" stroke="blue" stro...
In [25]:
display(svgPg)
In [26]:
val circ = circle(0, 0, 20, "red")
Out[26]:
circ: xml.Elem = <circle cx="200" cy="100" r="20.0" stroke="red" stroke-width="2"/>
In [27]:
val pic = plot(circ :: axes)
Out[27]:
pic: xml.Elem = <svg width="400" height="200"><circle cx="200" cy="100" r="20.0" stroke="red" stroke-width="2"/><line x1="0" y1="100" x2="400" y2="100" stroke="blue" stroke-width="2"/><line x1="200" y1="200" x2="200" y2="0" stroke="blue" stroke-width="2"/></svg>
In [28]:
display(DisplayData.html(pic.toString))