Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

matrix effect

#Open terminal
sudo apt-get install cmatrix
cmatrix
Comment

matrix effect

Letter l = new Letter(150, 15, 1.5);

void setup(){
  size(300, 300);
}

void draw(){
  background(0);
  l.display();
}

class Letter{
   PVector pos;
  float speed;
  String letter;
  float change_threshold = 0.1;
  color cor = color (3, 160, 98);
  String character = "";
  // maximum letters in a string
  int maxLetters = 35;
  // which character to swap
  int charIndex = 0;

  Letter (float xpos, float ypos, float vel) {
    for (int i = 0; i < maxLetters; i++) {
      character +=getRandomLetter() +"
";
    }
    this.pickLetter();
    pos = new PVector (xpos, ypos);
    speed = vel;
  }

  void display() {
    
    fill(this.cor);
    text(this.letter, this.pos.x, this.pos.y);
    float p = random(1);
    if (p < this.change_threshold && this.cor != color(255)) {
      this.pickLetter();
    }
  }

  void pickLetter() {

    //String character = str (floor (random(10)));
    //String character = new String ("a");
    //character += char (int(random(65, 65+24)));
    char randomChar = getRandomLetter();
    character = setCharAt(character, randomChar, charIndex);
    charIndex = (charIndex + 2)%character.length();
    this.letter = character;
  }


  void fall() {
    this.pos.y += this.speed;
  }

  // returns a random a-z char
  char getRandomLetter() {
    return char (int(random(65, 65+24)));
  }

  // return a new string with a char swapped at the given index
  String setCharAt(String myString, char myNewChar, int myCharIndex) {
    return myString.substring(0, myCharIndex) + myNewChar + myString.substring(myCharIndex + 1);
  }
}
Comment

PREVIOUS NEXT
Code Example
Shell :: tbomb github 
Shell :: How to download git for linux and unix 
Shell :: run sh from terminal mac 
Shell :: poetry install 
Shell :: windows find node path 
Shell :: git revert commit but keep changes 
Shell :: undo last commit git 
Shell :: tmu rename tab 
Shell :: how to install vim through powershell 
Shell :: best audio visualiser for linux 
Shell :: wsl restart 
Shell :: nuxt install 
Shell :: ffmpeg add two videos together 
Shell :: scp all files in directory 
Shell :: kill wine process 
Shell :: cannot find module json-loader 
Shell :: ubuntu activate bluetooth 
Shell :: undo airmon-ng check kill 
Shell :: remove bar in browser in ubuntu 
Shell :: downgrade cocoapods in mac m1 
Shell :: bash hide file 
Shell :: valgrind memory leak 
Shell :: how to remove a directory in git 
Shell :: linux go to home directory 
Shell :: bash vim how to append text to every line 
Shell :: script to kill a process in windows 
Shell :: search commit git 
Shell :: git diff between local and remote branch 
Shell :: nvm change node version 
Shell :: show ip address linux 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =