在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:shashi/Patchwork.jl开源软件地址:https://github.com/shashi/Patchwork.jl开源编程语言:JavaScript 78.5%开源软件介绍:PatchworkA library for representing browser DOM in Julia. It supports element creation, diff computation and browser-side patching. SetupFrom the REPL, run Pkg.add("Patchwork") Creating ElementsThe # E.g.
using Patchwork
Elem(:h1, "Hello, World!") creates an You can attach any DOM property (e.g. # E.g.
Elem(:h1, "Hello, World!", className="welcome", style=[:color => :white, :backgroundColor => :black]) This creates a You can of course nest elements inside another Elem(:div, [
Elem(:h1, "Hello, World!"),
Elem(:p, "How are you doing today?")])
The # E.g.
div_with_class = Elem(:div, "This div's class can change") & [:className => "shiny"] The h1_and_p = Elem(:div, Elem(:h1, "Hello, World!")) << Elem(:p, "How are you doing today?") SVG graphics are DOM nodes too, and hence can be created in Patchwork. Elem(:svg, Elem(:circle, cx=250, cy=250, r=100, fill="orange"),
width=500, height=500) draws a circle. If you are using IJulia, you can use the Interact.jl's using Interact, Patchwork
@manipulate for r=1:100, cx = 1:500, cy=1:400, color=["orange", "green", "blue"]
Elem(:svg, Elem(:circle, cx=cx, cy=cy, r=r, fill=color),
width=500, height=500)
end Diff computationThe # E.g.
patch = diff(left::Elem, right::Elem) Returns a "patch". A patch is a
For example, if you have a big diff(averybigelem, averybigelem & [:className => "shiny"]) will not depend on the size and complexity of JavaScript setup and patchingPatchwork has a javascript "runtime" in <script src="/path/to/build.js"></script> This is automatically done for you if you are using Patchwork from IJulia. Patchwork defines the At a lower level, the runtime exposes the // E.g.
node = new Patchwork.Node(mountId, elemJSON) this renders the node represented by
// E.g.
node.applyPatch(patchJSON) With Compose and GadflyIf Patchwork is installed, interactive plots or Compose graphics automatically use Patchwork to efficiently render them into SVG Virtual DOM. Any updates to the plot get turned into patches, sent over to the browser and applied to the plot. Usage in IJuliaWhen you load Patchwork in IJulia, the runtime is setup automatically for you. If the result of executing a cell is an When used with Reactive (or Interact), any DevelopmentYou will need a recent To build the JS files run the following from npm install .
npm install -g browserify
npm install -g uglifyjs
make Thanks
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论