chore: update @idraw/borad testing

This commit is contained in:
chenshenhai 2021-08-13 23:04:18 +08:00
parent e21a637d4e
commit 4d7b5e4067
14 changed files with 220 additions and 331 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

22
__tests__/util/browser.js Normal file
View file

@ -0,0 +1,22 @@
function mouseDown(x,y){
const event = new MouseEvent('mousedown', {
screenX: x,
screenY: y,
clientX: x,
clientY: y,
});
const elem = document.elementFromPoint(x,y);
elem.dispatchEvent(event);
}
function mouseUp(x,y){
const event = new MouseEvent('mouseup', {
screenX: x,
screenY: y,
clientX: x,
clientY: y,
});
const elem = document.elementFromPoint(x,y);
elem.dispatchEvent(event);
}

View file

@ -1,59 +0,0 @@
<html>
<head>
<style></style>
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<style>
html,body { margin: 0; padding: 0; }
#mount canvas {
border-right: 1px solid #aaaaaa40;
border-bottom: 1px solid #aaaaaa40;
background-image:
linear-gradient(#aaaaaa40 1px, transparent 0),
linear-gradient(90deg, #aaaaaa40 1px, transparent 0),
linear-gradient(#aaa 1px, transparent 0),
linear-gradient(90deg, #aaa 1px, transparent 0);
background-size: 10px 10px, 10px 10px, 50px 50px, 50px 50px;
}
</style>
</head>
<body>
<div id="mount"></div>
<script src="./../../dist/index.global.js"></script>
<script>
const Board = window.iDrawBoard;
const mount = document.querySelector('#mount');
const board = new Board(mount, {
width: 600,
height: 400,
contextWidth: 600,
contextHeight: 400,
devicePixelRatio: 4
});
const ctx = board.getContext();
ctx.setFillStyle('#ffffff');
ctx.fillRect(0, 0, 600, 400);
ctx.setFillStyle('#f0f0f0');
ctx.fillRect(10, 10, 200, 120);
ctx.setFillStyle('#cccccc');
ctx.fillRect(80, 80, 200, 120);
ctx.setFillStyle('#c0c0c0');
ctx.fillRect(160, 160, 200, 120);
ctx.setFillStyle('#e0e0e0');
ctx.fillRect(400 - 10, 300 - 10, 200, 100);
board.scale(0.5);
board.scale(1);
board.draw();
</script>
</body>
</html>

View file

@ -1,63 +0,0 @@
<html>
<head>
<style></style>
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<style>
html,body { margin: 0; padding: 0; }
#mount canvas {
border-right: 1px solid #aaaaaa40;
border-bottom: 1px solid #aaaaaa40;
background-image:
linear-gradient(#aaaaaa40 1px, transparent 0),
linear-gradient(90deg, #aaaaaa40 1px, transparent 0),
linear-gradient(#aaa 1px, transparent 0),
linear-gradient(90deg, #aaa 1px, transparent 0);
background-size: 10px 10px, 10px 10px, 50px 50px, 50px 50px;
}
</style>
</head>
<body>
<div id="mount"></div>
<script src="./../../dist/index.global.js"></script>
<script>
const Board = window.iDrawBoard;
const mount = document.querySelector('#mount');
const board = new Board(mount, {
width: 600,
height: 400,
contextWidth: 600,
contextHeight: 400,
devicePixelRatio: 4
});
const ctx = board.getContext();
ctx.setFillStyle('#ffffff');
ctx.fillRect(0, 0, 600, 400);
ctx.setFillStyle('#f0f0f0');
ctx.fillRect(10, 10, 200, 120);
ctx.setFillStyle('#cccccc');
ctx.fillRect(80, 80, 200, 120);
ctx.setFillStyle('#c0c0c0');
ctx.fillRect(160, 160, 200, 120);
ctx.setFillStyle('#e0e0e0');
ctx.fillRect(400 - 10, 300 - 10, 200, 100);
ctx.setFillStyle('#000');
ctx.fillRect(300 - 10, 200 - 10, 20, 20);
board.scale(2);
board.scrollX(-300);
board.scrollY(-200);
board.draw();
</script>
</body>
</html>

View file

@ -1,64 +0,0 @@
<html>
<head>
<style></style>
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<style>
html,body { margin: 0; padding: 0; }
#mount canvas {
border-right: 1px solid #aaaaaa40;
border-bottom: 1px solid #aaaaaa40;
background-image:
linear-gradient(#aaaaaa40 1px, transparent 0),
linear-gradient(90deg, #aaaaaa40 1px, transparent 0),
linear-gradient(#aaa 1px, transparent 0),
linear-gradient(90deg, #aaa 1px, transparent 0);
background-size: 10px 10px, 10px 10px, 50px 50px, 50px 50px;
}
</style>
</head>
<body>
<div id="mount"></div>
<script src="./../../dist/index.global.js"></script>
<script>
const Board = window.iDrawBoard;
const mount = document.querySelector('#mount');
const board = new Board(mount, {
width: 600,
height: 400,
contextWidth: 600,
contextHeight: 400,
devicePixelRatio: 4
});
const ctx = board.getContext();
ctx.setFillStyle('#ffffff');
ctx.fillRect(0, 0, 600, 400);
ctx.setFillStyle('#f0f0f0');
ctx.fillRect(10, 10, 200, 120);
ctx.setFillStyle('#cccccc');
ctx.fillRect(80, 80, 200, 120);
ctx.setFillStyle('#c0c0c0');
ctx.fillRect(160, 160, 200, 120);
ctx.setFillStyle('#e0e0e0');
ctx.fillRect(400 - 10, 300 - 10, 200, 100);
ctx.setFillStyle('#000');
ctx.fillRect(300 - 10, 200 - 10, 20, 20);
board.scale(2);
board.scrollX(-300);
board.scrollY(-200);
board.scale(1);
board.draw();
</script>
</body>
</html>

View file

@ -1,62 +0,0 @@
<html>
<head>
<style></style>
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<style>
html,body { margin: 0; padding: 0; }
#mount canvas {
border-right: 1px solid #aaaaaa40;
border-bottom: 1px solid #aaaaaa40;
background-image:
linear-gradient(#aaaaaa40 1px, transparent 0),
linear-gradient(90deg, #aaaaaa40 1px, transparent 0),
linear-gradient(#aaa 1px, transparent 0),
linear-gradient(90deg, #aaa 1px, transparent 0);
background-size: 10px 10px, 10px 10px, 50px 50px, 50px 50px;
}
</style>
</head>
<body>
<div id="mount"></div>
<script src="./../../dist/index.global.js"></script>
<script>
const Board = window.iDrawBoard;
const mount = document.querySelector('#mount');
const opts = {
width: 600,
height: 400,
contextWidth: 800,
contextHeight: 600,
devicePixelRatio: 4
}
const board = new Board(mount, opts);
const ctx = board.getContext();
ctx.setFillStyle('#ffffff');
ctx.fillRect(0, 0, opts.contextWidth, opts.contextHeight);
ctx.setFillStyle('#f0f0f0');
ctx.fillRect(10, 10, 200, 120);
ctx.setFillStyle('#cccccc');
ctx.fillRect(80, 80, 200, 120);
ctx.setFillStyle('#c0c0c0');
ctx.fillRect(160, 160, 200, 120);
ctx.setFillStyle('#e0e0e0');
ctx.fillRect(400 - 10, 300 - 10, 200, 100);
ctx.setFillStyle('#000');
ctx.fillRect(400 - 10, 300 - 10, 20, 20);
board.scale(0.5);
board.draw();
</script>
</body>
</html>

View file

@ -1,78 +0,0 @@
<html>
<head>
<style></style>
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<style>
html,body { margin: 0; padding: 0; }
#mount canvas {
border-right: 1px solid #aaaaaa40;
border-bottom: 1px solid #aaaaaa40;
background-image:
linear-gradient(#aaaaaa40 1px, transparent 0),
linear-gradient(90deg, #aaaaaa40 1px, transparent 0),
linear-gradient(#aaa 1px, transparent 0),
linear-gradient(90deg, #aaa 1px, transparent 0);
background-size: 10px 10px, 10px 10px, 50px 50px, 50px 50px;
}
</style>
</head>
<body>
<div id="mount"></div>
<script src="./../../dist/index.global.js"></script>
<script>
const Board = window.iDrawBoard;
const mount = document.querySelector('#mount');
const opts = {
width: 600,
height: 400,
contextWidth: 1000,
contextHeight: 900,
devicePixelRatio: 4
}
const board = new Board(mount, opts);
const ctx = board.getContext();
ctx.setFillStyle('#ffffff');
ctx.fillRect(0, 0, opts.contextWidth, opts.contextHeight);
ctx.setFillStyle('#f0f0f0');
ctx.fillRect(10, 10, 200, 120);
ctx.setFillStyle('#cccccc');
ctx.fillRect(80, 80, 200, 120);
ctx.setFillStyle('#c0c0c0');
ctx.fillRect(160, 160, 200, 120);
ctx.setFillStyle('#e0e0e0');
ctx.fillRect(260, 260, 200, 100);
ctx.setFillStyle('#e0e0e0');
ctx.fillRect(500 - 10, 500 - 10, 200, 100);
ctx.setFillStyle('#c0c0c0');
ctx.fillRect(600, 600, 200, 100);
ctx.setFillStyle('#cccccc');
ctx.fillRect(790, 690, 200, 100);
ctx.setFillStyle('#000');
ctx.fillRect(500 - 10, 450 - 10, 20, 20);
// board.scale(1.5);
// board.scrollX(-600);
// board.scrollY(-600);
// board.scale(1);
const result = board.scale(0.5);
console.log('result =', result);
board.draw();
</script>
</body>
</html>

View file

@ -0,0 +1,197 @@
<html>
<head>
<style></style>
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<style>
html,body { margin: 0; padding: 0; }
.box canvas {
border-right: 1px solid #aaaaaa40;
border-bottom: 1px solid #aaaaaa40;
background-image:
linear-gradient(#aaaaaa40 1px, transparent 0),
linear-gradient(90deg, #aaaaaa40 1px, transparent 0),
linear-gradient(#aaa 1px, transparent 0),
linear-gradient(90deg, #aaa 1px, transparent 0);
background-size: 10px 10px, 10px 10px, 50px 50px, 50px 50px;
}
.list {
width: 910px;
overflow: hidden;
border-top: 1px solid #aaaaaa;
border-left: 1px solid #aaaaaa;
}
.box {
width: 300;
height: 200;
float: left;
border-right: 1px solid #aaaaaa;
border-bottom: 1px solid #aaaaaa;
}
</style>
</head>
<body>
<div class="list">
<div class="box" id="mount-1"></div>
<div class="box" id="mount-2"></div>
<div class="box" id="mount-3"></div>
<div class="box" id="mount-4"></div>
<div class="box" id="mount-5"></div>
</div>
<script src="./../../dist/index.global.js"></script>
<script>
function drawBoard(board) {
const ctx = board.getContext();
ctx.setFillStyle('#ffffff');
ctx.fillRect(0, 0, 300, 200);
ctx.setFillStyle('#f0f0f0');
ctx.fillRect(5, 5, 100, 60);
ctx.setFillStyle('#cccccc');
ctx.fillRect(40, 40, 100, 60);
ctx.setFillStyle('#c0c0c0');
ctx.fillRect(80, 80, 100, 60);
ctx.setFillStyle('#e0e0e0');
ctx.fillRect(200 - 5, 150 - 5, 100, 50);
ctx.setFillStyle('#000');
ctx.fillRect(150 - 5, 100 - 5, 10, 10);
}
</script>
<script>
(function () {
const Board = window.iDrawBoard;
const mount = document.querySelector('#mount-1');
const board = new Board(mount, {
width: 300,
height: 200,
contextWidth: 300,
contextHeight: 200,
devicePixelRatio: 4
});
drawBoard(board);
board.scale(0.5);
board.scale(1);
board.draw();
})();
</script>
<script>
(function() {
const Board = window.iDrawBoard;
const mount = document.querySelector('#mount-2');
const board = new Board(mount, {
width: 300,
height: 200,
contextWidth: 300,
contextHeight: 200,
devicePixelRatio: 4
});
drawBoard(board);
board.scale(2);
board.scrollX(-150);
board.scrollY(-100);
board.draw();
})()
</script>
<script>
(function() {
const Board = window.iDrawBoard;
const mount = document.querySelector('#mount-3');
const board = new Board(mount, {
width: 300,
height: 200,
contextWidth: 300,
contextHeight: 200,
devicePixelRatio: 4
});
drawBoard(board);
board.scale(2);
board.scrollX(-300);
board.scrollY(-200);
board.scale(1);
board.draw();
})()
</script>
<script>
(function() {
const Board = window.iDrawBoard;
const mount = document.querySelector('#mount-4');
const board = new Board(mount, {
width: 300,
height: 200,
contextWidth: 300,
contextHeight: 200,
devicePixelRatio: 4
});
drawBoard(board);
board.scale(0.5);
board.draw();
})()
</script>
<script>
(function() {
const Board = window.iDrawBoard;
const mount = document.querySelector('#mount-5');
const opts = {
width: 300,
height: 200,
contextWidth: 500,
contextHeight: 400,
devicePixelRatio: 4
}
const board = new Board(mount, opts);
const ctx = board.getContext();
ctx.setFillStyle('#ffffff');
ctx.fillRect(0, 0, opts.contextWidth, opts.contextHeight);
ctx.setFillStyle('#f0f0f0');
ctx.fillRect(5, 5, 100, 60);
ctx.setFillStyle('#cccccc');
ctx.fillRect(40, 40, 100, 60);
ctx.setFillStyle('#c0c0c0');
ctx.fillRect(80, 80, 100, 60);
ctx.setFillStyle('#e0e0e0');
ctx.fillRect(130, 130, 100, 50);
ctx.setFillStyle('#e0e0e0');
ctx.fillRect(250 - 5, 250 - 5, 100, 50);
ctx.setFillStyle('#c0c0c0');
ctx.fillRect(300, 300, 100, 50);
ctx.setFillStyle('#cccccc');
ctx.fillRect(380, 345, 100, 50);
ctx.setFillStyle('#000');
ctx.fillRect(250 - 5, 225 - 5, 10, 10);
const result = board.scale(0.5);
console.log('result =', result);
board.draw();
})()
</script>
</body>
</html>

View file

@ -2,11 +2,7 @@ const pageList = [
{ path: 'board/examples/test/main.html', w: 600, h: 400, delay: 500 },
{ path: 'board/examples/test/transform-small.html', w: 600, h: 400, delay: 500 },
{ path: 'board/examples/test/transform-large.html', w: 600, h: 400, delay: 500 },
{ path: 'board/examples/test/scale-001.html', w: 600, h: 400, delay: 500 },
{ path: 'board/examples/test/scale-002.html', w: 600, h: 400, delay: 500 },
{ path: 'board/examples/test/scale-003.html', w: 600, h: 400, delay: 500 },
{ path: 'board/examples/test/scale-004.html', w: 600, h: 400, delay: 500 },
{ path: 'board/examples/test/scale-005.html', w: 600, h: 400, delay: 500 },
{ path: 'board/examples/test/scale.html', w: 920, h: 420, delay: 500 },
{ path: 'board/examples/test/scroll.html', w: 700, h: 500, delay: 500 },
{ path: 'board/examples/test/reset-size.html', w: 400, h: 300, delay: 500 },
{ path: 'core/examples/test/rect.html', w: 600, h: 400, delay: 500 },