simple-chain.js

total 0
used 0
limit 0
/* title: Simple Chain categories: chain rope constraints files: head pointlist point stage stroke mouse dragging ../point_src/random.js --- This example acts very similar to the leashing method but with more focused steps (less code.) */ class MainStage extends Stage { canvas='playspace' mounted(){ this.points = PointList.generate.random(10, [100, 200], [0,0, 5, 0]) this.points.forEach((p)=>{ p.update({vx: 0, vy:0 }) }) } updatePoints(points, target) { const distance = 20; points.forEach((point, index) => { const dx = target.x - point.x; const dy = target.y - point.y; const angle = Math.atan2(dy, dx); point.x = target.x - Math.cos(angle) * distance; point.y = target.y - Math.sin(angle) * distance; target = point; }); } draw(ctx){ this.clear(ctx) this.updatePoints(this.points, this.mouse.point) this.points.pen.indicator(ctx) } } ;stage = MainStage.go();
Run
Meta Data
title Simple Chain
imports ()
files ('head', 'pointlist', 'point', 'stage', 'stroke', 'mouse', 'dragging', '../point_src/random.js')
unused_keys ()
unknown_keys ('categories',)
categories ['chain', 'rope', 'constraints']
filepath_exists True
path simple-chain.js
filepath simple-chain.js
clean_files ('../point_src/core/head.js', '../point_src/pointlistdraw.js', '../point_src/pointlistgradient.js', '../point_src/pointlistshape.js', '../point_src/pointlistgenerator.js', '../point_src/unpack.js', '../point_src/pointlist.js', '../point_src/pointlistpen.js', '../point_src/pointpen.js', '../point_src/compass.js', '../point_src/center.js', '../point_src/point-content.js', '../point_src/pointdraw.js', '../point_src/relative-xy.js', '../point_src/pointcast.js', '../point_src/point.js', '../point_src/stage-resize.js', '../point_src/functions/resolve.js', '../point_src/stage.js', '../point_src/setunset.js', '../point_src/stroke.js', '../point_src/events.js', '../point_src/automouse.js', '../point_src/functions/clamp.js', '../point_src/distances.js', '../point_src/protractor.js', '../point_src/text/beta.js', '../point_src/dragging.js', '../point_src/random.js')
markdown {'html': '<p>This example acts very similar to the leashing method but with more focused steps (less code.)</p>', 'content': 'title: Simple Chain\ncategories: chain\n rope\n constraints\nfiles:\n head\n pointlist\n point\n stage\n stroke\n mouse\n dragging\n ../point_src/random.js\n---\n\nThis example acts very similar to the leashing method but with more focused steps (less code.)'}