{"id":20565744,"url":"https://github.com/phenax/pattern-lock-js","last_synced_at":"2025-09-21T17:24:50.693Z","repository":{"id":19190459,"uuid":"86463016","full_name":"phenax/pattern-lock-js","owner":"phenax","description":"Pattern lock library for the web using canvas","archived":false,"fork":false,"pushed_at":"2023-07-17T08:57:55.000Z","size":411,"stargazers_count":68,"open_issues_count":7,"forks_count":19,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-28T04:30:30.462Z","etag":null,"topics":["canvas","html5","javascript"],"latest_commit_sha":null,"homepage":"https://phenax.github.io/pattern-lock-js/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phenax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"custom":["https://www.paypal.me/phenax","https://www.buymeacoffee.com/phenax"],"liberapay":"phenax"}},"created_at":"2017-03-28T13:24:38.000Z","updated_at":"2024-11-07T08:13:52.000Z","dependencies_parsed_at":"2023-02-12T23:01:21.429Z","dependency_job_id":null,"html_url":"https://github.com/phenax/pattern-lock-js","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/phenax%2Fpattern-lock-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenax%2Fpattern-lock-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenax%2Fpattern-lock-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenax%2Fpattern-lock-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phenax","download_url":"https://codeload.github.com/phenax/pattern-lock-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248906928,"owners_count":21181245,"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":["canvas","html5","javascript"],"created_at":"2024-11-16T04:38:56.700Z","updated_at":"2025-09-21T17:24:45.641Z","avatar_url":"https://github.com/phenax.png","language":"JavaScript","readme":"# PatternLockJS\nA pattern lock library for the web. [Demo](https://phenax.github.io/pattern-lock-js/)\n\n\n![npm (scoped)](https://img.shields.io/npm/v/@phenax/pattern-lock-js.svg?style=flat-square)\n![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/@phenax/pattern-lock-js.svg?style=flat-square)\n![NpmLicense](https://img.shields.io/npm/l/@phenax/pattern-lock-js.svg?style=flat-square)\n\u003ca href=\"https://www.buymeacoffee.com/phenax\"\u003e\u003cimg src=\"https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg?style=flat-square\" alt=\"Buy Me A Coffee donate button\" /\u003e\u003c/a\u003e\n\n\n\n\n### Installation\n\nInstall the library with\n```bash\nyarn add @phenax/pattern-lock-js\n```\n\nImport the library with\n```js\nimport PatternLock from '@phenax/pattern-lock-js';\n```\n\n### Get started\n```javascript\nconst lock = PatternLock({\n    $canvas: document.querySelector('#patternLock'),\n    width: 300,\n    height: 430,\n    grid: [ 3, 3 ],\n});\n```\n\n### Customize the theme\n```javascript\nlock.setTheme('dark');\nlock.setTheme('light');\n\n// Or pass a custom theme\n\nlock.setTheme({\n    default: {\n        colors: {\n            accent: '#1abc9c',     // Accent color for node\n            primary: '#ffffff',    // Primary node and line color\n            bg: '#2c3e50',         // Canvas background color\n        },\n        dimens: {\n            node_radius: 20,       // Radius of the outer ring of a node\n            line_width: 6,         // Thickness of the line joining nodes\n            node_core: 8,          // Radius of the inner circle of a node\n            node_ring: 1,          // Outer ring thickness\n        }\n    },\n    success: {\n\t\tcolors: {\n\t\t\taccent: '#51e980',     // Green accent on successful match\n\t\t}\n\t},\n\tfailure: {\n\t\tcolors: {\n\t\t\taccent: '#e74c3c',     // Red accent on an unsuccessful match\n\t\t}\n    },\n    customState: {                 // Your custom state\n        dimens: {\n            node_radius: 25,       // Increases the node radius\n        }\n    },\n});\n```\n\n### Manually change the state\n```javascript\nlock.setThemeState('success'); // Switch state to successful\nlock.setThemeState('customState'); // Switch to your custom state\n```\n\n### You can even change the grid size dynamically\n```javascript\nlock.setGrid(4, 4); // 4x4 grid instead of the default 3x3\n```\n\n\n### Callback for when the pattern is complete\n```javascript\nlock.onComplete(({ hash }) =\u003e (myRealHash === hash) ? success() : failure());\n```\n\n### Or you can use the matchHash helper to check if the hash matches your set of correct passwords\n```javascript\n// If the pattern drawn is a Right L or a Diagonal L,\n//    then turn the pattern green\n//    else turn it red\nlock.matchHash([ 'LTU2MTIyNjM0Ng==', 'MTk1OTMwNzY2NQ==' ])\n    .onSuccess(() =\u003e lock.setThemeState('success'))\n    .onFailure(() =\u003e lock.setThemeState('failure'));\n```\n\n### Destroy to enable scrolling on touch\n\n```\nlock.destroy();\n```\n\n\u003cbr /\u003e\n","funding_links":["https://www.paypal.me/phenax","https://www.buymeacoffee.com/phenax","https://liberapay.com/phenax"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphenax%2Fpattern-lock-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphenax%2Fpattern-lock-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphenax%2Fpattern-lock-js/lists"}