JSPM

  • Created
  • Published
  • Downloads 14
  • Score
    100M100P100Q70088F
  • License MIT

2D graphic library

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (holst) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Holst is 2D Graphic library

    index.html

    <html>
      <body>
        <div id="app"></div>
      </body>
    </html>

    index.ts

    import { Scene, DynamicRenderer2D, Color, Shape } from 'holst'
    
    const scene = new Scene()
    const forwardAnimation = scene.createAnimation({ duration: 1500 })
    const backwardAnimation = scene.createAnimation({ duration: 1500 })
    const layer = scene.createLayer()
    const shape = Shape.create({ fill: Color.blue })
      .circle(400, 300, 150)
      .on('click', async () => {
        await forwardAnimation.play()
        await backwardAnimation.play()
      })
      .on('hover', e => (e.cursor = 'pointer'))
      .on('leave', e => (e.cursor = 'default'))
      
    layer.add(shape)
    
    forwardAnimation.action = ({ t }) => (
      shape.style.fill = Color.fromGradient(t, [Color.blue, Color.red])
    )
    
    backwardAnimation.action = ({ t }) => (
      shape.style.fill = Color.fromGradient(t, [Color.red, Color.blue])
    )
      
    const renderer = new DynamicRenderer2D({ width: 800, hight: 600 })
    renderer.render(scene)
    
    const app = document.getElementById('app')
    app.append(renderer.element)