(一)利用processing创建基本图形

本文介绍了如何在Processing环境中创建一个窗口并绘制基本图形。通过编程实现,展示了绘制图形的简单步骤,包括设置画布、绘制直线、矩形、圆形等。
摘要由CSDN通过智能技术生成

创建一个窗口并在窗口上绘制基本的形状:

class DrawShape{
  DrawShape(){
  }
  void draw_line(){
    int R = int(random(255));
    int G = int(random(255));
    int B = int(random(255));
    stroke(R, G, B, 255);
    if(mousePressed){
      line(10, height/5, width/3-10, height/5);
    }
  }
  void draw_triangle(){
    int R = int(random(255));
    int G = int(random(255));
    int B = int(random(255));
    stroke(R, G, B, 255);
    if(mousePressed){
      noFill();
      triangle(width/2, height/8, width/1.5-10, height/3, width/3 + 10, height/4 + 10);
    }
  }
  void draw_quadrangle(){
    int R = int(random(255));
    int G = int(random(255));
    int B = int(random(255));
    stroke(R, G, B);
    if(mousePressed){
      fill(192, 64, 0);
      quad(2*width/3 + 50, height/10, width-20, height/9+10, width-20, 3*height/9, 2*width/3&#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值