1 | <!DOCTYPE html>
|
2 | <html lang="en">
|
3 |
|
4 | <head>
|
5 | <meta charset="UTF-8">
|
6 | <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 | <meta http-equiv="X-UA-Compatible" content="ie=edge">
|
8 | <title>0.5Px模糊问题</title>
|
9 | <script src="../build/image2D.js"></script>
|
10 |
|
11 | <script>
|
12 | function drawerImage(ctx) {
|
13 |
|
14 | ctx.strokeStyle = '#000';
|
15 | ctx.lineWidth = 1;
|
16 |
|
17 |
|
18 | ctx.strokeRect(10, 10, 180, 180);
|
19 |
|
20 |
|
21 | ctx.beginPath();
|
22 | ctx.moveTo(20, 20);
|
23 | ctx.lineTo(100, 160);
|
24 | ctx.lineTo(180, 20);
|
25 | ctx.stroke();
|
26 |
|
27 | }
|
28 | </script>
|
29 | </head>
|
30 |
|
31 | <body>
|
32 |
|
33 | <span>SVG绘图效果</span>
|
34 | <svg width="200" height="200">
|
35 | <rect x='10' y='10' width='180' height='180' fill='none' stroke='#000'></rect>
|
36 | <path d="M20,20L100,160L180,20" fill='none' stroke='#000'></path>
|
37 | </svg>
|
38 |
|
39 | <span>优化后方案</span>
|
40 | <canvas width="200" height="200" id="canvas1"></canvas>
|
41 | <script>
|
42 | drawerImage($$('#canvas1').painter());
|
43 | </script>
|
44 |
|
45 | <span>原始效果</span>
|
46 | <canvas width="200" height="200" id="canvas2"></canvas>
|
47 | <script>
|
48 | drawerImage($$('#canvas2')[0].getContext('2d'));
|
49 | </script>
|
50 |
|
51 | </body>
|
52 |
|
53 | </html>
|