{"id":17087950,"url":"https://github.com/geraintluff/canvas-sketch","last_synced_at":"2025-04-12T20:33:14.855Z","repository":{"id":42568624,"uuid":"13829511","full_name":"geraintluff/canvas-sketch","owner":"geraintluff","description":"Transform an image into a pencil-sketch","archived":false,"fork":false,"pushed_at":"2014-08-17T01:44:52.000Z","size":9080,"stargazers_count":123,"open_issues_count":2,"forks_count":28,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-10-31T15:52:57.319Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geraintluff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-24T10:45:56.000Z","updated_at":"2024-10-28T06:46:52.000Z","dependencies_parsed_at":"2022-09-06T10:11:30.868Z","dependency_job_id":null,"html_url":"https://github.com/geraintluff/canvas-sketch","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/geraintluff%2Fcanvas-sketch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geraintluff%2Fcanvas-sketch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geraintluff%2Fcanvas-sketch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geraintluff%2Fcanvas-sketch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geraintluff","download_url":"https://codeload.github.com/geraintluff/canvas-sketch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223546010,"owners_count":17163002,"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-14T13:35:32.433Z","updated_at":"2024-11-07T16:03:29.596Z","avatar_url":"https://github.com/geraintluff.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"canvas-sketch\n=============\n\nTransform an image into a pencil-sketch, using the `\u003ccanvas\u003e` element.\n\nThe implemenation is not exactly efficient, so when you check out the [demo page](http://geraintluff.github.io/canvas-sketch/), try starting with a small image (a couple of hundred pixels across).\n\n## The algorithm\n\nThe principle is fairly simple.  At each point in the image, the hue is converted into an angle of shading (so blue and yellow are at right-angles to each other).  The saturation is converted into *consistency* of shading angles (so grey will be cross-hatched, grey-blue will be a bit rough-looking, and pure blue will be completely in line).  Brightness is obviously represented by density of lines.\n\nThe actual method is a bit of a hack - we create image-size pencil textures (using randomly drawn pencil lines with a specified thickness, length and density) for a few different RGB values.  The spacing of these values is determined by the \"Level steps\" control (so, 2 means that it will cover `(0, 0, 0)`, `(1, 0, 0)` and so on - 3 means it will cover `(0, 0, 0)`, `(0.5, 0, 0)` and so on).\n\nThen, we simply composite these textures together (fading between them), and add some basic edge-detection to simulate outlines.\n\n## Batch processing\n\nI hacked together a batch-processing system as a PHP script.  It downloads one image at a time, processes it, and POSTs it back to the server.\n\nThe config is in `batch-animation.json`.  Note the `lineAlphaVariation` and `edgeAmountVariation` properties, which randomise their corresponding parameters, resulting in a more or less coarse image.\n\nThe goal is to replicate the effect of tracing video frames using pencil sketches, where each frame will not turn out completely consistently:\n\n![GIF animation, from a video of a fruit bowl](100-coarse-random.gif)\n\n## License\n\nThe code is available as \"public domain\", meaning that it is completely free to use, without any restrictions at all (including re-licensing under your own terms).  Read the full license [here](http://geraintluff.github.com/tv4/LICENSE.txt).\n\nIt's also available under an [MIT license](http://jsonary.com/LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeraintluff%2Fcanvas-sketch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeraintluff%2Fcanvas-sketch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeraintluff%2Fcanvas-sketch/lists"}