#【六·一】让代码创造童话,共建快乐世界# 庆祝儿童节的Html和Python代码

6 篇文章 0 订阅
1 篇文章 0 订阅

1.儿童节的简介

国际儿童节(又称儿童节,International Children’s Day)定于每年的6月1日。为了悼念1942年6月10日的利迪策惨案和全世界所有在战争中死难的儿童,反对虐杀和毒害儿童,以及保障儿童权利。

1949年11月,国际民主妇女联合会在莫斯科举行理事会议,中国和其他国家的代表愤怒地揭露了帝国主义分子和各国反动派残杀、毒害儿童的罪行。会议决定以每年的6月1日为国际儿童节。它是为了保障世界各国儿童的生存权、保健权和受教育权,抚养权,为了改善儿童的生活,为了反对虐杀儿童和毒害儿童而设立的节日。世界上许多国家都将6月1日定为儿童的节日。

2.中国庆祝儿童节的方式

首先,组织各种各样的儿童活动是庆祝儿童节的主要形式之一。在学校和社区中,会有文艺表演、游戏和亲子活动等多种活动,以满足孩子们对于庆祝儿童节的期待。比如,在学校里,老师们通常会向孩子们介绍儿童节的由来和意义,并且会根据孩子们的兴趣爱好,设计一些有趣的课堂活动,例如:绘画、手工制作、唱歌跳舞等等。

其次,在儿童节这一天,许多家长也会给自己的孩子买礼物或者带他们去游乐场等地方玩耍,让孩子们感受到对他们的关爱与呵护。在中国,很多商家会在儿童节期间推出特别促销,销售各种有趣的玩具、游戏和书籍,为孩子们创造一个美好而难忘的节日体验。

此外,在中国儿童节期间,还有许多机构会给孩子们发放礼物和奖励,以表彰他们在学习和生活中所取得的进步。例如:在一些社区或者公共场合,会设立“最可爱的儿童”评选,选出表现优异的孩子,并且颁发证书和奖状等荣誉证明。这种形式不仅鼓励了孩子们做出更加积极向上的努力,同时也让孩子们感受到来自家庭和社会的温暖与关爱。

最后,为了庆祝儿童节,许多家长会为孩子们准备特别的餐点和甜品。这些美食通常是孩子们喜欢吃的,如巧克力蛋糕、水果沙拉、薯片等,让孩子们在这一天可以吃到自己喜欢的食品,增加庆祝儿童节的乐趣。

总之,中国庆祝儿童节的方式是多种多样的,无论是在家庭、学校还是社区,都会有不同形式的庆祝活动。这些活动不仅可以让孩子们度过一个快乐的节日,同时也向他们传递了积极向上、健康快乐的生活态度,为他们未来的成长打下坚实的基础。

3.一段庆祝儿童节的Python代码

通过Python的turtle库来实现绘制游乐园

import turtle

# 创建画布和画笔
canvas = turtle.Screen()
canvas.title("六一儿童节快乐!")
pen = turtle.Turtle()

# 绘制太阳
pen.penup()
pen.goto(-300, 200)
pen.pendown()
pen.begin_fill()
pen.color("yellow")
for i in range(36):
    pen.forward(50)
    pen.right(170)
pen.end_fill()

# 绘制草地
pen.penup()
pen.goto(-500, -250)
pen.pendown()
pen.begin_fill()
pen.color("green")
pen.setheading(0)
pen.forward(1000)
pen.right(90)
pen.forward(500)
pen.right(90)
pen.forward(1000)
pen.right(90)
pen.forward(500)
pen.end_fill()

# 绘制旋转木马
def draw_horse(x, y, size):
    pen.penup()
    pen.goto(x, y)
    pen.pendown()
    # 绘制马轮
    pen.color("brown")
    pen.begin_fill()
    pen.circle(size * 0.5)
    pen.end_fill()
    # 绘制马身体
    pen.penup()
    pen.goto(x, y + size * 0.5)
    pen.pendown()
    pen.begin_fill()
    pen.setheading(180)
    pen.forward(size * 1.2)
    pen.left(120)
    pen.forward(size * 1.2)
    pen.left(60)
    pen.forward(size * 1.2)
    pen.left(120)
    pen.forward(size * 1.2)
    pen.left(60)
    pen.forward(size * 1.2)
    pen.left(120)
    pen.forward(size * 0.5)
    pen.end_fill()
    # 绘制马鞍
    pen.penup()
    pen.goto(x, y + size)
    pen.pendown()
    pen.begin_fill()
    pen.setheading(0)
    pen.forward(size * 0.6)
    pen.right(90)
    pen.forward(size * 0.4)
    pen.right(90)
    pen.forward(size * 0.6)
    pen.right(90)
    pen.forward(size * 0.4)
    pen.end_fill()

draw_horse(-100, -50, 80)
draw_horse(200, -100, 100)
draw_horse(-300, -150, 60)

# 绘制摩天轮
pen.penup()
pen.goto(350, 180)
pen.pendown()
pen.color("blue")
pen.begin_fill()
pen.circle(100)
pen.end_fill()
for i in range(8):
    pen.penup()
    pen.goto(350, 280)
    pen.pendown()
    pen.setheading(i * 45)
    pen.forward(100)
    pen.dot(20)

# 绘制气球
pen.penup()
pen.goto(-250, 180)
pen.pendown()
pen.color("red")
pen.begin_fill()
pen.circle(30)
pen.end_fill()

pen.penup()
pen.goto(-220, 230)
pen.pendown()
pen.color("yellow")
pen.begin_fill()
pen.circle(30)
pen.end_fill()

pen.penup()
pen.goto(-180, 260)
pen.pendown()
pen.color("green")
pen.begin_fill()
pen.circle(30)
pen.end_fill()

pen.penup()
pen.goto(-120, 280)
pen.pendown()
pen.color("purple")
pen.begin_fill()
pen.circle(30)
pen.end_fill()

# 隐藏画笔
pen.hideturtle()

# 关闭画布
canvas.exitonclick()

4.一段庆祝儿童节的Html代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<style>
		body{margin:0;padding:0;overflow: hidden;}
		.city{width:100%;position:fixed;bottom: 0px;z-index: 100;}
		.city img{width: 100%;}
	</style>
	<title>儿童节快乐</title>
</head>
<body onselectstart = "return false">
 
<div style="height:700px;overflow:hidden;">
 
	<canvas id='cas' style="background-color:rgba(0,5,24,1);">浏览器不支持canvas</canvas>
	<div class="city"><img src="img/city.png" alt="" /></div>
	<img src="img/moon.png" alt="" id="moon" style="visibility: hidden;"/>
	<div style="display:none">
		<div class="shape">儿童节快乐</div>
		<div class="shape">永远快乐</div>
        <div class="shape">开开心心</div>
	</div>
	
</div>
	
	<script>
		var canvas = document.getElementById("cas");
		var ocas = document.createElement("canvas");
		var octx = ocas.getContext("2d");
		var ctx = canvas.getContext("2d");
		ocas.width = canvas.width = window.innerWidth;
		ocas.height = canvas.height = 700;
		var bigbooms = [];
	
		window.onload = function(){
			initAnimate()
		}
 
		function initAnimate(){
			drawBg();
 
			lastTime = new Date();
			animate();
		}
 
		var lastTime;
		function animate(){
			ctx.save();
			ctx.fillStyle = "rgba(0,5,24,0.1)";
			ctx.fillRect(0,0,canvas.width,canvas.height);
			ctx.restore();
 
 
			var newTime = new Date();
            if(newTime-lastTime>500+(window.innerHeight-767)/2){
				var random = Math.random()*100>2?true:false;
				var x = getRandom(canvas.width/5 , canvas.width*4/5);
				var y = getRandom(50 , 200);
				if(random){
					var bigboom = new Boom(getRandom(canvas.width/3,canvas.width*2/3) ,2,"#FFF" , {x:x , y:y});
					bigbooms.push(bigboom)
				}
				else {
					var bigboom = new Boom(getRandom(canvas.width/3,canvas.width*2/3) ,2,"#FFF" , {x:canvas.width/2 , y:200} , document.querySelectorAll(".shape")[parseInt(getRandom(0, document.querySelectorAll(".shape").length))]);
					bigbooms.push(bigboom)
				}
				lastTime = newTime;
				console.log(bigbooms)
			}
 
			stars.foreach(function(){
				this.paint();
			})
 
			drawMoon();
 
			bigbooms.foreach(function(index){
				var that = this;
				if(!this.dead){
					this._move();
					this._drawLight();
				}
				else{
					this.booms.foreach(function(index){
						if(!this.dead) {
							this.moveTo(index);
						}
						else if(index === that.booms.length-1){
							bigbooms[bigbooms.indexOf(that)] = null;
						}
					})
				}
			});
			
			raf(animate);
		}
 
		function drawMoon(){
			var moon = document.getElementById("moon");
			var centerX = canvas.width-200 , centerY = 100 , width = 80;
			if(moon.complete){
				ctx.drawImage(moon , centerX , centerY , width , width )
			}
			else {
				moon.onload = function(){
					ctx.drawImage(moon ,centerX , centerY , width , width)
				}
			}
			var index = 0;
			for(var i=0;i<10;i++){
				ctx.save();
				ctx.beginPath();
				ctx.arc(centerX+width/2 , centerY+width/2 , width/2+index , 0 , 2*Math.PI);
				ctx.fillStyle="rgba(240,219,120,0.005)";
				index+=2;
				ctx.fill();
				ctx.restore();
			}
			
		}
 
		Array.prototype.foreach = function(callback){
			for(var i=0;i<this.length;i++){
				if(this[i]!==null) callback.apply(this[i] , [i])
			}
		}
 
		var raf = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) { window.setTimeout(callback, 1000 / 60); };
 		
		canvas.onclick = function(){
			var x = event.clientX;
			var y = event.clientY;
			var bigboom = new Boom(getRandom(canvas.width/3,canvas.width*2/3) ,2,"#FFF" , {x:x , y:y});
			bigbooms.push(bigboom)
		}
 
		// canvas.addEventLisener("touchstart" , function(event){
		// 	var touch = event.targetTouches[0];
		// 	var x = event.pageX;
		// 	var y = event.pageY;
		// 	var bigboom = new Boom(getRandom(canvas.width/3,canvas.width*2/3) ,2,"#FFF" , {x:x , y:y});
		// 	bigbooms.push(bigboom)
		// })
 
		var Boom = function(x,r,c,boomArea,shape){
			this.booms = [];
			this.x = x;
			this.y = (canvas.height+r);
			this.r = r;
			this.c = c;
			this.shape = shape || false;
			this.boomArea = boomArea;
			this.theta = 0;
			this.dead = false;
			this.ba = parseInt(getRandom(80 , 200));
		}
		Boom.prototype = {
			_paint:function(){
				ctx.save();
				ctx.beginPath();
				ctx.arc(this.x,this.y,this.r,0,2*Math.PI);
				ctx.fillStyle = this.c;
				ctx.fill();
				ctx.restore();
			},
			_move:function(){
				var dx = this.boomArea.x - this.x , dy = this.boomArea.y - this.y;
				this.x = this.x+dx*0.01;
				this.y = this.y+dy*0.01;
 
				if(Math.abs(dx)<=this.ba && Math.abs(dy)<=this.ba){
					if(this.shape){
						this._shapBoom();
					}
					else this._boom();
					this.dead = true;
				}
				else {
					this._paint();
				}
			},
			_drawLight:function(){
				ctx.save();
				ctx.fillStyle = "rgba(255,228,150,0.3)";
				ctx.beginPath();
				ctx.arc(this.x , this.y , this.r+3*Math.random()+1 , 0 , 2*Math.PI);
				ctx.fill();
				ctx.restore();
			},
			_boom:function(){
				var fragNum = getRandom(30 , 200);
				var style = getRandom(0,10)>=5? 1 : 2;
				var color;
				if(style===1){
					color = {
						a:parseInt(getRandom(128,255)),
						b:parseInt(getRandom(128,255)),
						c:parseInt(getRandom(128,255))
					}
				}
 
				var fanwei = parseInt(getRandom(300, 400));
				for(var i=0;i<fragNum;i++){
					if(style===2){
						color = {
							a:parseInt(getRandom(128,255)),
							b:parseInt(getRandom(128,255)),
							c:parseInt(getRandom(128,255))
						}
					}
					var a = getRandom(-Math.PI, Math.PI);
					var x = getRandom(0, fanwei) * Math.cos(a) + this.x;
					var y = getRandom(0, fanwei) * Math.sin(a) + this.y; 
					var radius = getRandom(0 , 2)
					var frag = new Frag(this.x , this.y , radius , color , x , y );
					this.booms.push(frag);
				}
			},
			_shapBoom:function(){
				var that = this;
				putValue(ocas , octx , this.shape , 5, function(dots){
					var dx = canvas.width/2-that.x;
					var dy = canvas.height/2-that.y;
					for(var i=0;i<dots.length;i++){
						color = {a:dots[i].a,b:dots[i].b,c:dots[i].c}
						var x = dots[i].x;
						var y = dots[i].y;
						var radius = 1;
						var frag = new Frag(that.x , that.y , radius , color , x-dx , y-dy);
						that.booms.push(frag);
					}
				})
			}
		}
 
		function putValue(canvas , context , ele , dr , callback){
			context.clearRect(0,0,canvas.width,canvas.height);
			var img = new Image();
			if(ele.innerHTML.indexOf("img")>=0){
				img.src = ele.getElementsByTagName("img")[0].src;
				imgload(img , function(){
					context.drawImage(img , canvas.width/2 - img.width/2 , canvas.height/2 - img.width/2);
					dots = getimgData(canvas , context , dr);
					callback(dots);
				})
			}
			else {
				var text = ele.innerHTML;
				context.save();
				var fontSize =200;
				context.font = fontSize+"px 宋体 bold";
				context.textAlign = "center";
				context.textBaseline = "middle";
				context.fillStyle = "rgba("+parseInt(getRandom(128,255))+","+parseInt(getRandom(128,255))+","+parseInt(getRandom(128,255))+" , 1)";
				context.fillText(text , canvas.width/2 , canvas.height/2);
				context.restore();
				dots = getimgData(canvas , context , dr);
				callback(dots);
			}
		}
 
		function imgload(img , callback){
			if(img.complete){
				callback.call(img);
			}
			else {
				img.onload = function(){
					callback.call(this);
				}
			}
		}
 
		function getimgData(canvas , context , dr){
			var imgData = context.getImageData(0,0,canvas.width , canvas.height);
			context.clearRect(0,0,canvas.width , canvas.height);
			var dots = [];
			for(var x=0;x<imgData.width;x+=dr){
				for(var y=0;y<imgData.height;y+=dr){
					var i = (y*imgData.width + x)*4;
					if(imgData.data[i+3] > 128){
						var dot = {x:x , y:y , a:imgData.data[i] , b:imgData.data[i+1] , c:imgData.data[i+2]};
						dots.push(dot);
					}
				}
			}
			return dots;
		}
 
		function getRandom(a , b){
			return Math.random()*(b-a)+a;
		}
 
 
		var maxRadius = 1 , stars=[];
		function drawBg(){
			for(var i=0;i<100;i++){
				var r = Math.random()*maxRadius;
				var x = Math.random()*canvas.width;
				var y = Math.random()*2*canvas.height - canvas.height;
				var star = new Star(x , y , r);
				stars.push(star);
				star.paint()
			}
 
		}
 
		var Star = function(x,y,r){
			this.x = x;this.y=y;this.r=r;
		}
		Star.prototype = {
			paint:function(){
				ctx.save();
				ctx.beginPath();
				ctx.arc(this.x , this.y , this.r , 0 , 2*Math.PI);
				ctx.fillStyle = "rgba(255,255,255,"+this.r+")";
				ctx.fill();
				ctx.restore();
			}
		}
 
		var focallength = 250;
		var Frag = function(centerX , centerY , radius , color ,tx , ty){
			this.tx = tx;
			this.ty = ty;
			this.x = centerX;
			this.y = centerY;
			this.dead = false;
			this.centerX = centerX;
			this.centerY = centerY;
			this.radius = radius;
			this.color = color;
		}
 
		Frag.prototype = {
			paint:function(){
				ctx.save();
				ctx.beginPath();
				ctx.arc(this.x , this.y , this.radius , 0 , 2*Math.PI);
				ctx.fillStyle = "rgba("+this.color.a+","+this.color.b+","+this.color.c+",1)";
				ctx.fill()
				ctx.restore();
			},
			moveTo:function(index){
				this.ty = this.ty+0.3;
				var dx = this.tx - this.x , dy = this.ty - this.y;
				this.x = Math.abs(dx)<0.1 ? this.tx : (this.x+dx*0.1);
				this.y = Math.abs(dy)<0.1 ? this.ty : (this.y+dy*0.1);
				if(dx===0 && Math.abs(dy)<=80){
					this.dead = true;
				}
				this.paint();
			}
		}
	</script>
 
</body>
</html>
 

要在文件所在位置创建一个名为img的文件夹
在文件夹中放入一下内容:
1.命名为moon
在这里插入图片描述
2.命名为city
在这里插入图片描述
去水印的话私信找我哦!

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好,以下是一个简单的使用HTML制作类似于"https://www.fjnu.edu.cn/main.htm"网页的示例代码: ```html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>福建师范大学</title> </head> <body> <header> <h1>福建师范大学</h1> </header> <nav> <ul> <li><a href="#">首页</a></li> <li><a href="#">学校概况</a></li> <li><a href="#">新闻中心</a></li> <li><a href="#">招生就业</a></li> <li><a href="#">校园生活</a></li> <li><a href="#">教学科研</a></li> <li><a href="#">校友服务</a></li> </ul> </nav> <main> <article> <h2>学校简介</h2> <p>福建师范大学创建于1907年,是福建省人民政府与教育部共建高校。学校主要办学特色是师范教育和人文社会科学,具有百年办学历史和深厚的文化底蕴。</p> </article> <section> <h2>新闻动态</h2> <ul> <li><a href="#">福建师范大学2021年迎新工作启动</a></li> <li><a href="#">2021年福建师范大学教师招聘公告</a></li> <li><a href="#">福建师范大学2021年本科招生计划</a></li> </ul> </section> </main> <aside> <h2>联系我们</h2> <p>地址:福建省福州市闽侯县上街镇</p> <p>电话:0591-83442777</p> <p>邮箱:fjnu@fjnu.edu.cn</p> </aside> <footer> <p>© 2021 福建师范大学</p> </footer> </body> </html> ``` 在这个示例中,我们使用HTML5标记语言来创建网页。我们通过`<header>`元素来定义网页的标题,通过`<nav>`元素来定义网页的主要导航,通过`<main>`元素来定义网页的主要内容,通过`<aside>`元素来定义网页的侧边栏内容,通过`<footer>`元素来定义网页的页脚。在`<main>`元素中,我们使用`<article>`元素来定义学校简介部分的内容,使用`<section>`元素来定义新闻动态部分的内容。网页的样式和布局可以通过CSS来实现。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值