圣诞树是圣诞节必不可少的装饰品之一,下面我们一步一步来教你如何画一颗漂亮的圣诞树。
一、准备工作
在开始画圣诞树之前,我们需要准备一些工具和素材。
1、绘画工具:画笔、颜料、纸张。
2、素材:圣诞树的图片或者样板。
准备完工具和素材之后,我们就可以开始画圣诞树了。
二、画圣诞树枝干
1、在纸张上画一个三角形,这是圣诞树的主干。
<canvas id="myCanvas" width="300" height="300"></canvas>
<script>
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
ctx.beginPath();
ctx.moveTo(150, 50);
ctx.lineTo(50, 250);
ctx.lineTo(250, 250);
ctx.closePath();
ctx.stroke();
</script>
2、在三角形的底部画两条平行线,表示圣诞树的树干。
<canvas id="myCanvas" width="300" height="300"></canvas>
<script>
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
ctx.beginPath();
ctx.moveTo(150, 50);
ctx.lineTo(50, 250);
ctx.lineTo(250, 250);
ctx.closePath();
ctx.stroke();
ctx.beginPath();
ctx.moveTo(100, 250);
ctx.lineTo(200, 250);
ctx.stroke();
</script>
三、画圣诞树的叶子
1、画出一些不同大小和颜色的圆形,这些圆就是圣诞树的叶子。
<css>
.circle {
position: absolute;
background-color: green;
border-radius: 50%;
}
</css>
<script>
var container = document.getElementById('myCanvas');
function createCircle(x, y, r) {
var circle = document.createElement('div');
circle.style.width = r * 2 + 'px';
circle.style.height = r * 2 + 'px';
circle.style.left = x - r + 'px';
circle.style.top = y - r + 'px';
circle.classList.add('circle');
container.appendChild(circle);
}
createCircle(150, 140, 40);
createCircle(120, 190, 20);
createCircle(180, 210, 30);
createCircle(200, 150, 25);
createCircle(130, 120, 35);
</script>
2、将这些圆形放置在三角形上。
<css>
.circle {
position: absolute;
background-color: green;
border-radius: 50%;
}
</css>
<script>
var container = document.getElementById('myCanvas');
function createCircle(x, y, r) {
var circle = document.createElement('div');
circle.style.width = r * 2 + 'px';
circle.style.height = r * 2 + 'px';
circle.style.left = x - r + 'px';
circle.style.top = y - r + 'px';
circle.classList.add('circle');
container.appendChild(circle);
}
createCircle(150, 140, 40);
createCircle(120, 190, 20);
createCircle(180, 210, 30);
createCircle(200, 150, 25);
createCircle(130, 120, 35);
ctx.globalCompositeOperation='destination-over';
ctx.fillStyle="#69370A";
ctx.beginPath();
ctx.moveTo(150, 250);
ctx.lineTo(100, 230);
ctx.lineTo(150, 210);
ctx.lineTo(200, 230);
ctx.closePath();
ctx.fill();
</script>
四、画圣诞树的装饰品
1、画圣诞树的装饰品可以是很多种不同的形状和颜色,比如圆形、星星、小饰品等等。
<css>
.star {
fill: #DAA520;
}
</css>
<script>
ctx.fillStyle = '#EC1C24';
ctx.beginPath();
ctx.arc(150, 90, 10, 0, 2 * Math.PI);
ctx.fill();
ctx.fillStyle = '#fff';
ctx.beginPath();
ctx.arc(150, 110, 10, 0, 2 * Math.PI);
ctx.fill();
ctx.fillStyle = '#003366';
ctx.beginPath();
ctx.arc(150, 130, 10, 0, 2 * Math.PI);
ctx.fill();
ctx.fillStyle = '#DAA520';
ctx.beginPath();
ctx.moveTo(145, 62.5);
ctx.lineTo(165, 62.5);
ctx.lineTo(170, 77.5);
ctx.lineTo(180, 80);
ctx.lineTo(170, 82.5);
ctx.lineTo(165, 97.5);
ctx.lineTo(160, 82.5);
ctx.lineTo(150, 80);
ctx.lineTo(160, 77.5);
ctx.closePath();
ctx.fill();
</script>
2、将这些装饰品放置在圣诞树上。
<css>
.star {
fill: #DAA520;
}
</css>
<script>
ctx.fillStyle = '#EC1C24';
ctx.beginPath();
ctx.arc(150, 90, 10, 0, 2 * Math.PI);
ctx.fill();
ctx.fillStyle = '#fff';
ctx.beginPath();
ctx.arc(150, 110, 10, 0, 2 * Math.PI);
ctx.fill();
ctx.fillStyle = '#003366';
ctx.beginPath();
ctx.arc(150, 130, 10, 0, 2 * Math.PI);
ctx.fill();
ctx.fillStyle = '#DAA520';
ctx.beginPath();
ctx.moveTo(145, 62.5);
ctx.lineTo(165, 62.5);
ctx.lineTo(170, 77.5);
ctx.lineTo(180, 80);
ctx.lineTo(170, 82.5);
ctx.lineTo(165, 97.5);
ctx.lineTo(160, 82.5);
ctx.lineTo(150, 80);
ctx.lineTo(160, 77.5);
ctx.closePath();
ctx.fill();
ctx.fillStyle = '#003366';
ctx.beginPath();
ctx.arc(130, 120, 5, 0, 2 * Math.PI);
ctx.fill();
ctx.fillStyle = '#EC1C24';
ctx.beginPath();
ctx.arc(200, 150, 8, 0, 2 * Math.PI);
ctx.fill();
ctx.fillStyle = '#fff';
ctx.beginPath();
ctx.arc(120, 190, 6, 0, 2 * Math.PI);
ctx.fill();
ctx.fillStyle = '#FFD700';
ctx.beginPath();
ctx.arc(150, 140, 7, 0, 2 * Math.PI);
ctx.fill();
</script>
五、添加圣诞节祝福语
在圣诞树的下面,我们可以加上一些圣诞节的祝福语。
<canvas id="myCanvas" width="300" height="300"></canvas>
<script>
var canvas = document.getElementById('myCanvas');
var ctx = canvas.getContext('2d');
ctx.font = '24px Arial';
ctx.fillStyle = "#69370A";
ctx.textAlign="center";
ctx.fillText("Merry Christmas!", 150, 280);
</script>
这样,我们就画完了一颗漂亮的圣诞树。你可以根据自己的喜好添加一些不同的元素,让圣诞树更加独特。