gearbox.js

total 0
used 0
limit 0
/* title: Gears (Internal Wheel) src_dir: ../point_src/ categories: gears files: head point ../point_src/extras.js ../point_src/math.js ../point_src/point-content.js stage dragging pointlist mouse stroke ../point_src/split.js ../point_src/stage-clock.js ../point_src/touching.js ../point_src/coupling.js ../point_src/xybind.js ../point_src/gearbox.js ../point_src/json.js --- A simple example of gear-like rotations */ class MainStage extends Stage { // canvas = document.getElementById('playspace'); canvas = 'playspace' mounted(){ this.rawPointConf = { circle: { color: 'orange', width: 1}} let r = this.generate() let p = new Point(400, 400, 140) p.rachet = -1 let pin = p.copy().update({ radius: p.radius * .5 , ratchet: -1 }) // let pin2 = p.copy().update({ radius: p.radius * .3 }) this.p1 = p this.pin1 = pin this.gearBox.addGear(p) this.gearBox.addGear(pin) // this.gearBox.addGear(pin2) this.gearBox.bindPinionWheels(p, pin) this.dragging.add(p, pin) this.dragging.add(...r) this.dragging.onEmptyDown = this.onEmptyDown.bind(this) } generate(pointCount=2){ let gb = this.gearBox = new GearBox() gb.createMotor({x:100, y:300, radius: 30}) gb.createGear({x:100, y:200, radius: 100}) gb.createReductionGear({x:200, y:200, radius: 100}) gb.createReductionGear({x:300, y:200, radius: 100}) gb.createReductionGear({x:400, y:200, radius: 100}) gb.createInternalGear({x:400, y:300, radius: 60}) gb.createInternalGear({x:400, y:300, radius: 60}) return gb.points } onEmptyDown(ev) { // console.log('onEmptyDown') const p = Point.from(ev).update({ radius: 60 , angularVelocity: 1 }) this.gearBox.addGear(p) this.dragging.add(p) } draw(ctx){ this.clear(ctx) this.gearBox.performDraw(ctx) ctx.fillStyle = 'white' this.gearBox.points.forEach((p)=>{ let radtodeg = (p.angularVelocity / 360 * 60 /*fps */ // * 60 /* seconds */ ) p.text.string(ctx, radtodeg.toFixed(2)) }) let p = this.dragging.getPoint(); if(p) { p.pen.circle(ctx) } } } stage = MainStage.go();
Run
Meta Data
title Gears (Internal Wheel)
imports ()
files ('head', 'point', '../point_src/extras.js', '../point_src/math.js', '../point_src/point-content.js', 'stage', 'dragging', 'pointlist', 'mouse', 'stroke', '../point_src/split.js', '../point_src/stage-clock.js', '../point_src/touching.js', '../point_src/coupling.js', '../point_src/xybind.js', '../point_src/gearbox.js', '../point_src/json.js')
unused_keys ()
unknown_keys ('categories', 'src_dir')
categories ['gears']
src_dir ['../point_src/']
filepath_exists True
path gearbox.js
filepath gearbox.js
clean_files ('../point_src/core/head.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/extras.js', '../point_src/math.js', '../point_src/stage-resize.js', '../point_src/functions/resolve.js', '../point_src/stage.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/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/events.js', '../point_src/automouse.js', '../point_src/setunset.js', '../point_src/stroke.js', '../point_src/split.js', '../point_src/stage-clock.js', '../point_src/touching.js', '../point_src/coupling.js', '../point_src/xybind.js', '../point_src/gearbox.js', '../point_src/json.js')
markdown {'html': '<p>A simple example of gear-like rotations</p>', 'content': 'title: Gears (Internal Wheel)\nsrc_dir: ../point_src/\ncategories: gears\nfiles:\n head\n point\n ../point_src/extras.js\n ../point_src/math.js\n ../point_src/point-content.js\n stage\n dragging\n pointlist\n mouse\n stroke\n ../point_src/split.js\n ../point_src/stage-clock.js\n ../point_src/touching.js\n ../point_src/coupling.js\n ../point_src/xybind.js\n ../point_src/gearbox.js\n ../point_src/json.js\n---\n\nA simple example of gear-like rotations'}