Skip to content

Commit

Permalink
Deploy to GitHub pages [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
maptalks-doc-robot committed Nov 3, 2023
1 parent 0b6cf7d commit 5615311
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 102 deletions.
54 changes: 20 additions & 34 deletions cn/layer/swipe/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,9 @@

var renderer = layer.getRenderer();
var canvasGetter = renderer.getCanvasImage;

var swipeCanvas = document.createElement('canvas');

//override renderer's default method to get layer canvas image
renderer.getCanvasImage = function () {
var dpr = map.getDevicePixelRatio();
Expand All @@ -893,26 +896,16 @@
}
//drawn width after layer is erased by swipper
var ctx = renderer.context;

var width = renderer.canvas.width * (swipe.value / 100);
var height = ctx.canvas.height;

//copy drawn rect of original layer canvas
var drawnRect = document.createElement('canvas');
drawnRect.width = width;
drawnRect.height = ctx.canvas.height;
drawnRect.getContext('2d').drawImage(layerImage.image, 0, 0);

//clear the erased part
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
//draw a white background to cover the bottom layers when zooming
ctx.beginPath();
ctx.rect(0, 0, width / dpr, height / dpr);
ctx.fillStyle = '#fff';
ctx.fill();

//draw the drawn part on layer's canvas
ctx.drawImage(drawnRect, 0, 0, width / dpr, height / dpr);
layerImage.image = ctx.canvas;
var leftCtx = swipeCanvas.getContext('2d');
swipeCanvas.width = ctx.canvas.width;
swipeCanvas.height = ctx.canvas.height;
leftCtx.clearRect(0, 0, swipeCanvas.width, swipeCanvas.height);
leftCtx.drawImage(layerImage.image, 0, 0, width, height, 0, 0, width, height);
layerImage.image = swipeCanvas;
return layerImage;
};

Expand Down Expand Up @@ -965,6 +958,9 @@

var renderer = layer.getRenderer();
var canvasGetter = renderer.getCanvasImage;

var swipeCanvas = document.createElement('canvas');

//override renderer's default method to get layer canvas image
renderer.getCanvasImage = function() {
var dpr = map.getDevicePixelRatio();
Expand All @@ -975,26 +971,16 @@
}
//drawn width after layer is erased by swipper
var ctx = renderer.context;

var width = renderer.canvas.width * (swipe.value / 100);
var height = ctx.canvas.height;

//copy drawn rect of original layer canvas
var drawnRect = document.createElement('canvas');
drawnRect.width = width;
drawnRect.height = ctx.canvas.height;
drawnRect.getContext('2d').drawImage(layerImage.image, 0, 0);

//clear the erased part
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
//draw a white background to cover the bottom layers when zooming
ctx.beginPath();
ctx.rect(0, 0, width / dpr, height / dpr);
ctx.fillStyle = '#fff';
ctx.fill();

//draw the drawn part on layer's canvas
ctx.drawImage(drawnRect, 0, 0, width / dpr, height / dpr);
layerImage.image = ctx.canvas;
var leftCtx = swipeCanvas.getContext('2d');
swipeCanvas.width = ctx.canvas.width;
swipeCanvas.height = ctx.canvas.height;
leftCtx.clearRect(0, 0, swipeCanvas.width, swipeCanvas.height);
leftCtx.drawImage(layerImage.image, 0, 0, width, height, 0, 0, width, height);
layerImage.image = swipeCanvas;
return layerImage;
};

Expand Down
27 changes: 10 additions & 17 deletions cn/layer/swipe/raw/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@

var renderer = layer.getRenderer();
var canvasGetter = renderer.getCanvasImage;

var swipeCanvas = document.createElement('canvas');

//override renderer's default method to get layer canvas image
renderer.getCanvasImage = function () {
var dpr = map.getDevicePixelRatio();
Expand All @@ -48,26 +51,16 @@
}
//drawn width after layer is erased by swipper
var ctx = renderer.context;

var width = renderer.canvas.width * (swipe.value / 100);
var height = ctx.canvas.height;

//copy drawn rect of original layer canvas
var drawnRect = document.createElement('canvas');
drawnRect.width = width;
drawnRect.height = ctx.canvas.height;
drawnRect.getContext('2d').drawImage(layerImage.image, 0, 0);

//clear the erased part
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
//draw a white background to cover the bottom layers when zooming
ctx.beginPath();
ctx.rect(0, 0, width / dpr, height / dpr);
ctx.fillStyle = '#fff';
ctx.fill();

//draw the drawn part on layer's canvas
ctx.drawImage(drawnRect, 0, 0, width / dpr, height / dpr);
layerImage.image = ctx.canvas;
var leftCtx = swipeCanvas.getContext('2d');
swipeCanvas.width = ctx.canvas.width;
swipeCanvas.height = ctx.canvas.height;
leftCtx.clearRect(0, 0, swipeCanvas.width, swipeCanvas.height);
leftCtx.drawImage(layerImage.image, 0, 0, width, height, 0, 0, width, height);
layerImage.image = swipeCanvas;
return layerImage;
};

Expand Down
54 changes: 20 additions & 34 deletions en/layer/swipe/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,9 @@

var renderer = layer.getRenderer();
var canvasGetter = renderer.getCanvasImage;

var swipeCanvas = document.createElement('canvas');

//override renderer's default method to get layer canvas image
renderer.getCanvasImage = function () {
var dpr = map.getDevicePixelRatio();
Expand All @@ -893,26 +896,16 @@
}
//drawn width after layer is erased by swipper
var ctx = renderer.context;

var width = renderer.canvas.width * (swipe.value / 100);
var height = ctx.canvas.height;

//copy drawn rect of original layer canvas
var drawnRect = document.createElement('canvas');
drawnRect.width = width;
drawnRect.height = ctx.canvas.height;
drawnRect.getContext('2d').drawImage(layerImage.image, 0, 0);

//clear the erased part
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
//draw a white background to cover the bottom layers when zooming
ctx.beginPath();
ctx.rect(0, 0, width / dpr, height / dpr);
ctx.fillStyle = '#fff';
ctx.fill();

//draw the drawn part on layer's canvas
ctx.drawImage(drawnRect, 0, 0, width / dpr, height / dpr);
layerImage.image = ctx.canvas;
var leftCtx = swipeCanvas.getContext('2d');
swipeCanvas.width = ctx.canvas.width;
swipeCanvas.height = ctx.canvas.height;
leftCtx.clearRect(0, 0, swipeCanvas.width, swipeCanvas.height);
leftCtx.drawImage(layerImage.image, 0, 0, width, height, 0, 0, width, height);
layerImage.image = swipeCanvas;
return layerImage;
};

Expand Down Expand Up @@ -965,6 +958,9 @@

var renderer = layer.getRenderer();
var canvasGetter = renderer.getCanvasImage;

var swipeCanvas = document.createElement('canvas');

//override renderer's default method to get layer canvas image
renderer.getCanvasImage = function() {
var dpr = map.getDevicePixelRatio();
Expand All @@ -975,26 +971,16 @@
}
//drawn width after layer is erased by swipper
var ctx = renderer.context;

var width = renderer.canvas.width * (swipe.value / 100);
var height = ctx.canvas.height;

//copy drawn rect of original layer canvas
var drawnRect = document.createElement('canvas');
drawnRect.width = width;
drawnRect.height = ctx.canvas.height;
drawnRect.getContext('2d').drawImage(layerImage.image, 0, 0);

//clear the erased part
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
//draw a white background to cover the bottom layers when zooming
ctx.beginPath();
ctx.rect(0, 0, width / dpr, height / dpr);
ctx.fillStyle = '#fff';
ctx.fill();

//draw the drawn part on layer's canvas
ctx.drawImage(drawnRect, 0, 0, width / dpr, height / dpr);
layerImage.image = ctx.canvas;
var leftCtx = swipeCanvas.getContext('2d');
swipeCanvas.width = ctx.canvas.width;
swipeCanvas.height = ctx.canvas.height;
leftCtx.clearRect(0, 0, swipeCanvas.width, swipeCanvas.height);
leftCtx.drawImage(layerImage.image, 0, 0, width, height, 0, 0, width, height);
layerImage.image = swipeCanvas;
return layerImage;
};

Expand Down
27 changes: 10 additions & 17 deletions en/layer/swipe/raw/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@

var renderer = layer.getRenderer();
var canvasGetter = renderer.getCanvasImage;

var swipeCanvas = document.createElement('canvas');

//override renderer's default method to get layer canvas image
renderer.getCanvasImage = function () {
var dpr = map.getDevicePixelRatio();
Expand All @@ -48,26 +51,16 @@
}
//drawn width after layer is erased by swipper
var ctx = renderer.context;

var width = renderer.canvas.width * (swipe.value / 100);
var height = ctx.canvas.height;

//copy drawn rect of original layer canvas
var drawnRect = document.createElement('canvas');
drawnRect.width = width;
drawnRect.height = ctx.canvas.height;
drawnRect.getContext('2d').drawImage(layerImage.image, 0, 0);

//clear the erased part
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
//draw a white background to cover the bottom layers when zooming
ctx.beginPath();
ctx.rect(0, 0, width / dpr, height / dpr);
ctx.fillStyle = '#fff';
ctx.fill();

//draw the drawn part on layer's canvas
ctx.drawImage(drawnRect, 0, 0, width / dpr, height / dpr);
layerImage.image = ctx.canvas;
var leftCtx = swipeCanvas.getContext('2d');
swipeCanvas.width = ctx.canvas.width;
swipeCanvas.height = ctx.canvas.height;
leftCtx.clearRect(0, 0, swipeCanvas.width, swipeCanvas.height);
leftCtx.drawImage(layerImage.image, 0, 0, width, height, 0, 0, width, height);
layerImage.image = swipeCanvas;
return layerImage;
};

Expand Down

0 comments on commit 5615311

Please sign in to comment.