diff --git a/.all-contributorsrc b/.all-contributorsrc index 7176429ed8..c8f6e2869a 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2913,6 +2913,260 @@ "contributions": [ "doc" ] + }, + { + "login": "unjust", + "name": "Ivy Feraco", + "avatar_url": "https://avatars.githubusercontent.com/u/92090?v=4", + "profile": "https://github.com/unjust", + "contributions": [ + "bug" + ] + }, + { + "login": "Gaweph", + "name": "Gareth Williams", + "avatar_url": "https://avatars.githubusercontent.com/u/6419944?v=4", + "profile": "http://RandomSyntax.Net", + "contributions": [ + "code" + ] + }, + { + "login": "eltociear", + "name": "Ikko Ashimine", + "avatar_url": "https://avatars.githubusercontent.com/u/22633385?v=4", + "profile": "https://bandism.net/", + "contributions": [ + "doc" + ] + }, + { + "login": "0xJonas", + "name": "Jonas Rinke", + "avatar_url": "https://avatars.githubusercontent.com/u/24874041?v=4", + "profile": "https://github.com/0xJonas", + "contributions": [ + "bug" + ] + }, + { + "login": "KouichiMatsuda", + "name": "MATSUDA, Kouichi", + "avatar_url": "https://avatars.githubusercontent.com/u/14014568?v=4", + "profile": "http://www.gakuin.otsuma.ac.jp/english/", + "contributions": [ + "bug" + ] + }, + { + "login": "stampyzfanz", + "name": "stampyzfanz", + "avatar_url": "https://avatars.githubusercontent.com/u/34364128?v=4", + "profile": "https://github.com/stampyzfanz", + "contributions": [ + "doc" + ] + }, + { + "login": "taejs", + "name": "tae", + "avatar_url": "https://avatars.githubusercontent.com/u/41318449?v=4", + "profile": "https://github.com/taejs", + "contributions": [ + "bug" + ] + }, + { + "login": "Divyansh013", + "name": "Divyansh013", + "avatar_url": "https://avatars.githubusercontent.com/u/85135469?v=4", + "profile": "https://github.com/Divyansh013", + "contributions": [ + "translation" + ] + }, + { + "login": "rinkydevi", + "name": "rinkydevi", + "avatar_url": "https://avatars.githubusercontent.com/u/82359874?v=4", + "profile": "https://github.com/rinkydevi", + "contributions": [ + "translation" + ] + }, + { + "login": "cas-c4ta", + "name": "Coding for the Arts", + "avatar_url": "https://avatars.githubusercontent.com/u/88927553?v=4", + "profile": "https://www.zhdk.ch/weiterbildung/weiterbildung-design/cas-coding-for-the-arts", + "contributions": [ + "bug" + ] + }, + { + "login": "danieljamesross", + "name": "Dan", + "avatar_url": "https://avatars.githubusercontent.com/u/28922296?v=4", + "profile": "http://danieljamesross.github.io", + "contributions": [ + "bug" + ] + }, + { + "login": "liz-peng", + "name": "Liz Peng", + "avatar_url": "https://avatars.githubusercontent.com/u/8376256?v=4", + "profile": "https://github.com/liz-peng", + "contributions": [ + "design", + "code", + "tool" + ] + }, + { + "login": "koolaidkrusade", + "name": "koolaidkrusade", + "avatar_url": "https://avatars.githubusercontent.com/u/95722198?v=4", + "profile": "https://github.com/koolaidkrusade", + "contributions": [ + "doc" + ] + }, + { + "login": "smilee", + "name": "smilee", + "avatar_url": "https://avatars.githubusercontent.com/u/5793796?v=4", + "profile": "https://github.com/smilee", + "contributions": [ + "code" + ] + }, + { + "login": "CommanderRoot", + "name": "CommanderRoot", + "avatar_url": "https://avatars.githubusercontent.com/u/4395417?v=4", + "profile": "https://github.com/CommanderRoot", + "contributions": [ + "code" + ] + }, + { + "login": "processprocess", + "name": "Philip Bell", + "avatar_url": "https://avatars.githubusercontent.com/u/3860311?v=4", + "profile": "http://philipbell.org", + "contributions": [ + "doc" + ] + }, + { + "login": "tapioca24", + "name": "tapioca24", + "avatar_url": "https://avatars.githubusercontent.com/u/12683107?v=4", + "profile": "https://github.com/tapioca24", + "contributions": [ + "plugin" + ] + }, + { + "login": "Qianqianye", + "name": "Qianqian Ye", + "avatar_url": "https://avatars.githubusercontent.com/u/18587130?v=4", + "profile": "http://qianqian-ye.com", + "contributions": [ + "code", + "design", + "doc", + "eventOrganizing", + "review", + "translation" + ] + }, + { + "login": "adarrssh", + "name": "Adarsh", + "avatar_url": "https://avatars.githubusercontent.com/u/85433137?v=4", + "profile": "https://github.com/adarrssh", + "contributions": [ + "translation" + ] + }, + { + "login": "kaabe1", + "name": "kaabe1", + "avatar_url": "https://avatars.githubusercontent.com/u/78185255?v=4", + "profile": "https://github.com/kaabe1", + "contributions": [ + "design", + "eventOrganizing" + ] + }, + { + "login": "Guirdo", + "name": "Seb Méndez", + "avatar_url": "https://avatars.githubusercontent.com/u/21044700?v=4", + "profile": "https://www.guirdo.xyz/", + "contributions": [ + "translation" + ] + }, + { + "login": "3ru", + "name": "Ryuya", + "avatar_url": "https://avatars.githubusercontent.com/u/69892552?v=4", + "profile": "https://github.com/3ru", + "contributions": [ + "bug", + "review", + "code" + ] + }, + { + "login": "LEMIBANDDEXARI", + "name": "LEMIBANDDEXARI", + "avatar_url": "https://avatars.githubusercontent.com/u/70129787?v=4", + "profile": "https://github.com/LEMIBANDDEXARI", + "contributions": [ + "translation" + ] + }, + { + "login": "probablyvivek", + "name": "Vivek Tiwari", + "avatar_url": "https://avatars.githubusercontent.com/u/25459353?v=4", + "profile": "https://linktr.ee/probablyvivek", + "contributions": [ + "translation" + ] + }, + { + "login": "KevinGrajeda", + "name": "Kevin Grajeda", + "avatar_url": "https://avatars.githubusercontent.com/u/60023139?v=4", + "profile": "https://github.com/KevinGrajeda", + "contributions": [ + "code" + ] + }, + { + "login": "anniezhengg", + "name": "anniezhengg", + "avatar_url": "https://avatars.githubusercontent.com/u/78184655?v=4", + "profile": "https://github.com/anniezhengg", + "contributions": [ + "code", + "design" + ] + }, + { + "login": "SNP0301", + "name": "Seung-Gi Kim(David)", + "avatar_url": "https://avatars.githubusercontent.com/u/68281918?v=4", + "profile": "https://github.com/SNP0301", + "contributions": [ + "translation" + ] } ], "repoType": "github", diff --git a/.github/config.yml b/.github/config.yml index 706ea19698..c4629c14ed 100644 --- a/.github/config.yml +++ b/.github/config.yml @@ -4,8 +4,7 @@ # Comment to be posted to on first time issues newIssueWelcomeComment: > - Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, be sure to follow the issue template if you haven't already. - + Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, please make sure to fill out the inputs in the issue forms. Thank you! # Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome # Comment to be posted to on PRs from first time contributors in your repository diff --git a/README.md b/README.md index a80944a7aa..84f5fec034 100644 --- a/README.md +++ b/README.md @@ -54,8 +54,8 @@ Stewards are contributors that are particularly involved, familiar, or responsiv Anyone interested can volunteer to be a steward! There are no specific requirements for expertise, just an interest in actively learning and participating. If you’re familiar with one or more parts of this project, open an issue to volunteer as a steward! -* [@outofambit](https://github.com/outofambit) - project co-lead -* [@qianqianye](https://github.com/qianqianye) - project co-lead +* [@qianqianye](https://github.com/qianqianye) - p5.js Project Lead +* [@outofambit](https://github.com/outofambit) - p5.js Mentor * [@lmccart](https://github.com/lmccart) * [@limzykenneth](https://github.com/limzykenneth) * [@stalgiag](https://github.com/stalgiag) @@ -63,24 +63,25 @@ Anyone interested can volunteer to be a steward! There are no specific requireme * [@dhowe](https://github.com/dhowe) * [@rahulm2310](https://github.com/rahulm2310) -| Area | Steward(s) | -| :-------------------------------- | :------------------------------------------- | -| Accessibility (Web Accessibility) | outofambit | -| Color | outofambit | -| Core/Environment/Rendering | outofambit
limzykenneth | -| Data | | -| DOM | outofambit | -| Events | outofambit
limzykenneth | -| Image | stalgiag | -| IO | limzykenneth | -| Math | limzykenneth | -| Typography | dhowe | -| Utilities | | -| WebGL | stalgiag | -| Build Process/Unit Testing | outofambit | -| Localization Tools | outofambit | -| Friendly Errors | outofambit | -| [Website](https://github.com/processing/p5.js-website) | limzykenneth
rahulm2310 | +| Area | Steward(s) | +| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | +| Overall | [@qianqianye](https://github.com/qianqianye) | +| [Accessibility](https://github.com/processing/p5.js/tree/main/src/accessibility) | [@kungfuchicken](https://github.com/kungfuchicken) | +| [Color](https://github.com/processing/p5.js/tree/main/src/color) | [@KleoP](https://github.com/KleoP), [@murilopolese](https://github.com/murilopolese), [@aahdee](https://github.com/aahdee) | +| [Core](https://github.com/processing/p5.js/tree/main/src/core)/Environment/Rendering | [@limzykenneth](https://github.com/limzykenneth), [@davepagurek](https://github.com/davepagurek), [@jeffawang](https://github.com/jeffawang) | +| [Data](https://github.com/processing/p5.js/tree/main/src/data) | [@kungfuchicken](https://github.com/kungfuchicken) | +| [DOM](https://github.com/processing/p5.js/tree/main/src/dom) | [@outofambit](https://github.com/outofambit), [@SarveshLimaye](https://github.com/SarveshLimaye), [@SamirDhoke](https://github.com/SamirDhoke) | +| [Events](https://github.com/processing/p5.js/tree/main/src/events) | [@limzykenneth](https://github.com/limzykenneth) | +| [Image](https://github.com/processing/p5.js/tree/main/src/image) | [@stalgiag](https://github.com/stalgiag), [@cgusb](https://github.com/cgusb), [@photon-niko](https://github.com/photon-niko), [@KleoP](https://github.com/KleoP) +| [IO](https://github.com/processing/p5.js/tree/main/src/io) | [@limzykenneth](https://github.com/limzykenneth) | +| [Math](https://github.com/processing/p5.js/tree/main/src/math) | [@limzykenneth](https://github.com/limzykenneth), [@jeffawang](https://github.com/jeffawang), [@AdilRabbani](https://github.com/AdilRabbani) | +| [Typography](https://github.com/processing/p5.js/tree/main/src/typography) | [@dhowe](https://github.com/dhowe), [@SarveshLimaye](https://github.com/SarveshLimaye) | +| [Utilities](https://github.com/processing/p5.js/tree/main/src/utilities) | [@kungfuchicken](https://github.com/kungfuchicken) | +| [WebGL](https://github.com/processing/p5.js/tree/main/src/webgl) | [@stalgiag](https://github.com/stalgiag); GSoC 2022: [@aceslowman](https://github.com/aceslowman)(Contributor), [@kjhollen](https://github.com/kjhollen)(Mentor); [@ShenpaiSharma](https://github.com/ShenpaiSharma)(Contributor), [@calebfoss](https://github.com/calebfoss)(Mentor); [@davepagurek](https://github.com/davepagurek); [@jeffawang](https://github.com/jeffawang); [@AdilRabbani](https://github.com/AdilRabbani) | +| Build Process/Unit Testing | [@outofambit](https://github.com/outofambit), [@kungfuchicken](https://github.com/kungfuchicken) | +| Localization Tools | [@outofambit](https://github.com/outofambit), [@almchung](https://github.com/almchung) | +| Friendly Errors | [@outofambit](https://github.com/outofambit), [@almchung](https://github.com/almchung) | +| [Contributor Docs](https://github.com/processing/p5.js/tree/main/contributor_docs) | [SoD 2022](https://github.com/processing/p5.js/wiki/Season-of-Docs-2022-Organization-Application---p5.js): [@limzykenneth](https://github.com/limzykenneth) | ## Contributors @@ -542,6 +543,39 @@ We recognize all types of contributions. This project follows the [all-contribut
Beau Muylle

📖 +
Ivy Feraco

🐛 +
Gareth Williams

💻 +
Ikko Ashimine

📖 +
Jonas Rinke

🐛 +
MATSUDA, Kouichi

🐛 +
stampyzfanz

📖 + + +
tae

🐛 +
Divyansh013

🌍 +
rinkydevi

🌍 +
Coding for the Arts

🐛 +
Dan

🐛 +
Liz Peng

🎨 💻 🔧 +
koolaidkrusade

📖 + + +
smilee

💻 +
CommanderRoot

💻 +
Philip Bell

📖 +
tapioca24

🔌 +
Qianqian Ye

💻 🎨 📖 📋 👀 🌍 +
Adarsh

🌍 +
kaabe1

🎨 📋 + + +
Seb Méndez

🌍 +
Ryuya

🐛 👀 💻 +
LEMIBANDDEXARI

🌍 +
Vivek Tiwari

🌍 +
Kevin Grajeda

💻 +
anniezhengg

💻 🎨 +
Seung-Gi Kim(David)

🌍 diff --git a/contributor_docs/README.md b/contributor_docs/README.md index b78d671cb0..56f4de4984 100644 --- a/contributor_docs/README.md +++ b/contributor_docs/README.md @@ -14,10 +14,10 @@ We are prioritizing work that expands access (inclusion and accessibility) to p5 The overarching p5.js project includes some repositories other than this one: -- [p5.js](https://github.com/processing/p5.js): This repository contains the source code for the p5.js library. The [user-facing p5.js reference manual](https://p5js.org/reference/) is also generated from the [JSDoc](http://usejsdoc.org/) comments included in this source code. It is maintained by [Qianqian Q Ye](https://github.com/qianqianye) and [evelyn masso](https://github.com/outofambit). -- [p5.js-website](https://github.com/processing/p5.js-website) This repository contains most of the code for the [p5.js website](http://p5js.org), with the exception of the reference manual. It is maintained by [Kenneth Lim](https://github.com/limzykenneth), [Qianqian Q Ye](https://github.com/qianqianye) and [evelyn masso](https://github.com/outofambit). -- [p5.js-sound](https://github.com/processing/p5.js-sound) This repository contains the p5.sound.js library. It is maintained by [Jason Sigal](https://github.com/therewasaguy). -- [p5.js-web-editor](https://github.com/processing/p5.js-web-editor) This repository contains the source code for the [p5.js web editor](https://editor.p5js.org). It is maintained by [Cassie Tarakajian](https://github.com/catarak). Note that the older [p5.js editor](https://github.com/processing/p5.js-editor) is now deprecated. +- **[p5.js](https://github.com/processing/p5.js)**: This repository contains the source code for the p5.js library. The [user-facing p5.js reference manual](https://p5js.org/reference/) is also generated from the [JSDoc](http://usejsdoc.org/) comments included in this source code. It is maintained by [Qianqian Q Ye](https://github.com/qianqianye) and [evelyn masso](https://github.com/outofambit). +- **[p5.js-website](https://github.com/processing/p5.js-website)**: This repository contains most of the code for the [p5.js website](http://p5js.org), with the exception of the reference manual. It is maintained by [Kenneth Lim](https://github.com/limzykenneth), [Qianqian Q Ye](https://github.com/qianqianye) and [evelyn masso](https://github.com/outofambit). +- **[p5.js-sound](https://github.com/processing/p5.js-sound)**: This repository contains the p5.sound.js library. It is maintained by [Jason Sigal](https://github.com/therewasaguy). +- **[p5.js-web-editor](https://github.com/processing/p5.js-web-editor)**: This repository contains the source code for the [p5.js web editor](https://editor.p5js.org). It is maintained by [Cassie Tarakajian](https://github.com/catarak). Note that the older [p5.js editor](https://github.com/processing/p5.js-editor) is now deprecated. @@ -25,22 +25,22 @@ The overarching p5.js project includes some repositories other than this one: There are a lot of files here! Here's a brief overview. It can be confusing, but you don't need to understand every file in the repository to get started. We recommend beginning in one area (for example, fixing some inline documentation), and working your way outwards to exploring more. Luisa Pereira's [Looking Inside p5.js](https://www.luisapereira.net/teaching/materials/processing-foundation) also gives a video tour of the tools and files used in the p5.js workflow. -- `contributor_docs/` contains documents that explain practices and principles for contributors -- `docs/` does not actually contain docs! Rather, it contains the code used to *generate* the [online reference manual](https://p5js.org/reference/). -- `lib/` contains an empty example and the p5.sound add-on, which is periodically updated via pull request from the [p5.js-sound repository](https://github.com/processing/p5.js-sound). This is also where the built p5.js library gets placed after being compiled to a single file using [Grunt](https://gruntjs.com/). It does not need to be checked into the github repository when you make a pull request. -- `src/` contains all the source code for the library, which is topically organized into separated modules. This is what you'll work on if you are changing p5.js. Most folders have their own readme.md files inside to help you find your way around. -- `tasks/` contains scripts which perform automated tasks related to the build, deployment, and release of new versions of p5.js. -- `tests/` contains unit tests which ensure the library continues to function correctly as changes are made. -- `utils/` might contain additional files useful for the repository, but generally you can ignore this directory. +- 📁`contributor_docs/` contains documents that explain practices and principles for contributors +- 📁`docs/` does not actually contain docs! Rather, it contains the code used to *generate* the [online reference manual](https://p5js.org/reference/). +- 📁`lib/` contains an empty example and the p5.sound add-on, which is periodically updated via pull request from the [p5.js-sound repository](https://github.com/processing/p5.js-sound). This is also where the built p5.js library gets placed after being compiled to a single file using [Grunt](https://gruntjs.com/). It does not need to be checked into the github repository when you make a pull request. +- 📁`src/` contains all the source code for the library, which is topically organized into separated modules. This is what you'll work on if you are changing p5.js. Most folders have their own readme.md files inside to help you find your way around. +- 📁`tasks/` contains scripts which perform automated tasks related to the build, deployment, and release of new versions of p5.js. +- 📁`tests/` contains unit tests which ensure the library continues to function correctly as changes are made. +- 📁`utils/` might contain additional files useful for the repository, but generally you can ignore this directory. # Documentation -We realize the documentation is the most important part of this project. Poor documentation is one of the main barriers to access for new users and contributors, making the project less inclusive. The [contributing_documentation.md](./contributing_documentation.md) page gives an in-depth overview of getting started with documentation. The documentation for p5.js can be found in a few main places: +We realize the documentation is the most important part of this project. Poor documentation is one of the main barriers to access for new users and contributors, making the project less inclusive. The 📄[`contributing_documentation.md`](./contributing_documentation.md) page gives an in-depth overview of getting started with documentation. The documentation for p5.js can be found in a few main places: -- The [p5js.org/reference](https://p5js.org/reference/) is generated from [inline documentation](./inline_documentation.md) in the source code itself. This includes the text descriptions and parameters as well as the accompanying code snippet examples. We place all this inline to keep the code and documentation closely linked, and to reinforce the idea that contributing to documentation is as important (if not more) than contributing to the code. When the library gets built, it checks the inline documentation and examples to ensure they match up with the way the code behaves. To contribute, you can start by looking at the [inline_documentation.md](./inline_documentation.md) page. -- The [p5js.org/examples](http://p5js.org/examples) page contains longer examples that can be useful for learning p5.js. To contribute, you can start by looking at the [adding_examples.md](https://github.com/processing/p5.js-website/blob/main/contributor_docs/Adding_examples.md) page. +- The [p5js.org/reference](https://p5js.org/reference/) is generated from [inline documentation](./inline_documentation.md) in the source code itself. This includes the text descriptions and parameters as well as the accompanying code snippet examples. We place all this inline to keep the code and documentation closely linked, and to reinforce the idea that contributing to documentation is as important (if not more) than contributing to the code. When the library gets built, it checks the inline documentation and examples to ensure they match up with the way the code behaves. To contribute, you can start by looking at the 📄[`inline_documentation.md`](./inline_documentation.md) page. +- The [p5js.org/examples](http://p5js.org/examples) page contains longer examples that can be useful for learning p5.js. To contribute, you can start by looking at the 📄[`adding_examples.md`](https://github.com/processing/p5.js-website/blob/main/contributor_docs/Adding_examples.md) page. - The [p5js.org/learn](https://p5js.org/learn) page contains tutorials to help you learn concepts of p5.js and programming. To contribute, you can start by looking at the [p5.js guide to contributing to tutorials](https://p5js.org/learn/tutorial-guide.html). - You'll notice the p5.js website currently supports a few different languages. This is called internationalization (or i18n for short). You can read more about this documentation on the [i18n_contribution](https://github.com/processing/p5.js-website/blob/main/contributor_docs/i18n_contribution.md) page. @@ -52,13 +52,13 @@ We realize the documentation is the most important part of this project. Poor do * If you'd like to start working on an existing issue, comment on the issue that you plan to work on it so other contributors know it's being handled and can offer help. -* Once you have completed your work on this issue, [submit a pull request (PR)](./preparing_a_pull_request.md) against the p5.js main branch. In the description field of the PR, include "resolves #XXXX" tagging the issue you are fixing. If the PR addresses the issue but doesn't completely resolve it (ie the issue should remain open after your PR is merged), write "addresses #XXXX". +* Once you have completed your work on this issue, [submit a pull request (“PR”)](./preparing_a_pull_request.md) against the p5.js main branch. In the description field of the PR, include "resolves #XXXX" tagging the issue you are fixing. If the PR addresses the issue but doesn't completely resolve it (ie the issue should remain open after your PR is merged), write "addresses #XXXX". * If you discover a bug or have an idea for a new feature you'd like to add, begin by submitting an issue. Please do not simply submit a pull request containing the fix or new feature without making an issue first, we will probably not be able to accept it. Once you have gotten some feedback on the issue and a go ahead to address it, you can follow the process above to contribute the fix or feature. * You can triage issues which may include reproducing bug reports or asking for vital information, such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to [subscribe to p5.js on CodeTriage](https://www.codetriage.com/processing/p5.js). [![Open Source Helpers](https://www.codetriage.com/processing/p5.js/badges/users.svg)](https://www.codetriage.com/processing/p5.js) -* The [organization.md](https://github.com/processing/p5.js/blob/main/contributor_docs/organization.md) file gives a high-level overview of how issues can be organized and the decision making processes around them. Please feel welcome to get involved with this if you are interested. +* The 📄[`organization.md`](https://github.com/processing/p5.js/blob/main/contributor_docs/organization.md) file gives a high-level overview of how issues can be organized and the decision making processes around them. Please feel welcome to get involved with this if you are interested. @@ -76,20 +76,20 @@ This process is also covered [in a video by The Coding Train.](https://youtu.be/ 3. [Clone](https://help.github.com/articles/cloning-a-repository/) your new fork of the repository from GitHub onto your local computer. - ``` + ```shell $ git clone https://github.com/YOUR_USERNAME/p5.js.git ``` 4. Navigate into the project folder and install all its necessary dependencies with npm. - ``` + ```shell $ cd p5.js $ npm ci ``` 5. [Grunt](https://gruntjs.com/) should now be installed, and you can use it to build the library from the source code. - ``` + ```shell $ npm run grunt ``` @@ -97,7 +97,7 @@ This process is also covered [in a video by The Coding Train.](https://youtu.be/ 6. Make some changes locally to the codebase and [commit](https://help.github.com/articles/github-glossary/#commit) them with Git. - ``` + ```shell $ git add -u $ git commit -m "YOUR COMMIT MESSAGE" ``` @@ -106,7 +106,7 @@ This process is also covered [in a video by The Coding Train.](https://youtu.be/ 8. [Push](https://help.github.com/articles/github-glossary/#push) your new changes to your fork on GitHub. - ``` + ```shell $ git push ``` @@ -124,19 +124,19 @@ p5.js requires clean and stylistically consistent code syntax, which it enforces To detect errors, run the following command in your terminal (do not type the `$` prompt): -``` +```shell $ npm run lint ``` Some syntax errors can be automatically fixed: -``` +```shell $ npm run lint:fix ``` Sticking with the established project style is usually preferable, but [occasionally](https://github.com/processing/p5.js/search?utf8=%E2%9C%93&q=prettier-ignore&type=) using an alternate syntax might make your code easier to understand. For these cases, Prettier [offers an escape hatch](https://prettier.io/docs/en/ignore.html), the `// prettier-ignore` comment, which you can use to make granular exceptions. Try to avoid using this if you can, because there are good reasons for most of the style preferences enforced by the linting. -Here is a quick summary of code style rules. Please note that this list may be incomplete, and it's best to refer to the [.prettierrc](https://github.com/processing/p5.js/blob/main/.prettierrc) and [.eslintrc](https://github.com/processing/p5.js/blob/main/.eslintrc) files for the full list. +Here is a quick summary of code style rules. Please note that this list may be incomplete, and it's best to refer to the 📄[`.prettierrc`](https://github.com/processing/p5.js/blob/main/.prettierrc) and 📄[`.eslintrc`](https://github.com/processing/p5.js/blob/main/.eslintrc) files for the full list. * ES6 code syntax is used * Use single quotes (rather than double quotes) @@ -145,7 +145,7 @@ Here is a quick summary of code style rules. Please note that this list may be i * All variables defined in the code should be used at least once, or removed completely -* Do not compare x == true or x == false. Use (x) or (!x) instead. x == true, is certainly different from if (x)! Compare objects to null, numbers to 0 or strings to "", if there is chance for confusion. +* Do not compare `x == true` or `x == false`. Use `(x)` or `(!x)` instead. `x == true` is certainly different from `if (x)`! Compare objects to `null`, numbers to `0`, or strings to `""`, if there is chance for confusion. * Comment your code whenever there is ambiguity or complexity in the function you are writing @@ -155,11 +155,11 @@ Here is a quick summary of code style rules. Please note that this list may be i ## Unit Tests -Unit tests are small pieces of code which are created as complements to the primary logic and perform validation. The [unit_testing.md](./unit_testing.md) page gives more information about working with unit tests. If you are developing a major new feature for p5.js, you should probably include tests. Do not submit pull requests in which the tests do not pass, because that means something is broken. +Unit tests are small pieces of code which are created as complements to the primary logic and perform validation. The 📄[`unit_testing.md`](./unit_testing.md) page gives more information about working with unit tests. If you are developing a major new feature for p5.js, you should probably include tests. Do not submit pull requests in which the tests do not pass, because that means something is broken. In order to run unit tests, you'll need to make sure you have installed the project's dependencies. -``` +```shell $ npm ci ``` @@ -170,27 +170,27 @@ This will install *all* the dependencies for p5.js; briefly, the most important Once the dependencies are installed, use Grunt to run the unit tests. -``` +```shell $ grunt ``` Sometimes it is useful to run the tests in the browser instead of on the command line. To do this, first start the [connect](https://github.com/gruntjs/grunt-contrib-connect) server: -``` +```shell $ npm run dev ``` With the server running, you should be able to open `test/test.html` in a browser. -A complete guide to unit testing is beyond the scope of the p5.js documentation, but the short version is that any major changes or new features implemented in the source code contained in the `src/` directory should also be accompanied by test files in the `test/` directory that can be executed by Mocha to verify consistent behavior in all future versions of the library. When writing unit tests, use the [Chai.js reference](http://www.chaijs.com/api/assert/) as a guide for phrasing your assertion messages so that any errors caught by your tests in the future will be consistent and consequently easier for other developers to understand. +A complete guide to unit testing is beyond the scope of the p5.js documentation, but the short version is that any major changes or new features implemented in the source code contained in the 📁`src/` directory should also be accompanied by test files in the 📁`test/` directory that can be executed by Mocha to verify consistent behavior in all future versions of the library. When writing unit tests, use the [Chai.js reference](http://www.chaijs.com/api/assert/) as a guide for phrasing your assertion messages so that any errors caught by your tests in the future will be consistent and consequently easier for other developers to understand. # Miscellaneous -- There are other files in the [contributor_docs/](https://github.com/processing/p5.js/tree/main/contributor_docs) folder that you might explore. They pertain to contributing to specific areas of this project, both technical and non-technical. +- There are other files in the 📁[`contributor_docs/`](https://github.com/processing/p5.js/tree/main/contributor_docs) folder that you might explore. They pertain to contributing to specific areas of this project, both technical and non-technical. - [Looking Inside p5.js](https://www.luisapereira.net/teaching/materials/processing-foundation) is a video tour of the tools and files used in the p5.js development workflow. - [This video from The Coding Train](https://youtu.be/Rr3vLyP1Ods) :train::rainbow: gives an overview of getting started with technical contribution to p5.js. - The p5.js [Docker image](https://github.com/toolness/p5.js-docker) can be mounted in [Docker](https://www.docker.com/) and used to develop p5.js without requiring manual installation of requirements like [Node](https://nodejs.org/) or otherwise affecting the host operating system in any way, aside from the installation of Docker. -- The build process for the p5.js library generates a [json data file](https://p5js.org/reference/data.json) which contains the public API of p5.js and can be used in automated tooling, such as for autocompleting p5.js methods in an editor. This file is hosted on the p5.js website, but it is not included as part of the repository. +- The build process for the p5.js library generates a [JSON data file](https://p5js.org/reference/data.json) which contains the public API of p5.js and can be used in automated tooling, such as for autocompleting p5.js methods in an editor. This file is hosted on the p5.js website, but it is not included as part of the repository. - p5.js has recently migrated to [ES6](https://en.wikipedia.org/wiki/ECMAScript#6th_Edition_-_ECMAScript_2015). To see how this transition could effect your contribution please visit [ES6 adoption](./es6-adoption.md). diff --git a/contributor_docs/fes_reference_dev_notes.md b/contributor_docs/fes_reference_dev_notes.md index 725d2792f6..9eb625db4c 100644 --- a/contributor_docs/fes_reference_dev_notes.md +++ b/contributor_docs/fes_reference_dev_notes.md @@ -272,7 +272,7 @@ function preload() { } ```` FES will generate the following message in the console: -> 🌸 p5.js says: An error with message "Cannot read property 'background' of undefined" occured inside the p5js library when "background" was called (on line 4 in sketch.js [http://localhost:8000/lib/empty-example/sketch.js:4:3]). +> 🌸 p5.js says: An error with message "Cannot read property 'background' of undefined" occurred inside the p5js library when "background" was called (on line 4 in sketch.js [http://localhost:8000/lib/empty-example/sketch.js:4:3]). //If not stated otherwise, it might be due to "background" being called from preload. Nothing besides load calls (loadImage, loadJSON, loadFont, loadStrings, etc.) should be inside the preload function. (http://p5js.org/reference/#/p5/preload) Internal Error Example 2 @@ -283,7 +283,7 @@ function setup() { } ```` FES will generate the following message in the console: -> 🌸 p5.js says: An error with message "Cannot read property 'bind' of undefined" occured inside the p5js library when mouseClicked was called (on line 3 in sketch.js [http://localhost:8000/lib/empty-example/sketch.js:3:7]) If not stated otherwise, it might be an issue with the arguments passed to mouseClicked. (http://p5js.org/reference/#/p5/mouseClicked) +> 🌸 p5.js says: An error with message "Cannot read property 'bind' of undefined" occurred inside the p5js library when mouseClicked was called (on line 3 in sketch.js [http://localhost:8000/lib/empty-example/sketch.js:3:7]) If not stated otherwise, it might be an issue with the arguments passed to mouseClicked. (http://p5js.org/reference/#/p5/mouseClicked) Example of an Error in User's Sketch (Scope) ````JavaScript @@ -483,4 +483,4 @@ const original_functions = { ``` * Generate the FES reference from the inline doc. This generated reference can be a separate system from our main [p5.js reference], to keep functions for sketch and console separate to reduce possible confusion. -[p5.js reference]: https://p5js.org/reference/ \ No newline at end of file +[p5.js reference]: https://p5js.org/reference/ diff --git a/contributor_docs/friendly_error_system.md b/contributor_docs/friendly_error_system.md index 28652be7b9..7cc3ecb2ed 100644 --- a/contributor_docs/friendly_error_system.md +++ b/contributor_docs/friendly_error_system.md @@ -6,15 +6,24 @@ The Friendly Error System (FES, 🌸) aims to help new programmers by providing The FES prints messages in the console window, as seen in the [p5.js Web Editor] and your browser JavaScript console. The single minified file of p5 (p5.min.js) omits the FES. - *We have an ongoing survey!* Please take a moment to fill out this 5-minute survey to help us improve the FES: [🌸 SURVEY 🌸] - [p5.js Web Editor]: https://editor.p5js.org/ -[🌸 SURVEY 🌸]: https://bit.ly/p5fesSurvey +## Lowering the Barriers to Debugging +The design of a tool should match the need of the people who will use it. As a tool that aims to lower the barriers to debugging, the design of FES is no exception. + +The best way to evaluate our existing design is to hear directly from people using p5.js. We ran a community survey in 2021 to gather feedback and future wishes for Friendly Errors. + +We believe the insights from our community members will be helpful for our contributors. You can see the results through the summary comic or the full report: +* [21-22 FES Survey Report Comic] +* [21-22 FES Survey Full Report] + + +[21-22 FES Survey Report Comic]: https://almchung.github.io/p5jsFESsurvey/ +[21-22 FES Survey Full Report]: https://observablehq.com/@almchung/p5-fes-21-survey ## Writing Friendly Error Messages -In this section, we will describe how you can contribute to the p5.js library by writing and translating error messages. +How to contribute to the p5.js library by writing and translating error messages? The FES is a part of the p5.js' [internationalization] effort. We generate all FES messages' content through [i18next]-based `translator()` function. This dynamic error message generation happens for all languages, including English - the default language of the p5.js. @@ -26,21 +35,24 @@ We welcome contributions from all around the world! 🌐 #### Writing Best Practices -FES message writers should prioritize lowering the barrier of understanding error messages and debugging. +FES message writers should prioritize lowering the barrier of understanding error messages and increasing the accessibility of debugging process. -Here are some highlights from our upcoming best-practice doc: +[Friendly Errors i18n Book] discusses challenges and best practices for writing friendly error messages within the cross-cultural i18n context. Here are some points from the book: -* Use simple sentences. Consider breaking your sentence into smaller blocks for best utilizing i18next's [interpolation] feature. -* Keep the language friendly and inclusive. Look for possible bias and harm in your language. Adhere to [p5.js Code of Conduct]. -* Avoid using figures of speech. Prioritize cross-cultural communication. -* Try to spot possible "[expert blind spots]" in an error message and its related docs. -* Introduce one technical concept or term at a time—link one external resource written in a beginner-friendly language with plenty of short, practical examples. +* Understand your audience: do not make assumptions about the audience of our error messages. Try to learn who is using our library and how they use it. +* Keep language inclusive. We strive to make error messages "friendly," what does it mean for you? Look for possible bias and harm in your language. Adhere to [p5.js Code of Conduct]. +* Use simple sentences whenever possible. Consider breaking your sentence into smaller blocks for best utilizing i18next's [interpolation] feature. +* Prioritize cross-cultural communication and provide a great experience across languages. Avoid using figures of speech. +* Introduce one technical concept or technical term at a time. Keep consistency in technical writing. Try to link one external resource written in a beginner-friendly language with plenty of short, practical examples. +[Friendly Errors i18n Book]: https://almchung.github.io/p5-fes-i18n-book/ [interpolation]: https://www.i18next.com/translation-function/interpolation [p5.js Code of Conduct]: https://github.com/processing/p5.js/blob/main/CODE_OF_CONDUCT.md#p5js-code-of-conduct [expert blind spots]: https://tilt.colostate.edu/TipsAndGuides/Tip/181 +[Friendly Errors i18n Book] is a public project, and you can contribute to the book through this separate [repo]. +[repo]: https://github.com/almchung/p5-fes-i18n-book #### Location of Translation Files `translator()` is based on i18next and imported from `src/core/internationalization.js`. It generates messages by looking up text data from a JSON translation file: diff --git a/contributor_docs/hi/README.md b/contributor_docs/hi/README.md index b24b911194..1d6930692d 100644 --- a/contributor_docs/hi/README.md +++ b/contributor_docs/hi/README.md @@ -60,20 +60,20 @@ p5.js में योगदान देने में आपकी रुच 2. [फोर्क](https://help.github.com/articles/fork-a-repo) [p5.js रिपॉजिटरी](https://github.com/processing/p5.js) अपने खुद के गिटहब खाते में। 3. [क्लोन](https://help.github.com/articles/cloning-a-repository/) आपके स्थानीय कंप्यूटर पर गिटहब से रिपॉजिटरी का नया फोर्क। - ``` + ```shell $ git clone https://github.com/YOUR_USERNAME/p5.js.git ``` 4. प्रोजेक्ट फ़ोल्डर में नेविगेट करें और npm के साथ अपनी सभी आवश्यक निर्भरताएं स्थापित करें। - ``` + ```shell $ cd p5.js $ npm ci ``` 5. [ग्रंट](https://gruntjs.com/) अब स्थापित किया जाना चाहिए, और आप इसका उपयोग स्रोत कोड से लाइब्रेरी बनाने के लिए कर सकते हैं। - ``` + ```shell $ npm run grunt ``` @@ -81,7 +81,7 @@ p5.js में योगदान देने में आपकी रुच 6. स्थानीय रूप से कोडबेस और [कमिट](https://help.github.com/articles/github-glossary/#commit) में कुछ बदलाव करें। - ``` + ```shell $ git add -u $ git commit -m "YOUR COMMIT MESSAGE" ``` @@ -90,7 +90,7 @@ p5.js में योगदान देने में आपकी रुच 8. [पुश](https://help.github.com/articles/github-glossary/#push) गिटहब पर आपके फोर्क में आपके नए परिवर्तन। - ``` + ```shell $ git push ``` @@ -108,13 +108,13 @@ p5.js को स्वच्छ और शैलीगत सुसंगत क त्रुटियों का पता लगाने के लिए, अपने टर्मिनल में निम्न कमांड चलाएँ (`$` प्रांप्ट टाइप न करें): -``` +```shell $ npm run lint ``` कुछ सिंटैक्स त्रुटियां स्वचालित रूप से ठीक की जा सकती हैं: -``` +```shell $ npm run lint:fix ``` @@ -136,7 +136,7 @@ $ npm run lint:fix इकाई परीक्षण चलाने के लिए, आपको पहले परियोजना की निर्भरताएँ स्थापित करनी होंगी। -``` +```shell $ npm ci ``` @@ -147,13 +147,13 @@ $ npm ci एक बार निर्भरताएं स्थापित हो जाने के बाद, यूनिट परीक्षणों को चलाने के लिए ग्रंट का उपयोग करें। -``` +```shell $ grunt ``` कभी-कभी कमांड लाइन पर के बजाय ब्राउज़र में परीक्षण चलाना उपयोगी होता है। ऐसा करने के लिए, पहले [कनेक्ट](https://github.com/gruntjs/grunt-contrib-connect) सर्वर शुरू करें: -``` +```shell $ npm run dev ``` diff --git a/contributor_docs/hi/preparing_a_pull_request.md b/contributor_docs/hi/preparing_a_pull_request.md index 694dd139f3..6ce9587380 100644 --- a/contributor_docs/hi/preparing_a_pull_request.md +++ b/contributor_docs/hi/preparing_a_pull_request.md @@ -12,21 +12,21 @@ ### परिवर्तनों के बारे में जानें सुनिश्चित करें कि आप अपस्ट्रीम p5.js रिपॉजिटरी को ट्रैक कर रहे हैं। - git remote show upstream + $ git remote show upstream यदि आपको कोई त्रुटि दिखाई देती है, तो आपको "upstream" रिमोट रिपॉजिटरी के रूप में मुख्य p5.js रेपो को ट्रैक करना शुरू करना होगा। आपको केवल एक बार ऐसा करने की आवश्यकता होगी! लेकिन, अगर आप इसे दूसरी बार चलाते हैं तो कोई नुकसान नहीं होता है। - git remote add upstream https://github.com/processing/p5.js + $ git remote add upstream https://github.com/processing/p5.js फिर नवीनतम परिवर्तनों के बारे में पूछें। - git fetch upstream + $ git fetch upstream ### शायद ज़रुरत पड़े- एक नई शाखा में अपने परिवर्तनों की एक प्रति बनाएँ - git branch your-branch-name-backup + $ git branch your-branch-name-backup ### मुख्य शाखा से परिवर्तन लागू करता है, *बाद में* अपने परिवर्तन जोड़ता है - git rebase upstream/main + $ git rebase upstream/main ### विवादों का समाधान आपकी शाखा में कुछ उलझनें हो सकती हैं! @@ -39,7 +39,7 @@ यदि आपके पास अन्य फ़ाइलों में विरोध है और आप सुनिश्चित नहीं हैं कि उन्हें कैसे हल किया जाए ... मदद के लिए पूछें! ### और अंत में, महान गौरव के लिए - git push origin + $ git push origin यदि आप तकनीकी विवरणों के बारे में गहन जानकारी प्राप्त कर रहे हैं, तो रेबेसिंग पर एक अच्छा संदर्भ है। https://www.atlassian.com/git/tutorials/merging-vs-rebasing diff --git a/contributor_docs/hi/unit_testing.md b/contributor_docs/hi/unit_testing.md index a7473dceb0..7c24cc910e 100644 --- a/contributor_docs/hi/unit_testing.md +++ b/contributor_docs/hi/unit_testing.md @@ -9,8 +9,8 @@ ### सभी यूनिट टेस्ट को चलाना रेपो रूट में, अपने टर्मिनल में निम्न कमांड का उपयोग करें -``` -npm test +```shell +$ npm test ``` ### परीक्षण कवरेज @@ -25,7 +25,7 @@ npm test ### एक उदाहरण केवल "p5.ColorConversion" परीक्षणों का सूट चलाने के लिए, आप पढ़ने के लिए ```test/unit/color/color_conversion.js``` की पहली पंक्ति को बदल देंगे- -``` +```js suite.only('color/p5.ColorConversion', function() { ``` @@ -80,7 +80,7 @@ Node.js परीक्षणों के लिए सेटअप सभी ` हम ```p5.prototype.isKeyPressed``` के लिए एक परीक्षण सूट बना सकते हैं और इसके लिए परीक्षण बनाना शुरू कर सकते हैं। हम अपने यूनिट परीक्षणों की संरचना के लिए Mocha का उपयोग करेंगे। -``` +```js suite('p5.prototype.keyIsPressed', function() { test('keyIsPressed is a boolean', function() { //परीक्षण यहाँ लिखें @@ -98,7 +98,7 @@ suite('p5.prototype.keyIsPressed', function() { हमने परीक्षणों की संरचना की है, लेकिन हमने अभी तक परीक्षण नहीं लिखे हैं। हम इसके लिए ची के दावे का उपयोग करेंगे। निम्नलिखित को धयान मे रखते हुए- -``` +```js test('keyIsPressed is a boolean', function() { assert.isBoolean(myp5.keyIsPressed); //दावा करता है कि मूल्य एक बूलियन है। }); diff --git a/contributor_docs/inline_documentation.md b/contributor_docs/inline_documentation.md index 2349f64a05..e893a4cc77 100644 --- a/contributor_docs/inline_documentation.md +++ b/contributor_docs/inline_documentation.md @@ -16,7 +16,7 @@ You must specify one of these for the element to appear in the docs, with the na * When possible, link to other files when mentioning other function or variable names. For example, you can see the preload method linked in the description for [loadImage](https://github.com/processing/p5.js/blob/main/src/image/loading_displaying.js#L21). * Here is [yuidoc's reference](http://yui.github.io/yuidoc/syntax/index.html#basic-requirements) for more syntax information. -``` +```js /** * The x component of the vector * @property x @@ -25,7 +25,7 @@ You must specify one of these for the element to appear in the docs, with the na this.x = x || 0; ``` -``` +```js /** * Draw an arc @@ -45,7 +45,7 @@ You must specify one of these for the element to appear in the docs, with the na */ ``` -``` +```js /** * * Calculates the magnitude (length) of the vector and returns the result @@ -98,7 +98,7 @@ If the method returns the parent object, you can skip the `@return` and add this If a method has multiple possible parameter options, you can specify each individually. For example, see the examples for [background](http://p5js.org/reference/#p5/background) under "syntax". To do this, choose one version to list as the first signature using the guidelines above. At the end of the documentation block, you can add additional signatures, each in its own block, following the example below. -``` +```js /** * @method background * @param {String} colorstring color string, possible formats include: integer @@ -123,7 +123,7 @@ Notes: Use `@final` if a property or variable is a constant: -``` +```js /** * PI is a mathematical constant with the value 3.14159265358979323846. * @property PI @@ -135,7 +135,7 @@ Use `@final` if a property or variable is a constant: Use `@private` if a property or variable is a private variable (default is `@public` so no need to specify). -``` +```js /** * _start calls preload() setup() and draw() * @@ -149,7 +149,7 @@ Use `@private` if a property or variable is a private variable (default is `@pub The top of each *file* should contain a `@module` tag. Modules should correspond to JavaScript files (or require.js modules). They can work as groups in the lists of items. See [here](https://p5js.org/reference/#collection-list-nav) (the modules are COLOR, IMAGE, IO, PVECTOR, etc.). -``` +```js /** * @module image */ @@ -163,7 +163,7 @@ define(function (require) { Constructors are defined with `@class`. Each constructor should have the tag `@class` followed by the name of the class, as well as the tag `@constructor`, and any `@param` tags required. -``` +```js /** * The p5 constructor function. * @class p5 diff --git a/contributor_docs/ko/README.md b/contributor_docs/ko/README.md index 30ecb2f78e..bf770b4736 100644 --- a/contributor_docs/ko/README.md +++ b/contributor_docs/ko/README.md @@ -75,20 +75,20 @@ p5.js 프로젝트의 핵심적인 저장소들은 아래와 같습니다: 3. 포크 된 깃허브 저장소를 로컬 컴퓨터에 [클론](https://help.github.com/articles/cloning-a-repository/) 하십시오. - ``` + ```shell $ git clone https://github.com/YOUR_USERNAME/p5.js.git ``` 4. 프로젝트 폴더로 들어가 npm에 필요한 모든 디펜던시를 설치하십시오. - ``` + ```shell $ cd p5.js $ npm ci ``` 5. 이제 [Grunt](https://gruntjs.com/)가 설치되었을텐데, 소스 코드로부터 라이브러리를 빌드하기 위해 이를 이용할 수 있습니다. - ``` + ```shell $ npm run grunt ``` @@ -96,7 +96,7 @@ p5.js 프로젝트의 핵심적인 저장소들은 아래와 같습니다: 6. 로컬에서 코드 베이스를 변경하고, 깃(Git)으로 [커밋](https://help.github.com/articles/github-glossary/#commit) 하십시오. - ``` + ```shell $ git add -u $ git commit -m "YOUR COMMIT MESSAGE" ``` @@ -105,7 +105,7 @@ p5.js 프로젝트의 핵심적인 저장소들은 아래와 같습니다: 8. 변경 사항을 여러분의 깃허브 포크에 [푸시](https://help.github.com/articles/github-glossary/#push) 하십시오. - ``` + ```shell $ git push ``` @@ -123,13 +123,13 @@ p5.js는 깔끔하고 일관성 있는 스타일의 코드 문법을 요구하 에러를 포착하기 위해서는 터미널에서 다음 명령어를 실행하세요(`$` 프롬프트는 입력하지 마십시오): -``` +```shell $ npm run lint ``` 어떤 문법 오류는 자동적으로 고쳐질 수도 있습니다: -``` +```shell $ npm run lint:fix ``` @@ -158,7 +158,7 @@ $ npm run lint:fix 유닛 테스트를 돌리기 위해서는 프로젝트의 디펜던시들을 반드시 설치해야 합니다. -``` +```shell $ npm ci ``` @@ -169,13 +169,13 @@ $ npm ci 디펜던시들이 설치되면, Grunt를 이용해 유닛 테스트를 돌리십시오. -``` +```shell $ grunt ``` 때론 커맨드 라인 대신 브라우저에서 테스트를 돌리는 것도 유용합니다. 이를 위해선, 먼저 서버 [연결](https://github.com/gruntjs/grunt-contrib-connect)을 시작하십시오: -``` +```shell $ npm run dev ``` diff --git a/contributor_docs/ko/inline_documentation.md b/contributor_docs/ko/inline_documentation.md index 8cba28438c..513a2e5bce 100644 --- a/contributor_docs/ko/inline_documentation.md +++ b/contributor_docs/ko/inline_documentation.md @@ -16,7 +16,7 @@ __[필요한 예제 목록](https://github.com/processing/p5.js/issues/1954) (gr * 가능하면 다른 함수나 변수명을 언급 할 때 다른 파일을 링크해주세요. 예를 들면, [loadImage](https://github.com/processing/p5.js/blob/main/src/image/loading_displaying.js#L21)에 대한 설명과 링크가 추가된 사전로드 방법을 살펴볼 수 있습니다. * 더 많은 구문 정보를 살펴보려면 [yuidoc의 레퍼런스](http://yui.github.io/yuidoc/syntax/index.html#basic-requirements)를 참조해주세요. -``` +```js /** * The x component of the vector * @property x @@ -25,7 +25,7 @@ __[필요한 예제 목록](https://github.com/processing/p5.js/issues/1954) (gr this.x = x || 0; ``` -``` +```js /** * Draw an arc @@ -45,7 +45,7 @@ __[필요한 예제 목록](https://github.com/processing/p5.js/issues/1954) (gr */ ``` -``` +```js /** * * Calculates the magnitude (length) of the vector and returns the result @@ -97,7 +97,7 @@ __[필요한 예제 목록](https://github.com/processing/p5.js/issues/1954) (gr 메서드에 여러개의 가능한 매개 변수 옵션이 있을 경우 각각을 개별적으로 지정할 수 있습니다. 예를 들면 "syntax" 아래에 [background](http://p5js.org/reference/#p5/background)의 예제를 참조해주세요. 이렇게 하기 위해서 위의 지침에 따라 첫 번째로 표기하여 나열 할 버전 하나를 선택해주세요. 문서 블록의 끝에서 다음 예제에 따라 자체 블록에 추가 표기를 할 수 있습니다. -``` +```js /** * @method background * @param {String} colorstring color string, possible formats include: integer @@ -122,7 +122,7 @@ __[필요한 예제 목록](https://github.com/processing/p5.js/issues/1954) (gr 프로퍼티 또는 변수가 상수 인 경우 `@final` 사용합니다: -``` +```js /** * PI is a mathematical constant with the value 3.14159265358979323846. * @property PI @@ -135,7 +135,7 @@ __[필요한 예제 목록](https://github.com/processing/p5.js/issues/1954) (gr 프로퍼티 또는 변수가 private 변수 인 경우 `@private`를 사용합니다 (기본값은 `@public`이므로 지정할 필요가 없음). -``` +```js /** * _start calls preload() setup() and draw() * @@ -149,7 +149,7 @@ __[필요한 예제 목록](https://github.com/processing/p5.js/issues/1954) (gr 각 *파일* 상단에는 `@module` 태그가 있어야합니다. 모듈은 JavaScript 파일 (또는 require.js 모듈)과 일치해야 하며, 항목리스트에서 그룹으로 작업할 수 있습니다. 여기를 참조해주세요: http://p5js.org/api/#methods(모듈은 COLOR, IMAGE, PVECTOR 등이 있습니다.) -``` +```js /** * @module image */ @@ -163,7 +163,7 @@ define(function (require) { 생성자는 `@class`로 정의됩니다. 각 생성자는 `@class` 태그와 클래스명, `@constructor` 태그 및 필요한 모든 `@param` 태그를 가지고 있어야 합니다. -``` +```js /** * The p5 constructor function. * @class p5 diff --git a/contributor_docs/ko/preparing_a_pull_request.md b/contributor_docs/ko/preparing_a_pull_request.md index f265d44832..059191b5a7 100644 --- a/contributor_docs/ko/preparing_a_pull_request.md +++ b/contributor_docs/ko/preparing_a_pull_request.md @@ -12,21 +12,21 @@ ### 변경사항을 확인해주세요 upstream p5.js 저장소를 트래킹하고 있는지 확인해주세요. - git remote show upstream + $ git remote show upstream 에러를 보게 되면, 메인 p5.js 저장소를 "upstream" 원격 저장소로 트래킹해야 합니다. 이 작업은 한 번만 하면 됩니다! 하지만, 두 번 실행해도 아무 문제 없습니다. - git remote add upstream https://github.com/processing/p5.js + $ git remote add upstream https://github.com/processing/p5.js 그런 다음 git에서 최신 변경 사항을 확인해 봅니다. - git fetch upstream + $ git fetch upstream ### 만일의 경우를 대비해, 변경사항을 새 브랜치로 복사하세요. - git branch your-branch-name-backup + $ git branch your-branch-name-backup ### main 브랜치로부터의 변경사항을 *적용한 후* 여러분이 작업한 변경 사항을 추가하세요 - git rebase upstream/main + $ git rebase upstream/main ### 충돌 해결하기 충돌이 있을 수 있습니다! @@ -39,7 +39,7 @@ lib/p5.js와 lib/p5.min.js라면 쉽게 고칠 수 있습니다. grunt로 프로 다른 파일과 충돌이 있고, 어떻게 해결해야 하는지 모른다면... 도움을 요청해 주세요! ### 마침내 - git push origin + $ git push origin 기술적으로 세부사항에 대해 궁금한 점이 있을 경우, 여기 리베이싱에 대한 좋은 레퍼런스가 있습니다. https://www.atlassian.com/git/tutorials/merging-vs-rebasing diff --git a/contributor_docs/ko/release_process.md b/contributor_docs/ko/release_process.md index 32df4de3dd..72808ffca4 100644 --- a/contributor_docs/ko/release_process.md +++ b/contributor_docs/ko/release_process.md @@ -10,8 +10,8 @@ * 높은 대역폭: 다운로드/풀/푸쉬 할것이 많습니다. (총 \~190MB 예상) ## 사용법 -``` -npm run release +```shell +$ npm run release ``` * 빌드 단계가 실행되며 프로세스를 마치려면 `np`에서 제공하는 프롬프트를 따라야합니다. diff --git a/contributor_docs/ko/unit_testing.md b/contributor_docs/ko/unit_testing.md index 8d20119b07..7aa88646e6 100644 --- a/contributor_docs/ko/unit_testing.md +++ b/contributor_docs/ko/unit_testing.md @@ -93,7 +93,7 @@ p5.js 레파지토리에서 풀리퀘스트를 오픈하면, 자동으로 [테 `p5.prototype.isKeyPressed`를 위한 테스트 스위트를 생성하고, 테스트를 작성할 수 잇습니다. 단위테스트를 구성하기 위해 mocha를 사용할 것입니다. -``` +```js suite('p5.prototype.keyIsPressed', function() { test('keyIsPressed is a boolean', function() { //이곳에서 테스트 작성 @@ -113,7 +113,7 @@ suite('p5.prototype.keyIsPressed', function() { 다음을 고려해 보세요: -``` +```js test('keyIsPressed is a boolean', function() { assert.isBoolean(myp5.keyIsPressed); //해당 값이 boolean인지 확인 }); diff --git a/contributor_docs/organization.md b/contributor_docs/organization.md index f788685b3b..f42c008ea6 100644 --- a/contributor_docs/organization.md +++ b/contributor_docs/organization.md @@ -19,7 +19,7 @@ Helping with organization can be a great way to contribute. If a bug report is m ## Pull Requests - **All pull requests should be associated with an issue** - If you want to fix a bug or add a feature, start by opening an issue so the community can discuss it. - - If a pull request is opened without an associated issue, comment and ask the contributor to open a pull request. + - If a pull request is opened without an associated issue, comment and ask the contributor to open an issue. diff --git a/contributor_docs/preparing_a_pull_request.md b/contributor_docs/preparing_a_pull_request.md index a8d2e37200..fd461ded82 100644 --- a/contributor_docs/preparing_a_pull_request.md +++ b/contributor_docs/preparing_a_pull_request.md @@ -12,18 +12,18 @@ Pull-requests are easier when your code is up to date! You can use git rebase to ### Find out about changes Make sure you're tracking upstream p5.js repository. - git remote show upstream + $ git remote show upstream If you see an error, you'll need to start tracking the main p5.js repo as an "upstream" remote repository. You'll only need to do this once! But, no harm is done if you run it a second time. - git remote add upstream https://github.com/processing/p5.js + $ git remote add upstream https://github.com/processing/p5.js Then ask git about the latest changes. - git fetch upstream + $ git fetch upstream ### Just in case: make a copy of your changes in a new branch - git branch your-branch-name-backup + $ git branch your-branch-name-backup ### Apply changes from main branch, adds your changes *after* git rebase upstream/main @@ -39,7 +39,7 @@ If it’s just lib/p5.js and lib/p5.min.js, it’s easy to fix. just build the p If you have conflicts in other files & you're not sure how to resolve them... ask for help! ### And finally, for great glory - git push origin + $ git push origin Here's a good reference on rebasing, in case you're intensely curious about the technical details. https://www.atlassian.com/git/tutorials/merging-vs-rebasing diff --git a/contributor_docs/project_wrapups/README.md b/contributor_docs/project_wrapups/README.md index 57d35cbe3d..bc72124ce8 100644 --- a/contributor_docs/project_wrapups/README.md +++ b/contributor_docs/project_wrapups/README.md @@ -1,8 +1,10 @@ -This folder contains wrapup reports for projects from p5.js related [Google Summer of Code](https://summerofcode.withgoogle.com/organizations/4915113891463168/) projects, [Processing Fellowships](https://processingfoundation.org/fellowships), and others. +This folder contains wrap-up reports from p5.js related [Google Summer of Code](https://summerofcode.withgoogle.com/organizations/4915113891463168/) and [Processing Fellowships](https://processingfoundation.org/fellowships) projects. *Note for contributors: Embedded images and media are welcome. Please host these files externally rather than placing in this repo to avoid adding growing the repository filesize too much.* +## Google Summer of Code + ### Google Summer of Code 2021 * [Adding Alt Text to the p5.js Website](https://github.com/processing/p5.js/blob/main/contributor_docs/project_wrapups/katiejliu_gsoc_2021.md) by Katie Liu, 2021 * [Adding to p5.js Friendly Error System](https://github.com/processing/p5.js/blob/main/contributor_docs/project_wrapups/shantanuKaushik_gsoc_2021.md) by Shantanu Kaushik, 2021 @@ -21,7 +23,6 @@ This folder contains wrapup reports for projects from p5.js related [Google Summ * [p5 for 50+ teaching](https://github.com/processing/p5.js/blob/main/contributor_docs/project_wrapups/inhwayeom_gsoc_2020.md) by Inhwa Yeom, 2020 * [i18n improvements and Italian translation](https://github.com/processing/p5.js/blob/main/contributor_docs/project_wrapups/yukienomiya_gsoc_2020.md) by Yukie Nomiya, 2020 - ### Google Summer of Code 2019 * [Search Bar for Sketches in the p5.js Web Editor](https://github.com/processing/p5.js/blob/main/contributor_docs/project_wrapups/rachellim_gsoc_2019.md) by Rachel Lim, 2019 * [Improving WebGL functionality of p5.js](https://github.com/processing/p5.js/blob/main/contributor_docs/project_wrapups/sanket_gsoc_2019.md) by [Sanket Singh](https://github.com/sanketsingh24), 2019 @@ -33,14 +34,7 @@ This folder contains wrapup reports for projects from p5.js related [Google Summ * [Curating Community Creativity for p5.js 1.0](https://github.com/processing/p5.js/blob/main/contributor_docs/project_wrapups/ashleykang_gsoc2019.md) by Ashley Kang, 2019 * [Math in Motion](https://github.com/processing/p5.js/blob/main/contributor_docs/project_wrapups/acheng_ogarcia_gsoc_2019.md) by Alexandra Cheng and Oskar Garcia, 2019 -### Processing Foundation Fellowships 2018 -* [A p5.js Dissection Manual](https://medium.com/processing-foundation/a-p5-js-dissection-manual-38959ff8522e) by Vijith Assar, 2018 -* [Chinese Translation for p5.js and preparing a future of more translations](https://medium.com/processing-foundation/chinese-translation-for-p5-js-and-preparing-a-future-of-more-translations-b56843ea096e), [p5.js 的中文翻译 — 为支持更多种语言翻译做准备](https://medium.com/processing-foundation/p5-js-%E7%9A%84%E4%B8%AD%E6%96%87%E7%BF%BB%E8%AF%91-%E4%B8%BA%E6%94%AF%E6%8C%81%E6%9B%B4%E5%A4%9A%E7%A7%8D%E8%AF%AD%E8%A8%80%E7%BF%BB%E8%AF%91%E5%81%9A%E5%87%86%E5%A4%87-a0fa94da770f) by Kenneth Lim, 2018 -* [Making p5.js Accessible](https://medium.com/processing-foundation/making-p5-js-accessible-e2ce366e05a0) by Luis Morales-Navarro and Mathura Govindarajan, 2018 -* [Introducing the 2018 Processing Foundation Fellows](https://medium.com/processing-foundation/introducing-the-2018-processing-foundation-fellows-a16ae4e87f80) - ### Google Summer of Code 2018 - * [A Platform for Algorithmic Composition on p5.js-sound](https://github.com/processing/p5.js/blob/main/contributor_docs/project_wrapups/junshern_gsoc_2018.md) by Chan Jun Shern, 2018 * [New JavaScript console in p5.js web editor](https://github.com/processing/p5.js/blob/main/contributor_docs/project_wrapups/liang_gsoc_2018.md) by Liang Tang, 2018 * [Updates to WebGL Mode](https://github.com/processing/p5.js/blob/main/contributor_docs/project_wrapups/aidannelson_gsoc_2018.md) by Aidan Nelson, 2018 @@ -50,6 +44,48 @@ https://github.com/processing/p5.js/blob/main/contributor_docs/project_wrapups/j * [Updating hello.p5js.org](https://github.com/processing/p5.js/blob/main/contributor_docs/project_wrapups/elginmclaren_gsoc_2018.md) by Elgin-Skye McLaren, 2018 * [Improvements to existing I/O Methods of p5.js](https://github.com/processing/p5.js/blob/main/contributor_docs/project_wrapups/tanvi_gsoc_2018.md) by Tanvi Kumar, 2018 +### Google Summer of Code 2017 ([archive](https://summerofcode.withgoogle.com/archive/2017/organizations/5256745899261952/)) +* [Processing Foundation: GSOC Grand Wrap-Up Post](https://medium.com/processing-foundation/2017-google-summer-of-code-grand-wrap-up-post-16680b1438db) +* [Improving Developer Operations](https://github.com/processing/p5.js/blob/main/contributor_docs/project_wrapups/sakshamsaxena_gsoc_2017.md) by Saksham Saxena, 2017 +* [Maps, Maps, Maps!](https://medium.com/processing-foundation/maps-maps-maps-f0914218c87b) by Cristobal Valenzuela, 2017 +* [Friendly Error System for p5.js](https://medium.com/processing-foundation/2017-marks-the-processing-foundations-sixth-year-participating-in-google-summer-of-code-d365f62fc463) by A. Mira Chung, 2017 +* [Processing Foundation: Our Summer of Code Has Begun!](https://medium.com/processing-foundation/our-summer-of-code-has-begun-dffc1bbddb7c) + + +## Processing Foundation Fellowships + +### Processing Foundation Fellowships 2021 +* [Three-Layer CS Cake - How to Make Sure Every Kid Gets Some Cake](https://medium.com/processing-foundation/three-layer-cs-cake-how-to-make-sure-every-kid-gets-some-cake-f7ee52e147f1) by Angi Chau, 2021 Teaching Fellow +* [Easy but Awesome: Free and Open-Source Creative Tools for Middle-School Students](https://medium.com/processing-foundation/easy-but-awesome-free-and-open-source-creative-tools-for-middle-school-students-89260eb3824d) by Shawn Patrick Higgins, 2021 Teaching Fellow +* [P5LIVE: Walking Through a Collaborative p5.js Environment for Live Coding](https://medium.com/processing-foundation/p5live-walking-through-a-collaborative-p5-js-environment-for-live-coding-bc39d95908c6) by Ted Davis, 2021 Teaching Fellow +* [Translating p5.js into Portuguese for the Brazilian Community](https://medium.com/processing-foundation/translating-p5-js-into-portuguese-for-the-brazilian-community-14b969e77ab1) by Felipe Santos Gomes, Julia Brasil, Katherine Finn Zander, and Marcela Mancinos, 2021 +* [Computational Mama on Creating Space for Womxn Creators through Coding with Friends](https://medium.com/processing-foundation/ambika-joshi-on-creating-space-for-womxn-creators-through-coding-with-friends-805c00301e39) by Computational Mama, 2021 +* [Teaching Humans and Machines to Listen to Arrernte, an Indigenous Language of Central Australia](https://medium.com/processing-foundation/teaching-humans-and-machines-to-listen-to-arrernte-an-indigenous-language-of-central-australia-90d86957132e) by Indigemoji, 2021 +* [Meet Our 2021 Fellows!](https://medium.com/processing-foundation/meet-our-2021-fellows-c22084da8019) + + +### Processing Foundation Fellowships 2020 +* [Open Computer Vision for p5.js and Processing](https://medium.com/processing-foundation/open-computer-vision-for-p5-js-and-processing-fb4490441705) by George Profenza, 2020 +* [Zoom-Teaching p5.js to Children Grades 3–6](https://medium.com/processing-foundation/zoom-teaching-p5-js-to-children-grades-3-6-54a0955c0ba5) by Michael O’Connell, 2020 +* [Visualizing the Americans with Disabilities Act Using p5.js](https://medium.com/processing-foundation/visualizing-the-americans-with-disabilities-act-using-p5-js-7853b9180b56) by Kalila Shapiro, 2020 +* [p5.js for Ages 50+ in Korea](https://medium.com/processing-foundation/p5-js-for-ages-50-in-korea-50d47b5927fb) by Inhwa Yeom & Seonghyeon Kim, 2020 +* [Chill and Cozy p5.js & Processing Tutorials on Twitch](https://medium.com/processing-foundation/chill-and-cozy-p5-js-processing-tutorials-on-twitch-c10f068d0a7f) by Aren Davey, 2020 +* [Meet Our 2020 Fellows!](https://medium.com/processing-foundation/meet-our-2020-fellows-7a51034f6845) + +### Processing Foundation Fellowships 2019 +* [Interview with Stalgia Grigg, 2019 p5.js Fellow](https://medium.com/processing-foundation/interview-with-stalgia-grigg-2019-p5-js-fellow-6fc40252e0) by Stalgia Grigg, 2019 p5.js Fellow +* [Interview with Evelyn Masso, 2019 p5.js Fellow](https://medium.com/processing-foundation/interview-with-evelyn-masso-2019-p5-js-fellow-7ac6769704df) by Evelyn Masso, 2019 p5.js Fellow +* [Coding with Sound and Art for Middle-School Students](https://medium.com/processing-foundation/interview-with-2019-teaching-fellow-layla-quinones-3039f10ae761) by Layla Quinones, 2019 Teaching Fellow +* [p5.js Tutorials for Womxn in China](https://medium.com/processing-foundation/interview-with-2019-fellow-qianqian-ye-799c0115c295) by Qianqian Ye, 2019 +* [Teaching p5.js in Hindi](https://medium.com/processing-foundation/interview-with-2019-fellows-manaswini-das-nancy-chauhan-and-shaharyar-shamshi-172127c2e277) by Manaswini Das, Nancy Chauhan, and Shaharyar Shamshi, 2019 +* [Meet Our 2019 Fellows!](https://medium.com/processing-foundation/meet-our-2019-fellows-9f13d4e4a68a) + +### Processing Foundation Fellowships 2018 +* [A p5.js Dissection Manual](https://medium.com/processing-foundation/a-p5-js-dissection-manual-38959ff8522e) by Vijith Assar, 2018 +* [Chinese Translation for p5.js and preparing a future of more translations](https://medium.com/processing-foundation/chinese-translation-for-p5-js-and-preparing-a-future-of-more-translations-b56843ea096e), [p5.js 的中文翻译 — 为支持更多种语言翻译做准备](https://medium.com/processing-foundation/p5-js-%E7%9A%84%E4%B8%AD%E6%96%87%E7%BF%BB%E8%AF%91-%E4%B8%BA%E6%94%AF%E6%8C%81%E6%9B%B4%E5%A4%9A%E7%A7%8D%E8%AF%AD%E8%A8%80%E7%BF%BB%E8%AF%91%E5%81%9A%E5%87%86%E5%A4%87-a0fa94da770f) by Kenneth Lim, 2018 +* [Making p5.js Accessible](https://medium.com/processing-foundation/making-p5-js-accessible-e2ce366e05a0) by Luis Morales-Navarro and Mathura Govindarajan, 2018 +* [Introducing the 2018 Processing Foundation Fellows](https://medium.com/processing-foundation/introducing-the-2018-processing-foundation-fellows-a16ae4e87f80) + ### Processing Foundation Fellowships 2017 * [p5 Accessibility](https://medium.com/processing-foundation/p5-accessibility-115d84535fa8) by Claire Kearney-Volpe, 2017 * [A p5.js Web Editor for All](https://medium.com/processing-foundation/a-p5-js-web-editor-for-all-64aaa3f9d767) by Cassie Tarakajian, 2017 @@ -60,10 +96,4 @@ https://github.com/processing/p5.js/blob/main/contributor_docs/project_wrapups/j * [Creative Coding with p5.js for Prisons in Washington State](https://medium.com/processing-foundation/creative-coding-with-p5-js-for-prisons-in-washington-state-3bd1d342d769) by Susan Evans, 2017 * [Announcing our 2017 Processing Foundation Fellows](https://medium.com/processing-foundation/announcing-our-2017-processing-foundation-fellows-8b9e7c8bd2f) -### Google Summer of Code 2017 ([archive](https://summerofcode.withgoogle.com/archive/2017/organizations/5256745899261952/)) -* [Processing Foundation: GSOC Grand Wrap-Up Post](https://medium.com/processing-foundation/2017-google-summer-of-code-grand-wrap-up-post-16680b1438db) -* [Improving Developer Operations](https://github.com/processing/p5.js/blob/main/contributor_docs/project_wrapups/sakshamsaxena_gsoc_2017.md) by Saksham Saxena, 2017 -* [Maps, Maps, Maps!](https://medium.com/processing-foundation/maps-maps-maps-f0914218c87b) by Cristobal Valenzuela, 2017 -* [Friendly Error System for p5.js](https://medium.com/processing-foundation/2017-marks-the-processing-foundations-sixth-year-participating-in-google-summer-of-code-d365f62fc463) by A. Mira Chung, 2017 -* [Processing Foundation: Our Summer of Code Has Begun!](https://medium.com/processing-foundation/our-summer-of-code-has-begun-dffc1bbddb7c) diff --git a/contributor_docs/project_wrapups/sakshamsaxena_gsoc_2017.md b/contributor_docs/project_wrapups/sakshamsaxena_gsoc_2017.md index 7b7a655194..967fcf4509 100644 --- a/contributor_docs/project_wrapups/sakshamsaxena_gsoc_2017.md +++ b/contributor_docs/project_wrapups/sakshamsaxena_gsoc_2017.md @@ -20,8 +20,8 @@ Some helpful comments are added alongside to make the experience of reporting an This task was inspired by [Issue #94](https://github.com/processing/p5.js/issues/94). The goal was to implement such a functionality which enables users to select the desired components/modules which they want to use, and only those components would be bundled then itself to generate a custom build of p5.js. Currently, the usage is through invoking a Grunt task manually from the command line : -``` -grunt combineModules:module_a[:module_b][:module_c] +```shell +$ grunt combineModules:module_a[:module_b][:module_c] ``` where `module_X` refers to the name of the _*folder*_ of the desired component, viz. : ``` diff --git a/contributor_docs/release_process.md b/contributor_docs/release_process.md index fe2952f707..bdf3a57745 100644 --- a/contributor_docs/release_process.md +++ b/contributor_docs/release_process.md @@ -10,8 +10,8 @@ * High Bandwidth : Lots of things to download/pull/push (\~190 MB total I presume) ## Usage -``` -npm run release +```shell +$ npm run release ``` * This will run the build steps and you should follow the prompt provided by `np` to finish the process. diff --git a/contributor_docs/sk/README.md b/contributor_docs/sk/README.md index e2a98f0d57..76e92d8396 100644 --- a/contributor_docs/sk/README.md +++ b/contributor_docs/sk/README.md @@ -46,13 +46,13 @@ Vývojárske nástroje zahrnuté v kóde p5.js sú zámerne veľmi striktné oh p5.js požaduje čistý a štylisticky konzistentnú syntax kódu, ktorá je presadzovaná pomocou [Prettier](https://prettier.io/) a [ESlint](https://eslint.org/). Pravidlá sa kontrolujú pred odovzdaním kódu, avšak môžes si nainštalovať [ESlint plugin](https://eslint.org/docs/user-guide/integrations#editors) do svojho editora kódu, aby ti zvýraznil chyby hneď ako ich píšeš, čo ti pravdepodobne pomože predčasne predísť problémom s odovzdaním kódu s Gitom. Vo všeobecnosti sa mýlime na strane flexibility, pokiaľ ide o štýl kódovania, aby sme znížili prekážky účasti a príspevku. Pre odhalenie chýb vykonaj nasledujúci príkaz vo svojom oblúbenom príkazovom riadku (nepíš znak `$`): -``` +```shell $ npm run lint ``` Niektoré syntaktické chyby je však možné opraviť automaticky pomocou príkazu: -``` +```shell $ npm run lint:fix ``` Lepšie je držať sa zavedeného štýlu projektu, ale [príležitostne](https://github.com/processing/p5.js/search?utf8=%E2%9C%93&q=prettier-ignore&type=) by sa mohla použiť alternatívna syntax. Uľahčite tým pochopenie kódu. V týchto prípadoch Prettier [ponúka výnimky](https://prettier.io/docs/en/ignore.html), komentár `// prettier-ignore`, ktorý môžete použiť na získanie podrobných výnimiek. Pokúste sa vyhnúť použitiu tohto, ak je to možné, pretože existujú dobré dôvody pre väčšinu preferencií štýlov vynútených štylistickým procesorom. @@ -72,7 +72,7 @@ Unit testy sú malé časti kódu, ktoré sú vytvorené ako doplnok k hlavnej l Aby bolo možné spustiť unit testy, budeš musieť nainštalovať závislosti projektu. -``` +```shell $ npm ci ``` @@ -83,13 +83,13 @@ Tento príkaz nainštaluje *všetky* závislosti p5.js; stručne, najdôležitej Ak sú závislosti nainštalované, použi Grunt pre spustenie unit testov. -``` +```shell $ grunt ``` Niekedy je užitočné spustiť testy v priamo v prehliadači miesto príkazového riadku. Aby si tak urobil, najprv naštartuj [connect](https://github.com/gruntjs/grunt-contrib-connect) server: -``` +```shell $ npm run dev ``` @@ -103,20 +103,20 @@ Kompletný návod k unit testovaniu je nad rámec rozsahu p5.js dokumentácie, a 2. [Rozvetvi](https://help.github.com/articles/fork-a-repo) [repozitár p5.js](https://github.com/processing/p5.js) do svojho GitHub účtu. 3. [Vyklonuj](https://help.github.com/articles/cloning-a-repository/) svoj novo-rozvetvený repozitár z GitHub-u do svoj lokálneho počítača. - ``` + ```shell $ git clone https://github.com/YOUR_USERNAME/p5.js.git ``` 4. Prejdi do priečniku projektu a nainštaluj všetky nevyhnutné závislosti s npm. - ``` + ```shell $ cd p5.js $ npm ci ``` 5. [Grunt](https://gruntjs.com/) by mal byť teraz nainštalovaný a môžeš ho teda použiť na vybudovanie knižnice zo zdrojového kódu. - ``` + ```shell $ npm run grunt ``` @@ -124,7 +124,7 @@ Kompletný návod k unit testovaniu je nad rámec rozsahu p5.js dokumentácie, a 6. Vykonaj nejaké zmeny v lokálnom kóde a [odovzdaj](https://help.github.com/articles/github-glossary/#commit) ich s Git-om. - ``` + ```shell $ git add -u $ git commit -m "YOUR COMMIT MESSAGE" ``` @@ -133,7 +133,7 @@ Kompletný návod k unit testovaniu je nad rámec rozsahu p5.js dokumentácie, a 8. [Vypropaguj](https://help.github.com/articles/github-glossary/#push) svoje nové zmeny do svojho rozvetveného repozitára na GitHub-e. - ``` + ```shell $ git push ``` @@ -145,7 +145,7 @@ Tento proces je tiež pokrytý [vo videu od The Coding Train.](https://youtu.be/ Vnorené komentáre v p5.js sa budujú do verejnej [referenčnej príručky](https://p5js.org/reference/). Túto príručku si vieš pozrieť aj lokálne: -``` +```shell $ npm run docs:dev ``` diff --git a/contributor_docs/unit_testing.md b/contributor_docs/unit_testing.md index e060752fa6..f0f4f76cab 100644 --- a/contributor_docs/unit_testing.md +++ b/contributor_docs/unit_testing.md @@ -11,7 +11,7 @@ Here's a [good, quick intro to unit testing](https://codeburst.io/javascript-uni In the repo root, use the following command in your terminal ```shellsession -npm test +$ npm test ``` ## Test Coverage @@ -91,7 +91,7 @@ Now you can think of various tests against this expected behaviour. Possible tes We can create a test suite for `p5.prototype.keyIsPressed` and start creating tests for it. We will use mocha for structuring our unit tests. -``` +```js suite('p5.prototype.keyIsPressed', function() { test('keyIsPressed is a boolean', function() { //write test here @@ -110,7 +110,7 @@ suite('p5.prototype.keyIsPressed', function() { We have structured out tests but we haven't written the tests yet. We will be using chai's assert for that. Consider the following: -``` +```js test('keyIsPressed is a boolean', function() { assert.isBoolean(myp5.keyIsPressed); //Asserts that value is a boolean. }); diff --git a/contributor_docs/zh/README.md b/contributor_docs/zh/README.md index db4864cfe0..ce10d2c29d 100644 --- a/contributor_docs/zh/README.md +++ b/contributor_docs/zh/README.md @@ -63,20 +63,20 @@ p5.js 项目除了这个代码库外还包括了以下几个其他的代码库 3. [复制](https://help.github.com/articles/cloning-a-repository/) 此代码库的新 fork 到本地电脑: - ``` + ```shell $ git clone https://github.com/您的用户名/p5.js.git ``` 4. 导航到项目文件夹,并使用 npm 安装其所有所需的程式包。 - ``` + ```shell $ cd p5.js $ npm ci ``` 5. [Grunt](https://gruntjs.com/) 需要被安装,您可以使用它从源代码构建程式库。 - ``` + ```shell $ npm run grunt ``` @@ -84,7 +84,7 @@ p5.js 项目除了这个代码库外还包括了以下几个其他的代码库 6. 在本地源代码更改然后用 Git [commit](https://help.github.com/articles/github-glossary/#commit) 它们。 - ``` + ```shell $ git add -u $ git commit -m "YOUR COMMIT MESSAGE" ``` @@ -93,7 +93,7 @@ p5.js 项目除了这个代码库外还包括了以下几个其他的代码库 8. 将您对 GitHub 上的 fork 上载([Push](https://help.github.com/articles/github-glossary/#push))新更改。 - ``` + ```shell $ git push ``` @@ -109,13 +109,13 @@ p5.js 要求整齐且在风格上一致的代码语法,它使用称为 [Pretti 要检查错误,在命令行输入以下指令(不要键入 `$` 提示符): -``` +```shell $ npm run lint ``` 一些语法错误可以自动修复: -``` +```shell $ npm run lint:fix ``` @@ -142,7 +142,7 @@ $ npm run lint:fix 以运行单元测试,您需要确保已安装项目的依赖项。 -``` +```shell $ npm ci ``` @@ -153,13 +153,13 @@ $ npm ci 一旦安装了依赖项,请使用Grunt运行单元测试。 -``` +```shell $ grunt ``` 在浏览器而不是命令行中运行测试有时很有用。 为此,请首先启动 [connect](https://github.com/gruntjs/grunt-contrib-connect) 服务器: -``` +```shell $ npm run dev ``` diff --git a/docs/preprocessor.js b/docs/preprocessor.js index bbf7c3f0c2..08938280f0 100644 --- a/docs/preprocessor.js +++ b/docs/preprocessor.js @@ -10,7 +10,7 @@ function smokeTestMethods(data) { if ( classitem.access !== 'private' && - classitem.file.substr(0, 3) === 'src' && + classitem.file.slice(0, 3) === 'src' && classitem.name && !classitem.example ) { @@ -271,7 +271,7 @@ function buildParamDocs(docs) { function renderItemDescriptionsAsMarkdown(item) { if (item.description) { const entities = new Entities(); - item.description = entities.decode(marked(item.description)); + item.description = entities.decode(marked.parse(item.description)); } if (item.params) { item.params.forEach(renderItemDescriptionsAsMarkdown); diff --git a/docs/yuidoc-p5-theme/assets/transformation-matrix-4-4.png b/docs/yuidoc-p5-theme/assets/transformation-matrix-4-4.png new file mode 100644 index 0000000000..f4203b3312 Binary files /dev/null and b/docs/yuidoc-p5-theme/assets/transformation-matrix-4-4.png differ diff --git a/lib/addons/p5.sound.js b/lib/addons/p5.sound.js index ca19c190a9..a8a7e3f450 100644 --- a/lib/addons/p5.sound.js +++ b/lib/addons/p5.sound.js @@ -218,7 +218,7 @@ function getAudioContext() { * example below. This method utilizes * StartAudioContext * , a library by Yotam Mann (MIT Licence, 2016).

- * @param {Element|Array} [element(s)] This argument can be an Element, + * @param {Element|Array} [elements] This argument can be an Element, * Selector String, NodeList, p5.Element, * jQuery Element, or an Array of any of those. * @param {Function} [callback] Callback to invoke when the AudioContext diff --git a/package-lock.json b/package-lock.json index 5a31bfab4f..fec35c0586 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "p5", - "version": "1.4.1", + "version": "1.4.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -2431,6 +2431,38 @@ "to-fast-properties": "^2.0.0" } }, + "@kwsites/file-exists": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz", + "integrity": "sha512-m9/5YGR18lIwxSFDwfE3oA7bWuq9kdau6ugN4H2rJeyhFQZcG9AgSHkQtSD15a8WvTgfz9aikZMrKPHvbpqFiw==", + "dev": true, + "requires": { + "debug": "^4.1.1" + }, + "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } + } + }, + "@kwsites/promise-deferred": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@kwsites/promise-deferred/-/promise-deferred-1.1.1.tgz", + "integrity": "sha512-GaHYm+c0O9MjZRu0ongGBRbinu8gVAMd2UZjji6jVmqKtZluZnptXGWhz1E8j8D2HJ3f/yMxKAUC0b+57wncIw==", + "dev": true + }, "@samverschueren/stream-to-observable": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz", @@ -6552,9 +6584,9 @@ "dev": true }, "getobject": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/getobject/-/getobject-1.0.0.tgz", - "integrity": "sha512-tbUz6AKKKr2YiMB+fLWIgq5ZeBOobop9YMMAU9dC54/ot2ksMXt3DOFyBuhZw6ptcVszEykgByK20j7W9jHFag==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/getobject/-/getobject-1.0.2.tgz", + "integrity": "sha512-2zblDBaFcb3rB4rF77XVnuINOE2h2k/OnqXAiy0IrTxUfV1iFp3la33oAQVY9pCpWU268WFYVt2t71hlMuLsOg==", "dev": true }, "getpass": { @@ -6700,9 +6732,9 @@ "dev": true }, "grunt": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/grunt/-/grunt-1.3.0.tgz", - "integrity": "sha512-6ILlMXv11/4cxuhSMfSU+SfvbxrPuqZrAtLN64+tZpQ3DAKfSQPQHRbTjSbdtxfyQhGZPtN0bDZJ/LdCM5WXXA==", + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/grunt/-/grunt-1.5.3.tgz", + "integrity": "sha512-mKwmo4X2d8/4c/BmcOETHek675uOqw0RuA/zy12jaspWqvTp4+ZeQF1W+OTpcbncnaBsfbQJ6l0l4j+Sn/GmaQ==", "dev": true, "requires": { "dateformat": "~3.0.3", @@ -6710,10 +6742,10 @@ "exit": "~0.1.2", "findup-sync": "~0.3.0", "glob": "~7.1.6", - "grunt-cli": "~1.3.2", - "grunt-known-options": "~1.1.0", + "grunt-cli": "~1.4.3", + "grunt-known-options": "~2.0.0", "grunt-legacy-log": "~3.0.0", - "grunt-legacy-util": "~2.0.0", + "grunt-legacy-util": "~2.0.1", "iconv-lite": "~0.4.13", "js-yaml": "~3.14.0", "minimatch": "~3.0.4", @@ -6722,6 +6754,37 @@ "rimraf": "~3.0.2" }, "dependencies": { + "grunt-cli": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/grunt-cli/-/grunt-cli-1.4.3.tgz", + "integrity": "sha512-9Dtx/AhVeB4LYzsViCjUQkd0Kw0McN2gYpdmGYKtE2a5Yt7v1Q+HYZVWhqXc/kGnxlMtqKDxSwotiGeFmkrCoQ==", + "dev": true, + "requires": { + "grunt-known-options": "~2.0.0", + "interpret": "~1.1.0", + "liftup": "~3.0.1", + "nopt": "~4.0.1", + "v8flags": "~3.2.0" + }, + "dependencies": { + "nopt": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.3.tgz", + "integrity": "sha512-CvaGwVMztSMJLOeXPrez7fyfObdZqNUK1cPAEzLHrTybIua9pMdmmPR5YwtfNftIOMv3DPUhFaxsZMNTQO20Kg==", + "dev": true, + "requires": { + "abbrev": "1", + "osenv": "^0.1.4" + } + } + } + }, + "grunt-known-options": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/grunt-known-options/-/grunt-known-options-2.0.0.tgz", + "integrity": "sha512-GD7cTz0I4SAede1/+pAbmJRG44zFLPipVtdL9o3vqx9IEyb7b4/Y3s7r6ofI3CchR5GvYJ+8buCSioDv5dQLiA==", + "dev": true + }, "js-yaml": { "version": "3.14.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", @@ -6746,6 +6809,15 @@ "requires": { "glob": "^7.1.3" } + }, + "v8flags": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.2.0.tgz", + "integrity": "sha512-mH8etigqMfiGWdeXpaaqGfs6BndypxusHHcv2qSHyZkGEznCd/qAXCWWRzeowtL54147cktFOC4P5y+kl8d8Jg==", + "dev": true, + "requires": { + "homedir-polyfill": "^1.0.1" + } } } }, @@ -7158,14 +7230,6 @@ "grunt-legacy-log-utils": "~2.1.0", "hooker": "~0.2.3", "lodash": "~4.17.19" - }, - "dependencies": { - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true - } } }, "grunt-legacy-log-utils": { @@ -7188,9 +7252,9 @@ } }, "chalk": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", - "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -7212,12 +7276,6 @@ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true }, - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true - }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -7245,15 +7303,9 @@ }, "dependencies": { "async": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/async/-/async-3.2.0.tgz", - "integrity": "sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw==", - "dev": true - }, - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.3.tgz", + "integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==", "dev": true }, "which": { @@ -8148,6 +8200,15 @@ "ci-info": "^2.0.0" } }, + "is-core-module": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz", + "integrity": "sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, "is-data-descriptor": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", @@ -8962,6 +9023,108 @@ } } }, + "liftup": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/liftup/-/liftup-3.0.1.tgz", + "integrity": "sha512-yRHaiQDizWSzoXk3APcA71eOI/UuhEkNN9DiW2Tt44mhYzX4joFoCZlxsSOF7RyeLlfqzFLQI1ngFq3ggMPhOw==", + "dev": true, + "requires": { + "extend": "^3.0.2", + "findup-sync": "^4.0.0", + "fined": "^1.2.0", + "flagged-respawn": "^1.0.1", + "is-plain-object": "^2.0.4", + "object.map": "^1.0.1", + "rechoir": "^0.7.0", + "resolve": "^1.19.0" + }, + "dependencies": { + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "findup-sync": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-4.0.0.tgz", + "integrity": "sha512-6jvvn/12IC4quLBL1KNokxC7wWTvYncaVUYSoxWw7YykPLuRrnv4qdHcSOywOI5RpkOVGeQRtWM8/q+G6W6qfQ==", + "dev": true, + "requires": { + "detect-file": "^1.0.0", + "is-glob": "^4.0.0", + "micromatch": "^4.0.2", + "resolve-dir": "^1.0.1" + } + }, + "is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dev": true, + "requires": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + } + }, + "rechoir": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.7.1.tgz", + "integrity": "sha512-/njmZ8s1wVeR6pjTZ+0nCnv8SpZNRMT2D1RLOJQESlYFDBvwpTA4KWJpZ+sBJ4+vhjILRcK7JIFdGCdxEAAitg==", + "dev": true, + "requires": { + "resolve": "^1.9.0" + } + }, + "resolve": { + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", + "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==", + "dev": true, + "requires": { + "is-core-module": "^2.8.1", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + } + } + }, "lines-and-columns": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz", @@ -9639,9 +9802,9 @@ } }, "marked": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/marked/-/marked-0.7.0.tgz", - "integrity": "sha512-c+yYdCZJQrsRjTPhUx7VKkApw9bwDkNbHUKo1ovgcfDjb2kc8rLuRbIFyXL5WOEUwzSSKo3IXpph2K6DqB/KZg==", + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/marked/-/marked-4.0.10.tgz", + "integrity": "sha512-+QvuFj0nGgO970fySghXGmuw+Fd0gD2x3+MqCWLIPf5oxdv1Ka6b2q+z9RP01P/IaKPMEramy+7cNy/Lw8c3hw==", "dev": true }, "maxmin": { @@ -9842,9 +10005,9 @@ } }, "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", "dev": true }, "minimist-options": { @@ -12833,6 +12996,12 @@ "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", "dev": true }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + }, "pinkie": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", @@ -13936,9 +14105,9 @@ "dev": true }, "shell-quote": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.2.tgz", - "integrity": "sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg==", + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.3.tgz", + "integrity": "sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==", "dev": true }, "signal-exit": { @@ -14028,9 +14197,9 @@ "dev": true }, "simple-get": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.0.tgz", - "integrity": "sha512-bCR6cP+aTdScaQCnQKbPKtJOKDp/hj9EDLJo3Nw4y1QksqaovlW/bnptB6/c1e+qmNIDHRK+oXFDdEqBT8WzUA==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.1.tgz", + "integrity": "sha512-CQ5LTKGfCpvE1K0n2us+kuMPbk/q0EKl82s4aheV9oXjFEz6W/Y7oQFVJuU6QG77hRT4Ghb5RURteF5vnWjupA==", "dev": true, "optional": true, "requires": { @@ -14050,30 +14219,32 @@ } }, "mimic-response": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.0.0.tgz", - "integrity": "sha512-8ilDoEapqA4uQ3TwS0jakGONKXVJqpy+RpM+3b7pLdOjghCrEiGp9SRkFbUHAmZW9vdnrENWHjaweIoTIJExSQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.1.0.tgz", + "integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==", "dev": true, "optional": true } } }, "simple-git": { - "version": "1.132.0", - "resolved": "https://registry.npmjs.org/simple-git/-/simple-git-1.132.0.tgz", - "integrity": "sha512-xauHm1YqCTom1sC9eOjfq3/9RKiUA9iPnxBbrY2DdL8l4ADMu0jjM5l5lphQP5YWNqAL2aXC/OeuQ76vHtW5fg==", + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/simple-git/-/simple-git-3.5.0.tgz", + "integrity": "sha512-fZsaq5nzdxQRhMNs6ESGLpMUHoL5GRP+boWPhq9pMYMKwOGZV2jHOxi8AbFFA2Y/6u4kR99HoULizSbpzaODkA==", "dev": true, "requires": { - "debug": "^4.0.1" + "@kwsites/file-exists": "^1.1.1", + "@kwsites/promise-deferred": "^1.1.1", + "debug": "^4.3.3" }, "dependencies": { "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } }, "ms": { @@ -14621,6 +14792,12 @@ } } }, + "supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true + }, "symbol-observable": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.0.1.tgz", @@ -15198,13 +15375,21 @@ } }, "underscore.string": { - "version": "3.3.5", - "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.3.5.tgz", - "integrity": "sha512-g+dpmgn+XBneLmXXo+sGlW5xQEt4ErkS3mgeN2GFbremYeMBSJKr9Wf2KJplQVaiPY/f7FN6atosWYNm9ovrYg==", + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.3.6.tgz", + "integrity": "sha512-VoC83HWXmCrF6rgkyxS9GHv8W9Q5nhMKho+OadDJGzL2oDYbYEppBaCMH6pFlwLeqj2QS+hhkw2kpXkSdD1JxQ==", "dev": true, "requires": { - "sprintf-js": "^1.0.3", + "sprintf-js": "^1.1.1", "util-deprecate": "^1.0.2" + }, + "dependencies": { + "sprintf-js": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz", + "integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==", + "dev": true + } } }, "unicode-canonical-property-names-ecmascript": { diff --git a/package.json b/package.json index abf9634ac6..4c4cba9eb6 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "node --require @babel/register ./utils/sample-linter.js" ] }, - "version": "1.4.1", + "version": "1.4.2", "devDependencies": { "@babel/core": "^7.7.7", "@babel/preset-env": "^7.10.2", @@ -73,7 +73,7 @@ "i18next-browser-languagedetector": "^4.0.1", "libtess": "^1.2.2", "lint-staged": "^4.3.0", - "marked": "^0.7.0", + "marked": "^4.0.10", "mocha": "^6.2.2", "np": "^5.2.1", "omggif": "^1.0.10", @@ -84,7 +84,7 @@ "puppeteer": "^10.2.0", "regenerator-runtime": "^0.13.3", "request": "^2.88.0", - "simple-git": "^1.132.0", + "simple-git": "^3.3.0", "whatwg-fetch": "^2.0.4" }, "license": "LGPL-2.1", diff --git a/src/color/p5.Color.js b/src/color/p5.Color.js index 373c047370..d7c9876b85 100644 --- a/src/color/p5.Color.js +++ b/src/color/p5.Color.js @@ -12,7 +12,7 @@ import * as constants from '../core/constants'; import color_conversion from './color_conversion'; /** - * Each color stores the color mode and level maxes that was applied at the + * Each color stores the color mode and level maxes that were applied at the * time of its construction. These are used to interpret the input arguments * (at construction and later for that instance of color) and to format the * output e.g. when saturation() is requested. @@ -21,7 +21,7 @@ import color_conversion from './color_conversion'; * point form, normalized from 0 to 1. From this we calculate the closest * screen color (RGBA levels from 0 to 255) and expose this to the renderer. * - * We also cache normalized, floating point components of the color in various + * We also cache normalized, floating-point components of the color in various * representations as they are calculated. This is done to prevent repeating a * conversion that has already been performed. * @@ -49,7 +49,7 @@ p5.Color = function(pInst, vals) { }; /** - * This function returns the color formatted as a string. This can be useful + * This method returns the color formatted as a string. This can be useful * for debugging, or for using p5.js with other libraries. * * @method toString @@ -252,7 +252,7 @@ p5.Color.prototype.toString = function(format) { }; /** - * The setRed function sets the red component of a color. + * The setRed method sets the red component of a color. * The range depends on your color mode, in the default RGB mode it's between 0 and 255. * @method setRed * @param {Number} red the new red value @@ -279,7 +279,7 @@ p5.Color.prototype.setRed = function(new_red) { }; /** - * The setGreen function sets the green component of a color. + * The setGreen method sets the green component of a color. * The range depends on your color mode, in the default RGB mode it's between 0 and 255. * @method setGreen * @param {Number} green the new green value @@ -302,7 +302,7 @@ p5.Color.prototype.setGreen = function(new_green) { }; /** - * The setBlue function sets the blue component of a color. + * The setBlue method sets the blue component of a color. * The range depends on your color mode, in the default RGB mode it's between 0 and 255. * @method setBlue * @param {Number} blue the new blue value @@ -325,7 +325,7 @@ p5.Color.prototype.setBlue = function(new_blue) { }; /** - * The setAlpha function sets the transparency (alpha) value of a color. + * The setAlpha method sets the transparency (alpha) value of a color. * The range depends on your color mode, in the default RGB mode it's between 0 and 255. * @method setAlpha * @param {Number} alpha the new alpha value @@ -357,6 +357,10 @@ p5.Color.prototype._calculateLevels = function() { for (let i = array.length - 1; i >= 0; --i) { levels[i] = Math.round(array[i] * 255); } + + // Clear cached HSL/HSB values + this.hsla = null; + this.hsba = null; }; p5.Color.prototype._getAlpha = function() { diff --git a/src/color/setting.js b/src/color/setting.js index eac1c926a0..2d2c5f6188 100644 --- a/src/color/setting.js +++ b/src/color/setting.js @@ -359,7 +359,7 @@ p5.prototype.colorMode = function(mode, max1, max2, max3, maxA) { * and all named color strings are supported. In this case, an alpha number * value as a second argument is not supported, the RGBA form should be used. * - * A p5 Color object can also be provided to set the fill color. + * A p5.Color object can also be provided to set the fill color. * * @method fill * @param {Number} v1 red or hue value relative to @@ -594,7 +594,7 @@ p5.prototype.noStroke = function() { * number value as a second argument is not supported, the RGBA form should be * used. * - * A p5 Color object can also be provided to set the stroke color. + * A p5.Color object can also be provided to set the stroke color. * * @method stroke * @param {Number} v1 red or hue value relative to diff --git a/src/core/constants.js b/src/core/constants.js index a872802c78..49d4f48342 100644 --- a/src/core/constants.js +++ b/src/core/constants.js @@ -154,8 +154,8 @@ export const TAU = _PI * 2; */ export const TWO_PI = _PI * 2; /** - * Constant to be used with angleMode() function, to set the mode which - * p5.js interprets and calculates angles (either DEGREES or RADIANS). + * Constant to be used with the angleMode() function, to set the mode in + * which p5.js interprets and calculates angles (either DEGREES or RADIANS). * @property {String} DEGREES * @final * @@ -168,8 +168,8 @@ export const TWO_PI = _PI * 2; */ export const DEGREES = 'degrees'; /** - * Constant to be used with angleMode() function, to set the mode which - * p5.js interprets and calculates angles (either RADIANS or DEGREES). + * Constant to be used with the angleMode() function, to set the mode + * in which p5.js interprets and calculates angles (either RADIANS or DEGREES). * @property {String} RADIANS * @final * diff --git a/src/core/environment.js b/src/core/environment.js index 0268fa24f3..98c9140dde 100644 --- a/src/core/environment.js +++ b/src/core/environment.js @@ -53,7 +53,7 @@ p5.prototype.print = function(...args) { * The system variable frameCount contains the * number of frames that have been displayed since the program started. Inside * setup() the value is 0, after the first iteration - * of draw it is 1, etc. + * of draw() it is 1, etc. * * @property {Integer} frameCount * @readOnly @@ -241,7 +241,7 @@ p5.prototype.cursor = function(type, x, y) { * return a value. This is the same as getFrameRate(). * * Calling frameRate() with arguments that are not - * of the type numbers or are non positive also returns current framerate. + * of the type Number or are non-positive also returns current framerate. * * @method frameRate * @param {Number} fps number of frames to be displayed every second @@ -262,7 +262,7 @@ p5.prototype.cursor = function(type, x, y) { * * function draw() { * background(200); - * rectX = rectX += 1; // Move Rectangle + * rectX += 1; // Move Rectangle * * if (rectX >= width) { // If you go off screen. diff --git a/src/core/friendly_errors/sketch_reader.js b/src/core/friendly_errors/sketch_reader.js index 009a728d7c..edace305fc 100644 --- a/src/core/friendly_errors/sketch_reader.js +++ b/src/core/friendly_errors/sketch_reader.js @@ -235,8 +235,8 @@ if (typeof IS_MINIFIED !== 'undefined') { //create a new string which don't have multiline comments while (start !== -1 && end !== -1) { if (start === 0) { - code = code.substr(end + 2); - } else code = code.substr(0, start) + code.substr(end + 2); + code = code.slice(end + 2); + } else code = code.slice(0, start) + code.slice(end + 2); start = code.indexOf('/*'); end = code.indexOf('*/'); diff --git a/src/core/friendly_errors/validate_params.js b/src/core/friendly_errors/validate_params.js index 18e4a348f8..9e153fb47a 100644 --- a/src/core/friendly_errors/validate_params.js +++ b/src/core/friendly_errors/validate_params.js @@ -204,8 +204,8 @@ if (typeof IS_MINIFIED !== 'undefined') { // look for the docs in the `data.json` datastructure const ichDot = func.lastIndexOf('.'); - const funcName = func.substr(ichDot + 1); - const funcClass = func.substr(0, ichDot) || 'p5'; + const funcName = func.slice(ichDot + 1); + const funcClass = func.slice(0, ichDot !== -1 ? ichDot : 0) || 'p5'; const classitems = arrDoc; let queryResult = classitems[funcClass][funcName]; @@ -247,10 +247,10 @@ if (typeof IS_MINIFIED !== 'undefined') { // split this parameter's types format.types = format.type.split('|').map(function ct(type) { // array - if (type.substr(type.length - 2, 2) === '[]') { + if (type.slice(-2) === '[]') { return { name: type, - array: ct(type.substr(0, type.length - 2)) + array: ct(type.slice(0, -2)) }; } @@ -298,7 +298,7 @@ if (typeof IS_MINIFIED !== 'undefined') { } // function - if (lowerType.substr(0, 'function'.length) === 'function') { + if (lowerType.slice(0, 'function'.length) === 'function') { lowerType = 'function'; } // builtin diff --git a/src/core/main.js b/src/core/main.js index 739566bd8f..ef9fed4e4c 100644 --- a/src/core/main.js +++ b/src/core/main.js @@ -696,7 +696,7 @@ p5.instance = null; * * Note that this will disable the parts of the FES that cause performance * slowdown (like argument checking). Friendly errors that have no performance - * cost (like giving an descriptive error if a file load fails, or warning you + * cost (like giving a descriptive error if a file load fails, or warning you * if you try to override p5.js functions in the global space), * will remain in place. * diff --git a/src/core/p5.Element.js b/src/core/p5.Element.js index 92432e1a39..f01ee58b8b 100644 --- a/src/core/p5.Element.js +++ b/src/core/p5.Element.js @@ -9,8 +9,8 @@ import p5 from './main'; /** * Base class for all elements added to a sketch, including canvas, * graphics buffers, and other HTML elements. It is not called directly, but p5.Element - * objects are created by calling createCanvas, createGraphics, - * createDiv, createImg, createInput, etc. + * objects are created by calling createCanvas(), createGraphics(), + * createDiv(), createImg(), createInput(), etc. * * @class p5.Element * @constructor @@ -48,7 +48,7 @@ p5.Element = function(elt, pInst) { * * Attaches the element to the parent specified. A way of setting * the container for the element. Accepts either a string ID, DOM - * node, or p5.Element. If no arguments given, parent node is returned. + * node, or p5.Element. If no arguments are given, parent node is returned. * For more ways to position the canvas, see the * * positioning the canvas wiki page. @@ -116,7 +116,7 @@ p5.Element.prototype.parent = function(p) { * Sets the ID of the element. If no ID argument is passed in, it instead * returns the current ID of the element. * Note that only one element can have a particular id in a page. - * The .class() function can be used + * The class() method can be used * to identify multiple elements with the same class name. * * @method id @@ -187,10 +187,10 @@ p5.Element.prototype.class = function(c) { }; /** - * The .mousePressed() function is called + * The mousePressed() method is called * once after every time a mouse button is pressed over the element. Some mobile * browsers may also trigger this event on a touch screen, if the user performs - * a quick tap. This can be used to attach element specific event listeners. + * a quick tap. This can be used to attach element-specific event listeners. * * @method mousePressed * @param {Function|Boolean} fxn function to be fired when mouse is @@ -236,7 +236,7 @@ p5.Element.prototype.mousePressed = function(fxn) { this._pInst._setProperty('mouseIsPressed', true); this._pInst._setMouseButton(event); // Pass along the return-value of the callback: - return fxn.call(this); + return fxn.call(this, event); }; // Pass along the event-prepended form of the callback. p5.Element._adjustListener('mousedown', eventPrependedFxn, this); @@ -244,9 +244,9 @@ p5.Element.prototype.mousePressed = function(fxn) { }; /** - * The .doubleClicked() function is called once after every time a + * The doubleClicked() method is called once after every time a * mouse button is pressed twice over the element. This can be used to - * attach element and action specific event listeners. + * attach element and action-specific event listeners. * * @method doubleClicked * @param {Function|Boolean} fxn function to be fired when mouse is @@ -290,18 +290,18 @@ p5.Element.prototype.doubleClicked = function(fxn) { }; /** - * The mouseWheel() function is called + * The mouseWheel() method is called * once after every time a mouse wheel is scrolled over the element. This can - * be used to attach element specific event listeners. + * be used to attach element-specific event listeners. * - * The function accepts a callback function as argument which will be executed + * The method accepts a callback function as argument which will be executed * when the `wheel` event is triggered on the element, the callback function is * passed one argument `event`. The `event.deltaY` property returns negative * values if the mouse wheel is rotated up or away from the user and positive * in the other direction. The `event.deltaX` does the same as `event.deltaY` * except it reads the horizontal wheel scroll of the mouse wheel. * - * On OS X with "natural" scrolling enabled, the `event.deltaY` values are + * On macOS with "natural" scrolling enabled, the `event.deltaY` values are * reversed. * * @method mouseWheel @@ -352,10 +352,10 @@ p5.Element.prototype.mouseWheel = function(fxn) { }; /** - * The mouseReleased() function is + * The mouseReleased() method is * called once after every time a mouse button is released over the element. * Some mobile browsers may also trigger this event on a touch screen, if the - * user performs a quick tap. This can be used to attach element specific event listeners. + * user performs a quick tap. This can be used to attach element-specific event listeners. * * @method mouseReleased * @param {Function|Boolean} fxn function to be fired when mouse is @@ -401,10 +401,10 @@ p5.Element.prototype.mouseReleased = function(fxn) { }; /** - * The .mouseClicked() function is + * The mouseClicked() method is * called once after a mouse button is pressed and released over the element. * Some mobile browsers may also trigger this event on a touch screen, if the - * user performs a quick tap.This can be used to attach element specific event listeners. + * user performs a quick tap. This can be used to attach element-specific event listeners. * * @method mouseClicked * @param {Function|Boolean} fxn function to be fired when mouse is @@ -452,9 +452,9 @@ p5.Element.prototype.mouseClicked = function(fxn) { }; /** - * The .mouseMoved() function is called once every time a + * The mouseMoved() method is called once every time a * mouse moves over the element. This can be used to attach an - * element specific event listener. + * element-specific event listener. * * @method mouseMoved * @param {Function|Boolean} fxn function to be fired when a mouse moves @@ -508,9 +508,9 @@ p5.Element.prototype.mouseMoved = function(fxn) { }; /** - * The .mouseOver() function is called once after every time a + * The mouseOver() method is called once after every time a * mouse moves onto the element. This can be used to attach an - * element specific event listener. + * element-specific event listener. * * @method mouseOver * @param {Function|Boolean} fxn function to be fired when a mouse moves @@ -549,9 +549,9 @@ p5.Element.prototype.mouseOver = function(fxn) { }; /** - * The .mouseOut() function is called once after every time a + * The mouseOut() method is called once after every time a * mouse moves off the element. This can be used to attach an - * element specific event listener. + * element-specific event listener. * * @method mouseOut * @param {Function|Boolean} fxn function to be fired when a mouse @@ -590,8 +590,8 @@ p5.Element.prototype.mouseOut = function(fxn) { }; /** - * The .touchStarted() function is called once after every time a touch is - * registered. This can be used to attach element specific event listeners. + * The touchStarted() method is called once after every time a touch is + * registered. This can be used to attach element-specific event listeners. * * @method touchStarted * @param {Function|Boolean} fxn function to be fired when a touch @@ -637,8 +637,8 @@ p5.Element.prototype.touchStarted = function(fxn) { }; /** - * The .touchMoved() function is called once after every time a touch move is - * registered. This can be used to attach element specific event listeners. + * The touchMoved() method is called once after every time a touch move is + * registered. This can be used to attach element-specific event listeners. * * @method touchMoved * @param {Function|Boolean} fxn function to be fired when a touch moves over @@ -676,8 +676,8 @@ p5.Element.prototype.touchMoved = function(fxn) { }; /** - * The .touchEnded() function is called once after every time a touch is - * registered. This can be used to attach element specific event listeners. + * The touchEnded() method is called once after every time a touch is + * registered. This can be used to attach element-specific event listeners. * * @method touchEnded * @param {Function|Boolean} fxn function to be fired when a touch ends @@ -723,9 +723,9 @@ p5.Element.prototype.touchEnded = function(fxn) { }; /** - * The .dragOver() function is called once after every time a + * The dragOver() method is called once after every time a * file is dragged over the element. This can be used to attach an - * element specific event listener. + * element-specific event listener. * * @method dragOver * @param {Function|Boolean} fxn function to be fired when a file is @@ -761,9 +761,9 @@ p5.Element.prototype.dragOver = function(fxn) { }; /** - * The .dragLeave() function is called once after every time a + * The dragLeave() method is called once after every time a * dragged file leaves the element area. This can be used to attach an - * element specific event listener. + * element-specific event listener. * * @method dragLeave * @param {Function|Boolean} fxn function to be fired when a file is diff --git a/src/core/p5.Renderer2D.js b/src/core/p5.Renderer2D.js index 345e7d9cbe..e9a45fc5c0 100644 --- a/src/core/p5.Renderer2D.js +++ b/src/core/p5.Renderer2D.js @@ -47,7 +47,14 @@ p5.Renderer2D.prototype.background = function(...args) { this.resetMatrix(); if (args[0] instanceof p5.Image) { - this._pInst.image(args[0], 0, 0, this.width, this.height); + if (args[1] >= 0) { + // set transparency of background + const img = args[0]; + this.drawingContext.globalAlpha = args[1] / 255; + this._pInst.image(img, 0, 0, this.width, this.height); + } else { + this._pInst.image(args[0], 0, 0, this.width, this.height); + } } else { const curFill = this._getFill(); // create background rect diff --git a/src/core/rendering.js b/src/core/rendering.js index 771b55d5d1..c2526ad726 100644 --- a/src/core/rendering.js +++ b/src/core/rendering.js @@ -13,11 +13,11 @@ let defaultId = 'defaultCanvas0'; // this gets set again in createCanvas const defaultClass = 'p5Canvas'; /** - * Creates a canvas element in the document, and sets the dimensions of it - * in pixels. This method should be called only once at the start of setup. + * Creates a canvas element in the document and sets its dimensions + * in pixels. This method should be called only once at the start of setup(). * Calling createCanvas more than once in a * sketch will result in very unpredictable behavior. If you want more than - * one drawing canvas you could use createGraphics + * one drawing canvas you could use createGraphics() * (hidden by default but it can be shown). * * Important note: in 2D mode (i.e. when `p5.Renderer` is not set) the origin (0,0) @@ -37,7 +37,7 @@ const defaultClass = 'p5Canvas'; * @param {Number} w width of the canvas * @param {Number} h height of the canvas * @param {Constant} [renderer] either P2D or WEBGL - * @return {p5.Renderer} + * @return {p5.Renderer} pointer to p5.Renderer holding canvas * @example *
* diff --git a/src/core/shape/2d_primitives.js b/src/core/shape/2d_primitives.js index bc78959192..7484433b16 100644 --- a/src/core/shape/2d_primitives.js +++ b/src/core/shape/2d_primitives.js @@ -243,8 +243,8 @@ p5.prototype.arc = function(x, y, w, h, start, stop, mode, detail) { * with the ellipseMode() function. * * @method ellipse - * @param {Number} x x-coordinate of the center of ellipse. - * @param {Number} y y-coordinate of the center of ellipse. + * @param {Number} x x-coordinate of the center of the ellipse. + * @param {Number} y y-coordinate of the center of the ellipse. * @param {Number} w width of the ellipse. * @param {Number} [h] height of the ellipse. * @chainable @@ -264,7 +264,7 @@ p5.prototype.arc = function(x, y, w, h, start, stop, mode, detail) { * @param {Number} y * @param {Number} w * @param {Number} h - * @param {Integer} [detail] optional parameter for WebGL mode only. This is to + * @param {Integer} [detail] optional parameter for WEBGL mode only. This is to * specify the number of vertices that makes up the * perimeter of the ellipse. Default value is 25. Won't * draw a stroke for a detail of more than 50. @@ -277,15 +277,16 @@ p5.prototype.ellipse = function(x, y, w, h, detailX) { /** * Draws a circle to the screen. A circle is a simple closed shape. It is the set * of all points in a plane that are at a given distance from a given point, - * the centre. This function is a special case of the ellipse() function, where - * the width and height of the ellipse are the same. Height and width of the - * ellipse correspond to the diameter of the circle. By default, the first two - * parameters set the location of the centre of the circle, the third sets the - * diameter of the circle. + * the center. This function is a special case of the + * ellipse() function, where the width and height + * of the ellipse are the same. Height and width of the ellipse correspond to + * the diameter of the circle. By default, the first two parameters set the + * location of the center of the circle, the third sets the diameter of the + * circle. * * @method circle - * @param {Number} x x-coordinate of the centre of the circle. - * @param {Number} y y-coordinate of the centre of the circle. + * @param {Number} x x-coordinate of the center of the circle. + * @param {Number} y y-coordinate of the center of the circle. * @param {Number} d diameter of the circle. * @chainable * @example @@ -481,7 +482,7 @@ p5.prototype.point = function(...args) { }; /** - * Draws a quad on the canvas. A quad is a quadrilateral, a four sided polygon. It is + * Draws a quad on the canvas. A quad is a quadrilateral, a four-sided polygon. It is * similar to a rectangle, but the angles between its edges are not * constrained to ninety degrees. The first pair of parameters (x1,y1) * sets the first vertex and the subsequent pairs should proceed @@ -557,7 +558,7 @@ p5.prototype.quad = function(...args) { * Draws a rectangle on the canvas. A rectangle is a four-sided closed shape with * every angle at ninety degrees. By default, the first two parameters set * the location of the upper-left corner, the third sets the width, and the - * fourth sets the height. The way these parameters are interpreted, may be + * fourth sets the height. The way these parameters are interpreted may be * changed with the rectMode() function. * * The fifth, sixth, seventh and eighth parameters, if specified, diff --git a/src/core/shape/attributes.js b/src/core/shape/attributes.js index e65352d500..84d6158bd3 100644 --- a/src/core/shape/attributes.js +++ b/src/core/shape/attributes.js @@ -103,11 +103,12 @@ p5.prototype.ellipseMode = function(m) { * 2 pixelated 36×36 white ellipses to left & right of center, black background */ p5.prototype.noSmooth = function() { - this.setAttributes('antialias', false); if (!this._renderer.isP3D) { if ('imageSmoothingEnabled' in this.drawingContext) { this.drawingContext.imageSmoothingEnabled = false; } + } else { + this.setAttributes('antialias', false); } return this; }; @@ -123,7 +124,7 @@ p5.prototype.noSmooth = function() { * rectMode(CORNERS) interprets the first two parameters as the location of * one of the corners, and the third and fourth parameters as the location of * the diagonally opposite corner. Note, the rectangle is drawn between the - * coordinates, so it is not neccesary that the first corner be the upper left + * coordinates, so it is not necessary that the first corner be the upper left * corner. * * rectMode(CENTER) interprets the first two parameters as the shape's center diff --git a/src/core/shape/curves.js b/src/core/shape/curves.js index 73c0ff4ee3..4be0237f1a 100644 --- a/src/core/shape/curves.js +++ b/src/core/shape/curves.js @@ -454,7 +454,7 @@ p5.prototype.curveTightness = function(t) { * @param {Number} c coordinate of second point * @param {Number} d coordinate of second control point * @param {Number} t value between 0 and 1 - * @return {Number} bezier value at position t + * @return {Number} Curve value at position t * @example *
* diff --git a/src/core/shape/vertex.js b/src/core/shape/vertex.js index 775889f3dc..b6abe9aec6 100644 --- a/src/core/shape/vertex.js +++ b/src/core/shape/vertex.js @@ -89,12 +89,12 @@ p5.prototype.beginContour = function() { * Draw a series of connected triangles in strip fashion * * QUADS - * Draw a series of separate quad + * Draw a series of separate quads * * QUAD_STRIP * Draw quad strip using adjacent edges to form the next quad * - * TESS (WebGl only) + * TESS (WEBGL only) * Handle irregular polygon for filling curve by explicit tessellation * * After calling the beginShape() function, a series of vertex() commands must follow. To stop @@ -582,9 +582,9 @@ p5.prototype.endContour = function() { /** * The endShape() function is the companion to beginShape() and may only be - * called after beginShape(). When endShape() is called, all of image data - * defined since the previous call to beginShape() is written into the image - * buffer. The constant CLOSE as the value for the MODE parameter to close + * called after beginShape(). When endShape() is called, all of the image + * data defined since the previous call to beginShape() is written into the image + * buffer. The constant CLOSE as the value for the `mode` parameter to close * the shape (to connect the beginning and the end). * * @method endShape @@ -781,7 +781,7 @@ p5.prototype.endShape = function(mode) { *
* * @alt - * backwards s-shaped black line with the same s-shaped line in postive z-axis. + * backwards s-shaped black line with the same s-shaped line in positive z-axis. */ p5.prototype.quadraticVertex = function(...args) { p5._validateParameters('quadraticVertex', args); @@ -958,7 +958,7 @@ p5.prototype.quadraticVertex = function(...args) { * @method vertex * @param {Number} x * @param {Number} y - * @param {Number} z z-coordinate of the vertex. + * @param {Number} [z] z-coordinate of the vertex. * Defaults to 0 if not specified. * @chainable */ @@ -967,8 +967,8 @@ p5.prototype.quadraticVertex = function(...args) { * @param {Number} x * @param {Number} y * @param {Number} [z] - * @param {Number} u the vertex's texture u-coordinate - * @param {Number} v the vertex's texture v-coordinate + * @param {Number} [u] the vertex's texture u-coordinate + * @param {Number} [v] the vertex's texture v-coordinate * @chainable */ p5.prototype.vertex = function(x, y, moveTo, u, v) { diff --git a/src/core/structure.js b/src/core/structure.js index b01dc9e94e..85f66004dc 100644 --- a/src/core/structure.js +++ b/src/core/structure.js @@ -28,7 +28,7 @@ import p5 from './main'; * has been specified. Otherwise, the sketch would enter an odd state until * loop() was called. * - * Use isLooping() to check current state of loop(). + * Use isLooping() to check the current state of loop(). * * @method noLoop * @example @@ -88,7 +88,7 @@ p5.prototype.noLoop = function() { * * Avoid calling loop() from inside setup(). * - * Use isLooping() to check current state of loop(). + * Use isLooping() to check the current state of loop(). * * @method loop * @example @@ -138,6 +138,7 @@ p5.prototype.loop = function() { * isLooping() returns the current state for use within custom event handlers. * * @method isLooping + * @returns {boolean} * @example *
* diff --git a/src/core/transform.js b/src/core/transform.js index 1fe637e5d9..f77523ab64 100644 --- a/src/core/transform.js +++ b/src/core/transform.js @@ -24,13 +24,41 @@ import p5 from './main'; * > The transformation matrix used when applyMatrix is called * + * The transformation matrix used when applyMatrix is called with 4x4 matrix + * + * @method applyMatrix + * @param {Array} arr an array of numbers - should be 6 or 16 length (2*3 or 4*4 matrix values) + * @chainable + */ +/** * @method applyMatrix - * @param {Number|Array} a numbers which define the 2×3 matrix to be multiplied, or an array of numbers - * @param {Number} b numbers which define the 2×3 matrix to be multiplied - * @param {Number} c numbers which define the 2×3 matrix to be multiplied - * @param {Number} d numbers which define the 2×3 matrix to be multiplied - * @param {Number} e numbers which define the 2×3 matrix to be multiplied - * @param {Number} f numbers which define the 2×3 matrix to be multiplied + * @param {Number} a numbers which define the 2×3 or 4x4 matrix to be multiplied + * @param {Number} b numbers which define the 2×3 or 4x4 matrix to be multiplied + * @param {Number} c numbers which define the 2×3 or 4x4 matrix to be multiplied + * @param {Number} d numbers which define the 2×3 or 4x4 matrix to be multiplied + * @param {Number} e numbers which define the 2×3 or 4x4 matrix to be multiplied + * @param {Number} f numbers which define the 2×3 or 4x4 matrix to be multiplied + * @chainable + */ +/** + * @method applyMatrix + * @param {Number} a + * @param {Number} b + * @param {Number} c + * @param {Number} d + * @param {Number} e + * @param {Number} f + * @param {Number} g numbers which define the 4x4 matrix to be multiplied + * @param {Number} h numbers which define the 4x4 matrix to be multiplied + * @param {Number} i numbers which define the 4x4 matrix to be multiplied + * @param {Number} j numbers which define the 4x4 matrix to be multiplied + * @param {Number} k numbers which define the 4x4 matrix to be multiplied + * @param {Number} l numbers which define the 4x4 matrix to be multiplied + * @param {Number} m numbers which define the 4x4 matrix to be multiplied + * @param {Number} n numbers which define the 4x4 matrix to be multiplied + * @param {Number} o numbers which define the 4x4 matrix to be multiplied + * @param {Number} p numbers which define the 4x4 matrix to be multiplied * @chainable * @example *
@@ -198,13 +226,13 @@ p5.prototype.resetMatrix = function() { * Objects are always rotated around their relative position to the * origin and positive numbers rotate objects in a clockwise direction. * Transformations apply to everything that happens after and subsequent - * calls to the function accumulates the effect. For example, calling + * calls to the function accumulate the effect. For example, calling * rotate(HALF_PI) and then rotate(HALF_PI) is the same as rotate(PI). * All transformations are reset when draw() begins again. * * Technically, rotate() multiplies the current transformation matrix * by a rotation matrix. This function can be further controlled by - * the push() and pop(). + * push() and pop(). * * @method rotate * @param {Number} angle the angle of rotation, specified in radians @@ -506,7 +534,7 @@ p5.prototype.shearY = function(angle) { * @method translate * @param {Number} x left/right translation * @param {Number} y up/down translation - * @param {Number} [z] forward/backward translation (webgl only) + * @param {Number} [z] forward/backward translation (WEBGL only) * @chainable * @example *
diff --git a/src/data/local_storage.js b/src/data/local_storage.js index cd19af5597..c316da5ad2 100644 --- a/src/data/local_storage.js +++ b/src/data/local_storage.js @@ -39,6 +39,8 @@ import p5 from '../core/main'; * if (myText === null) { * myText = ''; * } + * describe(`When you type the key name is displayed as black text on white background. + * If you reload the page, the last letter typed is still displaying.`); * } * * function draw() { @@ -52,10 +54,6 @@ import p5 from '../core/main'; * storeItem('myText', myText); * } *
- * - * @alt - * When you type the key name is displayed as black text on white background. - * If you reload the page, the last letter typed is still displaying. */ p5.prototype.storeItem = function(key, value) { if (typeof key !== 'string') { @@ -127,6 +125,9 @@ p5.prototype.storeItem = function(key, value) { * if (myColor !== null) { * background(myColor); * } + * describe(`If you click, the canvas changes to a random color.· + * If you reload the page, the canvas is still the color it was when the + * page was previously loaded.`); * } * * function mousePressed() { @@ -134,11 +135,6 @@ p5.prototype.storeItem = function(key, value) { * storeItem('myColor', myColor); * } *
- * - * @alt - * If you click, the canvas changes to a random color. - * If you reload the page, the canvas is still the color it - * was when the page was previously loaded. */ p5.prototype.getItem = function(key) { let value = localStorage.getItem(key); diff --git a/src/dom/dom.js b/src/dom/dom.js index c66d67a53d..a07e277370 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -458,7 +458,7 @@ p5.prototype.createA = function(href, html, target) { * @param {Number} max maximum value of the slider * @param {Number} [value] default value of the slider * @param {Number} [step] step size for each tick of the slider (if step is set to 0, the slider will move continuously from the minimum to the maximum value) - * @return {p5.Element} pointer to p5.Element holding created node + * @return {p5.Element} pointer to p5.Element holding the created node * @example *
* let slider; @@ -540,7 +540,8 @@ p5.prototype.createButton = function(label, value) { /** * Creates a checkbox `<input></input>` element in the DOM. - * Calling .checked() on a checkbox returns if it is checked or not + * Calling .checked() on a checkbox returns a boolean indicating whether + * it is checked or not. * * @method createCheckbox * @param {String} [label] label displayed after checkbox @@ -624,14 +625,14 @@ p5.prototype.createCheckbox = function() { * It also helps to assign select-box methods to p5.Element when selecting existing select box. * - `.option(name, [value])` can be used to set options for the select after it is created. * - `.value()` will return the currently selected option. - * - `.selected()` will return current dropdown element which is an instance of p5.Element + * - `.selected()` will return the current dropdown element which is an instance of p5.Element. * - `.selected(value)` can be used to make given option selected by default when the page first loads. - * - `.disable()` marks whole of dropdown element as disabled. - * - `.disable(value)` marks given option as disabled + * - `.disable()` marks the whole dropdown element as disabled. + * - `.disable(value)` marks a given option as disabled. * * @method createSelect * @param {boolean} [multiple] true if dropdown should support multiple selections - * @return {p5.Element} + * @return {p5.Element} pointer to p5.Element holding created node * @example *
* let sel; @@ -768,7 +769,7 @@ p5.prototype.createSelect = function() { }; /** - * Creates a radio button element in the DOM.It also helps existing radio buttons + * Creates a radio button element in the DOM. It also helps existing radio buttons * assign methods of p5.Element. * - `.option(value, [label])` can be used to create a new option for the * element. If an option with a value already exists, it will be returned. @@ -783,8 +784,8 @@ p5.prototype.createSelect = function() { * - `.disable(Boolean)` method will enable/disable the whole radio button element. * * @method createRadio - * @param {Object} containerElement An container HTML Element either a div - * or span inside which all existing radio inputs will be considered as options. + * @param {Object} containerElement A container HTML Element, either a div + * or span, inside which all existing radio inputs will be considered as options. * @param {string} [name] A name parameter for each Input Element. * @return {p5.Element} pointer to p5.Element holding created node * @example @@ -956,9 +957,17 @@ p5.prototype.createRadio = function() { } } } else { + // forEach loop to uncheck all radio buttons before + // setting any one as checked. + self._getOptionsArray().forEach(option => { + option.checked = false; + option.removeAttribute('checked'); + }); + for (const option of self._getOptionsArray()) { if (option.value === value) { option.setAttribute('checked', true); + option.checked = true; result = option; } } @@ -978,7 +987,8 @@ p5.prototype.createRadio = function() { /** * Creates a colorPicker element in the DOM for color input. * The .value() method will return a hex string (#rrggbb) of the color. - * The .color() method will return a p5.Color object with the current chosen color. + * The .color() method will return a p5.Color + * object with the current chosen color. * * @method createColorPicker * @param {String|p5.Color} [value] default color of element @@ -1559,7 +1569,7 @@ p5.Element.prototype.removeClass = function(c) { /** * - * Checks if specified class already set to element + * Checks if specified class is already applied to element. * * @method hasClass * @returns {boolean} a boolean value if element has specified class @@ -1588,7 +1598,7 @@ p5.Element.prototype.hasClass = function(c) { /** * - * Toggles element class + * Toggles element class. * * @method toggleClass * @param c {String} class name to toggle @@ -1673,10 +1683,10 @@ p5.Element.prototype.child = function(childNode) { }; /** - * Centers a p5 Element either vertically, horizontally, + * Centers a p5.Element either vertically, horizontally, * or both, relative to its parent or according to - * the body if the Element has no parent. If no argument is passed - * the Element is aligned both vertically and horizontally. + * the body if the p5.Element has no parent. If no argument is passed + * the p5.Element is aligned both vertically and horizontally. * * @method center * @param {String} [align] passing 'vertical', 'horizontal' aligns element accordingly @@ -1726,8 +1736,8 @@ p5.Element.prototype.center = function(align) { /** * * If an argument is given, sets the inner HTML of the element, - * replacing any existing html. If true is included as a second - * argument, html is appended instead of replacing existing html. + * replacing any existing HTML. If true is included as a second + * argument, HTML is appended instead of replacing existing HTML. * If no arguments are given, returns * the inner HTML of the element. * @@ -1768,7 +1778,7 @@ p5.Element.prototype.html = function() { * position will be relative to (0, 0) of the window. * Essentially, this sets position:absolute and left and top * properties of style. If an optional third argument specifying position type is given, - * the x and y coordinates will be interpreted based on the positioning scheme. * If no arguments given, the function returns the x and y position of the element. * @@ -1883,10 +1893,10 @@ p5.Element.prototype._rotate = function() { }; /** - * Sets the given style (css) property (1st arg) of the element with the + * Sets the given style (CSS) property (1st arg) of the element with the * given value (2nd arg). If a single argument is given, .style() - * returns the value of the given property; however, if the single argument - * is given in css syntax ('text-align:center'), .style() sets the css + * returns the value of the given property; however, if a single argument + * is given in CSS syntax ('text-align:center'), .style() sets the CSS * appropriately. * * @method style @@ -1981,7 +1991,7 @@ p5.Element.prototype.style = function(prop, val) { * * Adds a new attribute or changes the value of an existing attribute * on the specified element. If no value is specified, returns the - * value of the given attribute, or null if attribute is not set. + * value of the given attribute, or null if the attribute is not set. * * @method attribute * @return {String} value of attribute @@ -2150,8 +2160,8 @@ p5.Element.prototype.hide = function() { * * Sets the width and height of the element. AUTO can be used to * only adjust one dimension at a time. If no arguments are given, it - * returns the width and height of the element in an object. In case of - * elements which need to be loaded, such as images, it is recommended + * returns the width and height of the element in an Object. In the case of + * elements that need to be loaded, such as images, it is recommended * to call the function after the element has finished loading. * * @method size diff --git a/src/events/acceleration.js b/src/events/acceleration.js index 0021609549..ecc7e6463d 100644 --- a/src/events/acceleration.js +++ b/src/events/acceleration.js @@ -35,11 +35,10 @@ p5.prototype.deviceOrientation = * background(220, 50); * fill('magenta'); * ellipse(width / 2, height / 2, accelerationX); + * describe('Magnitude of device acceleration is displayed as ellipse size.'); * } * *
- * @alt - * Magnitude of device acceleration is displayed as ellipse size */ p5.prototype.accelerationX = 0; @@ -58,11 +57,10 @@ p5.prototype.accelerationX = 0; * background(220, 50); * fill('magenta'); * ellipse(width / 2, height / 2, accelerationY); + * describe('Magnitude of device acceleration is displayed as ellipse size'); * } *
*
- * @alt - * Magnitude of device acceleration is displayed as ellipse size */ p5.prototype.accelerationY = 0; @@ -82,12 +80,10 @@ p5.prototype.accelerationY = 0; * background(220, 50); * fill('magenta'); * ellipse(width / 2, height / 2, accelerationZ); + * describe('Magnitude of device acceleration is displayed as ellipse size'); * } *
*
- * - * @alt - * Magnitude of device acceleration is displayed as ellipse size */ p5.prototype.accelerationZ = 0; @@ -157,11 +153,11 @@ p5.prototype._updatePAccelerations = function() { * rotateX(radians(rotationX)); * //rotateY(radians(rotationY)); * box(200, 200, 200); + * describe(`red horizontal line right, green vertical line bottom. + * black background.`); * } * *
- * @alt - * red horizontal line right, green vertical line bottom. black background. */ p5.prototype.rotationX = 0; @@ -190,11 +186,11 @@ p5.prototype.rotationX = 0; * //rotateX(radians(rotationX)); * rotateY(radians(rotationY)); * box(200, 200, 200); + * describe(`red horizontal line right, green vertical line bottom. + * black background.`); * } * * - * @alt - * red horizontal line right, green vertical line bottom. black background. */ p5.prototype.rotationY = 0; @@ -224,15 +220,14 @@ p5.prototype.rotationY = 0; * //rotateX(radians(rotationX)); * //rotateY(radians(rotationY)); * box(200, 200, 200); + * describe(`red horizontal line right, green vertical line bottom. + * black background.`); * } * * * * @property {Number} rotationZ * @readOnly - * - * @alt - * red horizontal line right, green vertical line bottom. black background. */ p5.prototype.rotationZ = 0; @@ -271,12 +266,10 @@ p5.prototype.rotationZ = 0; * } * * print(rotateDirection); + * describe('no image to display.'); * * * - * @alt - * no image to display. - * * @property {Number} pRotationX * @readOnly */ @@ -316,12 +309,10 @@ p5.prototype.pRotationX = 0; * rotateDirection = 'counter-clockwise'; * } * print(rotateDirection); + * describe('no image to display.'); * * * - * @alt - * no image to display. - * * @property {Number} pRotationY * @readOnly */ @@ -357,12 +348,10 @@ p5.prototype.pRotationY = 0; * rotateDirection = 'counter-clockwise'; * } * print(rotateDirection); + * describe('no image to display.'); * * * - * @alt - * no image to display. - * * @property {Number} pRotationZ * @readOnly */ @@ -403,6 +392,10 @@ p5.prototype._updatePRotations = function() { * function draw() { * fill(value); * rect(25, 25, 50, 50); + * describe(`50-by-50 black rect in center of canvas. + * turns white on mobile when device turns`); + * describe(`50-by-50 black rect in center of canvas. + * turns white on mobile when x-axis turns`); * } * function deviceTurned() { * if (turnAxis === 'X') { @@ -415,10 +408,6 @@ p5.prototype._updatePRotations = function() { * } * * - * - * @alt - * 50×50 black rect in center of canvas. turns white on mobile when device turns - * 50×50 black rect in center of canvas. turns white on mobile when x-axis turns */ p5.prototype.turnAxis = undefined; @@ -446,6 +435,8 @@ let shake_threshold = 30; * function draw() { * fill(value); * rect(25, 25, 50, 50); + * describe(`50-by-50 black rect in center of canvas. + * turns white on mobile when device moves`); * } * function deviceMoved() { * value = value + 5; @@ -458,9 +449,6 @@ let shake_threshold = 30; * } * * - * - * @alt - * 50×50 black rect in center of canvas. turns white on mobile when device moves */ p5.prototype.setMoveThreshold = function(val) { @@ -489,6 +477,8 @@ p5.prototype.setMoveThreshold = function(val) { * function draw() { * fill(value); * rect(25, 25, 50, 50); + * describe(`50-by-50 black rect in center of canvas. + * turns white on mobile when device is being shaked`); * } * function deviceMoved() { * value = value + 5; @@ -501,10 +491,6 @@ p5.prototype.setMoveThreshold = function(val) { * } * * - * - * @alt - * 50×50 black rect in center of canvas. turns white on mobile when device - * is being shaked */ p5.prototype.setShakeThreshold = function(val) { @@ -529,6 +515,8 @@ p5.prototype.setShakeThreshold = function(val) { * function draw() { * fill(value); * rect(25, 25, 50, 50); + * describe(`50-by-50 black rect in center of canvas. + * turns white on mobile when device moves`); * } * function deviceMoved() { * value = value + 5; @@ -538,9 +526,6 @@ p5.prototype.setShakeThreshold = function(val) { * } * * - * - * @alt - * 50×50 black rect in center of canvas. turns white on mobile when device moves */ /** @@ -563,6 +548,8 @@ p5.prototype.setShakeThreshold = function(val) { * function draw() { * fill(value); * rect(25, 25, 50, 50); + * describe(`50-by-50 black rect in center of canvas. + * turns white on mobile when device turns`); * } * function deviceTurned() { * if (value === 0) { @@ -583,6 +570,8 @@ p5.prototype.setShakeThreshold = function(val) { * function draw() { * fill(value); * rect(25, 25, 50, 50); + * describe(`50-by-50 black rect in center of canvas. + * turns white on mobile when x-axis turns`); * } * function deviceTurned() { * if (turnAxis === 'X') { @@ -595,10 +584,6 @@ p5.prototype.setShakeThreshold = function(val) { * } * * - * - * @alt - * 50×50 black rect in center of canvas. turns white on mobile when device turns - * 50×50 black rect in center of canvas. turns white on mobile when x-axis turns */ /** @@ -618,6 +603,8 @@ p5.prototype.setShakeThreshold = function(val) { * function draw() { * fill(value); * rect(25, 25, 50, 50); + * describe(`50-by-50 black rect in center of canvas. + * turns white on mobile when device shakes`); * } * function deviceShaken() { * value = value + 5; @@ -627,9 +614,6 @@ p5.prototype.setShakeThreshold = function(val) { * } * * - * - * @alt - * 50×50 black rect in center of canvas. turns white on mobile when device shakes */ p5.prototype._ondeviceorientation = function(e) { diff --git a/src/events/keyboard.js b/src/events/keyboard.js index 4ee87f313f..91911a4da7 100644 --- a/src/events/keyboard.js +++ b/src/events/keyboard.js @@ -23,12 +23,10 @@ import p5 from '../core/main'; * fill(255); * } * rect(25, 25, 50, 50); + * describe('50-by-50 white rect that turns black on keypress.'); * } * * - * - * @alt - * 50×50 white rect that turns black on keypress. */ p5.prototype.isKeyPressed = false; p5.prototype.keyIsPressed = false; // khan @@ -53,11 +51,9 @@ p5.prototype.keyIsPressed = false; // khan * function draw() { * background(200); * text(key, 33, 65); // Display last key pressed. + * describe('canvas displays any key value that is pressed in pink font.'); * } * - * - * @alt - * canvas displays any key value that is pressed in pink font. */ p5.prototype.key = ''; @@ -76,6 +72,8 @@ p5.prototype.key = ''; * function draw() { * fill(fillVal); * rect(25, 25, 50, 50); + * describe(`Grey rect center. turns white when up arrow pressed and black when down. + * Display key pressed and its keyCode in a yellow box.`); * } * * function keyPressed() { @@ -94,9 +92,6 @@ p5.prototype.key = ''; * print(key, ' ', keyCode); * } * - * @alt - * Grey rect center. turns white when up arrow pressed and black when down - * Display key pressed and its keyCode in a yellow box */ p5.prototype.keyCode = 0; @@ -130,6 +125,8 @@ p5.prototype.keyCode = 0; * function draw() { * fill(value); * rect(25, 25, 50, 50); + * describe(`black rect center. turns white when key pressed and black + * when released.`); * } * function keyPressed() { * if (value === 0) { @@ -146,6 +143,8 @@ p5.prototype.keyCode = 0; * function draw() { * fill(value); * rect(25, 25, 50, 50); + * describe(`black rect center. turns white when left arrow pressed and + * black when right.`); * } * function keyPressed() { * if (keyCode === LEFT_ARROW) { @@ -164,10 +163,6 @@ p5.prototype.keyCode = 0; * } * * - * - * @alt - * black rect center. turns white when key pressed and black when released - * black rect center. turns white when left arrow pressed and black when right. */ p5.prototype._onkeydown = function(e) { if (this._downKeys[e.which]) { @@ -192,7 +187,7 @@ p5.prototype._onkeydown = function(e) { * See key and keyCode for more information.

* Browsers may have different default * behaviors attached to various key events. To prevent any default - * behavior for this event, add "return false" to the end of the method. + * behavior for this event, add "return false" to the end of the function. * * @method keyReleased * @param {Object} [event] optional KeyboardEvent callback argument. @@ -203,6 +198,8 @@ p5.prototype._onkeydown = function(e) { * function draw() { * fill(value); * rect(25, 25, 50, 50); + * describe(`black rect center. turns white when key pressed and black + * when pressed again`); * } * function keyReleased() { * if (value === 0) { @@ -214,9 +211,6 @@ p5.prototype._onkeydown = function(e) { * } * * - * - * @alt - * black rect center. turns white when key pressed and black when pressed again */ p5.prototype._onkeyup = function(e) { this._downKeys[e.which] = false; @@ -252,7 +246,7 @@ p5.prototype._onkeyup = function(e) { * configured.

* Browsers may have different default behaviors attached to various key * events. To prevent any default behavior for this event, add "return false" - * to the end of the method. + * to the end of the function. * * @method keyTyped * @param {Object} [event] optional KeyboardEvent callback argument. @@ -263,6 +257,8 @@ p5.prototype._onkeyup = function(e) { * function draw() { * fill(value); * rect(25, 25, 50, 50); + * describe(`black rect center. turns white when 'a' key typed and + * black when 'b' pressed`); * } * function keyTyped() { * if (key === 'a') { @@ -275,9 +271,6 @@ p5.prototype._onkeyup = function(e) { * } * * - * - * @alt - * black rect center. turns white when 'a' key typed and black when 'b' pressed */ p5.prototype._onkeypress = function(e) { if (e.which === this._lastKeyCodeTyped) { @@ -345,6 +338,8 @@ p5.prototype._onblur = function(e) { * * clear(); * ellipse(x, y, 50, 50); + * describe(`50-by-50 red ellipse moves left, right, up, and + * down with arrow presses.`); * } * * @@ -369,12 +364,10 @@ p5.prototype._onblur = function(e) { * clear(); * fill(255, 0, 0); * ellipse(50, 50, diameter, diameter); + * describe(`50-by-50 red ellipse gets bigger or smaller when + * + or - are pressed.`); * } * - * - * @alt - * 50×50 red ellipse moves left, right, up and down with arrow presses. - * 50×50 red ellipse gets bigger or smaller when + or - are pressed. */ p5.prototype.keyIsDown = function(code) { p5._validateParameters('keyIsDown', arguments); diff --git a/src/events/mouse.js b/src/events/mouse.js index ae449c3191..59c20d3734 100644 --- a/src/events/mouse.js +++ b/src/events/mouse.js @@ -32,11 +32,11 @@ import * as constants from '../core/constants'; * background(237, 34, 93); * fill(0); * rect(x, 50, 50, 50); + * describe(`box moves left and right according to mouse movement + * then slowly back towards the center`); * } * * - * @alt - * box moves left and right according to mouse movement then slowly back towards the center */ p5.prototype.movedX = 0; @@ -62,11 +62,11 @@ p5.prototype.movedX = 0; * background(237, 34, 93); * fill(0); * rect(y, 50, 50, 50); + * describe(`box moves up and down according to mouse movement then + * slowly back towards the center`); * } * * - * @alt - * box moves up and down according to mouse movement then slowly back towards the center */ p5.prototype.movedY = 0; /* @@ -94,12 +94,10 @@ p5.prototype._hasMouseInteracted = false; * function draw() { * background(244, 248, 252); * line(mouseX, 0, mouseX, 100); + * describe(`horizontal black line moves left and right with mouse x-position`); * } * * - * - * @alt - * horizontal black line moves left and right with mouse x-position */ p5.prototype.mouseX = 0; @@ -120,12 +118,10 @@ p5.prototype.mouseX = 0; * function draw() { * background(244, 248, 252); * line(0, mouseY, 100, mouseY); + * describe(`vertical black line moves up and down with mouse y-position`); * } * * - * - * @alt - * vertical black line moves up and down with mouse y-position */ p5.prototype.mouseY = 0; @@ -152,12 +148,11 @@ p5.prototype.mouseY = 0; * background(244, 248, 252); * line(mouseX, mouseY, pmouseX, pmouseY); * print(pmouseX + ' -> ' + mouseX); + * describe(`line trail is created from cursor movements. + * faster movement make longer line.`); * } * * - * - * @alt - * line trail is created from cursor movements. faster movement make longer line. */ p5.prototype.pmouseX = 0; @@ -183,12 +178,11 @@ p5.prototype.pmouseX = 0; * } * * print(pmouseY + ' -> ' + mouseY); + * describe(`60-by-60 black rect center, fuchsia background. + * rect flickers on mouse movement`); * } * * - * - * @alt - * 60×60 black rect center, fuchsia background. rect flickers on mouse movement */ p5.prototype.pmouseY = 0; @@ -221,12 +215,11 @@ p5.prototype.pmouseY = 0; * * //the y of the square is relative to the canvas * rect(20, mouseY, 60, 60); + * describe(`60-by-60 black rect y moves with mouse y and fuchsia + * canvas moves with mouse x`); * } * * - * - * @alt - * 60×60 black rect y moves with mouse y and fuchsia canvas moves with mouse x */ p5.prototype.winMouseX = 0; @@ -259,12 +252,11 @@ p5.prototype.winMouseX = 0; * * //the x of the square is relative to the canvas * rect(mouseX, 20, 60, 60); + * describe(`60-by-60 black rect x moves with mouse x and + * fuchsia canvas y moves with mouse y`); * } * * - * - * @alt - * 60×60 black rect x moves with mouse x and fuchsia canvas y moves with mouse y */ p5.prototype.winMouseY = 0; @@ -299,12 +291,11 @@ p5.prototype.winMouseY = 0; * ellipse(50, 50, 10 + speed * 5, 10 + speed * 5); * //move the canvas to the mouse position * myCanvas.position(winMouseX + 1, winMouseY + 1); + * describe(`fuchsia ellipse moves with mouse x and y. + * Grows and shrinks with mouse speed`); * } * * - * - * @alt - * fuchsia ellipse moves with mouse x and y. Grows and shrinks with mouse speed */ p5.prototype.pwinMouseX = 0; @@ -339,12 +330,11 @@ p5.prototype.pwinMouseX = 0; * ellipse(50, 50, 10 + speed * 5, 10 + speed * 5); * //move the canvas to the mouse position * myCanvas.position(winMouseX + 1, winMouseY + 1); + * describe(`fuchsia ellipse moves with mouse x and y. + * Grows and shrinks with mouse speed`); * } * * - * - * @alt - * fuchsia ellipse moves with mouse x and y. Grows and shrinks with mouse speed */ p5.prototype.pwinMouseY = 0; @@ -377,12 +367,11 @@ p5.prototype.pwinMouseY = 0; * } * * print(mouseButton); + * describe(`50-by-50 black ellipse appears on center of fuchsia + * canvas on mouse click/press.`); * } * * - * - * @alt - * 50×50 black ellipse appears on center of fuchsia canvas on mouse click/press. */ p5.prototype.mouseButton = 0; @@ -407,12 +396,11 @@ p5.prototype.mouseButton = 0; * } * * print(mouseIsPressed); + * describe(`black 50-by-50 rect becomes ellipse with mouse click/press. + * fuchsia background.`); * } * * - * - * @alt - * black 50×50 rect becomes ellipse with mouse click/press. fuchsia background. */ p5.prototype.mouseIsPressed = false; @@ -497,6 +485,8 @@ p5.prototype._setMouseButton = function(e) { * function draw() { * fill(value); * rect(25, 25, 50, 50); + * describe(`black 50-by-50 rect becomes lighter with mouse movements until + * white then resets no image displayed`); * } * function mouseMoved() { * value = value + 5; @@ -526,10 +516,6 @@ p5.prototype._setMouseButton = function(e) { * } * * - * - * @alt - * black 50×50 rect becomes lighter with mouse movements until white then resets - * no image displayed */ /** @@ -538,7 +524,7 @@ p5.prototype._setMouseButton = function(e) { * touchMoved() function will be called instead if it is defined.

* Browsers may have different default * behaviors attached to various mouse events. To prevent any default - * behavior for this event, add "return false" to the end of the method. + * behavior for this event, add "return false" to the end of the function. * * @method mouseDragged * @param {Object} [event] optional MouseEvent callback argument. @@ -552,6 +538,8 @@ p5.prototype._setMouseButton = function(e) { * function draw() { * fill(value); * rect(25, 25, 50, 50); + * describe(`black 50-by-50 rect turns lighter with mouse click and + * drag until white, resets`); * } * function mouseDragged() { * value = value + 5; @@ -581,10 +569,6 @@ p5.prototype._setMouseButton = function(e) { * } * * - * - * @alt - * black 50×50 rect turns lighter with mouse click and drag until white, resets - * no image displayed */ p5.prototype._onmousemove = function(e) { const context = this._isGlobal ? window : this; @@ -620,7 +604,7 @@ p5.prototype._onmousemove = function(e) { * called instead if it is defined.

* Browsers may have different default * behaviors attached to various mouse events. To prevent any default - * behavior for this event, add "return false" to the end of the method. + * behavior for this event, add "return false" to the end of the function. * * @method mousePressed * @param {Object} [event] optional MouseEvent callback argument. @@ -634,6 +618,7 @@ p5.prototype._onmousemove = function(e) { * function draw() { * fill(value); * rect(25, 25, 50, 50); + * describe(`black 50-by-50 rect turns white with mouse click/press.`); * } * function mousePressed() { * if (value === 0) { @@ -664,10 +649,6 @@ p5.prototype._onmousemove = function(e) { * } * * - * - * @alt - * black 50×50 rect turns white with mouse click/press. - * no image displayed */ p5.prototype._onmousedown = function(e) { const context = this._isGlobal ? window : this; @@ -699,7 +680,7 @@ p5.prototype._onmousedown = function(e) { * function will be called instead if it is defined.

* Browsers may have different default * behaviors attached to various mouse events. To prevent any default - * behavior for this event, add "return false" to the end of the method. + * behavior for this event, add "return false" to the end of the function. * * @method mouseReleased * @param {Object} [event] optional MouseEvent callback argument. @@ -714,6 +695,7 @@ p5.prototype._onmousedown = function(e) { * function draw() { * fill(value); * rect(25, 25, 50, 50); + * describe(`black 50-by-50 rect turns white with mouse click/press.`); * } * function mouseReleased() { * if (value === 0) { @@ -744,10 +726,6 @@ p5.prototype._onmousedown = function(e) { * } * * - * - * @alt - * black 50×50 rect turns white with mouse click/press. - * no image displayed */ p5.prototype._onmouseup = function(e) { const context = this._isGlobal ? window : this; @@ -777,7 +755,7 @@ p5.prototype._ondragover = p5.prototype._onmousemove; * being pressed or released, see mousePressed() or mouseReleased().

* Browsers may have different default * behaviors attached to various mouse events. To prevent any default - * behavior for this event, add "return false" to the end of the method. + * behavior for this event, add "return false" to the end of the function. * * @method mouseClicked * @param {Object} [event] optional MouseEvent callback argument. @@ -792,6 +770,7 @@ p5.prototype._ondragover = p5.prototype._onmousemove; * function draw() { * fill(value); * rect(25, 25, 50, 50); + * describe(`black 50-by-50 rect turns white with mouse click/press.`); * } * * function mouseClicked() { @@ -823,10 +802,6 @@ p5.prototype._ondragover = p5.prototype._onmousemove; * } * * - * - * @alt - * black 50×50 rect turns white with mouse click/press. - * no image displayed */ p5.prototype._onclick = function(e) { const context = this._isGlobal ? window : this; @@ -860,6 +835,7 @@ p5.prototype._onclick = function(e) { * function draw() { * fill(value); * rect(25, 25, 50, 50); + * describe(`black 50-by-50 rect turns white with mouse doubleClick/press.`); * } * * function doubleClicked() { @@ -891,10 +867,6 @@ p5.prototype._onclick = function(e) { * } * * - * - * @alt - * black 50×50 rect turns white with mouse doubleClick/press. - * no image displayed */ p5.prototype._ondblclick = function(e) { @@ -929,7 +901,7 @@ p5.prototype._pmouseWheelDeltaY = 0; * touchpad.

* The event.delta property returns the amount the mouse wheel * have scrolled. The values can be positive or negative depending on the - * scroll direction (on OS X with "natural" scrolling enabled, the signs + * scroll direction (on macOS with "natural" scrolling enabled, the signs * are inverted).

* Browsers may have different default behaviors attached to various * mouse events. To prevent any default behavior for this event, add @@ -949,6 +921,8 @@ p5.prototype._pmouseWheelDeltaY = 0; * background(237, 34, 93); * fill(0); * rect(25, pos, 50, 50); + * describe(`black 50-by-50 rect moves up and down with vertical scroll. + * fuchsia background`); * } * * function mouseWheel(event) { @@ -960,9 +934,6 @@ p5.prototype._pmouseWheelDeltaY = 0; * } * * - * - * @alt - * black 50×50 rect moves up and down with vertical scroll. fuchsia background */ p5.prototype._onwheel = function(e) { const context = this._isGlobal ? window : this; @@ -1002,12 +973,11 @@ p5.prototype._onwheel = function(e) { * cam.pan(-movedX * 0.001); * cam.tilt(movedY * 0.001); * sphere(25); + * describe(`3D scene moves according to mouse mouse movement in a + * first person perspective`); * } * * - * - * @alt - * 3D scene moves according to mouse mouse movement in a first person perspective */ p5.prototype.requestPointerLock = function() { // pointer lock object forking for cross browser @@ -1036,6 +1006,7 @@ p5.prototype.requestPointerLock = function() { * let locked = false; * function draw() { * background(237, 34, 93); + * describe(`cursor gets locked / unlocked on mouse-click`); * } * function mouseClicked() { * if (!locked) { @@ -1048,9 +1019,6 @@ p5.prototype.requestPointerLock = function() { * } * * - * - * @alt - * cursor gets locked / unlocked on mouse-click */ p5.prototype.exitPointerLock = function() { document.exitPointerLock(); diff --git a/src/events/touch.js b/src/events/touch.js index 4849dc5d13..81c75062ee 100644 --- a/src/events/touch.js +++ b/src/events/touch.js @@ -29,12 +29,11 @@ import p5 from '../core/main'; * clear(); * let display = touches.length + ' touches'; * text(display, 5, 10); + * describe(`Number of touches currently registered are displayed + * on the canvas`); * } * * - * - * @alt - * Number of touches currently registered are displayed on the canvas */ p5.prototype.touches = []; @@ -88,6 +87,7 @@ function getTouchInfo(canvas, w, h, e, i = 0) { * function draw() { * fill(value); * rect(25, 25, 50, 50); + * describe(`50-by-50 black rect turns white with touch event.`); * } * function touchStarted() { * if (value === 0) { @@ -106,6 +106,7 @@ function getTouchInfo(canvas, w, h, e, i = 0) { * // prevent default * return false; * } + * describe('no image displayed'); * * * @@ -116,12 +117,9 @@ function getTouchInfo(canvas, w, h, e, i = 0) { * function touchStarted(event) { * console.log(event); * } + * describe('no image displayed'); * * - * - * @alt - * 50×50 black rect turns white with touch event. - * no image displayed */ p5.prototype._ontouchstart = function(e) { const context = this._isGlobal ? window : this; @@ -168,6 +166,7 @@ p5.prototype._ontouchstart = function(e) { * function draw() { * fill(value); * rect(25, 25, 50, 50); + * describe(`50-by-50 black rect turns lighter with touch until white. resets`); * } * function touchMoved() { * value = value + 5; @@ -185,6 +184,7 @@ p5.prototype._ontouchstart = function(e) { * // prevent default * return false; * } + * describe('no image displayed'); * * * @@ -195,12 +195,9 @@ p5.prototype._ontouchstart = function(e) { * function touchMoved(event) { * console.log(event); * } + * describe('no image displayed'); * * - * - * @alt - * 50×50 black rect turns lighter with touch until white. resets - * no image displayed */ p5.prototype._ontouchmove = function(e) { const context = this._isGlobal ? window : this; @@ -240,6 +237,7 @@ p5.prototype._ontouchmove = function(e) { * function draw() { * fill(value); * rect(25, 25, 50, 50); + * describe(`50-by-50 black rect turns white with touch.`); * } * function touchEnded() { * if (value === 0) { @@ -258,6 +256,7 @@ p5.prototype._ontouchmove = function(e) { * // prevent default * return false; * } + * describe('no image displayed'); * * * @@ -268,12 +267,9 @@ p5.prototype._ontouchmove = function(e) { * function touchEnded(event) { * console.log(event); * } + * describe('no image displayed'); * * - * - * @alt - * 50×50 black rect turns white with touch. - * no image displayed */ p5.prototype._ontouchend = function(e) { this._setProperty('mouseIsPressed', false); diff --git a/src/image/image.js b/src/image/image.js index 8260776c13..8ac3a24bba 100644 --- a/src/image/image.js +++ b/src/image/image.js @@ -420,15 +420,19 @@ p5.prototype.saveGif = function(pImg, filename) { * as an argument to the callback function as an array of objects, with the * size of array equal to the total number of frames. * - * Note that saveFrames() will only save the first 15 frames of an animation. + * The arguments `duration` and `framerate` are constrained to be less or equal to 15 and 22, respectively, which means you + * can only download a maximum of 15 seconds worth of frames at 22 frames per second, adding up to 330 frames. + * This is done in order to avoid memory problems since a large enough canvas can fill up the memory in your computer + * very easily and crash your program or even your browser. + * * To export longer animations, you might look into a library like * ccapture.js. * * @method saveFrames * @param {String} filename * @param {String} extension 'jpg' or 'png' - * @param {Number} duration Duration in seconds to save the frames for. - * @param {Number} framerate Framerate to save the frames in. + * @param {Number} duration Duration in seconds to save the frames for. This parameter will be constrained to be less or equal to 15. + * @param {Number} framerate Framerate to save the frames in. This parameter will be constrained to be less or equal to 22. * @param {function(Array)} [callback] A callback function that will be executed to handle the image data. This function should accept an array as argument. The diff --git a/src/image/p5.Image.js b/src/image/p5.Image.js index c21e758f1d..97253ec1ad 100644 --- a/src/image/p5.Image.js +++ b/src/image/p5.Image.js @@ -305,7 +305,7 @@ p5.Image.prototype.loadPixels = function() { * underlying canvas * @param {Integer} y y-offset of the target update area for the * underlying canvas - * @param {Integer} w height of the target update area for the + * @param {Integer} w width of the target update area for the * underlying canvas * @param {Integer} h height of the target update area for the * underlying canvas @@ -603,7 +603,7 @@ p5.Image.prototype.copy = function(...args) { /** * Masks part of an image from displaying by loading another * image and using its alpha channel as an alpha channel for - * this image. Masks are cumulative, one applied to an image + * this image. Masks are cumulative, once applied to an image * object, they cannot be removed. * * @method mask diff --git a/src/io/files.js b/src/io/files.js index 49ae034753..656cc26e2f 100644 --- a/src/io/files.js +++ b/src/io/files.js @@ -69,6 +69,8 @@ import '../core/friendly_errors/fes_core'; * ellipse(width / 2, height / 2, earthquakeMag * 10, earthquakeMag * 10); * textAlign(CENTER); * text(earthquakeName, 0, height - 30, width, 30); + * describe(`50×50 ellipse that changes from black to white + * depending on the current humidity`); * } * * @@ -85,6 +87,8 @@ import '../core/friendly_errors/fes_core'; * * function draw() { * background(200); + * describe(`50×50 ellipse that changes from black to white + * depending on the current humidity`); * } * * function drawEarthquake(earthquakes) { @@ -96,10 +100,6 @@ import '../core/friendly_errors/fes_core'; * text(earthquakeName, 0, height - 30, width, 30); * } * - * - * @alt - * 50×50 ellipse that changes from black to white depending on the current humidity - * 50×50 ellipse that changes from black to white depending on the current humidity */ /** * @method loadJSON @@ -217,6 +217,8 @@ p5.prototype.loadJSON = function(...args) { * function setup() { * background(200); * text(random(result), 10, 10, 80, 80); + * describe(`randomly generated text from a file, + * for example "i smell like butter"`); * } * * @@ -226,6 +228,8 @@ p5.prototype.loadJSON = function(...args) { *
* function setup() { * loadStrings('assets/test.txt', pickString); + * describe(`randomly generated text from a file, + * for example "i have three feet"`); * } * * function pickString(result) { @@ -233,10 +237,6 @@ p5.prototype.loadJSON = function(...args) { * text(random(result), 10, 10, 80, 80); * } *
- * - * @alt - * randomly generated text from a file, for example "i smell like butter" - * randomly generated text from a file, for example "i have three feet" */ p5.prototype.loadStrings = function(...args) { p5._validateParameters('loadStrings', args); @@ -364,13 +364,11 @@ p5.prototype.loadStrings = function(...args) { * for (let c = 0; c < table.getColumnCount(); c++) { * print(table.getString(r, c)); * } + * describe(`randomly generated text from a file, + * for example "i smell like butter"`); * } * * - * - * @alt - * randomly generated text from a file, for example "i smell like butter" - * randomly generated text from a file, for example "i have three feet" */ p5.prototype.loadTable = function(path) { // p5._validateParameters('loadTable', arguments); @@ -634,6 +632,7 @@ function makeObject(row, headers) { * let name = children[i].getContent(); * print(id + ', ' + coloring + ', ' + name); * } + * describe(`no image displayed`); * } * * // Sketch prints: @@ -641,9 +640,6 @@ function makeObject(row, headers) { * // 1, Panthera pardus, Leopard * // 2, Equus zebra, Zebra * - * - * @alt - * no image displayed */ p5.prototype.loadXML = function(...args) { const ret = new p5.XML(); @@ -712,11 +708,9 @@ p5.prototype.loadXML = function(...args) { * for (let i = 0; i < 5; i++) { * console.log(data.bytes[i].toString(16)); * } + * describe(`no image displayed`); * } * - * - * @alt - * no image displayed */ p5.prototype.loadBytes = function(file, callback, errorCallback) { const ret = {}; @@ -1434,18 +1428,21 @@ p5.PrintWriter = function(filename, extension) { * * // Saves the canvas as an image by default * save('myCanvas.jpg'); + * describe(`An example for saving a canvas as an image.`); * * - *
+ *
* // Saves p5.Image as an image * img = createImage(10, 10); * save(img, 'myImage.png'); + * describe(`An example for saving a p5.Image element as an image.`); *
* *
* // Saves p5.Renderer object as an image * obj = createGraphics(100, 100); * save(obj, 'myObject.png'); + * describe(`An example for saving a p5.Renderer element.`); *
* *
@@ -1458,6 +1455,9 @@ p5.PrintWriter = function(filename, extension) { * * // Tab Separated Values * save(myTable, 'myTable.tsv'); + * + * describe(`An example showing how to save a table in formats of + * HTML, CSV and TSV.`); *
* *
@@ -1468,21 +1468,17 @@ p5.PrintWriter = function(filename, extension) { * * // Optimizes JSON filesize * save(myJSON, 'my.json', true); + * + * describe(`An example for saving JSON to a txt file with some extra arguments.`); *
* *
* // Saves array of strings to text file with line breaks after each item * let arrayOfStrings = ['a', 'b']; * save(arrayOfStrings, 'my.txt'); + * describe(`An example for saving an array of strings to text file + * with line breaks.`); *
- * - * @alt - * An example for saving a canvas as an image. - * An example for saving a p5.Image element as an image. - * An example for saving a p5.Renderer element. - * An example showing how to save a table in formats of HTML, CSV and TSV. - * An example for saving JSON to a txt file with some extra arguments. - * An example for saving an array of strings to text file with line breaks. */ p5.prototype.save = function(object, _filename, _options) { @@ -1556,6 +1552,7 @@ p5.prototype.save = function(object, _filename, _options) { * createCanvas(100, 100); * background(200); * text('click here to save', 10, 10, 70, 80); + * describe(`no image displayed`); * } * * function mousePressed() { @@ -1571,9 +1568,6 @@ p5.prototype.save = function(object, _filename, _options) { * // "name": "Lion" * // } *
- * - * @alt - * no image displayed */ p5.prototype.saveJSON = function(json, filename, opt) { p5._validateParameters('saveJSON', arguments); @@ -1610,6 +1604,7 @@ p5.prototype.saveJSONArray = p5.prototype.saveJSON; * createCanvas(100, 100); * background(200); * text('click here to save', 10, 10, 70, 80); + * describe(`no image displayed`); * } * * function mousePressed() { @@ -1625,9 +1620,6 @@ p5.prototype.saveJSONArray = p5.prototype.saveJSON; * // cat * // dog * - * - * @alt - * no image displayed */ p5.prototype.saveStrings = function(list, filename, extension, isCRLF) { p5._validateParameters('saveStrings', arguments); @@ -1682,15 +1674,14 @@ function escapeHelper(content) { * * // To save, un-comment next line then click 'run' * // saveTable(table, 'new.csv'); + * + * describe(`no image displayed`); * } * * // Saves the following to a file called 'new.csv': * // id,species,name * // 0,Panthera leo,Lion * - * - * @alt - * no image displayed */ p5.prototype.saveTable = function(table, filename, options) { p5._validateParameters('saveTable', arguments); diff --git a/src/io/p5.Table.js b/src/io/p5.Table.js index 9dc0f6d286..b4be8220ad 100644 --- a/src/io/p5.Table.js +++ b/src/io/p5.Table.js @@ -125,12 +125,11 @@ p5.Table = function(rows) { * for (let r = 0; r < table.getRowCount(); r++) * for (let c = 0; c < table.getColumnCount(); c++) * print(table.getString(r, c)); + * + * describe(`no image displayed`); * } * * - * - * @alt - * no image displayed */ p5.Table.prototype.addRow = function(row) { // make sure it is a valid TableRow @@ -178,12 +177,11 @@ p5.Table.prototype.addRow = function(row) { * for (let r = 0; r < table.getRowCount(); r++) * for (let c = 0; c < table.getColumnCount(); c++) * print(table.getString(r, c)); + * + * describe(`no image displayed`); * } * * - * - * @alt - * no image displayed */ p5.Table.prototype.removeRow = function(id) { this.rows[id].table = null; // remove reference to table @@ -226,12 +224,11 @@ p5.Table.prototype.removeRow = function(id) { * for (let c = 0; c < table.getColumnCount(); c++) { * print(row.getString(c)); * } + * + * describe(`no image displayed`); * } * * - * - *@alt - * no image displayed */ p5.Table.prototype.getRow = function(r) { return this.rows[r]; @@ -274,12 +271,11 @@ p5.Table.prototype.getRow = function(r) { * for (let r = 0; r < table.getRowCount(); r++) * for (let c = 0; c < table.getColumnCount(); c++) * print(table.getString(r, c)); + * + * describe(`no image displayed`); * } * * - * - * @alt - * no image displayed */ p5.Table.prototype.getRows = function() { return this.rows; @@ -322,12 +318,10 @@ p5.Table.prototype.getRows = function() { * let row = table.findRow('Zebra', 'name'); * //find the corresponding species * print(row.getString('species')); + * describe(`no image displayed`); * } * * - * - * @alt - * no image displayed */ p5.Table.prototype.findRow = function(value, column) { // try the Object @@ -391,12 +385,10 @@ p5.Table.prototype.findRow = function(value, column) { * //find the rows containing animals named Goat * let rows = table.findRows('Goat', 'name'); * print(rows.length + ' Goats found'); + * describe(`no image displayed`); * } * * - * - *@alt - * no image displayed */ p5.Table.prototype.findRows = function(value, column) { const ret = []; @@ -573,12 +565,10 @@ p5.Table.prototype.matchRows = function(regexp, column) { * //getColumn returns an array that can be printed directly * print(table.getColumn('species')); * //outputs ["Capra hircus", "Panthera pardus", "Equus zebra"] + * describe(`no image displayed`); * } * * - * - *@alt - * no image displayed */ p5.Table.prototype.getColumn = function(value) { const ret = []; @@ -623,12 +613,10 @@ p5.Table.prototype.getColumn = function(value) { * table.clearRows(); * print(table.getRowCount() + ' total rows in table'); * print(table.getColumnCount() + ' total columns in table'); + * describe(`no image displayed`); * } * * - * - *@alt - * no image displayed */ p5.Table.prototype.clearRows = function() { delete this.rows; @@ -673,12 +661,11 @@ p5.Table.prototype.clearRows = function() { * for (let r = 0; r < table.getRowCount(); r++) * for (let c = 0; c < table.getColumnCount(); c++) * print(table.getString(r, c)); + * + * describe(`no image displayed`); * } * * - * - *@alt - * no image displayed */ p5.Table.prototype.addColumn = function(title) { const t = title || null; @@ -925,12 +912,10 @@ p5.Table.prototype.trim = function(column) { * function setup() { * table.removeColumn('id'); * print(table.getColumnCount()); + * describe(`no image displayed`); * } * * - * - *@alt - * no image displayed */ p5.Table.prototype.removeColumn = function(c) { let cString; @@ -995,12 +980,11 @@ p5.Table.prototype.removeColumn = function(c) { * for (let r = 0; r < table.getRowCount(); r++) * for (let c = 0; c < table.getColumnCount(); c++) * print(table.getString(r, c)); + * + * describe(`no image displayed`); * } * * - * - *@alt - * no image displayed */ p5.Table.prototype.set = function(row, column, value) { this.rows[row].set(column, value); @@ -1041,12 +1025,11 @@ p5.Table.prototype.set = function(row, column, value) { * * print(table.getColumn(0)); * //["0", 1, "2"] + * + * describe(`no image displayed`); * } * * - * - *@alt - * no image displayed */ p5.Table.prototype.setNum = function(row, column, value) { this.rows[row].setNum(column, value); @@ -1087,11 +1070,10 @@ p5.Table.prototype.setNum = function(row, column, value) { * newRow.setString('name', 'Wolf'); * * print(table.getArray()); + * + * describe(`no image displayed`); * } * - * - * @alt - * no image displayed */ p5.Table.prototype.setString = function(row, column, value) { this.rows[row].setString(column, value); @@ -1132,12 +1114,10 @@ p5.Table.prototype.setString = function(row, column, value) { * //Capra hircus * print(table.get(0, 'species')); * //Capra hircus + * describe(`no image displayed`); * } * * - * - *@alt - * no image displayed */ p5.Table.prototype.get = function(row, column) { return this.rows[row].get(column); @@ -1176,12 +1156,10 @@ p5.Table.prototype.get = function(row, column) { * function setup() { * print(table.getNum(1, 0) + 100); * //id 1 + 100 = 101 + * describe(`no image displayed`); * } * * - * - *@alt - * no image displayed */ p5.Table.prototype.getNum = function(row, column) { return this.rows[row].getNum(column); @@ -1227,12 +1205,10 @@ p5.Table.prototype.getNum = function(row, column) { * print(table.getString(2, 0)); // 2 * print(table.getString(2, 1)); // Equus zebra * print(table.getString(2, 2)); // Zebra + * describe(`no image displayed`); * } * * - * - *@alt - * no image displayed */ p5.Table.prototype.getString = function(row, column) { @@ -1273,12 +1249,11 @@ p5.Table.prototype.getString = function(row, column) { * * print(tableObject); * //outputs an object + * + * describe(`no image displayed`); * } * * - * - *@alt - * no image displayed */ p5.Table.prototype.getObject = function(headerColumn) { const tableObject = {}; @@ -1332,12 +1307,10 @@ p5.Table.prototype.getObject = function(headerColumn) { * for (let i = 0; i < tableArray.length; i++) { * print(tableArray[i]); * } + * describe(`no image displayed`); * } * * - * - *@alt - * no image displayed */ p5.Table.prototype.getArray = function() { const tableArray = []; diff --git a/src/io/p5.TableRow.js b/src/io/p5.TableRow.js index d13b131bbb..016cb7b57d 100644 --- a/src/io/p5.TableRow.js +++ b/src/io/p5.TableRow.js @@ -71,11 +71,10 @@ p5.TableRow = function(str, separator) { * * //print the results * print(table.getArray()); + * + * describe(`no image displayed`); * } * - * - * @alt - * no image displayed */ p5.TableRow.prototype.set = function(column, value) { // if typeof column is string, use .obj @@ -132,11 +131,10 @@ p5.TableRow.prototype.set = function(column, value) { * } * * print(table.getArray()); + * + * describe(`no image displayed`); * } * - * - * @alt - * no image displayed */ p5.TableRow.prototype.setNum = function(column, value) { const floatVal = parseFloat(value); @@ -177,11 +175,10 @@ p5.TableRow.prototype.setNum = function(column, value) { * } * * print(table.getArray()); + * + * describe(`no image displayed`); * } * - * - * @alt - * no image displayed */ p5.TableRow.prototype.setString = function(column, value) { const stringVal = value.toString(); @@ -222,11 +219,10 @@ p5.TableRow.prototype.setString = function(column, value) { * } * * print(names); + * + * describe(`no image displayed`); * } * - * - * @alt - * no image displayed */ p5.TableRow.prototype.get = function(column) { if (typeof column === 'string') { @@ -272,11 +268,9 @@ p5.TableRow.prototype.get = function(column) { * maxId = min(maxId, id); * } * print('minimum id = ' + minId + ', maximum id = ' + maxId); + * describe(`no image displayed`); * } * - * - * @alt - * no image displayed */ p5.TableRow.prototype.getNum = function(column) { let ret; @@ -329,11 +323,10 @@ p5.TableRow.prototype.getNum = function(column) { * } * * print('longest: ' + longest); + * + * describe(`no image displayed`); * } * - * - * @alt - * no image displayed */ p5.TableRow.prototype.getString = function(column) { if (typeof column === 'string') { diff --git a/src/io/p5.XML.js b/src/io/p5.XML.js index ac6e96f677..acd2d86415 100644 --- a/src/io/p5.XML.js +++ b/src/io/p5.XML.js @@ -39,6 +39,8 @@ import p5 from '../core/main'; * let name = children[i].getContent(); * print(id + ', ' + coloring + ', ' + name); * } + * + * describe(`no image displayed`); * } * * // Sketch prints: @@ -46,9 +48,6 @@ import p5 from '../core/main'; * // 1, Panthera pardus, Leopard * // 2, Equus zebra, Zebra * - * - * @alt - * no image displayed */ p5.XML = function(DOM) { if (!DOM) { diff --git a/src/math/calculation.js b/src/math/calculation.js index 7bc94ea85b..feccf4555a 100644 --- a/src/math/calculation.js +++ b/src/math/calculation.js @@ -22,11 +22,10 @@ import p5 from '../core/main'; * * print(x); // -3 * print(y); // 3 + * + * describe(`no image displayed`); * } * - * - * @alt - * no image displayed */ p5.prototype.abs = Math.abs; @@ -61,11 +60,11 @@ p5.prototype.abs = Math.abs; * noStroke(); * text(nfc(ax, 2), ax, ay - 5); * text(nfc(bx, 1), bx, by - 5); + * + * describe(`2 horizontal lines & number sets. increase with + * mouse x. bottom to 2 decimals`); * } * - * - * @alt - * 2 horizontal lines & number sets. increase with mouse x. bottom to 2 decimals */ p5.prototype.ceil = Math.ceil; @@ -102,11 +101,11 @@ p5.prototype.ceil = Math.ceil; * ellipse(xm, 33, 9, 9); // Not Constrained * fill(0); * ellipse(xc, 66, 9, 9); // Constrained + * + * describe(`2 vertical lines. 2 ellipses move with mouse X, + * 1 does not move past lines`); * } * - * - * @alt - * 2 vertical lines. 2 ellipses move with mouse X 1 does not move passed lines */ p5.prototype.constrain = function(n, low, high) { p5._validateParameters('constrain', arguments); @@ -115,7 +114,7 @@ p5.prototype.constrain = function(n, low, high) { /** * Calculates the distance between two points, in either two or three dimensions. - * If you looking for distance between two vectors see dist() + * If you looking for distance between two vectors see p5.Vector.dist() * * @method dist * @param {Number} x1 x-coordinate of the first point @@ -152,11 +151,11 @@ p5.prototype.constrain = function(n, low, high) { * text(nfc(d, 1), 0, -5); * pop(); * // Fancy! + * + * describe(`2 ellipses joined by line. 1 ellipse moves with + * mouse X&Y. Distance displayed.`); * } * - * - * @alt - * 2 ellipses joined by line. 1 ellipse moves with mouse X&Y. Distance displayed. */ /** * @method dist @@ -220,11 +219,10 @@ p5.prototype.dist = function(...args) { * endShape(); * line(0, 0, 0, height); * line(0, height - 1, width, height - 1); + * + * describe(`ellipse moves along a curve with mouse x. e^n displayed.`); * } * - * - * @alt - * ellipse moves along a curve with mouse x. e^n displayed. */ p5.prototype.exp = Math.exp; @@ -258,21 +256,21 @@ p5.prototype.exp = Math.exp; * noStroke(); * text(nfc(ax, 2), ax, ay - 5); * text(nfc(bx, 1), bx, by - 5); + * + * describe(`2 horizontal lines & number sets. + * increase with mouse x. bottom to 2 decimals`); * } * - * - * @alt - * 2 horizontal lines & number sets. increase with mouse x. bottom to 2 decimals */ p5.prototype.floor = Math.floor; /** * Calculates a number between two numbers at a specific increment. The amt * parameter is the amount to interpolate between the two values where 0.0 - * equal to the first point, 0.1 is very near the first point, 0.5 is + * is equal to the first point, 0.1 is very near the first point, 0.5 is * half-way in between, and 1.0 is equal to the second point. If the * value of amt is more than 1.0 or less than 0.0, the number will be - * calculated accordingly in the ratio of the two given numbers. The lerp + * calculated accordingly in the ratio of the two given numbers. The lerp() * function is convenient for creating motion along a straight * path and for drawing dotted lines. * @@ -302,11 +300,11 @@ p5.prototype.floor = Math.floor; * point(c, y); * point(d, y); * point(e, y); + * + * describe(`5 points horizontally staggered mid-canvas. + * mid 3 are grey, outer black`); * } * - * - * @alt - * 5 points horizontally staggered mid-canvas. mid 3 are grey, outer black */ p5.prototype.lerp = function(start, stop, amt) { p5._validateParameters('lerp', arguments); @@ -360,11 +358,11 @@ p5.prototype.lerp = function(start, stop, amt) { * endShape(); * line(0, 0, 0, height); * line(0, height / 2, width, height / 2); + * + * describe(`ellipse moves along a curve with mouse x. + * natural logarithm of n displayed.`); * } * - * - * @alt - * ellipse moves along a curve with mouse x. natural logarithm of n displayed. */ p5.prototype.log = Math.log; @@ -395,11 +393,10 @@ p5.prototype.log = Math.log; * print(mag(x1, y2)); // Prints "72.80109889280519" * line(0, 0, x2, y2); * print(mag(x2, y2)); // Prints "106.3014581273465" + * + * describe(`4 lines of different length radiate from top left of canvas.`); * } * - * - * @alt - * 4 lines of different length radiate from top left of canvas. */ p5.prototype.mag = function(x, y) { p5._validateParameters('mag', arguments); @@ -426,6 +423,7 @@ p5.prototype.mag = function(x, y) { * let value = 25; * let m = map(value, 0, 100, 0, width); * ellipse(m, 50, 10, 10); + * describe(`10×10 white ellipse with in mid left canvas`); * *
@@ -441,12 +439,11 @@ p5.prototype.mag = function(x, y) { * //after setting withinBounds to true * let x2 = map(mouseX, 0, width, 0, 100, true); * ellipse(x2, 75, 25, 25); + * + * describe(`Two 25×25 white ellipses move with mouse x. + * Bottom has more range from X`); * }
- * - * @alt - * 10 by 10 white ellipse with in mid left canvas - * 2 25 by 25 white ellipses move with mouse x. Bottom has more range from X */ p5.prototype.map = function(n, start1, stop1, start2, stop2, withinBounds) { p5._validateParameters('map', arguments); @@ -490,11 +487,11 @@ p5.prototype.map = function(n, start1, stop1, start2, stop2, withinBounds) { * // Draw the Maximum value in the array. * textSize(32); * text(max(numArray), maxX, maxY); + * + * describe(`Small text at top reads: Array Elements 2 1 5 4 8 9. + * Large text at center: 9`); * } * - * - * @alt - * Small text at top reads: Array Elements 2 1 5 4 8 9. Large text at center: 9 */ /** * @method max @@ -538,11 +535,11 @@ p5.prototype.max = function(...args) { * // Draw the Minimum value in the array. * textSize(32); * text(min(numArray), maxX, maxY); + * + * describe(`Small text at top reads: Array Elements 2 1 5 4 8 9. + * Large text at center: 1`); * } * - * - * @alt - * Small text at top reads: Array Elements 2 1 5 4 8 9. Large text at center: 1 */ /** * @method min @@ -598,11 +595,11 @@ p5.prototype.min = function(...args) { * let normalY = 40; * let normalX = 20; * text(normalized, normalX, normalY); + * + * describe(`ellipse moves with mouse. 0 shown left, 100 right, + * and updating values center`); * } * - * - * @alt - * ellipse moves with mouse. 0 shown left & 100 right and updating values center */ p5.prototype.norm = function(n, start, stop) { p5._validateParameters('norm', arguments); @@ -635,11 +632,10 @@ p5.prototype.norm = function(n, start, stop) { * ellipse(eLoc * 4, eLoc * 4, pow(eSize, 3), pow(eSize, 3)); * * ellipse(eLoc * 8, eLoc * 8, pow(eSize, 4), pow(eSize, 4)); + * + * describe(`small to large ellipses radiating from top left of canvas`); * } * - * - * @alt - * small to large ellipses radiating from top left of canvas */ p5.prototype.pow = Math.pow; @@ -655,10 +651,12 @@ p5.prototype.pow = Math.pow; *
* let x = round(3.7); * text(x, width / 2, height / 2); + * describe(`"4" written in middle of canvas`); *
*
* let x = round(12.782383, 2); * text(x, width / 2, height / 2); + * describe(`"12.78" written in middle of canvas`); *
*
* function draw() { @@ -682,13 +680,10 @@ p5.prototype.pow = Math.pow; * noStroke(); * text(nfc(ax, 2), ax, ay - 5); * text(nfc(bx, 1), bx, by - 5); + * + * describe(`two horizontal lines rounded values displayed on top.`); * } *
- * - * @alt - * "4" written in middle of canvas - * "12.78" written in middle of canvas - * two horizontal lines rounded values displayed on top. */ p5.prototype.round = function(n, decimals) { if (!decimals) { @@ -734,11 +729,11 @@ p5.prototype.round = function(n, decimals) { * fill(0); * text('x = ' + x1, 0, y1 + spacing); * text('sq(x) = ' + x2, 0, y2 + spacing); + * + * describe(`horizontal center line squared values displayed on + * top and regular on bottom.`); * } * - * - * @alt - * horizontal center line squared values displayed on top and regular on bottom. */ p5.prototype.sq = n => n * n; @@ -779,11 +774,11 @@ p5.prototype.sq = n => n * n; * let spacing = 15; * text('x = ' + x1, 0, y1 + spacing); * text('sqrt(x) = ' + x2, 0, y2 + spacing); + * + * describe(`horizontal center line squareroot values displayed on + * top and regular on bottom.`); * } * - * - * @alt - * horizontal center line squareroot values displayed on top and regular on bottom. */ p5.prototype.sqrt = Math.sqrt; @@ -839,16 +834,16 @@ function hypot(x, y, z) { *
* text(7345.73472742, 10, 25); * text(fract(7345.73472742), 10, 75); + * describe(`first row having a number and the second having + * the fractional part of the number`); *
* *
* text(1.4215e-15, 10, 25); * text(fract(1.4215e-15), 10, 75); + * describe(`first row having a number expressed in scientific + * notation and the second having the fractional part of the number`); *
- * - * @alt - * first row having a number and the second having the fractional part of the number - * first row having a number expressed in scientific notation and the second having the fractional part of the number */ p5.prototype.fract = function(toConvert) { p5._validateParameters('fract', arguments); diff --git a/src/math/math.js b/src/math/math.js index 89d07aaeef..d7479f68e8 100644 --- a/src/math/math.js +++ b/src/math/math.js @@ -9,7 +9,7 @@ import p5 from '../core/main'; /** * Creates a new p5.Vector (the datatype for storing vectors). This provides a - * two or three dimensional vector, specifically a Euclidean (also known as + * two or three-dimensional vector, specifically a Euclidean (also known as * geometric) vector. A vector is an entity that has both magnitude and * direction. * @@ -30,11 +30,9 @@ import p5 from '../core/main'; * function draw() { * background(255); * line(v1.x, v1.y, mouseX, mouseY); + * describe(`draws a line from center of canvas to mouse pointer position.`); * } * - * - * @alt - * draws a line from center of canvas to mouse pointer position. */ p5.prototype.createVector = function(x, y, z) { if (this instanceof p5) { diff --git a/src/math/noise.js b/src/math/noise.js index cb58e0744d..cbd8f5f0b1 100644 --- a/src/math/noise.js +++ b/src/math/noise.js @@ -36,26 +36,26 @@ let perlin; // will be initialized lazily by noise() or noiseSeed() /** * Returns the Perlin noise value at specified coordinates. Perlin noise is * a random sequence generator producing a more naturally ordered, harmonic - * succession of numbers compared to the standard random() function. + * succession of numbers compared to the standard random() function. * It was invented by Ken Perlin in the 1980s and been used since in * graphical applications to produce procedural textures, natural motion, * shapes, terrains etc.

The main difference to the - * random() function is that Perlin noise is defined in an infinite + * random() function is that Perlin noise is defined in an infinite * n-dimensional space where each pair of coordinates corresponds to a * fixed semi-random value (fixed only for the lifespan of the program; see * the noiseSeed() function). p5.js can compute 1D, 2D and 3D noise, * depending on the number of coordinates given. The resulting value will * always be between 0.0 and 1.0. The noise value can be animated by moving * through the noise space as demonstrated in the example above. The 2nd - * and 3rd dimension can also be interpreted as time.

The actual + * and 3rd dimensions can also be interpreted as time.

The actual * noise is structured similar to an audio signal, in respect to the * function's use of frequencies. Similar to the concept of harmonics in - * physics, perlin noise is computed over several octaves which are added + * physics, Perlin noise is computed over several octaves which are added * together for the final result.

Another way to adjust the * character of the resulting sequence is the scale of the input * coordinates. As the function works within an infinite space the value of * the coordinates doesn't matter as such, only the distance between - * successive coordinates does (eg. when using noise() within a + * successive coordinates does (eg. when using noise() within a * loop). As a general rule the smaller the difference between coordinates, * the smoother the resulting noise sequence will be. Steps of 0.005-0.03 * work best for most applications, but this will differ depending on use. @@ -76,6 +76,8 @@ let perlin; // will be initialized lazily by noise() or noiseSeed() * xoff = xoff + 0.01; * let n = noise(xoff) * width; * line(n, 0, n, height); + * describe(`vertical line moves left to right with updating + * noise values.`); * } * * @@ -89,13 +91,11 @@ let perlin; // will be initialized lazily by noise() or noiseSeed() * stroke(noiseVal*255); * line(x, mouseY+noiseVal*80, x, height); * } + * describe(`horizontal wave pattern effected by mouse x-position + * & updating noise values.`); * } * * - * - * @alt - * vertical line moves left to right with updating noise values. - * horizontal wave pattern effected by mouse x-position & updating noise values. */ p5.prototype.noise = function(x, y = 0, z = 0) { @@ -181,17 +181,17 @@ p5.prototype.noise = function(x, y = 0, z = 0) { * function. Similar to harmonics in physics, noise is computed over * several octaves. Lower octaves contribute more to the output signal and * as such define the overall intensity of the noise, whereas higher octaves - * create finer grained details in the noise sequence. + * create finer-grained details in the noise sequence. * * By default, noise is computed over 4 octaves with each octave contributing - * exactly half than its predecessor, starting at 50% strength for the 1st + * exactly half as much as its predecessor, starting at 50% strength for the 1st * octave. This falloff amount can be changed by adding an additional function * parameter. Eg. a falloff factor of 0.75 means each octave will now have * 75% impact (25% less) of the previous lower octave. Any value between - * 0.0 and 1.0 is valid, however note that values greater than 0.5 might - * result in greater than 1.0 values returned by noise(). + * 0.0 and 1.0 is valid, however, note that values greater than 0.5 might + * result in greater than 1.0 values returned by noise(). * - * By changing these parameters, the signal created by the noise() + * By changing these parameters, the signal created by the noise() * function can be adapted to fit very specific needs and characteristics. * * @method noiseDetail @@ -224,12 +224,11 @@ p5.prototype.noise = function(x, y = 0, z = 0) { * point(x + width / 2, y); * } * } + * describe(`2 vertical grey smokey patterns affected by + * mouse x-position and noise.`); * } * * - * - * @alt - * 2 vertical grey smokey patterns affected my mouse x-position and noise. */ p5.prototype.noiseDetail = function(lod, falloff) { if (lod > 0) { @@ -241,10 +240,10 @@ p5.prototype.noiseDetail = function(lod, falloff) { }; /** - * Sets the seed value for noise(). By default, noise() - * produces different results each time the program is run. Set the - * value parameter to a constant to return the same pseudo-random - * numbers each time the software is run. + * Sets the seed value for noise(). By default, + * noise() produces different results each time + * the program is run. Set the `seed` parameter to a constant to return + * the same pseudo-random numbers each time the software is run. * * @method noiseSeed * @param {Number} seed the seed value @@ -261,12 +260,10 @@ p5.prototype.noiseDetail = function(lod, falloff) { * xoff = xoff + .01; * let n = noise(xoff) * width; * line(n, 0, n, height); + * describe(`vertical grey lines drawing in pattern affected by noise.`); * } * * - * - * @alt - * vertical grey lines drawing in pattern affected by noise. */ p5.prototype.noiseSeed = function(seed) { // Linear Congruential Generator diff --git a/src/math/p5.Vector.js b/src/math/p5.Vector.js index fd0879cfc3..d7ba19b7e5 100644 --- a/src/math/p5.Vector.js +++ b/src/math/p5.Vector.js @@ -8,11 +8,11 @@ import p5 from '../core/main'; import * as constants from '../core/constants'; /** - * A class to describe a two or three dimensional vector, specifically + * A class to describe a two or three-dimensional vector, specifically * a Euclidean (also known as geometric) vector. A vector is an entity * that has both magnitude and direction. The datatype, however, stores - * the components of the vector (x, y for 2D, and x, y, z for 3D). The magnitude - * and direction can be accessed via the methods mag() and heading(). + * the components of the vector (`x`, `y` for 2D; or `x`, `y`, `z` for 3D). The magnitude + * and direction can be accessed via the methods p5.Vector.mag() and heading(). * * In many of the p5.js examples, you will see p5.Vector used to describe a * position, velocity, or acceleration. For example, if you consider a rectangle @@ -41,11 +41,11 @@ import * as constants from '../core/constants'; * ellipse(v2.x, v2.y, 50, 50); * v1.add(v2); * ellipse(v1.x, v1.y, 50, 50); + * + * describe(`2 white ellipses. One center-left the other + * bottom right and off canvas`); * * - * - * @alt - * 2 white ellipses. One center-left the other bottom right and off canvas */ p5.Vector = function Vector() { let x, y, z; @@ -84,8 +84,8 @@ p5.Vector = function Vector() { }; /** - * Returns a string representation of a vector v by calling String(v) - * or v.toString(). This method is useful for logging vectors in the + * Returns a string representation of a vector `v` by calling `String(v)` + * or `v.toString()`. This method is useful for logging vectors in the * console. * @method toString * @return {String} @@ -134,12 +134,12 @@ p5.Vector.prototype.toString = function p5VectorToString() { }; /** - * Sets the x, y, and z component of the vector using two or three separate + * Sets the `x`, `y`, and `z` components of the vector using two or three separate * variables, the data from a p5.Vector, or the values from a float array. * @method set - * @param {Number} [x] the x component of the vector - * @param {Number} [y] the y component of the vector - * @param {Number} [z] the z component of the vector + * @param {Number} [x] The x component of the vector + * @param {Number} [y] The y component of the vector + * @param {Number} [z] The z component of the vector * @chainable * @example *
@@ -194,7 +194,7 @@ p5.Vector.prototype.toString = function p5VectorToString() { */ /** * @method set - * @param {p5.Vector|Number[]} value the vector to set + * @param {p5.Vector|Number[]} value The vector to set * @chainable */ p5.Vector.prototype.set = function set(x, y, z) { @@ -220,7 +220,7 @@ p5.Vector.prototype.set = function set(x, y, z) { * Gets a copy of the vector, returns a p5.Vector object. * * @method copy - * @return {p5.Vector} the copy of the p5.Vector object + * @return {p5.Vector} A copy of the p5.Vector object * @example *
* @@ -246,16 +246,16 @@ p5.Vector.prototype.copy = function copy() { }; /** - * Adds x, y, and z components to a vector, adds one vector to another, or + * Adds `x`, `y`, and `z` components to a vector, adds one vector to another, or * adds two independent vectors together. The version of the method that adds * two vectors together is a static method and returns a p5.Vector, the others - * acts directly on the vector. Additionally, you may provide arguments to this function as an array. + * act directly on the vector. Additionally, you may provide arguments to this method as an array. * See the examples for more context. * * @method add - * @param {Number} x the x component of the vector to be added - * @param {Number} [y] the y component of the vector to be added - * @param {Number} [z] the z component of the vector to be added + * @param {Number} x The x component of the vector to be added + * @param {Number} [y] The y component of the vector to be added + * @param {Number} [z] The z component of the vector to be added * @chainable * @example *
@@ -324,7 +324,7 @@ p5.Vector.prototype.copy = function copy() { */ /** * @method add - * @param {p5.Vector|Number[]} value the vector to add + * @param {p5.Vector|Number[]} value The vector to add * @chainable */ p5.Vector.prototype.add = function add(x, y, z) { @@ -370,13 +370,13 @@ const calculateRemainder3D = function(xComponent, yComponent, zComponent) { return this; }; /** - * Gives remainder of a vector when it is divided by another vector. + * Gives the remainder of a vector when it is divided by another vector. * See examples for more context. * * @method rem - * @param {Number} x the x component of divisor vector - * @param {Number} y the y component of divisor vector - * @param {Number} z the z component of divisor vector + * @param {Number} x The x component of divisor vector + * @param {Number} y The y component of divisor vector + * @param {Number} z The z component of divisor vector * @chainable * @example *
@@ -400,7 +400,7 @@ const calculateRemainder3D = function(xComponent, yComponent, zComponent) { */ /** * @method rem - * @param {p5.Vector | Number[]} value divisor vector + * @param {p5.Vector | Number[]} value The divisor vector * @chainable */ p5.Vector.prototype.rem = function rem(x, y, z) { @@ -459,16 +459,16 @@ p5.Vector.prototype.rem = function rem(x, y, z) { }; /** - * Subtracts x, y, and z components from a vector, subtracts one vector from + * Subtracts `x`, `y`, and `z` components from a vector, subtracts one vector from * another, or subtracts two independent vectors. The version of the method * that subtracts two vectors is a static method and returns a p5.Vector, the - * other acts directly on the vector. Additionally, you may provide arguments to this function as an array. + * others act directly on the vector. Additionally, you may provide arguments to this method as an array. * See the examples for more context. * * @method sub - * @param {Number} x the x component of the vector to subtract - * @param {Number} [y] the y component of the vector to subtract - * @param {Number} [z] the z component of the vector to subtract + * @param {Number} x The x component of the vector to subtract + * @param {Number} [y] The y component of the vector to subtract + * @param {Number} [z] The z component of the vector to subtract * @chainable * @example *
@@ -560,12 +560,12 @@ p5.Vector.prototype.sub = function sub(x, y, z) { }; /** - * Multiplies the vector by a scalar, multiplies the x, y, and z components from a vector, or multiplies - * the x, y, and z components of two independent vectors. When multiplying a vector by a scalar, the x, y, - * and z components of the vector are all multiplied by the scalar. When multiplying a vector by a vector, - * the x, y, z components of both vectors are multiplied by each other - * (for example, with two vectors a and b: a.x * b.x, a.y * b.y, a.z * b.z). The static version of this method - * creates a new p5.Vector while the non static version acts on the vector + * Multiplies the vector by a scalar, multiplies the `x`, `y`, and `z` components from a vector, or multiplies + * the `x`, `y`, and `z` components of two independent vectors. When multiplying a vector by a scalar, the `x`, `y`, + * and `z` components of the vector are all multiplied by the scalar. When multiplying a vector by a vector, + * the `x`, `y`, `z` components of both vectors are multiplied by each other + * (for example, with two vectors `a` and `b`: `a.x * b.x`, `a.y * b.y`, `a.z * b.z`). The static version of this method + * creates a new p5.Vector while the non-static version acts on the vector * directly. Additionally, you may provide arguments to this function as an array. * See the examples for more context. * @@ -752,14 +752,15 @@ p5.Vector.prototype.mult = function mult(x, y, z) { }; /** - * Divides the vector by a scalar, divides a vector by the x, y, and z arguments, or divides the x, y, and - * z components of two vectors against each other. When dividing a vector by a scalar, the x, y, - * and z components of the vector are all divided by the scalar. When dividing a vector by a vector, - * the x, y, z components of the source vector are treated as the dividend, and the x, y, z components - * of the argument is treated as the divisor (for example with two vectors a and b: a.x / b.x, a.y / b.y, a.z / b.z). + * Divides the vector by a scalar, divides a vector by the `x`, `y`, and `z` arguments, or divides the `x`, `y`, and + * `z` components of two vectors against each other. When dividing a vector by a scalar, the `x`, `y`, + * and `z` components of the vector are all divided by the scalar. When dividing a vector by a vector, + * the `x`, `y`, `z` components of the source vector are treated as the dividend, and the `x`, `y`, `z` components + * of the argument is treated as the divisor. (For example, with two vectors + * `a` and `b`: `a.x / b.x`, `a.y / b.y`, `a.z / b.z`.) * The static version of this method creates a - * new p5.Vector while the non static version acts on the vector directly. - * Additionally, you may provide arguments to this function as an array. + * new p5.Vector while the non-static version acts on the vector directly. + * Additionally, you may provide arguments to this method as an array. * See the examples for more context. * * @method div @@ -958,10 +959,10 @@ p5.Vector.prototype.div = function div(x, y, z) { }; /** * Calculates the magnitude (length) of the vector and returns the result as - * a float (this is simply the equation sqrt(x\*x + y\*y + z\*z).) + * a float. (This is simply the equation `sqrt(x*x + y*y + z*z)`.) * * @method mag - * @return {Number} magnitude of the vector + * @return {Number} The magnitude of the vector * @example *
* @@ -1006,12 +1007,12 @@ p5.Vector.prototype.mag = function mag() { /** * Calculates the squared magnitude of the vector and returns the result - * as a float (this is simply the equation (x\*x + y\*y + z\*z).) + * as a float. (This is simply the equation `x*x + y*y + z*z`.) * Faster if the real length is not required in the * case of comparing vectors, etc. * * @method magSq - * @return {number} squared magnitude of the vector + * @return {number} The squared magnitude of the vector * @example *
* @@ -1064,10 +1065,10 @@ p5.Vector.prototype.magSq = function magSq() { * method. See the examples for more context. * * @method dot - * @param {Number} x x component of the vector - * @param {Number} [y] y component of the vector - * @param {Number} [z] z component of the vector - * @return {Number} the dot product + * @param {Number} x The x component of the vector + * @param {Number} [y] The y component of the vector + * @param {Number} [z] The z component of the vector + * @return {Number} The dot product * * @example *
@@ -1102,7 +1103,7 @@ p5.Vector.prototype.dot = function dot(x, y, z) { /** * Calculates and returns a vector composed of the cross product between - * two vectors. Both the static and non static methods return a new p5.Vector. + * two vectors. Both the static and non-static methods return a new p5.Vector. * See the examples for more context. * * @method cross @@ -1145,11 +1146,11 @@ p5.Vector.prototype.cross = function cross(v) { /** * Calculates the Euclidean distance between two points (considering a * point as a vector object). - * If you are looking to calculate distance with 2 points see dist() + * If you are looking to calculate distance between 2 points see dist() * * @method dist - * @param {p5.Vector} v the x, y, and z coordinates of a p5.Vector - * @return {Number} the distance + * @param {p5.Vector} v The x, y, and z coordinates of a p5.Vector + * @return {Number} The distance * @example *
* @@ -1218,7 +1219,7 @@ p5.Vector.prototype.dist = function dist(v) { * Normalize the vector to length 1 (make it a unit vector). * * @method normalize - * @return {p5.Vector} normalized p5.Vector + * @return {p5.Vector} The normalized p5.Vector * @example *
* @@ -1285,11 +1286,11 @@ p5.Vector.prototype.normalize = function normalize() { }; /** - * Limit the magnitude of this vector to the value used for the max + * Limit the magnitude of this vector to the value used for the `max` * parameter. * * @method limit - * @param {Number} max the maximum magnitude for the vector + * @param {Number} max The maximum magnitude for the vector * @chainable * @example *
@@ -1343,11 +1344,11 @@ p5.Vector.prototype.limit = function limit(max) { }; /** - * Set the magnitude of this vector to the value used for the len + * Set the magnitude of this vector to the value used for the `len` * parameter. * * @method setMag - * @param {number} len the new length for this vector + * @param {number} len The new length for this vector * @chainable * @example *
@@ -1399,13 +1400,13 @@ p5.Vector.prototype.setMag = function setMag(n) { }; /** - * Calculate the angle of rotation for this vector(only 2D vectors). + * Calculate the angle of rotation for this vector (only 2D vectors). * p5.Vectors created using createVector() - * will take the current angleMode into + * will take the current angleMode() into * consideration, and give the angle in radians or degree accordingly. * * @method heading - * @return {Number} the angle of rotation + * @return {Number} The angle of rotation * @example *
* @@ -1471,11 +1472,11 @@ p5.Vector.prototype.heading = function heading() { }; /** - * Rotate the vector to a specific angle (only 2D vectors), magnitude remains the - * same + * Rotate the vector to a specific angle (only 2D vectors); magnitude remains the + * same. * * @method setHeading - * @param {number} angle the angle of rotation + * @param {number} angle The angle of rotation * @chainable * @example *
@@ -1496,11 +1497,11 @@ p5.Vector.prototype.setHeading = function setHeading(a) { }; /** - * Rotate the vector by an angle (only 2D vectors), magnitude remains the - * same + * Rotate the vector by an angle (only 2D vectors); magnitude remains the + * same. * * @method rotate - * @param {number} angle the angle of rotation + * @param {number} angle The angle of rotation * @chainable * @example *
@@ -1565,13 +1566,13 @@ p5.Vector.prototype.rotate = function rotate(a) { }; /** - * Calculates and returns the angle between two vectors. This function will take + * Calculates and returns the angle between two vectors. This method will take * the current angleMode into consideration, and * give the angle in radians or degree accordingly. * * @method angleBetween - * @param {p5.Vector} value the x, y, and z components of a p5.Vector - * @return {Number} the angle between (in radians) + * @param {p5.Vector} value The x, y, and z components of a p5.Vector + * @return {Number} The angle between (in radians) * @example *
* @@ -1645,13 +1646,13 @@ p5.Vector.prototype.angleBetween = function angleBetween(v) { return angle; }; /** - * Linear interpolate the vector to another vector + * Linear interpolate the vector to another vector. * * @method lerp - * @param {Number} x the x component - * @param {Number} y the y component - * @param {Number} z the z component - * @param {Number} amt the amount of interpolation; some value between 0.0 + * @param {Number} x The x component + * @param {Number} y The y component + * @param {Number} z The z component + * @param {Number} amt The amount of interpolation; some value between 0.0 * (old vector) and 1.0 (new vector). 0.9 is very near * the new vector. 0.5 is halfway in between. * @chainable @@ -1719,7 +1720,7 @@ p5.Vector.prototype.angleBetween = function angleBetween(v) { */ /** * @method lerp - * @param {p5.Vector} v the p5.Vector to lerp to + * @param {p5.Vector} v The p5.Vector to lerp to * @param {Number} amt * @chainable */ @@ -1734,11 +1735,11 @@ p5.Vector.prototype.lerp = function lerp(x, y, z, amt) { }; /** - * Reflect the incoming vector about a normal to a line in 2D, or about a normal to a plane in 3D - * This method acts on the vector directly + * Reflect the incoming vector about a normal to a line in 2D, or about a normal to a plane in 3D. + * This method acts on the vector directly. * * @method reflect - * @param {p5.Vector} surfaceNormal the p5.Vector to reflect about, will be normalized by this method + * @param {p5.Vector} surfaceNormal The p5.Vector to reflect about; will be normalized by this method. * @chainable * @example *
@@ -1795,7 +1796,7 @@ p5.Vector.prototype.reflect = function reflect(surfaceNormal) { * array. * * @method array - * @return {Number[]} an Array with the 3 values + * @return {Number[]} An Array with the 3 values * @example *
* @@ -1821,13 +1822,13 @@ p5.Vector.prototype.array = function array() { }; /** - * Equality check against a p5.Vector + * Equality check against a p5.Vector. * * @method equals - * @param {Number} [x] the x component of the vector - * @param {Number} [y] the y component of the vector - * @param {Number} [z] the z component of the vector - * @return {Boolean} whether the vectors are equals + * @param {Number} [x] The x component of the vector + * @param {Number} [y] The y component of the vector + * @param {Number} [z] The z component of the vector + * @return {Boolean} Whether the vectors are equal * @example *
* @@ -1852,7 +1853,7 @@ p5.Vector.prototype.array = function array() { */ /** * @method equals - * @param {p5.Vector|Array} value the vector to compare + * @param {p5.Vector|Array} value The vector to compare * @return {Boolean} */ p5.Vector.prototype.equals = function equals(x, y, z) { @@ -1876,13 +1877,13 @@ p5.Vector.prototype.equals = function equals(x, y, z) { // Static Methods /** - * Make a new 2D vector from an angle + * Make a new 2D vector from an angle. * * @method fromAngle * @static - * @param {Number} angle the desired angle, in radians (unaffected by angleMode) - * @param {Number} [length] the length of the new vector (defaults to 1) - * @return {p5.Vector} the new p5.Vector object + * @param {Number} angle The desired angle, in radians (unaffected by angleMode) + * @param {Number} [length] The length of the new vector (defaults to 1) + * @return {p5.Vector} The new p5.Vector object * @example *
* @@ -1927,15 +1928,15 @@ p5.Vector.fromAngle = function fromAngle(angle, length) { }; /** - * Make a new 3D vector from a pair of ISO spherical angles + * Make a new 3D vector from a pair of ISO spherical angles. * * @method fromAngles * @static - * @param {Number} theta the polar angle, in radians (zero is up) - * @param {Number} phi the azimuthal angle, in radians + * @param {Number} theta The polar angle, in radians (zero is up) + * @param {Number} phi The azimuthal angle, in radians * (zero is out of the screen) - * @param {Number} [length] the length of the new vector (defaults to 1) - * @return {p5.Vector} the new p5.Vector object + * @param {Number} [length] The length of the new vector (defaults to 1) + * @return {p5.Vector} A new p5.Vector object * @example *
* @@ -1976,11 +1977,11 @@ p5.Vector.fromAngles = function(theta, phi, length) { }; /** - * Make a new 2D unit vector from a random angle + * Make a new 2D unit vector from a random angle. * * @method random2D * @static - * @return {p5.Vector} the new p5.Vector object + * @return {p5.Vector} A new p5.Vector object * @example *
* @@ -2033,7 +2034,7 @@ p5.Vector.random2D = function random2D() { * * @method random3D * @static - * @return {p5.Vector} the new p5.Vector object + * @return {p5.Vector} A new p5.Vector object * @example *
* @@ -2059,10 +2060,10 @@ p5.Vector.random3D = function random3D() { /** * @method add * @static - * @param {p5.Vector} v1 a p5.Vector to add - * @param {p5.Vector} v2 a p5.Vector to add - * @param {p5.Vector} [target] the vector to receive the result - * @return {p5.Vector} the resulting p5.Vector + * @param {p5.Vector} v1 A p5.Vector to add + * @param {p5.Vector} v2 A p5.Vector to add + * @param {p5.Vector} [target] The vector to receive the result + * @return {p5.Vector} The resulting p5.Vector */ p5.Vector.add = function add(v1, v2, target) { @@ -2085,15 +2086,15 @@ p5.Vector.add = function add(v1, v2, target) { /** * @method rem * @static - * @param {p5.Vector} v1 dividend p5.Vector - * @param {p5.Vector} v2 divisor p5.Vector + * @param {p5.Vector} v1 The dividend p5.Vector + * @param {p5.Vector} v2 The divisor p5.Vector */ /** * @method rem * @static * @param {p5.Vector} v1 * @param {p5.Vector} v2 - * @return {p5.Vector} the resulting p5.Vector + * @return {p5.Vector} The resulting p5.Vector */ p5.Vector.rem = function rem(v1, v2) { if (v1 instanceof p5.Vector && v2 instanceof p5.Vector) { @@ -2105,15 +2106,15 @@ p5.Vector.rem = function rem(v1, v2) { /* * Subtracts one p5.Vector from another and returns a new one. The second - * vector (v2) is subtracted from the first (v1), resulting in v1-v2. + * vector (`v2`) is subtracted from the first (`v1`), resulting in `v1-v2`. */ /** * @method sub * @static - * @param {p5.Vector} v1 a p5.Vector to subtract from - * @param {p5.Vector} v2 a p5.Vector to subtract - * @param {p5.Vector} [target] the vector to receive the result - * @return {p5.Vector} the resulting p5.Vector + * @param {p5.Vector} v1 A p5.Vector to subtract from + * @param {p5.Vector} v2 A p5.Vector to subtract + * @param {p5.Vector} [target] The vector to receive the result + * @return {p5.Vector} The resulting p5.Vector */ p5.Vector.sub = function sub(v1, v2, target) { @@ -2185,7 +2186,7 @@ p5.Vector.mult = function mult(v, n, target) { }; /** - * Rotates the vector (only 2D vectors) by the given angle, magnitude remains the same and returns a new vector. + * Rotates the vector (only 2D vectors) by the given angle; magnitude remains the same. Returns a new vector. */ /** @@ -2193,7 +2194,7 @@ p5.Vector.mult = function mult(v, n, target) { * @static * @param {p5.Vector} v * @param {Number} angle - * @param {p5.Vector} [target] the vector to receive the result + * @param {p5.Vector} [target] The vector to receive the result */ p5.Vector.rotate = function rotate(v, a, target) { if (arguments.length === 2) { @@ -2229,7 +2230,7 @@ p5.Vector.rotate = function rotate(v, a, target) { * @static * @param {p5.Vector} v * @param {Number} n - * @param {p5.Vector} [target] the vector to receive the result + * @param {p5.Vector} [target] The vector to receive the result */ /** @@ -2270,9 +2271,9 @@ p5.Vector.div = function div(v, n, target) { /** * @method dot * @static - * @param {p5.Vector} v1 the first p5.Vector - * @param {p5.Vector} v2 the second p5.Vector - * @return {Number} the dot product + * @param {p5.Vector} v1 The first p5.Vector + * @param {p5.Vector} v2 The second p5.Vector + * @return {Number} The dot product */ p5.Vector.dot = function dot(v1, v2) { return v1.dot(v2); @@ -2284,9 +2285,9 @@ p5.Vector.dot = function dot(v1, v2) { /** * @method cross * @static - * @param {p5.Vector} v1 the first p5.Vector - * @param {p5.Vector} v2 the second p5.Vector - * @return {Number} the cross product + * @param {p5.Vector} v1 The first p5.Vector + * @param {p5.Vector} v2 The second p5.Vector + * @return {Number} The cross product */ p5.Vector.cross = function cross(v1, v2) { return v1.cross(v2); @@ -2299,9 +2300,9 @@ p5.Vector.cross = function cross(v1, v2) { /** * @method dist * @static - * @param {p5.Vector} v1 the first p5.Vector - * @param {p5.Vector} v2 the second p5.Vector - * @return {Number} the distance + * @param {p5.Vector} v1 The first p5.Vector + * @param {p5.Vector} v2 The second p5.Vector + * @return {Number} The distance */ p5.Vector.dist = function dist(v1, v2) { return v1.dist(v2); @@ -2317,8 +2318,8 @@ p5.Vector.dist = function dist(v1, v2) { * @param {p5.Vector} v1 * @param {p5.Vector} v2 * @param {Number} amt - * @param {p5.Vector} [target] the vector to receive the result - * @return {p5.Vector} the lerped value + * @param {p5.Vector} [target] The vector to receive the result + * @return {p5.Vector} The lerped value */ p5.Vector.lerp = function lerp(v1, v2, amt, target) { if (!target) { @@ -2338,13 +2339,13 @@ p5.Vector.lerp = function lerp(v1, v2, amt, target) { /** * Calculates the magnitude (length) of the vector and returns the result as - * a float (this is simply the equation sqrt(x\*x + y\*y + z\*z).) + * a float (this is simply the equation `sqrt(x*x + y*y + z*z)`.) */ /** * @method mag * @static - * @param {p5.Vector} vecT the vector to return the magnitude of - * @return {Number} the magnitude of vecT + * @param {p5.Vector} vecT The vector to return the magnitude of + * @return {Number} The magnitude of vecT */ p5.Vector.mag = function mag(vecT) { const x = vecT.x, @@ -2360,9 +2361,9 @@ p5.Vector.mag = function mag(vecT) { /** * @method normalize * @static - * @param {p5.Vector} v the vector to normalize - * @param {p5.Vector} [target] the vector to receive the result - * @return {p5.Vector} v normalized to a length of 1 + * @param {p5.Vector} v The vector to normalize + * @param {p5.Vector} [target] The vector to receive the result + * @return {p5.Vector} The vector v, normalized to a length of 1 */ p5.Vector.normalize = function normalize(v, target) { if (arguments.length < 2) { diff --git a/src/math/random.js b/src/math/random.js index 2914020d33..137a459a73 100644 --- a/src/math/random.js +++ b/src/math/random.js @@ -52,11 +52,9 @@ p5.prototype._lcgSetSeed = function(stateProperty, val) { * stroke(r); * line(i, 0, i, 100); * } + * describe(`many vertical lines drawn in white, black, or grey.`); * *
- * - * @alt - * many vertical lines drawn in white, black or grey. */ p5.prototype.randomSeed = function(seed) { this._lcgSetSeed(randomStateProp, seed); @@ -92,6 +90,8 @@ p5.prototype.randomSeed = function(seed) { * stroke(r * 5); * line(50, i, 50 + r, i); * } + * describe(`100 horizontal lines from center canvas to right. + * The size and fill change each time.`); *
*
*
@@ -100,6 +100,8 @@ p5.prototype.randomSeed = function(seed) { * let r = random(-50, 50); * line(50, i, 50 + r, i); * } + * describe(`100 horizontal lines from center of canvas. + * The height & side change each render.`); * *
*
@@ -108,13 +110,9 @@ p5.prototype.randomSeed = function(seed) { * let words = ['apple', 'bear', 'cat', 'dog']; * let word = random(words); // select random word * text(word, 10, 50); // draw the word + * describe(`word displayed at random. Either apple, bear, cat, or dog.`); * *
- * - * @alt - * 100 horizontal lines from center canvas to right. size+fill change each time - * 100 horizontal lines from center of canvas. height & side change each render - * word displayed at random. Either apple, bear, cat, or dog */ /** * @method random @@ -160,9 +158,9 @@ p5.prototype.random = function(min, max) { * be returned. * * Takes either 0, 1 or 2 arguments.
- * If no args, returns a mean of 0 and standard deviation of 1.
- * If one arg, that arg is the mean (standard deviation is 1).
- * If two args, first is mean, second is standard deviation. + * If no args, the mean is 0 and the standard deviation is 1.
+ * If one arg, that arg is the mean and the standard deviation is 1.
+ * If two args, the first arg is the mean and the second is the standard deviation. * * @method randomGaussian * @param {Number} [mean] the mean @@ -175,6 +173,8 @@ p5.prototype.random = function(min, max) { * let x = randomGaussian(50, 15); * line(50, y, x, y); * } + * describe(`100 horizontal lines from center of canvas. + * The height & side change each render.`); * *
*
@@ -199,12 +199,12 @@ p5.prototype.random = function(min, max) { * let dist = abs(distribution[i]); * line(0, 0, dist, 0); * } + * + * describe(`black lines radiate from center of canvas. + * The size changes each render.`); * } * *
- * @alt - * 100 horizontal lines from center of canvas. height & side change each render - * black lines radiate from center of canvas. size determined each render */ p5.prototype.randomGaussian = function(mean, sd = 1) { let y1, x1, x2, w; diff --git a/src/math/trigonometry.js b/src/math/trigonometry.js index d71449cfc2..536d1d575d 100644 --- a/src/math/trigonometry.js +++ b/src/math/trigonometry.js @@ -18,8 +18,8 @@ p5.prototype._angleMode = constants.RADIANS; /** * The inverse of cos(), returns the arc cosine of a value. * This function expects the values in the range of -1 to 1 and values are returned in - * the range 0 to PI (3.1415927) if the angleMode is RADIANS or 0 to 180 if the - * angle mode is DEGREES. + * the range 0 to PI (3.1415927) if the angleMode() is RADIANS + * or 0 to 180 if the angleMode() is DEGREES. * * @method acos * @param {Number} value the value whose arc cosine is to be returned @@ -123,12 +123,13 @@ p5.prototype.atan = function(ratio) { /** * Calculates the angle (in radians) from a specified point to the coordinate * origin as measured from the positive x-axis. Values are returned as a - * float in the range from PI to -PI if the angleMode is RADIANS or 180 to - * -180 if the angleMode is DEGREES. The atan2() function is - * most often used for orienting geometry to the position of the cursor. + * float in the range from PI to -PI if the angleMode() + * is RADIANS or 180 to -180 if the angleMode() is DEGREES. + * The atan2() function is most often used for orienting geometry + * to the position of the cursor. * * Note: The y-coordinate of the point is the first parameter, and the - * x-coordinate is the second parameter, due the the structure of calculating + * x-coordinate is the second parameter, due to the structure of calculating * the tangent. * * @method atan2 @@ -145,12 +146,10 @@ p5.prototype.atan = function(ratio) { * let a = atan2(mouseY - height / 2, mouseX - width / 2); * rotate(a); * rect(-30, -5, 60, 10); + * describe(`60×10 rect at center of canvas rotates with mouse movements`); * } *
*
- * - * @alt - * 60 by 10 rect at center of canvas rotates with mouse movements */ p5.prototype.atan2 = function(y, x) { return this._fromRadians(Math.atan2(y, x)); @@ -173,11 +172,10 @@ p5.prototype.atan2 = function(y, x) { * line(i * 4, 50, i * 4, 50 + cos(a) * 40.0); * a = a + inc; * } + * describe(`vertical black lines form wave patterns, extend-down on + * left and right side`); *
*
- * - * @alt - * vertical black lines form wave patterns, extend-down on left and right side */ p5.prototype.cos = function(angle) { return Math.cos(this._toRadians(angle)); @@ -200,11 +198,10 @@ p5.prototype.cos = function(angle) { * line(i * 4, 50, i * 4, 50 + sin(a) * 40.0); * a = a + inc; * } + * describe(`vertical black lines extend down and up from center + * to form wave pattern.`); *
*
- * - * @alt - * vertical black lines extend down and up from center to form wave pattern */ p5.prototype.sin = function(angle) { return Math.sin(this._toRadians(angle)); @@ -227,10 +224,9 @@ p5.prototype.sin = function(angle) { * line(i, 50, i, 50 + tan(a) * 2.0); * a = a + inc; * } + * describe(`vertical black lines end down and up from center to + * form spike pattern.`); * - * - * @alt - * vertical black lines end down and up from center to form spike pattern */ p5.prototype.tan = function(angle) { return Math.tan(this._toRadians(angle)); @@ -241,7 +237,7 @@ p5.prototype.tan = function(angle) { * Radians and degrees are two ways of measuring the same thing. There are * 360 degrees in a circle and 2*PI radians in a circle. For example, * 90° = PI/2 = 1.5707964. This function does not take into account the - * current angleMode. + * current angleMode(). * * @method degrees * @param {Number} radians the radians value to convert to degrees @@ -283,11 +279,11 @@ p5.prototype.degrees = angle => angle * constants.RAD_TO_DEG; p5.prototype.radians = angle => angle * constants.DEG_TO_RAD; /** - * Sets the current mode of p5 to given mode. Default mode is RADIANS. + * Sets the current mode of p5 to the given mode. Default mode is RADIANS. * + * Calling angleMode() with no arguments returns current anglemode. * @method angleMode * @param {Constant} mode either RADIANS or DEGREES - * * @example *
* @@ -303,16 +299,22 @@ p5.prototype.radians = angle => angle * constants.DEG_TO_RAD; * angleMode(RADIANS); // Change the mode to RADIANS * rotate(a); // variable a stays the same * rect(-40, -5, 20, 10); // Smaller rectangle is rotating in radians + * describe(`40×10 rect in center rotates with mouse moves. + * 20×10 rect moves faster.`); * } * *
* - * @alt - * 40 by 10 rect in center rotates with mouse moves. 20 by 10 rect moves faster. - * + */ +/** + * @method angleMode + * @return {Constant} mode either RADIANS or DEGREES */ p5.prototype.angleMode = function(mode) { - if (mode === constants.DEGREES || mode === constants.RADIANS) { + p5._validateParameters('angleMode', arguments); + if (typeof mode === 'undefined') { + return this._angleMode; + } else if (mode === constants.DEGREES || mode === constants.RADIANS) { this._angleMode = mode; } }; diff --git a/src/typography/attributes.js b/src/typography/attributes.js index 0b8fba11ed..ee2fc13b89 100644 --- a/src/typography/attributes.js +++ b/src/typography/attributes.js @@ -20,7 +20,7 @@ import p5 from '../core/main'; * So if you write textAlign(LEFT), you are aligning the left * edge of your text to the x value you give in text(). * If you write textAlign(RIGHT, TOP), you are aligning the right edge - * of your text to the x value and the top of edge of the text + * of your text to the x value and the top edge of the text * to the y value. * * @method textAlign @@ -39,6 +39,8 @@ import p5 from '../core/main'; * text('EFGH', 50, 50); * textAlign(LEFT); * text('IJKL', 50, 70); + * describe(`Letters ABCD displayed at top left, EFGH at center, and + * IJKL at bottom right.`); * *
* @@ -62,12 +64,12 @@ import p5 from '../core/main'; * line(0, 87, width, 87); * textAlign(CENTER, BOTTOM); * text('BOTTOM', 0, 87, width); + * + * describe(`The names of the four vertical alignments (TOP, CENTER, BASELINE, + * and BOTTOM) rendered each showing that alignment's placement relative to a + * horizontal line.`); *
*
- * - * @alt - * Letters ABCD displayed at top left, EFGH at center and IJKL at bottom right. - * The names of the four vertical alignments (TOP, CENTER, BASELINE & BOTTOM) rendered each showing that alignment's placement relative to a horizontal line. */ /** * @method textAlign @@ -100,11 +102,11 @@ p5.prototype.textAlign = function(horizAlign, vertAlign) { * * textLeading(30); * text(lines, 70, 25); + * + * describe(`A set of L1, L2, and L3, displayed vertically 3 times. + * Spacing increases for each set.`); * *
- * - * @alt - * A set of L1 L2 & L3 displayed vertically 3 times. spacing increases for each set */ /** * @method textLeading @@ -132,11 +134,12 @@ p5.prototype.textLeading = function(theLeading) { * text('Font Size 14', 10, 60); * textSize(16); * text('Font Size 16', 10, 90); + * + * describe(`'Font Size 12' displayed small, + * 'Font Size 14' medium, and + * 'Font Size 16' large`); * *
- * - * @alt - * 'Font Size 12' displayed small, 'Font Size 14' medium & 'Font Size 16' large */ /** * @method textSize @@ -169,11 +172,12 @@ p5.prototype.textSize = function(theSize) { * text('Font Style Bold', 10, 65); * textStyle(BOLDITALIC); * text('Font Style Bold Italic', 10, 90); + * describe(`The words “Font Style Normal” displayed normally, + * “Font Style Italic” in italic, + * “Font Style Bold” in bold, and + * “Font Style Bold Italic” in bold italics.`); *
*
- * - * @alt - * Words Font Style Normal displayed normally, Italic in italic, bold in bold and bold italic in bold italics. */ /** * @method textStyle @@ -204,11 +208,10 @@ p5.prototype.textStyle = function(theStyle) { * let sWidth = textWidth(aString); * text(aString, 0, 85); * line(sWidth, 50, sWidth, 100); + * + * describe(`Letter P and p5.js are displayed with vertical lines at end.`); * *
- * - * @alt - * Letter P and p5.js are displayed with vertical lines at end. */ p5.prototype.textWidth = function(...args) { args[0] += ''; diff --git a/src/typography/loading_displaying.js b/src/typography/loading_displaying.js index d0a8553b73..5c046adf72 100644 --- a/src/typography/loading_displaying.js +++ b/src/typography/loading_displaying.js @@ -15,9 +15,9 @@ import '../core/friendly_errors/fes_core'; /** * Loads an opentype font file (.otf, .ttf) from a file or a URL, - * and returns a PFont Object. This method is asynchronous, - * meaning it may not finish before the next line in your sketch - * is executed. + * and returns a p5.Font object. This function + * is asynchronous, meaning it may not finish before the next line in + * your sketch is executed. * * The path to the font should be relative to the HTML file * that links in your sketch. Loading fonts from a URL or other @@ -119,11 +119,11 @@ p5.prototype.loadFont = function(path, onSuccess, onError) { const lastDotIdx = fileNoPath.lastIndexOf('.'); let fontFamily; let newStyle; - const fileExt = lastDotIdx < 1 ? null : fileNoPath.substr(lastDotIdx + 1); + const fileExt = lastDotIdx < 1 ? null : fileNoPath.slice(lastDotIdx + 1); // if so, add it to the DOM (name-only) for use with DOM module if (validFontTypes.includes(fileExt)) { - fontFamily = fileNoPath.substr(0, lastDotIdx); + fontFamily = fileNoPath.slice(0, lastDotIdx !== -1 ? lastDotIdx : 0); newStyle = document.createElement('style'); newStyle.appendChild( document.createTextNode( diff --git a/src/typography/p5.Font.js b/src/typography/p5.Font.js index 1c65ccae2a..b632db07da 100644 --- a/src/typography/p5.Font.js +++ b/src/typography/p5.Font.js @@ -64,12 +64,12 @@ p5.Font = function(p) { * textFont(font); * textSize(12); * text(textString, 10, 30); + * + * describe(`Words “Lorem ipsum dol” go off canvas and + * contained by white bounding box`); * } * *
- * - * @alt - *words Lorem ipsum dol go off canvas and contained by white bounding box */ p5.Font.prototype.textBounds = function(str, x = 0, y = 0, fontSize, opts) { // Check cache for existing bounds. Take into consideration the text alignment diff --git a/src/webgl/3d_primitives.js b/src/webgl/3d_primitives.js index 090a89479e..ef6a973cb0 100644 --- a/src/webgl/3d_primitives.js +++ b/src/webgl/3d_primitives.js @@ -27,6 +27,7 @@ import * as constants from '../core/constants'; * // with width 50 and height 50 * function setup() { * createCanvas(100, 100, WEBGL); + * describe('a white plane with black wireframe lines'); * } * * function draw() { @@ -112,6 +113,7 @@ p5.prototype.plane = function(width, height, detailX, detailY) { * // with width, height and depth of 50 * function setup() { * createCanvas(100, 100, WEBGL); + * describe('a white box rotating in 3D space'); * } * * function draw() { @@ -231,6 +233,7 @@ p5.prototype.box = function(width, height, depth, detailX, detailY) { * // draw a sphere with radius 40 * function setup() { * createCanvas(100, 100, WEBGL); + * describe('a white sphere with black wireframe lines'); * } * * function draw() { @@ -250,6 +253,9 @@ p5.prototype.box = function(width, height, depth, detailX, detailY) { * detailX = createSlider(3, 24, 3); * detailX.position(10, height + 5); * detailX.style('width', '80px'); + * describe( + * 'a white sphere with low detail on the x-axis, including a slider to adjust detailX' + * ); * } * * function draw() { @@ -270,6 +276,9 @@ p5.prototype.box = function(width, height, depth, detailX, detailY) { * detailY = createSlider(3, 16, 3); * detailY.position(10, height + 5); * detailY.style('width', '80px'); + * describe( + * 'a white sphere with low detail on the y-axis, including a slider to adjust detailY' + * ); * } * * function draw() { @@ -441,6 +450,7 @@ const _truncatedCone = function( * // with radius 20 and height 50 * function setup() { * createCanvas(100, 100, WEBGL); + * describe('a rotating white cylinder'); * } * * function draw() { @@ -462,6 +472,9 @@ const _truncatedCone = function( * detailX = createSlider(3, 24, 3); * detailX.position(10, height + 5); * detailX.style('width', '80px'); + * describe( + * 'a rotating white cylinder with limited X detail, with a slider that adjusts detailX' + * ); * } * * function draw() { @@ -482,6 +495,9 @@ const _truncatedCone = function( * detailY = createSlider(1, 16, 1); * detailY.position(10, height + 5); * detailY.style('width', '80px'); + * describe( + * 'a rotating white cylinder with limited Y detail, with a slider that adjusts detailY' + * ); * } * * function draw() { @@ -576,6 +592,7 @@ p5.prototype.cylinder = function( * // with radius 40 and height 70 * function setup() { * createCanvas(100, 100, WEBGL); + * describe('a rotating white cone'); * } * * function draw() { @@ -597,6 +614,9 @@ p5.prototype.cylinder = function( * detailX = createSlider(3, 16, 3); * detailX.position(10, height + 5); * detailX.style('width', '80px'); + * describe( + * 'a rotating white cone with limited X detail, with a slider that adjusts detailX' + * ); * } * * function draw() { @@ -617,6 +637,9 @@ p5.prototype.cylinder = function( * detailY = createSlider(3, 16, 3); * detailY.position(10, height + 5); * detailY.style('width', '80px'); + * describe( + * 'a rotating white cone with limited Y detail, with a slider that adjusts detailY' + * ); * } * * function draw() { @@ -692,6 +715,7 @@ p5.prototype.cone = function(radius, height, detailX, detailY, cap) { * // with radius 30, 40 and 40. * function setup() { * createCanvas(100, 100, WEBGL); + * describe('a white 3d ellipsoid'); * } * * function draw() { @@ -711,6 +735,9 @@ p5.prototype.cone = function(radius, height, detailX, detailY, cap) { * detailX = createSlider(2, 24, 12); * detailX.position(10, height + 5); * detailX.style('width', '80px'); + * describe( + * 'a rotating white ellipsoid with limited X detail, with a slider that adjusts detailX' + * ); * } * * function draw() { @@ -731,6 +758,9 @@ p5.prototype.cone = function(radius, height, detailX, detailY, cap) { * detailY = createSlider(2, 24, 6); * detailY.position(10, height + 5); * detailY.style('width', '80px'); + * describe( + * 'a rotating white ellipsoid with limited Y detail, with a slider that adjusts detailY' + * ); * } * * function draw() { @@ -826,6 +856,7 @@ p5.prototype.ellipsoid = function(radiusX, radiusY, radiusZ, detailX, detailY) { * // with ring radius 30 and tube radius 15 * function setup() { * createCanvas(100, 100, WEBGL); + * describe('a rotating white torus'); * } * * function draw() { @@ -847,6 +878,9 @@ p5.prototype.ellipsoid = function(radiusX, radiusY, radiusZ, detailX, detailY) { * detailX = createSlider(3, 24, 3); * detailX.position(10, height + 5); * detailX.style('width', '80px'); + * describe( + * 'a rotating white torus with limited X detail, with a slider that adjusts detailX' + * ); * } * * function draw() { @@ -867,6 +901,9 @@ p5.prototype.ellipsoid = function(radiusX, radiusY, radiusZ, detailX, detailY) { * detailY = createSlider(3, 16, 3); * detailY.position(10, height + 5); * detailY.style('width', '80px'); + * describe( + * 'a rotating white torus with limited Y detail, with a slider that adjusts detailY' + * ); * } * * function draw() { diff --git a/src/webgl/interaction.js b/src/webgl/interaction.js index 87680921df..d13a9acd3e 100644 --- a/src/webgl/interaction.js +++ b/src/webgl/interaction.js @@ -30,6 +30,9 @@ import * as constants from '../core/constants'; * function setup() { * createCanvas(100, 100, WEBGL); * normalMaterial(); + * describe( + * 'Camera orbits around a box when mouse is hold-clicked & then moved.' + * ); * } * function draw() { * background(200); @@ -167,6 +170,9 @@ p5.prototype.orbitControl = function(sensitivityX, sensitivityY, sensitivityZ) { * camera(0, -30, 100, 0, 0, 0, 0, 1, 0); * normalMaterial(); * debugMode(); + * describe( + * 'a 3D box is centered on a grid in a 3D sketch. an icon indicates the direction of each axis: a red line points +X, a green line +Y, and a blue line +Z. the grid and icon disappear when the spacebar is pressed.' + * ); * } * * function draw() { @@ -194,6 +200,7 @@ p5.prototype.orbitControl = function(sensitivityX, sensitivityY, sensitivityZ) { * camera(0, -30, 100, 0, 0, 0, 0, 1, 0); * normalMaterial(); * debugMode(GRID); + * describe('a 3D box is centered on a grid in a 3D sketch.'); * } * * function draw() { @@ -214,6 +221,9 @@ p5.prototype.orbitControl = function(sensitivityX, sensitivityY, sensitivityZ) { * camera(0, -30, 100, 0, 0, 0, 0, 1, 0); * normalMaterial(); * debugMode(AXES); + * describe( + * 'a 3D box is centered in a 3D sketch. an icon indicates the direction of each axis: a red line points +X, a green line +Y, and a blue line +Z.' + * ); * } * * function draw() { @@ -236,6 +246,7 @@ p5.prototype.orbitControl = function(sensitivityX, sensitivityY, sensitivityZ) { * camera(0, -30, 100, 0, 0, 0, 0, 1, 0); * normalMaterial(); * debugMode(GRID, 100, 10, 0, 0, 0); + * describe('a 3D box is centered on a grid in a 3D sketch'); * } * * function draw() { @@ -256,6 +267,9 @@ p5.prototype.orbitControl = function(sensitivityX, sensitivityY, sensitivityZ) { * camera(0, -30, 100, 0, 0, 0, 0, 1, 0); * normalMaterial(); * debugMode(100, 10, 0, 0, 0, 20, 0, -40, 0); + * describe( + * 'a 3D box is centered on a grid in a 3D sketch. an icon indicates the direction of each axis: a red line points +X, a green line +Y, and a blue line +Z.' + * ); * } * * function draw() { @@ -361,6 +375,9 @@ p5.prototype.debugMode = function(...args) { * camera(0, -30, 100, 0, 0, 0, 0, 1, 0); * normalMaterial(); * debugMode(); + * describe( + * 'a 3D box is centered on a grid in a 3D sketch. an icon indicates the direction of each axis: a red line points +X, a green line +Y, and a blue line +Z. the grid and icon disappear when the spacebar is pressed.' + * ); * } * * function draw() { diff --git a/src/webgl/light.js b/src/webgl/light.js index 739ff21d16..c5df0add0a 100644 --- a/src/webgl/light.js +++ b/src/webgl/light.js @@ -9,68 +9,91 @@ import p5 from '../core/main'; import * as constants from '../core/constants'; /** - * Creates an ambient light with a color. Ambient light is light that comes from everywhere on the canvas. - * It has no particular source. + * Creates an ambient light with the given color. + * + * Ambient light does not come from a specific direction. + * Objects are evenly lit from all sides. Ambient lights are + * almost always used in combination with other types of lights. + * + * Note: lights need to be called (whether directly or indirectly) + * within draw() to remain persistent in a looping program. + * Placing them in setup() will cause them to only have an effect + * the first time through the loop. + * * @method ambientLight - * @param {Number} v1 red or hue value relative to - * the current color range - * @param {Number} v2 green or saturation value - * relative to the current color range - * @param {Number} v3 blue or brightness value - * relative to the current color range - * @param {Number} [alpha] the alpha value + * @param {Number} v1 red or hue value relative to + * the current color range + * @param {Number} v2 green or saturation value + * relative to the current color range + * @param {Number} v3 blue or brightness value + * relative to the current color range + * @param {Number} [alpha] alpha value relative to current + * color range (default is 0-255) * @chainable * * @example *
* - * createCanvas(100, 100, WEBGL); - * ambientLight(0); - * ambientMaterial(250); - * sphere(40); + * function setup() { + * createCanvas(100, 100, WEBGL); + * noStroke(); + * describe('sphere with coral color under black light'); + * } + * function draw() { + * background(100); + * ambientLight(0); // black light (no light) + * ambientMaterial(255, 127, 80); // coral material + * sphere(40); + * } * *
+ * @alt + * sphere with coral color under black light + * + * @example *
* * function setup() { * createCanvas(100, 100, WEBGL); + * noStroke(); + * describe('sphere with coral color under white light'); * } * function draw() { - * background(51); - * ambientLight(100); // white light - * ambientMaterial(255, 102, 94); // magenta material - * box(30); + * background(100); + * ambientLight(255); // white light + * ambientMaterial(255, 127, 80); // coral material + * sphere(40); * } * *
* @alt - * evenly distributed light across a sphere - * evenly distributed light across a rotating sphere + * sphere with coral color under white light */ /** * @method ambientLight - * @param {String} value a color string + * @param {Number} gray number specifying value between + * white and black + * @param {Number} [alpha] * @chainable */ /** * @method ambientLight - * @param {Number} gray a gray value - * @param {Number} [alpha] + * @param {String} value a color string * @chainable */ /** * @method ambientLight * @param {Number[]} values an array containing the red,green,blue & - * and alpha components of the color + * and alpha components of the color * @chainable */ /** * @method ambientLight - * @param {p5.Color} color the ambient light color + * @param {p5.Color} color color as a p5.Color * @chainable */ p5.prototype.ambientLight = function(v1, v2, v3, a) { @@ -90,74 +113,101 @@ p5.prototype.ambientLight = function(v1, v2, v3, a) { }; /** - * Set's the color of the specular highlight when using a specular material and - * specular light. + * Sets the color of the specular highlight of a non-ambient light + * (i.e. all lights except ambientLight()). + * + * specularColor() affects only the lights which are created after + * it in the code. * - * This method can be combined with specularMaterial() and shininess() - * functions to set specular highlights. The default color is white, ie - * (255, 255, 255), which is used if this method is not called before - * specularMaterial(). If this method is called without specularMaterial(), - * There will be no effect. + * This function is used in combination with + * specularMaterial(). + * If a geometry does not use specularMaterial(), this function + * will have no effect. * - * Note: specularColor is equivalent to the processing function + * The default color is white (255, 255, 255), which is used if + * specularColor() is not explicitly called. + * + * Note: specularColor is equivalent to the Processing function * lightSpecular. * * @method specularColor * @param {Number} v1 red or hue value relative to - * the current color range + * the current color range * @param {Number} v2 green or saturation value - * relative to the current color range + * relative to the current color range * @param {Number} v3 blue or brightness value - * relative to the current color range + * relative to the current color range * @chainable * @example *
* + * let setRedSpecularColor = true; + * * function setup() { * createCanvas(100, 100, WEBGL); * noStroke(); + * describe( + * 'Sphere with specular highlight. Clicking the mouse toggles the specular highlight color between red and the default white.' + * ); * } * * function draw() { * background(0); - * shininess(20); - * ambientLight(50); - * specularColor(255, 0, 0); - * pointLight(255, 0, 0, 0, -50, 50); - * specularColor(0, 255, 0); - * pointLight(0, 255, 0, 0, 50, 50); - * specularMaterial(255); - * sphere(40); + * + * ambientLight(60); + * + * // add a point light to showcase specular color + * // -- use mouse location to position the light + * let lightPosX = mouseX - width / 2; + * let lightPosY = mouseY - height / 2; + * // -- set the light's specular color + * if (setRedSpecularColor) { + * specularColor(255, 0, 0); // red specular highlight + * } + * // -- create the light + * pointLight(200, 200, 200, lightPosX, lightPosY, 50); // white light + * + * // use specular material with high shininess + * specularMaterial(150); + * shininess(50); + * + * sphere(30, 64, 64); + * } + * + * function mouseClicked() { + * setRedSpecularColor = !setRedSpecularColor; * } * *
* * @alt - * different specular light sources from top and bottom of canvas + * Sphere with specular highlight. Clicking the mouse toggles the + * specular highlight color between red and the default white. */ /** * @method specularColor - * @param {String} value a color string + * @param {Number} gray number specifying value between + * white and black * @chainable */ /** * @method specularColor - * @param {Number} gray a gray value + * @param {String} value color as a CSS string * @chainable */ /** * @method specularColor - * @param {Number[]} values an array containing the red,green,blue & - * and alpha components of the color + * @param {Number[]} values color as an array containing the + * red, green, and blue components * @chainable */ /** * @method specularColor - * @param {p5.Color} color the ambient light color + * @param {p5.Color} color color as a p5.Color * @chainable */ p5.prototype.specularColor = function(v1, v2, v3) { @@ -175,21 +225,45 @@ p5.prototype.specularColor = function(v1, v2, v3) { }; /** - * Creates a directional light with a color and a direction + * Creates a directional light with the given color and direction. + * + * Directional light comes from one direction. + * The direction is specified as numbers inclusively between -1 and 1. + * For example, setting the direction as (0, -1, 0) will cause the + * geometry to be lit from below (since the light will be facing + * directly upwards). Similarly, setting the direction as (1, 0, 0) + * will cause the geometry to be lit from the left (since the light + * will be facing directly rightwards). + * + * Directional lights do not have a specific point of origin, and + * therefore cannot be positioned closer or farther away from a geometry. + * + * A maximum of **5** directional lights can be active at once. + * + * Note: lights need to be called (whether directly or indirectly) + * within draw() to remain persistent in a looping program. + * Placing them in setup() will cause them to only have an effect + * the first time through the loop. * - * A maximum of 5 directionalLight can be active at one time * @method directionalLight - * @param {Number} v1 red or hue value (depending on the current - * color mode), - * @param {Number} v2 green or saturation value - * @param {Number} v3 blue or brightness value - * @param {p5.Vector} position the direction of the light + * @param {Number} v1 red or hue value relative to the current + * color range + * @param {Number} v2 green or saturation value relative to the + * current color range + * @param {Number} v3 blue or brightness value relative to the + * current color range + * @param {Number} x x component of direction (inclusive range of -1 to 1) + * @param {Number} y y component of direction (inclusive range of -1 to 1) + * @param {Number} z z component of direction (inclusive range of -1 to 1) * @chainable * @example *
* * function setup() { * createCanvas(100, 100, WEBGL); + * describe( + * 'scene with sphere and directional light. The direction of the light is controlled with the mouse position.' + * ); * } * function draw() { * background(0); @@ -204,34 +278,34 @@ p5.prototype.specularColor = function(v1, v2, v3) { *
* * @alt - * light source on canvas changeable with mouse position + * scene with sphere and directional light. The direction of + * the light is controlled with the mouse position. */ /** * @method directionalLight - * @param {Number[]|String|p5.Color} color color Array, CSS color string, - * or p5.Color value - * @param {Number} x x axis direction - * @param {Number} y y axis direction - * @param {Number} z z axis direction + * @param {Number} v1 + * @param {Number} v2 + * @param {Number} v3 + * @param {p5.Vector} direction direction of light as a + * p5.Vector * @chainable */ /** * @method directionalLight - * @param {Number[]|String|p5.Color} color - * @param {p5.Vector} position + * @param {p5.Color|Number[]|String} color color as a p5.Color, + * as an array, or as a CSS string + * @param {Number} x + * @param {Number} y + * @param {Number} z * @chainable */ /** * @method directionalLight - * @param {Number} v1 - * @param {Number} v2 - * @param {Number} v3 - * @param {Number} x - * @param {Number} y - * @param {Number} z + * @param {p5.Color|Number[]|String} color + * @param {p5.Vector} direction * @chainable */ p5.prototype.directionalLight = function(v1, v2, v3, x, y, z) { @@ -278,36 +352,52 @@ p5.prototype.directionalLight = function(v1, v2, v3, x, y, z) { }; /** - * Creates a point light with a color and a light position + * Creates a point light with the given color and position. + * + * A point light emits light from a single point in all directions. + * Because the light is emitted from a specific point (position), + * it has a different effect when it is positioned farther vs. nearer + * an object. + * + * A maximum of **5** point lights can be active at once. + * + * Note: lights need to be called (whether directly or indirectly) + * within draw() to remain persistent in a looping program. + * Placing them in setup() will cause them to only have an effect + * the first time through the loop. * - * A maximum of 5 pointLight can be active at one time * @method pointLight - * @param {Number} v1 red or hue value (depending on the current - * color mode), - * @param {Number} v2 green or saturation value - * @param {Number} v3 blue or brightness value - * @param {Number} x x axis position - * @param {Number} y y axis position - * @param {Number} z z axis position + * @param {Number} v1 red or hue value relative to the current + * color range + * @param {Number} v2 green or saturation value relative to the + * current color range + * @param {Number} v3 blue or brightness value relative to the + * current color range + * @param {Number} x x component of position + * @param {Number} y y component of position + * @param {Number} z z component of position * @chainable * @example *
* * function setup() { * createCanvas(100, 100, WEBGL); + * describe( + * 'scene with sphere and point light. The position of the light is controlled with the mouse position.' + * ); * } * function draw() { * background(0); - * //move your mouse to change light position + * // move your mouse to change light position * let locX = mouseX - width / 2; * let locY = mouseY - height / 2; * // to set the light position, * // think of the world's coordinate as: - * // -width/2,-height/2 -------- width/2,-height/2 - * // | | - * // | 0,0 | - * // | | - * // -width/2,height/2--------width/2,height/2 + * // -width/2,-height/2 ----------- width/2,-height/2 + * // | | + * // | 0,0 | + * // | | + * // -width/2,height/2 ----------- width/2,height/2 * pointLight(250, 250, 250, locX, locY, 50); * noStroke(); * sphere(40); @@ -316,22 +406,23 @@ p5.prototype.directionalLight = function(v1, v2, v3, x, y, z) { *
* * @alt - * spot light on canvas changes position with mouse + * scene with sphere and point light. The position of + * the light is controlled with the mouse position. */ /** * @method pointLight - * @param {Number} v1 - * @param {Number} v2 - * @param {Number} v3 - * @param {p5.Vector} position the position of the light + * @param {Number} v1 + * @param {Number} v2 + * @param {Number} v3 + * @param {p5.Vector} position of light as a p5.Vector * @chainable */ /** * @method pointLight - * @param {Number[]|String|p5.Color} color color Array, CSS color string, - * or p5.Color value + * @param {p5.Color|Number[]|String} color color as a p5.Color, + * as an array, or as a CSS string * @param {Number} x * @param {Number} y * @param {Number} z @@ -340,7 +431,7 @@ p5.prototype.directionalLight = function(v1, v2, v3, x, y, z) { /** * @method pointLight - * @param {Number[]|String|p5.Color} color + * @param {p5.Color|Number[]|String} color * @param {p5.Vector} position * @chainable */ @@ -385,7 +476,15 @@ p5.prototype.pointLight = function(v1, v2, v3, x, y, z) { }; /** - * Sets the default ambient and directional light. The defaults are ambientLight(128, 128, 128) and directionalLight(128, 128, 128, 0, 0, -1). Lights need to be included in the draw() to remain persistent in a looping program. Placing them in the setup() of a looping program will cause them to only have an effect the first time through the loop. + * Places an ambient and directional light in the scene. + * The lights are set to ambientLight(128, 128, 128) and + * directionalLight(128, 128, 128, 0, 0, -1). + * + * Note: lights need to be called (whether directly or indirectly) + * within draw() to remain persistent in a looping program. + * Placing them in setup() will cause them to only have an effect + * the first time through the loop. + * * @method lights * @chainable * @example @@ -393,6 +492,7 @@ p5.prototype.pointLight = function(v1, v2, v3, x, y, z) { * * function setup() { * createCanvas(100, 100, WEBGL); + * describe('the light is partially ambient and partially directional'); * } * function draw() { * background(0); @@ -423,17 +523,22 @@ p5.prototype.lights = function() { }; /** - * Sets the falloff rates for point lights. It affects only the elements which are created after it in the code. - * The default value is lightFalloff(1.0, 0.0, 0.0), and the parameters are used to calculate the falloff with the following equation: + * Sets the falloff rate for pointLight() + * and spotLight(). + * + * lightFalloff() affects only the lights which are created after it + * in the code. + * + * The `constant`, `linear`, an `quadratic` parameters are used to calculate falloff as follows: * * d = distance from light position to vertex position * - * falloff = 1 / (CONSTANT + d \* LINEAR + ( d \* d ) \* QUADRATIC) + * falloff = 1 / (CONSTANT + d \* LINEAR + (d \* d) \* QUADRATIC) * * @method lightFalloff - * @param {Number} constant constant value for determining falloff - * @param {Number} linear linear value for determining falloff - * @param {Number} quadratic quadratic value for determining falloff + * @param {Number} constant CONSTANT value for determining falloff + * @param {Number} linear LINEAR value for determining falloff + * @param {Number} quadratic QUADRATIC value for determining falloff * @chainable * @example *
@@ -441,6 +546,9 @@ p5.prototype.lights = function() { * function setup() { * createCanvas(100, 100, WEBGL); * noStroke(); + * describe( + * 'Two spheres with different falloff values show different intensity of light' + * ); * } * function draw() { * ortho(); @@ -517,26 +625,43 @@ p5.prototype.lightFalloff = function( }; /** - * Creates a spotlight with a given color, position, direction of light, - * angle and concentration. Here, angle refers to the opening or aperture - * of the cone of the spotlight, and concentration is used to focus the - * light towards the center. Both angle and concentration are optional, but if - * you want to provide concentration, you will also have to specify the angle. + * Creates a spot light with the given color, position, + * light direction, angle, and concentration. + * + * Like a pointLight(), a spotLight() + * emits light from a specific point (position). It has a different effect + * when it is positioned farther vs. nearer an object. + * + * However, unlike a pointLight(), the light is emitted in **one direction** + * along a conical shape. The shape of the cone can be controlled using + * the `angle` and `concentration` parameters. + * + * The `angle` parameter is used to + * determine the radius of the cone. And the `concentration` + * parameter is used to focus the light towards the center of + * the cone. Both parameters are optional, however if you want + * to specify `concentration`, you must also specify `angle`. + * The minimum concentration value is 1. + * + * A maximum of **5** spot lights can be active at once. + * + * Note: lights need to be called (whether directly or indirectly) + * within draw() to remain persistent in a looping program. + * Placing them in setup() will cause them to only have an effect + * the first time through the loop. * - * A maximum of 5 spotLight can be active at one time * @method spotLight - * @param {Number} v1 red or hue value (depending on the current - * color mode), - * @param {Number} v2 green or saturation value - * @param {Number} v3 blue or brightness value - * @param {Number} x x axis position - * @param {Number} y y axis position - * @param {Number} z z axis position - * @param {Number} rx x axis direction of light - * @param {Number} ry y axis direction of light - * @param {Number} rz z axis direction of light - * @param {Number} [angle] optional parameter for angle. Defaults to PI/3 - * @param {Number} [conc] optional parameter for concentration. Defaults to 100 + * @param {Number} v1 red or hue value relative to the current color range + * @param {Number} v2 green or saturation value relative to the current color range + * @param {Number} v3 blue or brightness value relative to the current color range + * @param {Number} x x component of position + * @param {Number} y y component of position + * @param {Number} z z component of position + * @param {Number} rx x component of light direction (inclusive range of -1 to 1) + * @param {Number} ry y component of light direction (inclusive range of -1 to 1) + * @param {Number} rz z component of light direction (inclusive range of -1 to 1) + * @param {Number} [angle] angle of cone. Defaults to PI/3 + * @param {Number} [concentration] concentration of cone. Defaults to 100 * @chainable * * @example @@ -544,19 +669,22 @@ p5.prototype.lightFalloff = function( * * function setup() { * createCanvas(100, 100, WEBGL); + * describe( + * 'scene with sphere and spot light. The position of the light is controlled with the mouse position.' + * ); * } * function draw() { * background(0); - * //move your mouse to change light position + * // move your mouse to change light position * let locX = mouseX - width / 2; * let locY = mouseY - height / 2; * // to set the light position, * // think of the world's coordinate as: - * // -width/2,-height/2 -------- width/2,-height/2 - * // | | - * // | 0,0 | - * // | | - * // -width/2,height/2--------width/2,height/2 + * // -width/2,-height/2 ----------- width/2,-height/2 + * // | | + * // | 0,0 | + * // | | + * // -width/2,height/2 ----------- width/2,height/2 * ambientLight(50); * spotLight(0, 250, 0, locX, locY, 100, 0, 0, -1, Math.PI / 16); * noStroke(); @@ -566,16 +694,17 @@ p5.prototype.lightFalloff = function( *
* * @alt - * Spot light on a sphere which changes position with mouse + * scene with sphere and spot light. The position of + * the light is controlled with the mouse position. */ /** * @method spotLight - * @param {Number[]|String|p5.Color} color color Array, CSS color string, - * or p5.Color value - * @param {p5.Vector} position the position of the light - * @param {p5.Vector} direction the direction of the light + * @param {p5.Color|Number[]|String} color color as a p5.Color, + * as an array, or as a CSS string + * @param {p5.Vector} position position of light as a p5.Vector + * @param {p5.Vector} direction direction of light as a p5.Vector * @param {Number} [angle] - * @param {Number} [conc] + * @param {Number} [concentration] */ /** * @method spotLight @@ -585,27 +714,27 @@ p5.prototype.lightFalloff = function( * @param {p5.Vector} position * @param {p5.Vector} direction * @param {Number} [angle] - * @param {Number} [conc] + * @param {Number} [concentration] */ /** * @method spotLight - * @param {Number[]|String|p5.Color} color + * @param {p5.Color|Number[]|String} color * @param {Number} x * @param {Number} y * @param {Number} z * @param {p5.Vector} direction * @param {Number} [angle] - * @param {Number} [conc] + * @param {Number} [concentration] */ /** * @method spotLight - * @param {Number[]|String|p5.Color} color + * @param {p5.Color|Number[]|String} color * @param {p5.Vector} position * @param {Number} rx * @param {Number} ry * @param {Number} rz * @param {Number} [angle] - * @param {Number} [conc] + * @param {Number} [concentration] */ /** * @method spotLight @@ -617,7 +746,7 @@ p5.prototype.lightFalloff = function( * @param {Number} z * @param {p5.Vector} direction * @param {Number} [angle] - * @param {Number} [conc] + * @param {Number} [concentration] */ /** * @method spotLight @@ -629,11 +758,11 @@ p5.prototype.lightFalloff = function( * @param {Number} ry * @param {Number} rz * @param {Number} [angle] - * @param {Number} [conc] + * @param {Number} [concentration] */ /** * @method spotLight - * @param {Number[]|String|p5.Color} color + * @param {p5.Color|Number[]|String} color * @param {Number} x * @param {Number} y * @param {Number} z @@ -641,7 +770,7 @@ p5.prototype.lightFalloff = function( * @param {Number} ry * @param {Number} rz * @param {Number} [angle] - * @param {Number} [conc] + * @param {Number} [concentration] */ p5.prototype.spotLight = function( v1, @@ -857,10 +986,16 @@ p5.prototype.spotLight = function( }; /** - * This function will remove all the lights from the sketch for the - * subsequent materials rendered. It affects all the subsequent methods. - * Calls to lighting methods made after noLights() will re-enable lights - * in the sketch. + * Removes all lights present in a sketch. + * + * All subsequent geometry is rendered without lighting (until a new + * light is created with a call to one of the lighting functions + * (lights(), + * ambientLight(), + * directionalLight(), + * pointLight(), + * spotLight()). + * * @method noLights * @chainable * @example @@ -868,6 +1003,9 @@ p5.prototype.spotLight = function( * * function setup() { * createCanvas(100, 100, WEBGL); + * describe( + * 'Three white spheres. Each appears as a different color due to lighting.' + * ); * } * function draw() { * background(200); diff --git a/src/webgl/loading.js b/src/webgl/loading.js index 78e19145c2..039eba7fea 100755 --- a/src/webgl/loading.js +++ b/src/webgl/loading.js @@ -50,6 +50,7 @@ import './p5.Geometry'; * * function setup() { * createCanvas(100, 100, WEBGL); + * describe('Vertically rotating 3-d octahedron.'); * } * * function draw() { @@ -77,6 +78,7 @@ import './p5.Geometry'; * * function setup() { * createCanvas(100, 100, WEBGL); + * describe('Vertically rotating 3-d teapot with red, green and blue gradient.'); * } * * function draw() { @@ -602,6 +604,7 @@ function parseASCIISTL(model, lines) { * * function setup() { * createCanvas(100, 100, WEBGL); + * describe('Vertically rotating 3-d octahedron.'); * } * * function draw() { diff --git a/src/webgl/material.js b/src/webgl/material.js index 7590d0fe71..6694427a3b 100644 --- a/src/webgl/material.js +++ b/src/webgl/material.js @@ -45,6 +45,7 @@ import './p5.Texture'; * shader(mandel); * noStroke(); * mandel.setUniform('p', [-0.74364388703, 0.13182590421]); + * describe('zooming Mandelbrot set. a colorful, infinitely detailed fractal.'); * } * * function draw() { @@ -162,6 +163,7 @@ p5.prototype.loadShader = function( * * // 'p' is the center point of the Mandelbrot image * mandel.setUniform('p', [-0.74364388703, 0.13182590421]); + * describe('zooming Mandelbrot set. a colorful, infinitely detailed fractal.'); * } * * function draw() { @@ -233,6 +235,10 @@ p5.prototype.createShader = function(vertSrc, fragSrc) { * orangeBlue.setUniform('colorBackground', [0.226, 0.0, 0.615]); * * noStroke(); + * + * describe( + * 'canvas toggles between a circular gradient of orange and blue vertically. and a circular gradient of red and green moving horizontally when mouse is clicked/pressed.' + * ); * } * * function draw() { @@ -326,6 +332,10 @@ p5.prototype.shader = function(s) { * * // Create our shader * shaderProgram = createShader(vertSrc, fragSrc); + * + * describe( + * 'Two rotating cubes. The left one is painted using a custom (user-defined) shader, while the right one is painted using the default fill shader.' + * ); * } * * // prettier-ignore @@ -392,6 +402,7 @@ p5.prototype.resetShader = function() { * * function setup() { * createCanvas(100, 100, WEBGL); + * describe('spinning cube with a texture from an image'); * } * * function draw() { @@ -417,6 +428,7 @@ p5.prototype.resetShader = function() { * createCanvas(100, 100, WEBGL); * pg = createGraphics(200, 200); * pg.textSize(75); + * describe('plane with a texture from an image created by createGraphics()'); * } * * function draw() { @@ -444,6 +456,7 @@ p5.prototype.resetShader = function() { * } * function setup() { * createCanvas(100, 100, WEBGL); + * describe('rectangle with video as texture'); * } * * function draw() { @@ -473,6 +486,7 @@ p5.prototype.resetShader = function() { * * function setup() { * createCanvas(100, 100, WEBGL); + * describe('quad with a texture, mapped using normalized coordinates'); * } * * function draw() { @@ -529,6 +543,7 @@ p5.prototype.texture = function(tex) { * * function setup() { * createCanvas(100, 100, WEBGL); + * describe('quad with a texture, mapped using normalized coordinates'); * } * * function draw() { @@ -557,6 +572,7 @@ p5.prototype.texture = function(tex) { * * function setup() { * createCanvas(100, 100, WEBGL); + * describe('quad with a texture, mapped using image coordinates'); * } * * function draw() { @@ -615,6 +631,7 @@ p5.prototype.textureMode = function(mode) { * function setup() { * createCanvas(100, 100, WEBGL); * textureWrap(MIRROR); + * describe('an image of the rocky mountains repeated in mirrored tiles'); * } * * function draw() { @@ -657,11 +674,17 @@ p5.prototype.textureWrap = function(wrapX, wrapY = wrapX) { }; /** - * Normal material for geometry is a material that is not affected by light. - * It is not reflective and is a placeholder material often used for debugging. - * Surfaces facing the X-axis, become red, those facing the Y-axis, become green and those facing the Z-axis, become blue. - * You can view all possible materials in this + * Sets the current material as a normal material. + * + * A normal material is not affected by light. It is often used as + * a placeholder material when debugging. + * + * Surfaces facing the X-axis become red, those facing the Y-axis + * become green, and those facing the Z-axis become blue. + * + * You can view more materials in this * example. + * * @method normalMaterial * @chainable * @example @@ -669,6 +692,7 @@ p5.prototype.textureWrap = function(wrapX, wrapY = wrapX) { * * function setup() { * createCanvas(100, 100, WEBGL); + * describe('Sphere with normal material'); * } * * function draw() { @@ -679,7 +703,7 @@ p5.prototype.textureWrap = function(wrapX, wrapY = wrapX) { * *
* @alt - * Red, green and blue gradient. + * Sphere with normal material */ p5.prototype.normalMaterial = function(...args) { this._assert3d('normalMaterial'); @@ -695,68 +719,103 @@ p5.prototype.normalMaterial = function(...args) { }; /** - * Ambient material for geometry with a given color. Ambient material defines the color the object reflects under any lighting. - * For example, if the ambient material of an object is pure red, but the ambient lighting only contains green, the object will not reflect any light. - * Here's an example containing all possible materials. - * @method ambientMaterial - * @param {Number} v1 gray value, red or hue value - * (depending on the current color mode), - * @param {Number} [v2] green or saturation value - * @param {Number} [v3] blue or brightness value + * Sets the current material as an ambient material of the given color. + * + * The ambientMaterial() color is the color the object will reflect + * under **any** lighting. + * + * Consider an ambientMaterial() with the color yellow (255, 255, 0). + * If the light emits the color white (255, 255, 255), then the object + * will appear yellow as it will reflect the red and green components + * of the light. If the light emits the color red (255, 0, 0), then + * the object will appear red as it will reflect the red component + * of the light. If the light emits the color blue (0, 0, 255), + * then the object will appear black, as there is no component of + * the light that it can reflect. + * + * You can view more materials in this + * example. + * + * @method ambientMaterial + * @param {Number} v1 red or hue value relative to the current + * color range + * @param {Number} v2 green or saturation value relative to the + * current color range + * @param {Number} v3 blue or brightness value relative to the + * current color range * @chainable * @example *
* * function setup() { * createCanvas(100, 100, WEBGL); + * describe('sphere reflecting red, blue, and green light'); * } * function draw() { * background(0); * noStroke(); - * ambientLight(200); + * ambientLight(255); * ambientMaterial(70, 130, 230); * sphere(40); * } * *
+ * @alt + * sphere reflecting red, blue, and green light + * + * @example *
* * // ambientLight is both red and blue (magenta), * // so object only reflects it's red and blue components * function setup() { * createCanvas(100, 100, WEBGL); + * describe('box reflecting only red and blue light'); * } * function draw() { * background(70); - * ambientLight(100); // white light - * ambientMaterial(255, 0, 255); // pink material + * ambientLight(255, 0, 255); // magenta light + * ambientMaterial(255); // white material * box(30); * } * *
+ * @alt + * box reflecting only red and blue light + * + * @example *
* * // ambientLight is green. Since object does not contain * // green, it does not reflect any light * function setup() { * createCanvas(100, 100, WEBGL); + * describe('box reflecting no light'); * } * function draw() { * background(70); * ambientLight(0, 255, 0); // green light - * ambientMaterial(255, 0, 255); // pink material + * ambientMaterial(255, 0, 255); // magenta material * box(30); * } * *
* @alt - * radiating light source from top right of canvas - * box reflecting only red and blue light * box reflecting no light */ + +/** + * @method ambientMaterial + * @param {Number} gray number specifying value between + * white and black + * @chainable + */ + /** - * @method ambientMaterial - * @param {Number[]|String|p5.Color} color color, color Array, or CSS color string + * @method ambientMaterial + * @param {p5.Color|Number[]|String} color + * color as a p5.Color, + * as an array, or as a CSS string * @chainable */ p5.prototype.ambientMaterial = function(v1, v2, v3) { @@ -775,23 +834,35 @@ p5.prototype.ambientMaterial = function(v1, v2, v3) { }; /** - * Sets the emissive color of the material used for geometry drawn to - * the screen. This is a misnomer in the sense that the material does not - * actually emit light that effects surrounding polygons. Instead, - * it gives the appearance that the object is glowing. An emissive material - * will display at full strength even if there is no light for it to reflect. + * Sets the current material as an emissive material of + * the given color. + * + * An emissive material will display the emissive color at + * full strength regardless of lighting. This can give the + * appearance that the object is glowing. + * + * Note, "emissive" is a misnomer in the sense that the material + * does not actually emit light that will affect surrounding objects. + * + * You can view more materials in this + * example. + * * @method emissiveMaterial - * @param {Number} v1 gray value, red or hue value - * (depending on the current color mode), - * @param {Number} [v2] green or saturation value - * @param {Number} [v3] blue or brightness value - * @param {Number} [a] opacity + * @param {Number} v1 red or hue value relative to the current + * color range + * @param {Number} v2 green or saturation value relative to the + * current color range + * @param {Number} v3 blue or brightness value relative to the + * current color range + * @param {Number} [alpha] alpha value relative to current color + * range (default is 0-255) * @chainable * @example *
* * function setup() { * createCanvas(100, 100, WEBGL); + * describe('sphere with green emissive material'); * } * function draw() { * background(0); @@ -804,11 +875,21 @@ p5.prototype.ambientMaterial = function(v1, v2, v3) { *
* * @alt - * radiating light source from top right of canvas + * sphere with green emissive material */ + /** - * @method emissiveMaterial - * @param {Number[]|String|p5.Color} color color, color Array, or CSS color string + * @method emissiveMaterial + * @param {Number} gray number specifying value between + * white and black + * @chainable + */ + +/** + * @method emissiveMaterial + * @param {p5.Color|Number[]|String} color + * color as a p5.Color, + * as an array, or as a CSS string * @chainable */ p5.prototype.emissiveMaterial = function(v1, v2, v3, a) { @@ -827,11 +908,23 @@ p5.prototype.emissiveMaterial = function(v1, v2, v3, a) { }; /** - * Specular material for geometry with a given color. Specular material is a shiny reflective material. - * Like ambient material it also defines the color the object reflects under ambient lighting. - * For example, if the specular material of an object is pure red, but the ambient lighting only contains green, the object will not reflect any light. - * For all other types of light like point and directional light, a specular material will reflect the color of the light source to the viewer. - * Here's an example containing all possible materials. + * Sets the current material as a specular material of the given color. + * + * A specular material is reflective (shiny). The shininess can be + * controlled by the shininess() function. + * + * Like ambientMaterial(), + * the specularMaterial() color is the color the object will reflect + * under ambientLight(). + * However unlike ambientMaterial(), for all other types of lights + * (directionalLight(), + * pointLight(), + * spotLight()), + * a specular material will reflect the **color of the light source**. + * This is what gives it its "shiny" appearance. + * + * You can view more materials in this + * example. * * @method specularMaterial * @param {Number} gray number specifying value between white and black. @@ -845,6 +938,7 @@ p5.prototype.emissiveMaterial = function(v1, v2, v3, a) { * function setup() { * createCanvas(100, 100, WEBGL); * noStroke(); + * describe('torus with specular material'); * } * * function draw() { @@ -881,7 +975,9 @@ p5.prototype.emissiveMaterial = function(v1, v2, v3, a) { /** * @method specularMaterial - * @param {Number[]|String|p5.Color} color color Array, or CSS color string + * @param {p5.Color|Number[]|String} color + * color as a p5.Color, + * as an array, or as a CSS string * @chainable */ p5.prototype.specularMaterial = function(v1, v2, v3, alpha) { @@ -900,18 +996,20 @@ p5.prototype.specularMaterial = function(v1, v2, v3, alpha) { }; /** - * Sets the amount of gloss in the surface of shapes. - * Used in combination with specularMaterial() in setting - * the material properties of shapes. The default and minimum value is 1. + * Sets the amount of gloss ("shininess") of a + * specularMaterial(). + * + * The default and minimum value is 1. + * * @method shininess - * @param {Number} shine Degree of Shininess. - * Defaults to 1. + * @param {Number} shine degree of shininess * @chainable * @example *
* * function setup() { * createCanvas(100, 100, WEBGL); + * describe('two spheres, one more shiny than the other'); * } * function draw() { * background(0); @@ -931,7 +1029,7 @@ p5.prototype.specularMaterial = function(v1, v2, v3, alpha) { * *
* @alt - * Shininess on Camera changes position with mouse + * two spheres, one more shiny than the other */ p5.prototype.shininess = function(shine) { this._assert3d('shininess'); diff --git a/src/webgl/p5.Camera.js b/src/webgl/p5.Camera.js index f09dee3923..637ada8e69 100644 --- a/src/webgl/p5.Camera.js +++ b/src/webgl/p5.Camera.js @@ -45,6 +45,7 @@ import p5 from '../core/main'; * * function setup() { * createCanvas(100, 100, WEBGL); + * describe('a square moving closer and then away from the camera.'); * } * function draw() { * background(204); @@ -82,6 +83,9 @@ import p5 from '../core/main'; * sliderGroup[i].position(10, height + h); * sliderGroup[i].style('width', '80px'); * } + * describe( + * 'White square repeatedly grows to fill canvas and then shrinks. An interactive example of a red cube with 3 sliders for moving it across x, y, z axis and 3 sliders for shifting its center.' + * ); * } * * function draw() { @@ -141,6 +145,9 @@ p5.prototype.camera = function(...args) { * function setup() { * createCanvas(100, 100, WEBGL); * perspective(PI / 3.0, width / height, 0.1, 500); + * describe( + * 'two colored 3D boxes move back and forth, rotating as mouse is dragged.' + * ); * } * function draw() { * background(200); @@ -203,6 +210,9 @@ p5.prototype.perspective = function(...args) { * function setup() { * createCanvas(100, 100, WEBGL); * ortho(-width / 2, width / 2, height / 2, -height / 2, 0, 500); + * describe( + * 'two 3D boxes move back and forth along same plane, rotating as mouse is dragged.' + * ); * } * function draw() { * background(200); @@ -266,6 +276,9 @@ p5.prototype.ortho = function(...args) { * createCanvas(100, 100, WEBGL); * setAttributes('antialias', true); * frustum(-0.1, 0.1, -0.1, 0.1, 0.1, 200); + * describe( + * 'two 3D boxes move back and forth along same plane, rotating as mouse is dragged.' + * ); * } * function draw() { * background(200); @@ -328,6 +341,7 @@ p5.prototype.frustum = function(...args) { * createCanvas(100, 100, WEBGL); * background(0); * camera = createCamera(); + * describe('An example that creates a camera and moves it around the box.'); * } * * function draw() { @@ -398,6 +412,9 @@ p5.prototype.createCamera = function() { * cam = createCamera(); * // set initial pan angle * cam.pan(-0.8); + * describe( + * 'camera view pans left and right across a series of rotating 3D boxes.' + * ); * } * * function draw() { @@ -455,6 +472,7 @@ p5.Camera = function(renderer) { * cam = createCamera(); * div = createDiv(); * div.position(0, 0); + * describe('An example showing the use of camera object properties'); * } * * function draw() { @@ -482,6 +500,7 @@ p5.Camera = function(renderer) { * cam = createCamera(); * div = createDiv(); * div.position(0, 0); + * describe('An example showing the use of camera object properties'); * } * * function draw() { @@ -509,6 +528,7 @@ p5.Camera = function(renderer) { * cam = createCamera(); * div = createDiv(); * div.position(0, 0); + * describe('An example showing the use of camera object properties'); * } * * function draw() { @@ -538,6 +558,7 @@ p5.Camera = function(renderer) { * div = createDiv('centerX = ' + cam.centerX); * div.position(0, 0); * div.style('color', 'white'); + * describe('An example showing the use of camera object properties'); * } * * function draw() { @@ -566,6 +587,7 @@ p5.Camera = function(renderer) { * div = createDiv('centerY = ' + cam.centerY); * div.position(0, 0); * div.style('color', 'white'); + * describe('An example showing the use of camera object properties'); * } * * function draw() { @@ -594,6 +616,7 @@ p5.Camera = function(renderer) { * div = createDiv('centerZ = ' + cam.centerZ); * div.position(0, 0); * div.style('color', 'white'); + * describe('An example showing the use of camera object properties'); * } * * function draw() { @@ -622,6 +645,7 @@ p5.Camera = function(renderer) { * div.position(0, 0); * div.style('color', 'blue'); * div.style('font-size', '18px'); + * describe('An example showing the use of camera object properties'); * } *
* @@ -645,6 +669,7 @@ p5.Camera = function(renderer) { * div.position(0, 0); * div.style('color', 'blue'); * div.style('font-size', '18px'); + * describe('An example showing the use of camera object properties'); * } *
* @@ -668,6 +693,7 @@ p5.Camera = function(renderer) { * div.position(0, 0); * div.style('color', 'blue'); * div.style('font-size', '18px'); + * describe('An example showing the use of camera object properties'); * } *
* @@ -1744,6 +1770,10 @@ p5.Camera.prototype._isActive = function() { * * // set variable for previously active camera: * currentCamera = 1; + * + * describe( + * 'Canvas switches between two camera views, each showing a series of spinning 3D boxes.' + * ); * } * * function draw() { diff --git a/src/webgl/p5.RendererGL.Immediate.js b/src/webgl/p5.RendererGL.Immediate.js index 410237643b..3c23b0c56e 100644 --- a/src/webgl/p5.RendererGL.Immediate.js +++ b/src/webgl/p5.RendererGL.Immediate.js @@ -49,7 +49,7 @@ p5.RendererGL.prototype.beginShape = function(mode) { p5.RendererGL.prototype.vertex = function(x, y) { let z, u, v; - // default to (x, y) mode: all other arugments assumed to be 0. + // default to (x, y) mode: all other arguments assumed to be 0. z = u = v = 0; if (arguments.length === 3) { diff --git a/src/webgl/p5.Shader.js b/src/webgl/p5.Shader.js index 740e95978e..5435814f2d 100644 --- a/src/webgl/p5.Shader.js +++ b/src/webgl/p5.Shader.js @@ -341,6 +341,10 @@ p5.Shader.prototype.useProgram = function() { * createCanvas(100, 100, WEBGL); * shader(grad); * noStroke(); + * + * describe( + * 'canvas toggles between a circular gradient of orange and blue vertically. and a circular gradient of red and green moving horizontally when mouse is clicked/pressed.' + * ); * } * * function draw() { diff --git a/test/js/sinon.js b/test/js/sinon.js index c84a8597c4..f0a9e842e8 100644 --- a/test/js/sinon.js +++ b/test/js/sinon.js @@ -5,13 +5,13 @@ * @author Contributors: https://github.com/cjohansen/Sinon.JS/blob/master/AUTHORS * * (The BSD License) - * + * * Copyright (c) 2010-2014, Christian Johansen, christian@cjohansen.no * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: - * + * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, @@ -20,7 +20,7 @@ * * Neither the name of Christian Johansen nor the names of his contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -463,7 +463,7 @@ module.exports = m(require("samsam")); }) || function (m) { this.formatio = m(this.samsam); } )(function (samsam) { - + var formatio = { excludeConstructors: ["Object", /^.$/], quoteStrings: true, @@ -566,7 +566,7 @@ processed.push(array); var pieces = []; var i, l; - l = (this.limitChildrenCount > 0) ? + l = (this.limitChildrenCount > 0) ? Math.min(this.limitChildrenCount, array.length) : array.length; for (i = 0; i < l; ++i) { @@ -586,7 +586,7 @@ var pieces = [], properties = samsam.keys(object).sort(); var length = 3; var prop, str, obj, i, k, l; - l = (this.limitChildrenCount > 0) ? + l = (this.limitChildrenCount > 0) ? Math.min(this.limitChildrenCount, properties.length) : properties.length; for (i = 0; i < l; ++i) { @@ -636,7 +636,7 @@ var content = element.innerHTML; if (content.length > 20) { - content = content.substr(0, 20) + "[...]"; + content = content.slice(0, 20) + "[...]"; } var res = formatted + pairs.join(" ") + ">" + content + diff --git a/test/unit/color/p5.Color.js b/test/unit/color/p5.Color.js index a4b274c4fc..43ffaa4f02 100644 --- a/test/unit/color/p5.Color.js +++ b/test/unit/color/p5.Color.js @@ -986,7 +986,7 @@ suite('p5.Color', function() { test('should generate (r,g,b,a) color string with 0-1 normalized alpha', function() { // Will not exactly equal 0.5 due to math: test "0.5" substr of // 'rgba(128,0,128,0.5...' instead of checking the entire string - assert.equal(colorStr.substr(15, 3), '0.5'); + assert.equal(colorStr.slice(15, 18), '0.5'); }); test('should consistently generate the same output', function() { diff --git a/test/unit/color/setting.js b/test/unit/color/setting.js index d092831ac2..d72ce2bd74 100644 --- a/test/unit/color/setting.js +++ b/test/unit/color/setting.js @@ -214,4 +214,76 @@ suite('color/Setting', function() { assert.deepEqual(myp5._colorMaxes[myp5.HSB], [360, 100, 100, 1]); }); }); + + suite('p5.Color components', function() { + test('setRed() correctly sets red component', function() { + myp5.colorMode(myp5.RGB, 255); + const c = myp5.color(0, 162, 205, 255); + c.setRed(100); + assert.equal(myp5.red(c), 100); + assert.equal(myp5.green(c), 162); + assert.equal(myp5.blue(c), 205); + assert.equal(myp5.alpha(c), 255); + }); + + test('setGreen() correctly sets green component', function() { + myp5.colorMode(myp5.RGB, 255); + const c = myp5.color(0, 162, 205, 255); + c.setGreen(100); + assert.equal(myp5.red(c), 0); + assert.equal(myp5.green(c), 100); + assert.equal(myp5.blue(c), 205); + assert.equal(myp5.alpha(c), 255); + }); + + test('setBlue() correctly sets blue component', function() { + myp5.colorMode(myp5.RGB, 255); + const c = myp5.color(0, 162, 205, 255); + c.setBlue(100); + assert.equal(myp5.red(c), 0); + assert.equal(myp5.green(c), 162); + assert.equal(myp5.blue(c), 100); + assert.equal(myp5.alpha(c), 255); + }); + + test('setAlpha correctly sets alpha component', function() { + myp5.colorMode(myp5.RGB, 255); + const c = myp5.color(0, 162, 205, 255); + c.setAlpha(100); + assert.equal(myp5.red(c), 0); + assert.equal(myp5.green(c), 162); + assert.equal(myp5.blue(c), 205); + assert.equal(myp5.alpha(c), 100); + }); + + test('changing the red/green/blue/alpha components should clear the cached HSL/HSB values', function() { + myp5.colorMode(myp5.RGB, 255); + const c = myp5.color(0, 162, 205, 255); + + // create HSL/HSB values + myp5.lightness(c); + myp5.brightness(c); + c.setRed(100); + assert(!c.hsba); + assert(!c.hsla); + + myp5.lightness(c); + myp5.brightness(c); + c.setGreen(100); + assert(!c.hsba); + assert(!c.hsla); + + myp5.lightness(c); + myp5.brightness(c); + c.setBlue(100); + assert(!c.hsba); + assert(!c.hsla); + + myp5.lightness(c); + myp5.brightness(c); + c.setAlpha(100); + assert(!c.hsba); + assert(!c.hsla); + }); + }); }); diff --git a/test/unit/math/trigonometry.js b/test/unit/math/trigonometry.js index 437945f471..3445baa4c3 100644 --- a/test/unit/math/trigonometry.js +++ b/test/unit/math/trigonometry.js @@ -48,17 +48,33 @@ suite('Trigonometry', function() { suite('p5.prototype.angleMode', function() { test('should set constant to DEGREES', function() { myp5.angleMode(DEGREES); - assert.equal(myp5._angleMode, 'degrees'); + assert.equal(myp5.angleMode(), 'degrees'); }); test('should set constant to RADIANS', function() { myp5.angleMode(RADIANS); - assert.equal(myp5._angleMode, 'radians'); + assert.equal(myp5.angleMode(), 'radians'); + }); + + test('wrong param type', function() { + assert.validationError(function() { + myp5.angleMode('wtflolzkk'); + }); + }); + + test('should return radians', function() { + myp5.angleMode(RADIANS); + assert.equal(myp5.angleMode(), 'radians'); + }); + + test('should return degrees', function() { + myp5.angleMode(DEGREES); + assert.equal(myp5.angleMode(), 'degrees'); }); test('should always be RADIANS or DEGREES', function() { myp5.angleMode('wtflolzkk'); - assert.equal(myp5._angleMode, 'radians'); + assert.equal(myp5.angleMode(), 'radians'); }); }); diff --git a/translations/ko/README.md b/translations/ko/README.md index 4603f10aa9..c15844116f 100644 --- a/translations/ko/README.md +++ b/translations/ko/README.md @@ -1,15 +1,26 @@ # Welcome to the FES Korean branch! 안녕하세요, FES 한국어 브랜치에 어서오세요! -## 한국어 Translation Credits +## 한국어 공동 번역 기여자 Korean Translation Credits 2021년 가을부터 공동작업으로 진행되어 2022년 1월에 마무리된 FES 에러메시지 공동 번역 작업은 아래 분들이 함께하셨습니다. * [염인화](https://yinhwa.art/) (Inhwa Yeom): artist/XR researcher based in South Korea. (Take a look at her works on [p5 for 50+](https://p5for50.plus/) ([Processing Foundation Fellows 2020](https://medium.com/processing-foundation/p5-js-for-ages-50-in-korea-50d47b5927fb)) and p5js website Korean translation) * 전유진 (Youjin Jeon): artist/organizer based in Seoul, South Korea. [여성을 위한 열린 기술랩(Woman Open Tech Lab.kr)](http://womanopentechlab.kr/) and [Seoul Express](http://seoulexpress.kr/) * [정앎](https://www.almichu.com/) (Alm Chung, organizer): Korean-American artist/researcher based in Seattle, WA. * 이지현 (Jihyun Lee): Korean publishing editor based in South Korea -## 한국어 Translation Resources -* 추후 추가될 예정입니다! +## 영한 번역 리소스 (Korean-English Translation Resources) +* 영한 [번역에 도움이 되는 툴과 유의점들]입니다. +* 또한 영한 [번역 작업 중 마주치는 딜레마들] 속에서 저희가 채택한 방식을 모아 적어봤습니다. +* 외래 [기술 용어 다루기]에 대한 논의입니다. +* p5js 웹사이트와 기술 문서에서 사용하는 기술 용어들을 통일하기위해 사용하고 있 [p5js.org/ko 기술 용어 색인] 입니다. +* 현존하는 검색툴/번역 툴들과 연계 가능한 "[사이를 맴도는]" 번역문에 대해 생각해보는 글입니다. +이 외에도 FES의 세계화 작업 과정, 그리고 과정 중 논의된 이슈들을 [Friendly Errors i18n Book ✎ 친절한 오류 메시지 세계화 가이드북]에서 읽어보실 수 있습니다. "친절한 오류 메시지 세계화 가이드북"은 오픈 소스 프로젝트이며, 이 [독립된 레파지토리 (repository)]를 통해 기여 가능합니다. -질문이나 건의 사항은 @almchung 에게 문의주시길 바랍니다. \ No newline at end of file + +[번역에 도움이 되는 툴과 유의점들]: https://almchung.github.io/p5-fes-i18n-book/ch4/#tools +[번역 작업 중 마주치는 딜레마들]: https://almchung.github.io/p5-fes-i18n-book/ch4/#dilemmas +[기술 용어 다루기]: https://almchung.github.io/p5-fes-i18n-book/ch3/ +[사이를 맴도는]: https://almchung.github.io/p5-fes-i18n-book/ch5/ +[Friendly Errors i18n Book ✎ 친절한 오류 메시지 세계화 가이드북]: https://almchung.github.io/p5-fes-i18n-book/ +[독립된 레파지토리 (repository)]: https://github.com/almchung/p5-fes-i18n-book \ No newline at end of file