UNPKG

agentscript

Version:

AgentScript Model in Model/View architecture

41 lines (36 loc) 1.2 kB
<html> <head> <title>Buttons</title> </head> <body> <script type="module"> import Animator from 'https://agentscript.org/src/Animator.js' import TwoDraw from 'https://agentscript.org/src/TwoDraw.js' import Model from 'https://agentscript.org/models/ButtonsModel.js' const model = new Model() model.setup() const view = new TwoDraw(model, { div: 'modelDiv', patchSize: 20, drawOptions: { turtlesColor: t => model.cluster.has(t) ? 'red' : 'random', turtlesShape: 'circle', turtlesSize: 2, linksColor: 'yellow', linksWidth: 3, }, }) const anim = new Animator( () => { model.step() view.draw() if (model.done) anim.stop() }, -1, // run until done 30 // at fps steps/second ) </script> <div id="modelDiv"></div> </body> </html>