Giter VIP home page Giter VIP logo

feynmanjs's Introduction

#Feynman

Cross-browser Javascript library for drawing Feynman diagrams using SVG and HTML5, based on feynMF [1].

alt tag

See more examples

Disclaimer

The library is by no means ready yet to be used in "production". Check out jQuery.feyn [2] for a reliable HTML5 solution.

Usage

Dependencies

  • SVG.js - for now, see roadmap

Latex (feynMF) flavour example

HTML:

<div id="annihilation"></div>
...
<script src="../path/to/svg.min.js"></script>
<script src="../path/to/svg.foreign.js"></script>
<script src="../path/to/feynman.min.js"></script>

JavaScript:

var feynman = new Feynman();

var annihilation = {
  title      : 'Electron-Positron Annihilation',
  width      : 400,
  height     : 400,
  showAxes   : true,
  lang       : 'latex',
  diagram    : [
    'fmfleft{i1,o1}',
    'fmfright{i2,o2}',
    'fmf{electron}{i1,v1,o1}',
    'fmf{quark}{i2,v2,o2}',
    'fmf{photon}{v1,v2}',
    'fmfdot{v1,v2}'
  ]
};

feynman.draw("annihilation", annihilation);

More examples.

Features

Auto-layout

The library is based on feynMF [1] and it implements most of its features including the auto-layout system. Given a simple instruction set and description of participants in a system the engine will attempt to lay out the diagram as nicely as possible without any manual intervention. Currently there is no option to position elements by hand but it is top priority.

Parsers

The library allows easy implementation of different parser engines through a unified stage class. At the moment only the feynMF language is supported.

Labels

Experimental. The current label positioning function is dodgy, there is too many variables to calculate with and MathJax is unreliable. However it places labels good enough so that they can be fine tuned by hand using the labelx and labely attributes (see examples).

Roadmap

  • Add more line types e.g.: dashed, dotted
  • Add more vertex types, i.e.: blobs
  • Implement API to allow after-draw handling of elements (i.e.: fine tuning position of vertices, propagators etc.)
  • Remove svg.js dependency
  • Add support for non MathJax labels (i.e.: unicode labels)
  • Add option to turn off auto-layout and allow users to position elements through configuration
  • Animations: for educational purposes, to help easier understanding of particle behaviour

Development

Contributing

To submit a fix or an enhancement fork the repository, checkout the 'development' branch, add your name to the Contributors section in README.md, and send a pull request!

Building

Install dependencies first:

npm install

Then run build task:

grunt

Generated files can be found in the dist folder.

Running unit tests

To run test suite from command line type:

grunt test

Alternatively you can run it in the browser at /spec. There is also a grunt task with live reload:

grunt watch:test

References

[1] http://photino.github.io/jquery-feyn/index.html [2] http://www.pd.infn.it/TeX/doc/latex/feynmf/manual.pdf


This software is licensed under the MIT License.

Contributors

feynmanjs's People

Contributors

morcmarc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

msknathan silky 7dir

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.