{"id":1168,"url":"https://github.com/davidcairns/DePict","last_synced_at":"2025-07-30T20:32:41.413Z","repository":{"id":29318267,"uuid":"32851707","full_name":"davidcairns/DePict","owner":"davidcairns","description":"A simple, declarative, functional drawing framework, in Swift!","archived":false,"fork":false,"pushed_at":"2016-11-07T15:38:10.000Z","size":48,"stargazers_count":36,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-14T14:06:25.665Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","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/davidcairns.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}},"created_at":"2015-03-25T08:26:51.000Z","updated_at":"2023-03-11T20:51:27.000Z","dependencies_parsed_at":"2022-09-06T15:02:44.235Z","dependency_job_id":null,"html_url":"https://github.com/davidcairns/DePict","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidcairns%2FDePict","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidcairns%2FDePict/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidcairns%2FDePict/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidcairns%2FDePict/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidcairns","download_url":"https://codeload.github.com/davidcairns/DePict/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228187546,"owners_count":17882324,"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-01-05T20:15:40.400Z","updated_at":"2024-12-04T20:31:03.151Z","avatar_url":"https://github.com/davidcairns.png","language":"Swift","funding_links":[],"categories":["Graphics","UI","Libs"],"sub_categories":["Getting Started","Other free courses","Linter","Images"],"readme":"# DePict - A simple, declarative, functional drawing framework.\n\nTo produce a drawing, call the `Draw` function (just type *Draw* and let autocomplete\ndo the rest!).  \n\nPass `Draw` a `Colorer`. There are currently two ways to color something. Type either:\n• *Filled*, for filled-in shapes, or\n• *Outlined*, for outlined or “stroked” shapes.\n\nAnd then provide a color -- `Black`, `Yellow`, `Red`, or create anything you like.  \n\nNow you can specify the `Shape` to be drawn:\n• `Line`\n• `Rectangle`\n• `Circle`\n• \u0026 more\n\nThe end result of this is that your code reads like the thing you're actually drawing:\n\t`Draw(colorer: Filled(color: Blue, shape: Circle(…)))`\n\t“Draw a Filled Blue Circle”\n\n-----\n\n### Drawing a Face\n\nWe can draw a face in just a single line of readable, declarative code. See how the pieces reflect the final result.\n\n```\n\t\tDraw(colorer:\n\t\t\t// Hair (behind head)\n\t\t\tFilled(color: Black, shape: Circle(centerX: 50, Y: 58, radius: 40))\n\t\t\t\n\t\t\t// Face\n\t\t\t+ Filled(color: Brown, shape: Circle(centerX: 50, Y: 50, radius: 40))\n\t\t\t\n\t\t\t// Eyes and pupils\n\t\t\t+ Filled(color: White, shape: Rectangle(x: 20, y: 50, width: 20, height: 8))\n\t\t\t+ Filled(color: Blue, shape: Circle(centerX: 30, Y: 54, radius: 2))\n\t\t\t+ Filled(color: White, shape: Rectangle(x: 60, y: 50, width: 20, height: 8))\n\t\t\t+ Filled(color: Blue, shape: Circle(centerX: 70, Y: 54, radius: 2))\n\t\t\t\n\t\t\t// Nose\n\t\t\t+ Outlined(color: Light(Brown), shape:\n\t\t\t\tLine(fromX: 50, y: 54, toX: 56, y: 44)\n\t\t\t\t+ Line(fromX: 56, y: 44, toX: 52, y: 42)\n\t\t\t)\n\t\t\t\n\t\t\t// Mouth\n\t\t\t+ Outlined(color: Light(Red), shape:\n\t\t\t\tLine([(40, 30), (46, 25), (54, 25)])\n\t\t\t)\n\t\t)\n```\n\n![A Face](http://davidcairns.github.io/DePict_README_images/face.png \"A Face\")\n\n### Drawing Information graphics\n\nIt’s trivial to use DePict to turn data into information graphics, and the declarative style allows you to do so in an obvious, clear way.  \n\n1) Start with some data you want to graph…  \n`let data = [11, 87, 98, 48, 41, 88, 63, 69, 8, 79]`\n\n2) For each datum, create a filled rectangle with height relative to its value.\n`let bars = Array(0 ..\u003c data.count).map({ Filled(color: Magenta, shape: Rectangle(x: $0 * 10, y: 0, width: 5, height: data[$0])) })`\n\n3) Combine the rectangles.\n`let graphData = bars.reduce(EmptyColorer(), combine: +)`\n\n\n![Bar Charts](http://davidcairns.github.io/DePict_README_images/bar-chart.png \"A Bar Chart\")\n\n\n-----\n\nDePict is a super-simple wrapper for CoreGraphics that makes your drawing easy to ready and modify. It works great for iOS and Mac apps. Anything you would use CoreGraphics for, you can express more simply and easily with DePict.  \n\nIf you come up with something fun, fork the code, or tweet me `@davidcairns`!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidcairns%2FDePict","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidcairns%2FDePict","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidcairns%2FDePict/lists"}