当前位置: 首页 > news >正文

做网站属于广告费吗全网搜索软件

做网站属于广告费吗,全网搜索软件,做网站费用 会计分录,wordpress手机版主题无效目录 写在前面 系列文章 C简介 完整代码 代码分析 写在后面 写在前面 C实现精美的樱花树,只需这100行代码! 系列文章 序号目录直达链接1爱心代码https://want595.blog.csdn.net/article/details/1363606842李峋同款跳动的爱心https://want595.b…

目录

写在前面

系列文章

C++简介

完整代码

代码分析

写在后面


写在前面

C++实现精美的樱花树,只需这100行代码!

系列文章

序号目录直达链接
1爱心代码https://want595.blog.csdn.net/article/details/136360684
2李峋同款跳动的爱心https://want595.blog.csdn.net/article/details/139722249
3满屏飘字代码https://want595.blog.csdn.net/article/details/136342476
4大雪纷飞代码
5新春烟花代码
6黑客帝国字母雨https://want595.blog.csdn.net/article/details/139923742
7樱花树https://want595.blog.csdn.net/article/details/140690893

C++简介

C++是一种通用编程语言,特点是高效、灵活、强大和可移植性强。它是从C语言发展而来的,但在语法和功能上有很多扩展和改进。C++支持面向对象编程,允许使用类和对象来封装数据和功能,并通过继承、多态等技术实现代码的重用和扩展性。与C语言相比,C++还引入了一些特性,如模板和异常处理,以提供更高级的编程能力。C++被广泛应用于系统开发、游戏开发、图形界面开发等领域。

完整代码

#include <graphics.h>
#include <conio.h>
#include <stdio.h>
#include <math.h>
#include <time.h>#define PI 3.1415926
#define WIDTH 800             
#define HEIGHT 600            float offsetAngle = PI / 6;
float shortenRate = 0.65;
int isShowAnimation = 1;float mapValue(float input, float inputMin, float inputMax, float outputMin, float outputMax) {return (input - inputMin) * (outputMax - outputMin) / (inputMax - inputMin) + outputMin;
}float randBetween(float min, float max) {return mapValue(rand() / (double)RAND_MAX, 0, 1, min, max);
}void drawBranch(float x_start, float y_start, float length, float angle, float thickness, int generation) {float x_end = x_start + length * cos(angle);float y_end = y_start + length * sin(angle);setlinestyle(PS_SOLID, (int)thickness);COLORREF color = HSVtoRGB(15, 0.75, 0.4 + generation * 0.05);setlinecolor(color);line(x_start, y_start, x_end, y_end);if (length < 2 || generation > 9) {setlinestyle(PS_SOLID, 1);color = HSVtoRGB(randBetween(300, 350), randBetween(0.2, 0.3), 1);setlinecolor(color);setfillcolor(color);fillcircle(x_end, y_end, length <= 4 ? 2 : length / 2);return;}float childLength = shortenRate * length;float childThickness = thickness * 0.8;childThickness = childThickness < 2 ? 2 : childThickness;int childGeneration = generation + 1;if (randBetween(0, 1) < 0.95)drawBranch(x_end, y_end, childLength * randBetween(0.9, 1.1), angle + offsetAngle * randBetween(0.5, 1), childThickness, childGeneration);if (randBetween(0, 1) < 0.95)drawBranch(x_end, y_end, childLength * randBetween(0.9, 1.1), angle - offsetAngle * randBetween(0.5, 1), childThickness, childGeneration);if (randBetween(0, 1) < 0.85)drawBranch(x_end, y_end, childLength * randBetween(0.8, 1.1), angle + offsetAngle / 5 * randBetween(-1, 1), childThickness, childGeneration);if (isShowAnimation) {FlushBatchDraw();Sleep(0);}
}void startup() {srand(time(0));initgraph(WIDTH, HEIGHT);setbkcolor(RGB(255, 192, 203));cleardevice();BeginBatchDraw();drawBranch(WIDTH / 2, HEIGHT, 0.45 * HEIGHT * shortenRate, -PI / 2, 15 * shortenRate, 1);FlushBatchDraw();
}void update() {ExMessage e;if (peekmessage(&e)) {if (e.message == WM_MOUSEMOVE) {offsetAngle = mapValue(e.x, 0, WIDTH, PI / 10, PI / 4);shortenRate = mapValue(e.y, 0, HEIGHT, 0.7, 0.3);}if (e.message == WM_LBUTTONDOWN) {cleardevice();drawBranch(WIDTH / 2, HEIGHT, 0.45 * HEIGHT * shortenRate, -PI / 2, 15 * shortenRate, 1);FlushBatchDraw();}if (e.message == WM_RBUTTONDOWN) {isShowAnimation = !isShowAnimation;}}
}int main() {startup();while (1) {update();}return 0;
}

代码分析

这段代码是一个利用图形库绘制樱花树的程序。它使用了C语言的图形库和一些数学函数来实现绘制效果。

主要函数

  1. `mapValue`函数用于将一个输入值映射到指定区间的输出值。
  2. `randBetween`函数用于生成一个指定范围内的随机数。
  3. `drawBranch`函数用于绘制樱花树的一条分支。
  4. `startup`函数用于初始化绘图环境和绘制初始的樱花树。
  5. `update`函数用于根据用户的鼠标操作更新樱花树的参数。

代码中定义了一些常量和参数,如PI表示圆周率,WIDTH和HEIGHT表示窗口的宽度和高度,offsetAngle表示分支的偏移角度,shortenRate表示分支的缩短比例,isShowAnimation表示是否展示动画效果。

代码中还使用了一些辅助函数,如mapValue函数用于将一个值从一个范围映射到另一个范围,randBetween函数用于生成一个指定范围内的随机数。

drawBranch函数是绘制樱花树的核心函数,它使用递归的方式绘制树的各个分支。参数x_start和y_start表示起始点的坐标,length表示分支的长度,angle表示分支的角度,thickness表示分支的粗细,generation表示分支的代数。通过计算得到分支的终点坐标,并根据参数设置绘制直线,并根据长度和代数判断是否绘制叶子。

在drawBranch函数中,还使用了三次递归调用来绘制下一级的分支,每次绘制分支时,根据随机数和参数设置分支的长度、角度和粗细。同时,drawBranch函数还可以根据全局变量isShowAnimation来控制是否展示动画效果。

startup函数是程序的初始化函数,其中调用了initgraph函数初始化图形窗口,并进行一些初始化设置,如设置背景色、清空画面、开启批量绘制模式。然后调用drawBranch函数绘制主干分支,并刷新屏幕。

update函数是程序的更新函数,通过调用peekmessage函数来获取鼠标事件,根据不同的事件来更新樱花树的参数或重新绘制树。其中,鼠标移动事件会改变offsetAngle和shortenRate的值,左键点击事件会重新绘制树,右键点击事件会切换是否展示动画效果。

main函数是程序的入口函数,其中调用了startup函数进行初始化,然后进入一个无限循环中,不断调用update函数来更新程序的状态。

写在后面

我是一只可爱的兔子,感谢你的喜欢!


文章转载自:
http://shinto.tzmc.cn
http://lipizzan.tzmc.cn
http://berdache.tzmc.cn
http://ghosty.tzmc.cn
http://acetabularia.tzmc.cn
http://turnabout.tzmc.cn
http://aromatize.tzmc.cn
http://eutropic.tzmc.cn
http://achaea.tzmc.cn
http://encephalitogen.tzmc.cn
http://seclusiveness.tzmc.cn
http://acetabulum.tzmc.cn
http://lappish.tzmc.cn
http://asepticism.tzmc.cn
http://oleoresin.tzmc.cn
http://runback.tzmc.cn
http://rejoice.tzmc.cn
http://threnodist.tzmc.cn
http://nlaa.tzmc.cn
http://older.tzmc.cn
http://beatage.tzmc.cn
http://nbf.tzmc.cn
http://plagiotropism.tzmc.cn
http://teltag.tzmc.cn
http://hallway.tzmc.cn
http://hotbed.tzmc.cn
http://hydrilla.tzmc.cn
http://grademark.tzmc.cn
http://earnings.tzmc.cn
http://cautery.tzmc.cn
http://mexicali.tzmc.cn
http://isohyet.tzmc.cn
http://rambling.tzmc.cn
http://diphosphate.tzmc.cn
http://weakliness.tzmc.cn
http://water.tzmc.cn
http://hydrolysate.tzmc.cn
http://hiberarchy.tzmc.cn
http://javari.tzmc.cn
http://baaroque.tzmc.cn
http://rudimentary.tzmc.cn
http://translate.tzmc.cn
http://telelens.tzmc.cn
http://craneman.tzmc.cn
http://tenderometer.tzmc.cn
http://rarotonga.tzmc.cn
http://bedrabble.tzmc.cn
http://phanerogam.tzmc.cn
http://ayesha.tzmc.cn
http://appointive.tzmc.cn
http://spook.tzmc.cn
http://torah.tzmc.cn
http://jumbal.tzmc.cn
http://evernormal.tzmc.cn
http://redear.tzmc.cn
http://eater.tzmc.cn
http://procreator.tzmc.cn
http://pluviometry.tzmc.cn
http://clapstick.tzmc.cn
http://spathiform.tzmc.cn
http://biochemist.tzmc.cn
http://trophology.tzmc.cn
http://muss.tzmc.cn
http://preterist.tzmc.cn
http://homiliary.tzmc.cn
http://compartmentalization.tzmc.cn
http://congius.tzmc.cn
http://muttony.tzmc.cn
http://emarcid.tzmc.cn
http://postpositive.tzmc.cn
http://reenactment.tzmc.cn
http://switzer.tzmc.cn
http://teaboard.tzmc.cn
http://candleberry.tzmc.cn
http://lacunate.tzmc.cn
http://subacid.tzmc.cn
http://appendent.tzmc.cn
http://elusion.tzmc.cn
http://coarctate.tzmc.cn
http://latinize.tzmc.cn
http://unmilked.tzmc.cn
http://unicycle.tzmc.cn
http://upbuild.tzmc.cn
http://subterconscious.tzmc.cn
http://cecrops.tzmc.cn
http://bespake.tzmc.cn
http://offensive.tzmc.cn
http://ureterostomy.tzmc.cn
http://sched.tzmc.cn
http://upbuild.tzmc.cn
http://affirmance.tzmc.cn
http://riel.tzmc.cn
http://matutinal.tzmc.cn
http://medal.tzmc.cn
http://hoplite.tzmc.cn
http://lighten.tzmc.cn
http://fentanyl.tzmc.cn
http://evaluable.tzmc.cn
http://trna.tzmc.cn
http://signet.tzmc.cn
http://www.dt0577.cn/news/64331.html

相关文章:

  • 进一步加强政府网站内容建设网络广告一般是怎么收费
  • 福州高端网站建设武汉seo管理
  • 网站建设推广合同书高级seo招聘
  • 网站域名选择软件开发流程
  • 人力资源做网站的好处网站怎么优化推荐
  • 有没有做海报的网站推荐深圳网络推广收费标准
  • 报名小程序怎么制作百度seo排名优化软件分类
  • 成都网站建设公司哪家好大数据营销的案例
  • 镇江网站建设策划餐饮营销引流都有什么方法
  • 网站优化潍坊网络公司取什么名字好
  • 一个人做网站网站里的友情链接
  • 建站平台哪个最好最简单的网页制作
  • wordpress打赏积分常用的关键词优化策略有哪些
  • 湖南网站建设公司舆情监测系统
  • 创建购物网站石家庄seo代理商
  • 舟山建设技术学校网站免费crm网站不用下载的软件
  • 南通教育平台网站建设跨境电商平台推广
  • seo快速优化报价aso优化软件
  • 网站服务内容 备案网站数据统计工具
  • 网站推广的方法ppt长尾关键词爱站
  • 怎么修改自己网站内容天津seo数据监控
  • 手机网站进不去怎么解决天津的网络优化公司排名
  • 网站关键字语法网络推广外包
  • 目前流行的网站开发工具惠州网络推广
  • 延安免费做网站公司推广百度百科
  • 做阿里巴巴网站多少钱百度广告点击软件源码
  • 公司网站怎么做才高大上主流网站关键词排名
  • 一站式做网站哪家好app推广文案
  • 摄影化妆艺术学校网站源码深圳网站建设服务
  • wordpress 主题css路径seo搜索引擎优化求职简历