offscreen-example-as-image.js

total 0
used 0
limit 0
/* title: Offscreen as image. category: offscreen files: head ../point_src/math.js ../point_src/extras.js ../point_src/point-content.js pointlist point stage ../point_src/image.js ../point_src/offscreen.js mouse dragging stroke --- */ class MainStageOffScreenContext extends Stage { /* In this format we Install an "offscreen canvas" as the primary rendering unit. the `copyToOnScreen` copies the offScreen canvas into the visible onscreen canvas. */ canvas = 'playspace' mounted(){ // this.canvas = new OffscreenCanvas(500, 400) // this.canvas = this.canvas.transferControlToOffscreen() this.offScreenCanvas = this.offscreen.create({width:100, height:100}) this.image = new ImageLoader; let oCtx = this.offScreenCanvas.getContext('2d') oCtx.fillStyle = '#444'; //set fill color oCtx.fillRect(10, 10, 40, 40); this.point = new Point(10,20) this.point.rotation += 10 this.point.pen.indicator(oCtx) this.updateImage() this.image.position.radius = 50 this.dragging.add(this.image.position) // this.onScreenCanvas = document.getElementById("playspace")//.getContext("2d"); } updateImage(data=this.offScreenCanvas.transferToImageBitmap()){ // if(data == undefined){ // data = this.offScreenCanvas.transferToImageBitmap() // } this.image.setImageData(data) } redrawOffscreen() { let oCtx = this.offScreenCanvas.getContext('2d') oCtx.fillStyle = '#444'; //set fill color oCtx.fillRect(10, 10, 40, 40); this.point.pen.indicator(oCtx) this.updateImage() } draw(ctx){ this.clear(ctx) // this.mouse.point.pen.indicator(ctx) this.point.rotation += 2 // this.point.pen.indicator(ctx) this.redrawOffscreen() // let data = this.offScreenCanvas.transferToImageBitmap() // this.updateImage(data) this.image.position.pen.circle(ctx, {color:'#3356FF'}) this.image.draw(ctx) } } stage = MainStageOffScreenContext.go()//{ loop: false })
Run
Meta Data
title Offscreen as image.
imports ()
files ('head', '../point_src/math.js', '../point_src/extras.js', '../point_src/point-content.js', 'pointlist', 'point', 'stage', '../point_src/image.js', '../point_src/offscreen.js', 'mouse', 'dragging', 'stroke')
unused_keys ()
unknown_keys ('category',)
category ['offscreen']
filepath_exists True
path offscreen-example-as-image.js
filepath offscreen-example-as-image.js
clean_files ('../point_src/core/head.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/pointpen.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/image.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': '', 'content': 'title: Offscreen as image.\ncategory: offscreen\nfiles:\n head\n ../point_src/math.js\n ../point_src/extras.js\n ../point_src/point-content.js\n pointlist\n point\n stage\n ../point_src/image.js\n ../point_src/offscreen.js\n mouse\n dragging\n stroke\n---'}