{"id":16860944,"url":"https://github.com/nickmcintyre/processing-synchronization","last_synced_at":"2026-05-16T08:40:20.603Z","repository":{"id":130731707,"uuid":"180198914","full_name":"nickmcintyre/processing-synchronization","owner":"nickmcintyre","description":"Simulate oscillator synchronization with Processing","archived":false,"fork":false,"pushed_at":"2022-01-22T04:12:35.000Z","size":258,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-22T08:47:05.988Z","etag":null,"topics":["processing","synchronization"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nickmcintyre.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-04-08T17:25:09.000Z","updated_at":"2020-03-25T03:08:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"106f69d9-68d1-4f99-939c-86a07336f74d","html_url":"https://github.com/nickmcintyre/processing-synchronization","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/nickmcintyre/processing-synchronization","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickmcintyre%2Fprocessing-synchronization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickmcintyre%2Fprocessing-synchronization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickmcintyre%2Fprocessing-synchronization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickmcintyre%2Fprocessing-synchronization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nickmcintyre","download_url":"https://codeload.github.com/nickmcintyre/processing-synchronization/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickmcintyre%2Fprocessing-synchronization/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266991173,"owners_count":24017739,"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","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["processing","synchronization"],"created_at":"2024-10-13T14:28:10.029Z","updated_at":"2026-05-16T08:40:20.566Z","avatar_url":"https://github.com/nickmcintyre.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# processing-synchronization\n**Simulate oscillator synchronization with Processing**\n\n- Implements the [Kuramoto model](https://en.wikipedia.org/wiki/Kuramoto_model) for synchronization.\n- Supports oscillator networks of arbitrary size, coupling, connective arrangement, and noise level.\n\n## Example\nThe following example simulates the swarming behavior and bioluminescence of fireflies. Pairs well with [Owl City](https://youtu.be/zlxPp0vAniY).\n\n```java\n// Based on \"Flocking\" by Daniel Shiffman. CC BY-NC-SA 4.0\nimport sync.*;\n\nPNetwork net;\nSwarm swarm;\n\nvoid setup() {\n  size(640, 360);\n  int networkSize = 100;\n  float coupling = 10;\n  net = new PNetwork(this, networkSize, coupling);\n  swarm = new Swarm(net);\n  for (int i = 0; i \u003c networkSize; i++) {\n    swarm.addFly(new Firefly(width / 2, height / 2));\n  }\n}\n\nvoid draw() {\n  background(0, 5, 20);\n  swarm.run();\n}\n\n// Vary the range of the swarm's natural frequencies\nvoid mousePressed() {\n  float lo = random(TWO_PI);\n  float hi = lo + random(TWO_PI - lo);\n  for (int i = 0; i \u003c net.size(); i++) {\n    net.naturalFrequency[i] = random(lo, hi);\n  }\n}\n\n// The Firefly class\n\nclass Firefly {\n\n  PVector position;\n  PVector velocity;\n  PVector acceleration;\n  float d;\n  float maxforce;    // Maximum steering force\n  float maxspeed;    // Maximum speed\n\n  Firefly(float x, float y) {\n    acceleration = new PVector(0, 0);\n    velocity = PVector.random2D();\n    position = new PVector(x, y);\n    d = 10;\n    maxspeed = 2;\n    maxforce = 0.03;\n  }\n\n  void run(float phase) {\n    update(phase);\n    borders();\n    render(phase);\n  }\n\n  void applyForce(PVector force) {\n    // We could add mass here if we want A = F / M\n    acceleration.add(force);\n  }\n\n  // Method to update position\n  void update(float phase) {\n    // Update velocity\n    velocity.set(cos(phase), sin(phase));\n    velocity.add(acceleration);\n    // Limit speed\n    velocity.limit(maxspeed);\n    position.add(velocity);\n    // Reset accelertion to 0 each cycle\n    acceleration.mult(0);\n  }\n\n  void render(float phase) {\n    float alpha = 175 * round(map(phase, 0, TWO_PI, 0, 1));\n    fill(225, 240, 45, alpha);\n    stroke(225, 240, 45, alpha);\n    circle(position.x, position.y, d);\n  }\n\n  // Wraparound\n  void borders() {\n    float r = d / 2;\n    if (position.x \u003c -r) position.x = width + r;\n    if (position.y \u003c -r) position.y = height + r;\n    if (position.x \u003e width + r) position.x = -r;\n    if (position.y \u003e height + r) position.y = -r;\n  }\n}\n\n// The Swarm (a list of Firefly objects)\n\nclass Swarm {\n  ArrayList\u003cFirefly\u003e flies; // An ArrayList for all the fireflies\n  PNetwork net; // A PNetwork of coupled oscillators\n  float maxdist = sqrt(pow(width, 2) + pow(height, 2));\n  float maxcouple = 10;\n\n  Swarm(PNetwork net_) {\n    flies = new ArrayList\u003cFirefly\u003e(); // Initialize the ArrayList\n    net = net_;\n  }\n\n  void run() {\n    // Update coupling based on proximity\n    for (int i = 0; i \u003c flies.size(); i++) {\n      Firefly a = flies.get(i);\n      for (int j = i; j \u003c flies.size(); j++) {\n        Firefly b = flies.get(j);\n        float coupling = maxcouple - map(a.position.dist(b.position), 0, maxdist, 0, maxcouple);\n        net.coupling[i][j] = coupling;\n        net.coupling[j][i] = coupling;\n      }\n      a.run(net.phase[i]);  // Passing each firefly its updated phase\n    }\n    net.step();\n  }\n\n  void addFly(Firefly f) {\n    flies.add(f);\n  }\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnickmcintyre%2Fprocessing-synchronization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnickmcintyre%2Fprocessing-synchronization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnickmcintyre%2Fprocessing-synchronization/lists"}