]> _ Git - fluidbook-html5.git/commitdiff
wip #6064 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 21 Jun 2023 14:08:42 +0000 (16:08 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 21 Jun 2023 14:08:42 +0000 (16:08 +0200)
js/libs/fluidbook/fluidbook.loader.js

index c80f8760bb4c1b912f6c1c7d24c04c0ef88915bc..c1cdb5d8c5803e97fb887e56e5aeda021c5716b7 100644 (file)
@@ -420,7 +420,9 @@ FluidbookLoader.prototype = {
 
     getTextsURL: function (page) {
         return 'data/contents/p' + page + '.svg';
-    }, setBackground: function (page, callback) {
+    },
+
+    setBackground: function (page, callback) {
         var $this = this;
         var back = $("#page_" + page + ' .background');
         this._loadBackground(page, function () {
@@ -428,14 +430,18 @@ FluidbookLoader.prototype = {
             $(back).append($this.backgrounds[page]);
             callback();
         });
-    }, setOnStage: function (element) {
+    },
+
+    setOnStage: function (element) {
         if (element === undefined || element == null) {
             return;
         }
         if (!isOnStage(element)) {
             $("#loadedcontents").append($(element));
         }
-    }, _loadBackground: function (page, callback) {
+    },
+
+    _loadBackground: function (page, callback) {
         if (page <= 0 || page > this.fluidbook.settings.pages) {
             callback();
             return;
@@ -452,7 +458,9 @@ FluidbookLoader.prototype = {
                 this.__loadBackground(page, callback);
             }
         }
-    }, __loadBackground: function (page, callback) {
+    },
+
+    __loadBackground: function (page, callback) {
         if (page <= 0 || page > this.fluidbook.settings.pages) {
             callback();
             return;
@@ -463,7 +471,9 @@ FluidbookLoader.prototype = {
             return false;
         }
         this.backgrounds[page] = this.loadImage(url, null, null, null, page, callback);
-    }, needSeparateTextures: function (page) {
+    },
+
+    needSeparateTextures: function (page) {
         if (this._needSeparateTextures[page] === undefined) {
             var $this = this;
             this._needSeparateTextures[page] = false;
@@ -480,7 +490,9 @@ FluidbookLoader.prototype = {
             });
         }
         return this._needSeparateTextures[page];
-    }, loadTexture: function (page, callback, enter) {
+    },
+
+    loadTexture: function (page, callback, enter) {
         if (enter === undefined) {
             enter = true;
         }
@@ -602,6 +614,19 @@ FluidbookLoader.prototype = {
                     var top = parseFloat($(this).css('top')) * hr;
                     var width = parseFloat($(this).css('width')) * wr;
                     var height = parseFloat($(this).css('height')) * hr;
+
+                    var blendmode=$(this).data('blendmode');
+
+                    if (blendmode === 'normal') {
+                        ctx.globalCompositeOperation = 'source-over';
+                    } else {
+                        try {
+                            ctx.globalCompositeOperation = blendmode;
+                        } catch (e) {
+                            ctx.globalCompositeOperation = 'source-over';
+                        }
+                    }
+
                     if ($(this).is('[data-color]')) {
                         ctx.fillStyle = $(this).attr('data-color');
                         ctx.fillRect(left, top, width, height);