JSDM

× ssss

HTML

 
1
<div id = 'snowy'></div>
2
<canvas id = 'canv'  width="480" height="640"></canvas>
3
4

CSS

xxxxxxxxxx
34
 
1
body { 
2
  background-image:url('http://www.clipartpal.com/_thumbs/pd/holiday/christmas/Christmas_card_Santa_moon.png'); 
3
  background-size:100% 100%; 
4
  height:100vh;
5
  background-repeat: no-repeat;
6
  overflow:hidden;
7
  margin:0;
8
  width:100%;
9
}
10
canvas{
11
  position:absolute;
12
  bottom:-5em;
13
  left:20vw;
14
  z-index:1;
15
}
16
#snowy{
17
  background: none;
18
  background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/131045/snow1.png'),
19
 url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/131045/snow2.png'), 
20
 url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/131045/snow3.png');
21
  height: 100%;
22
  left: 0;
23
  position: absolute;
24
  top: 0;
25
  width: 100%;
26
  z-index:2;
27
  animation: snowy 15s linear infinite;
28
}
29
@keyframes snowy {
30
  0% {background-position: 0px 0px, 0px 0px, 0px 0px;}
31
  50% {background-position: 500px 500px, 100px 200px, -100px 150px;}
32
  100% {background-position: 500px 1000px, 200px 400px, -100px 300px;}
33
}
34
? ?
? ?
必须是有效的URL
+ 添加另一个资源

JS

xxxxxxxxxx
81
 
1
 var c = document.getElementById('canv'),
2
        $ = c.getContext('2d');
3
4
        //draw trunk
5
        $.beginPath();
6
        $.moveTo(220, 500);
7
        $.lineTo(260, 500);
8
        $.lineTo(260, 565);
9
        $.quadraticCurveTo(240, 575, 220, 565);
10
        $.closePath();
11
        $.fillStyle = 'hsl(11.2,93.8%,19%)';
12
        $.fill();
13
14
        // draw tree        
15
        $.beginPath();
16
        $.moveTo(240, 100);
17
        $.lineTo(120, 500);
18
        $.quadraticCurveTo(240, 530, 360, 500);
19
        $.closePath();
20
        var fillTree = $.createLinearGradient(240, 100, 240, 600);
21
        fillTree.addColorStop(0, 'hsla(128, 75%, 15%, 1)');
22
        fillTree.addColorStop(1, 'hsla(128, 85%, 25%, 1)');
23
        $.fillStyle = fillTree;
24
        $.fill();
25
        //$.stroke(); //outline tree - optional
26
27
        // generate ornaments
28
        var i = 0,
29
            ornamentCount = 4000
30
            ornaments = [];
31
        while (i < ornamentCount)
32
        {
33
            var x = Math.floor(Math.random()*240)+120,
34
                y = Math.floor(Math.random()*400)+120,
35
                color = '#' + ((x*10).toString(16) + (y*10).toString(16)).substr(0, 6);
36
37
            if ($.isPointInPath(x, y))
38
            {
39
                var ornament = {};
40
                ornament.x = x;
41
                ornament.y = y;
42
                ornament.color = color;
43
                ornaments[i] = ornament;
44
                i++;
45
            }
46
        }
47
48
        // clear path and draw ornaments
49
        $.lineWidth = 5;
50
        $.lineCap = 'round';
51
        for(i = 0; i<ornamentCount; i++)
52
        {
53
            var x = ornaments[i].x,
54
                y = ornaments[i].y,
55
                color = ornaments[i].color;
56
            $.beginPath();
57
            $.moveTo(x, y);
58
            $.lineTo(x, y+1);
59
            $.strokeStyle = color;
60
            $.stroke();
61
            $.closePath();
62
        }
63
64
        // draw big 'ol star on top
65
        $.beginPath();
66
        $.moveTo(240, 25);
67
        $.lineTo(254, 55);
68
        $.lineTo(289, 61);
69
        $.lineTo(265, 86);
70
        $.lineTo(270, 120);
71
        $.lineTo(240, 105);
72
        $.lineTo(210, 119);
73
        $.lineTo(215, 86);
74
        $.lineTo(191, 62);
75
        $.lineTo(225, 57);
76
        $.closePath();
77
        var fillStar = $.createRadialGradient(245, 73, 3, 235, 70, 50);
78
        fillStar.addColorStop(0, 'hsla(56, 95%, 55%, 1)');
79
        fillStar.addColorStop(1, 'hsla(49, 95%, 45%, 1)');
80
        $.fillStyle = fillStar;
81
        $.fill();
必须是有效的URL
+ 添加另一个资源
Close

文件管理 点击文件查看URL

图片

  1. 暂无文件

CSS

  1. 暂无文件

JavaScript

  1. 暂无文件

其他

  1. 暂无文件
拖动文件到上面的区域或者:
加载中 ..................