mouse-indicator.js

total 0
used 0
limit 0
/* --- title: Widget: Mouse Indicator tags: widget files: head point mouse stage fps ../point_src/smooth-number.js --- A "widget" presents the values in a small `div` indicator, connected to the widget through a standard (Vue) reactive integration: Add a widget: addWidget('example', { fields: { x: { value: 0 } , y: { value: 0 } } }) Update the widget with values: updateWidgetValues('diff', { x: 10 , y: -20 }) Raw example of updating the values within the widget: appShared.widgetsApp.widgets.example.fields.x = 100 Therefore to create a basic mouse widget: let widgetFields = appShared.widgetsApp.widgets.example.fields let pos = this.mouse.position widgetFields.x.value = ~~pos.x widgetFields.y.value = ~~pos.y This is identical to the `updateWidgetValues` call */ class MainStage extends Stage { canvas = 'playspace' mounted(){ console.log('in') addWidget('mouse', { showTitle: true , fields: { x: { value: 0/*, postfix: 'px' */} , y: { value: 0/*, postfix: 'px' */} , speed: { value: 0/*, postfix: 'px' */} } }) this.mouse.zIndex = 'bound' this.speedNumber = new SmoothNumber() this.speedNumber.modulusRate = 5 setTimeout(this.resize.bind(this), 20) } step() { let mouse = this.mouse let pos = mouse.position this.speedNumber.push(mouse.speed()) updateWidgetValues('mouse',{ 'x': ~~pos.x , 'y': ~~pos.y , 'speed': Math.sqrt(this.speedNumber).toFixed(0) // , 'speed': Math.sqrt(mouse.modulatedSpeed()).toFixed(0) // , 'speed': mouse.speed() }) } stepRaw() { let widget = getWidget('mouse') // let widget = appShared.widgetsApp?.widgets?.mouse.fields if(!widget){ return } let widgetFields = widget.fields let pos = this.mouse.position widgetFields.x.value = ~~pos.x widgetFields.y.value = ~~pos.y } step2() { let pos = this.mouse.position updateWidgetValue('mouse', 'x', ~~pos.x) updateWidgetValue('mouse', 'y', ~~pos.y) } draw(ctx){ this.step() this.clear(ctx) this.fps.drawFPS(ctx) this.center.pen.indicator(ctx, { color: 'gray', width: 1}) this.mouse.point.pen.indicator(ctx, { color: 'gray', width: 1}) // this.mouse.position.pen.indicator(ctx, { color: 'gray', width: 1}) } } stage = MainStage.go()
Run
Meta Data
title Widget: Mouse Indicator
imports ()
files ('head', 'point', 'mouse', 'stage', 'fps', '../point_src/smooth-number.js')
unused_keys ()
unknown_keys ('tags',)
tags ['widget']
filepath_exists True
path mouse-indicator.js
filepath mouse-indicator.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/events.js', '../point_src/automouse.js', '../point_src/stage-resize.js', '../point_src/functions/resolve.js', '../point_src/stage.js', '../point_src/stage-clock.js', '../point_src/text/alpha.js', '../point_src/smooth-number.js', '../point_src/text/fps.js')
markdown {'html': '<p>A "widget" presents the values in a small <code>div</code> indicator, connected to the\nwidget through a standard (Vue) reactive integration:</p>\n<p>Add a widget:</p>\n<pre><code>addWidget(\'example\', {\n fields: {\n x: { value: 0 }\n , y: { value: 0 }\n }\n})\n</code></pre>\n<p>Update the widget with values:</p>\n<pre><code>updateWidgetValues(\'diff\', {\n x: 10\n , y: -20\n})\n</code></pre>\n<p>Raw example of updating the values within the widget:</p>\n<pre><code>appShared.widgetsApp.widgets.example.fields.x = 100\n</code></pre>\n<p>Therefore to create a basic mouse widget:</p>\n<pre><code>let widgetFields = appShared.widgetsApp.widgets.example.fields\n\nlet pos = this.mouse.position\nwidgetFields.x.value = ~~pos.x\nwidgetFields.y.value = ~~pos.y\n</code></pre>\n<p>This is identical to the <code>updateWidgetValues</code> call</p>', 'content': '---\ntitle: Widget: Mouse Indicator\ntags: widget\nfiles:\n head\n point\n mouse\n stage\n fps\n ../point_src/smooth-number.js\n---\n\nA "widget" presents the values in a small `div` indicator, connected to the\nwidget through a standard (Vue) reactive integration:\n\nAdd a widget:\n\n addWidget(\'example\', {\n fields: {\n x: { value: 0 }\n , y: { value: 0 }\n }\n })\n\nUpdate the widget with values:\n\n updateWidgetValues(\'diff\', {\n x: 10\n , y: -20\n })\n\n\nRaw example of updating the values within the widget:\n\n appShared.widgetsApp.widgets.example.fields.x = 100\n\nTherefore to create a basic mouse widget:\n\n let widgetFields = appShared.widgetsApp.widgets.example.fields\n\n let pos = this.mouse.position\n widgetFields.x.value = ~~pos.x\n widgetFields.y.value = ~~pos.y\n\nThis is identical to the `updateWidgetValues` call'}