Servus Leute,
ich hoffe es geht in Ordnung das ich hier eine Javascript Frage stelle.
Ich möchte gerne das document element an einem Worker schicken.
geht das überhaupt ?
Der Grund ist ich möchte Images erstellen im Worker und ausschneiden.
hier einmal mein Code was ich bis her versucht habe:
Alles anzeigen
ich hoffe es geht in Ordnung das ich hier eine Javascript Frage stelle.
Ich möchte gerne das document element an einem Worker schicken.
geht das überhaupt ?
Der Grund ist ich möchte Images erstellen im Worker und ausschneiden.
hier einmal mein Code was ich bis her versucht habe:
Quellcode
- function Application(mainWindow) {
- this.mainWindow = mainWindow;
- this.userAvatar = null;
- this.enemyAvartar = null;
- this.io = new IOController(mainWindow);
- this.selectMenu = null;
- this.helper = Helper;
- this.workerMethods = {
- userAvatar : 0,
- enemyAvatar : 1
- };
- }
- Application.prototype.avatarClicked = function(e) {
- if (!this.userAvatar) {
- this.userAvatar = e;
- // if (this.mainWindow.Worker) {
- // var w = new this.mainWindow.Worker("js/worker/createSpriteWorker.js");
- // w.postMessage(this);
- // }
- e.setAttribute("isActiv", "true");
- e.firstElementChild.style.opacity = 0.7;
- e.firstElementChild.style.backgroundColor = "blue";
- } else if (!this.enemyAvartar) {
- this.enemyAvartar = e;
- // if (this.mainWindow.Worker) {
- // var w = new this.mainWindow.Worker("js/worker/createSpriteWorker.js");
- // w.postMessage(this);
- // }
- e.setAttribute("isActiv", "true");
- e.firstElementChild.style.opacity = 0.7;
- e.firstElementChild.style.backgroundColor = "red";
- }
- };
- Application.prototype.loadGameSceen = function(contentid) {
- if (this.userAvatar != null && this.enemyAvartar != null) {
- this.selectMenu = this.mainWindow.document.getElementById(contentid);
- this.selectMenu.style.opacity = 1;
- this.removeElementWithAnimation(this.selectMenu);
- } else {
- alert("bitte wählen sie ihren spiler aus");
- }
- };
- Application.prototype.removeElementWithAnimation = function(element) {
- var app = this;
- setTimeout(function() {
- if (element.style.opacity != 0.0) {
- element.style.opacity = (element.style.opacity - 0.1);
- app.removeElementWithAnimation(element);
- } else if (element.style.opacity == 0) {
- element.remove();
- }
- }, 30);
- };