-
准备工作
- 这一步只是我强迫症犯了哈,这个随意,画几根线而已。每一小格10个像素,中格50,大格100像素
-
void setup()
{
size(,);
} void draw()
{
background(,,);
//translate(width/2,height/2);
Aix(,,width,height,);
Aix(,,width,height,);
Aix(,,,,);
Aix(,,,,);
stroke();
strokeWeight();
line(-width,, width,);
line(,-height, ,height); DrawText();
} float weight = ;
float del = ;
float lonW = ;
float lonH = ;
void Aix(float w,float d,float lw,float lh,float st)
{
weight = w;
del = d;
lonW = lw;
lonH = lh;
stroke(st);
strokeWeight(weight);
for(int i = ;i <= width;i+=del)
{
line(i,-lonH, i,lonH);
}
for(int i = ;i >= -width;i-=del)
{
line(i,-lonH, i,lonH);
}
for(int i = ;i <= height;i+=del)
{
line(-lonW,i, lonW,i);
}
for(int i = ;i >= -height;i-=del)
{
line(-lonW,i, lonW,i);
}
} void DrawText()
{ }
- 打印文字
-
text(String str,float x,float y[,float z]);//在某位置显示文本,默认为白色的文本,可用 fill() 方法填充颜色
text(char[] chars,int start,int end,float x,float y[,float z]);
text(String str,float x1,float y1,float x2,float y2);//在两个点决定的矩形内显示字符串
text(float num,float x,float y[,float z]);void DrawText()
{
String str = "Hello World";
text(str,,);
} - 默认文字是白色的,所以如果一开始背景是浅色的话回看不清楚,这一点要注意。可用用 fill(); 方法改变颜色
-
- 字体大小
-
void DrawText()
{
String str = "Hello World"; textSize();//修改字体大小
text(str,,);
} - 对其方式
- textAlign(h[,o]); 其中,h表示水平对齐方式,o表示垂直对齐方式,可填入宏
- h
- RIGHT 右对齐
- CENTER
- LEFT
- o
- TOP
- CENTER
- BOTTOM
- BASELINE 基线对齐
- h
-
void DrawText()
{
String str = "Hello World"; noFill();
stroke(#E0A000);
rect(,, ,);//画矩形 textSize();
textAlign(RIGHT,BOTTOM);//右下对齐
text(str,,, ,);//在一个矩形内显示
}
- textAlign(h[,o]); 其中,h表示水平对齐方式,o表示垂直对齐方式,可填入宏
- 设置行高
-
void DrawText()
{
String str = "Hello World\nWorld Hello"; noFill();
stroke(#E0A000);
rect(,, ,); textSize();
textLeading();
text(str,,, ,);
textLeading();
text(str,,, ,);
textLeading();
text(str,,, ,);
}
-
-
文本宽度
-
void DrawText()
{
String str = "Hello World\nWorld Hello"; noFill();
stroke(#E0A000);
rect(,, ,); textSize();
textLeading();
text(str,,, ,); //画一个框把一行文字框起来
stroke(#FFFFCC);
line(,, textWidth(str),);//用到了获取字符串宽度的方法 textWidth()
line(,, textWidth(str),); stroke(#EECCEE);
line(,, ,);
line(textWidth(str),, textWidth(str),);
}
-
相关文章
- [MFC]SDI在图片背景上实现文本跟随鼠标移动
- Coding theano under remote ubuntu server from local Mac (在本地mac机器上,写、跑、调试、看-远程ubuntu上的theano代码)
- 在eclipse上写代码的时候,tomcat突然不能用了,重启都是闪一下就关了
- U-Boot在FL2440上移植(四)----支持网卡DM9000和烧写yaffs文件系统
- Swift可以在Windows系统上写程序了
- DataGridView 在指定的单元格上添加居中文本,以及获取指定单元格X,Y,坐标,高度宽度,以及行加上序号
- 在云服务器上搭建JSP环境并发布web项目(通过域名访问自己写的项目)
- Visual Studio写的项目在 IIS 服务器上运行的两种简单方法
- 在VMware上,ubuntu20.04和windows之间如何复制与粘贴文本?
- [编译] 7、在Linux下搭建安卓APP的开发烧写环境(makefile版-gradle版)—— 在Linux上用命令行+VIM开发安卓APP