]> _ Git - fluidbook-html5.git/commitdiff
wait #4777 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 13 Oct 2021 10:45:04 +0000 (12:45 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 13 Oct 2021 10:45:04 +0000 (12:45 +0200)
js/libs/fluidbook/fluidbook.loader.js

index 19a27b4b295532e28170f4827f3da80f87b36edb..54084d64147efe78b74dde4c802bd04c87581b62 100644 (file)
@@ -708,7 +708,7 @@ FluidbookLoader.prototype = {
         var z = window.devicePixelRatio * upscale;
         var mz = this.fluidbook.zoom.max * window.devicePixelRatio * upscale * 1.1;
 
-        $('canvas[data-page]').each(function () {
+        $('canvas[data-page]:not(.thick)').each(function () {
             if ($this.fluidbook.zoom.zoom === 1 && $(this).hasClass('z')) {
                 return;
             }
@@ -774,9 +774,41 @@ FluidbookLoader.prototype = {
                 ctx.drawImage(img, 0, 0, img.width - 2, img.height - 2, 0, 0, cw, ch);
             }
             $(this).data('w', cw).data('h', ch);
+
+            if (!$(this).hasClass('z') && $this.fluidbook.settings.textsThickness > 1 && $this.fluidbook.settings.textsThicknessPages.indexOf(page) >= 0) {
+                $('canvas:not(.z)[data-page=' + page + '].thick').remove();
+                var clone;
+                for (var i = 1; i <= $this.fluidbook.settings.textsThickness; i++) {
+                    clone = $this._cloneCanvas($(this).get(0));
+                    $(clone).insertBefore($(this));
+                }
+                var lastOpacity = $this.fluidbook.settings.textsThickness - Math.floor($this.fluidbook.settings.textsThickness);
+                if (lastOpacity > 0) {
+                    $(clone).css('opacity', lastOpacity);
+                }
+            }
+
         });
     },
 
+    _cloneCanvas: function (source) {
+        //create a new canvas
+        var dest = document.createElement('canvas');
+        var context = dest.getContext('2d');
+
+        //set dimensions
+        dest.width = source.width;
+        dest.height = source.height;
+
+        $(dest).addClass('thick').addClass('p').attr('data-page', $(source).attr('data-page'));
+
+        //apply the old canvas to the new one
+        context.drawImage(source, 0, 0);
+
+        //return the new canvas
+        return dest;
+    },
+
     _loadTexts: function (pageNr, callback) {
         if (pageNr <= 0 || pageNr > this.fluidbook.settings.pages) {
             callback();