寸金难买寸光阴-时间流逝就像雪花一样飘散

一、介绍

江大正飘柳絮像是冬天的雪花飘落,想做做自己喜欢的雪花的特效,通过参考《代码本色》弄了雪花。

二、实现雪花过程

**1.**先画一个雪花6个主分叉的其中一个的绘制——分支类然后用类方法生成完整的一支雪花分枝。

class Branch
{float radius,ratio,rotation;Branch(float radius_,float ratio_,float rot){radius=radius_;ratio=ratio_;rotation=rot;
}void generate()
{pushMatrix();rotate(radians(rotation)); float len=getStartLength(radius,ratio);branch(len);popMatrix();}void branch(float len)
{strokeWeight(len*0.15); strokeCap(ROUND);      line(0,0,0,-len);              translate(0,-len);           if(len>2) {pushMatrix();branch(len*ratio);popMatrix();pushMatrix();rotate(radians(-60)); branch(getStartLength(len,ratio));popMatrix();pushMatrix();rotate(radians(60)); branch(getStartLength(len,ratio));popMatrix();}}float getStartLength(float length,float  ratio){float len=(1-ratio)*length;return len;}
}

**2.**接下来实现雪花下落,随机生成新的雪花,然后消除落在画布外的雪花。

void  generate()
{PVector position =new PVector(random(0,width),0);PVector velocity =new PVector(0,random(5,10));float rotation =random(0,360);float aVel=random(-2,5);float radius =random(10,20);float ratio=0.618;snowflake s=new snowflake(position,velocity,rotation,aVel,radius,ratio);snowflakes.add(s);
}void  emit()
{if(speed >=1){for(int i=0;i<speed;i++){ generate();}}else if(speed>0){if(random(1)<speed){generate();}}
}void update()
{
Iterator<snowflake> ite=snowflakes.iterator();
while(ite.hasNext()){snowflake s=ite.next();s.update();s.show();
if(s.position.y>(height+s.radius)){ite.remove();}
}
}
void run () 


**3.**然后自己觉得时间就像雪花飘落一样流逝,本来想弄一个比较酷的时间表,但是实力不允许啊!就添加了一个比较low的一个时间表!

**4.**实验完整代码如下

import java.util.Iterator;snowsystem snow;
int cx, cy;
float secondsRadius;
float minutesRadius;
float hoursRadius;
float clockDiameter;void setup()
{size(640, 360);
snow =new snowsystem(0.8);
int radius = min(width, height) / 2;secondsRadius = radius * 0.72;minutesRadius = radius * 0.60;hoursRadius = radius * 0.50;clockDiameter = radius * 1.8;cx = width / 2;cy = height / 2;
}
void draw ()
{background(20);stroke(240);snow.run();fill(random(0,255),random(0,255),random(0,255));ellipse(cx, cy, clockDiameter, clockDiameter);// Angles for sin() and cos() start at 3 o'clock;// subtract HALF_PI to make them start at the topfloat s = map(second(), 0, 60, 0, TWO_PI) - HALF_PI;float m = map(minute() + norm(second(), 0, 60), 0, 60, 0, TWO_PI) - HALF_PI; float h = map(hour() + norm(minute(), 0, 60), 0, 24, 0, TWO_PI * 2) - HALF_PI;// Draw the hands of the clockstroke(255);strokeWeight(1);line(cx, cy, cx + cos(s) * secondsRadius, cy + sin(s) * secondsRadius);strokeWeight(2);line(cx, cy, cx + cos(m) * minutesRadius, cy + sin(m) * minutesRadius);strokeWeight(4);line(cx, cy, cx + cos(h) * hoursRadius, cy + sin(h) * hoursRadius);// Draw the minute ticksstrokeWeight(2);beginShape(POINTS);for (int a = 0; a < 360; a+=6) {float angle = radians(a);float x = cx + cos(angle) * secondsRadius;float y = cy + sin(angle) * secondsRadius;vertex(x, y);}endShape();}class Branch
{float radius,ratio,rotation;Branch(float radius_,float ratio_,float rot){radius=radius_;ratio=ratio_;rotation=rot;
}void generate()
{pushMatrix();rotate(radians(rotation)); float len=getStartLength(radius,ratio);branch(len);popMatrix();}void branch(float len)
{stroke(random(0,255),random(0,255),random(0,255));   strokeWeight(len*0.15); strokeCap(ROUND);      line(0,0,0,-len);              translate(0,-len);            if(len>2) {pushMatrix();branch(len*ratio);popMatrix();pushMatrix();rotate(radians(-60)); branch(getStartLength(len,ratio));popMatrix();pushMatrix();rotate(radians(60)); branch(getStartLength(len,ratio));popMatrix();}}float getStartLength(float length,float  ratio){float len=(1-ratio)*length;return len;}
}class snowflake
{PVector position ,velocity;float rotation ,aVelocity,radius,ratio;Branch[] branches=new Branch[6];snowflake(PVector pos,PVector vel,float rot,float aVel,float r,float rat){position =pos;velocity=vel;rotation=rot;aVelocity=aVel;radius=r;ratio=rat;for(int i=0;i<6;i++){ branches[i]=new Branch(radius,ratio,i*60);}}void update(){position.add(velocity);rotation+=aVelocity; }void show()  {pushMatrix();translate(position.x,position.y);rotate(radians(rotation));for(Branch b:branches){b.generate();}popMatrix();  }
}class snowsystem
{float speed ;ArrayList<snowflake> snowflakes;snowsystem (float speed_){speed=speed_;snowflakes=new ArrayList<snowflake>();}void  generate()
{PVector position =new PVector(random(0,width),0);PVector velocity =new PVector(0,random(5,10));float rotation =random(0,360);float aVel=random(-2,5);float radius =random(10,20);float ratio=0.618;snowflake s=new snowflake(position,velocity,rotation,aVel,radius,ratio);snowflakes.add(s);
}void  emit()
{if(speed >=1){for(int i=0;i<speed;i++){ generate();}}else if(speed>0){if(random(1)<speed){generate();}}
}void update()
{
Iterator<snowflake> ite=snowflakes.iterator();
while(ite.hasNext()){snowflake s=ite.next();s.update();s.show();
if(s.position.y>(height+s.radius)){ite.remove();}
}
}
void run ()
{ emit();update();}
}

三、总结

一开始我就对动画技术有着浓烈的好奇心,它在我的心里总有一份神秘感,带着好奇和神秘我在课堂上我跟随着老师的引导在动画的世界自由翱翔,但是学习的不好。这一学期动画的学习,我学到了很多知识。原来我本来以为画画是不用动脑筋的事情,其实画画也需要花很多的心思:颜色的搭配,运用各种数学公式等等,都要花很多的时间去学习。
讲课教师就像路人将我们带入了课间创作天地,激发了我们的创作欲望和学习灵感,有了更多的思索。特别是老师讲课的方式很有趣,比如我有一个喜欢的老师,就特别课爱,每一次讲着就会说一个笑话,虽然有点冷(哈哈哈)!
动画很可爱,它需要画而且要让他动起来,这是它与纯绘画不同的地方,在画这一点来说,需要懂一点造型艺术,还需要的熟悉各种数学原理!
自己觉得时间就像雪花飘落一样流逝,本来想弄一个比较酷的时间表,但是实力不允许啊!本次作业本来想弄一个时间表里的颜色随着音乐变颜色,尝试了好多次还是不行,就弄了个很low的一个随机变颜色的时间表!

融入动画技术的交互应用-雪花相关推荐

  1. 融入动画技术的交互应用优秀作业推荐

    观看本学期其他同学的作业中,我学习到许多,看到了很多有意思的交互应用,通过创意,交互体验,技术的丰富性.深入度.难度三方面进行评价,选出我认为最优秀的三个作品: 1.processing-洇 作者:张 ...

  2. 融入动画技术的交互应用

    融入动画技术的交互应用 前言 之前使用过p5.js做一些简单的编程,实现了一些简单的交互,比如画动态的风车.制做画图工具等:这次老师又提出了新的要求,让我们结合<代码本色>至少三个章节的技 ...

  3. 融入动画技术的交互应用——Map Generator!

    Map Generator 背景 技术 开发工具 涉及到的动画技术 涉及到的交互技术 灵感来源 展示 功能实现 使用柏林噪声生成地图 使用细胞自动机生成树木 使用柏林噪声.粒子系统模拟水面 使用向量模 ...

  4. androidtv item获取焦点设置动画和背景_动画技术的交互应用所作的动画

    动画技术的交互应用所作的动画 作者: 周益铭 本交互设计的实现主要运用了<The Nature of Code><代码本色-Daniel Shiffman>中向量(Vector ...

  5. 融入动画技术的音乐可视化交互技术——Fun Beats

    灵感来源 音乐给人带来美好的沉浸感体验,那么随着乐感的律动欣赏有趣的特效,一定是一场绝妙的视听盛宴.Fun beats是我们大创项目正在研究的一款培养乐感的交互式小程序,在原有的框架上,我结合< ...

  6. 融入动画技术的粒子效果文字动画交互应用

    写在前面 本次实现的交互系统是基于粒子系统的粒子文本效果.本次课程设计主要参考代码本色一书中的内容,系统应用中运用了 <代码本色> 第一章 向量.第二章 力.第四章 粒子系统等章节的动画技 ...

  7. 《春·蜂》processing下的动画技术交互应用

    <春·蜂>processing下的动画技术交互应用 <春·蜂> 代码绘制蜂巢 绽放的分形花 空气.液体中蜂蜜下降阻力不同 蜂巢细胞自动机 随大流的蜂群 随风摇曳的迎春树 交互动 ...

  8. 三维计算机动画的特征是真实性,三维动画技术有哪些优势特征呢?

    三维动画技术有哪些优势特征呢?三维动画又称3D动画,它不受时间.空间.地点.条件.对象的限制,运用各种表现形式把复杂.抽象的节目内容.科学原理.抽象概念等用集中.简化.形象.生动的形式表现出来.三维动 ...

  9. 如何设计出完美的动画技术架构

    动画在前端领域中的作用是提升用户体验.吸引用户注意力.在互联网行业中,它也是一个永久的热点话题.一般在电商平台或者娱乐类项目(快手.拼多多.淘宝.腾讯视频.抖音等)中会出现很多的动画场景. 那么通过本 ...

最新文章

  1. 5月“.公司”域名注册总量TOP15:西部数码第四
  2. Canu|三代组装软件
  3. Oracle集合操作函数:Union、Union All、Intersect、Minus
  4. 系统架构设计师考试知识点整理-2:进程的状态-三态模型和五态模型
  5. sql server 2008学习6 更复杂的查询
  6. kvm服务器中心管理,IP KVM如何在公共场所数据中心合理应用
  7. 下单问题分析及解决方式
  8. Equipment download and upload: all possible scenario
  9. MySQL什么是关系_MySQL教程-关系模型
  10. oraclr 和mysql的不同_Mysql和Oracle中的不同
  11. 确保客户端可以接收到服务端的异常serviceDebug includeExceptionDetailInFaults=true
  12. JavaScript高级程序设计之什么是原型模式
  13. mermaid流程图工具_Markdown高级使用之流程图
  14. java一次性查询几十万,几百万数据解决办法
  15. 虚拟光驱 安装深度linux,手把手教你如何用虚拟光驱安装深度WIN7
  16. 配置jdk与maven环境变量
  17. 视频直播声音不清晰的解决办法(小蜜蜂无线麦克风使用方式)
  18. excel冻结窗口_Excel工作学习超高频实用技巧
  19. 正式发售超两周 iPhone7部分机型仍然缺货
  20. Android开发学习之基于ZBar实现微信扫一扫

热门文章

  1. workbook需要引入的包_用Java玩转Excel,竟然如此easy~
  2. GITHUB无法打开与下载失败解决方法总结
  3. oracle 月底,Oracle查询月初和月底时间
  4. 安装office2016后文档表格不能显示图标
  5. java消息中间件_java消息中间件
  6. 微信小程序-开放标签
  7. 松下P2卡MXF视频恢复方法
  8. 《青浦区加快发展跨境电子商务实施细则(审议稿)》
  9. python基础3---循环和字符串列表
  10. 短视频APP开发功能介绍