This repository has been archived by the owner on Jan 22, 2024. It is now read-only.
/
subpixel.html
80 lines (68 loc) · 1.8 KB
/
subpixel.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE HTML>
<html>
<!--
Copyright 2007 The Closure Library Authors. All Rights Reserved.
Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<head>
<title>Sub pixel rendering</title>
<script type="text/javascript" src="../../base.js"></script>
<script type="text/javascript">
goog.require('goog.dom');
goog.require('goog.graphics');
</script>
<script type="text/javascript">
function testLineWidth() {
var graphics = goog.graphics.createGraphics(100, 100);
// vertical line
for (var i = 0; i < 100; i++) {
var stroke = new goog.graphics.Stroke(i / 100, 'black');
var path = graphics.createPath();
path.moveTo(49.5, i);
path.lineTo(49.5, i + 1);
path.close();
graphics.drawPath(path, stroke, null);
}
// horizontal line
for (var i = 0; i < 100; i++) {
var stroke = new goog.graphics.Stroke(i / 100, 'black');
var path = graphics.createPath();
path.moveTo(i, 49.5);
path.lineTo(i + 1, 49.5);
path.close();
graphics.drawPath(path, stroke, null);
}
graphics.render();
}
function testLinePos() {
var graphics = goog.graphics.createGraphics(100, 100);
var stroke = new goog.graphics.Stroke(1, 'black');
// vertical line
for (var i = 0; i < 100; i++) {
var path = graphics.createPath();
path.moveTo(49 + i / 100, i);
path.lineTo(49 + i / 100, i + 1);
path.close();
graphics.drawPath(path, stroke, null);
}
// horizontal line
for (var i = 0; i < 100; i++) {
var path = graphics.createPath();
path.moveTo(i, 49.5 + i / 100);
path.lineTo(i + 1, 49.5 + i / 100);
path.close();
graphics.drawPath(path, stroke, null);
}
graphics.render();
}
</script>
</head>
<body>
<script>
testLineWidth();
document.write('<br>');
testLinePos();
</script>
</body>
</html>