Processing基础之绘画
图形
//在(x, y)绘制点
point(x, y); //(x1, y1)到(x2, y2)的一条线
line(x1, y1, x2, y2); rect(x, y, weight, height); //Constant有三个值:
//默认CORNER:rect(左上x, 左上y, 宽, 高)
//CENTER:rect(中心x, 中心y, 宽, 高)
//CORNERS:rect(左上x, 左上y, 右下x, 右下y)
rectMode(Constant); //(x, y)圆心位置,weight水平直径,height垂直直径
ellipse(x, y, weight, height); //start圆弧起始角度,stop圆弧结束角度
arc(x, y, width, height, start, stop) //(x1, y1) (x2, y2) (x3, y3)表示三角形的三个顶点
triangle(x1, y1, x2, y2, x3, y3); //四边形
quad(x1, y1, x2, y2, x3, y3, x4, y4); //贝塞尔曲线
//(x1, y1)起始点 (x2, y2)终止点
//(cx1, cy1) (cx2, cy2)控制点
bezier(x1, y1, cx1, cy1 cx2, cy2, x2, y2); //自由图形
beginShape();//开始
vertex(x, y);//各节点
endShape(CLOSE);//结束绘制,闭合图形
案例:
size(300, 300);
background(50);
smooth(); //cloud
fill(255);
beginShape();
vertex(50, 180);
bezierVertex(50, 150, 80, 120, 132, 150);
bezierVertex(150, 115, 210, 135, 200, 160);
bezierVertex(270, 175, 230, 235, 170, 220);
bezierVertex(170, 250, 80, 255, 70, 220);
bezierVertex(20, 240, 25, 170, 50, 180);
endShape();
//moon
fill(255, 250, 190);
beginShape();
vertex(130, 60);
bezierVertex(250, 70, 210, 200, 130, 200);
bezierVertex(150, 190, 200, 115, 130, 60);
endShape();
效果

色彩
fill(灰阶)
fill(灰阶,透明度)
fill(R, G, B);
fill(R, G, B, alpha);//值越大,透明度越低
例子:
size(300, 300);
fill(255, 0, 0);//red
ellipse(100, 180, 130, 130);
fill(0, 255, 0);//green
ellipse(150, 100, 130, 130);
fill(0, 0, 255);//blue
ellipse(200, 180, 130, 130);
fill(255, 255, 0, 200);//
ellipse(140, 160, 60, 60);
效果

HSB色彩(百度百科)
例子
size(300, 300);
colorMode(HSB, 360, 100, 100);
fill(0, 100, 100);
rect(20, 20, 120, 50);
fill(0, 100, 50);
rect(160, 20, 120, 50); fill(120, 100, 100);
rect(20, 100, 120, 50);
fill(120, 100, 50);
rect(160, 100, 120, 50); fill(120, 50, 100);
rect(20, 180, 120, 50);
fill(120, 50, 50);
rect(160, 180, 120, 50);
效果

绘画属性
background(color)设定画布底色
fill(color)指定填充色
noFill()不填色
stroke(color)指定线条颜色
noStroke()不画线条
strokeWeight(thickness)指定边框宽度
strokeCap(mode)指定线条端点形式,SQUARE(方形端点)、PROJECT(方形延伸端点)、ROUND(圆形端点)
strokeJoin(mode)线条折角形式:MITER(尖角)、BEVEL(斜角)、ROUND(圆角)
smooth()开启平滑绘图模式
noSmooth()关闭
PDF输出
import processing.pdf.*;
size(300, 300, PDF, "test.pdf");
background(255);
smooth();
fill(100, 100 , 0);
line(20, 20, 100, 100);
效果

实例
代码:
size(300, 300);
background(255);
smooth();
noFill();
for (int i = 0; i < 75; i++) {
for (int x = 0; x < 350; x += 75) {
for (int y = 0; y < 350; y += 75) {
stroke(random(255), random(255), 255);
strokeWeight(4);
ellipse(x, y, i, i);
}
}
}
效果
Processing基础之绘画的更多相关文章
- 动态可视化 数据可视化之魅D3,Processing,pandas数据分析,科学计算包Numpy,可视化包Matplotlib,Matlab语言可视化的工作,Matlab没有指针和引用是个大问题
动态可视化 数据可视化之魅D3,Processing,pandas数据分析,科学计算包Numpy,可视化包Matplotlib,Matlab语言可视化的工作,Matlab没有指针和引用是个大问题 D3 ...
- 【重温基础】17.WebAPI介绍
本文是 重温基础 系列文章的第十七篇. 今日感受:挑战. 系列目录: [复习资料]ES6/ES7/ES8/ES9资料整理(个人整理) [重温基础]1-14篇 [重温基础]15.JS对象介绍 [重温基础 ...
- iTestSharp的简单应用
前言 最近公司某项目要针对一些信息基础表绘画成表格的形式然后生成pdf文件,在网上寻找到iTestSharp发现此类库很强大,虽然园子里已经有很多大牛写了关于此插件的使用方法,但是自己也想写一写,把自 ...
- 《Oracle Applications DBA 基础》- 9 - Concurrent Processing[Z]
<Oracle Applications DBA 基础>- 9 - Concurrent Processing================================== 参考资料 ...
- 《Oracle Applications DBA 基础》- 9 - Concurrent Processing
来自:http://www.itpub.net/thread-1411293-1-4.html <Oracle Applications DBA 基础>- 9 - Concurrent P ...
- [Qt扒手] PyQt5 基础绘画例子
[说明] 好吧,坦白从宽,我是Qt扒手(不要鄙视我).这是我根据qt官网提供的C++版本的例子(http://doc.qt.io/qt-5/qtwidgets-painting-basicdrawin ...
- Stanford NLP 学习笔记2:文本处理基础(text processing)
I. 正则表达式(regular expression) 正则表达式是专门处理文本字符串的正式语言(这个是基础中的基础,就不再详细叙述,不了解的可以看这里). ^(在字符前): 负选择,匹配除括号以外 ...
- canvas绘画基础(一):认识canvas画布
html5提供了一个<canvas>标签,结合javascript的canvas api接口可以用来绘制图形和动画.最近工作中涉及到画图的任务,下面来了解一下canvas的基础:canva ...
- WPF 基础 - 绘画 1) 线段、矩形、圆弧及填充色
1. 绘画 1.1 图形类型 Line X1.Y1.X2.Y2,Stroke,StrokeThickness Rectangle 矩形 Ellipse 椭圆 Polygon 多边形(自动闭合) Pol ...
随机推荐
- python头部注释 vim添加头部注释
1.先说说python和virtual python 一般环境下,python解释器会放在/usr/bin/ 下面,然后你执行python的时候就会运行了,但是如果没有在/usr/bin/下面的话,执 ...
- 如何查看Windows服务器运行了多长时间
前言:有时候管理.维护Windows服务器需要定期重启服务器(为什么需要重启,你懂的),但是这个"定期"有时候会受很多因素影响,例如某台服务器忘了重启:某台服务器那个时间段业务繁忙 ...
- Unshelve Instance 操作详解 - 每天5分钟玩转 OpenStack(39)
上一节我们 shelve instance 到 Glance,本节讨论如何通过 unshelve 操作恢复该 instance. 因为 Glance 中保存了 instance 的 image,uns ...
- markdown简要说明显示样式
markdown 什么是markdown: Markdown是一种可以使用普通文本编辑器编写的标记语言,通过简单的标记语法,它可以使普通文本内容具有一定的格式. Markdown具有一系列 ...
- android intent 传递list或者对象
(转:http://www.cnblogs.com/lee0oo0/archive/2012/09/24/2699805.html) 方法一: 如果单纯的传递List<String> 或者 ...
- android xml 布局错误
最近重新安装了下android开发环境,发现在调整页面的时候 ,老是报以下错误,导致无法静态显示ui效果. Missing styles. Is the correct theme chosen fo ...
- 使用Sqlserver更新锁防止数据脏读
有时候我们需要控制某条记录在程序读取后就不再进行更新,直到事务执行完释放后才可以.这时候我们就可以将所有要操作当前记录的查询加上更新锁,以防止查询后被其它事务修改.这种操作只锁定表中某行而不会锁定整个 ...
- 使用github之前的技能准备
Git的导入 介绍 Git属于分散型版本管理系统,是为版本管理而设计的软件.版本管理就是管理更新的历史记录.它为我们提供了一些在软件开发过程中必不可少的功能,例如记录一款软件添加或更改源代码的过程,回 ...
- [WPF系列-高级TemplateBinding vs RelativeSource TemplatedParent]
What is the difference between these 2 bindings: <ControlTemplate TargetType="{x:Type Button ...
- 【2016-11-2】【坚持学习】【Day17】【通过反射自动将datareader转为实体info】
通过ADO.net 查询到数据库的数据后,通过DataReader转为对象Info public class BaseInfo { /// <summary> /// 填充实体 /// & ...