{"id":16833519,"url":"https://github.com/garciadelcastillo/-dashed-lines-for-processing-","last_synced_at":"2025-10-11T06:13:09.522Z","repository":{"id":69995686,"uuid":"89379534","full_name":"garciadelcastillo/-dashed-lines-for-processing-","owner":"garciadelcastillo","description":"Draw dashed strokes in Processing!","archived":false,"fork":false,"pushed_at":"2018-10-30T20:33:32.000Z","size":6577,"stargazers_count":73,"open_issues_count":3,"forks_count":6,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-18T08:11:17.435Z","etag":null,"topics":[],"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/garciadelcastillo.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}},"created_at":"2017-04-25T15:55:11.000Z","updated_at":"2024-07-02T23:29:51.000Z","dependencies_parsed_at":"2023-03-02T19:45:11.661Z","dependency_job_id":null,"html_url":"https://github.com/garciadelcastillo/-dashed-lines-for-processing-","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/garciadelcastillo%2F-dashed-lines-for-processing-","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garciadelcastillo%2F-dashed-lines-for-processing-/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garciadelcastillo%2F-dashed-lines-for-processing-/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garciadelcastillo%2F-dashed-lines-for-processing-/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/garciadelcastillo","download_url":"https://codeload.github.com/garciadelcastillo/-dashed-lines-for-processing-/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244907420,"owners_count":20529850,"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":[],"created_at":"2024-10-13T11:54:31.065Z","updated_at":"2025-10-11T06:13:04.501Z","avatar_url":"https://github.com/garciadelcastillo.png","language":"Java","funding_links":[],"categories":["Libraries"],"sub_categories":["Contributions"],"readme":"# Dashed Lines for Processing\n\n![Dashed Line](https://github.com/garciadelcastillo/-dashed-lines-for-processing-/blob/master/assets/dashed_line.gif \"Dashed Line\")\n\nCouldn't be any simpler, just a [Processing](http://processing.org) library to draw geometry with dashed strokes!\n\n### Installation\nYou can install the library from Processing's Contribution Manager.\n\nAlternatively, you can extract the distribution file on your Processing's sketchbook. Download `dashedlines.zip` from the `dist` folder. Now go to your sketchbook folder (in Windows it will be something like `C:\\Users\\JohnDoe\\Documents\\Processing`), go inside `libraries`, and extract the contents of the `.zip` file to a folder called `dashedlines`. Once finished, your library should be found under: `C:\\Users\\JohnDoe\\Documents\\Processing\\libraries\\dashedlines\\library\\dashedlines.jar`.\n\nStill having trouble? [Read this](https://github.com/processing/processing/wiki/How-to-Install-a-Contributed-Library).\n\n## Hello Dash\nLet's take a look at a basic example on how to draw a simple dashed line:\n\n```java\n// Import the library\nimport garciadelcastillo.dashedlines.*;\n\n// Declare the main DashedLines object\nDashedLines dash;\n\nvoid setup() {\n  // Initialize it, passing a reference to the current PApplet\n  dash = new DashedLines(this);\n\n  // Set the dash-gap pattern in pixels\n  dash.pattern(10, 5);\n}\n\nvoid draw() {\n  background(127);\n\n  // Call the line method of the 'dash' object,\n  // as if it was Processing's native\n  dash.line(10, 10, 90, 90);\n  dash.line(10, 90, 90, 10);\n}\n\n```\n\nAnd voilà!\n\n![Hello Dash!](https://github.com/garciadelcastillo/-dashed-lines-for-processing-/blob/master/assets/hello_dash.png \"Hello Dash!\")\n\n\n## Features\nDashed Lines for Processing provides a **Processing-like API** to draw the same basic or complex shapes you would natively, but with **dashed strokes**. It computes stroke segments based on your `pattern` choice, and adapts the drawing to a best-fit solution. This is specially useful for example for animations:\n\n```java\ndash.pattern(20, 10);\ndash.line(n1.x, n1.y, n2.x, n2.y);\n```\n\n![Dashed Line](https://github.com/garciadelcastillo/-dashed-lines-for-processing-/blob/master/assets/dashed_line.gif \"Dashed Line\")\n\nDashed Lines contains methods to draw ~~all~~ _(under development, still kinks here and there)_ types of geometry that you would normally do in Processing. It inherits **inherit Processing's styles**, such as `stroke()`, `fill()`, `strokeWeight()` and **shape modes** like `rectMode()`. Additionally, it provides some options to **customize the dash-gap `pattern()`** or to add `offset()` to the pattern for **'walking ants' effect** on animations.\n\nFor example, for **2D primitives**:\n\n```java\ndash.pattern(30, 10, 15, 10);\n\n// Dashed objects inherit Processing's style properties, including shape modes.\nfill(255, 0, 0, 100);\nrectMode(CORNERS);\ndash.rect(n[0].x, n[0].y, n[1].x, n[1].y);\n\nfill(0, 255, 0, 100);\nellipseMode(CORNERS);\ndash.ellipse(n[2].x, n[2].y, n[3].x, n[3].y);\n\nfill(0, 0, 255, 100);\ndash.triangle(n[4].x, n[4].y, n[5].x, n[5].y, n[6].x, n[6].y);\n\nfill(255, 0, 255, 100);\ndash.quad(n[7].x, n[7].y, n[8].x, n[8].y, n[9].x, n[9].y, n[10].x, n[10].y);\n\n// Animate dashes with 'walking ants' effect\ndash.offset(dist);\ndist += 1;\n```\n![2D Primitives](https://github.com/garciadelcastillo/-dashed-lines-for-processing-/blob/master/assets/2d_primitives.gif \"2D Primitives\")\n\nFor **Bézier curves**:\n\n```java\ndash.pattern(30, 10);\n\nnoFill();\ndash.bezier(n[0].x, n[0].y, n[1].x, n[1].y, n[2].x, n[2].y, n[3].x, n[3].y);\n\ndash.offset(dist);\ndist += 1;\n```\n![Bezier Curve](https://github.com/garciadelcastillo/-dashed-lines-for-processing-/blob/master/assets/bezier_curve.gif \"Bezier Curve\")\n\nAnd for more **complex shapes**, you can use the `.beginShape()`, `.vertex()` and `.endShape()` interface, just like you would in Processing! :)\n\n```java\nstrokeCap(SQUARE);\nstrokeJoin(BEVEL);\ndash.pattern(30, 10);\n\n// Start the shape with the .beginShape() method\ndash.beginShape();\n// Add vertices like you would in Processing\nfor (int i = 0; i \u003c n.length; i++) {\n  dash.vertex(n[i].x, n[i].y);\n}\n// Finish drawing the shape\ndash.endShape();\n\ndash.offset(dist);\ndist += 1;\n```\n![Open Shape](https://github.com/garciadelcastillo/-dashed-lines-for-processing-/blob/master/assets/shape_open.gif \"Open Shape\")\n\nIncluding the option to use any of Processing's **shape modes**:\n\n```java\n// Shapes accept all the same modes as Processing's native implementation:\nfill(255, 0, 0, 100);\ndash.beginShape(TRIANGLES);\nfor (int i = 0; i \u003c n.length; i++) {\n  dash.vertex(n[i].x, n[i].y);\n}\ndash.endShape(CLOSE);\n```\n![TRIANGLES Shape](https://github.com/garciadelcastillo/-dashed-lines-for-processing-/blob/master/assets/shape_triangles.gif \"TRIANGLES Shape\")\n\n## Contribute\nThere is still [a lot to do](https://github.com/garciadelcastillo/-dashed-lines-for-processing-/blob/master/TODO.md), so if you have some time and are excited about computational geometry, feel free to fork and contribute, [report bugs](https://github.com/garciadelcastillo/-dashed-lines-for-processing-/issues) or [submit feature requests](https://github.com/garciadelcastillo/-dashed-lines-for-processing-/issues).\n\nAlso, if you found this library useful and did something cool with it, send your creation my way! I am always happy to hear about cool projects people are working on.\n\n## Acknowledgments\nMy deepest gratitude to all the folks at the [Processing Foundation](https://processing.org/) and the great [community](https://processing.org/reference/libraries/) that make this project so special and awesome.\n\nThanks to [Nono](https://github.com/nonoesp) for having pushed me to stick my head out of the books and make something useful, for once!\n\nKuddos to [Pomax](https://github.com/Pomax) for his amazing [Primer on Bézier Curves](https://pomax.github.io/bezierinfo/), it was incredibly helpful for the math behind these curves.\n\nIf you do something cool with this, tweet me! [@garciadelcast](https://twitter.com/garciadelcast)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgarciadelcastillo%2F-dashed-lines-for-processing-","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgarciadelcastillo%2F-dashed-lines-for-processing-","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgarciadelcastillo%2F-dashed-lines-for-processing-/lists"}