-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
232 lines (220 loc) · 7.03 KB
/
index.html
File metadata and controls
232 lines (220 loc) · 7.03 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<html>
<head>
<title>KNVS by Davsket</title>
<link href='http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:400,700|Rosario' rel='stylesheet' type='text/css'>
<style type="text/css">
html{
font-family: 'Rosario', sans-serif;
background: #f9f9f9;
background: url(http://subtlepatterns.com/patterns/cubes.png);
}
body{
color: #333;
}
h1, h2{
margin: 0;
}
h1{
font-family: 'Yanone Kaffeesatz', cursive;
font-size: 6em;
color: #222;
}
h2{
font-size: 1.2em;
margin-bottom: 10px;
color: #444;
}
header, footer, .container{
width: 800px;
margin: auto;
}
footer{
padding: 70px 0 30px;
text-align: center;
color: #666;
font-size: 0.8em;
}
code{
display: block;
}
.container{
padding-top: 20px;
}
.container canvas{
float: left;
border: 1px solid #eee;
margin-right: 20px;
background: white;
}
.container article{
overflow: hidden;
padding: 20px;
background: #ececec;
border-radius: 7px;
box-shadow: 2px 2px #e9e9e9;
margin-bottom: 20px;
}
.container div{
padding-left: 320px;
}
button{
color: white;
background: #333;
font-size: 1em;
border: 1px solid #333;
border-radius: 5px;
cursor: pointer;
padding: 5px 15px;
margin-top: 15px;
font-family: 'Rosario', sans-serif;
}
button:hover{
background: #555;
border: 1px solid #555;
}
</style>
<script type='text/javascript' src='src/knvs.js'></script>
<script type='text/javascript' src='lib/penner.js'></script>
</head>
<body>
<a href="http://github.com/monoku/knvs/"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://a248.e.akamai.net/assets.github.com/img/e6bef7a091f5f3138b8cd40bc3e114258dd68ddf/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f7265645f6161303030302e706e67" alt="Fork me on GitHub"></a>
<header>
<h1>KNVS</h1>
<p>
KNVS is a light weight javascript library for canvas animations, it takes a canvas element and creates a continuous animation board. Every element that you draw via the KNVS, is going to be redrawn in the canvas, so any change you do on the element, is gonna be reflected on the canvas.
</p>
<p>
Here you will find examples of the use of KNVS. You can fork this at: <a href='http://github.com/monoku/knvs/'>http://github.com/monoku/knvs/</a>
</p>
</header>
<article class='container'>
<article>
<canvas width='300' height='150' id='first'>
</canvas>
<div>
<h2>Creating a circle</h2>
<pre>
knvs = Knvs.create('first');
var circle = knvs.draw('circle', {left:150, top: 75,
radius: 50, color: 'rgba(218,43,58,1)'});
</pre>
<script type='text/javascript'>
var knvs = Knvs.create('first');
var circle = knvs.draw('circle', {left:150, top: 75, radius: 50, color: 'rgba(218,43,58,1)'});
</script>
</div>
</article>
<article>
<canvas width='300' height='150' id='second'>
</canvas>
<div>
<h2>Moving the circle</h2>
<pre>
knvs = Knvs.create('second');
var circle = knvs.draw('circle', {left:50, top: 75, radius: 50,
color: 'rgba(218,43,58,1)'});
circle.morph({left: 250});
</pre>
<button onclick='second();'>Run</button>
<script type='text/javascript'>
var knvs2 = Knvs.create('second');
var circle2 = knvs2.draw('circle', {left:50, top: 75, radius: 50, color: 'rgba(218,43,58,1)'});
function second(){
circle2.left = 50;
circle2.morph({left: 250});
}
</script>
</div>
</article>
<article>
<canvas width='300' height='250' id='third'>
</canvas>
<div>
<h2>Moving the circle with easing</h2>
<pre>
knvs = Knvs.create('third');
var circle = knvs.draw('circle', {left:50, top: 50,
radius: 50, color: 'rgba(218,43,58,1)'});
circle.morph({left: 250, top: 200},{transitions:
{top: bounce}, duration: 600});
</pre>
<button onclick='third();'>Run</button>
<script type='text/javascript'>
var knvs3 = Knvs.create('third');
var circle3 = knvs3.draw('circle', {left:50, top: 50, radius: 50, color: 'rgba(218,43,58,1)'});
function third(){
circle3.left = 50;
circle3.top = 50;
circle3.morph({left: 250, top: 200},{transitions:{top: bounce}, duration: 600});
}
</script>
</div>
</article>
<article>
<canvas width='300' height='250' id='fourth'>
</canvas>
<div>
<h2>Multiple stuff (colors rgba & hex)</h2>
<pre>
knvs = Knvs.create('fourth');
var circle = knvs.draw('circle', {left:50, top: 50,
radius: 50, color: 'rgba(218,43,58,1)'});
circle4.morph({left: 250, top: 200, color:
'#da2b3a'},{transitions:{top: bounce, left:
easeInOutQuad}, duration: 600});
</pre>
<button onclick='fourth();'>Run</button>
<script type='text/javascript'>
var knvs4 = Knvs.create('fourth');
var circle4 = knvs4.draw('circle', {left:50, top: 50, radius: 50, color: 'rgba(252,125,73,1)'});
function fourth(){
circle4.left = 50;
circle4.top = 50;
circle4.color = 'rgba(252,125,73,1)';
circle4.morph({left: 250, top: 200, color: '#da2b3a'},{transitions:{top: bounce, left: easeInOutQuad}, duration: 600});
}
</script>
</div>
</article>
<article>
<canvas width='300' height='250' id='fifth'>
</canvas>
<div>
<h2>Concat Morphs</h2>
<pre>
var knvs = Knvs.create('fifth');
var img = knvs.draw('image', {src:'res/img.jpg',
scalex: 0.1, scaley: 0.1, angle: 0,
angle_origin_x: 60, angle_origin_y: 60,
top: 20, left: 20});
img.morph({angle: 360, left: 250, top: 130},
{duration: 800, transitions: {left: easeOutCirc}})
.morph({angle: 360*2, left: 100, top: 50,
scalex: 0.2, scaley: 0.2}, {duration: 700,
transitions:{ top: easeInBack}})
.morph({scalex: 0.3, scaley: 0.3, left: 60,
top: 30}, {duration: 300, transitions:{
left: easeOutBounce, scaley: easeOutBounce,
scalex: easeOutBounce}});
</pre>
<button onclick='fifth();'>Run</button>
<script type='text/javascript'>
var knvs5 = Knvs.create('fifth');
var img = knvs5.draw('image', {src:'res/img.jpg', scalex: 0.1, scaley: 0.1, angle: 0, angle_origin_x: 60, angle_origin_y: 60, top: 20, left: 20});
function fifth(){
img.set({scalex: 0.1, scaley: 0.1, angle: 0, left: 20, top: 20, angle_origin_x: 292, angle_origin_y: 292});
img.morph({angle: 360, left: 250, top: 130}, {duration: 800, transitions: {left: easeOutCirc}})
.morph({angle: 360*2, left: 100, top: 50, scalex: 0.2, scaley: 0.2}, {duration: 700, transitions:{ top: easeInBack}})
.morph({scalex: 0.3, scaley: 0.3, left: 60, top: 30}, {duration: 300, transitions:{ left: easeOutBounce, scaley: easeOutBounce, scalex: easeOutBounce}});
}
</script>
</div>
</article>
</article>
<footer>
<address>
Developed by David Avellaneda - <a href='http://twitter.com/davsket'>@Davsket</a>, cofounder of <a href='http://monoku.com'>monoku</a>.
</address>
</footer>
</body>
</html>