zoukankan      html  css  js  c++  java
  • Processing函数与循环

    函数的定义

    返回类型 函数名称 (引数) {

    //函数的代码

    }

    如下面描绘熊猫的代码

    void setup() {

      size(900,300);

      smooth();

    }

    void draw() {

      background(200);

      for (int x=60;x<width;x+=110) {

        for (int y=50;y<height;y+=100) {

          panda(x,y);

        }

      }

    }

    void panda(int x,int y) {

      pushMatrix();

      translate(x,y);

      //耳朵

      fill(0);

      strokeWeight(1);

      ellipse(-35,-25,35,35);

      ellipse(35,-25,35,35);

      //头部

      fill(255);

      strokeWeight(0);

      ellipse(0,0,100,90);

      //眼睛

      fill(0);

      ellipse(-25,5,30,35);

      ellipse(25,5,30,35);

      fill(255);

      ellipse(-25,0,6,6);

      ellipse(25,0,6,6);

      //鼻子

      fill(0);

      ellipse(0,25,7,5);

      //嘴巴

      noFill();

      stroke(0);

      strokeWeight(1);

      bezier(-2.5,35,-2.5,37,2.5,37,2.5,35);

      popMatrix();

    }

    使用for语句和函数,绘制多个熊猫

  • 相关阅读:
    2020/5/18
    2020/5/17
    2020/5/15
    2020/5/13
    2020/5/12
    服务器环境配置五大免费主机系统
    6:运算符
    5:练习题
    4:Python的while循环
    3:Python条件语句
  • 原文地址:https://www.cnblogs.com/djcsch2001/p/2200226.html
Copyright © 2011-2022 走看看