05 Function

1 Rain in Colors

var drops = [];

function setup() {
  createCanvas(640, 360);
  for (var i = 0; i < 500; i++) {
    drops[i] = new Drop();
  }
}

function draw() {
  background(230, 230, 250);
  for (var i = 0; i < drops.length; i++) {
    drops[i].fall();
    drops[i].show();
  }
}

function Drop() {
  this.x = random(width);
  this.y = random(-500, -50);
  this.z = random(0, 20);

  this.fall = function() {
    this.y = this.y + 2;
    if (this.y > height) {
      this.y = random(-200, -100);
    }
  };

  this.show = function() {
    var thick = map(this.z, 0, 20, 1, 3);
    strokeWeight(thick);

    stroke(random(255), random(255), random(255));
    line(this.x, this.y, this.x, this.y + 4);
  };
}

P5Editor

You can find the rain drops are blinking now. Please change them to fixed colors.

2 TIXY: Create code by code

let code = '';
let cnt = 16;
let nums = [];
let numsOld = [];

function setup() {
  createCanvas(360, 360);
}

function draw() {
  background(50);
  translate(30, 30);
  noStroke();

  for (let x = 0; x < cnt; x++) {
    for (let y = 0; y < cnt; y++) {
      let r = play(deltaTime/1000, x * cnt + y, x, y);
      r = r > 1 ? 1 : r;
      r = r < -1 ? -1 : r;
      r > 0 ? fill(255, 0, 0) : fill(255, 255, 255);
      circle(x * 20, y * 20, abs(r) * 20);
      nums[x * cnt + y] = r;
    }
  }
  stroke(255, 255, 255);
  fill(255, 255, 255)
  text(code, 100, 320);

  let fcNum = fc(nums);
  if (isNaN(fcNum)) {
    code = '';
  }
  if (fc(nums) == 0) {
    code = '';
  }

  let isAnimation = false;
  if (numsOld.length > 0) {
    for (let i = 0; i < nums.length; i++) {
      if (nums[i] != numsOld[i]) {
        isAnimation = true;
        break;
      }
    }
    if (isAnimation == false) {
      code = '';
    }
  }

  numsOld = nums;
  nums = [];
}


function mouseClicked() {
  code = '';
}

function play(t, i, x, y) {
  let success = false;
  let result;
  if (code.length > 0) {
    return eval(code);
  }
  while (!success) {
    code = makeCode();
    try {
      result = eval(code);
      success = true;
      console.log(code);
    } catch (error) {
      //console.log(code + " Not runable");
    }
  }
  return result;
}

let words = [
  '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
  't', 'i', 'x', 'y',
  'PI', 'sin(', 'cos(', 
  //'abs(', 'pow(', 'sqrt(',
  'random(', '/', 
  '(', ')', '[', ']', '.', ',',
  '+', '-', '*', '%', '&', '|', 
  //'<', '>', '<=', '>=',
]

function makeCode() {
  let result = '';
  while (result.length < 12) {
    result = result + random(words);
  }
  return result;
}


function fc(arr) {
  let s,
    ave,
    sum = 0,
    sums = 0,
    len = arr.length;
  for (let i = 0; i < len; i++) {
    sum += arr[i];
  }
  ave = sum / len;
  for (let i = 0; i < len; i++) {
    sums += (arr[i] - ave) * (arr[i] - ave)
  }
  s = (sums / len).toFixed(4);
  return s;
}

P5Editor

Code generated:

P5Editor