zoukankan      html  css  js  c++  java
  • Processing编程【2】

    彩虹下的小车

    int  x=0, y=height;
    void setup() {
      size(500, 500);
    }
    void draw() {
      int i;
      int X=0;
      background(0, 0, 255);
      for (i=1000; i>=650; i-=50, X+=37)
      {
        colorMode(HSB, 360, 255, 100);
        stroke(X, 255, 100);
        strokeWeight(50);
        fill(0, 0, 255);
        ellipse(width, height, i, i);
      }
      drawCar(x, height-20, 20);
      x++;
      if (x > width+20) x = 0;
    }
    
    void drawCar(int posx, int posy, int thesize)
    {
      rectMode(CENTER);
      stroke(0);
      rect(posx, posy-20, thesize, thesize / 14);
    
      int offset = 20;
      drawWheel(posx - offset, posy - offset+30, offset);
      drawWheel(posx + offset, posy - offset+30, offset);
    }
    
    // Draw a wheel at (posx, posy) and use offset to 
    // determine its size.
    
    void drawWheel (int posx, int posy, int offset)
    {
      noStroke();
      fill(0);
      ellipse (posx, posy,offset, offset);
    }

    这里写图片描述

    水波模拟

    float r=0, r2=0, r3=0, r4=0;
    float c=0, c2=0, c3=0, c4=0;
    void setup()
    {
      size(600, 600);
      background(255);
    }
    void draw()
    {
    
      noStroke();
      frameRate(70);
    
      fill(c);
      ellipse(width/2, height/2, r+10, r+10);
      fill(255);
      ellipse(width/2, height/2, r, r);
      c=c+1;
      r=r+1;
      //while(r>50)
      //{
      if (r>50)
      {
        fill(c2);
        ellipse(width/2, height/2, r2+10, r2+10);
        fill(255);
        ellipse(width/2, height/2, r2, r2);
        c2=c2+0.7;
        r2=r2+1;
      }
      if (r2>50)
      {
        fill(c3);
        ellipse(width/2, height/2, r3+10, r3+10);
        fill(255);
        ellipse(width/2, height/2, r3, r3);
        c3=c3+0.7;
        r3=r3+1;
      }
      if (r3>50)
      {
        fill(c4);
        ellipse(width/2, height/2, r4+10, r4+10);
        fill(255);
        ellipse(width/2, height/2, r4, r4);
        c4=c4+0.7;
        r4=r4+1;
      }
    }

    这里写图片描述

    几何连线

    float w=0, h=0;
    int i, j, k,X=0;
    void setup()
    {
      background(255);
      size(500, 500);
      drawline();
    }
    
    void drawline() {
      for (k=1; k<=4; k++,X+=60) 
      {
        for (i=1; i<=2; i++)
        {
          for (j=1; j<=2; j++)
          {
            strokeWeight(4);
            colorMode(HSB, 360, 255, 100);
            stroke(X, 255, 100);
            line(width*i/3, w, h, height*j/3);
          }
        }
        if(k==1){h=0;w=width;}
        if(k==2){w=0;h=height;}
        if(k==3){w=width;h=height;}
      }
    }

    这里写图片描述

  • 相关阅读:
    zzuli--2134: 维克兹的进制转换(规律)
    hdu--1316--How Many Fibs?(java大数)
    NYOJ--517--最小公倍数(大数打表)
    NYOJ--513--A+B Problem IV(大数)
    NYOJ--45--棋盘覆盖(大数)
    NYOJ--114--某种序列(大数)
    HAUT--1262--魔法宝石(暴力)
    NYOJ--1276--机器设备(河南省第九届省赛,简单的bfs)
    hdu--1429--胜利大逃亡(续) (bfs+状态压缩)
    NYOJ--541--最强DE 战斗力(递推)
  • 原文地址:https://www.cnblogs.com/hitWTJ/p/9865447.html
Copyright © 2011-2022 走看看