{"id":17968557,"url":"https://github.com/abdur-rahmaanj/ppython","last_synced_at":"2025-03-25T10:32:22.200Z","repository":{"id":35484854,"uuid":"202482129","full_name":"Abdur-rahmaanJ/ppython","owner":"Abdur-rahmaanJ","description":"Implementation of processing.org's processing in pure python. No dependency, no import and no run()","archived":false,"fork":false,"pushed_at":"2023-11-24T22:00:35.000Z","size":5750,"stargazers_count":43,"open_issues_count":1,"forks_count":38,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-19T20:23:56.898Z","etag":null,"topics":["p5js","processing","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Abdur-rahmaanJ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"publiccode":null,"codemeta":null}},"created_at":"2019-08-15T05:54:00.000Z","updated_at":"2025-02-16T12:48:09.000Z","dependencies_parsed_at":"2024-10-29T15:03:37.194Z","dependency_job_id":null,"html_url":"https://github.com/Abdur-rahmaanJ/ppython","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abdur-rahmaanJ%2Fppython","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abdur-rahmaanJ%2Fppython/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abdur-rahmaanJ%2Fppython/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abdur-rahmaanJ%2Fppython/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Abdur-rahmaanJ","download_url":"https://codeload.github.com/Abdur-rahmaanJ/ppython/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245444266,"owners_count":20616347,"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":["p5js","processing","python"],"created_at":"2024-10-29T14:40:43.479Z","updated_at":"2025-03-25T10:32:19.012Z","avatar_url":"https://github.com/Abdur-rahmaanJ.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ppython\n\nImplementation of [processing.org](https://www.processing.org)'s processing in pure python (processing.py runs on jython, this one runs on **pure** python). No dependency, no import and no run().\n\n# Info\n\nRelease name: **omri**\n\nStability: alpha, highly volatile, more to be completed\n\n# Running\n\n```\ncd ppython/ppython\npython ppython.py \u003cpath-to-file\u003e/file.py \u003cheight\u003e \u003cwidth\u003e\n```\n\n# History\n\nHad this project lying around. Removed it from the fossils graveyard when Dr. Omri Har-Shemesh came to our Python meetup. I was inspired by his high physics background, I was reminded of this in my cupboard and decided to open it to the world.\n\nPlease don't see the source code (ppython.py) else you'll chase me out of the Python kingdom.\n\n# Why a pure python version?\n\nTo simply take advantage of the huge number of machine learning, data science and normal packages available.\n\n# How is this different from p5py?\n\n-   no dependency\n\nrequires only tkinter\n\n-   no imports\n\nyou only run your code as it should. no from x import \\*\n\n-   no run()\n\nno need to call run() at the end\n\n# Dependencies\n\n```python\n\u003e\u003e\u003e dependencies is None\nTrue\n```\n\nAbsolutely no dependency.\n\n# Gallery\n\nHere are some snippets:\n\n## Sound Bars\n\n```\npython ppython.py snippets/soundbars.py\n```\n\n![](ppython/images/ppython_soundbars.gif)\n\ncode:\n\n```python\ndef setup():\n    pass\n\ndef draw():\n    background(255, 255, 255)\n    for i in range(20):\n        ry = random(2, 10)*10\n        fill(i*10, 100, 20)\n        rect(10 + i*10, 150-ry, 10, ry)\n        fill(255, 0, 0)\n```\n\n## Microsoft Logo\n\n```\npython ppython.py snippets/winlogo.py\n```\n\n![](ppython/images/ppython_winlogo.jpg)\n\ncode:\n\n```python\ndef setup():\n    size = 100\n    noStroke()\n\n    fill(245, 80, 35)\n    rect(10, 10, size, size)\n\n    fill(125, 185, 0)\n    rect(120, 10, size, size)\n\n    fill(0, 160, 240)\n    rect(10, 120, size, size)\n\n    fill(255, 185, 0)\n    rect(120, 120, size, size)\n\ndef draw():\n    pass\n```\n\n## Paint\n\n```\npython ppython.py snippets/paint.py\n```\n\n![](ppython/images/ppython_paint.gif)\n\ncode:\n\n```python\ndef setup():\n    pass\n\ndef draw():\n    fill(255, 0, 0)\n    ellipse(mouseX, mouseY, 20, 20)\n```\n\n## Line Graph\n\n```\npython ppython.py snippets/line_graph.py\n```\n\n![](ppython/images/ppython_linegraph.jpg)\n\ncode:\n\n```python\ncoords = [\n    (20, 30),\n    (50, 35),\n    (80, 40),\n    (110, 50),\n    (130, 70),\n    (150, 90),\n    (180, 110),\n    (210, 120),\n    (240, 150),\n    (270, 200)\n]\n\ndef setup():\n    global coords\n    noStroke()\n    for coord in coords:\n        x = coord[0]; y = coord[1]\n        fill(255, 175, 150)\n        ellipse(x-5, y-5, 10, 10)\n    stroke(255, 175, 150)\n    strokeSize(3)\n    for i, coord in enumerate(coords):\n        if i+1 \u003c len(coords):\n            x = coord[0]; y = coord[1]\n            x2 = coords[i+1][0]; y2 = coords[i+1][1]\n            line(x, y, x2, y2)\n\ndef draw():\n    pass\n```\n\n## Brownian Motion\n\n```\npython ppython.py snippets/brownian_motion.py\n```\n\n![](ppython/images/ppython_brownian_motion.gif)\n\ncode:\n\n```python\nclass Particle:\n    def __init__(self, x, y, r=10, vx=1, vy=1, randv=False):\n        self.x = x\n        self.y = y\n        self.r = r\n        self.vx = vx\n        self.vy = vy\n\n        if randv:\n            rand1 = random(0, 1)\n            rand2 = random(0, 1)\n            if rand1:\n                self.vx *= -1\n            if rand2:\n                self.vy *= -1\n\n\n    def draw(self):\n        noStroke()\n        fill(140,70,20)\n        ellipse(self.x, self.y, self.r, self.r)\n\n    def update(self):\n        self.x += self.vx\n        self.y += self.vy\n\n    def check_bounds(self):\n        global width\n        if self.x \u003e width-self.r or self.x-self.r \u003c 0:\n            self.vx *= -1\n        if self.y \u003e height-self.r or self.y-self.r \u003c 0:\n            self.vy *= -1\n\n    def run(self):\n        self.update()\n        self.check_bounds()\n        self.draw()\n\nparticles = [Particle(\n                random(0, width), random(0, width), vx=2, vy=2, randv=True)\n            for i in range(200)]\ndef setup():\n    pass\n\ndef draw():\n    global particles\n    background(255, 255, 255)\n    for p in particles:\n        p.run()\n```\n\n## Grid Triangles\n\n```\npython ppython.py snippets/rand_triangles.py\n```\n\n![](ppython/images/ppython_rand_triangles.jpg)\n\ncode:\n\n```python\ndef triangle(x1, y1, x2, y2, x3, y3):\n    beginShape()\n    vertex(x1, y1)\n    vertex(x2, y2)\n    vertex(x3, y3)\n    endShape()\n\ndef setup():\n    background(255)\n    noStroke()\n    for x in range(0, width, 50):\n        for y in range(0, width, 50):\n            fill(random(0, 255), random(0, 255), random(0, 255))\n            triangle(\n                random(x, x+50),\n                random(y, y+50),\n                random(x, x+50),\n                random(y, y+50),\n                random(x, x+50),\n                random(y, y+50)\n                )\n\ndef draw():\n    pass\n```\n\n## Eyes\n\n```\npython ppython.py snippets/eyes.py\n```\n\n![](ppython/images/ppython_eyes.jpg)\n\ncode:\n\n```python\ndef setup():\n    size = 100\n    noStroke()\n\n    fill(255)\n    stroke(0)\n    ellipse(150, 150, 100, 200)\n    fill(255)\n    ellipse(250, 150, 100, 200)\n\n    fill(0)\n    ellipse(225, 250, 25, 25)\n    ellipse(325, 250, 25, 25)\n\ndef draw():\n    pass\n```\n\n## Random Stroke\n\n```\npython ppython.py snippets/random_stroke.py\n```\n\n![](ppython/images/random-stroke.gif)\n\n\u003e code:\n\n```python\ndef setup():\n    background(0)\n    strokeSize(20)\n    for w in range(width):\n        stroke(random(0, 255), random(0, 255), random(0, 255))\n        line(w, 0, w, height)\n\ndef draw():\n    pass\n```\n\n## Mouse Motion\n\n```\npython ppython.py snippets/mouse_motion.py\n```\n\n![](ppython/images/ppython_mouse_motion.gif)\n\n\u003e code:\n\n```python\ndef setup():\n    noStroke()\n\n\ndef draw():\n    max_distance = dist(0, 0, width, height)\n    background(255)\n\n    for i in range(0, width + 1, 20):\n        for y in range(0, height + 1, 20):\n            size = dist(mouseX, mouseY, i, y)\n            size = size / max_distance * 66\n            ellipse(i, y, size, size)\n```\n\n## Mitsubishi Logo\n\n```\npython ppython.py snippets/mitsubishi.py\n```\n\n![](ppython/images/ppython_mitsubishi.png)\n\n\u003e code:\n\n```python\ndef setup():\n    background(80)\n    noStroke()\n    fill(255)\n    # first\n    beginShape()\n    vertex(250, 20)\n    vertex(200, 120)\n    vertex(300, 120)\n    endShape()\n\n    beginShape()\n    vertex(250, 220)\n    vertex(200, 120)\n    vertex(300, 120)\n    endShape()\n\n    # left\n    beginShape()\n    vertex(250, 220)\n    vertex(140, 220)\n    vertex(200, 320)\n    endShape()\n\n    beginShape()\n    vertex(90, 320)\n    vertex(140, 220)\n    vertex(200, 320)\n    endShape()\n\n    # right\n    beginShape()\n    vertex(250, 220)\n    vertex(360, 220)\n    vertex(300, 320)\n    endShape()\n\n    beginShape()\n    vertex(410, 320)\n    vertex(360, 220)\n    vertex(300, 320)\n    endShape()\n\n\ndef draw():\n    pass\n\n```\n\n## MasterCard Logo\n\n```\npython ppython.py snippets/mastercard.py\n```\n\n![](ppython/images/ppython_mastercard.png)\n\n\u003e code:\n\n```python\ndef setup():\n    noStroke()\n\n    fill(200)\n    rect(100, 100, 300, 150)\n\n    fill(220, 20, 60)\n    ellipse(160, 125, 100, 100)\n\n    fill(255, 215, 0)\n    ellipse(230, 125, 100, 100)\n\n\ndef draw():\n    pass\n```\n\n# Docs\n\n### constants\n\n-   mouseX\n\nposition of x-coord of mouse\n\n-   mouseY\n\nposition of y-coord of mouse\n\n-   width\n\nwidth of the canvas\n\n-   height\n\nheight of the canvas\n\n### main functions\n\n-   setup()\n\nUsed to initialise what will be used only once\n\n-   draw()\n\ncode to be looped is placed in it\n\n### graphics\n\n-   line()\n\n```python\nline(x1, y1, x2, y2)\n```\n\n-   rect()\n\n```python\nrect(x, y, width, height)\n```\n\n-   ellipse()\n\n```python\nellipse(x, y, width, height)\n```\n\n-   beginShape()\n\n```python\nbeginShape()\nvertex(x1, y1)\nvertex(x2, y2)\nvertex(x3, y3)\nendShape()\n```\n\n### fill control\n\n-   background()\n\n```python\nbackground(r, g, b)\nbackground(r, g, b, a)\nbackground(grayness) # background(100) equals background(100, 100, 100)\n```\n\n-   fill()\n\n```python\nfill(r, g, b)\nfill(r, g, b, a)\nfill(grayness) # fill(100) equals fill(100, 100, 100)\n```\n\nUsed to colour shapes\n\n-   stroke()\n\n```python\nstroke(r, g, b)\nstroke(r, g, b, a)\nstroke(grayness) # stroke(100) equals stroke(100, 100, 100)\n```\n\nUsed to colour lines and boarders of shapes\n\n-   strokeSize()\n\n```python\nstrokeSize(thickness)\n```\n\nUsed to define borders of shapes\n\n-   noFill()\n\n```python\nnoFill()\n```\n\nRemoves filling\n\n-   noStroke()\n\n```python\nnoStroke()\n```\n\nRemoves strokes\n\n### utility\n\n-   random()\n\n```python\nrandom(end) # same as random(0, end)\nrandom(start, end)\nrandom() # returns arbitrary value from 0 to 1\n```\n\nReturns integer inclusive of start, exclusive of end\n\n-   dist\n\n```python\ndist(x1, x2, y1, y2)\n```\n\nReturns 2D distance between 2 coordinates.\n\n-   Change the size of the window as you feel\n\n```\npython ppython.py \u003cpath-to-file\u003e/file.py \u003cheight\u003e \u003cwidth\u003e\n```\n\n-   or you can change only height\n\n```\npython ppython.py \u003cpath-to-file\u003e/file.py \u003cheight\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabdur-rahmaanj%2Fppython","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabdur-rahmaanj%2Fppython","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabdur-rahmaanj%2Fppython/lists"}