offscreen-example-c.js

total 0
used 0
limit 0
/* title: Offscreen rendering. category: offscreen files: ../point_src/core/head.js ../point_src/pointpen.js ../point_src/pointdraw.js ../point_src/math.js ../point_src/extras.js ../point_src/point-content.js ../point_src/pointlist.js ../point_src/pointlistpen.js ../point_src/point.js ../point_src/stage.js ../point_src/offscreen.js mouse dragging stroke --- In this example, there is no `Stage.canvas` applied (initially). Instead an `OffscreenCanvas` canvas is created on `mount()` stage, replacing the inner `stage.ctx` with the offscreen alternative. The `draw(ctx)` context entity is the _offscreen_ canvas layer. Once everything is complete, we call `copyToOnScreen(offscreenCanvas, onScreenCanvas)` to push the content into something visible. Fundamentally the stage works in the same manner, as with a standard canvas, The only change is the final `copyToOnScreen` call. */ class MainStageOffScreenNoPrimary extends Stage { /* In this this example, we completely ignore the _setup_ canvas, opting to create an offScreen canvas after the setup. The offscreen is rendered to the onscreen using the `copyToOnScreen` */ // canvas = document.getElementById('playspace'); // canvas = 'playspace' // canvas = new OffscreenCanvas(500, 400) mounted(){ this.canvas = new OffscreenCanvas(500, 400) // this.offScreenCanvas = this.canvas.transferControlToOffscreen() this._ctx = this.canvas.getContext('2d') this.onScreenCanvas = document.getElementById("playspace")//.getContext("2d"); this.onScreenCanvas.width = 500 this.onScreenCanvas.height = 400 this.point = new Point(10, 10) } // resolveCanvas() {} // stickCanvasSize(canvas){ // const onScreenCanvas = document.getElementById("playspace")//.getContext("2d"); // onScreenCanvas.width = 300 // onScreenCanvas.height = 200 // return // } draw(ctx){ var context = ctx // this.offScreenCanvas.getContext("2d"); // this.clear(ctx) ctx.fillStyle = '#444'; //set fill color ctx.fillRect(10, 10, 40, 40); this.point.rotation += 1 this.point.pen.indicator(ctx) copyToOnScreen(this.canvas, this.onScreenCanvas) } } stage = MainStageOffScreenNoPrimary.go()//{ loop: false }) // stage = MainStageOffScreenDirect.go()//{ loop: false })
Run
Meta Data
title Offscreen rendering.
imports ()
files ('../point_src/core/head.js', '../point_src/pointpen.js', '../point_src/pointdraw.js', '../point_src/math.js', '../point_src/extras.js', '../point_src/point-content.js', '../point_src/pointlist.js', '../point_src/pointlistpen.js', '../point_src/point.js', '../point_src/stage.js', '../point_src/offscreen.js', 'mouse', 'dragging', 'stroke')
unused_keys ()
unknown_keys ('category',)
category ['offscreen']
filepath_exists True
path offscreen-example-c.js
filepath offscreen-example-c.js
clean_files ('../point_src/core/head.js', '../point_src/pointpen.js', '../point_src/pointdraw.js', '../point_src/math.js', '../point_src/extras.js', '../point_src/compass.js', '../point_src/center.js', '../point_src/point-content.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/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/offscreen.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/setunset.js', '../point_src/stroke.js')
markdown {'html': '<p>In this example, there is no <code>Stage.canvas</code> applied (initially).</p>\n<p>Instead an <code>OffscreenCanvas</code> canvas is created on <code>mount()</code> stage, replacing the\ninner <code>stage.ctx</code> with the offscreen alternative.</p>\n<p>The <code>draw(ctx)</code> context entity is the <em>offscreen</em> canvas layer. Once everything is complete,\nwe call <code>copyToOnScreen(offscreenCanvas, onScreenCanvas)</code> to push the content into\nsomething visible.</p>\n<p>Fundamentally the stage works in the same manner, as with a standard canvas,\nThe only change is the final <code>copyToOnScreen</code> call.</p>', 'content': 'title: Offscreen rendering.\ncategory: offscreen\nfiles:\n ../point_src/core/head.js\n ../point_src/pointpen.js\n ../point_src/pointdraw.js\n ../point_src/math.js\n ../point_src/extras.js\n ../point_src/point-content.js\n ../point_src/pointlist.js\n ../point_src/pointlistpen.js\n ../point_src/point.js\n ../point_src/stage.js\n ../point_src/offscreen.js\n mouse\n dragging\n stroke\n---\n\nIn this example, there is no `Stage.canvas` applied (initially).\n\nInstead an `OffscreenCanvas` canvas is created on `mount()` stage, replacing the\ninner `stage.ctx` with the offscreen alternative.\n\nThe `draw(ctx)` context entity is the _offscreen_ canvas layer. Once everything is complete,\nwe call `copyToOnScreen(offscreenCanvas, onScreenCanvas)` to push the content into\nsomething visible.\n\nFundamentally the stage works in the same manner, as with a standard canvas,\nThe only change is the final `copyToOnScreen` call.'}