{"slug": "drawbot-generate-a-jellyfish-like-pulsating-blobby-animation", "title": "DrawBot: Generate a jellyfish-like pulsating blobby animation.", "summary": "The article describes a Python script that generates an animated GIF of a jellyfish-like, pulsating blobby shape. The code creates multiple layered blobs that vary in size and phase, using random offsets and Bézier curves to produce an organic, undulating animation. The animation is saved as \"Jellyfish.gif\" with 95 frames at a duration of 1/20 second per frame.", "body_md": "Jellyfish.py\n\n      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.\n      \nLearn more about bidirectional Unicode characters\n\n \n    Show hidden characters\n\n# Generate a jellyfish-like pulsating blobby animation.\n\nfrom random import seed\n\ndef varyPoint(pt, radius, phase):\n\n    x, y = pt\n\n    dx = radius * cos(phase)\n\n    dy = radius * sin(phase)\n\n    return x + dx, y + dy\n\ndef drawBlob(blobPhase, blobRadius):\n\n    points = []  # list of off curve points forming the blob.\n\n    for i in range(numBlobPoints):\n\n        a = 2 * pi * i / numBlobPoints\n\n        x = blobRadius * cos(a)\n\n        y = blobRadius * sin(a)\n\n        rPhase, rSign = randomPhases[i]\n\n        points.append(varyPoint((x, y), 0.2 * blobRadius, rPhase + rSign * 2 * pi * blobPhase))\n\n    # Add a final 'fake' point, to tell the pen there is *no* on curve point at all\n\n    points.append(None)\n\n    bezPath = BezierPath()\n\n    bezPath.qCurveTo(*points)\n\n    bezPath.closePath()\n\n    drawPath(bezPath)\n\nseed(0)  # Ok ok, make this animation predictable.\n\nnumBlobPoints = 5\n\nrandomPhases = [(2 * pi * random(), choice([-1, 1])) for i in range(numBlobPoints)]\n\ncanvasSize = 500\n\nnBlobs = 24\n\nnFrames = 95\n\nfor frame in range(nFrames):\n\n    framePhase = frame / nFrames\n\n    newPage(canvasSize, canvasSize)\n\n    frameDuration(1/20)\n\n    fill(0)\n\n    rect(0, 0, canvasSize, canvasSize)\n\n    translate(canvasSize/2, canvasSize/2)\n\n    strokeWidth(2)\n\n    stroke(1)\n\n    fill(None)\n\n    for i in range(nBlobs):\n\n        blobPhase = i / nBlobs\n\n        radius = 5 + i * 10\n\n        drawBlob(framePhase + blobPhase * 0.75, radius)\n\nsaveImage(\"Jellyfish.gif\")", "url": "https://wpnews.pro/news/drawbot-generate-a-jellyfish-like-pulsating-blobby-animation", "canonical_source": "https://gist.github.com/justvanrossum/b65f4305ffcf2690bc65", "published_at": "2016-01-06 20:16:10+00:00", "updated_at": "2026-05-23 15:07:27.145748+00:00", "lang": "en", "topics": ["robotics", "science"], "entities": [], "alternates": {"html": "https://wpnews.pro/news/drawbot-generate-a-jellyfish-like-pulsating-blobby-animation", "markdown": "https://wpnews.pro/news/drawbot-generate-a-jellyfish-like-pulsating-blobby-animation.md", "text": "https://wpnews.pro/news/drawbot-generate-a-jellyfish-like-pulsating-blobby-animation.txt", "jsonld": "https://wpnews.pro/news/drawbot-generate-a-jellyfish-like-pulsating-blobby-animation.jsonld"}}