mirror of
https://github.com/openstf/stf
synced 2025-10-06 03:50:04 +02:00
Add Canvas Render.
This commit is contained in:
parent
168590a1b7
commit
aa28801e87
4 changed files with 51 additions and 0 deletions
16
res/app/components/stf/screen/image-render/canvas/index.js
Normal file
16
res/app/components/stf/screen/image-render/canvas/index.js
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
function CanvasRender(options, canvasElement) {
|
||||||
|
this.options = options
|
||||||
|
this.context = canvasElement.getContext('2d')
|
||||||
|
}
|
||||||
|
|
||||||
|
CanvasRender.prototype.draw = function (image) {
|
||||||
|
this.context.drawImage(image, 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
CanvasRender.prototype.clear = function () {
|
||||||
|
var width = 300
|
||||||
|
var height = 300
|
||||||
|
ctx.clearRect(0, 0, width, height)
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = CanvasRender
|
18
res/app/components/stf/screen/image-render/index.js
Normal file
18
res/app/components/stf/screen/image-render/index.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
var canvasRender = require('./canvas')
|
||||||
|
var webGLRender = require('./webgl')
|
||||||
|
var canvasElement;
|
||||||
|
|
||||||
|
function ImageRender(options) {
|
||||||
|
this.options = options
|
||||||
|
this.render = new canvasRender();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageRender.prototype.draw = function (image) {
|
||||||
|
this.render.draw(image)
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageRender.prototype.clear = function () {
|
||||||
|
this.render.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = ImageRender
|
15
res/app/components/stf/screen/image-render/webgl/index.js
Normal file
15
res/app/components/stf/screen/image-render/webgl/index.js
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
// Based on http://jsperf.com/canvas-drawimage-vs-webgl-drawarrays
|
||||||
|
|
||||||
|
function WebGLRender(options) {
|
||||||
|
this.options = options
|
||||||
|
}
|
||||||
|
|
||||||
|
WebGLRender.prototype.draw = function (image) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
WebGLRender.prototype.clear = function () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = WebGLRender
|
|
@ -1,3 +1,5 @@
|
||||||
|
var imageRender = require('./image-render')
|
||||||
|
|
||||||
module.exports = function DeviceScreenDirective($document, ScalingService, $rootScope) {
|
module.exports = function DeviceScreenDirective($document, ScalingService, $rootScope) {
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue