zoom.js

total 0
used 0
limit 0
/* --- title: Zooming Points src_dir: ../point_src/ categories: scaling files: ../point_src/math.js ../point_src/core/head.js point pointlist mouse ../point_src/stage.js ../point_src/extras.js ../point_src/random.js stroke dragging ../point_src/zoom.js --- Zoom many points. */ class MainStage extends Stage { // canvas = document.getElementById('playspace'); canvas = 'playspace' mounted(){ let radius = 7 let count = 100 const pointList = PointList.generate.random(count, 600, {x: 300, y:100}) this.factor = 1 pointList.forEach(p=>p.radius = random.int(20)) this.points = pointList this.dis = new Distances this.dis.addPoints(...pointList) this.zoom = new Zoom(this, pointList) // this.zoom.add(...pointList) this.dragging.add(...pointList) this.dragging.onEmptyDown = this.onEmptyDown.bind(this) this.dragging.onWheelEmpty = this.onWheelEmpty.bind(this) this.events.wake() this.innerZoom = 0 } onWheelEmpty(ev) { this.innerZoom += ev.deltaY let factor = this.factor = 1 + (this.innerZoom * -.001) if(this.origin) { this.zoom.update(this.origin, factor) } } onEmptyDown(ev) { // console.log('onEmptyDown') this.isPanning = true this.origin = Point.from(ev) this.zoom.update(this.origin, this.factor) } onMousemove(ev) { if(!this.isPanning) { return } this.origin.copy(this.mouse.position) // let d = Point.from(ev).distance2D(this.origin) // console.log('Pan', d) } onMouseup(ev) { this.isPanning = false } draw(ctx){ this.clear(ctx) if(this.origin){ this.zoom.update(this.origin, this.factor) } let mousePoint = Point.mouse.position this.points.lookAt(mousePoint) /* Draw each point; wrapping the _draw_ call_ with our own functionality.*/ this.points.pen.indicators(ctx, { color: '#444', width: 1}) this.zoom.zoomPoints.pen.indicators(ctx, { color: 'gray', width: 1}) this.origin?.pen.circle(ctx, 5, 'red') // let v = this.dis.closest(mousePoint) let v = this.dis.near(mousePoint, 200) for(const p of v){ p.pen.indicator(ctx, { color: 'green', width: 3}) } // console.log(v.length) } } stage = MainStage.go()
Run
Meta Data
title Zooming Points
imports ()
files ('../point_src/math.js', '../point_src/core/head.js', 'point', 'pointlist', 'mouse', '../point_src/stage.js', '../point_src/extras.js', '../point_src/random.js', 'stroke', 'dragging', '../point_src/zoom.js')
unused_keys ()
unknown_keys ('categories', 'src_dir')
categories ['scaling']
src_dir ['../point_src/']
filepath_exists True
path zoom.js
filepath zoom.js
clean_files ('../point_src/math.js', '../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/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/stage-resize.js', '../point_src/functions/resolve.js', '../point_src/stage.js', '../point_src/extras.js', '../point_src/random.js', '../point_src/setunset.js', '../point_src/stroke.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/zoom.js')
markdown {'html': '<p>Zoom many points.</p>', 'content': '---\ntitle: Zooming Points\nsrc_dir: ../point_src/\ncategories: scaling\nfiles:\n ../point_src/math.js\n ../point_src/core/head.js\n point\n pointlist\n mouse\n ../point_src/stage.js\n ../point_src/extras.js\n ../point_src/random.js\n stroke\n dragging\n ../point_src/zoom.js\n---\n\nZoom many points.'}