{"id":20469086,"url":"https://github.com/ghosts6/matrix","last_synced_at":"2026-04-19T00:31:50.317Z","repository":{"id":221562529,"uuid":"754739965","full_name":"Ghosts6/matrix","owner":"Ghosts6","description":"matrix animation with c++ cmd bash and html/js","archived":false,"fork":false,"pushed_at":"2024-02-10T00:38:49.000Z","size":26,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-16T01:49:38.991Z","etag":null,"topics":["bash","batch","cpp","html-css-javascript","matrix"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ghosts6.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-02-08T17:16:14.000Z","updated_at":"2024-09-14T08:01:53.000Z","dependencies_parsed_at":"2024-02-08T18:39:19.236Z","dependency_job_id":"8258a397-09c5-4379-b7d1-4653aa89e8b9","html_url":"https://github.com/Ghosts6/matrix","commit_stats":null,"previous_names":["ghosts6/matrix"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghosts6%2Fmatrix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghosts6%2Fmatrix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghosts6%2Fmatrix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghosts6%2Fmatrix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ghosts6","download_url":"https://codeload.github.com/Ghosts6/matrix/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242031698,"owners_count":20060627,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","batch","cpp","html-css-javascript","matrix"],"created_at":"2024-11-15T14:07:55.279Z","updated_at":"2026-04-19T00:31:48.642Z","avatar_url":"https://github.com/Ghosts6.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"![baner](https://github.com/Ghosts6/Local-website/blob/main/img/Baner.png)\n\n# 💻matrix:\n\nin this repo i create matrix animation with language like bash ,bat script,c++ and html/js\n\n\u003cimg width=\"1470\" alt=\"Screenshot 2024-02-08 at 8 58 33 PM\" src=\"https://github.com/Ghosts6/matrix/assets/95994481/6c99fd39-4361-4460-8816-3f159eee78e2\"\u003e\n\n# Bash\u0026bat:\n\n\nin this section we have some simple code with bash and cmd  that create basic version of matrix animation\n\nbash:\n```bash\n#!/bin/bash\n\nclear\necho \"\"\necho -e \"\\e[32m\"  \n\nwhile true; do\n    echo \"$RANDOM $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM\"\ndone\n```\ncmd:\n```bat\necho.\ncolor 0a\ntitle matrix\n:(variable)\necho %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% \ngoto(variable)\n```\n\n# C++:\n\nfor c++ i create two version of matrix in first version user have some accessablity like choosing color and word for matrix animation but on second version instead of getting input from user i work on code and some other feature like changeing color , random words and etc \n\nmatrix.cpp\n```cpp\n#include \u003ciostream\u003e\n#include \u003cncurses.h\u003e\n#include \u003ccstdlib\u003e\n#include \u003cctime\u003e\n#include \u003ccstring\u003e\n\nusing namespace std;\n\nconst int WORD_LENGTH = 5;\nconst int WORD_SPEED = 100;\nconst int MATRIX_COLS = 80;\nconst int MATRIX_ROWS = 24;\n\nclass MatrixWord {\nprivate:\n    int x;\n    int y;\n    char word[WORD_LENGTH + 1];\n\npublic:\n    MatrixWord(int x, int y, const char* word) : x(x), y(y) {\n        strncpy(this-\u003eword, word, WORD_LENGTH);\n        this-\u003eword[WORD_LENGTH] = '\\0'; \n    }\n\n    void move() {\n        y++;\n        if (y \u003e= LINES) {\n            y = 0;\n            x = rand() % COLS;\n        }\n    }\n\n    void draw() {\n        attron(COLOR_PAIR(1));\n        for (size_t i = 0; i \u003c strlen(word); i++) {\n            mvprintw(y + i, x, \"%c\", word[i]);\n        }\n        attroff(COLOR_PAIR(1));\n    }\n};\n\nclass MatrixAnimation {\nprivate:\n    int numWords;\n    MatrixWord** words;\n\npublic:\n    MatrixAnimation(int numWords, const char* word) : numWords(numWords) {\n        words = new MatrixWord*[numWords];\n        for (int i = 0; i \u003c numWords; i++) {\n            int x = rand() % COLS;\n            int y = rand() % LINES;\n            words[i] = new MatrixWord(x, y, word);\n        }\n    }\n\n    ~MatrixAnimation() {\n        for (int i = 0; i \u003c numWords; i++) {\n            delete words[i];\n        }\n        delete[] words;\n    }\n\n    void update() {\n        clear();\n        for (int i = 0; i \u003c numWords; i++) {\n            words[i]-\u003emove();\n            words[i]-\u003edraw();\n        }\n        refresh();\n        napms(WORD_SPEED);\n    }\n};\n\nint main() {\n    srand(time(NULL));\n\n    initscr();\n    curs_set(0);\n    start_color();\n    timeout(0);\n    keypad(stdscr, true);\n\n    string color_choice;\n    mvprintw(0, 0, \"Welcome to our matrix project\");\n    mvprintw(1, 0, \"Please select color (green, blue, red, white): \");\n    refresh();\n    cin \u003e\u003e color_choice;\n\n    init_pair(1, COLOR_GREEN, COLOR_BLACK);\n\n    if (color_choice == \"green\") {\n        init_pair(1, COLOR_GREEN, COLOR_BLACK);\n    } else if (color_choice == \"blue\") {\n        init_pair(1, COLOR_BLUE, COLOR_BLACK);\n    } else if (color_choice == \"red\") {\n        init_pair(1, COLOR_RED, COLOR_BLACK);\n    } else if (color_choice == \"white\") {\n        init_pair(1, COLOR_WHITE, COLOR_BLACK);\n    } else {\n        mvprintw(2, 0, \"Invalid color choice. Defaulting to green.\");\n    }\n\n    char word[WORD_LENGTH + 1];\n    string choice;\n    mvprintw(3, 0, \"Do you want to use a custom word? (yes/no): \");\n    refresh();\n    cin \u003e\u003e choice;\n\n    if (choice == \"Yes\" || choice == \"yes\") {\n        mvprintw(4, 0, \"Enter the word you want to use: \");\n        refresh();\n        cin \u003e\u003e word;\n    } else {\n        strncpy(word, \"MATRIX\", WORD_LENGTH);\n        word[WORD_LENGTH] = '\\0';\n    }\n\n    MatrixAnimation matrixAnimation(10, word);\n\n    int ch;\n    while ((ch = getch()) != 'q') {\n        matrixAnimation.update();\n        if ((ch = getch()) != ERR) {\n            ungetch(ch);\n        }\n    }\n    endwin();\n\n    return 0;\n}\n```\nmatrix_v2.cpp\n```cpp\n#include \u003ciostream\u003e\n#include \u003cncurses.h\u003e\n#include \u003ccstdlib\u003e\n#include \u003cctime\u003e\n#include \u003ccstring\u003e\n#include \u003cvector\u003e\n#include \u003cunistd.h\u003e\n\nusing namespace std;\n\nconst int WORD_LENGTH = 20;\nconst int WORD_SPEED = 100;\nconst int COLOR_CHANGE_INTERVAL = 1000;\nconst int MATRIX_COLS = 80;\nconst int MATRIX_ROWS = 45;\n\nclass MatrixWord {\nprivate:\n    int x;\n    int y;\n    char word[WORD_LENGTH + 1];\n    int colorPair;\n    int lastColorChangeTime;\n\npublic:\n    MatrixWord(int x, int y, const char* word, int colorPair) : x(x), y(y), colorPair(colorPair), lastColorChangeTime(0) {\n        strncpy(this-\u003eword, word, WORD_LENGTH);\n        this-\u003eword[WORD_LENGTH] = '\\0';\n    }\n\n    void move() {\n        y++;\n        if (y \u003e= LINES) {\n            y = 0;\n            x = rand() % COLS;\n        }\n    }\n\n    void draw() {\n        attron(COLOR_PAIR(colorPair));\n        for (size_t i = 0; i \u003c strlen(word); i++) {\n            mvprintw(y + i, x, \"%c\", word[i]);\n        }\n        attroff(COLOR_PAIR(colorPair));\n    }\n\n    void setColor(int newColor) {\n        colorPair = newColor;\n    }\n\n    int getLastColorChangeTime() const {\n        return lastColorChangeTime;\n    }\n\n    void updateLastColorChangeTime(int currentTime) {\n        lastColorChangeTime = currentTime;\n    }\n};\n\nclass MatrixAnimation {\nprivate:\n    int numWords;\n    vector\u003cMatrixWord*\u003e words;\n    int currentColor;\n\npublic:\n    MatrixAnimation(int numWords, const char* wordChars) : numWords(numWords), currentColor(1) {\n        for (int i = 0; i \u003c numWords; i++) {\n            int x = rand() % COLS;\n            int y = rand() % LINES;\n\n            char randomWord[WORD_LENGTH + 1];\n            for (int j = 0; j \u003c WORD_LENGTH; j++) {\n                randomWord[j] = wordChars[rand() % strlen(wordChars)];\n            }\n            randomWord[WORD_LENGTH] = '\\0';\n\n            words.push_back(new MatrixWord(x, y, randomWord, currentColor));\n        }\n    }\n\n    ~MatrixAnimation() {\n        for (auto word : words) {\n            delete word;\n        }\n    }\n\n    void update() {\n        clear();\n        int currentTime = static_cast\u003cint\u003e(time(nullptr) * 1000);\n\n        for (auto word : words) {\n            word-\u003emove();\n            word-\u003edraw();\n\n            if (currentTime - word-\u003egetLastColorChangeTime() \u003e= COLOR_CHANGE_INTERVAL * 1000) {\n                word-\u003esetColor(currentColor);\n                word-\u003eupdateLastColorChangeTime(currentTime);\n            }\n        }\n\n        refresh();\n        napms(WORD_SPEED);\n    }\n\n    void changeColor() {\n        currentColor = (currentColor % 4) + 1;\n    }\n};\n\nvoid initColorPairs() {\n    start_color();\n    init_pair(1, COLOR_GREEN, COLOR_BLACK);\n    init_pair(2, COLOR_RED, COLOR_BLACK);\n    init_pair(3, COLOR_BLUE, COLOR_BLACK);\n    init_pair(4, COLOR_MAGENTA, COLOR_BLACK);\n}\n\nint main() {\n    srand(time(nullptr));\n\n    initscr();\n    curs_set(0);\n    timeout(0);\n    keypad(stdscr, true);\n\n    const char* wordChars = \"ABCDEFGHIJKMLN123456\";\n\n    int numWords = 20;\n\n    initColorPairs();\n\n    MatrixAnimation matrixAnimation(numWords, wordChars);\n\n    while (true) {\n        matrixAnimation.update();\n        usleep(10000);\n        matrixAnimation.changeColor();\n    }\n\n    endwin();\n\n    return 0;\n}\n```\n\n\n# html/js/css:\n\ni also created matrix animation with help of frontend tools(html/css/js) and here you can take closer look to source code of it\n\nhtml:\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml len=\"en\"\u003e\n\u003chead\u003e\n    \u003clink rel=\"stylesheet\" href=\"matrix.css\"\u003e\n    \u003cmeta charset=\"UTF-8\"\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"\u003e   \n    \u003ctitle\u003eMatrix\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003ccanvas\u003e        \n    \u003c/canvas\u003e\n    \u003cscript src=\"matrix.js\"\u003e\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\njs:\n```js\nvar canvas = document.querySelector('canvas'),\n    ctx = canvas.getContext('2d');\n\ncanvas.width = window.innerWidth;\ncanvas.height = window.innerHeight;\n\nvar template = '\"ABCDEFGHIJKLMNOPQRSTUVXYZ123456789ABCDEFGHIJKLMNOPQRSTUVXYZ123456789\\\nABCDEFGHIJKLMNOPQRSTUVXYZ123456789ABCDEFGHIJKLMNOPQRSTUVXYZ123456789ABCDEFGHIJKLMNOP\\\nQRSTUVXYZ123456789ABCDEFGHIJKLMNOPQRSTUVXYZ123456789\";';\ntemplate = template.split('');\n\nvar fontSize = 14,\n    columns = canvas.width / fontSize;\n\nvar drops = [];\nfor (var i = 0; i \u003c columns; i++) {\n    drops[i] = 1;\n}\n\nvar colors = ['#00f', '#0f0', '#f00', '#800080'];\nvar currentColor = 0;\n\nfunction draw() {\n    if (Math.floor(Date.now() / 10000) % 4 === 0) {\n        currentColor = 0;\n    } else if (Math.floor(Date.now() / 10000) % 4 === 1) {\n        currentColor = 1;\n    } else if (Math.floor(Date.now() / 10000) % 4 === 2) {\n        currentColor = 2;\n    } else {\n        currentColor = 3;\n    }\n\n    ctx.fillStyle = 'rgba(0, 0, 0, .1)';\n    ctx.fillRect(0, 0, canvas.width, canvas.height);\n\n    for (var i = 0; i \u003c drops.length; i++) {\n        var text = template[Math.floor(Math.random() * template.length)];\n        ctx.fillStyle = colors[currentColor];\n        ctx.fillText(text, i * fontSize, drops[i] * fontSize);\n        drops[i]++;\n\n        if (drops[i] * fontSize \u003e canvas.height \u0026\u0026 Math.random() \u003e .95) {\n            drops[i] = 0;\n        }\n    }\n}\n\nsetInterval(draw, 33);\n```\ncss:\n```css\nbody{\n    background-color: black ;\n    background-size: 100% 100%;\n    background-attachment: fixed;\n}\n```\n\n\n# ▶video:\n\n[Screen Recording 2024-02-10 at 3.58.53 AM.webm](https://github.com/Ghosts6/matrix/assets/95994481/41938aa6-53e8-4fe9-86cc-ae505271f9af)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghosts6%2Fmatrix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghosts6%2Fmatrix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghosts6%2Fmatrix/lists"}