-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchapter7.html
More file actions
181 lines (172 loc) Β· 7.11 KB
/
chapter7.html
File metadata and controls
181 lines (172 loc) Β· 7.11 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chapter 7: HTML Graphics</title>
<link rel="stylesheet" href="style.css">
<style>
.tag-section { margin-bottom: 30px; }
.tag-demo { padding: 10px; background: #f9f9f9; border-radius: 8px; display: flex; flex-wrap: wrap; gap: 15px; }
.head-demo { display: flex; flex-wrap: wrap; gap: 15px; justify-content: flex-start; align-items: flex-start; }
.head-demo .item { text-align: center; flex: 1 1 30%; max-width: 30%; margin: 5px 0; }
.head-demo svg, .head-demo canvas { border: 1px solid #ccc; display: block; margin: 0 auto 5px; }
h3 { margin-bottom: 10px; }
.caption { font-size: 0.85rem; color: #333; }
</style>
</head>
<body>
<h2 class="chapter-header" id="heading">Chapter 7: HTML GRAPHICS</h2>
<!-- SVG Graphics Section -->
<div class="tag-section">
<h3>.1 SVG Graphics</h3>
<div class="tag-demo">
<div class="head-demo">
<div class="item">
<svg width="100" height="100"><rect x="10" y="10" width="80" height="60" stroke="red" stroke-width="2" fill="yellow"/></svg>
<div class="caption">Rectangle</div>
</div>
<div class="item">
<svg width="100" height="100"><rect x="10" y="10" width="80" height="60" rx="8" ry="8" stroke="red" stroke-width="2" fill="yellow"/></svg>
<div class="caption">Rounded Rectangle</div>
</div>
<div class="item">
<svg width="100" height="100"><circle cx="50" cy="50" r="40" stroke="red" stroke-width="2" fill="yellow"/></svg>
<div class="caption">Circle</div>
</div>
<div class="item">
<svg width="100" height="100"><ellipse cx="50" cy="50" rx="40" ry="20" fill="yellow" stroke="red" stroke-width="2"/></svg>
<div class="caption">Ellipse</div>
</div>
<div class="item">
<svg width="100" height="100"><line x1="0" y1="0" x2="100" y2="50" stroke="red" stroke-width="2"/></svg>
<div class="caption">Line</div>
</div>
<div class="item">
<svg width="100" height="100"><polyline points="50,0 100,50 50,100 0,50" fill="none" stroke="red" stroke-width="2"/></svg>
<div class="caption">Polyline</div>
</div>
<div class="item">
<svg width="100" height="100"><polygon points="50,0 100,50 50,100 0,50" fill="white" stroke="red" stroke-width="2"/></svg>
<div class="caption">Polygon</div>
</div>
<div class="item">
<svg height="100" width="100"><path d="M50 0 L25 80 l50 0 Z" fill="none" stroke="red" stroke-width="2"/></svg>
<div class="caption">Path</div>
</div>
<div class="item">
<svg height="100" width="200"><text x="0" y="20" fill="red">Line of text</text></svg>
<div class="caption">Text</div>
</div>
<div class="item">
<svg height="100" width="200">
<defs>
<filter id="my-filter"><feGaussianBlur in="SourceGraphic" stdDeviation="5"/></filter>
</defs>
<rect x="0" y="0" width="200" height="100" fill="green" filter="url(#my-filter)"/>
</svg>
<div class="caption">Filter (Blur)</div>
</div>
<div class="item">
<svg height="100" width="200">
<defs>
<linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" stop-color="yellow" />
<stop offset="50%" stop-color="green" />
<stop offset="100%" stop-color="red" />
</linearGradient>
</defs>
<rect x="0" y="0" width="200" height="100" fill="url(#grad1)"/>
</svg>
<div class="caption">Linear Gradient</div>
</div>
<div class="item">
<svg height="100" width="200">
<defs>
<radialGradient id="radgrad" cx="50%" cy="50%" r="50%" fx="30%" fy="30%">
<stop offset="0%" stop-color="yellow"/>
<stop offset="50%" stop-color="green"/>
<stop offset="100%" stop-color="red"/>
</radialGradient>
</defs>
<rect x="0" y="0" width="200" height="100" fill="url(#radgrad)"/>
</svg>
<div class="caption">Radial Gradient</div>
</div>
</div>
</div>
</div>
<!-- Canvas Section -->
<div class="tag-section">
<h3>.2 Canvas</h3>
<div class="tag-demo">
<div class="head-demo">
<div class="item">
<canvas id="canvas-text" width="200" height="100"></canvas>
<div class="caption">Text</div>
</div>
<div class="item">
<canvas id="canvas-line" width="200" height="100"></canvas>
<div class="caption">Line</div>
</div>
<div class="item">
<canvas id="canvas-circle" width="200" height="100"></canvas>
<div class="caption">Circle</div>
</div>
<div class="item">
<canvas id="canvas-rect" width="200" height="100"></canvas>
<div class="caption">Rectangle</div>
</div>
<div class="item">
<canvas id="canvas-lin-grad" width="200" height="100"></canvas>
<div class="caption">Linear Gradient</div>
</div>
<div class="item">
<canvas id="canvas-rad-grad" width="200" height="100"></canvas>
<div class="caption">Radial Gradient</div>
</div>
</div>
</div>
</div>
<script>
// Canvas Text
var c = document.getElementById("canvas-text");
var ctx = c.getContext("2d");
ctx.font = "20px Arial";
ctx.fillText("Neo D. Truman", 10, 50);
// Canvas Line
c = document.getElementById("canvas-line");
ctx = c.getContext("2d");
ctx.moveTo(0, 0);
ctx.lineTo(200, 100);
ctx.stroke();
// Canvas Circle
c = document.getElementById("canvas-circle");
ctx = c.getContext("2d");
ctx.beginPath();
ctx.arc(95, 50, 40, 0, 2 * Math.PI);
ctx.stroke();
// Canvas Rectangle
c = document.getElementById("canvas-rect");
ctx = c.getContext("2d");
ctx.rect(20, 20, 160, 60);
ctx.stroke();
// Canvas Linear Gradient
c = document.getElementById("canvas-lin-grad");
ctx = c.getContext("2d");
var grd = ctx.createLinearGradient(0, 0, 200, 0);
grd.addColorStop(0, "red");
grd.addColorStop(1, "yellow");
ctx.fillStyle = grd;
ctx.fillRect(20, 20, 160, 60);
// Canvas Radial Gradient
c = document.getElementById("canvas-rad-grad");
ctx = c.getContext("2d");
grd = ctx.createRadialGradient(60, 60, 10, 95, 50, 70);
grd.addColorStop(0, "red");
grd.addColorStop(1, "yellow");
ctx.fillStyle = grd;
ctx.fillRect(0, 0, 200, 100);
</script>
</body>
</html>