{"id":22160583,"url":"https://github.com/rozek/banglejs-2-drawmoonphase","last_synced_at":"2025-06-30T00:03:32.727Z","repository":{"id":114382888,"uuid":"446705130","full_name":"rozek/banglejs-2-drawmoonphase","owner":"rozek","description":"draws the interior of two half ovals to symbolize a moon phase","archived":false,"fork":false,"pushed_at":"2022-03-01T05:59:39.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-30T00:03:14.875Z","etag":null,"topics":["banglejs"],"latest_commit_sha":null,"homepage":"","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/rozek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2022-01-11T06:34:37.000Z","updated_at":"2022-01-11T06:40:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"1b3a7d63-7671-4940-9eaf-db4960b46023","html_url":"https://github.com/rozek/banglejs-2-drawmoonphase","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rozek/banglejs-2-drawmoonphase","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rozek%2Fbanglejs-2-drawmoonphase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rozek%2Fbanglejs-2-drawmoonphase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rozek%2Fbanglejs-2-drawmoonphase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rozek%2Fbanglejs-2-drawmoonphase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rozek","download_url":"https://codeload.github.com/rozek/banglejs-2-drawmoonphase/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rozek%2Fbanglejs-2-drawmoonphase/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262685616,"owners_count":23348447,"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":["banglejs"],"created_at":"2024-12-02T04:08:51.841Z","updated_at":"2025-06-30T00:03:32.652Z","avatar_url":"https://github.com/rozek.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# banglejs-2-drawmoonphase #\n\ndraws the interior of two half ovals to symbolize a moon phase\n\nThis module adds a method `drawMoonPhase` for drawing an image symbolizing a moon phase to the global graphics context `g`. It is based on an idea of forum user [HilmarSt](http://forum.espruino.com/profiles/182487/) (see this [discussion](http://forum.espruino.com/conversations/371330/)).\n\n![](Demo.png)\n\nThe new method has the signature\n\n```javascript\ng.drawMoonPhase(cx,cy, r, left, right);\n```\n\nwith the following parameters:\n\n* `cx` - x coordinate of the moon's center\n* `cy` - y coordinate of the moon's center\n* `r` - moon radius\n* `left` - left factor (see below)\n* `right` - right factor (see below)\n\nThe moon phase is drawn and filled with current foreground color.\n\n### Semantics of \"left\" and \"right\" ###\n\n`left` and `right` specify the actual phase that is to be shown:\n\n* both values range from -1...+1\n* set both to `1` for a full moon\n* set `right = 1` and start with `left = -1` for a waxing moon. Increase `left` until `1` for a full moon\n* set `left = 1` and start with `right = 1` for a waning moon. Decrease `right` until `-1`\n\n## Example ##\n\nThe following example illustrates how to use `drawMoonPhase` and produces the graphics shown above:\n\n```javascript\n  g.setBgColor('#000000');\n  g.clear(false);\n\n  require('https://raw.githubusercontent.com/rozek/banglejs-2-drawmoonphase/main/drawMoonPhase.js');\n\n  let ScreenWidth  = g.getWidth(),  CenterX = ScreenWidth/2;\n  let ScreenHeight = g.getHeight(), CenterY = ScreenHeight/2;\n\n  let Diameter = Math.floor(ScreenWidth / 7);\n  let Radius   = Diameter/2;\n\n  g.clear();\n\n  g.setColor('#FFFFFF');\n\n  g.drawMoonPhase(CenterX-3*Diameter,CenterY, Radius, 1,-1);\n  g.drawMoonPhase(CenterX-2*Diameter,CenterY, Radius, 1,-0.6);\n  g.drawMoonPhase(CenterX-1*Diameter,CenterY, Radius, 1,0.6);\n  g.drawMoonPhase(CenterX-0*Diameter,CenterY, Radius, 1,1);\n  g.drawMoonPhase(CenterX+1*Diameter,CenterY, Radius, 0.6,1);\n  g.drawMoonPhase(CenterX+2*Diameter,CenterY, Radius, -0.6,1);\n  g.drawMoonPhase(CenterX+3*Diameter,CenterY, Radius, -1,1);\n```\n\n## License ##\n\n[MIT License](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frozek%2Fbanglejs-2-drawmoonphase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frozek%2Fbanglejs-2-drawmoonphase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frozek%2Fbanglejs-2-drawmoonphase/lists"}