{"id":22530143,"url":"https://github.com/bohnacker/p5js-screenposition","last_synced_at":"2025-09-03T12:41:06.273Z","repository":{"id":150149607,"uuid":"197724778","full_name":"bohnacker/p5js-screenPosition","owner":"bohnacker","description":"This function provides a solution to the missing screenX and screenY functions in p5.js. See https://github.com/processing/p5.js/issues/1553 for the discussion. ","archived":false,"fork":false,"pushed_at":"2019-10-15T08:23:56.000Z","size":749,"stargazers_count":40,"open_issues_count":2,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-03T23:46:47.584Z","etag":null,"topics":["p5","p5-js","p5-library","p5js","screenx","screeny"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/bohnacker.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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-07-19T07:31:51.000Z","updated_at":"2025-02-13T14:25:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"aa74b87e-1723-4d01-bb12-c49c6905f4d6","html_url":"https://github.com/bohnacker/p5js-screenPosition","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/bohnacker/p5js-screenPosition","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bohnacker%2Fp5js-screenPosition","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bohnacker%2Fp5js-screenPosition/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bohnacker%2Fp5js-screenPosition/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bohnacker%2Fp5js-screenPosition/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bohnacker","download_url":"https://codeload.github.com/bohnacker/p5js-screenPosition/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bohnacker%2Fp5js-screenPosition/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273445505,"owners_count":25107149,"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","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["p5","p5-js","p5-library","p5js","screenx","screeny"],"created_at":"2024-12-07T07:18:28.300Z","updated_at":"2025-09-03T12:41:06.263Z","avatar_url":"https://github.com/bohnacker.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# p5js-screenPosition\n\n![screenPosition-Cover](img/screenPos-Cover.png)\n\nThis function provides a solution to the missing screenX and screenY functions in p5.js. See https://github.com/processing/p5.js/issues/1553 for the discussion. \n\n**This is work in progress.** \n\nAs far as I could find out there should be anything implemented to make it work perfectly in any mode (2D, WEBGL, angleMode DEGREES or RADIANS, normal or instance mode). If you'll find a case that isn't working correctly, please file an issue.\n\n## Usage\n\nFor a quick look on what it's doing see https://editor.p5js.org/bohnacker/sketches/nUk3bVW7b. \n\n### 1. Download\nDownload the latest release of `addScreenPositionFunction.js`.\n\n### 2. Use it in your project\nLink to it in your HTML file. It's only working in combination with p5.js.\n\n``` html\n\u003cscript src=\"p5.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"addScreenPositionFunction.js\"\u003e\u003c/script\u003e\n```\n\n### 3. Initializing\nCall the function `addScreenPositionFunction()` after creating the canvas.\n\n``` javascript\nfunction setup() {\n  createCanvas(400, 400);\n  addScreenPositionFunction();\n}\n```\n\nIf your using p5.js in instance mode you have to pass the instance:\n\n``` javascript\np.setup = function() {\n  p.createCanvas(400, 400);\n  addScreenPositionFunction( p );\n};\n```\n\nQuite similar if you want to use the function with offscreen graphics:\n\n``` javascript\ngraphics = createGraphics(400, 400);\naddScreenPositionFunction( graphics );\n```\n\n\n### 4. Getting the screen position\nNow you can use `screenPosition(x, y, [z])` to get the position of a coordinate on screen. It returns a p5.Vector.\n``` javascript\nvar p = screenPosition(-100, 50, 0);\n```\n\nOr giving a p5.Vector:\n``` javascript\nvar v = createVector(-100, 50, 0)\nvar p = screenPosition( v );\n```\n\nOr giving an array with x, y, z coordinates:\n``` javascript\nvar v = [-100, 50, 0];\nvar p = screenPosition( v );\n```\n\n## Acknowledgements\nThanks to Thibault Coppex (@tcoppex) for the 3d-modelview-projection-math he supplied in the issue discussion thread (https://github.com/processing/p5.js/issues/1553). I had to adjust it a bit maybe because p5js changed the way webgl is handled since 2016.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbohnacker%2Fp5js-screenposition","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbohnacker%2Fp5js-screenposition","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbohnacker%2Fp5js-screenposition/lists"}