Skip to content

JuliaJSXGraph/JSXGraphRecipesBase.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSXGraphRecipesBase.jl

Lightweight interface package for defining JSXGraph.jl recipes.

External packages can depend on this package (instead of JSXGraph.jl itself) to define how their custom types are rendered on a JSXGraph board via the @jsxrecipe macro.

Installation

using Pkg
Pkg.add("JSXGraphRecipesBase")

Quick Start

using JSXGraphRecipesBase

struct Triangle
    A::Tuple{Float64, Float64}
    B::Tuple{Float64, Float64}
    C::Tuple{Float64, Float64}
end

@jsxrecipe function f(t::Triangle; color="blue")
    p1 = ElementSpec(:point, t.A[1], t.A[2]; name="A")
    p2 = ElementSpec(:point, t.B[1], t.B[2]; name="B")
    p3 = ElementSpec(:point, t.C[1], t.C[2]; name="C")
    [p1, p2, p3, ElementSpec(:polygon, p1, p2, p3; strokeColor=color)]
end

Then in a script or notebook using JSXGraph.jl:

using JSXGraph

b = board("recipe-demo", xlim=(-5, 5), ylim=(-5, 5))
tri = Triangle((0.0, 0.0), (3.0, 0.0), (1.5, 2.5))
plot!(b, tri; color="red")

Exports

  • ElementSpec — specification for a single JSXGraph element
  • @jsxrecipe — macro to define a recipe for a custom type
  • apply_recipe — apply the registered recipe for an object
  • has_recipe — check whether a recipe exists for a type

License

MIT

About

Lightweight interface package for defining JSXGraph.jl recipes

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages