当前位置:网站首页>[p5.js] practical exercise - irregular symmetry
[p5.js] practical exercise - irregular symmetry
2022-07-28 17:49:00 【Zhigan doctrine circle Maojun】

Drawing process
Although this sentence is a little redundant , But to be honest , I didn't expect to make such a complex effect at first , In short, that is .... It's done unconsciously .
My initial idea is to make four tracks in the horizontal direction , Black and white interval , Form a wonderful visual illusion , Like this .

Maybe the final product looks a little complicated , But in fact, it is just a moving graph composed of many straight lines , So how to make a straight line “ move ” Well ?
The secret is to change the color of the line . In every frame , The color of each line in the figure is changing , And this change goes in a certain direction .
When I try to adjust the color parameters of the brush , Some wonderful color gradient effects come out .
At the beginning, I only set four tracks in the horizontal direction , Later, I added four more tracks in the vertical direction , So an irregular symmetric graph with diagonal lines as symmetry lines was born .
Code
let a;
let b;
let direction;
function setup() {
createCanvas(320, 320);
a = 0;
b = width;
direction = true;
frameRate(50);
}
function draw() {
a++;
if (a > width) {
a = 0;
direction = !direction;
}
if (direction === true) {
stroke(a , width - a, height - a);
} else {
stroke(width - a, height - a, b);
}
line(a, 0, a, height / 4);
line(a, height / 2, a, height - height / 4);
line(0, a, width / 4, a);
line(width / 2, a, width - width / 4, a);
b--;
if (b < 0) {
b = width;
}
if (direction === true) {
stroke(width - b, height - b, a);
} else {
stroke(b, width - b, height - b);
}
line(b, height - height / 4, b, height);
line(b, height / 4, b, height / 2);
line(width - width / 4, b, width, b);
line(width / 4, b, width / 2, b);
}
边栏推荐
- 100+ collection of medical image data sets
- How to bind idea with code cloud
- mmdetection3D---(1)
- 2.2-数据类型
- Please make sure you have the correct access rights and the repository exists.
- Ros自定义消息及使用
- PyTorch中grid_sample的使用方法
- 点云处理--voxel filter
- 软件测试前景如何?该如何进行学习呢?
- [C language note sharing] - dynamic memory management malloc, free, calloc, realloc, flexible array
猜你喜欢

【Unity】Timeline学习笔记(七):自定义片段(Clip)

C#中virtual(虚方法)的理解以及和abstract(抽象方法)的区别

R language drawing / drawing / drawing 2

编译原理学习笔记1(编译原理概述与词法分析)
![[C language note sharing] custom type: structure, enumeration, Union (recommended Collection)](/img/25/4a17c260b2b506ae1224520d9b85d1.png)
[C language note sharing] custom type: structure, enumeration, Union (recommended Collection)

Factor in R

都说软件测试是IT行业最差的,是这样的吗?

Internal class, common class

Jerry ac692x --- matrix keyboard addition

.net MVC understanding
随机推荐
MySQL高级-MVCC(超详细整理)
An article takes you closer to the overview and principle of kubernetes
PyTorch中grid_sample的使用方法
R language sub() usage
es6 Promise
Hgu95av2. Online installation failed
R language drawing / drawing / drawing 2
三维点云处理系列----PCA
MySQL详解
软件测试就业前景如何?
In depth sharing of Ali (ant financial) technical interview process, with preliminary preparation and learning direction
mmdetection3d(2)---结果、log可视化
小白必看的软件测试发展路线
分支与循环语句
多线程的使用
完全未接触过软件测试的人,培训两个月就可以上岗,真的现实吗?
leetcode系统性刷题(五)-----动态规划
【C语言进阶】——剖析入微数据在内存中的存储[上]
电脑充不进去电的解决方法
Visual object class introduces Pascal VOC dataset