-
Notifications
You must be signed in to change notification settings - Fork 3
/
rocky animation
628 lines (595 loc) · 16 KB
/
rocky animation
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
HTML-
<div class="sky column">
<div class="stars row">
<div class="rick column">
<div class="rick-hair"></div>
<div class="rick-head column">
<div class="eyebrow"></div>
<div class="eyes row">
<div class="eye--right"></div>
<div class="nose"></div>
<div class="eye--left"></div>
</div>
<div class="mouth"></div>
</div>
<div class="rick-body row">
<div class="arm arm--right">
<div class="rayGun"></div>
</div>
<div class="torso">
<div class="labCoat row">
<div class="labCoat-side labCoat--right"></div>
<div class="labCoat-opening"></div>
<div class="labCoat-side labCoat--left"></div>
</div>
</div>
<div class="arm arm--left"></div>
</div>
<div class="rick-belt row"></div>
<div class="rick-legs row">
<div class="rickLeg--right column">
<div class="sock"></div>
<div class="shoe"></div>
</div>
<div class="rickLeg--left column">
<div class="sock"></div>
<div class="shoe"></div>
</div>
</div>
</div>
</div>
<div class="ground"></div>
</div>
-------------------------------------------------
css-
$floor: #3a0943;
$floor--accent: #8f29a8;
$space: #100037;
$border-color: #666;
// RICK
$rick--width: 7rem;
$rick-head--height: 30vh;
$rick-eye--size: $rick-head--height / 2.5;
$rick-eye--pupilSize: $rick-eye--size * .5;
$rick-body--height: 10vh;
$rick-leg--height: 10vh;
// clothes
$rick-belt--height: 1rem;
$rick--coat--length: $rick-body--height * 1.5;
$collar--height: $rick-body--height * .3;
$collar--width: $rick-body--height * .1;
// Colors
$rick--skin: #decdbd;
$rick--hair: #b1daee;
$rick--coat: #f5f5f5;
$rick--shirt: #aae6e2;
$rick--belt: #352909;
$rick--pants: #7d6234;
$rayGun--green: #7fff50;
@mixin outline($fade:.1rem, $color: #000) {
box-shadow: 0 0 $fade $color; }
@mixin border() {
border: solid .2rem $border-color;}
.row { display: flex; }
.column {
display: flex;
flex-flow: column; }
.rick {
justify-content: flex-end;
align-items: center;
position: relative;
&-hair {
position: absolute;
bottom: $rick-leg--height + $rick-body--height;
z-index: 1;
background: $rick--hair;
width: $rick-head--height * 1.1;
height: $rick-head--height * 1.2;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
&:before {
content: "";
position: absolute;
top: 0;
left: 0;
width: $rick-head--height * 1;
height: $rick-head--height * 1.15;
background: $rick--hair;
-webkit-transform: rotate(145deg);
-moz-transform: rotate(145deg);
-ms-transform: rotate(145deg);
-o-transform: rotate(145deg); }
&:after {
content: "";
position: absolute;
top: 0;
left: 0;
width: $rick-head--height * 1.1;
height: $rick-head--height * 1.1;
background: $rick--hair;
-webkit-transform: rotate(-65deg);
-moz-transform: rotate(-65deg);
-ms-transform: rotate(-65deg);
-o-transform: rotate(-65deg); }
}
&-head {
z-index: 3;
position: relative;
@include outline(.8rem);
background-color: $rick--skin;
height: $rick-head--height;
width: $rick-head--height;
border-radius: $rick-head--height / 3;
align-items: center;
&:before,
&:after { // Ears
content: "";
z-index: 0;
position: absolute;
bottom: $rick-head--height * .2;
background-color: $rick--skin;
height: $rick-head--height * .15;
width: $rick-head--height * .15;
border-radius: $rick-head--height; }
&:before { right: 90%; border-left: solid .2rem $border-color; }
&:after { left: 90%; border-right: solid .2rem $border-color; }
.eyebrow {
background-color: $rick--hair;
width: $rick-head--height / 1.3;
height: $rick-head--height / 12;
border-radius: $rick-head--height;
margin-top: $rick-head--height / 5;
animation: browMove 5s ease-in-out alternate infinite;
@include border; }
.eyes {
position: relative;
& > div:not(.nose) { // Each eye
@include border;
background-color: #FFF;
width: $rick-eye--size;
height: $rick-eye--size;
border-radius: $rick-head--height;
position: relative;
display: flex;
justify-content: center;
align-items: center;
&:before { // Pupil
content: "*";
animation: lookAround 5s ease-in-out alternate infinite;
position: absolute;
top: 20%;
left: 35%;
font-size: $rick-eye--pupilSize;
height: 4rem;
line-height: 6rem;
text-align: center;
font-weight: bold; }
&:after { // Bag under eyes
content: "";
position: absolute;
top: 100%;
height: $rick-eye--size / 12;
width: $rick-eye--size / 2;
border-bottom: solid .2rem $border-color;
border-radius: 50% }
}
}
.nose {
position: absolute;
bottom: 0;
right: $rick-eye--size * .9;
transform: rotate(-20deg);
width: $rick-head--height * .1;
height: $rick-head--height * .3;
border-bottom: solid .3rem $border-color;
border-radius: 60%;
margin: $rick-head--height * -.05 0
}
.mouth {
position: relative;
border-top: solid .5rem darken($border-color,10);
width: $rick-head--height / 2;
height: $rick-head--height / 9;
border-radius: 40%;
margin-top: $rick-head--height / 9;
&:before,
&:after { // cheek wrinkles
content: "";
position: absolute;
display: block;
height: $rick-head--height / 15;
width: $rick-head--height / 15;
border-radius: 50%; }
&:before {
right: 90%;
border-left: solid .2rem $border-color }
&:after {
left: 90%;
border-right: solid .2rem $border-color }
}
}
&-body {
z-index: 2;
overflow: visible;
height: $rick-body--height;
.arm {
@include border;
position: relative;
border-top: none;
width: $rick--width / 6;
height: $rick-body--height * 1.3;
margin-top: $rick-body--height * -.1;
background-color: $rick--coat;
&:after { // Hand
content: "";
@include border;
background-color: $rick--skin;
height: 1rem;
left: -.3rem;
right: -.3rem;
position: absolute;
top: 98%;
border-radius: 1rem; }
.rayGun {
@include border;
position: absolute;
top: 100%;
right: 100%;
width: 1rem;
height: 4rem;
background-color: #CCC;
border-top-left-radius: 1rem;
border-top-right-radius: .1rem;
&:before {
content: '';
z-index: 5;
width: .5rem;
height: .8rem;
background-color: #000;
@include border;
position: absolute;
top: -.5rem;
right: 70%;
transform: rotate(45deg);
}
&:after {
content: '';
@include border;
z-index: 5;
width: 2rem;
height: 1.2rem;
position: absolute;
top: 40%;
right: 100%;
border-top-left-radius: 1rem;
border-bottom-left-radius: 1rem;
background-image:
radial-gradient(
circle closest-side,
lighten($rayGun--green, 35),
rgba($rayGun--green, .7)
);
animation: pulse .5s alternate infinite ease;
}
}
&.arm--right {
transform-origin: top;
animation: aimAround 5s ease-in-out alternate infinite;
}
}
.torso {
@include outline(.4rem);
background-color: $rick--shirt;
height: $rick-body--height;
width: $rick--width;
position: relative;
.labCoat {
position: absolute;
top: 0;
left: 0;
right: 0;
&-side {
@include outline(1rem);
z-index: 10;
width: $rick--width * .3; // coat side widths
background-color: $rick--coat;
height: $rick--coat--length;
position: relative;
&:before { // collar
content: '';
position: absolute;
background-color: lighten($rick--coat, 50);
width: $collar--width;
height: $collar--height;
}
&.labCoat--right {
border-bottom-right-radius: 100%;
&:before {
border-bottom-left-radius: 100%;
border-left: .2rem solid $border-color;
right: 0; }
}
&.labCoat--left {
border-bottom-left-radius: 100%;
&:before {
border-bottom-right-radius: 100%;
border-right: .2rem solid $border-color;
left: 0; }
}
}
&-opening {
// coat opening, showin undershirt
background-color: $rick--shirt;
flex-grow: 1;
height: $rick-body--height * 1;
}
}
}
}
&-belt {
z-index: 1;
background-color: $rick--belt;
height: $rick-belt--height;
width: $rick--width;
justify-content: center;
&:before {
content: "";
background-color: gold;
height: $rick-belt--height;
width: $rick-belt--height; }
}
&-legs {
z-index: 1;
height: $rick-leg--height;
width: $rick--width;
justify-content: space-between;
border-top: solid $rick-leg--height / 8 $rick--pants;
position: relative;
&:after { // coat tail behind him
content: '';
position: absolute;
top: 0;
right: $rick--width * .3;
left: $rick--width * .3;
height: $rick-body--height * .265;
background-color: darken($rick--coat,30);
box-shadow: inset 0 .5rem 1.2rem rgba(0,0,0,.8);
}
& > div {
background-color: $rick--pants;
height: $rick-leg--height;
width: $rick--width * .3;
justify-content: flex-end;
margin-top: -.1rem;
.sock {
background-color: #FFF;
height: 1rem;
width: 100%;
box-shadow: inset 0 0 1rem rgba(0,0,0,.6) }
.shoe {
margin-top: -.5rem;
background-color: #444;
height: 1rem;
width: $rick--width / 1.8;
padding: .5rem;
border-top-right-radius: 70%;
border-bottom: solid .2rem tan;
}
}
}
.rickLeg--right .shoe {
transform: rotateX(0deg) rotateY(180deg);
transform-origin: $rick--width * .15;
}
}
.stars {
min-height: 80vh;
background-color: $space;
justify-content: center;
align-items: flex-end;
padding-bottom: 3rem; // bump Rick up, pull stars down to offset ground roundness
margin-bottom: -3rem; }
.ground {
background-color: $floor;
min-height: calc(20vh + 3rem);
z-index: 1000;
position: relative;
border-top: solid .2rem $floor--accent;
border-top-right-radius: 50%;
border-top-left-radius: 50%;
margin: 0 -50vw;
&:before {
content: '';
position: absolute;
display: block;
width: 10vw;
top: 2rem;
left: 1rem;
height: .3rem;
border-radius: 1rem;
background-color: rgba(255,255,255,0);
$numberOflines: 20; // How many lines on the ground
$axisLength--X: 100; // How many vw the star grid goes on the X Axis
$axisLength--Y: 20; // How many vh the star grid goes on the Y Axis
$opacity: random(5) * .1; // Randomize the opacity
$adjustedAccentColor: rgba($floor--accent, $opacity);
$boxShadow: 20rem 1rem 0 $adjustedAccentColor;
@for $n from 1 through $numberOflines {
$boxShadow: #{$boxShadow} #{","} #{random($axisLength--X)}vw #{random($axisLength--Y)}vh 0 0 $adjustedAccentColor;
}
box-shadow: #{$boxShadow};
}
}
// Star stuff
$solarSystemSpeedThroughUniverse: 100s;
$numberOfStars: 100; // How many stars you want
$axisLength--X: 200; // How many rems the star grid goes on the X Axis
$axisLength--Y: 100; // How many rems the star grid goes on the Y Axis
$starColor: #8eea3d; // color of the stars
$base--size: 3.5rem;
.stars {
z-index: 0;
&:before {
position: absolute;
width: $base--size;
height: $base--size;
content: '';
border-radius: $base--size / 2; }
&:before { // stars
$boxShadow: 70rem 40rem .08rem -0.02rem $starColor; // I just set up one initial star, then concatinate to it on the loop
// Loop through and create stars, we devide by two because we create two per loop. One on the -x axis, on on +x;
@for $n from 1 through $numberOfStars / 2 {
// Set variables for the star when we hit each loop
$scale: random(3) * -.05; // Randomize the scale
$blur: random(1) / 50;
$opacity: random(8) * .1; // Randomize the opacity
$adjustedStarColor: rgba($starColor, $opacity);
// Here, we define two stars in each loop.. one for the -x margin (left of sun) and one for the right side (positive x)
// box-shadow: X-axis Y-axis Blur size (-0.01 -- -0.09) ,
$boxShadow: #{$boxShadow} #{","} -#{random($axisLength--X)}rem #{random($axisLength--Y)}rem #{$blur}rem #{$scale}rem $adjustedStarColor , #{random($axisLength--X)}rem #{random($axisLength--Y)}rem #{$blur}rem #{$scale}rem $adjustedStarColor ;
$boxShadow: #{$boxShadow} #{","} -#{random($axisLength--X)}rem -#{random($axisLength--Y)}rem #{$blur}rem #{$scale}rem $adjustedStarColor , #{random($axisLength--X)}rem -#{random($axisLength--Y)}rem #{$blur}rem #{$scale}rem $adjustedStarColor ;
}
box-shadow: #{$boxShadow};
// Call animation to spin stars
-webkit-animation: spin $solarSystemSpeedThroughUniverse linear infinite;
-moz-animation: spin $solarSystemSpeedThroughUniverse linear infinite;
-ms-animation: spin $solarSystemSpeedThroughUniverse linear infinite;
animation: spin $solarSystemSpeedThroughUniverse linear infinite;
} // before (stars)
}
// CSS ANIMATIONS
@keyframes lookAround {
0% {
top: 20%;
left: 35%;
}
10% {
top: 20%;
left: 35%;
}
13% {
top: 20%;
left: 70%;
}
30% {
top: 20%;
left: 65%;
}
33% {
top: 20%;
left: 15%;
}
50% {
top: 20%;
left: 15%;
}
53% {
top: 10%;
left: 15%;
}
80% {
top: 5%;
left: 35%;
}
90% {
top: 7%;
left: 35%;
}
92% {
top: 20%;
left: 35%;
}
100% {
top: 20%;
left: 35%;
}
}
@keyframes browMove {
0% {
transform: rotate(0deg);
}
10% {
transform: rotate(0deg);
}
13% {
transform: rotate(-2deg);
}
30% {
transform: rotate(0deg);
}
33% {
transform: rotate(0deg) rotate(2deg);
}
50% {
transform: rotate(0deg);
}
53% {
transform: rotate(0deg);
}
80% {
transform: rotate(0deg) translateY(-15%);
}
90% {
transform: rotate(0deg);
}
92% {
transform: rotate(0deg);
}
100% {
transform: rotate(0deg);
}
}
@keyframes aimAround {
0% {
transform: rotate(0deg);
}
10% {
transform: rotate(0deg);
}
13% {
transform: rotate(-4deg);
}
30% {
transform: rotate(0deg);
}
33% {
transform: rotate(0deg) rotate(95deg);
}
45% {
transform: rotate(0deg) rotate(100deg);
}
50% {
transform: rotate(0deg);
}
53% {
transform: rotate(0deg);
}
80% {
transform: rotate(0deg);
}
90% {
transform: rotate(0deg);
}
92% {
transform: rotate(0deg);
}
100% {
transform: rotate(0deg);
}
}
@-webkit-keyframes spin {
from { transform: rotate(0); }
to { transform: rotate(360deg); }
}
@keyframes spin {
from { transform: rotate(0); }
to { transform: rotate(360deg); }
}
@keyframes pulse {
from { opacity: .6 }
to { opacity: 1 }
}
html { font-size: 62.5%; font-family: helvetica, arial, sans-serif }
body { margin: 0; overflow: hidden; }