我的创作256天纪念日
- 机缘
- 收获
- 日常
- 成就
- 憧憬
机缘
机缘……好像128天的时候已经写过了……
小升初时,我开始接触编程,进入了一个全新的世界。刚开始学习编程时,我只是对电脑的一些操作比较感兴趣,但慢慢地,我开始对编写程序、设计算法产生了浓厚的兴趣。在实践中不断摸索和探索,我渐渐意识到编程这一领域有着非常巨大的发展潜力。
我有一份坚定的理想,那就是成为编程领域的创作者。我相信通过自己的不断努力和锤炼,我会成为一个优秀的编程工程师。在我看来,编程领域每一天都在变化,无论是新的技术、新的编程语言或者是新的领域,都有无限的可能性。并且,编程是一门让人感到非常有成就感的学科,通过编写代码,我们可以让计算机按照我们的指令去执行各种各样的任务,这感觉就像是在创造一个个小宇宙一样,非常奇妙。
另外,编程也是一门需要不断自我挑战和超越的学科。在编程的过程中,我们需要思考问题、找寻解决方案、迭代修改,不断改进,这个过程让我有机会去更好地锻炼自己的思维能力和创造力。而且,在编程领域中,我们不受时间和空间的限制,可以在任何地方、任何时间进行工作和学习,这种自由和灵活度也是我非常向往的。
我对编程领域产生了强烈的兴趣和热情,我相信只要坚持不懈地努力,我一定能够成为一个优秀的编程领域的创作者(bushi)。
收获
不知不觉,加入CSDN已经有256天了
也有不少的收获——截至现在(2023年10月16日21时15分18秒),已经完成了81篇文章的创作,而这篇恰好是第82篇;获得了58242的访问量,60个粉丝。
还有……
日常
现在进入八年级,学习压力倍增,所以文章写得也少了,不过我在B站有个号(记得支持!!!):
喜欢电脑的平某人的个人空间_Bilibili
成就
随便贴一点吧
这是C++
#include<graphics.h>
#include<conio.h>
#include<stdio.h>
int main() {
double width, height;//定义画面长度、宽度
width = 600;
height = 400;
initgraph(width, height);
double ball_x, ball_y, ball_vy, r, g;//定义小球x轴、y轴、y轴方向的速度、半径、重力加速度
g = 0.6;
r = 20;
ball_x = width / 4;//x坐标等于整个画面x轴长度的四分之一
ball_y = height - r;//y坐标等于画面的y轴长度减去圆的半径(保证圆在画面的最底端)
ball_vy = 0; //最初小球落在地面上时y轴方向的速度为0
double rect_left_x, rect_top_y, rect_width, rect_height;//定义方块的各个位置变量
rect_width = 20;
rect_height = 100;
rect_left_x = width * 3 / 4;
rect_top_y = height - rect_height;
double rect_vx = -3;//定义方块的移动速度
int score = 0;//定义得分
while (1) {
if (_kbhit()) {
char input = _getch();
if (input == ' ' && ball_y == 380) {
ball_vy = -16;
}
}
ball_vy = ball_vy + g;//根据牛顿力学定律得
ball_y = ball_y + ball_vy;//小球y轴方向的变化
if (ball_y >= height - r) {
ball_vy = 0;//小球落地以后速度清零
ball_y = height - r;
}
rect_left_x = rect_left_x + rect_vx;
if (rect_left_x <= 0) {//如果方块移动到最左边
score++;
rect_left_x = width;//方块消失以后重新出现
rect_height = rand() % int(height / 4) + height / 4;//设置随机高度
rect_vx = rand() / float(RAND_MAX) * 4 - 7;//设置方块随机速度
}
if ((rect_left_x <= ball_x + r) && (rect_left_x + rect_width >= ball_x - r) && (height - rect_height <= ball_y + r)) {
score = 0;
Sleep(100);//碰到方块慢动作
}
cleardevice();
fillrectangle(rect_left_x, height - rect_height, rect_left_x + rect_width, height);
fillcircle(ball_x, ball_y, r);
TCHAR s[20];//定义字符串数组
_swprintf(s, _T("%d"), score);//把score转换为字符串并储存在字符串数组s中
settextstyle(40, 0, _T("宋体"));//设置文本大小
outtextxy(50, 30, s);//输出得分
Sleep(10);
}
_getch();
closegraph();
return 0;
}
这是python
import requests
from bs4 import BeautifulSoup
import os
def download_images(url):
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
image_tags = soup.find_all('img')
if not os.path.exists('downloaded_images'):
os.makedirs('downloaded_images')
for tag in image_tags:
try:
image_url = tag['src']
if image_url.startswith('http'):
response = requests.get(image_url)
else:
response = requests.get(url + image_url, stream=True)
file_name = os.path.join('downloaded_images', image_url.split('/')[-1])
with open(file_name, 'wb') as f:
f.write(response.content)
print("下载完成:", file_name)
except Exception as e:
print("下载失败:", str(e))
url = input("请输入网址:(By CSDN@喜欢电脑的平某人)")
download_images(url)
这是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>
详见:
C++图形开发(15):C++小游戏——别碰方块
一个自动下载网页图片的python小程序
#【六·一】让代码创造童话,共建快乐世界# 庆祝儿童节的Html和Python代码
憧憬
作为一个初中生学习编程,我获得了许多宝贵的收获。首先,编程让我培养了解决问题的能力和逻辑思维能力。每当我遇到一个编程难题时,我需要分析问题、找出解决方案,并按照一定的逻辑步骤进行编码。这种思维方式不仅在编程中非常有用,也可以帮助我更好地解决日常生活中的各种困难。
其次,编程还提高了我的创造力和创新精神。在编程过程中,我可以自由地设计和实现自己的创意想法。这使我学会了思考如何将问题转化为具体的代码实现,同时也激发了我寻找新颖解决方案的动力。
此外,编程还培养了我的耐心和坚持不懈的品质。编程往往需要花费大量的时间和精力,我可能会面临各种错误和挫折,但是通过解决问题的过程,我学会了耐心地调试代码、坚持不懈地寻找bug并找到解决方案。
最重要的是,通过编程,我也发展了团队合作和沟通能力。在与其他同学一起解决编程项目时,我们需要相互合作、交流和分工合作,以达到共同的目标。这种合作经历不仅帮助我更好地理解团队协作的重要性,也提升了我的沟通和交流技巧。
总的来说,学习编程作为一个初中生给我带来了很多收获。它不仅培养了我的解决问题能力、逻辑思维能力和创新精神,还锻炼了我的耐心和坚持不懈的品质,同时也帮助我发展了团队合作和沟通能力。这些收获将对我的学习和未来的发展产生积极的影响。