{"id":23053540,"url":"https://github.com/component/convolve","last_synced_at":"2025-08-15T03:33:09.286Z","repository":{"id":4800044,"uuid":"5953145","full_name":"component/convolve","owner":"component","description":"Canvas convolution filters","archived":false,"fork":false,"pushed_at":"2013-03-21T20:20:57.000Z","size":431,"stargazers_count":19,"open_issues_count":1,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-05-08T17:16:35.483Z","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/component.png","metadata":{"files":{"readme":"Readme.md","changelog":"History.md","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":"2012-09-25T16:45:47.000Z","updated_at":"2022-05-09T14:12:38.000Z","dependencies_parsed_at":"2022-08-18T22:00:48.107Z","dependency_job_id":null,"html_url":"https://github.com/component/convolve","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fconvolve","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fconvolve/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fconvolve/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fconvolve/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/component","download_url":"https://codeload.github.com/component/convolve/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229890528,"owners_count":18140110,"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-12-16T00:18:35.222Z","updated_at":"2024-12-16T00:18:35.833Z","avatar_url":"https://github.com/component.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# convolve\n\n  Canvas [convolution](http://en.wikipedia.org/wiki/Convolution) filter.\n\n  ![](maru_edges.jpg)\n\n## API\n\n### convolve(matrix)\n\n  Return a new convolution `Filter` with the given `matrix`.\n\n### Filter#factor(n)\n\n  Change the factor to `n`, defaults to `1`.\n\n### Filter#bias(n)\n\n  Change the bias to `n`, defaults to `0`.\n\n### Filter#width(n)\n\n  Canvas width.\n\n### Filter#height(n)\n\n  Canvas height.\n\n### Filter#apply(input, result)\n\n  Apply the convolution filter to the `input` ImageData, populating \n  the `result` ImageData. This is a lower-level method, you most\n  likely want to apply to the entire canvas, in which case use below:\n\n### Filter#canvas(canvas)\n\n  Apply the convolution filter to the entire `canvas`\n  and immediately draw the results.\n\n## Example\n\n```js\nvar convolve = require('convolve');\nvar canvas = document.querySelector('canvas');\nvar ctx = canvas.getContext('2d');\n\nvar img = new Image;\nimg.onload = draw;\nimg.src = 'maru.jpg';\n\nvar sharpen = [\n  [-1, -1, -1],\n  [-1, 9, -1],\n  [-1, -1, -1]\n];\n\nvar blur = [\n  [0, .2, 0],\n  [.2, .2, .2],\n  [0, .2, 0],\n];\n\n// factor 1 / 7\nvar motionBlur = [\n  [1, 0, 0, 0, 0, 0, 0],\n  [0, 1, 0, 0, 0, 0, 0],\n  [0, 0, 1, 0, 0, 0, 0],\n  [0, 0, 0, 1, 0, 0, 0],\n  [0, 0, 0, 0, 1, 0, 0],\n  [0, 0, 0, 0, 0, 1, 0],\n  [0, 0, 0, 0, 0, 0, 1]\n];\n\nvar edges = [\n  [0, -1, 0],\n  [-1, 4, -1],\n  [0, -1, 0]\n];\n\nfunction draw() {\n  canvas.width = img.width;\n  canvas.height = img.height;\n  ctx.drawImage(img, 0, 0);\n  convolve(motionBlur)\n    .factor(1 / 7)\n    .canvas(canvas);\n}\n```\n\n# License\n\n  MIT\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomponent%2Fconvolve","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcomponent%2Fconvolve","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomponent%2Fconvolve/lists"}