From 1bbe58123689396b9a078b31d9270a4768a2accd Mon Sep 17 00:00:00 2001 From: Aashish Panthi Date: Tue, 2 Jun 2026 00:02:21 +0545 Subject: [PATCH 01/16] add details feature which shows the new addition in English language in a nice expandable way --- .github/actions/translation-tracker/index.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/actions/translation-tracker/index.js b/.github/actions/translation-tracker/index.js index 7d9f3ff715..6feb0ccd4b 100644 --- a/.github/actions/translation-tracker/index.js +++ b/.github/actions/translation-tracker/index.js @@ -269,7 +269,7 @@ class GitHubCommitTracker { let isTruncated = false; if (patch) { const lines = patch.split('\n'); - const maxLines = 80; + const maxLines = 50; if (lines.length > maxLines) { patchSnippet = lines.slice(0, maxLines).join('\n'); isTruncated = true; @@ -407,6 +407,24 @@ class GitHubCommitTracker { }); } + // English diff (optional best-effort) + if (englishDiff && (englishDiff.compareUrl || englishDiff.patchSnippet)) { + body += `### 🧩 Recent English Diff\n\n`; + if (englishDiff.compareUrl) { + body += `- [🔍 View full compare](${englishDiff.compareUrl})\n\n`; + } + if (englishDiff.patchSnippet) { + body += `
\nShow patch snippet\n\n`; + body += `\`\`\`diff\n${englishDiff.patchSnippet}\n\`\`\`\n\n`; + if (englishDiff.isTruncated) { + body += `_(Patch snippet truncated. Use the compare link above for the full diff.)_\n\n`; + } + body += `
\n\n`; + } else { + body += `_(No preview of the differences is available for this change. Use the compare link above.)_\n\n`; + } + } + body += `### 🔗 Quick Links - [📄 Current English file](https://github.com/${this.owner}/${this.repo}/blob/${this.currentBranch}/${englishFile}) From 9cb73c3a7812ddf59b50fd8d91320619c2979c57 Mon Sep 17 00:00:00 2001 From: Aashish Panthi Date: Tue, 2 Jun 2026 00:05:18 +0545 Subject: [PATCH 02/16] Add comments and text readability --- .github/actions/translation-tracker/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/translation-tracker/index.js b/.github/actions/translation-tracker/index.js index 6feb0ccd4b..83a7e66025 100644 --- a/.github/actions/translation-tracker/index.js +++ b/.github/actions/translation-tracker/index.js @@ -407,7 +407,7 @@ class GitHubCommitTracker { }); } - // English diff (optional best-effort) + // English diff. It shows the actual content changes in the English file. if (englishDiff && (englishDiff.compareUrl || englishDiff.patchSnippet)) { body += `### 🧩 Recent English Diff\n\n`; if (englishDiff.compareUrl) { @@ -421,7 +421,7 @@ class GitHubCommitTracker { } body += `\n\n`; } else { - body += `_(No preview of the differences is available for this change. Use the compare link above.)_\n\n`; + body += `_(Could't generate preview of the differences for this change. Use the compare link above to see the full diff.)_\n\n`; } } From 70a2cd1227bee9687740fc25fd9eb92c605a7d1e Mon Sep 17 00:00:00 2001 From: Aashish Panthi Date: Thu, 4 Jun 2026 13:15:21 +0545 Subject: [PATCH 03/16] fixed the small typo --- .github/actions/translation-tracker/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/translation-tracker/index.js b/.github/actions/translation-tracker/index.js index 83a7e66025..9ca677c58f 100644 --- a/.github/actions/translation-tracker/index.js +++ b/.github/actions/translation-tracker/index.js @@ -421,7 +421,7 @@ class GitHubCommitTracker { } body += `\n\n`; } else { - body += `_(Could't generate preview of the differences for this change. Use the compare link above to see the full diff.)_\n\n`; + body += `_(Couldn't generate preview of the differences for this change. Use the compare link above to see the full diff.)_\n\n`; } } From 2557caef903ac282d2bdadeff8f38629b9dddac2 Mon Sep 17 00:00:00 2001 From: Aashish Panthi Date: Thu, 25 Jun 2026 19:33:09 +0545 Subject: [PATCH 04/16] remove unnecessary code snippet --- .github/actions/translation-tracker/index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/actions/translation-tracker/index.js b/.github/actions/translation-tracker/index.js index 9ca677c58f..3c6e4f2698 100644 --- a/.github/actions/translation-tracker/index.js +++ b/.github/actions/translation-tracker/index.js @@ -410,9 +410,8 @@ class GitHubCommitTracker { // English diff. It shows the actual content changes in the English file. if (englishDiff && (englishDiff.compareUrl || englishDiff.patchSnippet)) { body += `### 🧩 Recent English Diff\n\n`; - if (englishDiff.compareUrl) { - body += `- [🔍 View full compare](${englishDiff.compareUrl})\n\n`; - } + body += `- [🔍 View full compare](${englishDiff.compareUrl})\n\n`; // provides url to compare the differences + if (englishDiff.patchSnippet) { body += `
\nShow patch snippet\n\n`; body += `\`\`\`diff\n${englishDiff.patchSnippet}\n\`\`\`\n\n`; From 659d2751f6ee87567803ac99095564de25d766f1 Mon Sep 17 00:00:00 2001 From: Aashish Panthi Date: Thu, 25 Jun 2026 21:15:34 +0545 Subject: [PATCH 05/16] implement the stub file generation logic --- .github/actions/translation-tracker/index.js | 369 +++++++++++++++++- .../actions/translation-tracker/package.json | 3 +- .../actions/translation-tracker/test-stubs.js | 19 + .github/workflows/translation-stubs.yml | 52 +++ 4 files changed, 437 insertions(+), 6 deletions(-) create mode 100644 .github/actions/translation-tracker/test-stubs.js create mode 100644 .github/workflows/translation-stubs.yml diff --git a/.github/actions/translation-tracker/index.js b/.github/actions/translation-tracker/index.js index 3c6e4f2698..812c4c9ba3 100644 --- a/.github/actions/translation-tracker/index.js +++ b/.github/actions/translation-tracker/index.js @@ -44,6 +44,129 @@ function getSlugFromEnglishPath(englishFilePath, contentType) { return relative; } +function parseEnvList(envValue, defaultList) { + if (!envValue || envValue.trim() === '') { + return defaultList; + } + return envValue.split(',').map((item) => item.trim()).filter(Boolean); +} + +/** + * Find English content files that have no translation file yet. + * Used for stub-file generation (Week 2). + */ +function findMissingTranslations(contentTypes, languages, options = {}) { + const { fullScan = false, testFiles = null } = options; + const missing = []; + + for (const contentType of contentTypes) { + let englishFiles; + if (testFiles) { + englishFiles = testFiles.filter( + (file) => + file.startsWith(`src/content/${contentType}/en/`) && + (file.endsWith('.mdx') || file.endsWith('.yaml')) + ); + } else if (fullScan) { + englishFiles = getAllEnglishContentFiles(contentType); + } else if (process.env.GITHUB_ACTIONS) { + englishFiles = getChangedFiles(null, contentType); + } else { + englishFiles = getAllEnglishContentFiles(contentType); + } + + for (const englishFile of englishFiles) { + for (const language of languages) { + const translationPath = getTranslationPath(englishFile, language); + if (!fileExists(translationPath)) { + missing.push({ englishFile, language, translationPath, contentType }); + } + } + } + } + + missing.sort((a, b) => a.translationPath.localeCompare(b.translationPath)); + return missing; +} + +/** Frontmatter fields copied into stubs (English values). Avoids duplicating params/examples. */ +const STUB_FRONTMATTER_KEYS = { + reference: ['title', 'module', 'submodule', 'file', 'description'], + examples: ['title', 'oneLineDescription', 'featuredImage', 'featuredImageAlt'], + tutorials: ['title', 'description'], + 'text-detail': ['title', 'description'], + events: ['title', 'description'], + libraries: ['title', 'description'], +}; + +function pickStubFrontmatter(frontmatter, contentType) { + const keys = STUB_FRONTMATTER_KEYS[contentType] || ['title', 'description']; + const picked = { needsTranslation: true }; + for (const key of keys) { + if (frontmatter[key] !== undefined) { + picked[key] = frontmatter[key]; + } + } + return picked; +} + +function parseFrontmatter(raw, filePath) { + const frontmatterMatch = raw.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/); + if (!frontmatterMatch) { + throw new Error(`Could not find frontmatter in ${filePath}`); + } + + return yaml.load(frontmatterMatch[1]) || {}; +} + +function stringifyMdx(frontmatter, body) { + const frontmatterText = yaml.dump(frontmatter, { + lineWidth: 100, + noRefs: true, + sortKeys: false, + }); + + return `---\n${frontmatterText}---\n${body}`; +} + +/** + * Build a placeholder translation file from an English source. + * Copies essential frontmatter (in English), sets needsTranslation: true, minimal body. + */ +function generateStubFromEnglish(englishPath, language, contentType = 'reference') { + const raw = fs.readFileSync(englishPath, 'utf8'); + const frontmatter = parseFrontmatter(raw, englishPath); + const translationPath = getTranslationPath(englishPath, language); + + const stubFrontmatter = pickStubFrontmatter(frontmatter, contentType); + + const stubComment = ``; + + const stubBody = `${stubComment} + + +`; + + const content = stringifyMdx(stubFrontmatter, stubBody); + + return { translationPath, content, englishPath }; +} + +/** Where dry-run stubs are written locally (never touches src/content by default). */ +function getStubWritePath(translationPath, dryRun) { + if (!dryRun) { + return translationPath; + } + const outputRoot = + process.env.STUB_OUTPUT_DIR || + path.join(process.cwd(), '.github/actions/translation-tracker/stub-preview'); + return path.join(outputRoot, translationPath); +} + async function loadStewardsConfig() { const STEWARDS_URL = 'https://raw.githubusercontent.com/processing/p5.js/main/stewards.yml'; @@ -410,8 +533,9 @@ class GitHubCommitTracker { // English diff. It shows the actual content changes in the English file. if (englishDiff && (englishDiff.compareUrl || englishDiff.patchSnippet)) { body += `### 🧩 Recent English Diff\n\n`; - body += `- [🔍 View full compare](${englishDiff.compareUrl})\n\n`; // provides url to compare the differences - + if (englishDiff.compareUrl) { + body += `- [🔍 View full compare](${englishDiff.compareUrl})\n\n`; + } if (englishDiff.patchSnippet) { body += `
\nShow patch snippet\n\n`; body += `\`\`\`diff\n${englishDiff.patchSnippet}\n\`\`\`\n\n`; @@ -461,6 +585,121 @@ ${outdatedLanguages.length > 0 || missingLanguages.length > 0 ? `**Change Type** }; return languages[langCode] || langCode; } + + /** + * Create a branch with one commit containing multiple new files (for stub PRs). + */ + async createBranchWithFiles(branchName, commitMessage, fileChanges) { + const baseBranch = this.currentBranch || 'main'; + + const { data: ref } = await this.octokit.rest.git.getRef({ + owner: this.owner, + repo: this.repo, + ref: `heads/${baseBranch}`, + }); + const baseSha = ref.object.sha; + + const { data: baseCommit } = await this.octokit.rest.git.getCommit({ + owner: this.owner, + repo: this.repo, + commit_sha: baseSha, + }); + + const treeItems = await Promise.all( + fileChanges.map(async ({ path: filePath, content }) => { + const { data: blob } = await this.octokit.rest.git.createBlob({ + owner: this.owner, + repo: this.repo, + content: Buffer.from(content, 'utf8').toString('base64'), + encoding: 'base64', + }); + return { path: filePath, mode: '100644', type: 'blob', sha: blob.sha }; + }) + ); + + const { data: tree } = await this.octokit.rest.git.createTree({ + owner: this.owner, + repo: this.repo, + base_tree: baseCommit.tree.sha, + tree: treeItems, + }); + + const { data: commit } = await this.octokit.rest.git.createCommit({ + owner: this.owner, + repo: this.repo, + message: commitMessage, + tree: tree.sha, + parents: [baseSha], + }); + + await this.octokit.rest.git.createRef({ + owner: this.owner, + repo: this.repo, + ref: `refs/heads/${branchName}`, + sha: commit.sha, + }); + + return { branchName, commitSha: commit.sha }; + } + + /** + * Open one PR per language with all stub files for that language. + */ + async createStubPullRequest(language, stubs) { + const dateStr = new Date().toISOString().slice(0, 10).replace(/-/g, ''); + const branchName = `translation-stubs/${language}-${dateStr}-${Date.now()}`; + const langName = this.getLanguageDisplayName(language); + const commitMessage = `chore(i18n): add ${language} translation stubs for ${stubs.length} page(s)`; + + const fileChanges = stubs.map((stub) => ({ + path: stub.translationPath, + content: stub.content, + })); + + try { + await this.createBranchWithFiles(branchName, commitMessage, fileChanges); + + const stewards = getStewardsForLanguage(this.stewardsConfig, language); + const stewardsText = stewards.length > 0 ? `\n\ncc ${stewards.join(' ')}` : ''; + const fileList = stubs.map((stub) => `- \`${stub.translationPath}\` (from \`${stub.englishPath}\`)`).join('\n'); + + const { data: pr } = await this.octokit.rest.pulls.create({ + owner: this.owner, + repo: this.repo, + title: `chore(i18n): add ${langName} translation stubs (${stubs.length})`, + head: branchName, + base: this.currentBranch || 'main', + body: `## Translation stub files + +This PR adds placeholder files for content that exists in English but has no ${langName} translation yet. + +Each stub: +- copies English frontmatter +- sets \`needsTranslation: true\` +- includes a short placeholder body for translators to replace + +### Files (${stubs.length}) + +${fileList} + +### Next steps for translators + +- [ ] Translate each file's body and frontmatter fields +- [ ] Remove or set \`needsTranslation: false\` when complete +- [ ] Keep code blocks, links, and structure aligned with the English source + +--- +🤖 *Auto-generated by the p5.js Translation Tracker*${stewardsText}`, + }); + + console.log(`\n🔀 Stub PR created for ${langName}: #${pr.number}`); + console.log(` URL: ${pr.html_url}`); + return pr; + } catch (error) { + console.error(`❌ Failed to create stub PR for ${language}:`, error.message); + return null; + } + } } /** @@ -700,19 +939,118 @@ async function checkTranslationStatus(changedFiles, githubTracker = null, create return translationStatus; } +/** + * Week 2: generate stub files and open one PR per language. + */ +async function runStubGeneration(githubTracker, options = {}) { + const languages = parseEnvList(process.env.STUB_LANGUAGES, ['es']); + const contentTypes = parseEnvList(process.env.STUB_CONTENT_TYPES, ['reference']); + const fullScan = options.fullScan ?? process.env.STUB_FULL_SCAN === 'true'; + const dryRun = process.env.STUB_DRY_RUN === 'true'; + const maxFiles = parseInt(process.env.STUB_MAX_FILES || '50', 10); + + console.log(`\n📦 Stub generation mode`); + console.log(` Languages: ${languages.join(', ')}`); + console.log(` Content types: ${contentTypes.join(', ')}`); + console.log(` Scan: ${fullScan ? 'all English files' : 'changed files only'}`); + + const missing = findMissingTranslations(contentTypes, languages, { + fullScan, + testFiles: options.testFiles || null, + }); -// Removed verbose summary function + if (missing.length === 0) { + console.log('\n✅ No missing translation files found for stub generation.'); + return { prsCreated: [], stubsWritten: 0 }; + } + console.log(`\n❌ Found ${missing.length} missing translation file(s):`); + missing.forEach((item) => { + console.log(` - ${item.englishFile} → ${item.language}`); + console.log(` Expected: ${item.translationPath}`); + }); + + const limited = missing.slice(0, maxFiles); + if (limited.length < missing.length) { + console.log(`\n⚠️ Limiting to ${maxFiles} stub(s) (STUB_MAX_FILES). Re-run to process more.`); + } + + const byLanguage = new Map(); + for (const item of limited) { + if (!byLanguage.has(item.language)) { + byLanguage.set(item.language, []); + } + byLanguage.get(item.language).push(item); + } + + const prsCreated = []; + let stubsWritten = 0; + + for (const [language, items] of byLanguage) { + const langName = githubTracker + ? githubTracker.getLanguageDisplayName(language) + : language; + + console.log(`\n📝 Generating ${items.length} stub(s) for ${langName}:`); + + const stubs = items.map((item) => { + const stub = generateStubFromEnglish(item.englishFile, language, item.contentType); + console.log(` 📄 ${item.englishFile} → ${stub.translationPath}`); + return stub; + }); + + if (dryRun || !githubTracker) { + const previewRoot = + process.env.STUB_OUTPUT_DIR || + path.join(process.cwd(), '.github/actions/translation-tracker/stub-preview'); + for (const stub of stubs) { + const writePath = getStubWritePath(stub.translationPath, true); + const dir = path.dirname(writePath); + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir, { recursive: true }); + } + fs.writeFileSync(writePath, stub.content, 'utf8'); + stubsWritten += 1; + } + console.log(`\n🧪 Dry run: wrote ${stubs.length} stub file(s) under ${previewRoot}`); + continue; + } + + const pr = await githubTracker.createStubPullRequest(language, stubs); + if (pr) { + prsCreated.push({ + language, + prNumber: pr.number, + prUrl: pr.html_url, + fileCount: stubs.length, + }); + stubsWritten += stubs.length; + } + } -// Remove verbose repository exploration + if (prsCreated.length > 0) { + console.log(`\n🔀 Stub PRs created: ${prsCreated.length}`); + prsCreated.forEach((pr) => { + console.log(` - ${pr.language}: PR #${pr.prNumber} (${pr.fileCount} file(s))`); + console.log(` URL: ${pr.prUrl}`); + }); + } else if (!dryRun && stubsWritten === 0 && limited.length > 0) { + console.log(`\n💡 Stubs were not written. Check GITHUB_TOKEN permissions (contents + pull-requests write).`); + } + + return { prsCreated, stubsWritten }; +} async function main(testFiles = null, options = {}) { const hasToken = !!process.env.GITHUB_TOKEN; const isGitHubAction = !!process.env.GITHUB_ACTIONS; // Detect if running in GitHub Actions const isProduction = hasToken && !testFiles; + const generateStubsMode = process.env.GENERATE_STUBS === 'true'; - if (testFiles) { + if (generateStubsMode) { + console.log(`📦 Stub generation: ${testFiles ? 'test files' : isGitHubAction ? 'changed files' : 'full scan'}`); + } else if (testFiles) { console.log(`🧪 Test mode: Checking ${testFiles.length} predefined files`); } else if (isGitHubAction) { console.log(`🚀 GitHub Actions: Checking changed files only`); @@ -732,6 +1070,23 @@ async function main(testFiles = null, options = {}) { } } + // Week 2: stub-file PR generation (separate mode from issue tracking) + if (generateStubsMode) { + const dryRun = process.env.STUB_DRY_RUN === 'true'; + if (!githubTracker && !dryRun) { + console.error('❌ GENERATE_STUBS requires GITHUB_TOKEN, or set STUB_DRY_RUN=true for local preview'); + process.exitCode = 1; + return; + } + + const fullScan = + process.env.STUB_FULL_SCAN === 'true' || + (!isGitHubAction && !testFiles); + + await runStubGeneration(githubTracker, { fullScan, testFiles }); + return; + } + const allTranslationStatus = []; for (const contentType of CONTENT_TYPES) { @@ -853,6 +1208,10 @@ module.exports = { getChangedFiles, getAllEnglishContentFiles, checkTranslationStatus, + findMissingTranslations, + generateStubFromEnglish, + pickStubFrontmatter, + runStubGeneration, GitHubCommitTracker, SUPPORTED_LANGUAGES, CONTENT_TYPES diff --git a/.github/actions/translation-tracker/package.json b/.github/actions/translation-tracker/package.json index 74594d8db0..ee7c2f85b5 100644 --- a/.github/actions/translation-tracker/package.json +++ b/.github/actions/translation-tracker/package.json @@ -5,7 +5,8 @@ "main": "index.js", "scripts": { "start": "node index.js", - "test": "node test-local.js" + "test": "node test-local.js", + "test:stubs": "node test-stubs.js" }, "keywords": [ "p5.js", diff --git a/.github/actions/translation-tracker/test-stubs.js b/.github/actions/translation-tracker/test-stubs.js new file mode 100644 index 0000000000..51be3b9246 --- /dev/null +++ b/.github/actions/translation-tracker/test-stubs.js @@ -0,0 +1,19 @@ +const path = require('path'); +const { main } = require('./index.js'); + +// Run from repository root so content paths resolve correctly. +process.chdir(path.join(__dirname, '../../..')); + +// Dry-run stub generation: writes stub files locally, does not open PRs. +process.env.GENERATE_STUBS = 'true'; +process.env.STUB_DRY_RUN = 'true'; +process.env.STUB_LANGUAGES = 'es'; +process.env.STUB_CONTENT_TYPES = 'reference'; +process.env.STUB_FULL_SCAN = 'true'; +process.env.STUB_MAX_FILES = '3'; + +console.log('🧪 Testing stub generation (dry run, max 3 files)'); +console.log(' Output: .github/actions/translation-tracker/stub-preview/'); +console.log('================================================='); + +main(); diff --git a/.github/workflows/translation-stubs.yml b/.github/workflows/translation-stubs.yml new file mode 100644 index 0000000000..14e920d066 --- /dev/null +++ b/.github/workflows/translation-stubs.yml @@ -0,0 +1,52 @@ +name: Translation Stub Generator + +on: + push: + branches: [feature/translation-tracker/stub-file-generation] + paths: + - 'src/content/reference/en/**' + workflow_dispatch: + inputs: + full_scan: + description: 'Scan all English reference files (not just latest commit)' + required: false + default: 'false' + type: choice + options: + - 'false' + - 'true' + languages: + description: 'Comma-separated language codes (default: es)' + required: false + default: 'es' + +permissions: + contents: write + pull-requests: write + +jobs: + generate-translation-stubs: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + + - name: Install translation tracker dependencies + run: cd .github/actions/translation-tracker && npm install + + - name: Generate stub files and open PRs + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GENERATE_STUBS: 'true' + STUB_LANGUAGES: ${{ github.event.inputs.languages || 'es' }} + STUB_CONTENT_TYPES: reference + STUB_FULL_SCAN: ${{ github.event.inputs.full_scan || 'false' }} + run: node .github/actions/translation-tracker/index.js \ No newline at end of file From b3b9457eb97ae7f857af4758fbe7651b720d69ab Mon Sep 17 00:00:00 2001 From: Aashish Panthi Date: Mon, 29 Jun 2026 22:58:35 +0545 Subject: [PATCH 06/16] add new file --- .../examples/en/16_New_file_testing/test.mdx | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/content/examples/en/16_New_file_testing/test.mdx diff --git a/src/content/examples/en/16_New_file_testing/test.mdx b/src/content/examples/en/16_New_file_testing/test.mdx new file mode 100644 index 0000000000..8f387301de --- /dev/null +++ b/src/content/examples/en/16_New_file_testing/test.mdx @@ -0,0 +1,36 @@ +--- +featuredImage: "../../../images/featured/15_Math_And_Physics-00_Non_Orthogonal_Reflection-thumbnail.png" +featuredImageAlt: A small green circle hovering over a yellow tilted plane at the bottom of the canvas. +title: Non-Orthogonal Reflection +oneLineDescription: Simulate a ball bouncing on a slanted surface. + +remix: + - description: Based on + attribution: + - name: Processing example by Ira Greenberg + URL: https://processing.org/examples/reflection1.html + - description: Ported by + attribution: + - name: David Blitz + - description: Revised by + attribution: + - name: Darren Kessner + URL: https://github.com/dkessner + code: + - label: 2023 code + URL: https://github.com/processing/p5.js-example/tree/main/examples/15_Math_And_Physics/00_Non_Orthogonal_Reflection + - collectivelyAttributedSince: 2024 +--- + +This example demonstrates a ball bouncing on a slanted +surface, implemented using vector calculations for reflection. + +The code makes extensive use of the +p5.Vector +class, including the +createVector() function to create new vectors, +and the vector methods +add() +and +dot() +for the vector calculations. \ No newline at end of file From 254c58ff7d48fa6370302e4a49039ac30dffc958 Mon Sep 17 00:00:00 2001 From: Aashish Panthi Date: Mon, 29 Jun 2026 23:04:41 +0545 Subject: [PATCH 07/16] Update branch specification format in translation-stubs.yml workflow --- .github/workflows/translation-stubs.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/translation-stubs.yml b/.github/workflows/translation-stubs.yml index 14e920d066..c75dd7d2fc 100644 --- a/.github/workflows/translation-stubs.yml +++ b/.github/workflows/translation-stubs.yml @@ -2,7 +2,8 @@ name: Translation Stub Generator on: push: - branches: [feature/translation-tracker/stub-file-generation] + branches: + - "feature/translation-tracker/stub-file-generation" paths: - 'src/content/reference/en/**' workflow_dispatch: From 7d1939c9b1ba73e4064a4b6206fb81513c0ff288 Mon Sep 17 00:00:00 2001 From: Aashish Panthi Date: Mon, 29 Jun 2026 23:11:15 +0545 Subject: [PATCH 08/16] Add new example for Non-Orthogonal Reflection simulation --- .../en/16_New_file_testing/test_copy.mdx | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/content/examples/en/16_New_file_testing/test_copy.mdx diff --git a/src/content/examples/en/16_New_file_testing/test_copy.mdx b/src/content/examples/en/16_New_file_testing/test_copy.mdx new file mode 100644 index 0000000000..8f387301de --- /dev/null +++ b/src/content/examples/en/16_New_file_testing/test_copy.mdx @@ -0,0 +1,36 @@ +--- +featuredImage: "../../../images/featured/15_Math_And_Physics-00_Non_Orthogonal_Reflection-thumbnail.png" +featuredImageAlt: A small green circle hovering over a yellow tilted plane at the bottom of the canvas. +title: Non-Orthogonal Reflection +oneLineDescription: Simulate a ball bouncing on a slanted surface. + +remix: + - description: Based on + attribution: + - name: Processing example by Ira Greenberg + URL: https://processing.org/examples/reflection1.html + - description: Ported by + attribution: + - name: David Blitz + - description: Revised by + attribution: + - name: Darren Kessner + URL: https://github.com/dkessner + code: + - label: 2023 code + URL: https://github.com/processing/p5.js-example/tree/main/examples/15_Math_And_Physics/00_Non_Orthogonal_Reflection + - collectivelyAttributedSince: 2024 +--- + +This example demonstrates a ball bouncing on a slanted +surface, implemented using vector calculations for reflection. + +The code makes extensive use of the +p5.Vector +class, including the +createVector() function to create new vectors, +and the vector methods +add() +and +dot() +for the vector calculations. \ No newline at end of file From 0232110ce33f77d1084b7816154ae89d64c20da9 Mon Sep 17 00:00:00 2001 From: Aashish Panthi Date: Mon, 29 Jun 2026 23:16:51 +0545 Subject: [PATCH 09/16] Add new example files for Non-Orthogonal Reflection simulation --- .../reference/en/16_New_file_testing/test.mdx | 36 +++++++++++++++++++ .../en/16_New_file_testing/test_copy.mdx | 36 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 src/content/reference/en/16_New_file_testing/test.mdx create mode 100644 src/content/reference/en/16_New_file_testing/test_copy.mdx diff --git a/src/content/reference/en/16_New_file_testing/test.mdx b/src/content/reference/en/16_New_file_testing/test.mdx new file mode 100644 index 0000000000..8f387301de --- /dev/null +++ b/src/content/reference/en/16_New_file_testing/test.mdx @@ -0,0 +1,36 @@ +--- +featuredImage: "../../../images/featured/15_Math_And_Physics-00_Non_Orthogonal_Reflection-thumbnail.png" +featuredImageAlt: A small green circle hovering over a yellow tilted plane at the bottom of the canvas. +title: Non-Orthogonal Reflection +oneLineDescription: Simulate a ball bouncing on a slanted surface. + +remix: + - description: Based on + attribution: + - name: Processing example by Ira Greenberg + URL: https://processing.org/examples/reflection1.html + - description: Ported by + attribution: + - name: David Blitz + - description: Revised by + attribution: + - name: Darren Kessner + URL: https://github.com/dkessner + code: + - label: 2023 code + URL: https://github.com/processing/p5.js-example/tree/main/examples/15_Math_And_Physics/00_Non_Orthogonal_Reflection + - collectivelyAttributedSince: 2024 +--- + +This example demonstrates a ball bouncing on a slanted +surface, implemented using vector calculations for reflection. + +The code makes extensive use of the +p5.Vector +class, including the +createVector() function to create new vectors, +and the vector methods +add() +and +dot() +for the vector calculations. \ No newline at end of file diff --git a/src/content/reference/en/16_New_file_testing/test_copy.mdx b/src/content/reference/en/16_New_file_testing/test_copy.mdx new file mode 100644 index 0000000000..8f387301de --- /dev/null +++ b/src/content/reference/en/16_New_file_testing/test_copy.mdx @@ -0,0 +1,36 @@ +--- +featuredImage: "../../../images/featured/15_Math_And_Physics-00_Non_Orthogonal_Reflection-thumbnail.png" +featuredImageAlt: A small green circle hovering over a yellow tilted plane at the bottom of the canvas. +title: Non-Orthogonal Reflection +oneLineDescription: Simulate a ball bouncing on a slanted surface. + +remix: + - description: Based on + attribution: + - name: Processing example by Ira Greenberg + URL: https://processing.org/examples/reflection1.html + - description: Ported by + attribution: + - name: David Blitz + - description: Revised by + attribution: + - name: Darren Kessner + URL: https://github.com/dkessner + code: + - label: 2023 code + URL: https://github.com/processing/p5.js-example/tree/main/examples/15_Math_And_Physics/00_Non_Orthogonal_Reflection + - collectivelyAttributedSince: 2024 +--- + +This example demonstrates a ball bouncing on a slanted +surface, implemented using vector calculations for reflection. + +The code makes extensive use of the +p5.Vector +class, including the +createVector() function to create new vectors, +and the vector methods +add() +and +dot() +for the vector calculations. \ No newline at end of file From e58df5db9dffdee71e47990be3c9182d2791f5b7 Mon Sep 17 00:00:00 2001 From: Aashish Panthi Date: Mon, 29 Jun 2026 23:22:49 +0545 Subject: [PATCH 10/16] Update translation tracker to support multiple languages and enhance README documentation --- .github/actions/translation-tracker/README.md | 134 ++++++++---------- .github/actions/translation-tracker/index.js | 2 +- .github/workflows/translation-stubs.yml | 6 +- .../reference/en/16_New_file_testing/test.mdx | 36 ----- .../en/16_New_file_testing/test_copy.mdx | 36 ----- 5 files changed, 62 insertions(+), 152 deletions(-) delete mode 100644 src/content/reference/en/16_New_file_testing/test.mdx delete mode 100644 src/content/reference/en/16_New_file_testing/test_copy.mdx diff --git a/.github/actions/translation-tracker/README.md b/.github/actions/translation-tracker/README.md index 53805e6499..2385e729d1 100644 --- a/.github/actions/translation-tracker/README.md +++ b/.github/actions/translation-tracker/README.md @@ -1,11 +1,12 @@ # p5.js Translation Tracker -Automatically tracks translation status for p5.js website examples, creates GitHub issues for outdated translations, and shows banners on the website. +Automatically tracks translation status, creates GitHub issues for outdated translations, generates stub files for missing translations, and powers outdated-translation banners on the website. ## Features -- Detects outdated/missing translations using Git commit comparison (currently focused on Examples content) +- Detects outdated/missing translations using Git commit comparison - Creates GitHub issues with diff snippets and action checklists +- **Week 2:** Generates translation stub files and opens **one PR per language** - Shows localized banners on outdated translation pages - Supports Spanish, Hindi, Korean, and Chinese Simplified @@ -15,104 +16,85 @@ Automatically tracks translation status for p5.js website examples, creates GitH .github/actions/translation-tracker/ ├── index.js # Main tracker logic ├── package.json # Dependencies -├── test-local.js # Local testing +├── test-local.js # Local issue-tracking test +├── test-stubs.js # Local stub dry-run (writes to stub-preview/) +└── stub-preview/ # Dry-run output (gitignored) -src/layouts/ExampleLayout.astro # Banner integration -src/components/OutdatedTranslationBanner/ # Banner component -public/translation-status/examples.json # Generated status (build artifact) +.github/workflows/ +├── translation-sync.yml # Issues + manifests on English changes +└── translation-stubs.yml # Stub PRs for missing reference pages ``` ## Usage -### Local Testing +### Issue tracking (local) + ```bash cd .github/actions/translation-tracker && npm install node test-local.js ``` -### Scan All Files (File-based) -```bash -node .github/actions/translation-tracker/index.js -``` +### Stub generation (local dry run — recommended) + +Writes stubs under `stub-preview/` only (does **not** modify `src/content/`): -### Scan All Files (GitHub API + Create Issues) ```bash -GITHUB_TOKEN=your_token GITHUB_REPOSITORY=owner/repo node .github/actions/translation-tracker/index.js +cd .github/actions/translation-tracker && npm install +npm run test:stubs ``` -### GitHub Actions Workflow -Create `.github/workflows/translation-sync.yml`: - -```yaml -name: Translation Sync Tracker - -on: - push: - branches: [main, week2] - paths: ['src/content/examples/en/**'] - workflow_dispatch: - -jobs: - track-translation-changes: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 2 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: '18' - - - name: Install dependencies - run: npm ci - - - name: Install translation tracker dependencies - run: cd .github/actions/translation-tracker && npm install - - - name: Run translation tracker - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: node .github/actions/translation-tracker/index.js +Preview path example: +`stub-preview/src/content/reference/es/p5/foo.mdx` + +### Stub generation (open PR on your fork) + +```bash +# From repository root — missing files from latest commit only (all languages by default) +GENERATE_STUBS=true \ + GITHUB_TOKEN=your_token GITHUB_REPOSITORY=youruser/p5.js-website \ + node .github/actions/translation-tracker/index.js + +# Single language or full scan (STUB_MAX_FILES is global across all languages) +GENERATE_STUBS=true STUB_FULL_SCAN=true STUB_MAX_FILES=10 STUB_LANGUAGES=es,hi \ + GITHUB_TOKEN=your_token GITHUB_REPOSITORY=youruser/p5.js-website \ + node .github/actions/translation-tracker/index.js ``` -## Environment Variables +**Fork:** Settings → Actions → Workflow permissions → **Read and write**. -- `GITHUB_TOKEN` - Required for GitHub API and issue creation -- `GITHUB_REPOSITORY` - Format: `owner/repo` (auto-detected in Actions) +### GitHub Actions -## What It Does +| Workflow | Trigger | What it does | +|----------|---------|----------------| +| `translation-sync.yml` | Push to `examples/en`, `tutorials/en` | Issues + manifests | +| `translation-stubs.yml` | Push to `reference/en`, or manual dispatch | Stub PRs (default: es, hi, ko, zh-Hans) | -1. **Scans** English example files for changes -2. **Compares** with translation files using Git commits -3. **Creates** GitHub issues for outdated translations with: - - Diff snippets showing what changed - - Links to files and comparisons - - Action checklist for translators - - Proper labels (`needs translation`, `lang-es`, etc.) -4. **Generates** manifest file for website banner system -5. **Shows** localized banners on outdated translation pages +Manual stub run: Actions → **Translation Stub Generator** → Run workflow → optional full scan. -## Sample Output +## Environment Variables -``` -📝 Checking 61 English example file(s) +| Variable | Purpose | +|----------|---------| +| `GITHUB_TOKEN` | API access (issues, PRs) | +| `GITHUB_REPOSITORY` | `owner/repo` (default: `processing/p5.js-website`) | +| `GENERATE_STUBS` | `true` = stub mode instead of issue tracking | +| `STUB_LANGUAGES` | Comma-separated (default: `es`, `hi`, `ko`, `zh-Hans`) | +| `STUB_CONTENT_TYPES` | Comma-separated (default: `reference`) | +| `STUB_FULL_SCAN` | `true` = all English files, not just latest commit | +| `STUB_DRY_RUN` | `true` = write to `stub-preview/`, no PR | +| `STUB_MAX_FILES` | Max stubs per run, total across all languages (default: `50`) | +| `STUB_OUTPUT_DIR` | Custom dry-run output directory | -📊 Translation Status Summary: - 🔄 Outdated: 48 - ❌ Missing: 0 - ✅ Up-to-date: 196 +## What stubs contain -🎫 GitHub issues created: 12 - - Issue #36: Spanish, Hindi, Korean, Chinese Simplified need updates - - URL: https://github.com/owner/repo/issues/36 +For each English file with **no** translation yet: -🗂️ Wrote translation manifest: public/translation-status/examples.json -``` +1. Essential English frontmatter (`title`, `description`, etc. — not full API params) +2. `needsTranslation: true` +3. Short HTML comment + placeholder body +4. One PR per language with all stubs grouped (never auto-merged) ## Dependencies -- `@actions/core`, `@actions/github`, `@octokit/rest` -- Node.js built-ins: `fs`, `path`, `child_process` \ No newline at end of file +- `@octokit/rest`, `js-yaml` +- Node.js built-ins: `fs`, `path`, `child_process` diff --git a/.github/actions/translation-tracker/index.js b/.github/actions/translation-tracker/index.js index 812c4c9ba3..a088f645c7 100644 --- a/.github/actions/translation-tracker/index.js +++ b/.github/actions/translation-tracker/index.js @@ -943,7 +943,7 @@ async function checkTranslationStatus(changedFiles, githubTracker = null, create * Week 2: generate stub files and open one PR per language. */ async function runStubGeneration(githubTracker, options = {}) { - const languages = parseEnvList(process.env.STUB_LANGUAGES, ['es']); + const languages = parseEnvList(process.env.STUB_LANGUAGES, SUPPORTED_LANGUAGES); const contentTypes = parseEnvList(process.env.STUB_CONTENT_TYPES, ['reference']); const fullScan = options.fullScan ?? process.env.STUB_FULL_SCAN === 'true'; const dryRun = process.env.STUB_DRY_RUN === 'true'; diff --git a/.github/workflows/translation-stubs.yml b/.github/workflows/translation-stubs.yml index c75dd7d2fc..290e3cc930 100644 --- a/.github/workflows/translation-stubs.yml +++ b/.github/workflows/translation-stubs.yml @@ -17,9 +17,9 @@ on: - 'false' - 'true' languages: - description: 'Comma-separated language codes (default: es)' + description: 'Comma-separated language codes (default: all supported)' required: false - default: 'es' + default: 'es,hi,ko,zh-Hans' permissions: contents: write @@ -47,7 +47,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GENERATE_STUBS: 'true' - STUB_LANGUAGES: ${{ github.event.inputs.languages || 'es' }} + STUB_LANGUAGES: ${{ github.event.inputs.languages || 'es,hi,ko,zh-Hans' }} STUB_CONTENT_TYPES: reference STUB_FULL_SCAN: ${{ github.event.inputs.full_scan || 'false' }} run: node .github/actions/translation-tracker/index.js \ No newline at end of file diff --git a/src/content/reference/en/16_New_file_testing/test.mdx b/src/content/reference/en/16_New_file_testing/test.mdx deleted file mode 100644 index 8f387301de..0000000000 --- a/src/content/reference/en/16_New_file_testing/test.mdx +++ /dev/null @@ -1,36 +0,0 @@ ---- -featuredImage: "../../../images/featured/15_Math_And_Physics-00_Non_Orthogonal_Reflection-thumbnail.png" -featuredImageAlt: A small green circle hovering over a yellow tilted plane at the bottom of the canvas. -title: Non-Orthogonal Reflection -oneLineDescription: Simulate a ball bouncing on a slanted surface. - -remix: - - description: Based on - attribution: - - name: Processing example by Ira Greenberg - URL: https://processing.org/examples/reflection1.html - - description: Ported by - attribution: - - name: David Blitz - - description: Revised by - attribution: - - name: Darren Kessner - URL: https://github.com/dkessner - code: - - label: 2023 code - URL: https://github.com/processing/p5.js-example/tree/main/examples/15_Math_And_Physics/00_Non_Orthogonal_Reflection - - collectivelyAttributedSince: 2024 ---- - -This example demonstrates a ball bouncing on a slanted -surface, implemented using vector calculations for reflection. - -The code makes extensive use of the -p5.Vector -class, including the -createVector() function to create new vectors, -and the vector methods -add() -and -dot() -for the vector calculations. \ No newline at end of file diff --git a/src/content/reference/en/16_New_file_testing/test_copy.mdx b/src/content/reference/en/16_New_file_testing/test_copy.mdx deleted file mode 100644 index 8f387301de..0000000000 --- a/src/content/reference/en/16_New_file_testing/test_copy.mdx +++ /dev/null @@ -1,36 +0,0 @@ ---- -featuredImage: "../../../images/featured/15_Math_And_Physics-00_Non_Orthogonal_Reflection-thumbnail.png" -featuredImageAlt: A small green circle hovering over a yellow tilted plane at the bottom of the canvas. -title: Non-Orthogonal Reflection -oneLineDescription: Simulate a ball bouncing on a slanted surface. - -remix: - - description: Based on - attribution: - - name: Processing example by Ira Greenberg - URL: https://processing.org/examples/reflection1.html - - description: Ported by - attribution: - - name: David Blitz - - description: Revised by - attribution: - - name: Darren Kessner - URL: https://github.com/dkessner - code: - - label: 2023 code - URL: https://github.com/processing/p5.js-example/tree/main/examples/15_Math_And_Physics/00_Non_Orthogonal_Reflection - - collectivelyAttributedSince: 2024 ---- - -This example demonstrates a ball bouncing on a slanted -surface, implemented using vector calculations for reflection. - -The code makes extensive use of the -p5.Vector -class, including the -createVector() function to create new vectors, -and the vector methods -add() -and -dot() -for the vector calculations. \ No newline at end of file From a3f1c4b0a4261d0057763bb12735daa8e57994fd Mon Sep 17 00:00:00 2001 From: Aashish Panthi Date: Mon, 29 Jun 2026 23:23:31 +0545 Subject: [PATCH 11/16] test --- .../reference/en/16_New_file_testing/hi.mdx | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/content/reference/en/16_New_file_testing/hi.mdx diff --git a/src/content/reference/en/16_New_file_testing/hi.mdx b/src/content/reference/en/16_New_file_testing/hi.mdx new file mode 100644 index 0000000000..8f387301de --- /dev/null +++ b/src/content/reference/en/16_New_file_testing/hi.mdx @@ -0,0 +1,36 @@ +--- +featuredImage: "../../../images/featured/15_Math_And_Physics-00_Non_Orthogonal_Reflection-thumbnail.png" +featuredImageAlt: A small green circle hovering over a yellow tilted plane at the bottom of the canvas. +title: Non-Orthogonal Reflection +oneLineDescription: Simulate a ball bouncing on a slanted surface. + +remix: + - description: Based on + attribution: + - name: Processing example by Ira Greenberg + URL: https://processing.org/examples/reflection1.html + - description: Ported by + attribution: + - name: David Blitz + - description: Revised by + attribution: + - name: Darren Kessner + URL: https://github.com/dkessner + code: + - label: 2023 code + URL: https://github.com/processing/p5.js-example/tree/main/examples/15_Math_And_Physics/00_Non_Orthogonal_Reflection + - collectivelyAttributedSince: 2024 +--- + +This example demonstrates a ball bouncing on a slanted +surface, implemented using vector calculations for reflection. + +The code makes extensive use of the +p5.Vector +class, including the +createVector() function to create new vectors, +and the vector methods +add() +and +dot() +for the vector calculations. \ No newline at end of file From a0d29dde19e30af1fa022165dbe11b0465e575b8 Mon Sep 17 00:00:00 2001 From: Aashish Panthi Date: Mon, 29 Jun 2026 23:32:42 +0545 Subject: [PATCH 12/16] remove the testing file and organize the code in index.js by creating multiple files. --- .../actions/translation-tracker/constants.js | 18 + .../translation-tracker/github-tracker.js | 440 +++++++ .github/actions/translation-tracker/index.js | 1104 +---------------- .../translation-tracker/package-lock.json | 31 +- .github/actions/translation-tracker/utils.js | 239 ++++ .../actions/translation-tracker/workflows.js | 345 ++++++ .../reference/en/16_New_file_testing/hi.mdx | 36 - 7 files changed, 1103 insertions(+), 1110 deletions(-) create mode 100644 .github/actions/translation-tracker/constants.js create mode 100644 .github/actions/translation-tracker/github-tracker.js create mode 100644 .github/actions/translation-tracker/utils.js create mode 100644 .github/actions/translation-tracker/workflows.js delete mode 100644 src/content/reference/en/16_New_file_testing/hi.mdx diff --git a/.github/actions/translation-tracker/constants.js b/.github/actions/translation-tracker/constants.js new file mode 100644 index 0000000000..d014077c45 --- /dev/null +++ b/.github/actions/translation-tracker/constants.js @@ -0,0 +1,18 @@ +const SUPPORTED_LANGUAGES = ['es', 'hi', 'ko', 'zh-Hans']; +const CONTENT_TYPES = ['examples', 'reference', 'tutorials', 'text-detail', 'events', 'libraries']; + +/** Frontmatter fields copied into stubs (English values). Avoids duplicating params/examples. */ +const STUB_FRONTMATTER_KEYS = { + reference: ['title', 'module', 'submodule', 'file', 'description'], + examples: ['title', 'oneLineDescription', 'featuredImage', 'featuredImageAlt'], + tutorials: ['title', 'description'], + 'text-detail': ['title', 'description'], + events: ['title', 'description'], + libraries: ['title', 'description'], +}; + +module.exports = { + SUPPORTED_LANGUAGES, + CONTENT_TYPES, + STUB_FRONTMATTER_KEYS, +}; diff --git a/.github/actions/translation-tracker/github-tracker.js b/.github/actions/translation-tracker/github-tracker.js new file mode 100644 index 0000000000..330f0b7f53 --- /dev/null +++ b/.github/actions/translation-tracker/github-tracker.js @@ -0,0 +1,440 @@ +const { execSync } = require('child_process'); +const path = require('path'); +const { Octokit } = require('@octokit/rest'); +const { getStewardsForLanguage, getLanguageDisplayName, loadStewardsConfig } = require('./utils'); + +class GitHubCommitTracker { + constructor(token, owner, repo) { + this.octokit = new Octokit({ auth: token }); + this.owner = owner; + this.repo = repo; + this.currentBranch = this.detectCurrentBranch(); + this.stewardsConfig = null; + } + + static async create(token, owner, repo) { + const instance = new GitHubCommitTracker(token, owner, repo); + instance.stewardsConfig = await loadStewardsConfig(); + return instance; + } + + detectCurrentBranch() { + try { + if (process.env.GITHUB_HEAD_REF) { + return process.env.GITHUB_HEAD_REF; + } + + if (process.env.GITHUB_REF_NAME) { + return process.env.GITHUB_REF_NAME; + } + + try { + const branch = execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf8' }).trim(); + if (branch && branch !== 'HEAD') { + return branch; + } + } catch (gitError) { + // Silent fallback + } + + return 'main'; + } catch (error) { + return 'main'; + } + } + + async getLastCommit(filePath) { + try { + const { data } = await this.octokit.rest.repos.listCommits({ + owner: this.owner, + repo: this.repo, + sha: this.currentBranch, + path: filePath, + per_page: 1, + }); + + if (data.length > 0) { + return { + sha: data[0].sha, + date: new Date(data[0].commit.committer.date), + message: data[0].commit.message, + author: data[0].commit.author.name, + url: data[0].html_url, + }; + } + + return null; + } catch (error) { + console.log( + `⚠️ Primary commit lookup failed for ${filePath} on branch '${this.currentBranch}': ${error.message}` + ); + + if (this.currentBranch !== 'main') { + try { + const { data } = await this.octokit.rest.repos.listCommits({ + owner: this.owner, + repo: this.repo, + sha: 'main', + path: filePath, + per_page: 1, + }); + + if (data.length > 0) { + return { + sha: data[0].sha, + date: new Date(data[0].commit.committer.date), + message: data[0].commit.message, + author: data[0].commit.author.name, + url: data[0].html_url, + }; + } + } catch (fallbackError) { + console.log(`⚠️ Fallback to main branch also failed for ${filePath}: ${fallbackError.message}`); + } + } + + console.log(`❌ Could not get commit info for ${filePath} from any branch`); + return null; + } + } + + async getRecentDiffForFile(filePath) { + try { + const { data: commits } = await this.octokit.rest.repos.listCommits({ + owner: this.owner, + repo: this.repo, + sha: this.currentBranch, + path: filePath, + per_page: 2, + }); + + if (!commits || commits.length === 0) { + return null; + } + + const headSha = commits[0].sha; + let baseSha = commits.length > 1 ? commits[1].sha : null; + + if (!baseSha) { + try { + const { data: headCommit } = await this.octokit.rest.repos.getCommit({ + owner: this.owner, + repo: this.repo, + ref: headSha, + }); + baseSha = headCommit.parents && headCommit.parents.length > 0 ? headCommit.parents[0].sha : null; + } catch (parentErr) { + console.log(`⚠️ Could not resolve base commit for diff of ${filePath}: ${parentErr.message}`); + } + } + + if (!baseSha) { + return { + baseSha: null, + headSha, + compareUrl: `https://github.com/${this.owner}/${this.repo}/commit/${headSha}`, + patchSnippet: null, + isTruncated: false, + }; + } + + const { data: compare } = await this.octokit.rest.repos.compareCommits({ + owner: this.owner, + repo: this.repo, + base: baseSha, + head: headSha, + }); + + const changedFile = (compare.files || []).find((f) => f.filename === filePath); + const patch = changedFile && changedFile.patch ? changedFile.patch : null; + + let patchSnippet = null; + let isTruncated = false; + if (patch) { + const lines = patch.split('\n'); + const maxLines = 50; + if (lines.length > maxLines) { + patchSnippet = lines.slice(0, maxLines).join('\n'); + isTruncated = true; + } else { + patchSnippet = patch; + } + } + + return { + baseSha, + headSha, + compareUrl: `https://github.com/${this.owner}/${this.repo}/compare/${baseSha}...${headSha}`, + patchSnippet, + isTruncated, + }; + } catch (error) { + console.log(`⚠️ Failed to compute diff for ${filePath} on branch '${this.currentBranch}': ${error.message}`); + return { + baseSha: null, + headSha: null, + compareUrl: `https://github.com/${this.owner}/${this.repo}/blob/${this.currentBranch}/${filePath}`, + patchSnippet: null, + isTruncated: false, + }; + } + } + + async createMultiLanguageTranslationIssue(fileTranslations) { + const englishFile = fileTranslations.englishFile; + const issueTitle = `🌍 Update translations for ${path.basename(englishFile)}`; + const englishDiff = await this.getRecentDiffForFile(englishFile); + const issueBody = this.formatMultiLanguageIssueBody(fileTranslations, englishDiff); + + const labels = ['needs translation', 'help wanted']; + const affectedLanguages = [ + ...fileTranslations.outdatedLanguages.map((l) => l.language), + ...fileTranslations.missingLanguages.map((l) => l.language), + ]; + + const uniqueLanguages = [...new Set(affectedLanguages)]; + uniqueLanguages.forEach((lang) => { + labels.push(`lang-${lang}`); + }); + + let assignees = []; + uniqueLanguages.forEach((lang) => { + const stewards = getStewardsForLanguage(this.stewardsConfig, lang); + assignees.push(...stewards); + }); + assignees = [...new Set(assignees.map((a) => a.replace('@', '')))]; + + try { + const createParams = { + owner: this.owner, + repo: this.repo, + title: issueTitle, + body: issueBody, + labels, + }; + + if (assignees.length > 0) { + createParams.assignees = assignees; + } + + const { data } = await this.octokit.rest.issues.create(createParams); + return data; + } catch (error) { + if (error.message.includes('assignees') && assignees.length > 0) { + try { + const { data } = await this.octokit.rest.issues.create({ + owner: this.owner, + repo: this.repo, + title: issueTitle, + body: issueBody, + labels, + }); + console.log(`⚠️ Issue created but stewards could not be assigned (not collaborators)`); + return data; + } catch (retryError) { + console.error(`❌ Error creating issue on retry:`, retryError.message); + return null; + } + } + console.error(`❌ Error creating multi-language issue:`, error.message); + return null; + } + } + + formatMultiLanguageIssueBody(fileTranslations, englishDiff) { + const englishFile = fileTranslations.englishFile; + const outdatedLanguages = fileTranslations.outdatedLanguages; + const missingLanguages = fileTranslations.missingLanguages; + const englishCommit = fileTranslations.englishCommit; + + let body = `## 🌍 Translation Update Needed + +**File**: \`${englishFile}\` +**Branch**: \`${this.currentBranch}\` + +### 📅 Timeline +- **Latest English update**: ${englishCommit.date.toLocaleDateString()} by ${englishCommit.author} + +`; + + if (outdatedLanguages.length > 0) { + body += `### 🔄 Outdated Translations\n\n`; + outdatedLanguages.forEach((lang) => { + const translationPath = lang.translationPath; + const stewards = getStewardsForLanguage(this.stewardsConfig, lang.language); + const stewardsText = stewards.length > 0 ? ` (cc ${stewards.join(', ')})` : ''; + body += `- **${this.getLanguageDisplayName(lang.language)}**: Last updated ${lang.commitInfo.translation.date.toLocaleDateString()} by ${lang.commitInfo.translation.author}${stewardsText}\n`; + body += ` - [📝 View file](https://github.com/${this.owner}/${this.repo}/blob/${this.currentBranch}/${translationPath})\n\n`; + }); + } + + if (missingLanguages.length > 0) { + body += `### ❌ Missing Translations\n\n`; + missingLanguages.forEach((lang) => { + const translationPath = lang.translationPath; + const stewards = getStewardsForLanguage(this.stewardsConfig, lang.language); + const stewardsText = stewards.length > 0 ? ` (cc ${stewards.join(', ')})` : ''; + body += `- **${this.getLanguageDisplayName(lang.language)}**: Translation file does not exist${stewardsText}\n`; + body += ` - Expected location: \`${translationPath}\`\n\n`; + }); + } + + if (englishDiff && (englishDiff.compareUrl || englishDiff.patchSnippet)) { + body += `### 🧩 Recent English Diff\n\n`; + if (englishDiff.compareUrl) { + body += `- [🔍 View full compare](${englishDiff.compareUrl})\n\n`; + } + if (englishDiff.patchSnippet) { + body += `
\nShow patch snippet\n\n`; + body += `\`\`\`diff\n${englishDiff.patchSnippet}\n\`\`\`\n\n`; + if (englishDiff.isTruncated) { + body += `_(Patch snippet truncated. Use the compare link above for the full diff.)_\n\n`; + } + body += `
\n\n`; + } else { + body += `_(Couldn't generate preview of the differences for this change. Use the compare link above to see the full diff.)_\n\n`; + } + } + + body += `### 🔗 Quick Links +- [📄 Current English file](https://github.com/${this.owner}/${this.repo}/blob/${this.currentBranch}/${englishFile}) + +### ✅ Action Checklist + +**For translators / contributors:** + +- [ ] Review the recent English file changes and the current translations +- [ ] Confirm if translation already reflects the update — close the issue if so +- [ ] Update the translation files accordingly +- [ ] Maintain structure, code blocks, and formatting +- [ ] Ensure translation is accurate and culturally appropriate + +### 📝 Summary of English File Changes +**Last commit**: [${englishCommit.message}](${englishCommit.url}) + +${outdatedLanguages.length > 0 || missingLanguages.length > 0 ? `**Change Type**: English file was updated. ${outdatedLanguages.length > 0 ? `${outdatedLanguages.map((l) => this.getLanguageDisplayName(l.language)).join(', ')} translation${outdatedLanguages.length > 1 ? 's' : ''} may be outdated.` : ''} ${missingLanguages.length > 0 ? `${missingLanguages.map((l) => this.getLanguageDisplayName(l.language)).join(', ')} translation${missingLanguages.length > 1 ? 's are' : ' is'} missing.` : ''}` : ''} + +--- +ℹ️ **Need help?** See our [Contributor Guidelines](https://p5js.org/contribute/contributor_guidelines/) + +🤖 *This issue was auto-generated by the p5.js Translation Tracker*`; + return body; + } + + getLanguageDisplayName(langCode) { + return getLanguageDisplayName(langCode); + } + + async createBranchWithFiles(branchName, commitMessage, fileChanges) { + const baseBranch = this.currentBranch || 'main'; + + const { data: ref } = await this.octokit.rest.git.getRef({ + owner: this.owner, + repo: this.repo, + ref: `heads/${baseBranch}`, + }); + const baseSha = ref.object.sha; + + const { data: baseCommit } = await this.octokit.rest.git.getCommit({ + owner: this.owner, + repo: this.repo, + commit_sha: baseSha, + }); + + const treeItems = await Promise.all( + fileChanges.map(async ({ path: filePath, content }) => { + const { data: blob } = await this.octokit.rest.git.createBlob({ + owner: this.owner, + repo: this.repo, + content: Buffer.from(content, 'utf8').toString('base64'), + encoding: 'base64', + }); + return { path: filePath, mode: '100644', type: 'blob', sha: blob.sha }; + }) + ); + + const { data: tree } = await this.octokit.rest.git.createTree({ + owner: this.owner, + repo: this.repo, + base_tree: baseCommit.tree.sha, + tree: treeItems, + }); + + const { data: commit } = await this.octokit.rest.git.createCommit({ + owner: this.owner, + repo: this.repo, + message: commitMessage, + tree: tree.sha, + parents: [baseSha], + }); + + await this.octokit.rest.git.createRef({ + owner: this.owner, + repo: this.repo, + ref: `refs/heads/${branchName}`, + sha: commit.sha, + }); + + return { branchName, commitSha: commit.sha }; + } + + async createStubPullRequest(language, stubs) { + const dateStr = new Date().toISOString().slice(0, 10).replace(/-/g, ''); + const branchName = `translation-stubs/${language}-${dateStr}-${Date.now()}`; + const langName = this.getLanguageDisplayName(language); + const commitMessage = `chore(i18n): add ${language} translation stubs for ${stubs.length} page(s)`; + + const fileChanges = stubs.map((stub) => ({ + path: stub.translationPath, + content: stub.content, + })); + + try { + await this.createBranchWithFiles(branchName, commitMessage, fileChanges); + + const stewards = getStewardsForLanguage(this.stewardsConfig, language); + const stewardsText = stewards.length > 0 ? `\n\ncc ${stewards.join(' ')}` : ''; + const fileList = stubs + .map((stub) => `- \`${stub.translationPath}\` (from \`${stub.englishPath}\`)`) + .join('\n'); + + const { data: pr } = await this.octokit.rest.pulls.create({ + owner: this.owner, + repo: this.repo, + title: `chore(i18n): add ${langName} translation stubs (${stubs.length})`, + head: branchName, + base: this.currentBranch || 'main', + body: `## Translation stub files + +This PR adds placeholder files for content that exists in English but has no ${langName} translation yet. + +Each stub: +- copies English frontmatter +- sets \`needsTranslation: true\` +- includes a short placeholder body for translators to replace + +### Files (${stubs.length}) + +${fileList} + +### Next steps for translators + +- [ ] Translate each file's body and frontmatter fields +- [ ] Remove or set \`needsTranslation: false\` when complete +- [ ] Keep code blocks, links, and structure aligned with the English source + +--- +🤖 *Auto-generated by the p5.js Translation Tracker*${stewardsText}`, + }); + + console.log(`\n🔀 Stub PR created for ${langName}: #${pr.number}`); + console.log(` URL: ${pr.html_url}`); + return pr; + } catch (error) { + console.error(`❌ Failed to create stub PR for ${language}:`, error.message); + return null; + } + } +} + +module.exports = { GitHubCommitTracker }; diff --git a/.github/actions/translation-tracker/index.js b/.github/actions/translation-tracker/index.js index a088f645c7..080e1301ac 100644 --- a/.github/actions/translation-tracker/index.js +++ b/.github/actions/translation-tracker/index.js @@ -1,1053 +1,22 @@ -const { execSync } = require('child_process'); const fs = require('fs'); const path = require('path'); -const https = require('https'); -const { Octokit } = require('@octokit/rest'); -const yaml = require('js-yaml'); - -const SUPPORTED_LANGUAGES = ['es', 'hi', 'ko', 'zh-Hans']; -const CONTENT_TYPES = ['examples', 'reference', 'tutorials', 'text-detail', 'events', 'libraries']; - -function getTranslationPath(englishFilePath, language) { - // Ensure we have a valid English path - if (!englishFilePath.includes('/en/')) { - throw new Error(`Invalid English file path: ${englishFilePath}. Must contain '/en/'`); - } - - // Split path into parts and replace 'en' directory with target language - const pathParts = englishFilePath.split('/'); - const enIndex = pathParts.findIndex(part => part === 'en'); - - if (enIndex === -1) { - throw new Error(`Could not find 'en' directory in path: ${englishFilePath}`); - } - - // Create new path with language replacement - const translationParts = [...pathParts]; - translationParts[enIndex] = language; - - return translationParts.join('/'); -} - -function getSlugFromEnglishPath(englishFilePath, contentType) { - const prefix = `src/content/${contentType}/en/`; - if (!englishFilePath.startsWith(prefix)) return null; - let relative = englishFilePath.substring(prefix.length); - - if (relative.endsWith('/description.mdx')) { - relative = relative.slice(0, -'/description.mdx'.length); - } else if (relative.endsWith('.mdx')) { - relative = relative.slice(0, -'.mdx'.length); - } else if (relative.endsWith('.yaml')) { - relative = relative.slice(0, -'.yaml'.length); - } - return relative; -} - -function parseEnvList(envValue, defaultList) { - if (!envValue || envValue.trim() === '') { - return defaultList; - } - return envValue.split(',').map((item) => item.trim()).filter(Boolean); -} - -/** - * Find English content files that have no translation file yet. - * Used for stub-file generation (Week 2). - */ -function findMissingTranslations(contentTypes, languages, options = {}) { - const { fullScan = false, testFiles = null } = options; - const missing = []; - - for (const contentType of contentTypes) { - let englishFiles; - if (testFiles) { - englishFiles = testFiles.filter( - (file) => - file.startsWith(`src/content/${contentType}/en/`) && - (file.endsWith('.mdx') || file.endsWith('.yaml')) - ); - } else if (fullScan) { - englishFiles = getAllEnglishContentFiles(contentType); - } else if (process.env.GITHUB_ACTIONS) { - englishFiles = getChangedFiles(null, contentType); - } else { - englishFiles = getAllEnglishContentFiles(contentType); - } - - for (const englishFile of englishFiles) { - for (const language of languages) { - const translationPath = getTranslationPath(englishFile, language); - if (!fileExists(translationPath)) { - missing.push({ englishFile, language, translationPath, contentType }); - } - } - } - } - - missing.sort((a, b) => a.translationPath.localeCompare(b.translationPath)); - return missing; -} - -/** Frontmatter fields copied into stubs (English values). Avoids duplicating params/examples. */ -const STUB_FRONTMATTER_KEYS = { - reference: ['title', 'module', 'submodule', 'file', 'description'], - examples: ['title', 'oneLineDescription', 'featuredImage', 'featuredImageAlt'], - tutorials: ['title', 'description'], - 'text-detail': ['title', 'description'], - events: ['title', 'description'], - libraries: ['title', 'description'], -}; - -function pickStubFrontmatter(frontmatter, contentType) { - const keys = STUB_FRONTMATTER_KEYS[contentType] || ['title', 'description']; - const picked = { needsTranslation: true }; - for (const key of keys) { - if (frontmatter[key] !== undefined) { - picked[key] = frontmatter[key]; - } - } - return picked; -} - -function parseFrontmatter(raw, filePath) { - const frontmatterMatch = raw.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/); - if (!frontmatterMatch) { - throw new Error(`Could not find frontmatter in ${filePath}`); - } - - return yaml.load(frontmatterMatch[1]) || {}; -} - -function stringifyMdx(frontmatter, body) { - const frontmatterText = yaml.dump(frontmatter, { - lineWidth: 100, - noRefs: true, - sortKeys: false, - }); - - return `---\n${frontmatterText}---\n${body}`; -} - -/** - * Build a placeholder translation file from an English source. - * Copies essential frontmatter (in English), sets needsTranslation: true, minimal body. - */ -function generateStubFromEnglish(englishPath, language, contentType = 'reference') { - const raw = fs.readFileSync(englishPath, 'utf8'); - const frontmatter = parseFrontmatter(raw, englishPath); - const translationPath = getTranslationPath(englishPath, language); - - const stubFrontmatter = pickStubFrontmatter(frontmatter, contentType); - - const stubComment = ``; - - const stubBody = `${stubComment} - - -`; - - const content = stringifyMdx(stubFrontmatter, stubBody); - - return { translationPath, content, englishPath }; -} - -/** Where dry-run stubs are written locally (never touches src/content by default). */ -function getStubWritePath(translationPath, dryRun) { - if (!dryRun) { - return translationPath; - } - const outputRoot = - process.env.STUB_OUTPUT_DIR || - path.join(process.cwd(), '.github/actions/translation-tracker/stub-preview'); - return path.join(outputRoot, translationPath); -} - -async function loadStewardsConfig() { - const STEWARDS_URL = 'https://raw.githubusercontent.com/processing/p5.js/main/stewards.yml'; - - return new Promise((resolve, reject) => { - https.get(STEWARDS_URL, (res) => { - let data = ''; - - res.on('data', (chunk) => { - data += chunk; - }); - - res.on('end', () => { - try { - const config = yaml.load(data); - console.log('Successfully loaded stewards config from p5.js repository'); - resolve(config); - } catch (error) { - console.log(`Could not parse stewards config: ${error.message}`); - resolve(null); - } - }); - }).on('error', (error) => { - console.log(` Could not load stewards config from remote: ${error.message}`); - resolve(null); - }); - }); -} - -function getStewardsForLanguage(stewardsConfig, language) { - if (!stewardsConfig) return []; - - // Map website language codes to stewards.yml language codes - const languageMap = { - 'zh-Hans': 'zh', // Simplified Chinese - 'hi': 'hi', - 'ko': 'ko', - 'es': 'es' - }; - - const stewardsLangCode = languageMap[language] || language; - const stewards = []; - - for (const [username, areas] of Object.entries(stewardsConfig)) { - if (!Array.isArray(areas)) continue; - - // Check if this steward has i18n area with the target language - for (const area of areas) { - if (typeof area === 'object' && area.i18n) { - const languages = area.i18n; - if (Array.isArray(languages) && languages.includes(stewardsLangCode)) { - stewards.push(`@${username}`); - break; - } - } - } - } - - return stewards; -} - -class GitHubCommitTracker { - constructor(token, owner, repo) { - this.octokit = new Octokit({ auth: token }); - this.owner = owner; - this.repo = repo; - this.currentBranch = this.detectCurrentBranch(); - this.stewardsConfig = null; - } - - - static async create(token, owner, repo) { - const instance = new GitHubCommitTracker(token, owner, repo); - instance.stewardsConfig = await loadStewardsConfig(); - return instance; - } - - /** - * Detect the current git branch - */ - detectCurrentBranch() { - try { - // GitHub Actions environment - if (process.env.GITHUB_HEAD_REF) { - return process.env.GITHUB_HEAD_REF; // For pull requests - } - - if (process.env.GITHUB_REF_NAME) { - return process.env.GITHUB_REF_NAME; - } - - // Git command fallback - try { - const branch = execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf8' }).trim(); - if (branch && branch !== 'HEAD') { - return branch; - } - } catch (gitError) { - // Silent fallback - } - - // Default fallback - return 'main'; - - } catch (error) { - return 'main'; - } - } - - /** - * Get the last commit for a specific file using GitHub API - */ - async getLastCommit(filePath) { - try { - const { data } = await this.octokit.rest.repos.listCommits({ - owner: this.owner, - repo: this.repo, - sha: this.currentBranch, - path: filePath, - per_page: 1 - }); - - if (data.length > 0) { - return { - sha: data[0].sha, - date: new Date(data[0].commit.committer.date), - message: data[0].commit.message, - author: data[0].commit.author.name, - url: data[0].html_url - }; - } - - return null; - } catch (error) { - console.log(`⚠️ Primary commit lookup failed for ${filePath} on branch '${this.currentBranch}': ${error.message}`); - - // Fallback to main branch if current branch fails - if (this.currentBranch !== 'main') { - try { - const { data } = await this.octokit.rest.repos.listCommits({ - owner: this.owner, - repo: this.repo, - sha: 'main', - path: filePath, - per_page: 1 - }); - - if (data.length > 0) { - return { - sha: data[0].sha, - date: new Date(data[0].commit.committer.date), - message: data[0].commit.message, - author: data[0].commit.author.name, - url: data[0].html_url - }; - } - } catch (fallbackError) { - console.log(`⚠️ Fallback to main branch also failed for ${filePath}: ${fallbackError.message}`); - } - } - - console.log(`❌ Could not get commit info for ${filePath} from any branch`); - return null; - } - } - - /** - * Get a recent diff for a file (head vs previous commit) and return a short patch snippet - */ - async getRecentDiffForFile(filePath) { - try { - // Get latest two commits for this file on current branch - const { data: commits } = await this.octokit.rest.repos.listCommits({ - owner: this.owner, - repo: this.repo, - sha: this.currentBranch, - path: filePath, - per_page: 2, - }); - - if (!commits || commits.length === 0) { - return null; - } - - const headSha = commits[0].sha; - let baseSha = commits.length > 1 ? commits[1].sha : null; - - // If only one commit is found for the file (new file), use the parent of head - if (!baseSha) { - try { - const { data: headCommit } = await this.octokit.rest.repos.getCommit({ - owner: this.owner, - repo: this.repo, - ref: headSha, - }); - baseSha = headCommit.parents && headCommit.parents.length > 0 ? headCommit.parents[0].sha : null; - } catch (parentErr) { - console.log(`⚠️ Could not resolve base commit for diff of ${filePath}: ${parentErr.message}`); - } - } - - if (!baseSha) { - return { - baseSha: null, - headSha, - compareUrl: `https://github.com/${this.owner}/${this.repo}/commit/${headSha}`, - patchSnippet: null, - isTruncated: false, - }; - } - - // Compare the two commits and extract the file patch - const { data: compare } = await this.octokit.rest.repos.compareCommits({ - owner: this.owner, - repo: this.repo, - base: baseSha, - head: headSha, - }); - - const changedFile = (compare.files || []).find((f) => f.filename === filePath); - const patch = changedFile && changedFile.patch ? changedFile.patch : null; - - let patchSnippet = null; - let isTruncated = false; - if (patch) { - const lines = patch.split('\n'); - const maxLines = 50; - if (lines.length > maxLines) { - patchSnippet = lines.slice(0, maxLines).join('\n'); - isTruncated = true; - } else { - patchSnippet = patch; - } - } - - return { - baseSha, - headSha, - compareUrl: `https://github.com/${this.owner}/${this.repo}/compare/${baseSha}...${headSha}`, - patchSnippet, - isTruncated, - }; - } catch (error) { - console.log(`⚠️ Failed to compute diff for ${filePath} on branch '${this.currentBranch}': ${error.message}`); - // Fallback to at least provide a compare link to branch head - return { - baseSha: null, - headSha: null, - compareUrl: `https://github.com/${this.owner}/${this.repo}/blob/${this.currentBranch}/${filePath}`, - patchSnippet: null, - isTruncated: false, - }; - } - } - - async createMultiLanguageTranslationIssue(fileTranslations) { - const englishFile = fileTranslations.englishFile; - const issueTitle = `🌍 Update translations for ${path.basename(englishFile)}`; - // Fetch recent English diff (best-effort) - const englishDiff = await this.getRecentDiffForFile(englishFile); - const issueBody = this.formatMultiLanguageIssueBody(fileTranslations, englishDiff); - - // Create labels: "needs translation" + specific language labels - const labels = ['needs translation', 'help wanted']; - const affectedLanguages = [ - ...fileTranslations.outdatedLanguages.map(l => l.language), - ...fileTranslations.missingLanguages.map(l => l.language) - ]; - - // Add specific language labels (remove duplicates) - const uniqueLanguages = [...new Set(affectedLanguages)]; - uniqueLanguages.forEach(lang => { - labels.push(`lang-${lang}`); - }); - - let assignees = []; - uniqueLanguages.forEach(lang => { - const stewards = getStewardsForLanguage(this.stewardsConfig, lang); - assignees.push(...stewards); - }); - assignees = [...new Set(assignees.map(a => a.replace('@', '')))]; - - try { - const createParams = { - owner: this.owner, - repo: this.repo, - title: issueTitle, - body: issueBody, - labels: labels - }; - - if (assignees.length > 0) { - createParams.assignees = assignees; - } - - const { data } = await this.octokit.rest.issues.create(createParams); - - return data; - } catch (error) { - // If assignees fail, try again without assignees - if (error.message.includes('assignees') && assignees.length > 0) { - try { - const { data } = await this.octokit.rest.issues.create({ - owner: this.owner, - repo: this.repo, - title: issueTitle, - body: issueBody, - labels: labels - }); - console.log(`⚠️ Issue created but stewards could not be assigned (not collaborators)`); - return data; - } catch (retryError) { - console.error(`❌ Error creating issue on retry:`, retryError.message); - return null; - } - } - console.error(`❌ Error creating multi-language issue:`, error.message); - return null; - } - } - - /** - * Format the issue body for multi-language updates - */ - formatMultiLanguageIssueBody(fileTranslations, englishDiff) { - const englishFile = fileTranslations.englishFile; - const outdatedLanguages = fileTranslations.outdatedLanguages; - const missingLanguages = fileTranslations.missingLanguages; - const englishCommit = fileTranslations.englishCommit; - - let body = `## 🌍 Translation Update Needed - -**File**: \`${englishFile}\` -**Branch**: \`${this.currentBranch}\` - -### 📅 Timeline -- **Latest English update**: ${englishCommit.date.toLocaleDateString()} by ${englishCommit.author} - -`; - - // Outdated translations section - if (outdatedLanguages.length > 0) { - body += `### 🔄 Outdated Translations\n\n`; - outdatedLanguages.forEach(lang => { - const translationPath = lang.translationPath; - const stewards = getStewardsForLanguage(this.stewardsConfig, lang.language); - const stewardsText = stewards.length > 0 ? ` (cc ${stewards.join(', ')})` : ''; - body += `- **${this.getLanguageDisplayName(lang.language)}**: Last updated ${lang.commitInfo.translation.date.toLocaleDateString()} by ${lang.commitInfo.translation.author}${stewardsText}\n`; - body += ` - [📝 View file](https://github.com/${this.owner}/${this.repo}/blob/${this.currentBranch}/${translationPath})\n\n`; - }); - } - - // Missing translations section - if (missingLanguages.length > 0) { - body += `### ❌ Missing Translations\n\n`; - missingLanguages.forEach(lang => { - const translationPath = lang.translationPath; - const stewards = getStewardsForLanguage(this.stewardsConfig, lang.language); - const stewardsText = stewards.length > 0 ? ` (cc ${stewards.join(', ')})` : ''; - body += `- **${this.getLanguageDisplayName(lang.language)}**: Translation file does not exist${stewardsText}\n`; - body += ` - Expected location: \`${translationPath}\`\n\n`; - }); - } - - // English diff. It shows the actual content changes in the English file. - if (englishDiff && (englishDiff.compareUrl || englishDiff.patchSnippet)) { - body += `### 🧩 Recent English Diff\n\n`; - if (englishDiff.compareUrl) { - body += `- [🔍 View full compare](${englishDiff.compareUrl})\n\n`; - } - if (englishDiff.patchSnippet) { - body += `
\nShow patch snippet\n\n`; - body += `\`\`\`diff\n${englishDiff.patchSnippet}\n\`\`\`\n\n`; - if (englishDiff.isTruncated) { - body += `_(Patch snippet truncated. Use the compare link above for the full diff.)_\n\n`; - } - body += `
\n\n`; - } else { - body += `_(Couldn't generate preview of the differences for this change. Use the compare link above to see the full diff.)_\n\n`; - } - } - - body += `### 🔗 Quick Links -- [📄 Current English file](https://github.com/${this.owner}/${this.repo}/blob/${this.currentBranch}/${englishFile}) - -### ✅ Action Checklist - -**For translators / contributors:** - -- [ ] Review the recent English file changes and the current translations -- [ ] Confirm if translation already reflects the update — close the issue if so -- [ ] Update the translation files accordingly -- [ ] Maintain structure, code blocks, and formatting -- [ ] Ensure translation is accurate and culturally appropriate - -### 📝 Summary of English File Changes -**Last commit**: [${englishCommit.message}](${englishCommit.url}) - -${outdatedLanguages.length > 0 || missingLanguages.length > 0 ? `**Change Type**: English file was updated. ${outdatedLanguages.length > 0 ? `${outdatedLanguages.map(l => this.getLanguageDisplayName(l.language)).join(', ')} translation${outdatedLanguages.length > 1 ? 's' : ''} may be outdated.` : ''} ${missingLanguages.length > 0 ? `${missingLanguages.map(l => this.getLanguageDisplayName(l.language)).join(', ')} translation${missingLanguages.length > 1 ? 's are' : ' is'} missing.` : ''}` : ''} - ---- -ℹ️ **Need help?** See our [Contributor Guidelines](https://p5js.org/contribute/contributor_guidelines/) - -🤖 *This issue was auto-generated by the p5.js Translation Tracker*`; - return body; - } - - /** - * Get display name for language code - */ - getLanguageDisplayName(langCode) { - const languages = { - 'es': 'Spanish (Español)', - 'hi': 'Hindi (हिन्दी)', - 'ko': 'Korean (한국어)', - 'zh-Hans': 'Chinese Simplified (简体中文)' - }; - return languages[langCode] || langCode; - } - - /** - * Create a branch with one commit containing multiple new files (for stub PRs). - */ - async createBranchWithFiles(branchName, commitMessage, fileChanges) { - const baseBranch = this.currentBranch || 'main'; - - const { data: ref } = await this.octokit.rest.git.getRef({ - owner: this.owner, - repo: this.repo, - ref: `heads/${baseBranch}`, - }); - const baseSha = ref.object.sha; - - const { data: baseCommit } = await this.octokit.rest.git.getCommit({ - owner: this.owner, - repo: this.repo, - commit_sha: baseSha, - }); - - const treeItems = await Promise.all( - fileChanges.map(async ({ path: filePath, content }) => { - const { data: blob } = await this.octokit.rest.git.createBlob({ - owner: this.owner, - repo: this.repo, - content: Buffer.from(content, 'utf8').toString('base64'), - encoding: 'base64', - }); - return { path: filePath, mode: '100644', type: 'blob', sha: blob.sha }; - }) - ); - - const { data: tree } = await this.octokit.rest.git.createTree({ - owner: this.owner, - repo: this.repo, - base_tree: baseCommit.tree.sha, - tree: treeItems, - }); - - const { data: commit } = await this.octokit.rest.git.createCommit({ - owner: this.owner, - repo: this.repo, - message: commitMessage, - tree: tree.sha, - parents: [baseSha], - }); - - await this.octokit.rest.git.createRef({ - owner: this.owner, - repo: this.repo, - ref: `refs/heads/${branchName}`, - sha: commit.sha, - }); - - return { branchName, commitSha: commit.sha }; - } - - /** - * Open one PR per language with all stub files for that language. - */ - async createStubPullRequest(language, stubs) { - const dateStr = new Date().toISOString().slice(0, 10).replace(/-/g, ''); - const branchName = `translation-stubs/${language}-${dateStr}-${Date.now()}`; - const langName = this.getLanguageDisplayName(language); - const commitMessage = `chore(i18n): add ${language} translation stubs for ${stubs.length} page(s)`; - - const fileChanges = stubs.map((stub) => ({ - path: stub.translationPath, - content: stub.content, - })); - - try { - await this.createBranchWithFiles(branchName, commitMessage, fileChanges); - - const stewards = getStewardsForLanguage(this.stewardsConfig, language); - const stewardsText = stewards.length > 0 ? `\n\ncc ${stewards.join(' ')}` : ''; - const fileList = stubs.map((stub) => `- \`${stub.translationPath}\` (from \`${stub.englishPath}\`)`).join('\n'); - - const { data: pr } = await this.octokit.rest.pulls.create({ - owner: this.owner, - repo: this.repo, - title: `chore(i18n): add ${langName} translation stubs (${stubs.length})`, - head: branchName, - base: this.currentBranch || 'main', - body: `## Translation stub files - -This PR adds placeholder files for content that exists in English but has no ${langName} translation yet. - -Each stub: -- copies English frontmatter -- sets \`needsTranslation: true\` -- includes a short placeholder body for translators to replace - -### Files (${stubs.length}) - -${fileList} - -### Next steps for translators - -- [ ] Translate each file's body and frontmatter fields -- [ ] Remove or set \`needsTranslation: false\` when complete -- [ ] Keep code blocks, links, and structure aligned with the English source - ---- -🤖 *Auto-generated by the p5.js Translation Tracker*${stewardsText}`, - }); - - console.log(`\n🔀 Stub PR created for ${langName}: #${pr.number}`); - console.log(` URL: ${pr.html_url}`); - return pr; - } catch (error) { - console.error(`❌ Failed to create stub PR for ${language}:`, error.message); - return null; - } - } -} - -/** - * Get changed files from git or test files (generalized for different content types) - */ -function getChangedFiles(testFiles = null, contentType = 'examples') { - // Allow passing test files for local development (Week 1 feature) - if (testFiles) { - console.log('🧪 Using provided test files for local testing'); - return testFiles.filter(file => - file.startsWith(`src/content/${contentType}/en`) && (file.endsWith('.mdx') || file.endsWith('.yaml')) - ); - } - - try { - // Different git commands for different event types - const gitCommand = process.env.GITHUB_EVENT_NAME === 'pull_request' - ? 'git diff --name-only origin/main...HEAD' // Compare with base branch for PRs - : 'git diff --name-only HEAD~1 HEAD'; // Compare with previous commit for pushes - - const changedFilesOutput = execSync(gitCommand, { encoding: 'utf8' }); - const allChangedFiles = changedFilesOutput.trim().split('\n').filter(file => file.length > 0); - - const changedContentFiles = allChangedFiles.filter(file => - file.startsWith(`src/content/${contentType}/en`) && (file.endsWith('.mdx') || file.endsWith('.yaml')) - ); - - return changedContentFiles; - } catch (error) { - console.error('❌ Error getting changed files:', error.message); - return []; - } -} - -/** - * Scan all English files in a content directory (generalized for examples, tutorials, text-detail) - */ -function getAllEnglishContentFiles(contentType = 'examples') { - const contentPath = `src/content/${contentType}/en`; - const allFiles = []; - - try { - if (!fs.existsSync(contentPath)) { - console.log(`❌ Content path does not exist: ${contentPath}`); - return []; - } - - const scanDirectory = (dir) => { - const items = fs.readdirSync(dir); - items.forEach(item => { - const itemPath = path.join(dir, item); - if (fs.statSync(itemPath).isDirectory()) { - scanDirectory(itemPath); - } else if (item.endsWith('.mdx') || item.endsWith('.yaml')) { - allFiles.push(itemPath); - } - }); - }; - - scanDirectory(contentPath); - console.log(`📊 Found ${allFiles.length} English ${contentType} files to check`); - return allFiles; - } catch (error) { - console.error(`❌ Error scanning English ${contentType} files:`, error.message); - return []; - } -} - -function fileExists(filePath) { - try { - return fs.existsSync(filePath); - } catch (error) { - return false; - } -} - - -function getFileModTime(filePath) { - try { - return fs.statSync(filePath).mtime; - } catch (error) { - console.log(`⚠️ Could not get file timestamp for ${filePath}: ${error.message}`); - return null; - } -} - - -async function checkTranslationStatus(changedFiles, githubTracker = null, createIssues = false) { - const translationStatus = { - needsUpdate: [], - missing: [], - upToDate: [], - issuesCreated: [], - fileTranslationMap: new Map() - }; - - // Group translation issues by file to create single issues per file - const fileTranslationMap = translationStatus.fileTranslationMap; - - for (const englishFile of changedFiles) { - - let englishCommit = null; - if (githubTracker) { - englishCommit = await githubTracker.getLastCommit(englishFile); - if (!englishCommit) { - console.log(`⚠️ Skipping ${englishFile} - could not retrieve commit data`); - continue; - } - } - - const fileTranslations = { - englishFile, - outdatedLanguages: [], - missingLanguages: [], - upToDateLanguages: [], - englishCommit - }; - - for (const language of SUPPORTED_LANGUAGES) { - const translationPath = getTranslationPath(englishFile, language); - const exists = fileExists(translationPath); - - if (!exists) { - const missingItem = { - englishFile, - language, - translationPath, - status: 'missing' - }; - translationStatus.missing.push(missingItem); - fileTranslations.missingLanguages.push(missingItem); - continue; - } - - - if (githubTracker) { - const translationCommit = await githubTracker.getLastCommit(translationPath); - - if (!translationCommit) { - const missingItem = { - englishFile, - language, - translationPath, - status: 'missing' - }; - translationStatus.missing.push(missingItem); - fileTranslations.missingLanguages.push(missingItem); - continue; - } - - const isOutdated = englishCommit.date > translationCommit.date; - - if (isOutdated) { - const statusItem = { - englishFile, - language, - translationPath, - status: 'outdated', - commitInfo: { - english: englishCommit, - translation: translationCommit - } - }; - - translationStatus.needsUpdate.push(statusItem); - fileTranslations.outdatedLanguages.push(statusItem); - } else { - const upToDateItem = { - englishFile, - language, - translationPath, - status: 'up-to-date' - }; - translationStatus.upToDate.push(upToDateItem); - fileTranslations.upToDateLanguages.push(upToDateItem); - } - } else { - // Fallback to file modification time comparison - const englishModTime = getFileModTime(englishFile); - if (!englishModTime) { - console.log(` ⚠️ Could not get modification time for English file`); - continue; - } - - const translationModTime = getFileModTime(translationPath); - const isOutdated = translationModTime < englishModTime; - - if (isOutdated) { - const statusItem = { - englishFile, - language, - translationPath, - status: 'outdated', - englishModTime, - translationModTime - }; - translationStatus.needsUpdate.push(statusItem); - fileTranslations.outdatedLanguages.push(statusItem); - } else { - const upToDateItem = { - englishFile, - language, - translationPath, - status: 'up-to-date' - }; - translationStatus.upToDate.push(upToDateItem); - fileTranslations.upToDateLanguages.push(upToDateItem); - } - } - } - - // Store file translations for potential issue creation - if (fileTranslations.outdatedLanguages.length > 0 || fileTranslations.missingLanguages.length > 0) { - fileTranslationMap.set(englishFile, fileTranslations); - } - } - - // Create single issues per file (covering all affected languages) - if (createIssues && githubTracker) { - for (const [englishFile, fileTranslations] of fileTranslationMap) { - const issue = await githubTracker.createMultiLanguageTranslationIssue(fileTranslations); - if (issue) { - const issueItem = { - englishFile, - affectedLanguages: [ - ...fileTranslations.outdatedLanguages.map(l => l.language), - ...fileTranslations.missingLanguages.map(l => l.language) - ], - issueNumber: issue.number, - issueUrl: issue.html_url - }; - translationStatus.issuesCreated.push(issueItem); - } - } - } - - return translationStatus; -} - -/** - * Week 2: generate stub files and open one PR per language. - */ -async function runStubGeneration(githubTracker, options = {}) { - const languages = parseEnvList(process.env.STUB_LANGUAGES, SUPPORTED_LANGUAGES); - const contentTypes = parseEnvList(process.env.STUB_CONTENT_TYPES, ['reference']); - const fullScan = options.fullScan ?? process.env.STUB_FULL_SCAN === 'true'; - const dryRun = process.env.STUB_DRY_RUN === 'true'; - const maxFiles = parseInt(process.env.STUB_MAX_FILES || '50', 10); - - console.log(`\n📦 Stub generation mode`); - console.log(` Languages: ${languages.join(', ')}`); - console.log(` Content types: ${contentTypes.join(', ')}`); - console.log(` Scan: ${fullScan ? 'all English files' : 'changed files only'}`); - - const missing = findMissingTranslations(contentTypes, languages, { - fullScan, - testFiles: options.testFiles || null, - }); - - if (missing.length === 0) { - console.log('\n✅ No missing translation files found for stub generation.'); - return { prsCreated: [], stubsWritten: 0 }; - } - - console.log(`\n❌ Found ${missing.length} missing translation file(s):`); - missing.forEach((item) => { - console.log(` - ${item.englishFile} → ${item.language}`); - console.log(` Expected: ${item.translationPath}`); - }); - - const limited = missing.slice(0, maxFiles); - if (limited.length < missing.length) { - console.log(`\n⚠️ Limiting to ${maxFiles} stub(s) (STUB_MAX_FILES). Re-run to process more.`); - } - - const byLanguage = new Map(); - for (const item of limited) { - if (!byLanguage.has(item.language)) { - byLanguage.set(item.language, []); - } - byLanguage.get(item.language).push(item); - } - - const prsCreated = []; - let stubsWritten = 0; - - for (const [language, items] of byLanguage) { - const langName = githubTracker - ? githubTracker.getLanguageDisplayName(language) - : language; - - console.log(`\n📝 Generating ${items.length} stub(s) for ${langName}:`); - - const stubs = items.map((item) => { - const stub = generateStubFromEnglish(item.englishFile, language, item.contentType); - console.log(` 📄 ${item.englishFile} → ${stub.translationPath}`); - return stub; - }); - - if (dryRun || !githubTracker) { - const previewRoot = - process.env.STUB_OUTPUT_DIR || - path.join(process.cwd(), '.github/actions/translation-tracker/stub-preview'); - for (const stub of stubs) { - const writePath = getStubWritePath(stub.translationPath, true); - const dir = path.dirname(writePath); - if (!fs.existsSync(dir)) { - fs.mkdirSync(dir, { recursive: true }); - } - fs.writeFileSync(writePath, stub.content, 'utf8'); - stubsWritten += 1; - } - console.log(`\n🧪 Dry run: wrote ${stubs.length} stub file(s) under ${previewRoot}`); - continue; - } - - const pr = await githubTracker.createStubPullRequest(language, stubs); - if (pr) { - prsCreated.push({ - language, - prNumber: pr.number, - prUrl: pr.html_url, - fileCount: stubs.length, - }); - stubsWritten += stubs.length; - } - } - - if (prsCreated.length > 0) { - console.log(`\n🔀 Stub PRs created: ${prsCreated.length}`); - prsCreated.forEach((pr) => { - console.log(` - ${pr.language}: PR #${pr.prNumber} (${pr.fileCount} file(s))`); - console.log(` URL: ${pr.prUrl}`); - }); - } else if (!dryRun && stubsWritten === 0 && limited.length > 0) { - console.log(`\n💡 Stubs were not written. Check GITHUB_TOKEN permissions (contents + pull-requests write).`); - } - - return { prsCreated, stubsWritten }; -} - +const { SUPPORTED_LANGUAGES, CONTENT_TYPES } = require('./constants'); +const { getChangedFiles, getAllEnglishContentFiles, getSlugFromEnglishPath } = require('./utils'); +const { GitHubCommitTracker } = require('./github-tracker'); +const { + checkTranslationStatus, + runStubGeneration, + findMissingTranslations, + generateStubFromEnglish, + pickStubFrontmatter, +} = require('./workflows'); async function main(testFiles = null, options = {}) { const hasToken = !!process.env.GITHUB_TOKEN; - const isGitHubAction = !!process.env.GITHUB_ACTIONS; // Detect if running in GitHub Actions + const isGitHubAction = !!process.env.GITHUB_ACTIONS; const isProduction = hasToken && !testFiles; const generateStubsMode = process.env.GENERATE_STUBS === 'true'; - + if (generateStubsMode) { console.log(`📦 Stub generation: ${testFiles ? 'test files' : isGitHubAction ? 'changed files' : 'full scan'}`); } else if (testFiles) { @@ -1058,7 +27,6 @@ async function main(testFiles = null, options = {}) { console.log(`🔍 Manual run: Scanning all files`); } - // Initialize GitHub tracker if token is available let githubTracker = null; if (hasToken) { try { @@ -1070,7 +38,6 @@ async function main(testFiles = null, options = {}) { } } - // Week 2: stub-file PR generation (separate mode from issue tracking) if (generateStubsMode) { const dryRun = process.env.STUB_DRY_RUN === 'true'; if (!githubTracker && !dryRun) { @@ -1079,9 +46,7 @@ async function main(testFiles = null, options = {}) { return; } - const fullScan = - process.env.STUB_FULL_SCAN === 'true' || - (!isGitHubAction && !testFiles); + const fullScan = process.env.STUB_FULL_SCAN === 'true' || (!isGitHubAction && !testFiles); await runStubGeneration(githubTracker, { fullScan, testFiles }); return; @@ -1099,33 +64,29 @@ async function main(testFiles = null, options = {}) { console.log(`📊 Scanning all English ${contentType} files...`); filesToCheck = getAllEnglishContentFiles(contentType); } - + if (filesToCheck.length === 0) { continue; } - + console.log(`\n📝 Checking ${filesToCheck.length} English ${contentType} file(s):`); - filesToCheck.forEach(file => console.log(` - ${file}`)); + filesToCheck.forEach((file) => console.log(` - ${file}`)); const createIssues = isProduction && githubTracker !== null; - const translationStatus = await checkTranslationStatus( - filesToCheck, - githubTracker, - createIssues - ); - + const translationStatus = await checkTranslationStatus(filesToCheck, githubTracker, createIssues); + allTranslationStatus.push({ contentType, translationStatus }); const { needsUpdate, missing, upToDate, issuesCreated } = translationStatus; - + console.log(`\n📊 Translation Status Summary for ${contentType}:`); console.log(` 🔄 Outdated: ${needsUpdate.length}`); console.log(` ❌ Missing: ${missing.length}`); console.log(` ✅ Up-to-date: ${upToDate.length}`); - + if (needsUpdate.length > 0) { console.log(`\n🔄 Files needing translation updates:`); - needsUpdate.forEach(item => { + needsUpdate.forEach((item) => { const langName = githubTracker ? githubTracker.getLanguageDisplayName(item.language) : item.language; if (githubTracker && item.commitInfo) { console.log(` - ${item.englishFile} → ${langName}`); @@ -1140,21 +101,21 @@ async function main(testFiles = null, options = {}) { } }); } - + if (missing.length > 0) { console.log(`\n❌ Missing translation files:`); - missing.forEach(item => { + missing.forEach((item) => { const langName = githubTracker ? githubTracker.getLanguageDisplayName(item.language) : item.language; console.log(` - ${item.englishFile} → ${langName}`); console.log(` Expected: ${item.translationPath}`); }); } - + if (issuesCreated.length > 0) { console.log(`\n🎫 GitHub issues created: ${issuesCreated.length}`); - issuesCreated.forEach(issue => { + issuesCreated.forEach((issue) => { console.log(` - Issue #${issue.issueNumber}: ${issue.englishFile}`); - console.log(` Languages: ${issue.affectedLanguages.map(lang => githubTracker.getLanguageDisplayName(lang)).join(', ')}`); + console.log(` Languages: ${issue.affectedLanguages.map((lang) => githubTracker.getLanguageDisplayName(lang)).join(', ')}`); console.log(` URL: ${issue.issueUrl}`); }); } else if (needsUpdate.length > 0 || missing.length > 0) { @@ -1162,12 +123,11 @@ async function main(testFiles = null, options = {}) { console.log(`\n💡 Run with GITHUB_TOKEN to create GitHub issues`); } } - + if (needsUpdate.length === 0 && missing.length === 0) { console.log(`\n✅ All ${contentType} translations are up to date!`); } - // Write manifest JSON for the site to consume try { const manifestDir = path.join(process.cwd(), 'public', 'translation-status'); const manifestPath = path.join(manifestDir, `${contentType}.json`); @@ -1178,9 +138,9 @@ async function main(testFiles = null, options = {}) { for (const [englishFile, fileTranslations] of translationStatus.fileTranslationMap) { const slug = getSlugFromEnglishPath(englishFile, contentType); if (!slug) continue; - const outdated = fileTranslations.outdatedLanguages.map(l => l.language); - const missingLangs = fileTranslations.missingLanguages.map(l => l.language); - const upToDateLangs = fileTranslations.upToDateLanguages.map(l => l.language); + const outdated = fileTranslations.outdatedLanguages.map((l) => l.language); + const missingLangs = fileTranslations.missingLanguages.map((l) => l.language); + const upToDateLangs = fileTranslations.upToDateLanguages.map((l) => l.language); content[slug] = { englishFile, outdated, @@ -1202,7 +162,6 @@ async function main(testFiles = null, options = {}) { } } -// Export for testing (simplified) module.exports = { main, getChangedFiles, @@ -1214,10 +173,9 @@ module.exports = { runStubGeneration, GitHubCommitTracker, SUPPORTED_LANGUAGES, - CONTENT_TYPES + CONTENT_TYPES, }; -// Run if called directly if (require.main === module) { main(); } diff --git a/.github/actions/translation-tracker/package-lock.json b/.github/actions/translation-tracker/package-lock.json index c99f32cf66..2784e337f7 100644 --- a/.github/actions/translation-tracker/package-lock.json +++ b/.github/actions/translation-tracker/package-lock.json @@ -11,7 +11,8 @@ "dependencies": { "@actions/core": "^1.10.0", "@actions/github": "^5.1.1", - "@octokit/rest": "^19.0.5" + "@octokit/rest": "^19.0.5", + "js-yaml": "^4.1.0" }, "engines": { "node": ">=18.0.0" @@ -339,6 +340,12 @@ "@octokit/openapi-types": "^12.11.0" } }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "license": "Python-2.0" + }, "node_modules/before-after-hook": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", @@ -357,6 +364,28 @@ "node": ">=0.10.0" } }, + "node_modules/js-yaml": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.0.tgz", + "integrity": "sha512-1td788aAnnZ5qs7V2QIRl1owjtYpbKt749Y3xauqQgwIIGF/xXWz1wMTEBx5O3LK3lXLVuqXPdPxj2BoFHaW9Q==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, "node_modules/node-fetch": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", diff --git a/.github/actions/translation-tracker/utils.js b/.github/actions/translation-tracker/utils.js new file mode 100644 index 0000000000..e5b5f53897 --- /dev/null +++ b/.github/actions/translation-tracker/utils.js @@ -0,0 +1,239 @@ +const { execSync } = require('child_process'); +const fs = require('fs'); +const path = require('path'); +const https = require('https'); +const yaml = require('js-yaml'); + +function getTranslationPath(englishFilePath, language) { + if (!englishFilePath.includes('/en/')) { + throw new Error(`Invalid English file path: ${englishFilePath}. Must contain '/en/'`); + } + + const pathParts = englishFilePath.split('/'); + const enIndex = pathParts.findIndex((part) => part === 'en'); + + if (enIndex === -1) { + throw new Error(`Could not find 'en' directory in path: ${englishFilePath}`); + } + + const translationParts = [...pathParts]; + translationParts[enIndex] = language; + + return translationParts.join('/'); +} + +function getSlugFromEnglishPath(englishFilePath, contentType) { + const prefix = `src/content/${contentType}/en/`; + if (!englishFilePath.startsWith(prefix)) return null; + let relative = englishFilePath.substring(prefix.length); + + if (relative.endsWith('/description.mdx')) { + relative = relative.slice(0, -'/description.mdx'.length); + } else if (relative.endsWith('.mdx')) { + relative = relative.slice(0, -'.mdx'.length); + } else if (relative.endsWith('.yaml')) { + relative = relative.slice(0, -'.yaml'.length); + } + return relative; +} + +function parseEnvList(envValue, defaultList) { + if (!envValue || envValue.trim() === '') { + return defaultList; + } + return envValue.split(',').map((item) => item.trim()).filter(Boolean); +} + +function fileExists(filePath) { + try { + return fs.existsSync(filePath); + } catch (error) { + return false; + } +} + +function getFileModTime(filePath) { + try { + return fs.statSync(filePath).mtime; + } catch (error) { + console.log(`⚠️ Could not get file timestamp for ${filePath}: ${error.message}`); + return null; + } +} + +function parseFrontmatter(raw, filePath) { + const frontmatterMatch = raw.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/); + if (!frontmatterMatch) { + throw new Error(`Could not find frontmatter in ${filePath}`); + } + + return yaml.load(frontmatterMatch[1]) || {}; +} + +function stringifyMdx(frontmatter, body) { + const frontmatterText = yaml.dump(frontmatter, { + lineWidth: 100, + noRefs: true, + sortKeys: false, + }); + + return `---\n${frontmatterText}---\n${body}`; +} + +/** Where dry-run stubs are written locally (never touches src/content by default). */ +function getStubWritePath(translationPath, dryRun) { + if (!dryRun) { + return translationPath; + } + const outputRoot = + process.env.STUB_OUTPUT_DIR || + path.join(process.cwd(), '.github/actions/translation-tracker/stub-preview'); + return path.join(outputRoot, translationPath); +} + +function getChangedFiles(testFiles = null, contentType = 'examples') { + if (testFiles) { + console.log('🧪 Using provided test files for local testing'); + return testFiles.filter( + (file) => + file.startsWith(`src/content/${contentType}/en`) && + (file.endsWith('.mdx') || file.endsWith('.yaml')) + ); + } + + try { + const gitCommand = + process.env.GITHUB_EVENT_NAME === 'pull_request' + ? 'git diff --name-only origin/main...HEAD' + : 'git diff --name-only HEAD~1 HEAD'; + + const changedFilesOutput = execSync(gitCommand, { encoding: 'utf8' }); + const allChangedFiles = changedFilesOutput.trim().split('\n').filter((file) => file.length > 0); + + return allChangedFiles.filter( + (file) => + file.startsWith(`src/content/${contentType}/en`) && + (file.endsWith('.mdx') || file.endsWith('.yaml')) + ); + } catch (error) { + console.error('❌ Error getting changed files:', error.message); + return []; + } +} + +function getAllEnglishContentFiles(contentType = 'examples') { + const contentPath = `src/content/${contentType}/en`; + const allFiles = []; + + try { + if (!fs.existsSync(contentPath)) { + console.log(`❌ Content path does not exist: ${contentPath}`); + return []; + } + + const scanDirectory = (dir) => { + const items = fs.readdirSync(dir); + items.forEach((item) => { + const itemPath = path.join(dir, item); + if (fs.statSync(itemPath).isDirectory()) { + scanDirectory(itemPath); + } else if (item.endsWith('.mdx') || item.endsWith('.yaml')) { + allFiles.push(itemPath); + } + }); + }; + + scanDirectory(contentPath); + console.log(`📊 Found ${allFiles.length} English ${contentType} files to check`); + return allFiles; + } catch (error) { + console.error(`❌ Error scanning English ${contentType} files:`, error.message); + return []; + } +} + +async function loadStewardsConfig() { + const STEWARDS_URL = 'https://raw.githubusercontent.com/processing/p5.js/main/stewards.yml'; + + return new Promise((resolve) => { + https + .get(STEWARDS_URL, (res) => { + let data = ''; + + res.on('data', (chunk) => { + data += chunk; + }); + + res.on('end', () => { + try { + const config = yaml.load(data); + console.log('Successfully loaded stewards config from p5.js repository'); + resolve(config); + } catch (error) { + console.log(`Could not parse stewards config: ${error.message}`); + resolve(null); + } + }); + }) + .on('error', (error) => { + console.log(` Could not load stewards config from remote: ${error.message}`); + resolve(null); + }); + }); +} + +function getStewardsForLanguage(stewardsConfig, language) { + if (!stewardsConfig) return []; + + const languageMap = { + 'zh-Hans': 'zh', + hi: 'hi', + ko: 'ko', + es: 'es', + }; + + const stewardsLangCode = languageMap[language] || language; + const stewards = []; + + for (const [username, areas] of Object.entries(stewardsConfig)) { + if (!Array.isArray(areas)) continue; + + for (const area of areas) { + if (typeof area === 'object' && area.i18n) { + const languages = area.i18n; + if (Array.isArray(languages) && languages.includes(stewardsLangCode)) { + stewards.push(`@${username}`); + break; + } + } + } + } + + return stewards; +} + +function getLanguageDisplayName(langCode) { + const languages = { + es: 'Spanish (Español)', + hi: 'Hindi (हिन्दी)', + ko: 'Korean (한국어)', + 'zh-Hans': 'Chinese Simplified (简体中文)', + }; + return languages[langCode] || langCode; +} + +module.exports = { + getTranslationPath, + getSlugFromEnglishPath, + parseEnvList, + fileExists, + getFileModTime, + parseFrontmatter, + stringifyMdx, + getStubWritePath, + getChangedFiles, + getAllEnglishContentFiles, + loadStewardsConfig, + getStewardsForLanguage, + getLanguageDisplayName, +}; diff --git a/.github/actions/translation-tracker/workflows.js b/.github/actions/translation-tracker/workflows.js new file mode 100644 index 0000000000..43f8d6efc8 --- /dev/null +++ b/.github/actions/translation-tracker/workflows.js @@ -0,0 +1,345 @@ +const fs = require('fs'); +const path = require('path'); +const { SUPPORTED_LANGUAGES, STUB_FRONTMATTER_KEYS } = require('./constants'); +const { + getTranslationPath, + parseEnvList, + fileExists, + getFileModTime, + parseFrontmatter, + stringifyMdx, + getStubWritePath, + getChangedFiles, + getAllEnglishContentFiles, + getLanguageDisplayName, +} = require('./utils'); + +/** + * Find English content files that have no translation file yet. + * Used for stub-file generation (Week 2). + */ +function findMissingTranslations(contentTypes, languages, options = {}) { + const { fullScan = false, testFiles = null } = options; + const missing = []; + + for (const contentType of contentTypes) { + let englishFiles; + if (testFiles) { + englishFiles = testFiles.filter( + (file) => + file.startsWith(`src/content/${contentType}/en/`) && + (file.endsWith('.mdx') || file.endsWith('.yaml')) + ); + } else if (fullScan) { + englishFiles = getAllEnglishContentFiles(contentType); + } else if (process.env.GITHUB_ACTIONS) { + englishFiles = getChangedFiles(null, contentType); + } else { + englishFiles = getAllEnglishContentFiles(contentType); + } + + for (const englishFile of englishFiles) { + for (const language of languages) { + const translationPath = getTranslationPath(englishFile, language); + if (!fileExists(translationPath)) { + missing.push({ englishFile, language, translationPath, contentType }); + } + } + } + } + + missing.sort((a, b) => a.translationPath.localeCompare(b.translationPath)); + return missing; +} + +function pickStubFrontmatter(frontmatter, contentType) { + const keys = STUB_FRONTMATTER_KEYS[contentType] || ['title', 'description']; + const picked = { needsTranslation: true }; + for (const key of keys) { + if (frontmatter[key] !== undefined) { + picked[key] = frontmatter[key]; + } + } + return picked; +} + +/** + * Build a placeholder translation file from an English source. + * Copies essential frontmatter (in English), sets needsTranslation: true, minimal body. + */ +function generateStubFromEnglish(englishPath, language, contentType = 'reference') { + const raw = fs.readFileSync(englishPath, 'utf8'); + const frontmatter = parseFrontmatter(raw, englishPath); + const translationPath = getTranslationPath(englishPath, language); + + const stubFrontmatter = pickStubFrontmatter(frontmatter, contentType); + + const stubComment = ``; + + const stubBody = `${stubComment} + + +`; + + const content = stringifyMdx(stubFrontmatter, stubBody); + + return { translationPath, content, englishPath }; +} + +async function checkTranslationStatus(changedFiles, githubTracker = null, createIssues = false) { + const translationStatus = { + needsUpdate: [], + missing: [], + upToDate: [], + issuesCreated: [], + fileTranslationMap: new Map(), + }; + + const fileTranslationMap = translationStatus.fileTranslationMap; + + for (const englishFile of changedFiles) { + let englishCommit = null; + if (githubTracker) { + englishCommit = await githubTracker.getLastCommit(englishFile); + if (!englishCommit) { + console.log(`⚠️ Skipping ${englishFile} - could not retrieve commit data`); + continue; + } + } + + const fileTranslations = { + englishFile, + outdatedLanguages: [], + missingLanguages: [], + upToDateLanguages: [], + englishCommit, + }; + + for (const language of SUPPORTED_LANGUAGES) { + const translationPath = getTranslationPath(englishFile, language); + const exists = fileExists(translationPath); + + if (!exists) { + const missingItem = { + englishFile, + language, + translationPath, + status: 'missing', + }; + translationStatus.missing.push(missingItem); + fileTranslations.missingLanguages.push(missingItem); + continue; + } + + if (githubTracker) { + const translationCommit = await githubTracker.getLastCommit(translationPath); + + if (!translationCommit) { + const missingItem = { + englishFile, + language, + translationPath, + status: 'missing', + }; + translationStatus.missing.push(missingItem); + fileTranslations.missingLanguages.push(missingItem); + continue; + } + + const isOutdated = englishCommit.date > translationCommit.date; + + if (isOutdated) { + const statusItem = { + englishFile, + language, + translationPath, + status: 'outdated', + commitInfo: { + english: englishCommit, + translation: translationCommit, + }, + }; + + translationStatus.needsUpdate.push(statusItem); + fileTranslations.outdatedLanguages.push(statusItem); + } else { + const upToDateItem = { + englishFile, + language, + translationPath, + status: 'up-to-date', + }; + translationStatus.upToDate.push(upToDateItem); + fileTranslations.upToDateLanguages.push(upToDateItem); + } + } else { + const englishModTime = getFileModTime(englishFile); + if (!englishModTime) { + console.log(` ⚠️ Could not get modification time for English file`); + continue; + } + + const translationModTime = getFileModTime(translationPath); + const isOutdated = translationModTime < englishModTime; + + if (isOutdated) { + const statusItem = { + englishFile, + language, + translationPath, + status: 'outdated', + englishModTime, + translationModTime, + }; + translationStatus.needsUpdate.push(statusItem); + fileTranslations.outdatedLanguages.push(statusItem); + } else { + const upToDateItem = { + englishFile, + language, + translationPath, + status: 'up-to-date', + }; + translationStatus.upToDate.push(upToDateItem); + fileTranslations.upToDateLanguages.push(upToDateItem); + } + } + } + + if (fileTranslations.outdatedLanguages.length > 0 || fileTranslations.missingLanguages.length > 0) { + fileTranslationMap.set(englishFile, fileTranslations); + } + } + + if (createIssues && githubTracker) { + for (const [, fileTranslations] of fileTranslationMap) { + const issue = await githubTracker.createMultiLanguageTranslationIssue(fileTranslations); + if (issue) { + const issueItem = { + englishFile: fileTranslations.englishFile, + affectedLanguages: [ + ...fileTranslations.outdatedLanguages.map((l) => l.language), + ...fileTranslations.missingLanguages.map((l) => l.language), + ], + issueNumber: issue.number, + issueUrl: issue.html_url, + }; + translationStatus.issuesCreated.push(issueItem); + } + } + } + + return translationStatus; +} + +/** + * Week 2: generate stub files and open one PR per language. + */ +async function runStubGeneration(githubTracker, options = {}) { + const languages = parseEnvList(process.env.STUB_LANGUAGES, SUPPORTED_LANGUAGES); + const contentTypes = parseEnvList(process.env.STUB_CONTENT_TYPES, ['reference']); + const fullScan = options.fullScan ?? process.env.STUB_FULL_SCAN === 'true'; + const dryRun = process.env.STUB_DRY_RUN === 'true'; + const maxFiles = parseInt(process.env.STUB_MAX_FILES || '50', 10); + + console.log(`\n📦 Stub generation mode`); + console.log(` Languages: ${languages.join(', ')}`); + console.log(` Content types: ${contentTypes.join(', ')}`); + console.log(` Scan: ${fullScan ? 'all English files' : 'changed files only'}`); + + const missing = findMissingTranslations(contentTypes, languages, { + fullScan, + testFiles: options.testFiles || null, + }); + + if (missing.length === 0) { + console.log('\n✅ No missing translation files found for stub generation.'); + return { prsCreated: [], stubsWritten: 0 }; + } + + console.log(`\n❌ Found ${missing.length} missing translation file(s):`); + missing.forEach((item) => { + console.log(` - ${item.englishFile} → ${item.language}`); + console.log(` Expected: ${item.translationPath}`); + }); + + const limited = missing.slice(0, maxFiles); + if (limited.length < missing.length) { + console.log(`\n⚠️ Limiting to ${maxFiles} stub(s) (STUB_MAX_FILES). Re-run to process more.`); + } + + const byLanguage = new Map(); + for (const item of limited) { + if (!byLanguage.has(item.language)) { + byLanguage.set(item.language, []); + } + byLanguage.get(item.language).push(item); + } + + const prsCreated = []; + let stubsWritten = 0; + + for (const [language, items] of byLanguage) { + const langName = githubTracker ? githubTracker.getLanguageDisplayName(language) : getLanguageDisplayName(language); + + console.log(`\n📝 Generating ${items.length} stub(s) for ${langName}:`); + + const stubs = items.map((item) => { + const stub = generateStubFromEnglish(item.englishFile, language, item.contentType); + console.log(` 📄 ${item.englishFile} → ${stub.translationPath}`); + return stub; + }); + + if (dryRun || !githubTracker) { + const previewRoot = + process.env.STUB_OUTPUT_DIR || + path.join(process.cwd(), '.github/actions/translation-tracker/stub-preview'); + for (const stub of stubs) { + const writePath = getStubWritePath(stub.translationPath, true); + const dir = path.dirname(writePath); + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir, { recursive: true }); + } + fs.writeFileSync(writePath, stub.content, 'utf8'); + stubsWritten += 1; + } + console.log(`\n🧪 Dry run: wrote ${stubs.length} stub file(s) under ${previewRoot}`); + continue; + } + + const pr = await githubTracker.createStubPullRequest(language, stubs); + if (pr) { + prsCreated.push({ + language, + prNumber: pr.number, + prUrl: pr.html_url, + fileCount: stubs.length, + }); + stubsWritten += stubs.length; + } + } + + if (prsCreated.length > 0) { + console.log(`\n🔀 Stub PRs created: ${prsCreated.length}`); + prsCreated.forEach((pr) => { + console.log(` - ${pr.language}: PR #${pr.prNumber} (${pr.fileCount} file(s))`); + console.log(` URL: ${pr.prUrl}`); + }); + } else if (!dryRun && stubsWritten === 0 && limited.length > 0) { + console.log(`\n💡 Stubs were not written. Check GITHUB_TOKEN permissions (contents + pull-requests write).`); + } + + return { prsCreated, stubsWritten }; +} + +module.exports = { + findMissingTranslations, + pickStubFrontmatter, + generateStubFromEnglish, + checkTranslationStatus, + runStubGeneration, +}; diff --git a/src/content/reference/en/16_New_file_testing/hi.mdx b/src/content/reference/en/16_New_file_testing/hi.mdx deleted file mode 100644 index 8f387301de..0000000000 --- a/src/content/reference/en/16_New_file_testing/hi.mdx +++ /dev/null @@ -1,36 +0,0 @@ ---- -featuredImage: "../../../images/featured/15_Math_And_Physics-00_Non_Orthogonal_Reflection-thumbnail.png" -featuredImageAlt: A small green circle hovering over a yellow tilted plane at the bottom of the canvas. -title: Non-Orthogonal Reflection -oneLineDescription: Simulate a ball bouncing on a slanted surface. - -remix: - - description: Based on - attribution: - - name: Processing example by Ira Greenberg - URL: https://processing.org/examples/reflection1.html - - description: Ported by - attribution: - - name: David Blitz - - description: Revised by - attribution: - - name: Darren Kessner - URL: https://github.com/dkessner - code: - - label: 2023 code - URL: https://github.com/processing/p5.js-example/tree/main/examples/15_Math_And_Physics/00_Non_Orthogonal_Reflection - - collectivelyAttributedSince: 2024 ---- - -This example demonstrates a ball bouncing on a slanted -surface, implemented using vector calculations for reflection. - -The code makes extensive use of the -p5.Vector -class, including the -createVector() function to create new vectors, -and the vector methods -add() -and -dot() -for the vector calculations. \ No newline at end of file From 1d3a309bd3225bf9f9d8a67ab3dd888d6baee6f5 Mon Sep 17 00:00:00 2001 From: Aashish Panthi Date: Mon, 29 Jun 2026 23:33:32 +0545 Subject: [PATCH 13/16] test by changing files --- src/content/reference/en/p5 copy/abs.mdx | 61 ++ .../reference/en/p5 copy/accelerationX.mdx | 37 + .../reference/en/p5 copy/accelerationY.mdx | 37 + .../reference/en/p5 copy/accelerationZ.mdx | 37 + src/content/reference/en/p5 copy/acos.mdx | 86 ++ src/content/reference/en/p5 copy/alpha.mdx | 120 +++ .../reference/en/p5 copy/ambientLight.mdx | 241 ++++++ .../reference/en/p5 copy/ambientMaterial.mdx | 269 ++++++ .../reference/en/p5 copy/angleMode.mdx | 219 +++++ src/content/reference/en/p5 copy/append.mdx | 48 ++ .../reference/en/p5 copy/applyMatrix.mdx | 347 ++++++++ src/content/reference/en/p5 copy/arc.mdx | 274 ++++++ .../reference/en/p5 copy/arrayCopy.mdx | 95 +++ src/content/reference/en/p5 copy/asin.mdx | 86 ++ src/content/reference/en/p5 copy/atan.mdx | 86 ++ src/content/reference/en/p5 copy/atan2.mdx | 106 +++ .../reference/en/p5 copy/background.mdx | 336 ++++++++ .../reference/en/p5 copy/baseColorShader.mdx | 178 ++++ .../en/p5 copy/baseMaterialShader.mdx | 418 +++++++++ .../reference/en/p5 copy/baseNormalShader.mdx | 211 +++++ .../reference/en/p5 copy/baseStrokeShader.mdx | 356 ++++++++ .../reference/en/p5 copy/beginClip.mdx | 208 +++++ .../reference/en/p5 copy/beginContour.mdx | 134 +++ .../reference/en/p5 copy/beginGeometry.mdx | 281 +++++++ .../reference/en/p5 copy/beginShape.mdx | 449 ++++++++++ src/content/reference/en/p5 copy/bezier.mdx | 273 ++++++ .../reference/en/p5 copy/bezierDetail.mdx | 121 +++ .../reference/en/p5 copy/bezierPoint.mdx | 162 ++++ .../reference/en/p5 copy/bezierTangent.mdx | 155 ++++ .../reference/en/p5 copy/bezierVertex.mdx | 337 ++++++++ src/content/reference/en/p5 copy/blend.mdx | 214 +++++ .../reference/en/p5 copy/blendMode.mdx | 541 ++++++++++++ src/content/reference/en/p5 copy/blue.mdx | 158 ++++ src/content/reference/en/p5 copy/boolean.mdx | 157 ++++ src/content/reference/en/p5 copy/box.mdx | 186 ++++ .../reference/en/p5 copy/brightness.mdx | 168 ++++ .../reference/en/p5 copy/buildGeometry.mdx | 263 ++++++ src/content/reference/en/p5 copy/byte.mdx | 180 ++++ src/content/reference/en/p5 copy/camera.mdx | 200 +++++ src/content/reference/en/p5 copy/ceil.mdx | 65 ++ src/content/reference/en/p5 copy/changed.mdx | 87 ++ src/content/reference/en/p5 copy/char.mdx | 152 ++++ src/content/reference/en/p5 copy/circle.mdx | 77 ++ src/content/reference/en/p5 copy/class.mdx | 19 + src/content/reference/en/p5 copy/clear.mdx | 108 +++ .../reference/en/p5 copy/clearDepth.mdx | 113 +++ .../reference/en/p5 copy/clearStorage.mdx | 81 ++ src/content/reference/en/p5 copy/clip.mdx | 225 +++++ src/content/reference/en/p5 copy/color.mdx | 349 ++++++++ .../reference/en/p5 copy/colorMode.mdx | 271 ++++++ src/content/reference/en/p5 copy/concat.mdx | 54 ++ src/content/reference/en/p5 copy/cone.mdx | 265 ++++++ src/content/reference/en/p5 copy/console.mdx | 99 +++ .../reference/en/p5 copy/constants/ADD.mdx | 18 + .../reference/en/p5 copy/constants/ALT.mdx | 18 + .../reference/en/p5 copy/constants/ARROW.mdx | 18 + .../reference/en/p5 copy/constants/AUTO.mdx | 25 + .../reference/en/p5 copy/constants/AXES.mdx | 18 + .../en/p5 copy/constants/BACKSPACE.mdx | 18 + .../en/p5 copy/constants/BASELINE.mdx | 18 + .../reference/en/p5 copy/constants/BEVEL.mdx | 18 + .../reference/en/p5 copy/constants/BEZIER.mdx | 18 + .../reference/en/p5 copy/constants/BLEND.mdx | 18 + .../reference/en/p5 copy/constants/BLUR.mdx | 18 + .../reference/en/p5 copy/constants/BOLD.mdx | 18 + .../en/p5 copy/constants/BOLDITALIC.mdx | 18 + .../reference/en/p5 copy/constants/BOTTOM.mdx | 18 + .../reference/en/p5 copy/constants/BURN.mdx | 18 + .../reference/en/p5 copy/constants/CENTER.mdx | 18 + .../reference/en/p5 copy/constants/CHAR.mdx | 18 + .../reference/en/p5 copy/constants/CHORD.mdx | 18 + .../reference/en/p5 copy/constants/CLAMP.mdx | 18 + .../reference/en/p5 copy/constants/CLOSE.mdx | 18 + .../en/p5 copy/constants/CONTAIN.mdx | 18 + .../en/p5 copy/constants/CONTROL.mdx | 18 + .../reference/en/p5 copy/constants/CORNER.mdx | 18 + .../en/p5 copy/constants/CORNERS.mdx | 18 + .../reference/en/p5 copy/constants/COVER.mdx | 18 + .../reference/en/p5 copy/constants/CROSS.mdx | 18 + .../reference/en/p5 copy/constants/CURVE.mdx | 18 + .../en/p5 copy/constants/DARKEST.mdx | 18 + .../en/p5 copy/constants/DEGREES.mdx | 59 ++ .../reference/en/p5 copy/constants/DELETE.mdx | 18 + .../en/p5 copy/constants/DIFFERENCE.mdx | 18 + .../reference/en/p5 copy/constants/DILATE.mdx | 18 + .../reference/en/p5 copy/constants/DODGE.mdx | 18 + .../en/p5 copy/constants/DOWN_ARROW.mdx | 18 + .../reference/en/p5 copy/constants/ENTER.mdx | 18 + .../reference/en/p5 copy/constants/ERODE.mdx | 18 + .../reference/en/p5 copy/constants/ESCAPE.mdx | 18 + .../en/p5 copy/constants/EXCLUSION.mdx | 18 + .../en/p5 copy/constants/FALLBACK.mdx | 18 + .../reference/en/p5 copy/constants/FILL.mdx | 18 + .../reference/en/p5 copy/constants/FLAT.mdx | 18 + .../reference/en/p5 copy/constants/FLOAT.mdx | 18 + .../reference/en/p5 copy/constants/GRAY.mdx | 18 + .../reference/en/p5 copy/constants/GRID.mdx | 18 + .../en/p5 copy/constants/HALF_FLOAT.mdx | 18 + .../en/p5 copy/constants/HALF_PI.mdx | 109 +++ .../reference/en/p5 copy/constants/HAND.mdx | 18 + .../en/p5 copy/constants/HARD_LIGHT.mdx | 18 + .../reference/en/p5 copy/constants/HSB.mdx | 24 + .../reference/en/p5 copy/constants/HSL.mdx | 18 + .../reference/en/p5 copy/constants/IMAGE.mdx | 18 + .../en/p5 copy/constants/IMMEDIATE.mdx | 18 + .../reference/en/p5 copy/constants/INVERT.mdx | 18 + .../reference/en/p5 copy/constants/ITALIC.mdx | 18 + .../reference/en/p5 copy/constants/LABEL.mdx | 18 + .../en/p5 copy/constants/LANDSCAPE.mdx | 18 + .../reference/en/p5 copy/constants/LEFT.mdx | 18 + .../en/p5 copy/constants/LEFT_ARROW.mdx | 18 + .../en/p5 copy/constants/LIGHTEST.mdx | 18 + .../reference/en/p5 copy/constants/LINEAR.mdx | 18 + .../reference/en/p5 copy/constants/LINES.mdx | 18 + .../en/p5 copy/constants/LINE_LOOP.mdx | 18 + .../en/p5 copy/constants/LINE_STRIP.mdx | 18 + .../reference/en/p5 copy/constants/MIRROR.mdx | 18 + .../reference/en/p5 copy/constants/MITER.mdx | 18 + .../reference/en/p5 copy/constants/MOVE.mdx | 18 + .../en/p5 copy/constants/MULTIPLY.mdx | 18 + .../en/p5 copy/constants/NEAREST.mdx | 18 + .../reference/en/p5 copy/constants/NORMAL.mdx | 18 + .../reference/en/p5 copy/constants/OPAQUE.mdx | 18 + .../reference/en/p5 copy/constants/OPEN.mdx | 18 + .../reference/en/p5 copy/constants/OPTION.mdx | 18 + .../en/p5 copy/constants/OVERLAY.mdx | 18 + .../reference/en/p5 copy/constants/P2D.mdx | 19 + .../reference/en/p5 copy/constants/PI.mdx | 108 +++ .../reference/en/p5 copy/constants/PIE.mdx | 18 + .../reference/en/p5 copy/constants/POINTS.mdx | 18 + .../en/p5 copy/constants/PORTRAIT.mdx | 18 + .../en/p5 copy/constants/POSTERIZE.mdx | 18 + .../en/p5 copy/constants/PROJECT.mdx | 18 + .../en/p5 copy/constants/QUADRATIC.mdx | 18 + .../reference/en/p5 copy/constants/QUADS.mdx | 18 + .../en/p5 copy/constants/QUAD_STRIP.mdx | 18 + .../en/p5 copy/constants/QUARTER_PI.mdx | 109 +++ .../en/p5 copy/constants/RADIANS.mdx | 66 ++ .../reference/en/p5 copy/constants/RADIUS.mdx | 18 + .../reference/en/p5 copy/constants/REMOVE.mdx | 18 + .../reference/en/p5 copy/constants/REPEAT.mdx | 18 + .../en/p5 copy/constants/REPLACE.mdx | 18 + .../reference/en/p5 copy/constants/RETURN.mdx | 18 + .../reference/en/p5 copy/constants/RGB.mdx | 18 + .../reference/en/p5 copy/constants/RGBA.mdx | 18 + .../reference/en/p5 copy/constants/RIGHT.mdx | 18 + .../en/p5 copy/constants/RIGHT_ARROW.mdx | 18 + .../reference/en/p5 copy/constants/ROUND.mdx | 18 + .../reference/en/p5 copy/constants/SCREEN.mdx | 18 + .../reference/en/p5 copy/constants/SHIFT.mdx | 18 + .../reference/en/p5 copy/constants/SMOOTH.mdx | 18 + .../en/p5 copy/constants/SOFT_LIGHT.mdx | 18 + .../reference/en/p5 copy/constants/SQUARE.mdx | 18 + .../reference/en/p5 copy/constants/STROKE.mdx | 18 + .../en/p5 copy/constants/SUBTRACT.mdx | 18 + .../reference/en/p5 copy/constants/TAB.mdx | 18 + .../reference/en/p5 copy/constants/TAU.mdx | 114 +++ .../reference/en/p5 copy/constants/TESS.mdx | 18 + .../reference/en/p5 copy/constants/TEXT.mdx | 18 + .../en/p5 copy/constants/TEXTURE.mdx | 18 + .../en/p5 copy/constants/THRESHOLD.mdx | 18 + .../reference/en/p5 copy/constants/TOP.mdx | 18 + .../en/p5 copy/constants/TRIANGLES.mdx | 18 + .../en/p5 copy/constants/TRIANGLE_FAN.mdx | 18 + .../en/p5 copy/constants/TRIANGLE_STRIP.mdx | 18 + .../reference/en/p5 copy/constants/TWO_PI.mdx | 114 +++ .../en/p5 copy/constants/UNSIGNED_BYTE.mdx | 18 + .../en/p5 copy/constants/UNSIGNED_INT.mdx | 18 + .../en/p5 copy/constants/UP_ARROW.mdx | 18 + .../en/p5 copy/constants/VERSION.mdx | 19 + .../reference/en/p5 copy/constants/WAIT.mdx | 18 + .../reference/en/p5 copy/constants/WEBGL.mdx | 91 ++ .../reference/en/p5 copy/constants/WEBGL2.mdx | 21 + .../reference/en/p5 copy/constants/WORD.mdx | 18 + .../reference/en/p5 copy/constrain.mdx | 86 ++ src/content/reference/en/p5 copy/copy.mdx | 144 ++++ src/content/reference/en/p5 copy/cos.mdx | 107 +++ src/content/reference/en/p5 copy/createA.mdx | 93 ++ .../reference/en/p5 copy/createAudio.mdx | 83 ++ .../reference/en/p5 copy/createButton.mdx | 109 +++ .../reference/en/p5 copy/createCamera.mdx | 99 +++ .../reference/en/p5 copy/createCanvas.mdx | 191 +++++ .../reference/en/p5 copy/createCapture.mdx | 189 +++++ .../reference/en/p5 copy/createCheckbox.mdx | 131 +++ .../en/p5 copy/createColorPicker.mdx | 101 +++ .../reference/en/p5 copy/createConvolver.mdx | 78 ++ .../reference/en/p5 copy/createDiv.mdx | 72 ++ .../reference/en/p5 copy/createElement.mdx | 78 ++ .../reference/en/p5 copy/createFileInput.mdx | 138 +++ .../en/p5 copy/createFilterShader.mdx | 148 ++++ .../en/p5 copy/createFramebuffer.mdx | 208 +++++ .../reference/en/p5 copy/createGraphics.mdx | 191 +++++ .../reference/en/p5 copy/createImage.mdx | 172 ++++ .../reference/en/p5 copy/createImg.mdx | 115 +++ .../reference/en/p5 copy/createInput.mdx | 118 +++ .../reference/en/p5 copy/createModel.mdx | 193 +++++ .../reference/en/p5 copy/createNumberDict.mdx | 57 ++ src/content/reference/en/p5 copy/createP.mdx | 54 ++ .../reference/en/p5 copy/createRadio.mdx | 223 +++++ .../reference/en/p5 copy/createSelect.mdx | 235 ++++++ .../reference/en/p5 copy/createShader.mdx | 438 ++++++++++ .../reference/en/p5 copy/createSlider.mdx | 162 ++++ .../reference/en/p5 copy/createSpan.mdx | 93 ++ .../reference/en/p5 copy/createStringDict.mdx | 56 ++ .../reference/en/p5 copy/createVector.mdx | 133 +++ .../reference/en/p5 copy/createVideo.mdx | 135 +++ .../reference/en/p5 copy/createWriter.mdx | 146 ++++ src/content/reference/en/p5 copy/cursor.mdx | 139 +++ src/content/reference/en/p5 copy/curve.mdx | 272 ++++++ .../reference/en/p5 copy/curveDetail.mdx | 117 +++ .../reference/en/p5 copy/curvePoint.mdx | 160 ++++ .../reference/en/p5 copy/curveTangent.mdx | 153 ++++ .../reference/en/p5 copy/curveTightness.mdx | 77 ++ .../reference/en/p5 copy/curveVertex.mdx | 407 +++++++++ src/content/reference/en/p5 copy/cylinder.mdx | 282 +++++++ src/content/reference/en/p5 copy/day.mdx | 47 ++ .../reference/en/p5 copy/debugMode.mdx | 362 ++++++++ src/content/reference/en/p5 copy/degrees.mdx | 53 ++ .../reference/en/p5 copy/deltaTime.mdx | 68 ++ src/content/reference/en/p5 copy/describe.mdx | 137 +++ .../reference/en/p5 copy/describeElement.mdx | 127 +++ .../reference/en/p5 copy/deviceMoved.mdx | 49 ++ .../en/p5 copy/deviceOrientation.mdx | 22 + .../reference/en/p5 copy/deviceShaken.mdx | 50 ++ .../reference/en/p5 copy/deviceTurned.mdx | 80 ++ .../reference/en/p5 copy/directionalLight.mdx | 277 ++++++ .../en/p5 copy/disableFriendlyErrors.mdx | 55 ++ .../reference/en/p5 copy/displayDensity.mdx | 55 ++ .../reference/en/p5 copy/displayHeight.mdx | 47 ++ .../reference/en/p5 copy/displayWidth.mdx | 47 ++ src/content/reference/en/p5 copy/dist.mdx | 121 +++ .../reference/en/p5 copy/doubleClicked.mdx | 157 ++++ src/content/reference/en/p5 copy/draw.mdx | 129 +++ .../reference/en/p5 copy/drawingContext.mdx | 78 ++ src/content/reference/en/p5 copy/ellipse.mdx | 164 ++++ .../reference/en/p5 copy/ellipseMode.mdx | 113 +++ .../reference/en/p5 copy/ellipsoid.mdx | 233 +++++ .../reference/en/p5 copy/emissiveMaterial.mdx | 140 ++++ src/content/reference/en/p5 copy/endClip.mdx | 43 + .../reference/en/p5 copy/endContour.mdx | 133 +++ .../reference/en/p5 copy/endGeometry.mdx | 285 +++++++ src/content/reference/en/p5 copy/endShape.mdx | 256 ++++++ src/content/reference/en/p5 copy/erase.mdx | 123 +++ .../reference/en/p5 copy/exitPointerLock.mdx | 82 ++ src/content/reference/en/p5 copy/exp.mdx | 83 ++ src/content/reference/en/p5 copy/fill.mdx | 312 +++++++ src/content/reference/en/p5 copy/filter.mdx | 330 ++++++++ src/content/reference/en/p5 copy/float.mdx | 116 +++ src/content/reference/en/p5 copy/floor.mdx | 57 ++ src/content/reference/en/p5 copy/focused.mdx | 50 ++ src/content/reference/en/p5 copy/for.mdx | 290 +++++++ src/content/reference/en/p5 copy/fract.mdx | 55 ++ .../reference/en/p5 copy/frameCount.mdx | 73 ++ .../reference/en/p5 copy/frameRate.mdx | 107 +++ .../reference/en/p5 copy/freeGeometry.mdx | 152 ++++ .../reference/en/p5 copy/freqToMidi.mdx | 29 + src/content/reference/en/p5 copy/frustum.mdx | 175 ++++ .../reference/en/p5 copy/fullscreen.mdx | 63 ++ src/content/reference/en/p5 copy/function.mdx | 19 + src/content/reference/en/p5 copy/get.mdx | 178 ++++ .../reference/en/p5 copy/getAudioContext.mdx | 56 ++ src/content/reference/en/p5 copy/getItem.mdx | 151 ++++ .../reference/en/p5 copy/getOutputVolume.mdx | 25 + .../en/p5 copy/getTargetFrameRate.mdx | 48 ++ src/content/reference/en/p5 copy/getURL.mdx | 46 + .../reference/en/p5 copy/getURLParams.mdx | 59 ++ .../reference/en/p5 copy/getURLPath.mdx | 58 ++ src/content/reference/en/p5 copy/green.mdx | 159 ++++ .../reference/en/p5 copy/gridOutput.mdx | 189 +++++ src/content/reference/en/p5 copy/height.mdx | 87 ++ src/content/reference/en/p5 copy/hex.mdx | 166 ++++ src/content/reference/en/p5 copy/hour.mdx | 47 ++ src/content/reference/en/p5 copy/httpDo.mdx | 150 ++++ src/content/reference/en/p5 copy/httpGet.mdx | 140 ++++ src/content/reference/en/p5 copy/httpPost.mdx | 165 ++++ src/content/reference/en/p5 copy/hue.mdx | 145 ++++ src/content/reference/en/p5 copy/if.mdx | 268 ++++++ src/content/reference/en/p5 copy/image.mdx | 327 ++++++++ .../reference/en/p5 copy/imageLight.mdx | 86 ++ .../reference/en/p5 copy/imageMode.mdx | 129 +++ src/content/reference/en/p5 copy/input.mdx | 88 ++ src/content/reference/en/p5 copy/int.mdx | 169 ++++ .../reference/en/p5 copy/isLooping.mdx | 65 ++ src/content/reference/en/p5 copy/join.mdx | 70 ++ src/content/reference/en/p5 copy/key.mdx | 106 +++ src/content/reference/en/p5 copy/keyCode.mdx | 128 +++ .../reference/en/p5 copy/keyIsDown.mdx | 142 ++++ .../reference/en/p5 copy/keyIsPressed.mdx | 105 +++ .../reference/en/p5 copy/keyPressed.mdx | 192 +++++ .../reference/en/p5 copy/keyReleased.mdx | 188 +++++ src/content/reference/en/p5 copy/keyTyped.mdx | 170 ++++ src/content/reference/en/p5 copy/lerp.mdx | 122 +++ .../reference/en/p5 copy/lerpColor.mdx | 96 +++ src/content/reference/en/p5 copy/let.mdx | 91 ++ .../reference/en/p5 copy/lightFalloff.mdx | 100 +++ .../reference/en/p5 copy/lightness.mdx | 168 ++++ src/content/reference/en/p5 copy/lights.mdx | 88 ++ src/content/reference/en/p5 copy/line.mdx | 194 +++++ .../reference/en/p5 copy/linePerspective.mdx | 164 ++++ .../reference/en/p5 copy/loadBytes.mdx | 56 ++ src/content/reference/en/p5 copy/loadFont.mdx | 171 ++++ .../reference/en/p5 copy/loadImage.mdx | 137 +++ src/content/reference/en/p5 copy/loadJSON.mdx | 288 +++++++ .../reference/en/p5 copy/loadModel.mdx | 469 +++++++++++ .../reference/en/p5 copy/loadPixels.mdx | 61 ++ .../reference/en/p5 copy/loadShader.mdx | 172 ++++ .../reference/en/p5 copy/loadSound.mdx | 78 ++ .../reference/en/p5 copy/loadStrings.mdx | 188 +++++ .../reference/en/p5 copy/loadTable.mdx | 124 +++ src/content/reference/en/p5 copy/loadXML.mdx | 220 +++++ src/content/reference/en/p5 copy/log.mdx | 79 ++ src/content/reference/en/p5 copy/loop.mdx | 111 +++ src/content/reference/en/p5 copy/mag.mdx | 84 ++ src/content/reference/en/p5 copy/map.mdx | 119 +++ src/content/reference/en/p5 copy/match.mdx | 91 ++ src/content/reference/en/p5 copy/matchAll.mdx | 107 +++ src/content/reference/en/p5 copy/max.mdx | 104 +++ .../reference/en/p5 copy/metalness.mdx | 142 ++++ .../reference/en/p5 copy/midiToFreq.mdx | 66 ++ src/content/reference/en/p5 copy/millis.mdx | 147 ++++ src/content/reference/en/p5 copy/min.mdx | 104 +++ src/content/reference/en/p5 copy/minute.mdx | 47 ++ src/content/reference/en/p5 copy/model.mdx | 155 ++++ src/content/reference/en/p5 copy/month.mdx | 47 ++ .../reference/en/p5 copy/mouseButton.mdx | 87 ++ .../reference/en/p5 copy/mouseClicked.mdx | 196 +++++ .../reference/en/p5 copy/mouseDragged.mdx | 130 +++ .../reference/en/p5 copy/mouseIsPressed.mdx | 73 ++ .../reference/en/p5 copy/mouseMoved.mdx | 118 +++ .../reference/en/p5 copy/mousePressed.mdx | 193 +++++ .../reference/en/p5 copy/mouseReleased.mdx | 195 +++++ .../reference/en/p5 copy/mouseWheel.mdx | 162 ++++ src/content/reference/en/p5 copy/mouseX.mdx | 124 +++ src/content/reference/en/p5 copy/mouseY.mdx | 124 +++ src/content/reference/en/p5 copy/movedX.mdx | 78 ++ src/content/reference/en/p5 copy/movedY.mdx | 78 ++ src/content/reference/en/p5 copy/nf.mdx | 159 ++++ src/content/reference/en/p5 copy/nfc.mdx | 153 ++++ src/content/reference/en/p5 copy/nfp.mdx | 188 +++++ src/content/reference/en/p5 copy/nfs.mdx | 176 ++++ src/content/reference/en/p5 copy/noCanvas.mdx | 36 + src/content/reference/en/p5 copy/noCursor.mdx | 38 + .../reference/en/p5 copy/noDebugMode.mdx | 54 ++ src/content/reference/en/p5 copy/noErase.mdx | 55 ++ src/content/reference/en/p5 copy/noFill.mdx | 73 ++ src/content/reference/en/p5 copy/noLights.mdx | 79 ++ src/content/reference/en/p5 copy/noLoop.mdx | 139 +++ src/content/reference/en/p5 copy/noSmooth.mdx | 92 ++ src/content/reference/en/p5 copy/noStroke.mdx | 71 ++ src/content/reference/en/p5 copy/noTint.mdx | 51 ++ src/content/reference/en/p5 copy/noise.mdx | 282 +++++++ .../reference/en/p5 copy/noiseDetail.mdx | 100 +++ .../reference/en/p5 copy/noiseSeed.mdx | 68 ++ src/content/reference/en/p5 copy/norm.mdx | 69 ++ src/content/reference/en/p5 copy/normal.mdx | 250 ++++++ .../reference/en/p5 copy/normalMaterial.mdx | 55 ++ .../reference/en/p5 copy/orbitControl.mdx | 203 +++++ src/content/reference/en/p5 copy/ortho.mdx | 168 ++++ .../reference/en/p5 copy/outputVolume.mdx | 51 ++ .../reference/en/p5 copy/p5.Camera.mdx | 659 +++++++++++++++ src/content/reference/en/p5 copy/p5.Color.mdx | 116 +++ .../reference/en/p5 copy/p5.Element.mdx | 545 ++++++++++++ src/content/reference/en/p5 copy/p5.File.mdx | 153 ++++ src/content/reference/en/p5 copy/p5.Font.mdx | 146 ++++ .../reference/en/p5 copy/p5.Framebuffer.mdx | 443 ++++++++++ .../reference/en/p5 copy/p5.Geometry.mdx | 793 ++++++++++++++++++ .../reference/en/p5 copy/p5.Graphics.mdx | 261 ++++++ src/content/reference/en/p5 copy/p5.Image.mdx | 519 ++++++++++++ .../reference/en/p5 copy/p5.MediaElement.mdx | 258 ++++++ .../reference/en/p5 copy/p5.NumberDict.mdx | 63 ++ .../reference/en/p5 copy/p5.PrintWriter.mdx | 35 + .../reference/en/p5 copy/p5.Renderer.mdx | 34 + .../reference/en/p5 copy/p5.Shader.mdx | 433 ++++++++++ .../reference/en/p5 copy/p5.StringDict.mdx | 15 + src/content/reference/en/p5 copy/p5.Table.mdx | 213 +++++ .../reference/en/p5 copy/p5.TableRow.mdx | 66 ++ .../reference/en/p5 copy/p5.TypedDict.mdx | 66 ++ .../reference/en/p5 copy/p5.Vector.mdx | 673 +++++++++++++++ src/content/reference/en/p5 copy/p5.XML.mdx | 321 +++++++ src/content/reference/en/p5 copy/p5.mdx | 51 ++ .../reference/en/p5 copy/pAccelerationX.mdx | 21 + .../reference/en/p5 copy/pAccelerationY.mdx | 21 + .../reference/en/p5 copy/pAccelerationZ.mdx | 21 + .../reference/en/p5 copy/pRotationX.mdx | 63 ++ .../reference/en/p5 copy/pRotationY.mdx | 62 ++ .../reference/en/p5 copy/pRotationZ.mdx | 58 ++ .../reference/en/p5 copy/paletteLerp.mdx | 66 ++ src/content/reference/en/p5 copy/panorama.mdx | 76 ++ .../reference/en/p5 copy/perspective.mdx | 194 +++++ .../reference/en/p5 copy/pixelDensity.mdx | 90 ++ src/content/reference/en/p5 copy/pixels.mdx | 173 ++++ src/content/reference/en/p5 copy/plane.mdx | 152 ++++ src/content/reference/en/p5 copy/pmouseX.mdx | 88 ++ src/content/reference/en/p5 copy/pmouseY.mdx | 88 ++ src/content/reference/en/p5 copy/point.mdx | 229 +++++ .../reference/en/p5 copy/pointLight.mdx | 329 ++++++++ src/content/reference/en/p5 copy/pop.mdx | 20 + src/content/reference/en/p5 copy/pow.mdx | 67 ++ src/content/reference/en/p5 copy/preload.mdx | 70 ++ src/content/reference/en/p5 copy/print.mdx | 55 ++ src/content/reference/en/p5 copy/push.mdx | 20 + .../reference/en/p5 copy/pwinMouseX.mdx | 99 +++ .../reference/en/p5 copy/pwinMouseY.mdx | 99 +++ src/content/reference/en/p5 copy/quad.mdx | 233 +++++ .../reference/en/p5 copy/quadraticVertex.mdx | 303 +++++++ src/content/reference/en/p5 copy/radians.mdx | 53 ++ src/content/reference/en/p5 copy/random.mdx | 48 ++ .../reference/en/p5 copy/randomGaussian.mdx | 104 +++ .../reference/en/p5 copy/randomSeed.mdx | 71 ++ src/content/reference/en/p5 copy/rect.mdx | 209 +++++ src/content/reference/en/p5 copy/rectMode.mdx | 142 ++++ src/content/reference/en/p5 copy/red.mdx | 158 ++++ src/content/reference/en/p5 copy/redraw.mdx | 117 +++ src/content/reference/en/p5 copy/remove.mdx | 57 ++ .../reference/en/p5 copy/removeElements.mdx | 85 ++ .../reference/en/p5 copy/removeItem.mdx | 97 +++ .../en/p5 copy/requestPointerLock.mdx | 85 ++ .../reference/en/p5 copy/resetMatrix.mdx | 52 ++ .../reference/en/p5 copy/resetShader.mdx | 95 +++ .../reference/en/p5 copy/resizeCanvas.mdx | 133 +++ src/content/reference/en/p5 copy/reverse.mdx | 43 + src/content/reference/en/p5 copy/rotate.mdx | 226 +++++ src/content/reference/en/p5 copy/rotateX.mdx | 161 ++++ src/content/reference/en/p5 copy/rotateY.mdx | 161 ++++ src/content/reference/en/p5 copy/rotateZ.mdx | 161 ++++ .../reference/en/p5 copy/rotationX.mdx | 45 + .../reference/en/p5 copy/rotationY.mdx | 45 + .../reference/en/p5 copy/rotationZ.mdx | 47 ++ src/content/reference/en/p5 copy/round.mdx | 88 ++ .../reference/en/p5 copy/sampleRate.mdx | 26 + .../reference/en/p5 copy/saturation.mdx | 201 +++++ src/content/reference/en/p5 copy/save.mdx | 140 ++++ .../reference/en/p5 copy/saveCanvas.mdx | 166 ++++ .../reference/en/p5 copy/saveFrames.mdx | 175 ++++ src/content/reference/en/p5 copy/saveGif.mdx | 119 +++ src/content/reference/en/p5 copy/saveJSON.mdx | 170 ++++ .../reference/en/p5 copy/saveSound.mdx | 35 + .../reference/en/p5 copy/saveStrings.mdx | 185 ++++ .../reference/en/p5 copy/saveTable.mdx | 70 ++ src/content/reference/en/p5 copy/scale.mdx | 231 +++++ src/content/reference/en/p5 copy/second.mdx | 47 ++ src/content/reference/en/p5 copy/select.mdx | 113 +++ .../reference/en/p5 copy/selectAll.mdx | 121 +++ src/content/reference/en/p5 copy/set.mdx | 157 ++++ .../reference/en/p5 copy/setAttributes.mdx | 163 ++++ src/content/reference/en/p5 copy/setBPM.mdx | 29 + .../reference/en/p5 copy/setCamera.mdx | 81 ++ .../reference/en/p5 copy/setMoveThreshold.mdx | 59 ++ .../en/p5 copy/setShakeThreshold.mdx | 59 ++ src/content/reference/en/p5 copy/setup.mdx | 111 +++ src/content/reference/en/p5 copy/shader.mdx | 244 ++++++ src/content/reference/en/p5 copy/shearX.mdx | 105 +++ src/content/reference/en/p5 copy/shearY.mdx | 105 +++ .../reference/en/p5 copy/shininess.mdx | 86 ++ src/content/reference/en/p5 copy/shorten.mdx | 44 + src/content/reference/en/p5 copy/shuffle.mdx | 132 +++ src/content/reference/en/p5 copy/sin.mdx | 107 +++ src/content/reference/en/p5 copy/smooth.mdx | 94 +++ src/content/reference/en/p5 copy/sort.mdx | 63 ++ .../reference/en/p5 copy/soundFormats.mdx | 51 ++ src/content/reference/en/p5 copy/soundOut.mdx | 26 + .../reference/en/p5 copy/specularColor.mdx | 308 +++++++ .../reference/en/p5 copy/specularMaterial.mdx | 311 +++++++ src/content/reference/en/p5 copy/sphere.mdx | 165 ++++ src/content/reference/en/p5 copy/splice.mdx | 58 ++ src/content/reference/en/p5 copy/split.mdx | 87 ++ .../reference/en/p5 copy/splitTokens.mdx | 180 ++++ .../reference/en/p5 copy/spotLight.mdx | 398 +++++++++ src/content/reference/en/p5 copy/sq.mdx | 83 ++ src/content/reference/en/p5 copy/sqrt.mdx | 84 ++ src/content/reference/en/p5 copy/square.mdx | 163 ++++ .../reference/en/p5 copy/storeItem.mdx | 149 ++++ src/content/reference/en/p5 copy/str.mdx | 135 +++ src/content/reference/en/p5 copy/stroke.mdx | 311 +++++++ .../reference/en/p5 copy/strokeCap.mdx | 67 ++ .../reference/en/p5 copy/strokeJoin.mdx | 114 +++ .../reference/en/p5 copy/strokeWeight.mdx | 77 ++ src/content/reference/en/p5 copy/subset.mdx | 59 ++ src/content/reference/en/p5 copy/tan.mdx | 66 ++ src/content/reference/en/p5 copy/text.mdx | 96 +++ .../reference/en/p5 copy/textAlign.mdx | 135 +++ .../reference/en/p5 copy/textAscent.mdx | 71 ++ .../reference/en/p5 copy/textDescent.mdx | 71 ++ src/content/reference/en/p5 copy/textFont.mdx | 127 +++ .../reference/en/p5 copy/textLeading.mdx | 63 ++ .../reference/en/p5 copy/textOutput.mdx | 186 ++++ src/content/reference/en/p5 copy/textSize.mdx | 65 ++ .../reference/en/p5 copy/textStyle.mdx | 79 ++ .../reference/en/p5 copy/textWidth.mdx | 83 ++ src/content/reference/en/p5 copy/textWrap.mdx | 111 +++ src/content/reference/en/p5 copy/texture.mdx | 207 +++++ .../reference/en/p5 copy/textureMode.mdx | 254 ++++++ .../reference/en/p5 copy/textureWrap.mdx | 370 ++++++++ src/content/reference/en/p5 copy/tint.mdx | 201 +++++ src/content/reference/en/p5 copy/torus.mdx | 200 +++++ .../reference/en/p5 copy/touchEnded.mdx | 196 +++++ .../reference/en/p5 copy/touchMoved.mdx | 198 +++++ .../reference/en/p5 copy/touchStarted.mdx | 197 +++++ src/content/reference/en/p5 copy/touches.mdx | 102 +++ .../reference/en/p5 copy/translate.mdx | 241 ++++++ src/content/reference/en/p5 copy/triangle.mdx | 104 +++ src/content/reference/en/p5 copy/trim.mdx | 113 +++ src/content/reference/en/p5 copy/turnAxis.mdx | 54 ++ .../reference/en/p5 copy/types/Array.mdx | 269 ++++++ .../reference/en/p5 copy/types/Boolean.mdx | 273 ++++++ .../reference/en/p5 copy/types/Number.mdx | 201 +++++ .../reference/en/p5 copy/types/Object.mdx | 91 ++ .../reference/en/p5 copy/types/String.mdx | 153 ++++ src/content/reference/en/p5 copy/unchar.mdx | 114 +++ src/content/reference/en/p5 copy/unhex.mdx | 121 +++ .../reference/en/p5 copy/updatePixels.mdx | 94 +++ .../reference/en/p5 copy/userStartAudio.mdx | 99 +++ src/content/reference/en/p5 copy/vertex.mdx | 242 ++++++ .../reference/en/p5 copy/webglVersion.mdx | 105 +++ src/content/reference/en/p5 copy/while.mdx | 161 ++++ src/content/reference/en/p5 copy/width.mdx | 87 ++ .../reference/en/p5 copy/winMouseX.mdx | 61 ++ .../reference/en/p5 copy/winMouseY.mdx | 61 ++ .../reference/en/p5 copy/windowHeight.mdx | 43 + .../reference/en/p5 copy/windowResized.mdx | 64 ++ .../reference/en/p5 copy/windowWidth.mdx | 43 + src/content/reference/en/p5 copy/year.mdx | 47 ++ 522 files changed, 60135 insertions(+) create mode 100644 src/content/reference/en/p5 copy/abs.mdx create mode 100644 src/content/reference/en/p5 copy/accelerationX.mdx create mode 100644 src/content/reference/en/p5 copy/accelerationY.mdx create mode 100644 src/content/reference/en/p5 copy/accelerationZ.mdx create mode 100644 src/content/reference/en/p5 copy/acos.mdx create mode 100644 src/content/reference/en/p5 copy/alpha.mdx create mode 100644 src/content/reference/en/p5 copy/ambientLight.mdx create mode 100644 src/content/reference/en/p5 copy/ambientMaterial.mdx create mode 100644 src/content/reference/en/p5 copy/angleMode.mdx create mode 100644 src/content/reference/en/p5 copy/append.mdx create mode 100644 src/content/reference/en/p5 copy/applyMatrix.mdx create mode 100644 src/content/reference/en/p5 copy/arc.mdx create mode 100644 src/content/reference/en/p5 copy/arrayCopy.mdx create mode 100644 src/content/reference/en/p5 copy/asin.mdx create mode 100644 src/content/reference/en/p5 copy/atan.mdx create mode 100644 src/content/reference/en/p5 copy/atan2.mdx create mode 100644 src/content/reference/en/p5 copy/background.mdx create mode 100644 src/content/reference/en/p5 copy/baseColorShader.mdx create mode 100644 src/content/reference/en/p5 copy/baseMaterialShader.mdx create mode 100644 src/content/reference/en/p5 copy/baseNormalShader.mdx create mode 100644 src/content/reference/en/p5 copy/baseStrokeShader.mdx create mode 100644 src/content/reference/en/p5 copy/beginClip.mdx create mode 100644 src/content/reference/en/p5 copy/beginContour.mdx create mode 100644 src/content/reference/en/p5 copy/beginGeometry.mdx create mode 100644 src/content/reference/en/p5 copy/beginShape.mdx create mode 100644 src/content/reference/en/p5 copy/bezier.mdx create mode 100644 src/content/reference/en/p5 copy/bezierDetail.mdx create mode 100644 src/content/reference/en/p5 copy/bezierPoint.mdx create mode 100644 src/content/reference/en/p5 copy/bezierTangent.mdx create mode 100644 src/content/reference/en/p5 copy/bezierVertex.mdx create mode 100644 src/content/reference/en/p5 copy/blend.mdx create mode 100644 src/content/reference/en/p5 copy/blendMode.mdx create mode 100644 src/content/reference/en/p5 copy/blue.mdx create mode 100644 src/content/reference/en/p5 copy/boolean.mdx create mode 100644 src/content/reference/en/p5 copy/box.mdx create mode 100644 src/content/reference/en/p5 copy/brightness.mdx create mode 100644 src/content/reference/en/p5 copy/buildGeometry.mdx create mode 100644 src/content/reference/en/p5 copy/byte.mdx create mode 100644 src/content/reference/en/p5 copy/camera.mdx create mode 100644 src/content/reference/en/p5 copy/ceil.mdx create mode 100644 src/content/reference/en/p5 copy/changed.mdx create mode 100644 src/content/reference/en/p5 copy/char.mdx create mode 100644 src/content/reference/en/p5 copy/circle.mdx create mode 100644 src/content/reference/en/p5 copy/class.mdx create mode 100644 src/content/reference/en/p5 copy/clear.mdx create mode 100644 src/content/reference/en/p5 copy/clearDepth.mdx create mode 100644 src/content/reference/en/p5 copy/clearStorage.mdx create mode 100644 src/content/reference/en/p5 copy/clip.mdx create mode 100644 src/content/reference/en/p5 copy/color.mdx create mode 100644 src/content/reference/en/p5 copy/colorMode.mdx create mode 100644 src/content/reference/en/p5 copy/concat.mdx create mode 100644 src/content/reference/en/p5 copy/cone.mdx create mode 100644 src/content/reference/en/p5 copy/console.mdx create mode 100644 src/content/reference/en/p5 copy/constants/ADD.mdx create mode 100644 src/content/reference/en/p5 copy/constants/ALT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/ARROW.mdx create mode 100644 src/content/reference/en/p5 copy/constants/AUTO.mdx create mode 100644 src/content/reference/en/p5 copy/constants/AXES.mdx create mode 100644 src/content/reference/en/p5 copy/constants/BACKSPACE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/BASELINE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/BEVEL.mdx create mode 100644 src/content/reference/en/p5 copy/constants/BEZIER.mdx create mode 100644 src/content/reference/en/p5 copy/constants/BLEND.mdx create mode 100644 src/content/reference/en/p5 copy/constants/BLUR.mdx create mode 100644 src/content/reference/en/p5 copy/constants/BOLD.mdx create mode 100644 src/content/reference/en/p5 copy/constants/BOLDITALIC.mdx create mode 100644 src/content/reference/en/p5 copy/constants/BOTTOM.mdx create mode 100644 src/content/reference/en/p5 copy/constants/BURN.mdx create mode 100644 src/content/reference/en/p5 copy/constants/CENTER.mdx create mode 100644 src/content/reference/en/p5 copy/constants/CHAR.mdx create mode 100644 src/content/reference/en/p5 copy/constants/CHORD.mdx create mode 100644 src/content/reference/en/p5 copy/constants/CLAMP.mdx create mode 100644 src/content/reference/en/p5 copy/constants/CLOSE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/CONTAIN.mdx create mode 100644 src/content/reference/en/p5 copy/constants/CONTROL.mdx create mode 100644 src/content/reference/en/p5 copy/constants/CORNER.mdx create mode 100644 src/content/reference/en/p5 copy/constants/CORNERS.mdx create mode 100644 src/content/reference/en/p5 copy/constants/COVER.mdx create mode 100644 src/content/reference/en/p5 copy/constants/CROSS.mdx create mode 100644 src/content/reference/en/p5 copy/constants/CURVE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/DARKEST.mdx create mode 100644 src/content/reference/en/p5 copy/constants/DEGREES.mdx create mode 100644 src/content/reference/en/p5 copy/constants/DELETE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/DIFFERENCE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/DILATE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/DODGE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/DOWN_ARROW.mdx create mode 100644 src/content/reference/en/p5 copy/constants/ENTER.mdx create mode 100644 src/content/reference/en/p5 copy/constants/ERODE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/ESCAPE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/EXCLUSION.mdx create mode 100644 src/content/reference/en/p5 copy/constants/FALLBACK.mdx create mode 100644 src/content/reference/en/p5 copy/constants/FILL.mdx create mode 100644 src/content/reference/en/p5 copy/constants/FLAT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/FLOAT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/GRAY.mdx create mode 100644 src/content/reference/en/p5 copy/constants/GRID.mdx create mode 100644 src/content/reference/en/p5 copy/constants/HALF_FLOAT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/HALF_PI.mdx create mode 100644 src/content/reference/en/p5 copy/constants/HAND.mdx create mode 100644 src/content/reference/en/p5 copy/constants/HARD_LIGHT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/HSB.mdx create mode 100644 src/content/reference/en/p5 copy/constants/HSL.mdx create mode 100644 src/content/reference/en/p5 copy/constants/IMAGE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/IMMEDIATE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/INVERT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/ITALIC.mdx create mode 100644 src/content/reference/en/p5 copy/constants/LABEL.mdx create mode 100644 src/content/reference/en/p5 copy/constants/LANDSCAPE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/LEFT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/LEFT_ARROW.mdx create mode 100644 src/content/reference/en/p5 copy/constants/LIGHTEST.mdx create mode 100644 src/content/reference/en/p5 copy/constants/LINEAR.mdx create mode 100644 src/content/reference/en/p5 copy/constants/LINES.mdx create mode 100644 src/content/reference/en/p5 copy/constants/LINE_LOOP.mdx create mode 100644 src/content/reference/en/p5 copy/constants/LINE_STRIP.mdx create mode 100644 src/content/reference/en/p5 copy/constants/MIRROR.mdx create mode 100644 src/content/reference/en/p5 copy/constants/MITER.mdx create mode 100644 src/content/reference/en/p5 copy/constants/MOVE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/MULTIPLY.mdx create mode 100644 src/content/reference/en/p5 copy/constants/NEAREST.mdx create mode 100644 src/content/reference/en/p5 copy/constants/NORMAL.mdx create mode 100644 src/content/reference/en/p5 copy/constants/OPAQUE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/OPEN.mdx create mode 100644 src/content/reference/en/p5 copy/constants/OPTION.mdx create mode 100644 src/content/reference/en/p5 copy/constants/OVERLAY.mdx create mode 100644 src/content/reference/en/p5 copy/constants/P2D.mdx create mode 100644 src/content/reference/en/p5 copy/constants/PI.mdx create mode 100644 src/content/reference/en/p5 copy/constants/PIE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/POINTS.mdx create mode 100644 src/content/reference/en/p5 copy/constants/PORTRAIT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/POSTERIZE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/PROJECT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/QUADRATIC.mdx create mode 100644 src/content/reference/en/p5 copy/constants/QUADS.mdx create mode 100644 src/content/reference/en/p5 copy/constants/QUAD_STRIP.mdx create mode 100644 src/content/reference/en/p5 copy/constants/QUARTER_PI.mdx create mode 100644 src/content/reference/en/p5 copy/constants/RADIANS.mdx create mode 100644 src/content/reference/en/p5 copy/constants/RADIUS.mdx create mode 100644 src/content/reference/en/p5 copy/constants/REMOVE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/REPEAT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/REPLACE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/RETURN.mdx create mode 100644 src/content/reference/en/p5 copy/constants/RGB.mdx create mode 100644 src/content/reference/en/p5 copy/constants/RGBA.mdx create mode 100644 src/content/reference/en/p5 copy/constants/RIGHT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/RIGHT_ARROW.mdx create mode 100644 src/content/reference/en/p5 copy/constants/ROUND.mdx create mode 100644 src/content/reference/en/p5 copy/constants/SCREEN.mdx create mode 100644 src/content/reference/en/p5 copy/constants/SHIFT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/SMOOTH.mdx create mode 100644 src/content/reference/en/p5 copy/constants/SOFT_LIGHT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/SQUARE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/STROKE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/SUBTRACT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/TAB.mdx create mode 100644 src/content/reference/en/p5 copy/constants/TAU.mdx create mode 100644 src/content/reference/en/p5 copy/constants/TESS.mdx create mode 100644 src/content/reference/en/p5 copy/constants/TEXT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/TEXTURE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/THRESHOLD.mdx create mode 100644 src/content/reference/en/p5 copy/constants/TOP.mdx create mode 100644 src/content/reference/en/p5 copy/constants/TRIANGLES.mdx create mode 100644 src/content/reference/en/p5 copy/constants/TRIANGLE_FAN.mdx create mode 100644 src/content/reference/en/p5 copy/constants/TRIANGLE_STRIP.mdx create mode 100644 src/content/reference/en/p5 copy/constants/TWO_PI.mdx create mode 100644 src/content/reference/en/p5 copy/constants/UNSIGNED_BYTE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/UNSIGNED_INT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/UP_ARROW.mdx create mode 100644 src/content/reference/en/p5 copy/constants/VERSION.mdx create mode 100644 src/content/reference/en/p5 copy/constants/WAIT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/WEBGL.mdx create mode 100644 src/content/reference/en/p5 copy/constants/WEBGL2.mdx create mode 100644 src/content/reference/en/p5 copy/constants/WORD.mdx create mode 100644 src/content/reference/en/p5 copy/constrain.mdx create mode 100644 src/content/reference/en/p5 copy/copy.mdx create mode 100644 src/content/reference/en/p5 copy/cos.mdx create mode 100644 src/content/reference/en/p5 copy/createA.mdx create mode 100644 src/content/reference/en/p5 copy/createAudio.mdx create mode 100644 src/content/reference/en/p5 copy/createButton.mdx create mode 100644 src/content/reference/en/p5 copy/createCamera.mdx create mode 100644 src/content/reference/en/p5 copy/createCanvas.mdx create mode 100644 src/content/reference/en/p5 copy/createCapture.mdx create mode 100644 src/content/reference/en/p5 copy/createCheckbox.mdx create mode 100644 src/content/reference/en/p5 copy/createColorPicker.mdx create mode 100644 src/content/reference/en/p5 copy/createConvolver.mdx create mode 100644 src/content/reference/en/p5 copy/createDiv.mdx create mode 100644 src/content/reference/en/p5 copy/createElement.mdx create mode 100644 src/content/reference/en/p5 copy/createFileInput.mdx create mode 100644 src/content/reference/en/p5 copy/createFilterShader.mdx create mode 100644 src/content/reference/en/p5 copy/createFramebuffer.mdx create mode 100644 src/content/reference/en/p5 copy/createGraphics.mdx create mode 100644 src/content/reference/en/p5 copy/createImage.mdx create mode 100644 src/content/reference/en/p5 copy/createImg.mdx create mode 100644 src/content/reference/en/p5 copy/createInput.mdx create mode 100644 src/content/reference/en/p5 copy/createModel.mdx create mode 100644 src/content/reference/en/p5 copy/createNumberDict.mdx create mode 100644 src/content/reference/en/p5 copy/createP.mdx create mode 100644 src/content/reference/en/p5 copy/createRadio.mdx create mode 100644 src/content/reference/en/p5 copy/createSelect.mdx create mode 100644 src/content/reference/en/p5 copy/createShader.mdx create mode 100644 src/content/reference/en/p5 copy/createSlider.mdx create mode 100644 src/content/reference/en/p5 copy/createSpan.mdx create mode 100644 src/content/reference/en/p5 copy/createStringDict.mdx create mode 100644 src/content/reference/en/p5 copy/createVector.mdx create mode 100644 src/content/reference/en/p5 copy/createVideo.mdx create mode 100644 src/content/reference/en/p5 copy/createWriter.mdx create mode 100644 src/content/reference/en/p5 copy/cursor.mdx create mode 100644 src/content/reference/en/p5 copy/curve.mdx create mode 100644 src/content/reference/en/p5 copy/curveDetail.mdx create mode 100644 src/content/reference/en/p5 copy/curvePoint.mdx create mode 100644 src/content/reference/en/p5 copy/curveTangent.mdx create mode 100644 src/content/reference/en/p5 copy/curveTightness.mdx create mode 100644 src/content/reference/en/p5 copy/curveVertex.mdx create mode 100644 src/content/reference/en/p5 copy/cylinder.mdx create mode 100644 src/content/reference/en/p5 copy/day.mdx create mode 100644 src/content/reference/en/p5 copy/debugMode.mdx create mode 100644 src/content/reference/en/p5 copy/degrees.mdx create mode 100644 src/content/reference/en/p5 copy/deltaTime.mdx create mode 100644 src/content/reference/en/p5 copy/describe.mdx create mode 100644 src/content/reference/en/p5 copy/describeElement.mdx create mode 100644 src/content/reference/en/p5 copy/deviceMoved.mdx create mode 100644 src/content/reference/en/p5 copy/deviceOrientation.mdx create mode 100644 src/content/reference/en/p5 copy/deviceShaken.mdx create mode 100644 src/content/reference/en/p5 copy/deviceTurned.mdx create mode 100644 src/content/reference/en/p5 copy/directionalLight.mdx create mode 100644 src/content/reference/en/p5 copy/disableFriendlyErrors.mdx create mode 100644 src/content/reference/en/p5 copy/displayDensity.mdx create mode 100644 src/content/reference/en/p5 copy/displayHeight.mdx create mode 100644 src/content/reference/en/p5 copy/displayWidth.mdx create mode 100644 src/content/reference/en/p5 copy/dist.mdx create mode 100644 src/content/reference/en/p5 copy/doubleClicked.mdx create mode 100644 src/content/reference/en/p5 copy/draw.mdx create mode 100644 src/content/reference/en/p5 copy/drawingContext.mdx create mode 100644 src/content/reference/en/p5 copy/ellipse.mdx create mode 100644 src/content/reference/en/p5 copy/ellipseMode.mdx create mode 100644 src/content/reference/en/p5 copy/ellipsoid.mdx create mode 100644 src/content/reference/en/p5 copy/emissiveMaterial.mdx create mode 100644 src/content/reference/en/p5 copy/endClip.mdx create mode 100644 src/content/reference/en/p5 copy/endContour.mdx create mode 100644 src/content/reference/en/p5 copy/endGeometry.mdx create mode 100644 src/content/reference/en/p5 copy/endShape.mdx create mode 100644 src/content/reference/en/p5 copy/erase.mdx create mode 100644 src/content/reference/en/p5 copy/exitPointerLock.mdx create mode 100644 src/content/reference/en/p5 copy/exp.mdx create mode 100644 src/content/reference/en/p5 copy/fill.mdx create mode 100644 src/content/reference/en/p5 copy/filter.mdx create mode 100644 src/content/reference/en/p5 copy/float.mdx create mode 100644 src/content/reference/en/p5 copy/floor.mdx create mode 100644 src/content/reference/en/p5 copy/focused.mdx create mode 100644 src/content/reference/en/p5 copy/for.mdx create mode 100644 src/content/reference/en/p5 copy/fract.mdx create mode 100644 src/content/reference/en/p5 copy/frameCount.mdx create mode 100644 src/content/reference/en/p5 copy/frameRate.mdx create mode 100644 src/content/reference/en/p5 copy/freeGeometry.mdx create mode 100644 src/content/reference/en/p5 copy/freqToMidi.mdx create mode 100644 src/content/reference/en/p5 copy/frustum.mdx create mode 100644 src/content/reference/en/p5 copy/fullscreen.mdx create mode 100644 src/content/reference/en/p5 copy/function.mdx create mode 100644 src/content/reference/en/p5 copy/get.mdx create mode 100644 src/content/reference/en/p5 copy/getAudioContext.mdx create mode 100644 src/content/reference/en/p5 copy/getItem.mdx create mode 100644 src/content/reference/en/p5 copy/getOutputVolume.mdx create mode 100644 src/content/reference/en/p5 copy/getTargetFrameRate.mdx create mode 100644 src/content/reference/en/p5 copy/getURL.mdx create mode 100644 src/content/reference/en/p5 copy/getURLParams.mdx create mode 100644 src/content/reference/en/p5 copy/getURLPath.mdx create mode 100644 src/content/reference/en/p5 copy/green.mdx create mode 100644 src/content/reference/en/p5 copy/gridOutput.mdx create mode 100644 src/content/reference/en/p5 copy/height.mdx create mode 100644 src/content/reference/en/p5 copy/hex.mdx create mode 100644 src/content/reference/en/p5 copy/hour.mdx create mode 100644 src/content/reference/en/p5 copy/httpDo.mdx create mode 100644 src/content/reference/en/p5 copy/httpGet.mdx create mode 100644 src/content/reference/en/p5 copy/httpPost.mdx create mode 100644 src/content/reference/en/p5 copy/hue.mdx create mode 100644 src/content/reference/en/p5 copy/if.mdx create mode 100644 src/content/reference/en/p5 copy/image.mdx create mode 100644 src/content/reference/en/p5 copy/imageLight.mdx create mode 100644 src/content/reference/en/p5 copy/imageMode.mdx create mode 100644 src/content/reference/en/p5 copy/input.mdx create mode 100644 src/content/reference/en/p5 copy/int.mdx create mode 100644 src/content/reference/en/p5 copy/isLooping.mdx create mode 100644 src/content/reference/en/p5 copy/join.mdx create mode 100644 src/content/reference/en/p5 copy/key.mdx create mode 100644 src/content/reference/en/p5 copy/keyCode.mdx create mode 100644 src/content/reference/en/p5 copy/keyIsDown.mdx create mode 100644 src/content/reference/en/p5 copy/keyIsPressed.mdx create mode 100644 src/content/reference/en/p5 copy/keyPressed.mdx create mode 100644 src/content/reference/en/p5 copy/keyReleased.mdx create mode 100644 src/content/reference/en/p5 copy/keyTyped.mdx create mode 100644 src/content/reference/en/p5 copy/lerp.mdx create mode 100644 src/content/reference/en/p5 copy/lerpColor.mdx create mode 100644 src/content/reference/en/p5 copy/let.mdx create mode 100644 src/content/reference/en/p5 copy/lightFalloff.mdx create mode 100644 src/content/reference/en/p5 copy/lightness.mdx create mode 100644 src/content/reference/en/p5 copy/lights.mdx create mode 100644 src/content/reference/en/p5 copy/line.mdx create mode 100644 src/content/reference/en/p5 copy/linePerspective.mdx create mode 100644 src/content/reference/en/p5 copy/loadBytes.mdx create mode 100644 src/content/reference/en/p5 copy/loadFont.mdx create mode 100644 src/content/reference/en/p5 copy/loadImage.mdx create mode 100644 src/content/reference/en/p5 copy/loadJSON.mdx create mode 100644 src/content/reference/en/p5 copy/loadModel.mdx create mode 100644 src/content/reference/en/p5 copy/loadPixels.mdx create mode 100644 src/content/reference/en/p5 copy/loadShader.mdx create mode 100644 src/content/reference/en/p5 copy/loadSound.mdx create mode 100644 src/content/reference/en/p5 copy/loadStrings.mdx create mode 100644 src/content/reference/en/p5 copy/loadTable.mdx create mode 100644 src/content/reference/en/p5 copy/loadXML.mdx create mode 100644 src/content/reference/en/p5 copy/log.mdx create mode 100644 src/content/reference/en/p5 copy/loop.mdx create mode 100644 src/content/reference/en/p5 copy/mag.mdx create mode 100644 src/content/reference/en/p5 copy/map.mdx create mode 100644 src/content/reference/en/p5 copy/match.mdx create mode 100644 src/content/reference/en/p5 copy/matchAll.mdx create mode 100644 src/content/reference/en/p5 copy/max.mdx create mode 100644 src/content/reference/en/p5 copy/metalness.mdx create mode 100644 src/content/reference/en/p5 copy/midiToFreq.mdx create mode 100644 src/content/reference/en/p5 copy/millis.mdx create mode 100644 src/content/reference/en/p5 copy/min.mdx create mode 100644 src/content/reference/en/p5 copy/minute.mdx create mode 100644 src/content/reference/en/p5 copy/model.mdx create mode 100644 src/content/reference/en/p5 copy/month.mdx create mode 100644 src/content/reference/en/p5 copy/mouseButton.mdx create mode 100644 src/content/reference/en/p5 copy/mouseClicked.mdx create mode 100644 src/content/reference/en/p5 copy/mouseDragged.mdx create mode 100644 src/content/reference/en/p5 copy/mouseIsPressed.mdx create mode 100644 src/content/reference/en/p5 copy/mouseMoved.mdx create mode 100644 src/content/reference/en/p5 copy/mousePressed.mdx create mode 100644 src/content/reference/en/p5 copy/mouseReleased.mdx create mode 100644 src/content/reference/en/p5 copy/mouseWheel.mdx create mode 100644 src/content/reference/en/p5 copy/mouseX.mdx create mode 100644 src/content/reference/en/p5 copy/mouseY.mdx create mode 100644 src/content/reference/en/p5 copy/movedX.mdx create mode 100644 src/content/reference/en/p5 copy/movedY.mdx create mode 100644 src/content/reference/en/p5 copy/nf.mdx create mode 100644 src/content/reference/en/p5 copy/nfc.mdx create mode 100644 src/content/reference/en/p5 copy/nfp.mdx create mode 100644 src/content/reference/en/p5 copy/nfs.mdx create mode 100644 src/content/reference/en/p5 copy/noCanvas.mdx create mode 100644 src/content/reference/en/p5 copy/noCursor.mdx create mode 100644 src/content/reference/en/p5 copy/noDebugMode.mdx create mode 100644 src/content/reference/en/p5 copy/noErase.mdx create mode 100644 src/content/reference/en/p5 copy/noFill.mdx create mode 100644 src/content/reference/en/p5 copy/noLights.mdx create mode 100644 src/content/reference/en/p5 copy/noLoop.mdx create mode 100644 src/content/reference/en/p5 copy/noSmooth.mdx create mode 100644 src/content/reference/en/p5 copy/noStroke.mdx create mode 100644 src/content/reference/en/p5 copy/noTint.mdx create mode 100644 src/content/reference/en/p5 copy/noise.mdx create mode 100644 src/content/reference/en/p5 copy/noiseDetail.mdx create mode 100644 src/content/reference/en/p5 copy/noiseSeed.mdx create mode 100644 src/content/reference/en/p5 copy/norm.mdx create mode 100644 src/content/reference/en/p5 copy/normal.mdx create mode 100644 src/content/reference/en/p5 copy/normalMaterial.mdx create mode 100644 src/content/reference/en/p5 copy/orbitControl.mdx create mode 100644 src/content/reference/en/p5 copy/ortho.mdx create mode 100644 src/content/reference/en/p5 copy/outputVolume.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Camera.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Color.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Element.mdx create mode 100644 src/content/reference/en/p5 copy/p5.File.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Font.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Framebuffer.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Geometry.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Graphics.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Image.mdx create mode 100644 src/content/reference/en/p5 copy/p5.MediaElement.mdx create mode 100644 src/content/reference/en/p5 copy/p5.NumberDict.mdx create mode 100644 src/content/reference/en/p5 copy/p5.PrintWriter.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Renderer.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Shader.mdx create mode 100644 src/content/reference/en/p5 copy/p5.StringDict.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Table.mdx create mode 100644 src/content/reference/en/p5 copy/p5.TableRow.mdx create mode 100644 src/content/reference/en/p5 copy/p5.TypedDict.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Vector.mdx create mode 100644 src/content/reference/en/p5 copy/p5.XML.mdx create mode 100644 src/content/reference/en/p5 copy/p5.mdx create mode 100644 src/content/reference/en/p5 copy/pAccelerationX.mdx create mode 100644 src/content/reference/en/p5 copy/pAccelerationY.mdx create mode 100644 src/content/reference/en/p5 copy/pAccelerationZ.mdx create mode 100644 src/content/reference/en/p5 copy/pRotationX.mdx create mode 100644 src/content/reference/en/p5 copy/pRotationY.mdx create mode 100644 src/content/reference/en/p5 copy/pRotationZ.mdx create mode 100644 src/content/reference/en/p5 copy/paletteLerp.mdx create mode 100644 src/content/reference/en/p5 copy/panorama.mdx create mode 100644 src/content/reference/en/p5 copy/perspective.mdx create mode 100644 src/content/reference/en/p5 copy/pixelDensity.mdx create mode 100644 src/content/reference/en/p5 copy/pixels.mdx create mode 100644 src/content/reference/en/p5 copy/plane.mdx create mode 100644 src/content/reference/en/p5 copy/pmouseX.mdx create mode 100644 src/content/reference/en/p5 copy/pmouseY.mdx create mode 100644 src/content/reference/en/p5 copy/point.mdx create mode 100644 src/content/reference/en/p5 copy/pointLight.mdx create mode 100644 src/content/reference/en/p5 copy/pop.mdx create mode 100644 src/content/reference/en/p5 copy/pow.mdx create mode 100644 src/content/reference/en/p5 copy/preload.mdx create mode 100644 src/content/reference/en/p5 copy/print.mdx create mode 100644 src/content/reference/en/p5 copy/push.mdx create mode 100644 src/content/reference/en/p5 copy/pwinMouseX.mdx create mode 100644 src/content/reference/en/p5 copy/pwinMouseY.mdx create mode 100644 src/content/reference/en/p5 copy/quad.mdx create mode 100644 src/content/reference/en/p5 copy/quadraticVertex.mdx create mode 100644 src/content/reference/en/p5 copy/radians.mdx create mode 100644 src/content/reference/en/p5 copy/random.mdx create mode 100644 src/content/reference/en/p5 copy/randomGaussian.mdx create mode 100644 src/content/reference/en/p5 copy/randomSeed.mdx create mode 100644 src/content/reference/en/p5 copy/rect.mdx create mode 100644 src/content/reference/en/p5 copy/rectMode.mdx create mode 100644 src/content/reference/en/p5 copy/red.mdx create mode 100644 src/content/reference/en/p5 copy/redraw.mdx create mode 100644 src/content/reference/en/p5 copy/remove.mdx create mode 100644 src/content/reference/en/p5 copy/removeElements.mdx create mode 100644 src/content/reference/en/p5 copy/removeItem.mdx create mode 100644 src/content/reference/en/p5 copy/requestPointerLock.mdx create mode 100644 src/content/reference/en/p5 copy/resetMatrix.mdx create mode 100644 src/content/reference/en/p5 copy/resetShader.mdx create mode 100644 src/content/reference/en/p5 copy/resizeCanvas.mdx create mode 100644 src/content/reference/en/p5 copy/reverse.mdx create mode 100644 src/content/reference/en/p5 copy/rotate.mdx create mode 100644 src/content/reference/en/p5 copy/rotateX.mdx create mode 100644 src/content/reference/en/p5 copy/rotateY.mdx create mode 100644 src/content/reference/en/p5 copy/rotateZ.mdx create mode 100644 src/content/reference/en/p5 copy/rotationX.mdx create mode 100644 src/content/reference/en/p5 copy/rotationY.mdx create mode 100644 src/content/reference/en/p5 copy/rotationZ.mdx create mode 100644 src/content/reference/en/p5 copy/round.mdx create mode 100644 src/content/reference/en/p5 copy/sampleRate.mdx create mode 100644 src/content/reference/en/p5 copy/saturation.mdx create mode 100644 src/content/reference/en/p5 copy/save.mdx create mode 100644 src/content/reference/en/p5 copy/saveCanvas.mdx create mode 100644 src/content/reference/en/p5 copy/saveFrames.mdx create mode 100644 src/content/reference/en/p5 copy/saveGif.mdx create mode 100644 src/content/reference/en/p5 copy/saveJSON.mdx create mode 100644 src/content/reference/en/p5 copy/saveSound.mdx create mode 100644 src/content/reference/en/p5 copy/saveStrings.mdx create mode 100644 src/content/reference/en/p5 copy/saveTable.mdx create mode 100644 src/content/reference/en/p5 copy/scale.mdx create mode 100644 src/content/reference/en/p5 copy/second.mdx create mode 100644 src/content/reference/en/p5 copy/select.mdx create mode 100644 src/content/reference/en/p5 copy/selectAll.mdx create mode 100644 src/content/reference/en/p5 copy/set.mdx create mode 100644 src/content/reference/en/p5 copy/setAttributes.mdx create mode 100644 src/content/reference/en/p5 copy/setBPM.mdx create mode 100644 src/content/reference/en/p5 copy/setCamera.mdx create mode 100644 src/content/reference/en/p5 copy/setMoveThreshold.mdx create mode 100644 src/content/reference/en/p5 copy/setShakeThreshold.mdx create mode 100644 src/content/reference/en/p5 copy/setup.mdx create mode 100644 src/content/reference/en/p5 copy/shader.mdx create mode 100644 src/content/reference/en/p5 copy/shearX.mdx create mode 100644 src/content/reference/en/p5 copy/shearY.mdx create mode 100644 src/content/reference/en/p5 copy/shininess.mdx create mode 100644 src/content/reference/en/p5 copy/shorten.mdx create mode 100644 src/content/reference/en/p5 copy/shuffle.mdx create mode 100644 src/content/reference/en/p5 copy/sin.mdx create mode 100644 src/content/reference/en/p5 copy/smooth.mdx create mode 100644 src/content/reference/en/p5 copy/sort.mdx create mode 100644 src/content/reference/en/p5 copy/soundFormats.mdx create mode 100644 src/content/reference/en/p5 copy/soundOut.mdx create mode 100644 src/content/reference/en/p5 copy/specularColor.mdx create mode 100644 src/content/reference/en/p5 copy/specularMaterial.mdx create mode 100644 src/content/reference/en/p5 copy/sphere.mdx create mode 100644 src/content/reference/en/p5 copy/splice.mdx create mode 100644 src/content/reference/en/p5 copy/split.mdx create mode 100644 src/content/reference/en/p5 copy/splitTokens.mdx create mode 100644 src/content/reference/en/p5 copy/spotLight.mdx create mode 100644 src/content/reference/en/p5 copy/sq.mdx create mode 100644 src/content/reference/en/p5 copy/sqrt.mdx create mode 100644 src/content/reference/en/p5 copy/square.mdx create mode 100644 src/content/reference/en/p5 copy/storeItem.mdx create mode 100644 src/content/reference/en/p5 copy/str.mdx create mode 100644 src/content/reference/en/p5 copy/stroke.mdx create mode 100644 src/content/reference/en/p5 copy/strokeCap.mdx create mode 100644 src/content/reference/en/p5 copy/strokeJoin.mdx create mode 100644 src/content/reference/en/p5 copy/strokeWeight.mdx create mode 100644 src/content/reference/en/p5 copy/subset.mdx create mode 100644 src/content/reference/en/p5 copy/tan.mdx create mode 100644 src/content/reference/en/p5 copy/text.mdx create mode 100644 src/content/reference/en/p5 copy/textAlign.mdx create mode 100644 src/content/reference/en/p5 copy/textAscent.mdx create mode 100644 src/content/reference/en/p5 copy/textDescent.mdx create mode 100644 src/content/reference/en/p5 copy/textFont.mdx create mode 100644 src/content/reference/en/p5 copy/textLeading.mdx create mode 100644 src/content/reference/en/p5 copy/textOutput.mdx create mode 100644 src/content/reference/en/p5 copy/textSize.mdx create mode 100644 src/content/reference/en/p5 copy/textStyle.mdx create mode 100644 src/content/reference/en/p5 copy/textWidth.mdx create mode 100644 src/content/reference/en/p5 copy/textWrap.mdx create mode 100644 src/content/reference/en/p5 copy/texture.mdx create mode 100644 src/content/reference/en/p5 copy/textureMode.mdx create mode 100644 src/content/reference/en/p5 copy/textureWrap.mdx create mode 100644 src/content/reference/en/p5 copy/tint.mdx create mode 100644 src/content/reference/en/p5 copy/torus.mdx create mode 100644 src/content/reference/en/p5 copy/touchEnded.mdx create mode 100644 src/content/reference/en/p5 copy/touchMoved.mdx create mode 100644 src/content/reference/en/p5 copy/touchStarted.mdx create mode 100644 src/content/reference/en/p5 copy/touches.mdx create mode 100644 src/content/reference/en/p5 copy/translate.mdx create mode 100644 src/content/reference/en/p5 copy/triangle.mdx create mode 100644 src/content/reference/en/p5 copy/trim.mdx create mode 100644 src/content/reference/en/p5 copy/turnAxis.mdx create mode 100644 src/content/reference/en/p5 copy/types/Array.mdx create mode 100644 src/content/reference/en/p5 copy/types/Boolean.mdx create mode 100644 src/content/reference/en/p5 copy/types/Number.mdx create mode 100644 src/content/reference/en/p5 copy/types/Object.mdx create mode 100644 src/content/reference/en/p5 copy/types/String.mdx create mode 100644 src/content/reference/en/p5 copy/unchar.mdx create mode 100644 src/content/reference/en/p5 copy/unhex.mdx create mode 100644 src/content/reference/en/p5 copy/updatePixels.mdx create mode 100644 src/content/reference/en/p5 copy/userStartAudio.mdx create mode 100644 src/content/reference/en/p5 copy/vertex.mdx create mode 100644 src/content/reference/en/p5 copy/webglVersion.mdx create mode 100644 src/content/reference/en/p5 copy/while.mdx create mode 100644 src/content/reference/en/p5 copy/width.mdx create mode 100644 src/content/reference/en/p5 copy/winMouseX.mdx create mode 100644 src/content/reference/en/p5 copy/winMouseY.mdx create mode 100644 src/content/reference/en/p5 copy/windowHeight.mdx create mode 100644 src/content/reference/en/p5 copy/windowResized.mdx create mode 100644 src/content/reference/en/p5 copy/windowWidth.mdx create mode 100644 src/content/reference/en/p5 copy/year.mdx diff --git a/src/content/reference/en/p5 copy/abs.mdx b/src/content/reference/en/p5 copy/abs.mdx new file mode 100644 index 0000000000..1bdb6895ff --- /dev/null +++ b/src/content/reference/en/p5 copy/abs.mdx @@ -0,0 +1,61 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L10 +title: abs +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Calculates the absolute value of a number.

+ +

A number's absolute value is its distance from zero on the number line. + + -5 and 5 are both five units away from zero, so calling abs(-5) + and + + abs(5) both return 5. The absolute value of a number is always + positive.

+line: 10 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A gray square with a vertical black line that divides it in half. A white rectangle gets taller when the user moves the mouse away from the line.'); + } + + function draw() { + background(200); + + // Divide the canvas. + line(50, 0, 50, 100); + + // Calculate the mouse's distance from the middle. + let h = abs(mouseX - 50); + + // Draw a rectangle based on the mouse's distance + // from the middle. + rect(0, 100 - h, 100, h); + } + +
+class: p5 +params: + - name: 'n' + description: | +

number to compute.

+ type: Number +return: + description: absolute value of given number. + type: Number +chainable: false +--- + + +# abs diff --git a/src/content/reference/en/p5 copy/accelerationX.mdx b/src/content/reference/en/p5 copy/accelerationX.mdx new file mode 100644 index 0000000000..6a47fc46ce --- /dev/null +++ b/src/content/reference/en/p5 copy/accelerationX.mdx @@ -0,0 +1,37 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L23 +title: accelerationX +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

The system variable accelerationX always contains the acceleration of the + + device along the x axis. Value is represented as meters per second + squared.

+line: 23 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // Move a touchscreen device to register + // acceleration changes. + function draw() { + background(220, 50); + fill('magenta'); + ellipse(width / 2, height / 2, accelerationX); + describe('Magnitude of device acceleration is displayed as ellipse size.'); + } + +
+class: p5 +type: Number +--- + + +# accelerationX diff --git a/src/content/reference/en/p5 copy/accelerationY.mdx b/src/content/reference/en/p5 copy/accelerationY.mdx new file mode 100644 index 0000000000..bf5f54e39b --- /dev/null +++ b/src/content/reference/en/p5 copy/accelerationY.mdx @@ -0,0 +1,37 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L45 +title: accelerationY +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

The system variable accelerationY always contains the acceleration of the + + device along the y axis. Value is represented as meters per second + squared.

+line: 45 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // Move a touchscreen device to register + // acceleration changes. + function draw() { + background(220, 50); + fill('magenta'); + ellipse(width / 2, height / 2, accelerationY); + describe('Magnitude of device acceleration is displayed as ellipse size'); + } + +
+class: p5 +type: Number +--- + + +# accelerationY diff --git a/src/content/reference/en/p5 copy/accelerationZ.mdx b/src/content/reference/en/p5 copy/accelerationZ.mdx new file mode 100644 index 0000000000..11e5cbb53e --- /dev/null +++ b/src/content/reference/en/p5 copy/accelerationZ.mdx @@ -0,0 +1,37 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L67 +title: accelerationZ +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

The system variable accelerationZ always contains the acceleration of the + + device along the z axis. Value is represented as meters per second + squared.

+line: 67 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // Move a touchscreen device to register + // acceleration changes. + function draw() { + background(220, 50); + fill('magenta'); + ellipse(width / 2, height / 2, accelerationZ); + describe('Magnitude of device acceleration is displayed as ellipse size'); + } + +
+class: p5 +type: Number +--- + + +# accelerationZ diff --git a/src/content/reference/en/p5 copy/acos.mdx b/src/content/reference/en/p5 copy/acos.mdx new file mode 100644 index 0000000000..c9ed943f5e --- /dev/null +++ b/src/content/reference/en/p5 copy/acos.mdx @@ -0,0 +1,86 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L18 +title: acos +module: Math +submodule: Trigonometry +file: src/math/trigonometry.js +description: > +

Calculates the arc cosine of a number.

+ +

acos() is the inverse of cos(). It expects + + arguments in the range -1 to 1. By default, acos() returns values + in the + + range 0 to π (about 3.14). If the + + angleMode() is DEGREES, + then values are + + returned in the range 0 to 180.

+line: 18 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Calculate cos() and acos() values. + let a = PI; + let c = cos(a); + let ac = acos(c); + + // Display the values. + text(`${round(a, 3)}`, 35, 25); + text(`${round(c, 3)}`, 35, 50); + text(`${round(ac, 3)}`, 35, 75); + + describe('The numbers 3.142, -1, and 3.142 written on separate rows.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Calculate cos() and acos() values. + let a = PI + QUARTER_PI; + let c = cos(a); + let ac = acos(c); + + // Display the values. + text(`${round(a, 3)}`, 35, 25); + text(`${round(c, 3)}`, 35, 50); + text(`${round(ac, 3)}`, 35, 75); + + describe('The numbers 3.927, -0.707, and 2.356 written on separate rows.'); + } + +
+class: p5 +params: + - name: value + description: | +

value whose arc cosine is to be returned.

+ type: Number +return: + description: arc cosine of the given value. + type: Number +chainable: false +--- + + +# acos diff --git a/src/content/reference/en/p5 copy/alpha.mdx b/src/content/reference/en/p5 copy/alpha.mdx new file mode 100644 index 0000000000..c1a87aa78d --- /dev/null +++ b/src/content/reference/en/p5 copy/alpha.mdx @@ -0,0 +1,120 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L16 +title: alpha +module: Color +submodule: Creating & Reading +file: src/color/creating_reading.js +description: > +

Gets the alpha (transparency) value of a color.

+ +

alpha() extracts the alpha value from a + + p5.Color object, an array of color + components, or + + a CSS color string.

+line: 16 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object. + let c = color(0, 126, 255, 102); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'alphaValue' to 102. + let alphaValue = alpha(c); + + // Draw the right rectangle. + fill(alphaValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light blue and the right one is charcoal gray.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a color array. + let c = [0, 126, 255, 102]; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'alphaValue' to 102. + let alphaValue = alpha(c); + + // Draw the left rectangle. + fill(alphaValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light blue and the right one is charcoal gray.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a CSS color string. + let c = 'rgba(0, 126, 255, 0.4)'; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'alphaValue' to 102. + let alphaValue = alpha(c); + + // Draw the right rectangle. + fill(alphaValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light blue and the right one is charcoal gray.'); + } + +
+class: p5 +params: + - name: color + description: | +

p5.Color object, array of + color components, or CSS color string.

+ type: 'p5.Color|Number[]|String' +return: + description: the alpha value. + type: Number +chainable: false +--- + + +# alpha diff --git a/src/content/reference/en/p5 copy/ambientLight.mdx b/src/content/reference/en/p5 copy/ambientLight.mdx new file mode 100644 index 0000000000..09f9159592 --- /dev/null +++ b/src/content/reference/en/p5 copy/ambientLight.mdx @@ -0,0 +1,241 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L10 +title: ambientLight +module: 3D +submodule: Lights +file: src/webgl/light.js +description: > +

Creates a light that shines from all directions.

+ +

Ambient light does not come from one direction. Instead, 3D shapes are + + lit evenly from all sides. Ambient lights are almost always used in + + combination with other types of lights.

+ +

There are three ways to call ambientLight() with optional + parameters to + + set the light’s color.

+ +

The first way to call ambientLight() has two parameters, + gray and + + alpha. alpha is optional. Grayscale and alpha values + between 0 and 255 + + can be passed to set the ambient light’s color, as in + ambientLight(50) or + + ambientLight(50, 30).

+ +

The second way to call ambientLight() has one parameter, + color. A + + p5.Color object, an array of color + values, or a + + CSS color string, as in ambientLight('magenta'), can be passed to + set the + + ambient light’s color.

+ +

The third way to call ambientLight() has four parameters, + v1, v2, + + v3, and alpha. alpha is optional. RGBA, + HSBA, or HSLA values can be + + passed to set the ambient light’s colors, as in ambientLight(255, 0, + 0) + + or ambientLight(255, 0, 0, 30). Color values will be interpreted + using + + the current colorMode().

+line: 10 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click the canvas to turn on the light. + + let isLit = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A sphere drawn against a gray background. The sphere appears to change color when the user double-clicks.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Control the light. + if (isLit === true) { + // Use a grayscale value of 80. + ambientLight(80); + } + + // Draw the sphere. + sphere(30); + } + + // Turn on the ambient light when the user double-clicks. + function doubleClicked() { + isLit = true; + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A faded magenta sphere drawn against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + // Use a p5.Color object. + let c = color('orchid'); + ambientLight(c); + + // Draw the sphere. + sphere(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A faded magenta sphere drawn against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + // Use a CSS color string. + ambientLight('#DA70D6'); + + // Draw the sphere. + sphere(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A faded magenta sphere drawn against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + // Use RGB values + ambientLight(218, 112, 214); + + // Draw the sphere. + sphere(30); + } + +
+class: p5 +overloads: + - line: 10 + params: + - name: v1 + description: | +

red or hue value in the current + colorMode().

+ type: Number + - name: v2 + description: | +

green or saturation value in the current + colorMode().

+ type: Number + - name: v3 + description: | +

blue, brightness, or lightness value in the current + colorMode().

+ type: Number + - name: alpha + description: | +

alpha (transparency) value in the current + colorMode().

+ type: Number + optional: true + chainable: 1 + - line: 164 + params: + - name: gray + description: | +

grayscale value between 0 and 255.

+ type: Number + - name: alpha + description: '' + type: Number + optional: true + chainable: 1 + - line: 171 + params: + - name: value + description: | +

color as a CSS string.

+ type: String + chainable: 1 + - line: 177 + params: + - name: values + description: | +

color as an array of RGBA, HSBA, or HSLA + values.

+ type: 'Number[]' + chainable: 1 + - line: 184 + params: + - name: color + description: | +

color as a p5.Color object.

+ type: p5.Color + chainable: 1 +chainable: true +--- + + +# ambientLight diff --git a/src/content/reference/en/p5 copy/ambientMaterial.mdx b/src/content/reference/en/p5 copy/ambientMaterial.mdx new file mode 100644 index 0000000000..8b96f24260 --- /dev/null +++ b/src/content/reference/en/p5 copy/ambientMaterial.mdx @@ -0,0 +1,269 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2416 +title: ambientMaterial +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Sets the ambient color of shapes’ surface material.

+ +

The ambientMaterial() color sets the components of the + + ambientLight() color that shapes + will + + reflect. For example, calling ambientMaterial(255, 255, 0) would + cause a + + shape to reflect red and green light, but not blue light.

+ +

ambientMaterial() can be called three ways with different + parameters to + + set the material’s color.

+ +

The first way to call ambientMaterial() has one parameter, + gray. + + Grayscale values between 0 and 255, as in ambientMaterial(50), + can be + + passed to set the material’s color. Higher grayscale values make shapes + + appear brighter.

+ +

The second way to call ambientMaterial() has one parameter, + color. A + + p5.Color object, an array of color + values, or a + + CSS color string, as in ambientMaterial('magenta'), can be passed + to set + + the material’s color.

+ +

The third way to call ambientMaterial() has three parameters, + v1, v2, + + and v3. RGB, HSB, or HSL values, as in ambientMaterial(255, + 0, 0), can + + be passed to set the material’s colors. Color values will be interpreted + + using the current colorMode().

+ +

Note: ambientMaterial() can only be used in WebGL mode.

+line: 2416 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A magenta cube drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on a magenta ambient light. + ambientLight(255, 0, 255); + + // Draw the box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A purple cube drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on a magenta ambient light. + ambientLight(255, 0, 255); + + // Add a dark gray ambient material. + ambientMaterial(150); + + // Draw the box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A red cube drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on a magenta ambient light. + ambientLight(255, 0, 255); + + // Add a yellow ambient material using RGB values. + ambientMaterial(255, 255, 0); + + // Draw the box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A red cube drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on a magenta ambient light. + ambientLight(255, 0, 255); + + // Add a yellow ambient material using a p5.Color object. + let c = color(255, 255, 0); + ambientMaterial(c); + + // Draw the box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A red cube drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on a magenta ambient light. + ambientLight(255, 0, 255); + + // Add a yellow ambient material using a color string. + ambientMaterial('yellow'); + + // Draw the box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A yellow cube drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on a white ambient light. + ambientLight(255, 255, 255); + + // Add a yellow ambient material using a color string. + ambientMaterial('yellow'); + + // Draw the box. + box(); + } + +
+class: p5 +overloads: + - line: 2416 + params: + - name: v1 + description: | +

red or hue value in the current + colorMode().

+ type: Number + - name: v2 + description: | +

green or saturation value in the + current colorMode().

+ type: Number + - name: v3 + description: | +

blue, brightness, or lightness value in the + current colorMode().

+ type: Number + chainable: 1 + - line: 2621 + params: + - name: gray + description: | +

grayscale value between 0 (black) and 255 (white).

+ type: Number + chainable: 1 + - line: 2627 + params: + - name: color + description: | +

color as a p5.Color object, + an array of color values, or a CSS string.

+ type: 'p5.Color|Number[]|String' + chainable: 1 +chainable: true +--- + + +# ambientMaterial diff --git a/src/content/reference/en/p5 copy/angleMode.mdx b/src/content/reference/en/p5 copy/angleMode.mdx new file mode 100644 index 0000000000..3401a563cd --- /dev/null +++ b/src/content/reference/en/p5 copy/angleMode.mdx @@ -0,0 +1,219 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L557 +title: angleMode +module: Math +submodule: Trigonometry +file: src/math/trigonometry.js +description: > +

Changes the unit system used to measure angles.

+ +

Degrees and radians are both units for measuring angles. There are 360˚ in + + one full rotation. A full rotation is 2 × π (about 6.28) radians.

+ +

Functions such as rotate() and + + sin() expect angles measured radians by + default. + + Calling angleMode(DEGREES) switches to degrees. Calling + + angleMode(RADIANS) switches back to radians.

+ +

Calling angleMode() with no arguments returns current angle + mode, which + + is either RADIANS or DEGREES.

+line: 557 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Rotate 1/8 turn. + rotate(QUARTER_PI); + + // Draw a line. + line(0, 0, 80, 0); + + describe('A diagonal line radiating from the top-left corner of a square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use degrees. + angleMode(DEGREES); + + // Rotate 1/8 turn. + rotate(45); + + // Draw a line. + line(0, 0, 80, 0); + + describe('A diagonal line radiating from the top-left corner of a square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(50); + + // Calculate the angle to rotate. + let angle = TWO_PI / 7; + + // Move the origin to the center. + translate(50, 50); + + // Style the flower. + noStroke(); + fill(255, 50); + + // Draw the flower. + for (let i = 0; i < 7; i += 1) { + ellipse(0, 0, 80, 20); + rotate(angle); + } + + describe('A translucent white flower on a dark background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(50); + + // Use degrees. + angleMode(DEGREES); + + // Calculate the angle to rotate. + let angle = 360 / 7; + + // Move the origin to the center. + translate(50, 50); + + // Style the flower. + noStroke(); + fill(255, 50); + + // Draw the flower. + for (let i = 0; i < 7; i += 1) { + ellipse(0, 0, 80, 20); + rotate(angle); + } + + describe('A translucent white flower on a dark background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A white ball on a string oscillates left and right.'); + } + + function draw() { + background(200); + + // Calculate the coordinates. + let x = 30 * cos(frameCount * 0.05) + 50; + let y = 50; + + // Draw the oscillator. + line(50, y, x, y); + circle(x, y, 20); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Use degrees. + angleMode(DEGREES); + + describe('A white ball on a string oscillates left and right.'); + } + + function draw() { + background(200); + + // Calculate the coordinates. + let x = 30 * cos(frameCount * 2.86) + 50; + let y = 50; + + // Draw the oscillator. + line(50, y, x, y); + circle(x, y, 20); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw the upper line. + rotate(PI / 6); + line(0, 0, 80, 0); + + // Use degrees. + angleMode(DEGREES); + + // Draw the lower line. + rotate(30); + line(0, 0, 80, 0); + + describe('Two diagonal lines radiating from the top-left corner of a square. The lines are oriented 30 degrees from the edges of the square and 30 degrees apart from each other.'); + } + +
+class: p5 +overloads: + - line: 557 + params: + - name: mode + description: | +

either RADIANS or DEGREES.

+ type: Constant + - line: 743 + params: [] + return: + description: mode either RADIANS or DEGREES + type: Constant +chainable: false +--- + + +# angleMode diff --git a/src/content/reference/en/p5 copy/append.mdx b/src/content/reference/en/p5 copy/append.mdx new file mode 100644 index 0000000000..4e0bbeb5eb --- /dev/null +++ b/src/content/reference/en/p5 copy/append.mdx @@ -0,0 +1,48 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L10 +title: append +module: Data +submodule: Array Functions +file: src/utilities/array_functions.js +description: | +

Adds a value to the end of an array. Extends the length of + the array by one. Maps to Array.push().

+line: 10 +deprecated: >- + Use array.push(value) + instead. +isConstructor: false +itemtype: method +example: + - |- + +
+ function setup() { + let myArray = ['Mango', 'Apple', 'Papaya']; + print(myArray); // ['Mango', 'Apple', 'Papaya'] + + append(myArray, 'Peach'); + print(myArray); // ['Mango', 'Apple', 'Papaya', 'Peach'] + } +
+class: p5 +params: + - name: array + description: | +

Array to append

+ type: Array + - name: value + description: | +

to be added to the Array

+ type: Any +return: + description: the array that was appended to + type: Array +chainable: false +--- + + +# append diff --git a/src/content/reference/en/p5 copy/applyMatrix.mdx b/src/content/reference/en/p5 copy/applyMatrix.mdx new file mode 100644 index 0000000000..b105ed75da --- /dev/null +++ b/src/content/reference/en/p5 copy/applyMatrix.mdx @@ -0,0 +1,347 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L11 +title: applyMatrix +module: Transform +submodule: Transform +file: src/core/transform.js +description: > +

Applies a transformation matrix to the coordinate system.

+ +

Transformations such as + + translate(), + + rotate(), and + + scale() + + use matrix-vector multiplication behind the scenes. A table of numbers, + + called a matrix, encodes each transformation. The values in the matrix + + then multiply each point on the canvas, which is represented by a vector.

+ +

applyMatrix() allows for many transformations to be applied at + once. See + + Wikipedia + + and MDN + + for more details about transformations.

+ +

There are two ways to call applyMatrix() in two and three + dimensions.

+ +

In 2D mode, the parameters a, b, c, + d, e, and f, correspond to + + elements in the following transformation matrix:

+ +
+ +

The transformation matrix used when applyMatrix is called in 2D
+  mode.

+ +
+ +

The numbers can be passed individually, as in + + applyMatrix(2, 0, 0, 0, 2, 0). They can also be passed in an + array, as in + + applyMatrix([2, 0, 0, 0, 2, 0]).

+ +

In 3D mode, the parameters a, b, c, + d, e, f, g, + h, i, + + j, k, l, m, + n, o, and p correspond to elements in + the + + following transformation matrix:

+ +

The transformation matrix used when applyMatrix is called in 3D
+  mode.

+ +

The numbers can be passed individually, as in + + applyMatrix(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1). They + can + + also be passed in an array, as in + + applyMatrix([2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, + 1]).

+ +

By default, transformations accumulate. The + + push() and pop() functions + + can be used to isolate transformations within distinct drawing groups.

+ +

Note: Transformations are reset at the beginning of the draw loop. Calling + + applyMatrix() inside the draw() + function won't + + cause shapes to transform continuously.

+line: 11 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A white circle on a gray background.'); + } + + function draw() { + background(200); + + // Translate the origin to the center. + applyMatrix(1, 0, 0, 1, 50, 50); + + // Draw the circle at coordinates (0, 0). + circle(0, 0, 40); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A white circle on a gray background.'); + } + + function draw() { + background(200); + + // Translate the origin to the center. + let m = [1, 0, 0, 1, 50, 50]; + applyMatrix(m); + + // Draw the circle at coordinates (0, 0). + circle(0, 0, 40); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe("A white rectangle on a gray background. The rectangle's long axis runs from top-left to bottom-right."); + } + + function draw() { + background(200); + + // Rotate the coordinate system 1/8 turn. + let angle = QUARTER_PI; + let ca = cos(angle); + let sa = sin(angle); + applyMatrix(ca, sa, -sa, ca, 0, 0); + + // Draw a rectangle at coordinates (50, 0). + rect(50, 0, 40, 20); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'Two white squares on a gray background. The larger square appears at the top-center. The smaller square appears at the top-left.' + ); + } + + function draw() { + background(200); + + // Draw a square at (30, 20). + square(30, 20, 40); + + // Scale the coordinate system by a factor of 0.5. + applyMatrix(0.5, 0, 0, 0.5, 0, 0); + + // Draw a square at (30, 20). + // It appears at (15, 10) after scaling. + square(30, 20, 40); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A white quadrilateral on a gray background.'); + } + + function draw() { + background(200); + + // Calculate the shear factor. + let angle = QUARTER_PI; + let shearFactor = 1 / tan(HALF_PI - angle); + + // Shear the coordinate system along the x-axis. + applyMatrix(1, 0, shearFactor, 1, 0, 0); + + // Draw the square. + square(0, 0, 50); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube rotates slowly against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system a little more each frame. + let angle = frameCount * 0.01; + let ca = cos(angle); + let sa = sin(angle); + applyMatrix(ca, 0, sa, 0, 0, 1, 0, 0, -sa, 0, ca, 0, 0, 0, 0, 1); + + // Draw a box. + box(); + } + +
+class: p5 +overloads: + - line: 11 + params: + - name: arr + description: > +

an array containing the elements of the transformation matrix. Its + length should be either 6 (2D) or 16 (3D).

+ type: Array + chainable: 1 + - line: 206 + params: + - name: a + description: | +

an element of the transformation matrix.

+ type: Number + - name: b + description: | +

an element of the transformation matrix.

+ type: Number + - name: c + description: | +

an element of the transformation matrix.

+ type: Number + - name: d + description: | +

an element of the transformation matrix.

+ type: Number + - name: e + description: | +

an element of the transformation matrix.

+ type: Number + - name: f + description: | +

an element of the transformation matrix.

+ type: Number + chainable: 1 + - line: 216 + params: + - name: a + description: '' + type: Number + - name: b + description: '' + type: Number + - name: c + description: '' + type: Number + - name: d + description: '' + type: Number + - name: e + description: '' + type: Number + - name: f + description: '' + type: Number + - name: g + description: | +

an element of the transformation matrix.

+ type: Number + - name: h + description: | +

an element of the transformation matrix.

+ type: Number + - name: i + description: | +

an element of the transformation matrix.

+ type: Number + - name: j + description: | +

an element of the transformation matrix.

+ type: Number + - name: k + description: | +

an element of the transformation matrix.

+ type: Number + - name: l + description: | +

an element of the transformation matrix.

+ type: Number + - name: m + description: | +

an element of the transformation matrix.

+ type: Number + - name: 'n' + description: | +

an element of the transformation matrix.

+ type: Number + - name: o + description: | +

an element of the transformation matrix.

+ type: Number + - name: p + description: | +

an element of the transformation matrix.

+ type: Number + chainable: 1 +chainable: true +--- + + +# applyMatrix diff --git a/src/content/reference/en/p5 copy/arc.mdx b/src/content/reference/en/p5 copy/arc.mdx new file mode 100644 index 0000000000..ee50708815 --- /dev/null +++ b/src/content/reference/en/p5 copy/arc.mdx @@ -0,0 +1,274 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L102 +title: arc +module: Shape +submodule: 2D Primitives +file: src/core/shape/2d_primitives.js +description: > +

Draws an arc.

+ +

An arc is a section of an ellipse defined by the x, + y, w, and + + h parameters. x and y set the location + of the arc's center. w and + + h set the arc's width and height. See + + ellipse() and + + ellipseMode() for more details.

+ +

The fifth and sixth parameters, start and stop, + set the angles + + between which to draw the arc. Arcs are always drawn clockwise from + + start to stop. The fifth and sixth parameters, start + and stop, set the + + angles between which to draw the arc. By default, angles are given in radians, + but if angleMode + + (DEGREES) is set, the function interprets the values in degrees.

+ +

The seventh parameter, mode, is optional. It determines the + arc's fill + + style. The fill modes are a semi-circle (OPEN), a closed + semi-circle + + (CHORD), or a closed pie segment (PIE).

+ +

The eighth parameter, detail, is also optional. It determines + how many + + vertices are used to draw the arc in WebGL mode. The default value is 25.

+line: 102 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + arc(50, 50, 80, 80, 0, PI + HALF_PI); + + describe('A white circle on a gray canvas. The top-right quarter of the circle is missing.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + arc(50, 50, 80, 40, 0, PI + HALF_PI); + + describe('A white ellipse on a gray canvas. The top-right quarter of the ellipse is missing.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Bottom-right. + arc(50, 55, 50, 50, 0, HALF_PI); + + noFill(); + + // Bottom-left. + arc(50, 55, 60, 60, HALF_PI, PI); + + // Top-left. + arc(50, 55, 70, 70, PI, PI + QUARTER_PI); + + // Top-right. + arc(50, 55, 80, 80, PI + QUARTER_PI, TWO_PI); + + describe( + 'A shattered outline of an circle with a quarter of a white circle at the bottom-right.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Default fill mode. + arc(50, 50, 80, 80, 0, PI + QUARTER_PI); + + describe('A white circle with the top-right third missing. The bottom is outlined in black.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // OPEN fill mode. + arc(50, 50, 80, 80, 0, PI + QUARTER_PI, OPEN); + + describe( + 'A white circle missing a section from the top-right. The bottom is outlined in black.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // CHORD fill mode. + arc(50, 50, 80, 80, 0, PI + QUARTER_PI, CHORD); + + describe('A white circle with a black outline missing a section from the top-right.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // PIE fill mode. + arc(50, 50, 80, 80, 0, PI + QUARTER_PI, PIE); + + describe('A white circle with a black outline. The top-right third is missing.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + // PIE fill mode. + arc(0, 0, 80, 80, 0, PI + QUARTER_PI, PIE); + + describe('A white circle with a black outline. The top-right third is missing.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + // PIE fill mode with 5 vertices. + arc(0, 0, 80, 80, 0, PI + QUARTER_PI, PIE, 5); + + describe('A white circle with a black outline. The top-right third is missing.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A yellow circle on a black background. The circle opens and closes its mouth.'); + } + + function draw() { + background(0); + + // Style the arc. + noStroke(); + fill(255, 255, 0); + + // Update start and stop angles. + let biteSize = PI / 16; + let startAngle = biteSize * sin(frameCount * 0.1) + biteSize; + let endAngle = TWO_PI - startAngle; + + // Draw the arc. + arc(50, 50, 80, 80, startAngle, endAngle, PIE); + } + +
+class: p5 +params: + - name: x + description: | +

x-coordinate of the arc's ellipse.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the arc's ellipse.

+ type: Number + - name: w + description: | +

width of the arc's ellipse by default.

+ type: Number + - name: h + description: | +

height of the arc's ellipse by default.

+ type: Number + - name: start + description: | +

angle to start the arc, specified in radians.

+ type: Number + - name: stop + description: | +

angle to stop the arc, specified in radians.

+ type: Number + - name: mode + description: | +

optional parameter to determine the way of drawing + the arc. either CHORD, PIE, or OPEN.

+ type: Constant + optional: true + - name: detail + description: | +

optional parameter for WebGL mode only. This is to + specify the number of vertices that makes up the + perimeter of the arc. Default value is 25. Won't + draw a stroke for a detail of more than 50.

+ type: Integer + optional: true +chainable: true +--- + + +# arc diff --git a/src/content/reference/en/p5 copy/arrayCopy.mdx b/src/content/reference/en/p5 copy/arrayCopy.mdx new file mode 100644 index 0000000000..2d149d1ed3 --- /dev/null +++ b/src/content/reference/en/p5 copy/arrayCopy.mdx @@ -0,0 +1,95 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L35 +title: arrayCopy +module: Data +submodule: Array Functions +file: src/utilities/array_functions.js +description: > +

Copies an array (or part of an array) to another array. The src array is + + copied to the dst array, beginning at the position specified by + + srcPosition and into the position specified by dstPosition. The number of + + elements to copy is determined by length. Note that copying values + + overwrites existing values in the destination array. To append values + + instead of overwriting them, use concat().

+ +

The simplified version with only two arguments, arrayCopy(src, dst), + + copies an entire array to another of the same size. It is equivalent to + + arrayCopy(src, 0, dst, 0, src.length).

+ +

Using this function is far more efficient for copying array data than + + iterating through a for() loop and copying each element individually.

+line: 35 +deprecated: >- + Use arr1.copyWithin(arr2) + instead. +isConstructor: false +itemtype: method +example: + - |- + +
+ let src = ['A', 'B', 'C']; + let dst = [1, 2, 3]; + let srcPosition = 1; + let dstPosition = 0; + let length = 2; + + print(src); // ['A', 'B', 'C'] + print(dst); // [ 1 , 2 , 3 ] + + arrayCopy(src, srcPosition, dst, dstPosition, length); + print(dst); // ['B', 'C', 3] +
+class: p5 +overloads: + - line: 35 + params: + - name: src + description: | +

the source Array

+ type: Array + - name: srcPosition + description: | +

starting position in the source Array

+ type: Integer + - name: dst + description: | +

the destination Array

+ type: Array + - name: dstPosition + description: | +

starting position in the destination Array

+ type: Integer + - name: length + description: | +

number of Array elements to be copied

+ type: Integer + - line: 73 + params: + - name: src + description: '' + type: Array + - name: dst + description: '' + type: Array + - name: length + description: '' + type: Integer + optional: true +chainable: false +--- + + +# arrayCopy diff --git a/src/content/reference/en/p5 copy/asin.mdx b/src/content/reference/en/p5 copy/asin.mdx new file mode 100644 index 0000000000..78518c0050 --- /dev/null +++ b/src/content/reference/en/p5 copy/asin.mdx @@ -0,0 +1,86 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L80 +title: asin +module: Math +submodule: Trigonometry +file: src/math/trigonometry.js +description: > +

Calculates the arc sine of a number.

+ +

asin() is the inverse of sin(). It expects input + + values in the range of -1 to 1. By default, asin() returns values + in the + + range -π ÷ 2 (about -1.57) to π ÷ 2 (about 1.57). If + + the angleMode() is DEGREES + then values are + + returned in the range -90 to 90.

+line: 80 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Calculate sin() and asin() values. + let a = PI / 3; + let s = sin(a); + let as = asin(s); + + // Display the values. + text(`${round(a, 3)}`, 35, 25); + text(`${round(s, 3)}`, 35, 50); + text(`${round(as, 3)}`, 35, 75); + + describe('The numbers 1.047, 0.866, and 1.047 written on separate rows.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Calculate sin() and asin() values. + let a = PI + PI / 3; + let s = sin(a); + let as = asin(s); + + // Display the values. + text(`${round(a, 3)}`, 35, 25); + text(`${round(s, 3)}`, 35, 50); + text(`${round(as, 3)}`, 35, 75); + + describe('The numbers 4.189, -0.866, and -1.047 written on separate rows.'); + } + +
+class: p5 +params: + - name: value + description: | +

value whose arc sine is to be returned.

+ type: Number +return: + description: arc sine of the given value. + type: Number +chainable: false +--- + + +# asin diff --git a/src/content/reference/en/p5 copy/atan.mdx b/src/content/reference/en/p5 copy/atan.mdx new file mode 100644 index 0000000000..86b3874bb0 --- /dev/null +++ b/src/content/reference/en/p5 copy/atan.mdx @@ -0,0 +1,86 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L142 +title: atan +module: Math +submodule: Trigonometry +file: src/math/trigonometry.js +description: > +

Calculates the arc tangent of a number.

+ +

atan() is the inverse of tan(). It expects input + + values in the range of -Infinity to Infinity. By default, atan() + returns + + values in the range -π ÷ 2 (about -1.57) to π ÷ 2 + + (about 1.57). If the angleMode() is + DEGREES + + then values are returned in the range -90 to 90.

+line: 142 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Calculate tan() and atan() values. + let a = PI / 3; + let t = tan(a); + let at = atan(t); + + // Display the values. + text(`${round(a, 3)}`, 35, 25); + text(`${round(t, 3)}`, 35, 50); + text(`${round(at, 3)}`, 35, 75); + + describe('The numbers 1.047, 1.732, and 1.047 written on separate rows.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Calculate tan() and atan() values. + let a = PI + PI / 3; + let t = tan(a); + let at = atan(t); + + // Display the values. + text(`${round(a, 3)}`, 35, 25); + text(`${round(t, 3)}`, 35, 50); + text(`${round(at, 3)}`, 35, 75); + + describe('The numbers 4.189, 1.732, and 1.047 written on separate rows.'); + } + +
+class: p5 +params: + - name: value + description: | +

value whose arc tangent is to be returned.

+ type: Number +return: + description: arc tangent of the given value. + type: Number +chainable: false +--- + + +# atan diff --git a/src/content/reference/en/p5 copy/atan2.mdx b/src/content/reference/en/p5 copy/atan2.mdx new file mode 100644 index 0000000000..200b49516b --- /dev/null +++ b/src/content/reference/en/p5 copy/atan2.mdx @@ -0,0 +1,106 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L204 +title: atan2 +module: Math +submodule: Trigonometry +file: src/math/trigonometry.js +description: > +

Calculates the angle formed by a point, the origin, and the positive + + x-axis.

+ +

atan2() is most often used for orienting geometry to the + mouse's + + position, as in atan2(mouseY, mouseX). The first parameter is the + point's + + y-coordinate and the second parameter is its x-coordinate.

+ +

By default, atan2() returns values in the range + + -π (about -3.14) to π (3.14). If the + + angleMode() is DEGREES, + then values are + + returned in the range -180 to 180.

+line: 204 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A rectangle at the top-left of the canvas rotates with mouse movements.'); + } + + function draw() { + background(200); + + // Calculate the angle between the mouse + // and the origin. + let a = atan2(mouseY, mouseX); + + // Rotate. + rotate(a); + + // Draw the shape. + rect(0, 0, 60, 10); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A rectangle at the center of the canvas rotates with mouse movements.'); + } + + function draw() { + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Get the mouse's coordinates relative to the origin. + let x = mouseX - 50; + let y = mouseY - 50; + + // Calculate the angle between the mouse and the origin. + let a = atan2(y, x); + + // Rotate. + rotate(a); + + // Draw the shape. + rect(-30, -5, 60, 10); + } + +
+class: p5 +params: + - name: 'y' + description: | +

y-coordinate of the point.

+ type: Number + - name: x + description: | +

x-coordinate of the point.

+ type: Number +return: + description: arc tangent of the given point. + type: Number +chainable: false +--- + + +# atan2 diff --git a/src/content/reference/en/p5 copy/background.mdx b/src/content/reference/en/p5 copy/background.mdx new file mode 100644 index 0000000000..6250c60339 --- /dev/null +++ b/src/content/reference/en/p5 copy/background.mdx @@ -0,0 +1,336 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L414 +title: background +module: Color +submodule: Setting +file: src/color/setting.js +description: > +

Sets the color used for the background of the canvas.

+ +

By default, the background is transparent. background() is + typically used + + within draw() to clear the display window at + the + + beginning of each frame. It can also be used inside + + setup() to set the background on the first + frame + + of animation.

+ +

The version of background() with one parameter interprets the + value one + + of four ways. If the parameter is a Number, it's interpreted as a + grayscale + + value. If the parameter is a String, it's interpreted as a CSS + color string. + + RGB, RGBA, HSL, HSLA, hex, and named color strings are supported. If the + + parameter is a p5.Color object, it will + be used as + + the background color. If the parameter is a + + p5.Image object, it will be used as the + background + + image.

+ +

The version of background() with two parameters interprets the + first one + + as a grayscale value. The second parameter sets the alpha (transparency) + + value.

+ +

The version of background() with three parameters interprets + them as RGB, + + HSB, or HSL colors, depending on the current + + colorMode(). By default, colors are + specified + + in RGB values. Calling background(255, 204, 0) sets the + background a bright + + yellow color.

+ +

The version of background() with four parameters interprets + them as RGBA, + + HSBA, or HSLA colors, depending on the current + + colorMode(). The last parameter sets + the alpha + + (transparency) value.

+line: 414 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // A grayscale value. + background(51); + + describe('A canvas with a dark charcoal gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // A grayscale value and an alpha value. + background(51, 0.4); + describe('A canvas with a transparent gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // R, G & B values. + background(255, 204, 0); + + describe('A canvas with a yellow background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // R, G, B, and Alpha values. + background(255, 0, 0, 128); + + describe('A canvas with a semi-transparent red background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Use HSB color. + colorMode(HSB); + + // H, S & B values. + background(255, 204, 100); + + describe('A canvas with a royal blue background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // A CSS named color. + background('red'); + + describe('A canvas with a red background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Three-digit hex RGB notation. + background('#fae'); + + describe('A canvas with a pink background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Six-digit hex RGB notation. + background('#222222'); + + describe('A canvas with a black background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Integer RGB notation. + background('rgb(0, 255, 0)'); + + describe('A canvas with a bright green background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Integer RGBA notation. + background('rgba(0, 255, 0, 0.25)'); + + describe('A canvas with a transparent green background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Percentage RGB notation. + background('rgb(100%, 0%, 10%)'); + + describe('A canvas with a red background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Percentage RGBA notation. + background('rgba(100%, 0%, 100%, 0.5)'); + + describe('A canvas with a transparent purple background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // A p5.Color object. + let c = color(0, 0, 255); + background(c); + + describe('A canvas with a blue background.'); + } + +
+class: p5 +overloads: + - line: 414 + params: + - name: color + description: > +

any value created by the color() + function

+ type: p5.Color + chainable: 1 + - line: 626 + params: + - name: colorstring + description: | +

color string, possible formats include: integer + rgb() or rgba(), percentage rgb() or rgba(), + 3-digit hex, 6-digit hex.

+ type: String + - name: a + description: | +

opacity of the background relative to current + color range (default is 0-255).

+ type: Number + optional: true + chainable: 1 + - line: 636 + params: + - name: gray + description: | +

specifies a value between white and black.

+ type: Number + - name: a + description: '' + type: Number + optional: true + chainable: 1 + - line: 643 + params: + - name: v1 + description: > +

red value if color mode is RGB, or hue value if color mode is + HSB.

+ type: Number + - name: v2 + description: > +

green value if color mode is RGB, or saturation value if color mode + is HSB.

+ type: Number + - name: v3 + description: > +

blue value if color mode is RGB, or brightness value if color mode + is HSB.

+ type: Number + - name: a + description: '' + type: Number + optional: true + chainable: 1 + - line: 652 + params: + - name: values + description: | +

an array containing the red, green, blue + and alpha components of the color.

+ type: 'Number[]' + chainable: 1 + - line: 659 + params: + - name: image + description: | +

image created with loadImage() + or createImage(), + to set as background. + (must be same size as the sketch window).

+ type: p5.Image + - name: a + description: '' + type: Number + optional: true + chainable: 1 +chainable: true +--- + + +# background diff --git a/src/content/reference/en/p5 copy/baseColorShader.mdx b/src/content/reference/en/p5 copy/baseColorShader.mdx new file mode 100644 index 0000000000..a608e4d5ce --- /dev/null +++ b/src/content/reference/en/p5 copy/baseColorShader.mdx @@ -0,0 +1,178 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1292 +title: baseColorShader +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Get the shader used when no lights or materials are applied.

+ +

You can call baseColorShader().modify() + + and change any of the following hooks:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
HookDescription
void beforeVertexCalled at the start of the vertex shader.
vec3 getLocalPositionUpdate the position of vertices before transforms are applied. It takes in + vec3 position and must return a modified version.
vec3 getWorldPositionUpdate the position of vertices after transforms are applied. It takes in + vec3 position and pust return a modified version.
vec3 getLocalNormalUpdate the normal before transforms are applied. It takes in vec3 + normal and must return a modified version.
vec3 getWorldNormalUpdate the normal after transforms are applied. It takes in vec3 + normal and must return a modified version.
vec2 getUVUpdate the texture coordinates. It takes in vec2 uv and must + return a modified version.
vec4 getVertexColorUpdate the color of each vertex. It takes in a vec4 color and + must return a modified version.
void afterVertexCalled at the end of the vertex shader.
void beforeFragmentCalled at the start of the fragment shader.
vec4 getFinalColorUpdate the final color after mixing. It takes in a vec4 color + and must return a modified version.
void afterFragmentCalled at the end of the fragment shader.
+ +

Most of the time, you will need to write your hooks in GLSL ES version 300. + If you + + are using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.

+ +

Call baseColorShader().inspectHooks() to see all the possible + hooks and + + their default implementations.

+line: 1292 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let myShader; + + function setup() { + createCanvas(200, 200, WEBGL); + myShader = baseColorShader().modify({ + uniforms: { + 'float time': () => millis() + }, + 'vec3 getWorldPosition': `(vec3 pos) { + pos.y += 20. * sin(time * 0.001 + pos.x * 0.05); + return pos; + }` + }); + } + + function draw() { + background(255); + shader(myShader); + noStroke(); + fill('red'); + circle(0, 0, 50); + } + +
+class: p5 +return: + description: The color shader + type: p5.Shader +chainable: false +beta: true +--- + + +# baseColorShader diff --git a/src/content/reference/en/p5 copy/baseMaterialShader.mdx b/src/content/reference/en/p5 copy/baseMaterialShader.mdx new file mode 100644 index 0000000000..d41248d1aa --- /dev/null +++ b/src/content/reference/en/p5 copy/baseMaterialShader.mdx @@ -0,0 +1,418 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L886 +title: baseMaterialShader +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Get the default shader used with lights, materials, + + and textures.

+ +

You can call baseMaterialShader().modify() + + and change any of the following hooks:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
HookDescription
+ + +

void beforeVertex

+ +
+ + +

Called at the start of the vertex shader.

+ +
+ + +

vec3 getLocalPosition

+ +
+ + +

Update the position of vertices before transforms are applied. It takes in + vec3 position and must return a modified version.

+ +
+ + +

vec3 getWorldPosition

+ +
+ + +

Update the position of vertices after transforms are applied. It takes in + vec3 position and pust return a modified version.

+ +
+ + +

vec3 getLocalNormal

+ +
+ + +

Update the normal before transforms are applied. It takes in vec3 + normal and must return a modified version.

+ +
+ + +

vec3 getWorldNormal

+ +
+ + +

Update the normal after transforms are applied. It takes in vec3 + normal and must return a modified version.

+ +
+ + +

vec2 getUV

+ +
+ + +

Update the texture coordinates. It takes in vec2 uv and must + return a modified version.

+ +
+ + +

vec4 getVertexColor

+ +
+ + +

Update the color of each vertex. It takes in a vec4 color and + must return a modified version.

+ +
+ + +

void afterVertex

+ +
+ + +

Called at the end of the vertex shader.

+ +
+ + +

void beforeFragment

+ +
+ + +

Called at the start of the fragment shader.

+ +
+ + +

Inputs getPixelInputs

+ +
+ + +

Update the per-pixel inputs of the material. It takes in an + Inputs struct, which includes:

+ +
    + +
  • vec3 normal, the direction pointing out of the surface
  • + +
  • vec2 texCoord, a vector where x and + y are between 0 and 1 describing the spot on a texture the pixel + is mapped to, as a fraction of the texture size
  • + +
  • vec3 ambientLight, the ambient light color on the vertex
  • + +
  • vec4 color, the base material color of the pixel
  • + +
  • vec3 ambientMaterial, the color of the pixel when affected by + ambient light
  • + +
  • vec3 specularMaterial, the color of the pixel when reflecting + specular highlights
  • + +
  • vec3 emissiveMaterial, the light color emitted by the + pixel
  • + +
  • float shininess, a number representing how sharp specular + reflections should be, from 1 to infinity
  • + +
  • float metalness, a number representing how mirrorlike the + material should be, between 0 and 1 + + The struct can be modified and returned.
+ + +

vec4 combineColors

+ +
+ + +

Take in a ColorComponents struct containing all the different + components of light, and combining them into + + a single final color. The struct contains:

+ +
    + +
  • vec3 baseColor, the base color of the pixel
  • + +
  • float opacity, the opacity between 0 and 1 that it should be + drawn at
  • + +
  • vec3 ambientColor, the color of the pixel when affected by + ambient light
  • + +
  • vec3 specularColor, the color of the pixel when affected by + specular reflections
  • + +
  • vec3 diffuse, the amount of diffused light hitting the + pixel
  • + +
  • vec3 ambient, the amount of ambient light hitting the + pixel
  • + +
  • vec3 specular, the amount of specular reflection hitting the + pixel
  • + +
  • vec3 emissive, the amount of light emitted by the pixel
  • + +
+ +
+ + +

vec4 getFinalColor

+ +
+ + +

Update the final color after mixing. It takes in a vec4 color + and must return a modified version.

+ +
+ + +

void afterFragment

+ +
+ + +

Called at the end of the fragment shader.

+ +
+ + +

Most of the time, you will need to write your hooks in GLSL ES version 300. + If you + + are using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.

+ +

Call baseMaterialShader().inspectHooks() to see all the + possible hooks and + + their default implementations.

+line: 886 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let myShader; + + function setup() { + createCanvas(200, 200, WEBGL); + myShader = baseMaterialShader().modify({ + uniforms: { + 'float time': () => millis() + }, + 'vec3 getWorldPosition': `(vec3 pos) { + pos.y += 20.0 * sin(time * 0.001 + pos.x * 0.05); + return pos; + }` + }); + } + + function draw() { + background(255); + shader(myShader); + lights(); + noStroke(); + fill('red'); + sphere(50); + } + +
+ - |- + +
+ + let myShader; + + function setup() { + createCanvas(200, 200, WEBGL); + myShader = baseMaterialShader().modify({ + declarations: 'vec3 myNormal;', + 'Inputs getPixelInputs': `(Inputs inputs) { + myNormal = inputs.normal; + return inputs; + }`, + 'vec4 getFinalColor': `(vec4 color) { + return mix( + vec4(1.0, 1.0, 1.0, 1.0), + color, + abs(dot(myNormal, vec3(0.0, 0.0, 1.0))) + ); + }` + }); + } + + function draw() { + background(255); + rotateY(millis() * 0.001); + shader(myShader); + lights(); + noStroke(); + fill('red'); + torus(30); + } + +
+ - |- + +
+ + let myShader; + let environment; + + function preload() { + environment = loadImage('/assets/outdoor_spheremap.jpg'); + } + + function setup() { + createCanvas(200, 200, WEBGL); + myShader = baseMaterialShader().modify({ + 'Inputs getPixelInputs': `(Inputs inputs) { + float factor = + sin( + inputs.texCoord.x * ${TWO_PI} + + inputs.texCoord.y * ${TWO_PI} + ) * 0.4 + 0.5; + inputs.shininess = mix(1., 100., factor); + inputs.metalness = factor; + return inputs; + }` + }); + } + + function draw() { + panorama(environment); + ambientLight(100); + imageLight(environment); + rotateY(millis() * 0.001); + shader(myShader); + noStroke(); + fill(255); + specularMaterial(150); + sphere(50); + } + +
+ - |- + +
+ + let myShader; + + function setup() { + createCanvas(200, 200, WEBGL); + myShader = baseMaterialShader().modify({ + 'Inputs getPixelInputs': `(Inputs inputs) { + vec3 newNormal = inputs.normal; + // Simple bump mapping: adjust the normal based on position + newNormal.x += 0.2 * sin( + sin( + inputs.texCoord.y * ${TWO_PI} * 10.0 + + inputs.texCoord.x * ${TWO_PI} * 25.0 + ) + ); + newNormal.y += 0.2 * sin( + sin( + inputs.texCoord.x * ${TWO_PI} * 10.0 + + inputs.texCoord.y * ${TWO_PI} * 25.0 + ) + ); + inputs.normal = normalize(newNormal); + return inputs; + }` + }); + } + + function draw() { + background(255); + shader(myShader); + ambientLight(150); + pointLight( + 255, 255, 255, + 100*cos(frameCount*0.04), -50, 100*sin(frameCount*0.04) + ); + noStroke(); + fill('red'); + shininess(200); + specularMaterial(255); + sphere(50); + } + +
+class: p5 +return: + description: The material shader + type: p5.Shader +chainable: false +beta: true +--- + + +# baseMaterialShader diff --git a/src/content/reference/en/p5 copy/baseNormalShader.mdx b/src/content/reference/en/p5 copy/baseNormalShader.mdx new file mode 100644 index 0000000000..4eac6e9109 --- /dev/null +++ b/src/content/reference/en/p5 copy/baseNormalShader.mdx @@ -0,0 +1,211 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1197 +title: baseNormalShader +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Get the shader used by normalMaterial().

+ +

You can call baseNormalShader().modify() + + and change any of the following hooks:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
HookDescription
void beforeVertexCalled at the start of the vertex shader.
vec3 getLocalPositionUpdate the position of vertices before transforms are applied. It takes in + vec3 position and must return a modified version.
vec3 getWorldPositionUpdate the position of vertices after transforms are applied. It takes in + vec3 position and pust return a modified version.
vec3 getLocalNormalUpdate the normal before transforms are applied. It takes in vec3 + normal and must return a modified version.
vec3 getWorldNormalUpdate the normal after transforms are applied. It takes in vec3 + normal and must return a modified version.
vec2 getUVUpdate the texture coordinates. It takes in vec2 uv and must + return a modified version.
vec4 getVertexColorUpdate the color of each vertex. It takes in a vec4 color and + must return a modified version.
void afterVertexCalled at the end of the vertex shader.
void beforeFragmentCalled at the start of the fragment shader.
vec4 getFinalColorUpdate the final color after mixing. It takes in a vec4 color + and must return a modified version.
void afterFragmentCalled at the end of the fragment shader.
+ +

Most of the time, you will need to write your hooks in GLSL ES version 300. + If you + + are using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.

+ +

Call baseNormalShader().inspectHooks() to see all the possible + hooks and + + their default implementations.

+line: 1197 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let myShader; + + function setup() { + createCanvas(200, 200, WEBGL); + myShader = baseNormalShader().modify({ + uniforms: { + 'float time': () => millis() + }, + 'vec3 getWorldPosition': `(vec3 pos) { + pos.y += 20. * sin(time * 0.001 + pos.x * 0.05); + return pos; + }` + }); + } + + function draw() { + background(255); + shader(myShader); + noStroke(); + sphere(50); + } + +
+ - |- + +
+ + let myShader; + + function setup() { + createCanvas(200, 200, WEBGL); + myShader = baseNormalShader().modify({ + 'vec3 getWorldNormal': '(vec3 normal) { return abs(normal); }', + 'vec4 getFinalColor': `(vec4 color) { + // Map the r, g, and b values of the old normal to new colors + // instead of just red, green, and blue: + vec3 newColor = + color.r * vec3(89.0, 240.0, 232.0) / 255.0 + + color.g * vec3(240.0, 237.0, 89.0) / 255.0 + + color.b * vec3(205.0, 55.0, 222.0) / 255.0; + newColor = newColor / (color.r + color.g + color.b); + return vec4(newColor, 1.0) * color.a; + }` + }); + } + + function draw() { + background(255); + shader(myShader); + noStroke(); + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.015); + box(100); + } + +
+class: p5 +return: + description: The `normalMaterial` shader + type: p5.Shader +chainable: false +beta: true +--- + + +# baseNormalShader diff --git a/src/content/reference/en/p5 copy/baseStrokeShader.mdx b/src/content/reference/en/p5 copy/baseStrokeShader.mdx new file mode 100644 index 0000000000..f2bfb42be5 --- /dev/null +++ b/src/content/reference/en/p5 copy/baseStrokeShader.mdx @@ -0,0 +1,356 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1355 +title: baseStrokeShader +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Get the shader used when drawing the strokes of shapes.

+ +

You can call baseStrokeShader().modify() + + and change any of the following hooks:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
HookDescription
+ + +

void beforeVertex

+ +
+ + +

Called at the start of the vertex shader.

+ +
+ + +

vec3 getLocalPosition

+ +
+ + +

Update the position of vertices before transforms are applied. It takes in + vec3 position and must return a modified version.

+ +
+ + +

vec3 getWorldPosition

+ +
+ + +

Update the position of vertices after transforms are applied. It takes in + vec3 position and pust return a modified version.

+ +
+ + +

float getStrokeWeight

+ +
+ + +

Update the stroke weight. It takes in float weight and pust + return a modified version.

+ +
+ + +

vec2 getLineCenter

+ +
+ + +

Update the center of the line. It takes in vec2 center and + must return a modified version.

+ +
+ + +

vec2 getLinePosition

+ +
+ + +

Update the position of each vertex on the edge of the line. It takes in + vec2 position and must return a modified version.

+ +
+ + +

vec4 getVertexColor

+ +
+ + +

Update the color of each vertex. It takes in a vec4 color and + must return a modified version.

+ +
+ + +

void afterVertex

+ +
+ + +

Called at the end of the vertex shader.

+ +
+ + +

void beforeFragment

+ +
+ + +

Called at the start of the fragment shader.

+ +
+ + +

Inputs getPixelInputs

+ +
+ + +

Update the inputs to the shader. It takes in a struct Inputs + inputs, which includes:

+ +
    + +
  • vec4 color, the color of the stroke
  • + +
  • vec2 tangent, the direction of the stroke in screen + space
  • + +
  • vec2 center, the coordinate of the center of the stroke in + screen space p5.js pixels
  • + +
  • vec2 position, the coordinate of the current pixel in screen + space p5.js pixels
  • + +
  • float strokeWeight, the thickness of the stroke in p5.js + pixels
  • + +
+ +
+ + +

bool shouldDiscard

+ +
+ + +

Caps and joins are made by discarded pixels in the fragment shader to carve + away unwanted areas. Use this to change this logic. It takes in a bool + willDiscard and must return a modified version.

+ +
+ + +

vec4 getFinalColor

+ +
+ + +

Update the final color after mixing. It takes in a vec4 color + and must return a modified version.

+ +
+ + +

void afterFragment

+ +
+ + +

Called at the end of the fragment shader.

+ +
+ + +

Most of the time, you will need to write your hooks in GLSL ES version 300. + If you + + are using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.

+ +

Call baseStrokeShader().inspectHooks() to see all the possible + hooks and + + their default implementations.

+line: 1355 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let myShader; + + function setup() { + createCanvas(200, 200, WEBGL); + myShader = baseStrokeShader().modify({ + 'Inputs getPixelInputs': `(Inputs inputs) { + float opacity = 1.0 - smoothstep( + 0.0, + 15.0, + length(inputs.position - inputs.center) + ); + inputs.color *= opacity; + return inputs; + }` + }); + } + + function draw() { + background(255); + shader(myShader); + strokeWeight(30); + line( + -width/3, + sin(millis()*0.001) * height/4, + width/3, + sin(millis()*0.001 + 1) * height/4 + ); + } + +
+ - |- + +
+ + let myShader; + + function setup() { + createCanvas(200, 200, WEBGL); + myShader = baseStrokeShader().modify({ + uniforms: { + 'float time': () => millis() + }, + declarations: 'vec3 myPosition;', + 'vec3 getWorldPosition': `(vec3 pos) { + myPosition = pos; + return pos; + }`, + 'float getStrokeWeight': `(float w) { + // Add a somewhat random offset to the weight + // that varies based on position and time + float scale = 0.8 + 0.2*sin(10.0 * sin( + floor(time/250.) + + myPosition.x*0.01 + + myPosition.y*0.01 + )); + return w * scale; + }` + }); + } + + function draw() { + background(255); + shader(myShader); + myShader.setUniform('time', millis()); + strokeWeight(10); + beginShape(); + for (let i = 0; i <= 50; i++) { + let r = map(i, 0, 50, 0, width/3); + let x = r*cos(i*0.2); + let y = r*sin(i*0.2); + vertex(x, y); + } + endShape(); + } + +
+ - |- + +
+ + let myShader; + + function setup() { + createCanvas(200, 200, WEBGL); + myShader = baseStrokeShader().modify({ + 'float random': `(vec2 p) { + vec3 p3 = fract(vec3(p.xyx) * .1031); + p3 += dot(p3, p3.yzx + 33.33); + return fract((p3.x + p3.y) * p3.z); + }`, + 'Inputs getPixelInputs': `(Inputs inputs) { + // Replace alpha in the color with dithering by + // randomly setting pixel colors to 0 based on opacity + float a = inputs.color.a; + inputs.color.a = 1.0; + inputs.color *= random(inputs.position.xy) > a ? 0.0 : 1.0; + return inputs; + }` + }); + } + + function draw() { + background(255); + shader(myShader); + strokeWeight(10); + beginShape(); + for (let i = 0; i <= 50; i++) { + stroke( + 0, + 255 + * map(i, 0, 20, 0, 1, true) + * map(i, 30, 50, 1, 0, true) + ); + vertex( + map(i, 0, 50, -1, 1) * width/3, + 50 * sin(i/10 + frameCount/100) + ); + } + endShape(); + } + +
+class: p5 +return: + description: The stroke shader + type: p5.Shader +chainable: false +beta: true +--- + + +# baseStrokeShader diff --git a/src/content/reference/en/p5 copy/beginClip.mdx b/src/content/reference/en/p5 copy/beginClip.mdx new file mode 100644 index 0000000000..ebad022a68 --- /dev/null +++ b/src/content/reference/en/p5 copy/beginClip.mdx @@ -0,0 +1,208 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L13 +title: beginClip +module: Color +submodule: Setting +file: src/color/setting.js +description: > +

Starts defining a shape that will mask any shapes drawn afterward.

+ +

Any shapes drawn between beginClip() and + + endClip() will add to the mask shape. The + mask + + will apply to anything drawn after endClip().

+ +

The parameter, options, is optional. If an object with an + invert + + property is passed, as in beginClip({ invert: true }), it will be + used to + + set the masking mode. { invert: true } inverts the mask, creating + holes + + in shapes that are masked. invert is false by + default.

+ +

Masks can be contained between the + + push() and pop() functions. + + Doing so allows unmasked shapes to be drawn after masked shapes.

+ +

Masks can also be defined in a callback function that's passed to + + clip().

+line: 13 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a mask. + beginClip(); + triangle(15, 37, 30, 13, 43, 37); + circle(45, 45, 7); + endClip(); + + // Draw a backing shape. + square(5, 5, 45); + + describe('A white triangle and circle on a gray background.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an inverted mask. + beginClip({ invert: true }); + triangle(15, 37, 30, 13, 43, 37); + circle(45, 45, 7); + endClip(); + + // Draw a backing shape. + square(5, 5, 45); + + describe('A white square at the top-left corner of a gray square. The white square has a triangle and a circle cut out of it.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + noStroke(); + + // Draw a masked shape. + push(); + // Create a mask. + beginClip(); + triangle(15, 37, 30, 13, 43, 37); + circle(45, 45, 7); + endClip(); + + // Draw a backing shape. + square(5, 5, 45); + pop(); + + // Translate the origin to the center. + translate(50, 50); + + // Draw an inverted masked shape. + push(); + // Create an inverted mask. + beginClip({ invert: true }); + triangle(15, 37, 30, 13, 43, 37); + circle(45, 45, 7); + endClip(); + + // Draw a backing shape. + square(5, 5, 45); + pop(); + + describe('In the top left, a white triangle and circle. In the bottom right, a white square with a triangle and circle cut out of it.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A silhouette of a rotating torus colored fuchsia.'); + } + + function draw() { + background(200); + + // Create a mask. + beginClip(); + push(); + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + scale(0.5); + torus(30, 15); + pop(); + endClip(); + + // Draw a backing shape. + noStroke(); + fill('fuchsia'); + plane(100); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A silhouette of a rotating torus colored with a gradient from cyan to purple.'); + } + + function draw() { + background(200); + + // Create a mask. + beginClip(); + push(); + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + scale(0.5); + torus(30, 15); + pop(); + endClip(); + + // Draw a backing shape. + noStroke(); + beginShape(QUAD_STRIP); + fill(0, 255, 255); + vertex(-width / 2, -height / 2); + vertex(width / 2, -height / 2); + fill(100, 0, 100); + vertex(-width / 2, height / 2); + vertex(width / 2, height / 2); + endShape(); + } + +
+class: p5 +params: + - name: options + description: | +

an object containing clip settings.

+ type: Object + optional: true +chainable: false +--- + + +# beginClip diff --git a/src/content/reference/en/p5 copy/beginContour.mdx b/src/content/reference/en/p5 copy/beginContour.mdx new file mode 100644 index 0000000000..5ecd6d1437 --- /dev/null +++ b/src/content/reference/en/p5 copy/beginContour.mdx @@ -0,0 +1,134 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L20 +title: beginContour +module: Shape +submodule: Vertex +file: src/core/shape/vertex.js +description: > +

Begins creating a hole within a flat shape.

+ +

The beginContour() and endContour() + + functions allow for creating negative space within custom shapes that are + + flat. beginContour() begins adding vertices to a negative space + and + + endContour() stops adding them. + + beginContour() and endContour() must be + + called between beginShape() and + + endShape().

+ +

Transformations such as translate(), + + rotate(), and scale() + + don't work between beginContour() and + + endContour(). It's also not possible + to use + + other shapes, such as ellipse() or + + rect(), between beginContour() + and + + endContour().

+ +

Note: The vertices that define a negative space must "wind" in the opposite + + direction from the outer shape. First, draw vertices for the outer shape + + clockwise order. Then, draw vertices for the negative space in + + counter-clockwise order.

+line: 20 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + beginShape(); + + // Exterior vertices, clockwise winding. + vertex(10, 10); + vertex(90, 10); + vertex(90, 90); + vertex(10, 90); + + // Interior vertices, counter-clockwise winding. + beginContour(); + vertex(30, 30); + vertex(30, 70); + vertex(70, 70); + vertex(70, 30); + endContour(); + + // Stop drawing the shape. + endShape(CLOSE); + + describe('A white square with a square hole in its center drawn on a gray background.'); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white square with a square hole in its center drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Start drawing the shape. + beginShape(); + + // Exterior vertices, clockwise winding. + vertex(-40, -40); + vertex(40, -40); + vertex(40, 40); + vertex(-40, 40); + + // Interior vertices, counter-clockwise winding. + beginContour(); + vertex(-20, -20); + vertex(-20, 20); + vertex(20, 20); + vertex(20, -20); + endContour(); + + // Stop drawing the shape. + endShape(CLOSE); + } + +
+class: p5 +chainable: true +--- + + +# beginContour diff --git a/src/content/reference/en/p5 copy/beginGeometry.mdx b/src/content/reference/en/p5 copy/beginGeometry.mdx new file mode 100644 index 0000000000..3fdf211bd3 --- /dev/null +++ b/src/content/reference/en/p5 copy/beginGeometry.mdx @@ -0,0 +1,281 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L13 +title: beginGeometry +module: Shape +submodule: 3D Primitives +file: src/webgl/3d_primitives.js +description: > +

Begins adding shapes to a new + + p5.Geometry object.

+ +

The beginGeometry() and endGeometry() + + functions help with creating complex 3D shapes from simpler ones such as + + sphere(). beginGeometry() + begins adding shapes + + to a custom p5.Geometry object and + + endGeometry() stops adding them.

+ +

beginGeometry() and endGeometry() can help + + to make sketches more performant. For example, if a complex 3D shape + + doesn’t change while a sketch runs, then it can be created with + + beginGeometry() and endGeometry(). + + Creating a p5.Geometry object once and + then + + drawing it will run faster than repeatedly drawing the individual pieces.

+ +

See buildGeometry() for another + way to + + build 3D shapes.

+ +

Note: beginGeometry() can only be used in WebGL mode.

+line: 13 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Start building the p5.Geometry object. + beginGeometry(); + + // Add a cone. + cone(); + + // Stop building the p5.Geometry object. + shape = endGeometry(); + + describe('A white cone drawn on a gray background.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the p5.Geometry object. + noStroke(); + + // Draw the p5.Geometry object. + model(shape); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the p5.Geometry object. + createArrow(); + + describe('A white arrow drawn on a gray background.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the p5.Geometry object. + noStroke(); + + // Draw the p5.Geometry object. + model(shape); + } + + function createArrow() { + // Start building the p5.Geometry object. + beginGeometry(); + + // Add shapes. + push(); + rotateX(PI); + cone(10); + translate(0, -10, 0); + cylinder(3, 20); + pop(); + + // Stop building the p5.Geometry object. + shape = endGeometry(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let blueArrow; + let redArrow; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the arrows. + redArrow = createArrow('red'); + blueArrow = createArrow('blue'); + + describe('A red arrow and a blue arrow drawn on a gray background. The blue arrow rotates slowly.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the arrows. + noStroke(); + + // Draw the red arrow. + model(redArrow); + + // Translate and rotate the coordinate system. + translate(30, 0, 0); + rotateZ(frameCount * 0.01); + + // Draw the blue arrow. + model(blueArrow); + } + + function createArrow(fillColor) { + // Start building the p5.Geometry object. + beginGeometry(); + + fill(fillColor); + + // Add shapes to the p5.Geometry object. + push(); + rotateX(PI); + cone(10); + translate(0, -10, 0); + cylinder(3, 20); + pop(); + + // Stop building the p5.Geometry object. + let shape = endGeometry(); + + return shape; + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let button; + let particles; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a button to reset the particle system. + button = createButton('Reset'); + + // Call resetModel() when the user presses the button. + button.mousePressed(resetModel); + + // Add the original set of particles. + resetModel(); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the particles. + noStroke(); + + // Draw the particles. + model(particles); + } + + function resetModel() { + // If the p5.Geometry object has already been created, + // free those resources. + if (particles) { + freeGeometry(particles); + } + + // Create a new p5.Geometry object with random spheres. + particles = createParticles(); + } + + function createParticles() { + // Start building the p5.Geometry object. + beginGeometry(); + + // Add shapes. + for (let i = 0; i < 60; i += 1) { + // Calculate random coordinates. + let x = randomGaussian(0, 20); + let y = randomGaussian(0, 20); + let z = randomGaussian(0, 20); + + push(); + // Translate to the particle's coordinates. + translate(x, y, z); + // Draw the particle. + sphere(5); + pop(); + } + + // Stop building the p5.Geometry object. + let shape = endGeometry(); + + return shape; + } + +
+class: p5 +chainable: false +--- + + +# beginGeometry diff --git a/src/content/reference/en/p5 copy/beginShape.mdx b/src/content/reference/en/p5 copy/beginShape.mdx new file mode 100644 index 0000000000..d8642333db --- /dev/null +++ b/src/content/reference/en/p5 copy/beginShape.mdx @@ -0,0 +1,449 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L129 +title: beginShape +module: Shape +submodule: Vertex +file: src/core/shape/vertex.js +description: > +

Begins adding vertices to a custom shape.

+ +

The beginShape() and endShape() functions + + allow for creating custom shapes in 2D or 3D. beginShape() begins + adding + + vertices to a custom shape and endShape() stops + + adding them.

+ +

The parameter, kind, sets the kind of shape to make. By + default, any + + irregular polygon can be drawn. The available modes for kind are:

+ +
    + +
  • POINTS to draw a series of points.
  • + +
  • LINES to draw a series of unconnected line segments.
  • + +
  • TRIANGLES to draw a series of separate triangles.
  • + +
  • TRIANGLE_FAN to draw a series of connected triangles sharing + the first vertex in a fan-like fashion.
  • + +
  • TRIANGLE_STRIP to draw a series of connected triangles in + strip fashion.
  • + +
  • QUADS to draw a series of separate quadrilaterals + (quads).
  • + +
  • QUAD_STRIP to draw quad strip using adjacent edges to form + the next quad.
  • + +
  • TESS to create a filling curve by explicit tessellation + (WebGL only).
  • + +
+ +

After calling beginShape(), shapes can be built by calling + + vertex(), + + bezierVertex(), + + quadraticVertex(), and/or + + curveVertex(). Calling + + endShape() will stop adding vertices to + the + + shape. Each shape will be outlined with the current stroke color and filled + + with the current fill color.

+ +

Transformations such as translate(), + + rotate(), and + + scale() don't work between + beginShape() and + + endShape(). It's also not possible to + use + + other shapes, such as ellipse() or + + rect(), between beginShape() + and + + endShape().

+line: 129 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + beginShape(); + + // Add vertices. + vertex(30, 20); + vertex(85, 20); + vertex(85, 75); + vertex(30, 75); + + // Stop drawing the shape. + endShape(CLOSE); + + describe('A white square on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + // Only draw the vertices (points). + beginShape(POINTS); + + // Add vertices. + vertex(30, 20); + vertex(85, 20); + vertex(85, 75); + vertex(30, 75); + + // Stop drawing the shape. + endShape(); + + describe('Four black dots that form a square are drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + // Only draw lines between alternating pairs of vertices. + beginShape(LINES); + + // Add vertices. + vertex(30, 20); + vertex(85, 20); + vertex(85, 75); + vertex(30, 75); + + // Stop drawing the shape. + endShape(); + + describe('Two horizontal black lines on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the shape. + noFill(); + + // Start drawing the shape. + beginShape(); + + // Add vertices. + vertex(30, 20); + vertex(85, 20); + vertex(85, 75); + vertex(30, 75); + + // Stop drawing the shape. + endShape(); + + describe('Three black lines form a sideways U shape on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the shape. + noFill(); + + // Start drawing the shape. + beginShape(); + + // Add vertices. + vertex(30, 20); + vertex(85, 20); + vertex(85, 75); + vertex(30, 75); + + // Stop drawing the shape. + // Connect the first and last vertices. + endShape(CLOSE); + + describe('A black outline of a square drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + // Draw a series of triangles. + beginShape(TRIANGLES); + + // Left triangle. + vertex(30, 75); + vertex(40, 20); + vertex(50, 75); + + // Right triangle. + vertex(60, 20); + vertex(70, 75); + vertex(80, 20); + + // Stop drawing the shape. + endShape(); + + describe('Two white triangles drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + // Draw a series of triangles. + beginShape(TRIANGLE_STRIP); + + // Add vertices. + vertex(30, 75); + vertex(40, 20); + vertex(50, 75); + vertex(60, 20); + vertex(70, 75); + vertex(80, 20); + vertex(90, 75); + + // Stop drawing the shape. + endShape(); + + describe('Five white triangles that are interleaved drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + // Draw a series of triangles that share their first vertex. + beginShape(TRIANGLE_FAN); + + // Add vertices. + vertex(57.5, 50); + vertex(57.5, 15); + vertex(92, 50); + vertex(57.5, 85); + vertex(22, 50); + vertex(57.5, 15); + + // Stop drawing the shape. + endShape(); + + describe('Four white triangles form a square are drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + // Draw a series of quadrilaterals. + beginShape(QUADS); + + // Left rectangle. + vertex(30, 20); + vertex(30, 75); + vertex(50, 75); + vertex(50, 20); + + // Right rectangle. + vertex(65, 20); + vertex(65, 75); + vertex(85, 75); + vertex(85, 20); + + // Stop drawing the shape. + endShape(); + + describe('Two white rectangles drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + // Draw a series of quadrilaterals. + beginShape(QUAD_STRIP); + + // Add vertices. + vertex(30, 20); + vertex(30, 75); + vertex(50, 20); + vertex(50, 75); + vertex(65, 20); + vertex(65, 75); + vertex(85, 20); + vertex(85, 75); + + // Stop drawing the shape. + endShape(); + + describe('Three white rectangles that share edges are drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + // Start drawing the shape. + // Draw a series of quadrilaterals. + beginShape(TESS); + + // Add the vertices. + vertex(-30, -30, 0); + vertex(30, -30, 0); + vertex(30, -10, 0); + vertex(-10, -10, 0); + vertex(-10, 10, 0); + vertex(30, 10, 0); + vertex(30, 30, 0); + vertex(-30, 30, 0); + + // Stop drawing the shape. + // Connect the first and last vertices. + endShape(CLOSE); + + describe('A blocky C shape drawn in white on a gray background.'); + } + +
+ +
+ + // Click and drag with the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A blocky C shape drawn in red, blue, and green on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Start drawing the shape. + // Draw a series of quadrilaterals. + beginShape(TESS); + + // Add the vertices. + fill('red'); + stroke('red'); + vertex(-30, -30, 0); + vertex(30, -30, 0); + vertex(30, -10, 0); + fill('green'); + stroke('green'); + vertex(-10, -10, 0); + vertex(-10, 10, 0); + vertex(30, 10, 0); + fill('blue'); + stroke('blue'); + vertex(30, 30, 0); + vertex(-30, 30, 0); + + // Stop drawing the shape. + // Connect the first and last vertices. + endShape(CLOSE); + } + +
+class: p5 +params: + - name: kind + description: | +

either POINTS, LINES, TRIANGLES, TRIANGLE_FAN + TRIANGLE_STRIP, QUADS, QUAD_STRIP or TESS.

+ type: Constant + optional: true +chainable: true +--- + + +# beginShape diff --git a/src/content/reference/en/p5 copy/bezier.mdx b/src/content/reference/en/p5 copy/bezier.mdx new file mode 100644 index 0000000000..50c15330b7 --- /dev/null +++ b/src/content/reference/en/p5 copy/bezier.mdx @@ -0,0 +1,273 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L13 +title: bezier +module: Shape +submodule: Curves +file: src/core/shape/curves.js +description: > +

Draws a Bézier curve.

+ +

Bézier curves can form shapes and curves that slope gently. They're defined + + by two anchor points and two control points. Bézier curves provide more + + control than the spline curves created with the + + curve() function.

+ +

The first two parameters, x1 and y1, set the + first anchor point. The + + first anchor point is where the curve starts.

+ +

The next four parameters, x2, y2, + x3, and y3, set the two control + + points. The control points "pull" the curve towards them.

+ +

The seventh and eighth parameters, x4 and y4, set + the last anchor + + point. The last anchor point is where the curve ends.

+ +

Bézier curves can also be drawn in 3D using WebGL mode. The 3D version of + + bezier() has twelve arguments because each point has x-, y-, + + and z-coordinates.

+line: 13 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw the anchor points in black. + stroke(0); + strokeWeight(5); + point(85, 20); + point(15, 80); + + // Draw the control points in red. + stroke(255, 0, 0); + point(10, 10); + point(90, 90); + + // Draw a black bezier curve. + noFill(); + stroke(0); + strokeWeight(1); + bezier(85, 20, 10, 10, 90, 90, 15, 80); + + // Draw red lines from the anchor points to the control points. + stroke(255, 0, 0); + line(85, 20, 10, 10); + line(15, 80, 90, 90); + + describe( + 'A gray square with three curves. A black s-curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' + ); + } + +
+ +
+ + // Click the mouse near the red dot in the top-left corner + // and drag to change the curve's shape. + + let x2 = 10; + let y2 = 10; + let isChanging = false; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with three curves. A black s-curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' + ); + } + + function draw() { + background(200); + + // Draw the anchor points in black. + stroke(0); + strokeWeight(5); + point(85, 20); + point(15, 80); + + // Draw the control points in red. + stroke(255, 0, 0); + point(x2, y2); + point(90, 90); + + // Draw a black bezier curve. + noFill(); + stroke(0); + strokeWeight(1); + bezier(85, 20, x2, y2, 90, 90, 15, 80); + + // Draw red lines from the anchor points to the control points. + stroke(255, 0, 0); + line(85, 20, x2, y2); + line(15, 80, 90, 90); + } + + // Start changing the first control point if the user clicks near it. + function mousePressed() { + if (dist(mouseX, mouseY, x2, y2) < 20) { + isChanging = true; + } + } + + // Stop changing the first control point when the user releases the mouse. + function mouseReleased() { + isChanging = false; + } + + // Update the first control point while the user drags the mouse. + function mouseDragged() { + if (isChanging === true) { + x2 = mouseX; + y2 = mouseY; + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background('skyblue'); + + // Draw the red balloon. + fill('red'); + bezier(50, 60, 5, 15, 95, 15, 50, 60); + + // Draw the balloon string. + line(50, 60, 50, 80); + + describe('A red balloon in a blue sky.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A red balloon in a blue sky. The balloon rotates slowly, revealing that it is flat.'); + } + + function draw() { + background('skyblue'); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Draw the red balloon. + fill('red'); + bezier(0, 0, 0, -45, -45, 0, 45, -45, 0, 0, 0, 0); + + // Draw the balloon string. + line(0, 0, 0, 0, 20, 0); + } + +
+class: p5 +overloads: + - line: 13 + params: + - name: x1 + description: | +

x-coordinate of the first anchor point.

+ type: Number + - name: y1 + description: | +

y-coordinate of the first anchor point.

+ type: Number + - name: x2 + description: | +

x-coordinate of the first control point.

+ type: Number + - name: y2 + description: | +

y-coordinate of the first control point.

+ type: Number + - name: x3 + description: | +

x-coordinate of the second control point.

+ type: Number + - name: y3 + description: | +

y-coordinate of the second control point.

+ type: Number + - name: x4 + description: | +

x-coordinate of the second anchor point.

+ type: Number + - name: y4 + description: | +

y-coordinate of the second anchor point.

+ type: Number + chainable: 1 + - line: 191 + params: + - name: x1 + description: '' + type: Number + - name: y1 + description: '' + type: Number + - name: z1 + description: | +

z-coordinate of the first anchor point.

+ type: Number + - name: x2 + description: '' + type: Number + - name: y2 + description: '' + type: Number + - name: z2 + description: | +

z-coordinate of the first control point.

+ type: Number + - name: x3 + description: '' + type: Number + - name: y3 + description: '' + type: Number + - name: z3 + description: | +

z-coordinate of the second control point.

+ type: Number + - name: x4 + description: '' + type: Number + - name: y4 + description: '' + type: Number + - name: z4 + description: | +

z-coordinate of the second anchor point.

+ type: Number + chainable: 1 +chainable: true +--- + + +# bezier diff --git a/src/content/reference/en/p5 copy/bezierDetail.mdx b/src/content/reference/en/p5 copy/bezierDetail.mdx new file mode 100644 index 0000000000..b4f895a3fc --- /dev/null +++ b/src/content/reference/en/p5 copy/bezierDetail.mdx @@ -0,0 +1,121 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L221 +title: bezierDetail +module: Shape +submodule: Curves +file: src/core/shape/curves.js +description: > +

Sets the number of segments used to draw Bézier curves in WebGL mode.

+ +

In WebGL mode, smooth shapes are drawn using many flat segments. Adding + + more flat segments makes shapes appear smoother.

+ +

The parameter, detail, is the number of segments to use while + drawing a + + Bézier curve. For example, calling bezierDetail(5) will use 5 + segments to + + draw curves with the bezier() function. By + + default,detail is 20.

+ +

Note: bezierDetail() has no effect in 2D mode.

+line: 221 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Draw the original curve. + + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw the anchor points in black. + stroke(0); + strokeWeight(5); + point(85, 20); + point(15, 80); + + // Draw the control points in red. + stroke(255, 0, 0); + point(10, 10); + point(90, 90); + + // Draw a black bezier curve. + noFill(); + stroke(0); + strokeWeight(1); + bezier(85, 20, 10, 10, 90, 90, 15, 80); + + // Draw red lines from the anchor points to the control points. + stroke(255, 0, 0); + line(85, 20, 10, 10); + line(15, 80, 90, 90); + + describe( + 'A gray square with three curves. A black s-curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' + ); + } + +
+ +
+ + // Draw the curve with less detail. + + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + // Set the curveDetail() to 5. + bezierDetail(5); + + // Draw the anchor points in black. + stroke(0); + strokeWeight(5); + point(35, -30, 0); + point(-35, 30, 0); + + // Draw the control points in red. + stroke(255, 0, 0); + point(-40, -40, 0); + point(40, 40, 0); + + // Draw a black bezier curve. + noFill(); + stroke(0); + strokeWeight(1); + bezier(35, -30, 0, -40, -40, 0, 40, 40, 0, -35, 30, 0); + + // Draw red lines from the anchor points to the control points. + stroke(255, 0, 0); + line(35, -30, -40, -40); + line(-35, 30, 40, 40); + + describe( + 'A gray square with three curves. A black s-curve is drawn with jagged segments. Two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' + ); + } + +
+class: p5 +params: + - name: detail + description: | +

number of segments to use. Defaults to 20.

+ type: Number +chainable: true +--- + + +# bezierDetail diff --git a/src/content/reference/en/p5 copy/bezierPoint.mdx b/src/content/reference/en/p5 copy/bezierPoint.mdx new file mode 100644 index 0000000000..a42c171121 --- /dev/null +++ b/src/content/reference/en/p5 copy/bezierPoint.mdx @@ -0,0 +1,162 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L324 +title: bezierPoint +module: Shape +submodule: Curves +file: src/core/shape/curves.js +description: > +

Calculates coordinates along a Bézier curve using interpolation.

+ +

bezierPoint() calculates coordinates along a Bézier curve + using the + + anchor and control points. It expects points in the same order as the + + bezier() function. + bezierPoint() works one axis + + at a time. Passing the anchor and control points' x-coordinates will + + calculate the x-coordinate of a point on the curve. Passing the anchor and + + control points' y-coordinates will calculate the y-coordinate of a point on + + the curve.

+ +

The first parameter, a, is the coordinate of the first anchor + point.

+ +

The second and third parameters, b and c, are the + coordinates of the + + control points.

+ +

The fourth parameter, d, is the coordinate of the last anchor + point.

+ +

The fifth parameter, t, is the amount to interpolate along the + curve. 0 + + is the first anchor point, 1 is the second anchor point, and 0.5 is halfway + + between them.

+line: 324 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Set the coordinates for the curve's anchor and control points. + let x1 = 85; + let x2 = 10; + let x3 = 90; + let x4 = 15; + let y1 = 20; + let y2 = 10; + let y3 = 90; + let y4 = 80; + + // Style the curve. + noFill(); + + // Draw the curve. + bezier(x1, y1, x2, y2, x3, y3, x4, y4); + + // Draw circles along the curve's path. + fill(255); + + // Top-right. + let x = bezierPoint(x1, x2, x3, x4, 0); + let y = bezierPoint(y1, y2, y3, y4, 0); + circle(x, y, 5); + + // Center. + x = bezierPoint(x1, x2, x3, x4, 0.5); + y = bezierPoint(y1, y2, y3, y4, 0.5); + circle(x, y, 5); + + // Bottom-left. + x = bezierPoint(x1, x2, x3, x4, 1); + y = bezierPoint(y1, y2, y3, y4, 1); + circle(x, y, 5); + + describe('A black s-curve on a gray square. The endpoints and center of the curve are marked with white circles.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A black s-curve on a gray square. A white circle moves back and forth along the curve.'); + } + + function draw() { + background(200); + + // Set the coordinates for the curve's anchor and control points. + let x1 = 85; + let x2 = 10; + let x3 = 90; + let x4 = 15; + let y1 = 20; + let y2 = 10; + let y3 = 90; + let y4 = 80; + + // Draw the curve. + noFill(); + bezier(x1, y1, x2, y2, x3, y3, x4, y4); + + // Calculate the circle's coordinates. + let t = 0.5 * sin(frameCount * 0.01) + 0.5; + let x = bezierPoint(x1, x2, x3, x4, t); + let y = bezierPoint(y1, y2, y3, y4, t); + + // Draw the circle. + fill(255); + circle(x, y, 5); + } + +
+class: p5 +params: + - name: a + description: | +

coordinate of first anchor point.

+ type: Number + - name: b + description: | +

coordinate of first control point.

+ type: Number + - name: c + description: | +

coordinate of second control point.

+ type: Number + - name: d + description: | +

coordinate of second anchor point.

+ type: Number + - name: t + description: | +

amount to interpolate between 0 and 1.

+ type: Number +return: + description: coordinate of the point on the curve. + type: Number +chainable: false +--- + + +# bezierPoint diff --git a/src/content/reference/en/p5 copy/bezierTangent.mdx b/src/content/reference/en/p5 copy/bezierTangent.mdx new file mode 100644 index 0000000000..8fb0edfaa8 --- /dev/null +++ b/src/content/reference/en/p5 copy/bezierTangent.mdx @@ -0,0 +1,155 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L450 +title: bezierTangent +module: Shape +submodule: Curves +file: src/core/shape/curves.js +description: > +

Calculates coordinates along a line that's tangent to a Bézier curve.

+ +

Tangent lines skim the surface of a curve. A tangent line's slope equals + + the curve's slope at the point where it intersects.

+ +

bezierTangent() calculates coordinates along a tangent line + using the + + Bézier curve's anchor and control points. It expects points in the same + + order as the bezier() function. + bezierTangent() + + works one axis at a time. Passing the anchor and control points' + + x-coordinates will calculate the x-coordinate of a point on the tangent + + line. Passing the anchor and control points' y-coordinates will calculate + + the y-coordinate of a point on the tangent line.

+ +

The first parameter, a, is the coordinate of the first anchor + point.

+ +

The second and third parameters, b and c, are the + coordinates of the + + control points.

+ +

The fourth parameter, d, is the coordinate of the last anchor + point.

+ +

The fifth parameter, t, is the amount to interpolate along the + curve. 0 + + is the first anchor point, 1 is the second anchor point, and 0.5 is halfway + + between them.

+line: 450 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Set the coordinates for the curve's anchor and control points. + let x1 = 85; + let x2 = 10; + let x3 = 90; + let x4 = 15; + let y1 = 20; + let y2 = 10; + let y3 = 90; + let y4 = 80; + + // Style the curve. + noFill(); + + // Draw the curve. + bezier(x1, y1, x2, y2, x3, y3, x4, y4); + + // Draw tangents along the curve's path. + fill(255); + + // Top-right circle. + stroke(0); + let x = bezierPoint(x1, x2, x3, x4, 0); + let y = bezierPoint(y1, y2, y3, y4, 0); + circle(x, y, 5); + + // Top-right tangent line. + // Scale the tangent point to draw a shorter line. + stroke(255, 0, 0); + let tx = 0.1 * bezierTangent(x1, x2, x3, x4, 0); + let ty = 0.1 * bezierTangent(y1, y2, y3, y4, 0); + line(x + tx, y + ty, x - tx, y - ty); + + // Center circle. + stroke(0); + x = bezierPoint(x1, x2, x3, x4, 0.5); + y = bezierPoint(y1, y2, y3, y4, 0.5); + circle(x, y, 5); + + // Center tangent line. + // Scale the tangent point to draw a shorter line. + stroke(255, 0, 0); + tx = 0.1 * bezierTangent(x1, x2, x3, x4, 0.5); + ty = 0.1 * bezierTangent(y1, y2, y3, y4, 0.5); + line(x + tx, y + ty, x - tx, y - ty); + + // Bottom-left circle. + stroke(0); + x = bezierPoint(x1, x2, x3, x4, 1); + y = bezierPoint(y1, y2, y3, y4, 1); + circle(x, y, 5); + + // Bottom-left tangent. + // Scale the tangent point to draw a shorter line. + stroke(255, 0, 0); + tx = 0.1 * bezierTangent(x1, x2, x3, x4, 1); + ty = 0.1 * bezierTangent(y1, y2, y3, y4, 1); + line(x + tx, y + ty, x - tx, y - ty); + + describe( + 'A black s-curve on a gray square. The endpoints and center of the curve are marked with white circles. Red tangent lines extend from the white circles.' + ); + } + +
+class: p5 +params: + - name: a + description: | +

coordinate of first anchor point.

+ type: Number + - name: b + description: | +

coordinate of first control point.

+ type: Number + - name: c + description: | +

coordinate of second control point.

+ type: Number + - name: d + description: | +

coordinate of second anchor point.

+ type: Number + - name: t + description: | +

amount to interpolate between 0 and 1.

+ type: Number +return: + description: coordinate of a point on the tangent line. + type: Number +chainable: false +--- + + +# bezierTangent diff --git a/src/content/reference/en/p5 copy/bezierVertex.mdx b/src/content/reference/en/p5 copy/bezierVertex.mdx new file mode 100644 index 0000000000..f4b5fb57cb --- /dev/null +++ b/src/content/reference/en/p5 copy/bezierVertex.mdx @@ -0,0 +1,337 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L543 +title: bezierVertex +module: Shape +submodule: Vertex +file: src/core/shape/vertex.js +description: > +

Adds a Bézier curve segment to a custom shape.

+ +

bezierVertex() adds a curved segment to custom shapes. The + Bézier curves + + it creates are defined like those made by the + + bezier() function. + bezierVertex() must be + + called between the + + beginShape() and + + endShape() functions. The curved segment + uses + + the previous vertex as the first anchor point, so there must be at least + + one call to vertex() before + bezierVertex() can + + be used.

+ +

The first four parameters, x2, y2, + x3, and y3, set the curve’s two + + control points. The control points "pull" the curve towards them.

+ +

The fifth and sixth parameters, x4, and y4, set + the last anchor point. + + The last anchor point is where the curve ends.

+ +

Bézier curves can also be drawn in 3D using WebGL mode. The 3D version of + + bezierVertex() has eight arguments because each point has x-, y-, + and + + z-coordinates.

+ +

Note: bezierVertex() won’t work when an argument is passed to + + beginShape().

+line: 543 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the shape. + noFill(); + + // Start drawing the shape. + beginShape(); + + // Add the first anchor point. + vertex(30, 20); + + // Add the Bézier vertex. + bezierVertex(80, 0, 80, 75, 30, 75); + + // Stop drawing the shape. + endShape(); + + describe('A black C curve on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw the anchor points in black. + stroke(0); + strokeWeight(5); + point(30, 20); + point(30, 75); + + // Draw the control points in red. + stroke(255, 0, 0); + point(80, 0); + point(80, 75); + + // Style the shape. + noFill(); + stroke(0); + strokeWeight(1); + + // Start drawing the shape. + beginShape(); + + // Add the first anchor point. + vertex(30, 20); + + // Add the Bézier vertex. + bezierVertex(80, 0, 80, 75, 30, 75); + + // Stop drawing the shape. + endShape(); + + // Draw red lines from the anchor points to the control points. + stroke(255, 0, 0); + line(30, 20, 80, 0); + line(30, 75, 80, 75); + + describe( + 'A gray square with three curves. A black curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' + ); + } + +
+ +
+ + // Click the mouse near the red dot in the top-right corner + // and drag to change the curve's shape. + + let x2 = 80; + let y2 = 0; + let isChanging = false; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with three curves. A black curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' + ); + } + + function draw() { + background(200); + + // Draw the anchor points in black. + stroke(0); + strokeWeight(5); + point(30, 20); + point(30, 75); + + // Draw the control points in red. + stroke(255, 0, 0); + point(x2, y2); + point(80, 75); + + // Style the shape. + noFill(); + stroke(0); + strokeWeight(1); + + // Start drawing the shape. + beginShape(); + + // Add the first anchor point. + vertex(30, 20); + + // Add the Bézier vertex. + bezierVertex(x2, y2, 80, 75, 30, 75); + + // Stop drawing the shape. + endShape(); + + // Draw red lines from the anchor points to the control points. + stroke(255, 0, 0); + line(30, 20, x2, y2); + line(30, 75, 80, 75); + } + + // Start changing the first control point if the user clicks near it. + function mousePressed() { + if (dist(mouseX, mouseY, x2, y2) < 20) { + isChanging = true; + } + } + + // Stop changing the first control point when the user releases the mouse. + function mouseReleased() { + isChanging = false; + } + + // Update the first control point while the user drags the mouse. + function mouseDragged() { + if (isChanging === true) { + x2 = mouseX; + y2 = mouseY; + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + beginShape(); + + // Add the first anchor point. + vertex(30, 20); + + // Add the Bézier vertices. + bezierVertex(80, 0, 80, 75, 30, 75); + bezierVertex(50, 80, 60, 25, 30, 20); + + // Stop drawing the shape. + endShape(); + + describe('A crescent moon shape drawn in white on a gray background.'); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A crescent moon shape drawn in white on a blue background. When the user drags the mouse, the scene rotates and a second moon is revealed.'); + } + + function draw() { + background('midnightblue'); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the moons. + noStroke(); + fill('lemonchiffon'); + + // Draw the first moon. + beginShape(); + vertex(-20, -30, 0); + bezierVertex(30, -50, 0, 30, 25, 0, -20, 25, 0); + bezierVertex(0, 30, 0, 10, -25, 0, -20, -30, 0); + endShape(); + + // Draw the second moon. + beginShape(); + vertex(-20, -30, -20); + bezierVertex(30, -50, -20, 30, 25, -20, -20, 25, -20); + bezierVertex(0, 30, -20, 10, -25, -20, -20, -30, -20); + endShape(); + } + +
+class: p5 +overloads: + - line: 543 + params: + - name: x2 + description: | +

x-coordinate of the first control point.

+ type: Number + - name: y2 + description: | +

y-coordinate of the first control point.

+ type: Number + - name: x3 + description: | +

x-coordinate of the second control point.

+ type: Number + - name: y3 + description: | +

y-coordinate of the second control point.

+ type: Number + - name: x4 + description: | +

x-coordinate of the anchor point.

+ type: Number + - name: y4 + description: | +

y-coordinate of the anchor point.

+ type: Number + chainable: 1 + - line: 792 + params: + - name: x2 + description: '' + type: Number + - name: y2 + description: '' + type: Number + - name: z2 + description: | +

z-coordinate of the first control point.

+ type: Number + - name: x3 + description: '' + type: Number + - name: y3 + description: '' + type: Number + - name: z3 + description: | +

z-coordinate of the second control point.

+ type: Number + - name: x4 + description: '' + type: Number + - name: y4 + description: '' + type: Number + - name: z4 + description: | +

z-coordinate of the anchor point.

+ type: Number + chainable: 1 +chainable: true +--- + + +# bezierVertex diff --git a/src/content/reference/en/p5 copy/blend.mdx b/src/content/reference/en/p5 copy/blend.mdx new file mode 100644 index 0000000000..53e9a94dc9 --- /dev/null +++ b/src/content/reference/en/p5 copy/blend.mdx @@ -0,0 +1,214 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L148 +title: blend +module: Image +submodule: Pixels +file: src/image/pixels.js +description: > +

Copies a region of pixels from one image to another.

+ +

The first parameter, srcImage, is the + + p5.Image object to blend.

+ +

The next four parameters, sx, sy, + sw, and sh determine the region + + to blend from the source image. (sx, sy) is the top-left corner + of the + + region. sw and sh are the regions width and + height.

+ +

The next four parameters, dx, dy, + dw, and dh determine the region + + of the canvas to blend into. (dx, dy) is the top-left corner of + the + + region. dw and dh are the regions width and + height.

+ +

The tenth parameter, blendMode, sets the effect used to blend + the images' + + colors. The options are BLEND, DARKEST, + LIGHTEST, DIFFERENCE, + + MULTIPLY, EXCLUSION, SCREEN, + REPLACE, OVERLAY, HARD_LIGHT, + + SOFT_LIGHT, DODGE, BURN, + ADD, or NORMAL

+line: 148 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img0; + let img1; + + // Load the images. + function preload() { + img0 = loadImage('/assets/rockies.jpg'); + img1 = loadImage('/assets/bricks_third.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Use the mountains as the background. + background(img0); + + // Display the bricks. + image(img1, 0, 0); + + // Display the bricks faded into the landscape. + blend(img1, 0, 0, 33, 100, 67, 0, 33, 100, LIGHTEST); + + describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears faded on the right of the image.'); + } + +
+ +
+ + let img0; + let img1; + + // Load the images. + function preload() { + img0 = loadImage('/assets/rockies.jpg'); + img1 = loadImage('/assets/bricks_third.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Use the mountains as the background. + background(img0); + + // Display the bricks. + image(img1, 0, 0); + + // Display the bricks partially transparent. + blend(img1, 0, 0, 33, 100, 67, 0, 33, 100, DARKEST); + + describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears transparent on the right of the image.'); + } + +
+ +
+ + let img0; + let img1; + + // Load the images. + function preload() { + img0 = loadImage('/assets/rockies.jpg'); + img1 = loadImage('/assets/bricks_third.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Use the mountains as the background. + background(img0); + + // Display the bricks. + image(img1, 0, 0); + + // Display the bricks washed out into the landscape. + blend(img1, 0, 0, 33, 100, 67, 0, 33, 100, ADD); + + describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears washed out on the right of the image.'); + } + +
+class: p5 +overloads: + - line: 148 + params: + - name: srcImage + description: | +

source image.

+ type: p5.Image + - name: sx + description: | +

x-coordinate of the source's upper-left corner.

+ type: Integer + - name: sy + description: | +

y-coordinate of the source's upper-left corner.

+ type: Integer + - name: sw + description: | +

source image width.

+ type: Integer + - name: sh + description: | +

source image height.

+ type: Integer + - name: dx + description: | +

x-coordinate of the destination's upper-left corner.

+ type: Integer + - name: dy + description: | +

y-coordinate of the destination's upper-left corner.

+ type: Integer + - name: dw + description: | +

destination image width.

+ type: Integer + - name: dh + description: | +

destination image height.

+ type: Integer + - name: blendMode + description: | +

the blend mode. either + BLEND, DARKEST, LIGHTEST, DIFFERENCE, + MULTIPLY, EXCLUSION, SCREEN, REPLACE, OVERLAY, HARD_LIGHT, + SOFT_LIGHT, DODGE, BURN, ADD or NORMAL.

+ type: Constant + - line: 267 + params: + - name: sx + description: '' + type: Integer + - name: sy + description: '' + type: Integer + - name: sw + description: '' + type: Integer + - name: sh + description: '' + type: Integer + - name: dx + description: '' + type: Integer + - name: dy + description: '' + type: Integer + - name: dw + description: '' + type: Integer + - name: dh + description: '' + type: Integer + - name: blendMode + description: '' + type: Constant +chainable: false +--- + + +# blend diff --git a/src/content/reference/en/p5 copy/blendMode.mdx b/src/content/reference/en/p5 copy/blendMode.mdx new file mode 100644 index 0000000000..8f6365b78d --- /dev/null +++ b/src/content/reference/en/p5 copy/blendMode.mdx @@ -0,0 +1,541 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L720 +title: blendMode +module: Rendering +submodule: Rendering +file: src/core/rendering.js +description: > +

Sets the way colors blend when added to the canvas.

+ +

By default, drawing with a solid color paints over the current pixel values + + on the canvas. blendMode() offers many options for blending + colors.

+ +

Shapes, images, and text can be used as sources for drawing to the canvas. + + A source pixel changes the color of the canvas pixel where it's drawn. The + + final color results from blending the source pixel's color with the canvas + + pixel's color. RGB color values from the source and canvas pixels are + + compared, added, subtracted, multiplied, and divided to create different + + effects. Red values with red values, greens with greens, and blues with + + blues.

+ +

The parameter, mode, sets the blend mode. For example, calling + + blendMode(ADD) sets the blend mode to ADD. The + following blend modes + + are available in both 2D and WebGL mode:

+ +
    + +
  • BLEND: color values from the source overwrite the canvas. + This is the default mode.
  • + +
  • ADD: color values from the source are added to values from + the canvas.
  • + +
  • DARKEST: keeps the darkest color value.
  • + +
  • LIGHTEST: keeps the lightest color value.
  • + +
  • EXCLUSION: similar to DIFFERENCE but with less + contrast.
  • + +
  • MULTIPLY: color values from the source are multiplied with + values from the canvas. The result is always darker.
  • + +
  • SCREEN: all color values are inverted, then multiplied, then + inverted again. The result is always lighter. (Opposite of + MULTIPLY)
  • + +
  • REPLACE: the last source drawn completely replaces the rest + of the canvas.
  • + +
  • REMOVE: overlapping pixels are removed by making them + completely transparent.
  • + +
+ +

The following blend modes are only available in 2D mode:

+ +
    + +
  • DIFFERENCE: color values from the source are subtracted from + the values from the canvas. If the difference is a negative number, it's made + positive.
  • + +
  • OVERLAY: combines MULTIPLY and + SCREEN. Dark values in the canvas get darker and light values get + lighter.
  • + +
  • HARD_LIGHT: combines MULTIPLY and + SCREEN. Dark values in the source get darker and light values get + lighter.
  • + +
  • SOFT_LIGHT: a softer version of HARD_LIGHT.
  • + +
  • DODGE: lightens light tones and increases contrast. Divides + the canvas color values by the inverted color values from the source.
  • + +
  • BURN: darkens dark tones and increases contrast. Divides the + source color values by the inverted color values from the canvas, then inverts + the result.
  • + +
+ +

The following blend modes are only available in WebGL mode:

+ +
    + +
  • SUBTRACT: RGB values from the source are subtracted from the + values from the canvas. If the difference is a negative number, it's made + positive. Alpha (transparency) values from the source and canvas are + added.
  • + +
+line: 720 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Use the default blend mode. + blendMode(BLEND); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('A Sky Blue line and a Deep Rose line form an X on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(HARD_LIGHT); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('An ocean blue line and a hot pink line form an X on a gray background. The area where they overlap is Magenta purple.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(ADD); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('An icy blue line and a light lavender line form an X on a gray background. The area where they overlap is white.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(DARKEST); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('A steel blue line and a cranberry line form an X on a gray background. The area where they overlap is deep purple.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(BURN); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('A cobalt blue line and a burgundy line form an X on a gray background. The area where they overlap is black.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(LIGHTEST); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('A pale lavender line and a soft beige line form an X on a gray background. The area where they overlap is pale lilac.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(EXCLUSION); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('An earthy brown line and a muted sage line form an X on a gray background. The area where they overlap is sage green.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(MULTIPLY); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('A slate blue line and a plum line form an X on a gray background. The area where they overlap is dark Indigo.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(SCREEN); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('A baby blue line and a peach pink line form an X on a gray background. The area where they overlap is misty lilac.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(REPLACE); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('A diagonal deep rose line.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(REMOVE); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('The silhouette of an X is missing from a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(DIFFERENCE); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('A light burgundy line and a forest green line form an X on a gray background. The area where they overlap is dark cocoa.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(OVERLAY); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('A cornflower blue line and a light rose line form an X on a gray background. The area where they overlap is violet.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(SOFT_LIGHT); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('A pale sky line and a rose blush line form an X on a gray background. The area where they overlap is lavender.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(DODGE); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('An aqua blue line and a light pink line form an X on a gray background. The area where they overlap is white.'); + } + +
+ +
+ + function setup() { + // Create a canvas with WEBGL mode. + createCanvas(100, 100, WEBGL); + + // Set the background color. + background(180); + + // Set the blend mode to SUBTRACT. + blendMode(SUBTRACT); + + // Style the lines. + strokeWeight(30); + + // Draw the blue line. + stroke('#1a85ff'); + line(-25, -25, 25, 25); + + // Draw the red line. + stroke('#d41159'); + line(25, -25, -25, 25); + + describe('A burnt orange and a sea green line form an X on a gray background. The area where they overlap is forest green.'); + } + +
+class: p5 +params: + - name: mode + description: | +

blend mode to set. + either BLEND, DARKEST, LIGHTEST, DIFFERENCE, MULTIPLY, + EXCLUSION, SCREEN, REPLACE, OVERLAY, HARD_LIGHT, + SOFT_LIGHT, DODGE, BURN, ADD, REMOVE or SUBTRACT

+ type: Constant +chainable: false +--- + + +# blendMode diff --git a/src/content/reference/en/p5 copy/blue.mdx b/src/content/reference/en/p5 copy/blue.mdx new file mode 100644 index 0000000000..d3e05aae37 --- /dev/null +++ b/src/content/reference/en/p5 copy/blue.mdx @@ -0,0 +1,158 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L117 +title: blue +module: Color +submodule: Creating & Reading +file: src/color/creating_reading.js +description: > +

Gets the blue value of a color.

+ +

blue() extracts the blue value from a + + p5.Color object, an array of color + components, or + + a CSS color string.

+ +

By default, blue() returns a color's blue value in the range 0 + + to 255. If the colorMode() is set to + RGB, it + + returns the blue value in the given range.

+line: 117 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object using RGB values. + let c = color(175, 100, 220); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'blueValue' to 220. + let blueValue = blue(c); + + // Draw the right rectangle. + fill(0, 0, blueValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is royal blue.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a color array. + let c = [175, 100, 220]; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'blueValue' to 220. + let blueValue = blue(c); + + // Draw the right rectangle. + fill(0, 0, blueValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is royal blue.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a CSS color string. + let c = 'rgb(175, 100, 220)'; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'blueValue' to 220. + let blueValue = blue(c); + + // Draw the right rectangle. + fill(0, 0, blueValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is royal blue.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use RGB color with values in the range 0-100. + colorMode(RGB, 100); + + // Create a p5.Color object using RGB values. + let c = color(69, 39, 86); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'blueValue' to 86. + let blueValue = blue(c); + + // Draw the right rectangle. + fill(0, 0, blueValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is royal blue.'); + } + +
+class: p5 +params: + - name: color + description: | +

p5.Color object, array of + color components, or CSS color string.

+ type: 'p5.Color|Number[]|String' +return: + description: the blue value. + type: Number +chainable: false +--- + + +# blue diff --git a/src/content/reference/en/p5 copy/boolean.mdx b/src/content/reference/en/p5 copy/boolean.mdx new file mode 100644 index 0000000000..8eab48af5f --- /dev/null +++ b/src/content/reference/en/p5 copy/boolean.mdx @@ -0,0 +1,157 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L341 +title: boolean +module: Data +submodule: Conversion +file: src/utilities/conversion.js +description: > +

Converts a String or Number to a + Boolean.

+ +

boolean() converts values to true or + false.

+ +

The parameter, n, is the value to convert. If n + is a string, then + + boolean('true') will return true and every other + string value will + + return false. If n is a number, then + boolean(0) will return false + + and every other numeric value will return true. If an array is + passed, as + + in boolean([0, 1, 'true', 'blue']), then an array of Boolean + values will + + be returned.

+line: 341 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a number variable. + let original = 0; + + // Convert the number to a Boolean value. + let converted = boolean(original); + + // Style the circle based on the converted value. + if (converted === true) { + fill('blue'); + } else { + fill('red'); + } + + // Draw the circle. + circle(50, 50, 40); + + describe('A red circle on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let original = 'true'; + + // Convert the string to a Boolean value. + let converted = boolean(original); + + // Style the circle based on the converted value. + if (converted === true) { + fill('blue'); + } else { + fill('red'); + } + + // Draw the circle. + circle(50, 50, 40); + + describe('A blue circle on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of values. + let original = [0, 'hi', 123, 'true']; + + // Convert the array to a Boolean values. + let converted = boolean(original); + + // Iterate over the array of converted Boolean values. + for (let i = 0; i < converted.length; i += 1) { + + // Style the circle based on the converted value. + if (converted[i] === true) { + fill('blue'); + } else { + fill('red'); + } + + // Calculate the x-coordinate. + let x = (i + 1) * 20; + + // Draw the circle. + circle(x, 50, 15); + } + + describe( + 'A row of circles on a gray background. The two circles on the left are red and the two on the right are blue.' + ); + } + +
+class: p5 +return: + description: converted Boolean value. + type: Boolean +overloads: + - line: 341 + params: + - name: 'n' + description: | +

value to convert.

+ type: String|Boolean|Number + return: + description: converted Boolean value. + type: Boolean + - line: 451 + params: + - name: ns + description: | +

values to convert.

+ type: Array + return: + description: converted Boolean values. + type: 'Boolean[]' +chainable: false +--- + + +# boolean diff --git a/src/content/reference/en/p5 copy/box.mdx b/src/content/reference/en/p5 copy/box.mdx new file mode 100644 index 0000000000..a4f5282947 --- /dev/null +++ b/src/content/reference/en/p5 copy/box.mdx @@ -0,0 +1,186 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L1009 +title: box +module: Shape +submodule: 3D Primitives +file: src/webgl/3d_primitives.js +description: > +

Draws a box (rectangular prism).

+ +

A box is a 3D shape with six faces. Each face makes a 90˚ with four + + neighboring faces.

+ +

The first parameter, width, is optional. If a + Number is passed, as in + + box(20), it sets the box’s width and height. By default, + width is 50.

+ +

The second parameter, height, is also optional. If a + Number is passed, + + as in box(20, 30), it sets the box’s height. By default, + height is set + + to the box’s width.

+ +

The third parameter, depth, is also optional. If a + Number is passed, as + + in box(20, 30, 40), it sets the box’s depth. By default, + depth is set + + to the box’s height.

+ +

The fourth parameter, detailX, is also optional. If a + Number is passed, + + as in box(20, 30, 40, 5), it sets the number of triangle + subdivisions to + + use along the x-axis. All 3D shapes are made by connecting triangles to + + form their surfaces. By default, detailX is 1.

+ +

The fifth parameter, detailY, is also optional. If a number is + passed, as + + in box(20, 30, 40, 5, 7), it sets the number of triangle + subdivisions to + + use along the y-axis. All 3D shapes are made by connecting triangles to + + form their surfaces. By default, detailY is 1.

+ +

Note: box() can only be used in WebGL mode.

+line: 1009 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white box on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white box on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the box. + // Set its width and height to 30. + box(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white box on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the box. + // Set its width to 30 and height to 50. + box(30, 50); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white box on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the box. + // Set its width to 30, height to 50, and depth to 10. + box(30, 50, 10); + } + +
+class: p5 +params: + - name: width + description: | +

width of the box.

+ type: Number + optional: true + - name: height + description: | +

height of the box.

+ type: Number + optional: true + - name: depth + description: | +

depth of the box.

+ type: Number + optional: true + - name: detailX + description: | +

number of triangle subdivisions along the x-axis.

+ type: Integer + optional: true + - name: detailY + description: | +

number of triangle subdivisions along the y-axis.

+ type: Integer + optional: true +chainable: true +--- + + +# box diff --git a/src/content/reference/en/p5 copy/brightness.mdx b/src/content/reference/en/p5 copy/brightness.mdx new file mode 100644 index 0000000000..2860cbf226 --- /dev/null +++ b/src/content/reference/en/p5 copy/brightness.mdx @@ -0,0 +1,168 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L253 +title: brightness +module: Color +submodule: Creating & Reading +file: src/color/creating_reading.js +description: > +

Gets the brightness value of a color.

+ +

brightness() extracts the HSB brightness value from a + + p5.Color object, an array of color + components, or + + a CSS color string.

+ +

By default, brightness() returns a color's HSB brightness in + the range 0 + + to 100. If the colorMode() is set to + HSB, it + + returns the brightness value in the given range.

+line: 253 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use HSB color. + colorMode(HSB); + + // Create a p5.Color object. + let c = color(0, 50, 100); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'brightValue' to 100. + let brightValue = brightness(c); + + // Draw the right rectangle. + fill(brightValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is white.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use HSB color. + colorMode(HSB); + + // Create a color array. + let c = [0, 50, 100]; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'brightValue' to 100. + let brightValue = brightness(c); + + // Draw the right rectangle. + fill(brightValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is white.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use HSB color. + colorMode(HSB); + + // Create a CSS color string. + let c = 'rgb(255, 128, 128)'; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'brightValue' to 100. + let brightValue = brightness(c); + + // Draw the right rectangle. + fill(brightValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is white.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use HSB color with values in the range 0-255. + colorMode(HSB, 255); + + // Create a p5.Color object. + let c = color(0, 127, 255); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'brightValue' to 255. + let brightValue = brightness(c); + + // Draw the right rectangle. + fill(brightValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is white.'); + } + +
+class: p5 +params: + - name: color + description: | +

p5.Color object, array of + color components, or CSS color string.

+ type: 'p5.Color|Number[]|String' +return: + description: the brightness value. + type: Number +chainable: false +--- + + +# brightness diff --git a/src/content/reference/en/p5 copy/buildGeometry.mdx b/src/content/reference/en/p5 copy/buildGeometry.mdx new file mode 100644 index 0000000000..ef58d7b650 --- /dev/null +++ b/src/content/reference/en/p5 copy/buildGeometry.mdx @@ -0,0 +1,263 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L520 +title: buildGeometry +module: Shape +submodule: 3D Primitives +file: src/webgl/3d_primitives.js +description: > +

Creates a custom p5.Geometry object + from + + simpler 3D shapes.

+ +

buildGeometry() helps with creating complex 3D shapes from + simpler ones + + such as sphere(). It can help to make + sketches + + more performant. For example, if a complex 3D shape doesn’t change while a + + sketch runs, then it can be created with buildGeometry(). + Creating a + + p5.Geometry object once and then + drawing it + + will run faster than repeatedly drawing the individual pieces.

+ +

The parameter, callback, is a function with the drawing + instructions for + + the new p5.Geometry object. It will be + called + + once to create the new 3D shape.

+ +

See beginGeometry() and + + endGeometry() for another way to + build 3D + + shapes.

+ +

Note: buildGeometry() can only be used in WebGL mode.

+line: 520 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the p5.Geometry object. + shape = buildGeometry(createShape); + + describe('A white cone drawn on a gray background.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the p5.Geometry object. + noStroke(); + + // Draw the p5.Geometry object. + model(shape); + } + + // Create p5.Geometry object from a single cone. + function createShape() { + cone(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the arrow. + shape = buildGeometry(createArrow); + + describe('A white arrow drawn on a gray background.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the arrow. + noStroke(); + + // Draw the arrow. + model(shape); + } + + function createArrow() { + // Add shapes to the p5.Geometry object. + push(); + rotateX(PI); + cone(10); + translate(0, -10, 0); + cylinder(3, 20); + pop(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the p5.Geometry object. + shape = buildGeometry(createArrow); + + describe('Two white arrows drawn on a gray background. The arrow on the right rotates slowly.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the arrows. + noStroke(); + + // Draw the p5.Geometry object. + model(shape); + + // Translate and rotate the coordinate system. + translate(30, 0, 0); + rotateZ(frameCount * 0.01); + + // Draw the p5.Geometry object again. + model(shape); + } + + function createArrow() { + // Add shapes to the p5.Geometry object. + push(); + rotateX(PI); + cone(10); + translate(0, -10, 0); + cylinder(3, 20); + pop(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let button; + let particles; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a button to reset the particle system. + button = createButton('Reset'); + + // Call resetModel() when the user presses the button. + button.mousePressed(resetModel); + + // Add the original set of particles. + resetModel(); + + describe('A set of white spheres on a gray background. The spheres are positioned randomly. Their positions reset when the user presses the Reset button.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the particles. + noStroke(); + + // Draw the particles. + model(particles); + } + + function resetModel() { + // If the p5.Geometry object has already been created, + // free those resources. + if (particles) { + freeGeometry(particles); + } + + // Create a new p5.Geometry object with random spheres. + particles = buildGeometry(createParticles); + } + + function createParticles() { + for (let i = 0; i < 60; i += 1) { + // Calculate random coordinates. + let x = randomGaussian(0, 20); + let y = randomGaussian(0, 20); + let z = randomGaussian(0, 20); + + push(); + // Translate to the particle's coordinates. + translate(x, y, z); + // Draw the particle. + sphere(5); + pop(); + } + } + +
+class: p5 +params: + - name: callback + description: | +

function that draws the shape.

+ type: Function +return: + description: new 3D shape. + type: p5.Geometry +chainable: false +--- + + +# buildGeometry diff --git a/src/content/reference/en/p5 copy/byte.mdx b/src/content/reference/en/p5 copy/byte.mdx new file mode 100644 index 0000000000..0a6f3234a4 --- /dev/null +++ b/src/content/reference/en/p5 copy/byte.mdx @@ -0,0 +1,180 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L468 +title: byte +module: Data +submodule: Conversion +file: src/utilities/conversion.js +description: > +

Converts a Boolean, String, or + Number to its byte value.

+ +

byte() converts a value to an integer (whole number) between + -128 and + + 127. Values greater than 127 wrap around while negative values are + + unchanged. For example, 128 becomes -128 and -129 remains the same.

+ +

The parameter, n, is the value to convert. If n + is a Boolean, as in + + byte(false) or byte(true), the number 0 + (false) or 1 (true) will be + + returned. If n is a string or number, as in + byte('256') or byte(256), + + then the byte value will be returned. Decimal values are ignored. If an + + array is passed, as in byte([true, 123, '456']), then an array of + byte + + values will be returned.

+ +

Note: If a value can't be converted to a number, as in + byte('giraffe'), + + then the value NaN (not a number) will be returned.

+line: 468 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a Boolean variable. + let original = true; + + // Convert the Boolean to its byte value. + let converted = byte(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the original and converted values. + text(`${original} : ${converted}`, 50, 50); + + describe('The text "true : 1" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let original = '256'; + + // Convert the string to its byte value. + let converted = byte(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the original and converted values. + text(`${original} : ${converted}`, 50, 50); + + describe('The text "256 : 0" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a number variable. + let original = 256; + + // Convert the number to its byte value. + let converted = byte(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the original and converted values. + text(`${original} : ${converted}`, 50, 50); + + describe('The text "256 : 0" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of values. + let original = [false, '64', 383]; + + // Convert the array elements to their byte values. + let converted = byte(original); + + // Iterate over the converted array elements. + for (let i = 0; i < converted.length; i += 1) { + + // Style the circle. + fill(converted[i]); + + // Calculate the x-coordinate. + let x = (i + 1) * 25; + + // Draw the circle. + circle(x, 50, 20); + } + + describe( + 'Three gray circles on a gray background. The circles get lighter from left to right.' + ); + } + +
+class: p5 +return: + description: converted byte value. + type: Number +overloads: + - line: 468 + params: + - name: 'n' + description: | +

value to convert.

+ type: String|Boolean|Number + return: + description: converted byte value. + type: Number + - line: 598 + params: + - name: ns + description: | +

values to convert.

+ type: Array + return: + description: converted byte values. + type: 'Number[]' +chainable: false +--- + + +# byte diff --git a/src/content/reference/en/p5 copy/camera.mdx b/src/content/reference/en/p5 copy/camera.mdx new file mode 100644 index 0000000000..55f983385e --- /dev/null +++ b/src/content/reference/en/p5 copy/camera.mdx @@ -0,0 +1,200 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L13 +title: camera +module: 3D +submodule: Camera +file: src/webgl/p5.Camera.js +description: > +

Sets the position and orientation of the current camera in a 3D sketch.

+ +

camera() allows objects to be viewed from different angles. It + has nine + + parameters that are all optional.

+ +

The first three parameters, x, y, and + z, are the coordinates of the + + camera’s position. For example, calling camera(0, 0, 0) places + the camera + + at the origin (0, 0, 0). By default, the camera is placed at + + (0, 0, 800).

+ +

The next three parameters, centerX, centerY, and + centerZ are the + + coordinates of the point where the camera faces. For example, calling + + camera(0, 0, 0, 10, 20, 30) places the camera at the origin + (0, 0, 0) + + and points it at (10, 20, 30). By default, the camera points at + the + + origin (0, 0, 0).

+ +

The last three parameters, upX, upY, and + upZ are the components of + + the "up" vector. The "up" vector orients the camera’s y-axis. For example, + + calling camera(0, 0, 0, 10, 20, 30, 0, -1, 0) places the camera + at the + + origin (0, 0, 0), points it at (10, 20, 30), and + sets the "up" vector + + to (0, -1, 0) which is like holding it upside-down. By default, + the "up" + + vector is (0, 1, 0).

+ +

Note: camera() can only be used in WebGL mode.

+line: 13 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Move the camera to the top-right. + camera(200, -400, 800); + + // Draw the box. + box(); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube apperas to sway left and right on a gray background.'); + } + + function draw() { + background(200); + + // Calculate the camera's x-coordinate. + let x = 400 * cos(frameCount * 0.01); + + // Orbit the camera around the box. + camera(x, -400, 800); + + // Draw the box. + box(); + } + +
+ +
+ + // Adjust the range sliders to change the camera's position. + + let xSlider; + let ySlider; + let zSlider; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create slider objects to set the camera's coordinates. + xSlider = createSlider(-400, 400, 400); + xSlider.position(0, 100); + xSlider.size(100); + ySlider = createSlider(-400, 400, -200); + ySlider.position(0, 120); + ySlider.size(100); + zSlider = createSlider(0, 1600, 800); + zSlider.position(0, 140); + zSlider.size(100); + + describe( + 'A white cube drawn against a gray background. Three range sliders appear beneath the image. The camera position changes when the user moves the sliders.' + ); + } + + function draw() { + background(200); + + // Get the camera's coordinates from the sliders. + let x = xSlider.value(); + let y = ySlider.value(); + let z = zSlider.value(); + + // Move the camera. + camera(x, y, z); + + // Draw the box. + box(); + } + +
+class: p5 +params: + - name: x + description: | +

x-coordinate of the camera. Defaults to 0.

+ type: Number + optional: true + - name: 'y' + description: | +

y-coordinate of the camera. Defaults to 0.

+ type: Number + optional: true + - name: z + description: | +

z-coordinate of the camera. Defaults to 800.

+ type: Number + optional: true + - name: centerX + description: | +

x-coordinate of the point the camera faces. Defaults to 0.

+ type: Number + optional: true + - name: centerY + description: | +

y-coordinate of the point the camera faces. Defaults to 0.

+ type: Number + optional: true + - name: centerZ + description: | +

z-coordinate of the point the camera faces. Defaults to 0.

+ type: Number + optional: true + - name: upX + description: | +

x-component of the camera’s "up" vector. Defaults to 0.

+ type: Number + optional: true + - name: upY + description: | +

y-component of the camera’s "up" vector. Defaults to 1.

+ type: Number + optional: true + - name: upZ + description: | +

z-component of the camera’s "up" vector. Defaults to 0.

+ type: Number + optional: true +chainable: true +--- + + +# camera diff --git a/src/content/reference/en/p5 copy/ceil.mdx b/src/content/reference/en/p5 copy/ceil.mdx new file mode 100644 index 0000000000..45c17468bf --- /dev/null +++ b/src/content/reference/en/p5 copy/ceil.mdx @@ -0,0 +1,65 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L48 +title: ceil +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Calculates the closest integer value that is greater than or equal to a + + number.

+ +

For example, calling ceil(9.03) and ceil(9.97) + both return the value + + 10.

+line: 48 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use RGB color with values from 0 to 1. + colorMode(RGB, 1); + + noStroke(); + + // Draw the left rectangle. + let r = 0.3; + fill(r, 0, 0); + rect(0, 0, 50, 100); + + // Round r up to 1. + r = ceil(r); + + // Draw the right rectangle. + fill(r, 0, 0); + rect(50, 0, 50, 100); + + describe('Two rectangles. The one on the left is dark red and the one on the right is bright red.'); + } + +
+class: p5 +params: + - name: 'n' + description: | +

number to round up.

+ type: Number +return: + description: rounded up number. + type: Integer +chainable: false +--- + + +# ceil diff --git a/src/content/reference/en/p5 copy/changed.mdx b/src/content/reference/en/p5 copy/changed.mdx new file mode 100644 index 0000000000..45289630e9 --- /dev/null +++ b/src/content/reference/en/p5 copy/changed.mdx @@ -0,0 +1,87 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L330 +title: changed +module: DOM +submodule: DOM +file: src/dom/dom.js +description: | +

Calls a function when the element changes.

+

Calling myElement.changed(false) disables the function.

+line: 330 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let dropdown; + + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a dropdown menu and add a few color options. + dropdown = createSelect(); + dropdown.position(0, 0); + dropdown.option('red'); + dropdown.option('green'); + dropdown.option('blue'); + + // Call paintBackground() when the color option changes. + dropdown.changed(paintBackground); + + describe('A gray square with a dropdown menu at the top. The square changes color when an option is selected.'); + } + + // Paint the background with the selected color. + function paintBackground() { + let c = dropdown.value(); + background(c); + } + +
+ +
+ + let checkbox; + + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a checkbox and place it beneath the canvas. + checkbox = createCheckbox(' circle'); + checkbox.position(0, 100); + + // Call repaint() when the checkbox changes. + checkbox.changed(repaint); + + describe('A gray square with a checkbox underneath it that says "circle". A white circle appears when the box is checked and disappears otherwise.'); + } + + // Paint the background gray and determine whether to draw a circle. + function repaint() { + background(200); + if (checkbox.checked() === true) { + circle(50, 50, 30); + } + } + +
+class: p5 +params: + - name: fxn + description: | +

function to call when the element changes. + false disables the function.

+ type: Function|Boolean +chainable: true +--- + + +# changed diff --git a/src/content/reference/en/p5 copy/char.mdx b/src/content/reference/en/p5 copy/char.mdx new file mode 100644 index 0000000000..e01e22a9f7 --- /dev/null +++ b/src/content/reference/en/p5 copy/char.mdx @@ -0,0 +1,152 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L612 +title: char +module: Data +submodule: Conversion +file: src/utilities/conversion.js +description: > +

Converts a Number or String to a single-character + String.

+ +

char() converts numbers to their single-character string + representations.

+ +

The parameter, n, is the value to convert. If a number is + passed, as in + + char(65), the corresponding single-character string is returned. + If a + + string is passed, as in char('65'), the string is converted to an + integer + + (whole number) and the corresponding single-character string is returned. + + If an array is passed, as in char([65, 66, 67]), an array of + + single-character strings is returned.

+ +

See MDN + + for more information about conversions.

+line: 612 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a number variable. + let original = 65; + + // Convert the number to a char. + let converted = char(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the original and converted values. + text(`${original} : ${converted}`, 50, 50); + + describe('The text "65 : A" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let original = '65'; + + // Convert the string to a char. + let converted = char(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the original and converted values. + text(`${original} : ${converted}`, 50, 50); + + describe('The text "65 : A" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of numbers. + let original = ['65', 66, '67']; + + // Convert the string to a char. + let converted = char(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Iterate over elements of the converted array. + for (let i = 0; i < converted.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 25; + + // Display the original and converted values. + text(`${original[i]} : ${converted[i]}`, 50, y); + } + + describe( + 'The text "65 : A", "66 : B", and "67 : C" written on three separate lines. The text is in black on a gray background.' + ); + } + +
+class: p5 +return: + description: converted single-character string. + type: String +overloads: + - line: 612 + params: + - name: 'n' + description: | +

value to convert.

+ type: String|Number + return: + description: converted single-character string. + type: String + - line: 716 + params: + - name: ns + description: | +

values to convert.

+ type: Array + return: + description: converted single-character strings. + type: 'String[]' +chainable: false +--- + + +# char diff --git a/src/content/reference/en/p5 copy/circle.mdx b/src/content/reference/en/p5 copy/circle.mdx new file mode 100644 index 0000000000..46069bea74 --- /dev/null +++ b/src/content/reference/en/p5 copy/circle.mdx @@ -0,0 +1,77 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L488 +title: circle +module: Shape +submodule: 2D Primitives +file: src/core/shape/2d_primitives.js +description: > +

Draws a circle.

+ +

A circle is a round shape defined by the x, y, + and d parameters. + + x and y set the location of its center. + d sets its width and height (diameter). + + Every point on the circle's edge is the same distance, 0.5 * d, + from its center. + + 0.5 * d (half the diameter) is the circle's radius. + + See ellipseMode() for other ways to + set its position.

+line: 488 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + circle(50, 50, 25); + + describe('A white circle with black outline in the middle of a gray canvas.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + circle(0, 0, 25); + + describe('A white circle with black outline in the middle of a gray canvas.'); + } + +
+class: p5 +params: + - name: x + description: | +

x-coordinate of the center of the circle.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the center of the circle.

+ type: Number + - name: d + description: | +

diameter of the circle.

+ type: Number +chainable: true +--- + + +# circle diff --git a/src/content/reference/en/p5 copy/class.mdx b/src/content/reference/en/p5 copy/class.mdx new file mode 100644 index 0000000000..94b64b75c2 --- /dev/null +++ b/src/content/reference/en/p5 copy/class.mdx @@ -0,0 +1,19 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L1329 +title: class +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: "

A template for creating objects of a particular type.

\n

Classes can make it easier to program with objects. For example, a Frog\nclass could create objects that behave like frogs. Each object created\nusing a class is called an instance of that class. All instances of a class\nare the same type. Here's an example of creating an instance of a Frog\nclass:

\n
let fifi = new Frog(50, 50, 20);\n
\n

The variable fifi refers to an instance of the Frog class. The keyword\nnew is used to call the Frog class' constructor in the statement\nnew Frog(). Altogether, a new Frog object was created and assigned to\nthe variable fifi. Classes are templates, so they can be used to create\nmore than one instance:

\n
// First Frog instance.\nlet frog1 = new Frog(25, 50, 10);\n\n// Second Frog instance.\nlet frog2 = new Frog(75, 50, 10);\n
\n

A simple Frog class could be declared as follows:

\n
class Frog {\n  constructor(x, y, size) {\n    // This code runs once when an instance is created.\n    this.x = x;\n    this.y = y;\n    this.size = size;\n  }\n\n  show() {\n    // This code runs once when myFrog.show() is called.\n    textAlign(CENTER, CENTER);\n    textSize(this.size);\n    text('\U0001F438', this.x, this.y);\n  }\n\n  hop() {\n    // This code runs once when myFrog.hop() is called.\n    this.x += random(-10, 10);\n    this.y += random(-10, 10);\n  }\n}\n
\n

Class declarations begin with the keyword class followed by the class\nname, such as Frog, and curly braces {}. Class names should use\nPascalCase and can't have spaces in their names. For example, naming a\nclass Kermit The Frog with spaces between each word would throw a\nSyntaxError. The code between the curly braces {} defines the class.

\n

Functions that belong to a class are called methods. constructor(),\nshow(), and hop() are methods in the Frog class. Methods define an\nobject's behavior. Methods can accept parameters and return values, just\nlike functions. Note that methods don't use the function keyword.

\n

constructor() is a special method that's called once when an instance of\nthe class is created. The statement new Frog() calls the Frog class'\nconstructor() method.

\n

A class definition is a template for instances. The keyword this refers\nto an instance's data and methods. For example, each Frog instance has\nunique coordinates stored in this.x and this.y. The show() method\nuses those coordinates to draw the frog. The hop() method updates those\ncoordinates when called. Once a Frog instance is created, its data and\nmethods can be accessed using the dot operator . as follows:

\n
// Draw a lily pad.\nfill('green');\nstroke('green');\ncircle(fifi.x, fifi.y, 2 * fifi.size);\n\n// Show the Frog.\nfifi.show();\n\n// Hop.\nfifi.hop();\n
\n" +line: 1329 +isConstructor: false +itemtype: property +example: + - "\n
\n\n// Declare a frog variable.\nlet fifi;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variable a new Frog object.\n fifi = new Frog(50, 50, 20);\n\n describe('A frog face drawn on a blue background.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frog.\n fifi.show();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n}\n\n
\n\n
\n\n// Declare two frog variables.\nlet frog1;\nlet frog2;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variables a new Frog object.\n frog1 = new Frog(25, 50, 10);\n frog2 = new Frog(75, 50, 20);\n\n describe('Two frog faces drawn next to each other on a blue background.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frogs.\n frog1.show();\n frog2.show();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n}\n\n
\n\n
\n\n// Declare two frog variables.\nlet frog1;\nlet frog2;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variables a new Frog object.\n frog1 = new Frog(25, 50, 10);\n frog2 = new Frog(75, 50, 20);\n\n // Slow the frame rate.\n frameRate(1);\n\n describe('Two frog faces on a blue background. The frogs hop around randomly.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frogs.\n frog1.show();\n frog2.show();\n\n // Move the frogs.\n frog1.hop();\n frog2.hop();\n\n // Wrap around if they've hopped off the edge.\n frog1.checkEdges();\n frog2.checkEdges();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n\n hop() {\n this.x += random(-10, 10);\n this.y += random(-10, 10);\n }\n\n checkEdges() {\n if (this.x > width) {\n this.x = this.x - width;\n } else if (this.x < 0) {\n this.x = width - this.x;\n }\n\n if (this.y > height) {\n this.y = this.y - height;\n } else if (this.y < 0) {\n this.y = height - this.y;\n }\n }\n}\n\n
\n\n
\n\n// Create an array that will hold frogs.\nlet frogs = [];\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Add Frog objects to the array.\n for (let i = 0; i < 5; i += 1) {\n // Calculate random coordinates and size.\n let x = random(0, 100);\n let y = random(0, 100);\n let s = random(2, 20);\n\n // Create a new Frog object.\n let frog = new Frog(x, y, s);\n\n // Add the Frog to the array.\n frogs.push(frog);\n }\n\n // Slow the frame rate.\n frameRate(1);\n\n describe(\n 'Five frog faces on a blue background. The frogs hop around randomly.'\n );\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n for (let frog of frogs) {\n // Show the frog.\n frog.show();\n\n // Move the frog.\n frog.hop();\n\n // Wrap around if they've hopped off the edge.\n frog.checkEdges();\n }\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n\n hop() {\n this.x += random(-10, 10);\n this.y += random(-10, 10);\n }\n\n checkEdges() {\n if (this.x > width) {\n this.x = this.x - width;\n } else if (this.x < 0) {\n this.x = width - this.x;\n }\n\n if (this.y > height) {\n this.y = this.y - height;\n } else if (this.y < 0) {\n this.y = height - this.y;\n }\n }\n}\n\n
" +class: p5 +--- + + +# class diff --git a/src/content/reference/en/p5 copy/clear.mdx b/src/content/reference/en/p5 copy/clear.mdx new file mode 100644 index 0000000000..a096184afc --- /dev/null +++ b/src/content/reference/en/p5 copy/clear.mdx @@ -0,0 +1,108 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L673 +title: clear +module: Color +submodule: Setting +file: src/color/setting.js +description: > +

Clears the pixels on the canvas.

+ +

clear() makes every pixel 100% transparent. Calling + clear() doesn't + + clear objects created by createX() functions such as + + createGraphics(), + + createVideo(), and + + createImg(). These objects will remain + + unchanged after calling clear() and can be redrawn.

+ +

In WebGL mode, this function can clear the screen to a specific color. It + + interprets four numeric parameters as normalized RGBA color values. It also + + clears the depth buffer. If you are not using the WebGL renderer, these + + parameters will have no effect.

+line: 673 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + describe('A gray square. White circles are drawn as the user moves the mouse. The circles disappear when the user presses the mouse.'); + } + + function draw() { + circle(mouseX, mouseY, 20); + } + + function mousePressed() { + clear(); + background(200); + } + +
+ +
+ + let pg; + + function setup() { + createCanvas(100, 100); + background(200); + + pg = createGraphics(60, 60); + pg.background(200); + pg.noStroke(); + pg.circle(pg.width / 2, pg.height / 2, 15); + image(pg, 20, 20); + + describe('A white circle drawn on a gray square. The square gets smaller when the mouse is pressed.'); + } + + function mousePressed() { + clear(); + image(pg, 20, 20); + } + +
+class: p5 +params: + - name: r + description: | +

normalized red value.

+ type: Number + optional: true + - name: g + description: | +

normalized green value.

+ type: Number + optional: true + - name: b + description: | +

normalized blue value.

+ type: Number + optional: true + - name: a + description: | +

normalized alpha value.

+ type: Number + optional: true +chainable: true +--- + + +# clear diff --git a/src/content/reference/en/p5 copy/clearDepth.mdx b/src/content/reference/en/p5 copy/clearDepth.mdx new file mode 100644 index 0000000000..25425d1920 --- /dev/null +++ b/src/content/reference/en/p5 copy/clearDepth.mdx @@ -0,0 +1,113 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L635 +title: clearDepth +module: Rendering +submodule: Rendering +file: src/core/rendering.js +description: > +

Clears the depth buffer in WebGL mode.

+ +

clearDepth() clears information about how far objects are from + the camera + + in 3D space. This information is stored in an object called the + + depth buffer. Clearing the depth buffer ensures new objects aren't + drawn + + behind old ones. Doing so can be useful for feedback effects in which the + + previous frame serves as the background for the current frame.

+ +

The parameter, depth, is optional. If a number is passed, as + in + + clearDepth(0.5), it determines the range of objects to clear from + the + + depth buffer. 0 doesn't clear any depth information, 0.5 clears depth + + information halfway between the near and far clipping planes, and 1 clears + + depth information all the way to the far clipping plane. By default, + + depth is 1.

+ +

Note: clearDepth() can only be used in WebGL mode.

+line: 635 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let previous; + let current; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the p5.Framebuffer objects. + previous = createFramebuffer({ format: FLOAT }); + current = createFramebuffer({ format: FLOAT }); + + describe( + 'A multicolor box drifts from side to side on a white background. It leaves a trail that fades over time.' + ); + } + + function draw() { + // Swap the previous p5.Framebuffer and the + // current one so it can be used as a texture. + [previous, current] = [current, previous]; + + // Start drawing to the current p5.Framebuffer. + current.begin(); + + // Paint the background. + background(255); + + // Draw the previous p5.Framebuffer. + // Clear the depth buffer so the previous + // frame doesn't block the current one. + push(); + tint(255, 250); + image(previous, -50, -50); + clearDepth(); + pop(); + + // Draw the box on top of the previous frame. + push(); + let x = 25 * sin(frameCount * 0.01); + let y = 25 * sin(frameCount * 0.02); + translate(x, y, 0); + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + normalMaterial(); + box(12); + pop(); + + // Stop drawing to the current p5.Framebuffer. + current.end(); + + // Display the current p5.Framebuffer. + image(current, -50, -50); + } + +
+class: p5 +params: + - name: depth + description: | +

amount of the depth buffer to clear between 0 + (none) and 1 (far clipping plane). Defaults to 1.

+ type: Number + optional: true +chainable: false +--- + + +# clearDepth diff --git a/src/content/reference/en/p5 copy/clearStorage.mdx b/src/content/reference/en/p5 copy/clearStorage.mdx new file mode 100644 index 0000000000..d2c89e63bf --- /dev/null +++ b/src/content/reference/en/p5 copy/clearStorage.mdx @@ -0,0 +1,81 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/data/local_storage.js#L313 +title: clearStorage +module: Data +submodule: LocalStorage +file: src/data/local_storage.js +description: > +

Removes all items in the web browser's local storage.

+ +

Web browsers can save small amounts of data using the built-in + + localStorage object. + + Data stored in localStorage can be retrieved at any point, even + after + + refreshing a page or restarting the browser. Data are stored as key-value + + pairs. Calling clearStorage() removes all data from + localStorage.

+ +

Note: Sensitive data such as passwords or personal information shouldn't be + + stored in localStorage.

+line: 313 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Double-click to clear localStorage. + + function setup() { + createCanvas(100, 100); + + // Store the player's name. + storeItem('name', 'Feist'); + + // Store the player's score. + storeItem('score', 1234); + + describe( + 'The text "Feist: 1234" written in black on a gray background. The text "null: null" appears when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(14); + + // Retrieve the name. + let name = getItem('name'); + + // Retrieve the score. + let score = getItem('score'); + + // Display the score. + text(`${name}: ${score}`, 50, 50); + } + + // Clear localStorage when the user double-clicks. + function doubleClicked() { + clearStorage(); + } + +
+class: p5 +chainable: false +--- + + +# clearStorage diff --git a/src/content/reference/en/p5 copy/clip.mdx b/src/content/reference/en/p5 copy/clip.mdx new file mode 100644 index 0000000000..ae72687f03 --- /dev/null +++ b/src/content/reference/en/p5 copy/clip.mdx @@ -0,0 +1,225 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L222 +title: clip +module: Color +submodule: Setting +file: src/color/setting.js +description: > +

Defines a shape that will mask any shapes drawn afterward.

+ +

The first parameter, callback, is a function that defines the + mask. + + Any shapes drawn in callback will add to the mask shape. The + mask + + will apply to anything drawn after clip() is called.

+ +

The second parameter, options, is optional. If an object with + an invert + + property is passed, as in beginClip({ invert: true }), it will be + used to + + set the masking mode. { invert: true } inverts the mask, creating + holes + + in shapes that are masked. invert is false by + default.

+ +

Masks can be contained between the + + push() and pop() functions. + + Doing so allows unmasked shapes to be drawn after masked shapes.

+ +

Masks can also be defined with beginClip() + + and endClip().

+line: 222 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a mask. + clip(mask); + + // Draw a backing shape. + square(5, 5, 45); + + describe('A white triangle and circle on a gray background.'); + } + + // Declare a function that defines the mask. + function mask() { + triangle(15, 37, 30, 13, 43, 37); + circle(45, 45, 7); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an inverted mask. + clip(mask, { invert: true }); + + // Draw a backing shape. + square(5, 5, 45); + + describe('A white square at the top-left corner of a gray square. The white square has a triangle and a circle cut out of it.'); + } + + // Declare a function that defines the mask. + function mask() { + triangle(15, 37, 30, 13, 43, 37); + circle(45, 45, 7); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + noStroke(); + + // Draw a masked shape. + push(); + // Create a mask. + clip(mask); + + // Draw a backing shape. + square(5, 5, 45); + pop(); + + // Translate the origin to the center. + translate(50, 50); + + // Draw an inverted masked shape. + push(); + // Create an inverted mask. + clip(mask, { invert: true }); + + // Draw a backing shape. + square(5, 5, 45); + pop(); + + describe('In the top left, a white triangle and circle. In the bottom right, a white square with a triangle and circle cut out of it.'); + } + + // Declare a function that defines the mask. + function mask() { + triangle(15, 37, 30, 13, 43, 37); + circle(45, 45, 7); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A silhouette of a rotating torus colored fuchsia.'); + } + + function draw() { + background(200); + + // Create a mask. + clip(mask); + + // Draw a backing shape. + noStroke(); + fill('fuchsia'); + plane(100); + } + + // Declare a function that defines the mask. + function mask() { + push(); + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + scale(0.5); + torus(30, 15); + pop(); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A silhouette of a rotating torus colored with a gradient from cyan to purple.'); + } + + function draw() { + background(200); + + // Create a mask. + clip(mask); + + // Draw a backing shape. + noStroke(); + beginShape(QUAD_STRIP); + fill(0, 255, 255); + vertex(-width / 2, -height / 2); + vertex(width / 2, -height / 2); + fill(100, 0, 100); + vertex(-width / 2, height / 2); + vertex(width / 2, height / 2); + endShape(); + } + + // Declare a function that defines the mask. + function mask() { + push(); + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + scale(0.5); + torus(30, 15); + pop(); + } + +
+class: p5 +params: + - name: callback + description: | +

a function that draws the mask shape.

+ type: Function + - name: options + description: | +

an object containing clip settings.

+ type: Object + optional: true +chainable: false +--- + + +# clip diff --git a/src/content/reference/en/p5 copy/color.mdx b/src/content/reference/en/p5 copy/color.mdx new file mode 100644 index 0000000000..ad2bdbd8da --- /dev/null +++ b/src/content/reference/en/p5 copy/color.mdx @@ -0,0 +1,349 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L398 +title: color +module: Color +submodule: Creating & Reading +file: src/color/creating_reading.js +description: > +

Creates a p5.Color object.

+ +

By default, the parameters are interpreted as RGB values. Calling + + color(255, 204, 0) will return a bright yellow color. The way + these + + parameters are interpreted may be changed with the + + colorMode() function.

+ +

The version of color() with one parameter interprets the value + one of two + + ways. If the parameter is a number, it's interpreted as a grayscale value. + + If the parameter is a string, it's interpreted as a CSS color string.

+ +

The version of color() with two parameters interprets the + first one as a + + grayscale value. The second parameter sets the alpha (transparency) value.

+ +

The version of color() with three parameters interprets them + as RGB, HSB, + + or HSL colors, depending on the current colorMode().

+ +

The version of color() with four parameters interprets them as + RGBA, HSBA, + + or HSLA colors, depending on the current colorMode(). The last + parameter + + sets the alpha (transparency) value.

+line: 398 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object using RGB values. + let c = color(255, 204, 0); + + // Draw the square. + fill(c); + noStroke(); + square(30, 20, 55); + + describe('A yellow square on a gray canvas.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object using RGB values. + let c1 = color(255, 204, 0); + + // Draw the left circle. + fill(c1); + noStroke(); + circle(25, 25, 80); + + // Create a p5.Color object using a grayscale value. + let c2 = color(65); + + // Draw the right circle. + fill(c2); + circle(75, 75, 80); + + describe( + 'Two circles on a gray canvas. The circle in the top-left corner is yellow and the one at the bottom-right is gray.' + ); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object using a named color. + let c = color('magenta'); + + // Draw the square. + fill(c); + noStroke(); + square(20, 20, 60); + + describe('A magenta square on a gray canvas.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object using a hex color code. + let c1 = color('#0f0'); + + // Draw the left rectangle. + fill(c1); + noStroke(); + rect(0, 10, 45, 80); + + // Create a p5.Color object using a hex color code. + let c2 = color('#00ff00'); + + // Draw the right rectangle. + fill(c2); + rect(55, 10, 45, 80); + + describe('Two bright green rectangles on a gray canvas.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object using a RGB color string. + let c1 = color('rgb(0, 0, 255)'); + + // Draw the top-left square. + fill(c1); + square(10, 10, 35); + + // Create a p5.Color object using a RGB color string. + let c2 = color('rgb(0%, 0%, 100%)'); + + // Draw the top-right square. + fill(c2); + square(55, 10, 35); + + // Create a p5.Color object using a RGBA color string. + let c3 = color('rgba(0, 0, 255, 1)'); + + // Draw the bottom-left square. + fill(c3); + square(10, 55, 35); + + // Create a p5.Color object using a RGBA color string. + let c4 = color('rgba(0%, 0%, 100%, 1)'); + + // Draw the bottom-right square. + fill(c4); + square(55, 55, 35); + + describe('Four blue squares in the corners of a gray canvas.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object using a HSL color string. + let c1 = color('hsl(160, 100%, 50%)'); + + // Draw the left rectangle. + noStroke(); + fill(c1); + rect(0, 10, 45, 80); + + // Create a p5.Color object using a HSLA color string. + let c2 = color('hsla(160, 100%, 50%, 0.5)'); + + // Draw the right rectangle. + fill(c2); + rect(55, 10, 45, 80); + + describe('Two sea green rectangles. A darker rectangle on the left and a brighter one on the right.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object using a HSB color string. + let c1 = color('hsb(160, 100%, 50%)'); + + // Draw the left rectangle. + noStroke(); + fill(c1); + rect(0, 10, 45, 80); + + // Create a p5.Color object using a HSBA color string. + let c2 = color('hsba(160, 100%, 50%, 0.5)'); + + // Draw the right rectangle. + fill(c2); + rect(55, 10, 45, 80); + + describe('Two green rectangles. A darker rectangle on the left and a brighter one on the right.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object using RGB values. + let c1 = color(50, 55, 100); + + // Draw the left rectangle. + fill(c1); + rect(0, 10, 45, 80); + + // Switch the color mode to HSB. + colorMode(HSB, 100); + + // Create a p5.Color object using HSB values. + let c2 = color(50, 55, 100); + + // Draw the right rectangle. + fill(c2); + rect(55, 10, 45, 80); + + describe('Two blue rectangles. A darker rectangle on the left and a brighter one on the right.'); + } + +
+class: p5 +return: + description: resulting color. + type: p5.Color +overloads: + - line: 398 + params: + - name: gray + description: | +

number specifying value between white and black.

+ type: Number + - name: alpha + description: | +

alpha value relative to current color range + (default is 0-255).

+ type: Number + optional: true + return: + description: resulting color. + type: p5.Color + - line: 652 + params: + - name: v1 + description: | +

red or hue value relative to + the current color range.

+ type: Number + - name: v2 + description: | +

green or saturation value + relative to the current color range.

+ type: Number + - name: v3 + description: | +

blue or brightness value + relative to the current color range.

+ type: Number + - name: alpha + description: '' + type: Number + optional: true + return: + description: '' + type: p5.Color + - line: 664 + params: + - name: value + description: | +

a color string.

+ type: String + return: + description: '' + type: p5.Color + - line: 670 + params: + - name: values + description: | +

an array containing the red, green, blue, + and alpha components of the color.

+ type: 'Number[]' + return: + description: '' + type: p5.Color + - line: 677 + params: + - name: color + description: '' + type: p5.Color + return: + description: '' + type: p5.Color +chainable: false +--- + + +# color diff --git a/src/content/reference/en/p5 copy/colorMode.mdx b/src/content/reference/en/p5 copy/colorMode.mdx new file mode 100644 index 0000000000..b4aca3c9ce --- /dev/null +++ b/src/content/reference/en/p5 copy/colorMode.mdx @@ -0,0 +1,271 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L751 +title: colorMode +module: Color +submodule: Setting +file: src/color/setting.js +description: > +

Changes the way color values are interpreted.

+ +

By default, the Number parameters for fill(), + + stroke(), + + background(), and + + color() are defined by values between 0 and + 255 + + using the RGB color model. This is equivalent to calling + + colorMode(RGB, 255). Pure red is color(255, 0, 0) in + this model.

+ +

Calling colorMode(RGB, 100) sets colors to use RGB color + values + + between 0 and 100. Pure red is color(100, 0, 0) in this + model.

+ +

Calling colorMode(HSB) or colorMode(HSL) changes + to HSB or HSL system + + instead of RGB. Pure red is color(0, 100, 100) in HSB and + + color(0, 100, 50) in HSL.

+ +

p5.Color objects remember the mode + that they were + + created in. Changing modes doesn't affect their appearance.

+line: 751 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Fill with pure red. + fill(255, 0, 0); + + circle(50, 50, 25); + + describe('A gray square with a red circle at its center.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use RGB color with values in the range 0-100. + colorMode(RGB, 100); + + // Fill with pure red. + fill(100, 0, 0); + + circle(50, 50, 25); + + describe('A gray square with a red circle at its center.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use HSB color. + colorMode(HSB); + + // Fill with pure red. + fill(0, 100, 100); + + circle(50, 50, 25); + + describe('A gray square with a red circle at its center.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use HSL color. + colorMode(HSL); + + // Fill with pure red. + fill(0, 100, 50); + + circle(50, 50, 25); + + describe('A gray square with a red circle at its center.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Use RGB color with values in the range 0-100. + colorMode(RGB, 100); + + for (let x = 0; x < 100; x += 1) { + for (let y = 0; y < 100; y += 1) { + stroke(x, y, 0); + point(x, y); + } + } + + describe( + 'A diagonal green to red gradient from bottom-left to top-right with shading transitioning to black at top-left corner.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Use HSB color with values in the range 0-100. + colorMode(HSB, 100); + + for (let x = 0; x < 100; x += 1) { + for (let y = 0; y < 100; y += 1) { + stroke(x, y, 100); + point(x, y); + } + } + + describe('A rainbow gradient from left-to-right. Brightness transitions to white at the top.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Create a p5.Color object. + let myColor = color(180, 175, 230); + background(myColor); + + // Use RGB color with values in the range 0-1. + colorMode(RGB, 1); + + // Get the red, green, and blue color components. + let redValue = red(myColor); + let greenValue = green(myColor); + let blueValue = blue(myColor); + + // Round the color components for display. + redValue = round(redValue, 2); + greenValue = round(greenValue, 2); + blueValue = round(blueValue, 2); + + // Display the color components. + text(`Red: ${redValue}`, 10, 10, 80, 80); + text(`Green: ${greenValue}`, 10, 40, 80, 80); + text(`Blue: ${blueValue}`, 10, 70, 80, 80); + + describe('A purple canvas with the red, green, and blue decimal values of the color written on it.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(255); + + // Use RGB color with alpha values in the range 0-1. + colorMode(RGB, 255, 255, 255, 1); + + noFill(); + strokeWeight(4); + stroke(255, 0, 10, 0.3); + circle(40, 40, 50); + circle(50, 60, 50); + + describe('Two overlapping translucent pink circle outlines.'); + } + +
+class: p5 +overloads: + - line: 751 + params: + - name: mode + description: | +

either RGB, HSB or HSL, corresponding to + Red/Green/Blue and Hue/Saturation/Brightness + (or Lightness).

+ type: Constant + - name: max + description: | +

range for all values.

+ type: Number + optional: true + chainable: 1 + - line: 956 + params: + - name: mode + description: '' + type: Constant + - name: max1 + description: | +

range for the red or hue depending on the + current color mode.

+ type: Number + - name: max2 + description: | +

range for the green or saturation depending + on the current color mode.

+ type: Number + - name: max3 + description: | +

range for the blue or brightness/lightness + depending on the current color mode.

+ type: Number + - name: maxA + description: | +

range for the alpha.

+ type: Number + optional: true + chainable: 1 +chainable: true +--- + + +# colorMode diff --git a/src/content/reference/en/p5 copy/concat.mdx b/src/content/reference/en/p5 copy/concat.mdx new file mode 100644 index 0000000000..1e83bf84c0 --- /dev/null +++ b/src/content/reference/en/p5 copy/concat.mdx @@ -0,0 +1,54 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L112 +title: concat +module: Data +submodule: Array Functions +file: src/utilities/array_functions.js +description: | +

Concatenates two arrays, maps to Array.concat(). Does not modify the + input arrays.

+line: 112 +deprecated: >- + Use arr1.concat(arr2) + instead. +isConstructor: false +itemtype: method +example: + - |- + +
+ function setup() { + let arr1 = ['A', 'B', 'C']; + let arr2 = [1, 2, 3]; + + print(arr1); // ['A','B','C'] + print(arr2); // [1,2,3] + + let arr3 = concat(arr1, arr2); + + print(arr1); // ['A','B','C'] + print(arr2); // [1, 2, 3] + print(arr3); // ['A','B','C', 1, 2, 3] + } +
+class: p5 +params: + - name: a + description: | +

first Array to concatenate

+ type: Array + - name: b + description: | +

second Array to concatenate

+ type: Array +return: + description: concatenated array + type: Array +chainable: false +--- + + +# concat diff --git a/src/content/reference/en/p5 copy/cone.mdx b/src/content/reference/en/p5 copy/cone.mdx new file mode 100644 index 0000000000..ff0756d0a5 --- /dev/null +++ b/src/content/reference/en/p5 copy/cone.mdx @@ -0,0 +1,265 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L1730 +title: cone +module: Shape +submodule: 3D Primitives +file: src/webgl/3d_primitives.js +description: > +

Draws a cone.

+ +

A cone is a 3D shape with triangular faces that connect a flat bottom to a + + single point. Cones with few faces look like pyramids. Cones with many + + faces have smooth surfaces.

+ +

The first parameter, radius, is optional. If a + Number is passed, as in + + cone(20), it sets the radius of the cone’s base. By default, + radius is + + 50.

+ +

The second parameter, height, is also optional. If a + Number is passed, + + as in cone(20, 30), it sets the cone’s height. By default, + height is + + set to the cone’s radius.

+ +

The third parameter, detailX, is also optional. If a + Number is passed, + + as in cone(20, 30, 5), it sets the number of edges used to form + the + + cone's base. Using more edges makes the base look more like a circle. By + + default, detailX is 24.

+ +

The fourth parameter, detailY, is also optional. If a + Number is passed, + + as in cone(20, 30, 5, 7), it sets the number of triangle + subdivisions to + + use along the y-axis connecting the base to the tip. All 3D shapes are made + + by connecting triangles to form their surfaces. By default, + detailY is 1.

+ +

The fifth parameter, cap, is also optional. If a + false is passed, as + + in cone(20, 30, 5, 7, false) the cone’s base won’t be drawn. By + default, + + cap is true.

+ +

Note: cone() can only be used in WebGL mode.

+line: 1730 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cone on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cone. + cone(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cone on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cone. + // Set its radius and height to 30. + cone(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cone on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cone. + // Set its radius to 30 and height to 50. + cone(30, 50); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cone on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cone. + // Set its radius to 30 and height to 50. + // Set its detailX to 5. + cone(30, 50, 5); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white pyramid on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cone. + // Set its radius to 30 and height to 50. + // Set its detailX to 5. + cone(30, 50, 5); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cone on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cone. + // Set its radius to 30 and height to 50. + // Set its detailX to 24 and detailY to 2. + cone(30, 50, 24, 2); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cone on a gray background. Its base is missing.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cone. + // Set its radius to 30 and height to 50. + // Set its detailX to 24 and detailY to 1. + // Don't draw its base. + cone(30, 50, 24, 1, false); + } + +
+class: p5 +params: + - name: radius + description: | +

radius of the cone's base. Defaults to 50.

+ type: Number + optional: true + - name: height + description: | +

height of the cone. Defaults to the value of radius.

+ type: Number + optional: true + - name: detailX + description: | +

number of edges used to draw the base. Defaults to 24.

+ type: Integer + optional: true + - name: detailY + description: | +

number of triangle subdivisions along the y-axis. Defaults to 1.

+ type: Integer + optional: true + - name: cap + description: | +

whether to draw the cone's base. Defaults to true.

+ type: Boolean + optional: true +chainable: true +--- + + +# cone diff --git a/src/content/reference/en/p5 copy/console.mdx b/src/content/reference/en/p5 copy/console.mdx new file mode 100644 index 0000000000..411b08357e --- /dev/null +++ b/src/content/reference/en/p5 copy/console.mdx @@ -0,0 +1,99 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L1988 +title: console +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: > +

Prints a message to the web browser's console.

+ +

The console + + object is helpful for printing messages while debugging. For example, it's + + common to add a console.log() statement while studying how a + section of + + code works:

+ +
if (isPlaying === true) {
+    // Add a console.log() statement to make sure this block of code runs.
+    console.log('Got here!');
+
+    // Game logic.
+  }
+
+  
+ +

console.error() is helpful for tracking errors because it + prints + + formatted messages. For example, it's common to encounter errors when + + loading media assets:

+ +
// Logs an error message with special
+  formatting.
+
+  function handleFailure(error) {
+    console.error('Oops!', error);
+  }
+
+
+  // Try to load an image and call handleError() if it fails.
+
+  loadImage('https://example.com/cat.jpg', handleImage, handleError);
+
+  
+line: 1988 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + noCanvas(); + + // Prints "Hello!" to the console. + console.log('Hello!'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Try to load an image from a fake URL. + // Call handleError() if the image fails to load. + loadImage('https://example.com/cat.jpg', handleImage, handleError); + } + + // Displays the image. + function handleImage(img) { + image(img, 0, 0); + + describe('A cat on a gray background.'); + } + + // Prints the error. + function handleError(error) { + console.error('Oops!', error); + + describe('A gray square.'); + } + +
+class: p5 +--- + + +# console diff --git a/src/content/reference/en/p5 copy/constants/ADD.mdx b/src/content/reference/en/p5 copy/constants/ADD.mdx new file mode 100644 index 0000000000..9148f688e9 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/ADD.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L905 +title: ADD +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 905 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# ADD diff --git a/src/content/reference/en/p5 copy/constants/ALT.mdx b/src/content/reference/en/p5 copy/constants/ALT.mdx new file mode 100644 index 0000000000..a039e3919b --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/ALT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L820 +title: ALT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 820 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# ALT diff --git a/src/content/reference/en/p5 copy/constants/ARROW.mdx b/src/content/reference/en/p5 copy/constants/ARROW.mdx new file mode 100644 index 0000000000..d2a0e065a1 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/ARROW.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L55 +title: ARROW +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 55 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# ARROW diff --git a/src/content/reference/en/p5 copy/constants/AUTO.mdx b/src/content/reference/en/p5 copy/constants/AUTO.mdx new file mode 100644 index 0000000000..185fb15902 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/AUTO.mdx @@ -0,0 +1,25 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L810 +title: AUTO +module: Constants +submodule: Constants +file: src/core/constants.js +description: > +

AUTO allows us to automatically set the width or height of an element (but + not both), + + based on the current height and width of the element. Only one parameter can + + be passed to the size function as + AUTO, at a time.

+line: 810 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# AUTO diff --git a/src/content/reference/en/p5 copy/constants/AXES.mdx b/src/content/reference/en/p5 copy/constants/AXES.mdx new file mode 100644 index 0000000000..c6f60b6b89 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/AXES.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1171 +title: AXES +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1171 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# AXES diff --git a/src/content/reference/en/p5 copy/constants/BACKSPACE.mdx b/src/content/reference/en/p5 copy/constants/BACKSPACE.mdx new file mode 100644 index 0000000000..ee299ffcff --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/BACKSPACE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L826 +title: BACKSPACE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 826 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# BACKSPACE diff --git a/src/content/reference/en/p5 copy/constants/BASELINE.mdx b/src/content/reference/en/p5 copy/constants/BASELINE.mdx new file mode 100644 index 0000000000..200aa201ec --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/BASELINE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L675 +title: BASELINE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 675 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# BASELINE diff --git a/src/content/reference/en/p5 copy/constants/BEVEL.mdx b/src/content/reference/en/p5 copy/constants/BEVEL.mdx new file mode 100644 index 0000000000..a4af3693f7 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/BEVEL.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L777 +title: BEVEL +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 777 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# BEVEL diff --git a/src/content/reference/en/p5 copy/constants/BEZIER.mdx b/src/content/reference/en/p5 copy/constants/BEZIER.mdx new file mode 100644 index 0000000000..b2993b2c33 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/BEZIER.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1073 +title: BEZIER +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1073 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# BEZIER diff --git a/src/content/reference/en/p5 copy/constants/BLEND.mdx b/src/content/reference/en/p5 copy/constants/BLEND.mdx new file mode 100644 index 0000000000..bf367f05eb --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/BLEND.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L893 +title: BLEND +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 893 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# BLEND diff --git a/src/content/reference/en/p5 copy/constants/BLUR.mdx b/src/content/reference/en/p5 copy/constants/BLUR.mdx new file mode 100644 index 0000000000..5580994e74 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/BLUR.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1019 +title: BLUR +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1019 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# BLUR diff --git a/src/content/reference/en/p5 copy/constants/BOLD.mdx b/src/content/reference/en/p5 copy/constants/BOLD.mdx new file mode 100644 index 0000000000..6069c955e8 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/BOLD.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1036 +title: BOLD +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1036 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# BOLD diff --git a/src/content/reference/en/p5 copy/constants/BOLDITALIC.mdx b/src/content/reference/en/p5 copy/constants/BOLDITALIC.mdx new file mode 100644 index 0000000000..2967579a9c --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/BOLDITALIC.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1041 +title: BOLDITALIC +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1041 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# BOLDITALIC diff --git a/src/content/reference/en/p5 copy/constants/BOTTOM.mdx b/src/content/reference/en/p5 copy/constants/BOTTOM.mdx new file mode 100644 index 0000000000..b01ded11ea --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/BOTTOM.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L670 +title: BOTTOM +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 670 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# BOTTOM diff --git a/src/content/reference/en/p5 copy/constants/BURN.mdx b/src/content/reference/en/p5 copy/constants/BURN.mdx new file mode 100644 index 0000000000..7ba3764dac --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/BURN.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L976 +title: BURN +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 976 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# BURN diff --git a/src/content/reference/en/p5 copy/constants/CENTER.mdx b/src/content/reference/en/p5 copy/constants/CENTER.mdx new file mode 100644 index 0000000000..cab0205cef --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/CENTER.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L660 +title: CENTER +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 660 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# CENTER diff --git a/src/content/reference/en/p5 copy/constants/CHAR.mdx b/src/content/reference/en/p5 copy/constants/CHAR.mdx new file mode 100644 index 0000000000..564855787a --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/CHAR.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1046 +title: CHAR +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1046 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# CHAR diff --git a/src/content/reference/en/p5 copy/constants/CHORD.mdx b/src/content/reference/en/p5 copy/constants/CHORD.mdx new file mode 100644 index 0000000000..40896bb3a1 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/CHORD.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L750 +title: CHORD +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 750 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# CHORD diff --git a/src/content/reference/en/p5 copy/constants/CLAMP.mdx b/src/content/reference/en/p5 copy/constants/CLAMP.mdx new file mode 100644 index 0000000000..977b02599d --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/CLAMP.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1126 +title: CLAMP +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1126 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# CLAMP diff --git a/src/content/reference/en/p5 copy/constants/CLOSE.mdx b/src/content/reference/en/p5 copy/constants/CLOSE.mdx new file mode 100644 index 0000000000..34bc946fe5 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/CLOSE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L740 +title: CLOSE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 740 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# CLOSE diff --git a/src/content/reference/en/p5 copy/constants/CONTAIN.mdx b/src/content/reference/en/p5 copy/constants/CONTAIN.mdx new file mode 100644 index 0000000000..59d56be350 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/CONTAIN.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1188 +title: CONTAIN +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1188 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# CONTAIN diff --git a/src/content/reference/en/p5 copy/constants/CONTROL.mdx b/src/content/reference/en/p5 copy/constants/CONTROL.mdx new file mode 100644 index 0000000000..d620bb502d --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/CONTROL.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L831 +title: CONTROL +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 831 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# CONTROL diff --git a/src/content/reference/en/p5 copy/constants/CORNER.mdx b/src/content/reference/en/p5 copy/constants/CORNER.mdx new file mode 100644 index 0000000000..e8b5eced3e --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/CORNER.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L635 +title: CORNER +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 635 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# CORNER diff --git a/src/content/reference/en/p5 copy/constants/CORNERS.mdx b/src/content/reference/en/p5 copy/constants/CORNERS.mdx new file mode 100644 index 0000000000..85e4226b1e --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/CORNERS.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L640 +title: CORNERS +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 640 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# CORNERS diff --git a/src/content/reference/en/p5 copy/constants/COVER.mdx b/src/content/reference/en/p5 copy/constants/COVER.mdx new file mode 100644 index 0000000000..3714b4bec3 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/COVER.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1194 +title: COVER +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1194 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# COVER diff --git a/src/content/reference/en/p5 copy/constants/CROSS.mdx b/src/content/reference/en/p5 copy/constants/CROSS.mdx new file mode 100644 index 0000000000..eba1238e34 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/CROSS.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L60 +title: CROSS +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 60 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# CROSS diff --git a/src/content/reference/en/p5 copy/constants/CURVE.mdx b/src/content/reference/en/p5 copy/constants/CURVE.mdx new file mode 100644 index 0000000000..3e46bf2151 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/CURVE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1078 +title: CURVE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1078 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# CURVE diff --git a/src/content/reference/en/p5 copy/constants/DARKEST.mdx b/src/content/reference/en/p5 copy/constants/DARKEST.mdx new file mode 100644 index 0000000000..b86d06dec4 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/DARKEST.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L913 +title: DARKEST +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 913 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# DARKEST diff --git a/src/content/reference/en/p5 copy/constants/DEGREES.mdx b/src/content/reference/en/p5 copy/constants/DEGREES.mdx new file mode 100644 index 0000000000..c259f456ad --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/DEGREES.mdx @@ -0,0 +1,59 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L547 +title: DEGREES +module: Constants +submodule: Constants +file: src/core/constants.js +description: > +

A String constant that's used to set the + + angleMode().

+ +

By default, functions such as rotate() + and + + sin() expect angles measured in units of + radians. + + Calling angleMode(DEGREES) ensures that angles are measured in + units of + + degrees.

+ +

Note: TWO_PI radians equals 360˚.

+line: 547 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw a red arc from 0 to HALF_PI radians. + fill(255, 0, 0); + arc(50, 50, 80, 80, 0, HALF_PI); + + // Use degrees. + angleMode(DEGREES); + + // Draw a blue arc from 90˚ to 180˚. + fill(0, 0, 255); + arc(50, 50, 80, 80, 90, 180); + + describe('The bottom half of a circle drawn on a gray background. The bottom-right quarter is red. The bottom-left quarter is blue.'); + } + +
+class: p5 +type: String +--- + + +# DEGREES diff --git a/src/content/reference/en/p5 copy/constants/DELETE.mdx b/src/content/reference/en/p5 copy/constants/DELETE.mdx new file mode 100644 index 0000000000..3bef8a3983 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/DELETE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L836 +title: DELETE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 836 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# DELETE diff --git a/src/content/reference/en/p5 copy/constants/DIFFERENCE.mdx b/src/content/reference/en/p5 copy/constants/DIFFERENCE.mdx new file mode 100644 index 0000000000..27d7e0880c --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/DIFFERENCE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L924 +title: DIFFERENCE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 924 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# DIFFERENCE diff --git a/src/content/reference/en/p5 copy/constants/DILATE.mdx b/src/content/reference/en/p5 copy/constants/DILATE.mdx new file mode 100644 index 0000000000..5eca5b06dd --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/DILATE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1009 +title: DILATE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1009 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# DILATE diff --git a/src/content/reference/en/p5 copy/constants/DODGE.mdx b/src/content/reference/en/p5 copy/constants/DODGE.mdx new file mode 100644 index 0000000000..ba1594bfe4 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/DODGE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L970 +title: DODGE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 970 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# DODGE diff --git a/src/content/reference/en/p5 copy/constants/DOWN_ARROW.mdx b/src/content/reference/en/p5 copy/constants/DOWN_ARROW.mdx new file mode 100644 index 0000000000..c1d80ae679 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/DOWN_ARROW.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L841 +title: DOWN_ARROW +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 841 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# DOWN\_ARROW diff --git a/src/content/reference/en/p5 copy/constants/ENTER.mdx b/src/content/reference/en/p5 copy/constants/ENTER.mdx new file mode 100644 index 0000000000..0ded2aec7f --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/ENTER.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L846 +title: ENTER +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 846 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# ENTER diff --git a/src/content/reference/en/p5 copy/constants/ERODE.mdx b/src/content/reference/en/p5 copy/constants/ERODE.mdx new file mode 100644 index 0000000000..9dba021043 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/ERODE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1014 +title: ERODE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1014 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# ERODE diff --git a/src/content/reference/en/p5 copy/constants/ESCAPE.mdx b/src/content/reference/en/p5 copy/constants/ESCAPE.mdx new file mode 100644 index 0000000000..53256ed7ce --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/ESCAPE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L851 +title: ESCAPE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 851 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# ESCAPE diff --git a/src/content/reference/en/p5 copy/constants/EXCLUSION.mdx b/src/content/reference/en/p5 copy/constants/EXCLUSION.mdx new file mode 100644 index 0000000000..61c3572125 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/EXCLUSION.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L934 +title: EXCLUSION +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 934 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# EXCLUSION diff --git a/src/content/reference/en/p5 copy/constants/FALLBACK.mdx b/src/content/reference/en/p5 copy/constants/FALLBACK.mdx new file mode 100644 index 0000000000..6c9f4ec37c --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/FALLBACK.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1182 +title: FALLBACK +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1182 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# FALLBACK diff --git a/src/content/reference/en/p5 copy/constants/FILL.mdx b/src/content/reference/en/p5 copy/constants/FILL.mdx new file mode 100644 index 0000000000..9e2ca1ce96 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/FILL.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1090 +title: FILL +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1090 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# FILL diff --git a/src/content/reference/en/p5 copy/constants/FLAT.mdx b/src/content/reference/en/p5 copy/constants/FLAT.mdx new file mode 100644 index 0000000000..50d8b95b1e --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/FLAT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1138 +title: FLAT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1138 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# FLAT diff --git a/src/content/reference/en/p5 copy/constants/FLOAT.mdx b/src/content/reference/en/p5 copy/constants/FLOAT.mdx new file mode 100644 index 0000000000..b063ffc631 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/FLOAT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1212 +title: FLOAT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1212 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# FLOAT diff --git a/src/content/reference/en/p5 copy/constants/GRAY.mdx b/src/content/reference/en/p5 copy/constants/GRAY.mdx new file mode 100644 index 0000000000..ca8a56d090 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/GRAY.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L989 +title: GRAY +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 989 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# GRAY diff --git a/src/content/reference/en/p5 copy/constants/GRID.mdx b/src/content/reference/en/p5 copy/constants/GRID.mdx new file mode 100644 index 0000000000..683bbf43f9 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/GRID.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1165 +title: GRID +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1165 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# GRID diff --git a/src/content/reference/en/p5 copy/constants/HALF_FLOAT.mdx b/src/content/reference/en/p5 copy/constants/HALF_FLOAT.mdx new file mode 100644 index 0000000000..a70c409626 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/HALF_FLOAT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1218 +title: HALF_FLOAT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1218 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# HALF\_FLOAT diff --git a/src/content/reference/en/p5 copy/constants/HALF_PI.mdx b/src/content/reference/en/p5 copy/constants/HALF_PI.mdx new file mode 100644 index 0000000000..212458ee9e --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/HALF_PI.mdx @@ -0,0 +1,109 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L88 +title: HALF_PI +module: Constants +submodule: Constants +file: src/core/constants.js +description: > +

A Number constant that's approximately 1.5708.

+ +

HALF_PI is half the value of the mathematical constant π. It's + useful for + + many tasks that involve rotation and oscillation. For example, calling + + rotate(HALF_PI) rotates the coordinate system + HALF_PI radians, which is + + a quarter turn (90˚).

+ +

Note: TWO_PI radians equals 360˚, PI radians + equals 180˚, HALF_PI + + radians equals 90˚, and QUARTER_PI radians equals 45˚.

+line: 88 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw an arc from 0 to HALF_PI. + arc(50, 50, 80, 80, 0, HALF_PI); + + describe('The bottom-right quarter of a circle drawn in white on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Draw a line. + line(0, 0, 40, 0); + + // Rotate a quarter turn. + rotate(HALF_PI); + + // Draw the same line, rotated. + line(0, 0, 40, 0); + + describe('Two black lines on a gray background. One line extends from the center to the right. The other line extends from the center to the bottom.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A red circle and a blue circle oscillate from left to right on a gray background. The red circle appears to chase the blue circle.' + ); + } + + function draw() { + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Calculate the x-coordinates. + let x1 = 40 * sin(frameCount * 0.05); + let x2 = 40 * sin(frameCount * 0.05 + HALF_PI); + + // Style the oscillators. + noStroke(); + + // Draw the red oscillator. + fill(255, 0, 0); + circle(x1, 0, 20); + + // Draw the blue oscillator. + fill(0, 0, 255); + circle(x2, 0, 20); + } + +
+class: p5 +type: Number +--- + + +# HALF\_PI diff --git a/src/content/reference/en/p5 copy/constants/HAND.mdx b/src/content/reference/en/p5 copy/constants/HAND.mdx new file mode 100644 index 0000000000..0bd864fb59 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/HAND.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L65 +title: HAND +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 65 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# HAND diff --git a/src/content/reference/en/p5 copy/constants/HARD_LIGHT.mdx b/src/content/reference/en/p5 copy/constants/HARD_LIGHT.mdx new file mode 100644 index 0000000000..9f3f9742fc --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/HARD_LIGHT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L960 +title: HARD_LIGHT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 960 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# HARD\_LIGHT diff --git a/src/content/reference/en/p5 copy/constants/HSB.mdx b/src/content/reference/en/p5 copy/constants/HSB.mdx new file mode 100644 index 0000000000..d921d5405e --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/HSB.mdx @@ -0,0 +1,24 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L794 +title: HSB +module: Constants +submodule: Constants +file: src/core/constants.js +description: > +

HSB (hue, saturation, brightness) is a type of color model. + + You can learn more about it at + + HSB.

+line: 794 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# HSB diff --git a/src/content/reference/en/p5 copy/constants/HSL.mdx b/src/content/reference/en/p5 copy/constants/HSL.mdx new file mode 100644 index 0000000000..aa660c2da5 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/HSL.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L803 +title: HSL +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 803 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# HSL diff --git a/src/content/reference/en/p5 copy/constants/IMAGE.mdx b/src/content/reference/en/p5 copy/constants/IMAGE.mdx new file mode 100644 index 0000000000..479af890bb --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/IMAGE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1108 +title: IMAGE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1108 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# IMAGE diff --git a/src/content/reference/en/p5 copy/constants/IMMEDIATE.mdx b/src/content/reference/en/p5 copy/constants/IMMEDIATE.mdx new file mode 100644 index 0000000000..52b38ee8b5 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/IMMEDIATE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1100 +title: IMMEDIATE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1100 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# IMMEDIATE diff --git a/src/content/reference/en/p5 copy/constants/INVERT.mdx b/src/content/reference/en/p5 copy/constants/INVERT.mdx new file mode 100644 index 0000000000..9c383dd4d1 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/INVERT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L999 +title: INVERT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 999 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# INVERT diff --git a/src/content/reference/en/p5 copy/constants/ITALIC.mdx b/src/content/reference/en/p5 copy/constants/ITALIC.mdx new file mode 100644 index 0000000000..d0a9a1f2e5 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/ITALIC.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1031 +title: ITALIC +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1031 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# ITALIC diff --git a/src/content/reference/en/p5 copy/constants/LABEL.mdx b/src/content/reference/en/p5 copy/constants/LABEL.mdx new file mode 100644 index 0000000000..92786b3feb --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/LABEL.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1177 +title: LABEL +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1177 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# LABEL diff --git a/src/content/reference/en/p5 copy/constants/LANDSCAPE.mdx b/src/content/reference/en/p5 copy/constants/LANDSCAPE.mdx new file mode 100644 index 0000000000..c1709051cd --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/LANDSCAPE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1150 +title: LANDSCAPE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1150 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# LANDSCAPE diff --git a/src/content/reference/en/p5 copy/constants/LEFT.mdx b/src/content/reference/en/p5 copy/constants/LEFT.mdx new file mode 100644 index 0000000000..6e48fe2d99 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/LEFT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L655 +title: LEFT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 655 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# LEFT diff --git a/src/content/reference/en/p5 copy/constants/LEFT_ARROW.mdx b/src/content/reference/en/p5 copy/constants/LEFT_ARROW.mdx new file mode 100644 index 0000000000..8628e56688 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/LEFT_ARROW.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L856 +title: LEFT_ARROW +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 856 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# LEFT\_ARROW diff --git a/src/content/reference/en/p5 copy/constants/LIGHTEST.mdx b/src/content/reference/en/p5 copy/constants/LIGHTEST.mdx new file mode 100644 index 0000000000..bd15662468 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/LIGHTEST.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L918 +title: LIGHTEST +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 918 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# LIGHTEST diff --git a/src/content/reference/en/p5 copy/constants/LINEAR.mdx b/src/content/reference/en/p5 copy/constants/LINEAR.mdx new file mode 100644 index 0000000000..e56c663585 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/LINEAR.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1063 +title: LINEAR +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1063 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# LINEAR diff --git a/src/content/reference/en/p5 copy/constants/LINES.mdx b/src/content/reference/en/p5 copy/constants/LINES.mdx new file mode 100644 index 0000000000..9d7d5d2abc --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/LINES.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L687 +title: LINES +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 687 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# LINES diff --git a/src/content/reference/en/p5 copy/constants/LINE_LOOP.mdx b/src/content/reference/en/p5 copy/constants/LINE_LOOP.mdx new file mode 100644 index 0000000000..2a566fa4c7 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/LINE_LOOP.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L699 +title: LINE_LOOP +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 699 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# LINE\_LOOP diff --git a/src/content/reference/en/p5 copy/constants/LINE_STRIP.mdx b/src/content/reference/en/p5 copy/constants/LINE_STRIP.mdx new file mode 100644 index 0000000000..816e857d01 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/LINE_STRIP.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L693 +title: LINE_STRIP +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 693 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# LINE\_STRIP diff --git a/src/content/reference/en/p5 copy/constants/MIRROR.mdx b/src/content/reference/en/p5 copy/constants/MIRROR.mdx new file mode 100644 index 0000000000..9b2bcd7146 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/MIRROR.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1131 +title: MIRROR +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1131 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# MIRROR diff --git a/src/content/reference/en/p5 copy/constants/MITER.mdx b/src/content/reference/en/p5 copy/constants/MITER.mdx new file mode 100644 index 0000000000..533039ecc8 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/MITER.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L782 +title: MITER +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 782 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# MITER diff --git a/src/content/reference/en/p5 copy/constants/MOVE.mdx b/src/content/reference/en/p5 copy/constants/MOVE.mdx new file mode 100644 index 0000000000..aea9bf8a71 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/MOVE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L70 +title: MOVE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 70 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# MOVE diff --git a/src/content/reference/en/p5 copy/constants/MULTIPLY.mdx b/src/content/reference/en/p5 copy/constants/MULTIPLY.mdx new file mode 100644 index 0000000000..ce343b4bf2 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/MULTIPLY.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L939 +title: MULTIPLY +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 939 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# MULTIPLY diff --git a/src/content/reference/en/p5 copy/constants/NEAREST.mdx b/src/content/reference/en/p5 copy/constants/NEAREST.mdx new file mode 100644 index 0000000000..9fba7e46cf --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/NEAREST.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1116 +title: NEAREST +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1116 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# NEAREST diff --git a/src/content/reference/en/p5 copy/constants/NORMAL.mdx b/src/content/reference/en/p5 copy/constants/NORMAL.mdx new file mode 100644 index 0000000000..2c49e02fbf --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/NORMAL.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1026 +title: NORMAL +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1026 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# NORMAL diff --git a/src/content/reference/en/p5 copy/constants/OPAQUE.mdx b/src/content/reference/en/p5 copy/constants/OPAQUE.mdx new file mode 100644 index 0000000000..9ddf599dd1 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/OPAQUE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L994 +title: OPAQUE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 994 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# OPAQUE diff --git a/src/content/reference/en/p5 copy/constants/OPEN.mdx b/src/content/reference/en/p5 copy/constants/OPEN.mdx new file mode 100644 index 0000000000..29011d1e69 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/OPEN.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L745 +title: OPEN +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 745 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# OPEN diff --git a/src/content/reference/en/p5 copy/constants/OPTION.mdx b/src/content/reference/en/p5 copy/constants/OPTION.mdx new file mode 100644 index 0000000000..8ea0e625db --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/OPTION.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L861 +title: OPTION +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 861 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# OPTION diff --git a/src/content/reference/en/p5 copy/constants/OVERLAY.mdx b/src/content/reference/en/p5 copy/constants/OVERLAY.mdx new file mode 100644 index 0000000000..ccb03411bb --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/OVERLAY.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L955 +title: OVERLAY +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 955 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# OVERLAY diff --git a/src/content/reference/en/p5 copy/constants/P2D.mdx b/src/content/reference/en/p5 copy/constants/P2D.mdx new file mode 100644 index 0000000000..83f09b1d9c --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/P2D.mdx @@ -0,0 +1,19 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L18 +title: P2D +module: Constants +submodule: Constants +file: src/core/constants.js +description: | +

The default, two-dimensional renderer.

+line: 18 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# P2D diff --git a/src/content/reference/en/p5 copy/constants/PI.mdx b/src/content/reference/en/p5 copy/constants/PI.mdx new file mode 100644 index 0000000000..bddf509592 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/PI.mdx @@ -0,0 +1,108 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L178 +title: PI +module: Constants +submodule: Constants +file: src/core/constants.js +description: > +

A Number constant that's approximately 3.1416.

+ +

PI is the mathematical constant π. It's useful for many tasks + that + + involve rotation and oscillation. For example, calling rotate(PI) + rotates + + the coordinate system PI radians, which is a half turn + (180˚).

+ +

Note: TWO_PI radians equals 360˚, PI radians + equals 180˚, HALF_PI + + radians equals 90˚, and QUARTER_PI radians equals 45˚.

+line: 178 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw an arc from 0 to PI. + arc(50, 50, 80, 80, 0, PI); + + describe('The bottom half of a circle drawn in white on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Draw a line. + line(0, 0, 40, 0); + + // Rotate a half turn. + rotate(PI); + + // Draw the same line, rotated. + line(0, 0, 40, 0); + + describe('A horizontal black line on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A red circle and a blue circle oscillate from left to right on a gray background. The circles drift apart, then meet in the middle, over and over again.' + ); + } + + function draw() { + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Calculate the x-coordinates. + let x1 = 40 * sin(frameCount * 0.05); + let x2 = 40 * sin(frameCount * 0.05 + PI); + + // Style the oscillators. + noStroke(); + + // Draw the red oscillator. + fill(255, 0, 0); + circle(x1, 0, 20); + + // Draw the blue oscillator. + fill(0, 0, 255); + circle(x2, 0, 20); + } + +
+class: p5 +type: Number +--- + + +# PI diff --git a/src/content/reference/en/p5 copy/constants/PIE.mdx b/src/content/reference/en/p5 copy/constants/PIE.mdx new file mode 100644 index 0000000000..7be0810e6e --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/PIE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L755 +title: PIE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 755 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# PIE diff --git a/src/content/reference/en/p5 copy/constants/POINTS.mdx b/src/content/reference/en/p5 copy/constants/POINTS.mdx new file mode 100644 index 0000000000..8dea326a14 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/POINTS.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L681 +title: POINTS +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 681 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# POINTS diff --git a/src/content/reference/en/p5 copy/constants/PORTRAIT.mdx b/src/content/reference/en/p5 copy/constants/PORTRAIT.mdx new file mode 100644 index 0000000000..492546578c --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/PORTRAIT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1155 +title: PORTRAIT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1155 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# PORTRAIT diff --git a/src/content/reference/en/p5 copy/constants/POSTERIZE.mdx b/src/content/reference/en/p5 copy/constants/POSTERIZE.mdx new file mode 100644 index 0000000000..198c365591 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/POSTERIZE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1004 +title: POSTERIZE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1004 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# POSTERIZE diff --git a/src/content/reference/en/p5 copy/constants/PROJECT.mdx b/src/content/reference/en/p5 copy/constants/PROJECT.mdx new file mode 100644 index 0000000000..ce6f7dbaac --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/PROJECT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L760 +title: PROJECT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 760 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# PROJECT diff --git a/src/content/reference/en/p5 copy/constants/QUADRATIC.mdx b/src/content/reference/en/p5 copy/constants/QUADRATIC.mdx new file mode 100644 index 0000000000..49e8d2cc19 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/QUADRATIC.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1068 +title: QUADRATIC +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1068 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# QUADRATIC diff --git a/src/content/reference/en/p5 copy/constants/QUADS.mdx b/src/content/reference/en/p5 copy/constants/QUADS.mdx new file mode 100644 index 0000000000..c67a193a4f --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/QUADS.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L723 +title: QUADS +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 723 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# QUADS diff --git a/src/content/reference/en/p5 copy/constants/QUAD_STRIP.mdx b/src/content/reference/en/p5 copy/constants/QUAD_STRIP.mdx new file mode 100644 index 0000000000..c1ce9d4291 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/QUAD_STRIP.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L728 +title: QUAD_STRIP +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 728 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# QUAD\_STRIP diff --git a/src/content/reference/en/p5 copy/constants/QUARTER_PI.mdx b/src/content/reference/en/p5 copy/constants/QUARTER_PI.mdx new file mode 100644 index 0000000000..5f4cc24bc1 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/QUARTER_PI.mdx @@ -0,0 +1,109 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L267 +title: QUARTER_PI +module: Constants +submodule: Constants +file: src/core/constants.js +description: > +

A Number constant that's approximately 0.7854.

+ +

QUARTER_PI is one-fourth the value of the mathematical + constant π. It's + + useful for many tasks that involve rotation and oscillation. For example, + + calling rotate(QUARTER_PI) rotates the coordinate system + QUARTER_PI + + radians, which is an eighth of a turn (45˚).

+ +

Note: TWO_PI radians equals 360˚, PI radians + equals 180˚, HALF_PI + + radians equals 90˚, and QUARTER_PI radians equals 45˚.

+line: 267 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw an arc from 0 to QUARTER_PI. + arc(50, 50, 80, 80, 0, QUARTER_PI); + + describe('A one-eighth slice of a circle drawn in white on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Draw a line. + line(0, 0, 40, 0); + + // Rotate an eighth turn. + rotate(QUARTER_PI); + + // Draw the same line, rotated. + line(0, 0, 40, 0); + + describe('Two black lines that form a "V" opening towards the bottom-right corner of a gray square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A red circle and a blue circle oscillate from left to right on a gray background. The red circle appears to chase the blue circle.' + ); + } + + function draw() { + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Calculate the x-coordinates. + let x1 = 40 * sin(frameCount * 0.05); + let x2 = 40 * sin(frameCount * 0.05 + QUARTER_PI); + + // Style the oscillators. + noStroke(); + + // Draw the red oscillator. + fill(255, 0, 0); + circle(x1, 0, 20); + + // Draw the blue oscillator. + fill(0, 0, 255); + circle(x2, 0, 20); + } + +
+class: p5 +type: Number +--- + + +# QUARTER\_PI diff --git a/src/content/reference/en/p5 copy/constants/RADIANS.mdx b/src/content/reference/en/p5 copy/constants/RADIANS.mdx new file mode 100644 index 0000000000..856db37b9f --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/RADIANS.mdx @@ -0,0 +1,66 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L587 +title: RADIANS +module: Constants +submodule: Constants +file: src/core/constants.js +description: > +

A String constant that's used to set the + + angleMode().

+ +

By default, functions such as rotate() + and + + sin() expect angles measured in units of + radians. + + Calling angleMode(RADIANS) ensures that angles are measured in + units of + + radians. Doing so can be useful if the + + angleMode() has been set to + + DEGREES.

+ +

Note: TWO_PI radians equals 360˚.

+line: 587 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use degrees. + angleMode(DEGREES); + + // Draw a red arc from 0˚ to 90˚. + fill(255, 0, 0); + arc(50, 50, 80, 80, 0, 90); + + // Use radians. + angleMode(RADIANS); + + // Draw a blue arc from HALF_PI to PI. + fill(0, 0, 255); + arc(50, 50, 80, 80, HALF_PI, PI); + + describe('The bottom half of a circle drawn on a gray background. The bottom-right quarter is red. The bottom-left quarter is blue.'); + } + +
+class: p5 +type: String +--- + + +# RADIANS diff --git a/src/content/reference/en/p5 copy/constants/RADIUS.mdx b/src/content/reference/en/p5 copy/constants/RADIUS.mdx new file mode 100644 index 0000000000..95f1dcdeef --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/RADIUS.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L645 +title: RADIUS +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 645 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# RADIUS diff --git a/src/content/reference/en/p5 copy/constants/REMOVE.mdx b/src/content/reference/en/p5 copy/constants/REMOVE.mdx new file mode 100644 index 0000000000..c2daffc564 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/REMOVE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L899 +title: REMOVE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 899 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# REMOVE diff --git a/src/content/reference/en/p5 copy/constants/REPEAT.mdx b/src/content/reference/en/p5 copy/constants/REPEAT.mdx new file mode 100644 index 0000000000..c9e75c8bec --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/REPEAT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1121 +title: REPEAT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1121 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# REPEAT diff --git a/src/content/reference/en/p5 copy/constants/REPLACE.mdx b/src/content/reference/en/p5 copy/constants/REPLACE.mdx new file mode 100644 index 0000000000..8a04f06130 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/REPLACE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L949 +title: REPLACE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 949 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# REPLACE diff --git a/src/content/reference/en/p5 copy/constants/RETURN.mdx b/src/content/reference/en/p5 copy/constants/RETURN.mdx new file mode 100644 index 0000000000..3069efc256 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/RETURN.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L866 +title: RETURN +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 866 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# RETURN diff --git a/src/content/reference/en/p5 copy/constants/RGB.mdx b/src/content/reference/en/p5 copy/constants/RGB.mdx new file mode 100644 index 0000000000..b0ae826064 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/RGB.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L789 +title: RGB +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 789 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# RGB diff --git a/src/content/reference/en/p5 copy/constants/RGBA.mdx b/src/content/reference/en/p5 copy/constants/RGBA.mdx new file mode 100644 index 0000000000..256949cfd1 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/RGBA.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1224 +title: RGBA +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1224 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# RGBA diff --git a/src/content/reference/en/p5 copy/constants/RIGHT.mdx b/src/content/reference/en/p5 copy/constants/RIGHT.mdx new file mode 100644 index 0000000000..e9f69e8a80 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/RIGHT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L650 +title: RIGHT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 650 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# RIGHT diff --git a/src/content/reference/en/p5 copy/constants/RIGHT_ARROW.mdx b/src/content/reference/en/p5 copy/constants/RIGHT_ARROW.mdx new file mode 100644 index 0000000000..731ab29fb5 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/RIGHT_ARROW.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L871 +title: RIGHT_ARROW +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 871 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# RIGHT\_ARROW diff --git a/src/content/reference/en/p5 copy/constants/ROUND.mdx b/src/content/reference/en/p5 copy/constants/ROUND.mdx new file mode 100644 index 0000000000..50426d2636 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/ROUND.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L772 +title: ROUND +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 772 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# ROUND diff --git a/src/content/reference/en/p5 copy/constants/SCREEN.mdx b/src/content/reference/en/p5 copy/constants/SCREEN.mdx new file mode 100644 index 0000000000..65f2e6192d --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/SCREEN.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L944 +title: SCREEN +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 944 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# SCREEN diff --git a/src/content/reference/en/p5 copy/constants/SHIFT.mdx b/src/content/reference/en/p5 copy/constants/SHIFT.mdx new file mode 100644 index 0000000000..e48b091ab3 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/SHIFT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L876 +title: SHIFT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 876 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# SHIFT diff --git a/src/content/reference/en/p5 copy/constants/SMOOTH.mdx b/src/content/reference/en/p5 copy/constants/SMOOTH.mdx new file mode 100644 index 0000000000..816be1029b --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/SMOOTH.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1143 +title: SMOOTH +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1143 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# SMOOTH diff --git a/src/content/reference/en/p5 copy/constants/SOFT_LIGHT.mdx b/src/content/reference/en/p5 copy/constants/SOFT_LIGHT.mdx new file mode 100644 index 0000000000..846e6fe72b --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/SOFT_LIGHT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L965 +title: SOFT_LIGHT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 965 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# SOFT\_LIGHT diff --git a/src/content/reference/en/p5 copy/constants/SQUARE.mdx b/src/content/reference/en/p5 copy/constants/SQUARE.mdx new file mode 100644 index 0000000000..7b5da139d7 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/SQUARE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L766 +title: SQUARE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 766 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# SQUARE diff --git a/src/content/reference/en/p5 copy/constants/STROKE.mdx b/src/content/reference/en/p5 copy/constants/STROKE.mdx new file mode 100644 index 0000000000..16cfa32e5e --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/STROKE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1085 +title: STROKE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1085 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# STROKE diff --git a/src/content/reference/en/p5 copy/constants/SUBTRACT.mdx b/src/content/reference/en/p5 copy/constants/SUBTRACT.mdx new file mode 100644 index 0000000000..2bd6d94fe9 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/SUBTRACT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L929 +title: SUBTRACT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 929 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# SUBTRACT diff --git a/src/content/reference/en/p5 copy/constants/TAB.mdx b/src/content/reference/en/p5 copy/constants/TAB.mdx new file mode 100644 index 0000000000..cf89117ae4 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/TAB.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L881 +title: TAB +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 881 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# TAB diff --git a/src/content/reference/en/p5 copy/constants/TAU.mdx b/src/content/reference/en/p5 copy/constants/TAU.mdx new file mode 100644 index 0000000000..a553339913 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/TAU.mdx @@ -0,0 +1,114 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L357 +title: TAU +module: Constants +submodule: Constants +file: src/core/constants.js +description: > +

A Number constant that's approximately 6.2382.

+ +

TAU is twice the value of the mathematical constant π. It's + useful for + + many tasks that involve rotation and oscillation. For example, calling + + rotate(TAU) rotates the coordinate system TAU + radians, which is one + + full turn (360˚). TAU and TWO_PI are equal.

+ +

Note: TAU radians equals 360˚, PI radians equals + 180˚, HALF_PI + + radians equals 90˚, and QUARTER_PI radians equals 45˚.

+line: 357 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw an arc from 0 to TAU. + arc(50, 50, 80, 80, 0, TAU); + + describe('A white circle drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Draw a line. + line(0, 0, 40, 0); + + // Rotate a full turn. + rotate(TAU); + + // Style the second line. + strokeWeight(5); + + // Draw the same line, shorter and rotated. + line(0, 0, 20, 0); + + describe( + 'Two horizontal black lines on a gray background. A thick line extends from the center toward the right. A thin line extends from the end of the thick line.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A red circle with a blue center oscillates from left to right on a gray background.' + ); + } + + function draw() { + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Calculate the x-coordinates. + let x1 = 40 * sin(frameCount * 0.05); + let x2 = 40 * sin(frameCount * 0.05 + TAU); + + // Style the oscillators. + noStroke(); + + // Draw the red oscillator. + fill(255, 0, 0); + circle(x1, 0, 20); + + // Draw the blue oscillator, smaller. + fill(0, 0, 255); + circle(x2, 0, 10); + } + +
+class: p5 +type: Number +--- + + +# TAU diff --git a/src/content/reference/en/p5 copy/constants/TESS.mdx b/src/content/reference/en/p5 copy/constants/TESS.mdx new file mode 100644 index 0000000000..e6f853e8ab --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/TESS.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L734 +title: TESS +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 734 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# TESS diff --git a/src/content/reference/en/p5 copy/constants/TEXT.mdx b/src/content/reference/en/p5 copy/constants/TEXT.mdx new file mode 100644 index 0000000000..157a90001a --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/TEXT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L75 +title: TEXT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 75 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# TEXT diff --git a/src/content/reference/en/p5 copy/constants/TEXTURE.mdx b/src/content/reference/en/p5 copy/constants/TEXTURE.mdx new file mode 100644 index 0000000000..8ada92f376 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/TEXTURE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1095 +title: TEXTURE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1095 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# TEXTURE diff --git a/src/content/reference/en/p5 copy/constants/THRESHOLD.mdx b/src/content/reference/en/p5 copy/constants/THRESHOLD.mdx new file mode 100644 index 0000000000..f12e6ea336 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/THRESHOLD.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L984 +title: THRESHOLD +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 984 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# THRESHOLD diff --git a/src/content/reference/en/p5 copy/constants/TOP.mdx b/src/content/reference/en/p5 copy/constants/TOP.mdx new file mode 100644 index 0000000000..a91b5f4824 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/TOP.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L665 +title: TOP +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 665 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# TOP diff --git a/src/content/reference/en/p5 copy/constants/TRIANGLES.mdx b/src/content/reference/en/p5 copy/constants/TRIANGLES.mdx new file mode 100644 index 0000000000..ec281d033e --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/TRIANGLES.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L705 +title: TRIANGLES +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 705 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# TRIANGLES diff --git a/src/content/reference/en/p5 copy/constants/TRIANGLE_FAN.mdx b/src/content/reference/en/p5 copy/constants/TRIANGLE_FAN.mdx new file mode 100644 index 0000000000..bcd5d5f5a1 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/TRIANGLE_FAN.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L711 +title: TRIANGLE_FAN +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 711 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# TRIANGLE\_FAN diff --git a/src/content/reference/en/p5 copy/constants/TRIANGLE_STRIP.mdx b/src/content/reference/en/p5 copy/constants/TRIANGLE_STRIP.mdx new file mode 100644 index 0000000000..fefe226e17 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/TRIANGLE_STRIP.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L717 +title: TRIANGLE_STRIP +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 717 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# TRIANGLE\_STRIP diff --git a/src/content/reference/en/p5 copy/constants/TWO_PI.mdx b/src/content/reference/en/p5 copy/constants/TWO_PI.mdx new file mode 100644 index 0000000000..ed62a10b0f --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/TWO_PI.mdx @@ -0,0 +1,114 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L452 +title: TWO_PI +module: Constants +submodule: Constants +file: src/core/constants.js +description: > +

A Number constant that's approximately 6.2382.

+ +

TWO_PI is twice the value of the mathematical constant π. It's + useful for + + many tasks that involve rotation and oscillation. For example, calling + + rotate(TWO_PI) rotates the coordinate system TWO_PI + radians, which is + + one full turn (360˚). TWO_PI and TAU are equal.

+ +

Note: TWO_PI radians equals 360˚, PI radians + equals 180˚, HALF_PI + + radians equals 90˚, and QUARTER_PI radians equals 45˚.

+line: 452 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw an arc from 0 to TWO_PI. + arc(50, 50, 80, 80, 0, TWO_PI); + + describe('A white circle drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Draw a line. + line(0, 0, 40, 0); + + // Rotate a full turn. + rotate(TWO_PI); + + // Style the second line. + strokeWeight(5); + + // Draw the same line, shorter and rotated. + line(0, 0, 20, 0); + + describe( + 'Two horizontal black lines on a gray background. A thick line extends from the center toward the right. A thin line extends from the end of the thick line.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A red circle with a blue center oscillates from left to right on a gray background.' + ); + } + + function draw() { + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Calculate the x-coordinates. + let x1 = 40 * sin(frameCount * 0.05); + let x2 = 40 * sin(frameCount * 0.05 + TWO_PI); + + // Style the oscillators. + noStroke(); + + // Draw the red oscillator. + fill(255, 0, 0); + circle(x1, 0, 20); + + // Draw the blue oscillator, smaller. + fill(0, 0, 255); + circle(x2, 0, 10); + } + +
+class: p5 +type: Number +--- + + +# TWO\_PI diff --git a/src/content/reference/en/p5 copy/constants/UNSIGNED_BYTE.mdx b/src/content/reference/en/p5 copy/constants/UNSIGNED_BYTE.mdx new file mode 100644 index 0000000000..00acfe29c0 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/UNSIGNED_BYTE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1200 +title: UNSIGNED_BYTE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1200 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# UNSIGNED\_BYTE diff --git a/src/content/reference/en/p5 copy/constants/UNSIGNED_INT.mdx b/src/content/reference/en/p5 copy/constants/UNSIGNED_INT.mdx new file mode 100644 index 0000000000..f060682a13 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/UNSIGNED_INT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1206 +title: UNSIGNED_INT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1206 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# UNSIGNED\_INT diff --git a/src/content/reference/en/p5 copy/constants/UP_ARROW.mdx b/src/content/reference/en/p5 copy/constants/UP_ARROW.mdx new file mode 100644 index 0000000000..e0e0326aa6 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/UP_ARROW.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L886 +title: UP_ARROW +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 886 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# UP\_ARROW diff --git a/src/content/reference/en/p5 copy/constants/VERSION.mdx b/src/content/reference/en/p5 copy/constants/VERSION.mdx new file mode 100644 index 0000000000..f9f62fca55 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/VERSION.mdx @@ -0,0 +1,19 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L9 +title: VERSION +module: Constants +submodule: Constants +file: src/core/constants.js +description: | +

Version of this p5.js.

+line: 9 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# VERSION diff --git a/src/content/reference/en/p5 copy/constants/WAIT.mdx b/src/content/reference/en/p5 copy/constants/WAIT.mdx new file mode 100644 index 0000000000..833f77ee4f --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/WAIT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L80 +title: WAIT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 80 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# WAIT diff --git a/src/content/reference/en/p5 copy/constants/WEBGL.mdx b/src/content/reference/en/p5 copy/constants/WEBGL.mdx new file mode 100644 index 0000000000..2919ec489c --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/WEBGL.mdx @@ -0,0 +1,91 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L24 +title: WEBGL +module: Constants +submodule: Constants +file: src/core/constants.js +description: > +

One of the two render modes in p5.js, used for computationally intensive + tasks like 3D rendering and shaders.

+ +

WEBGL differs from the default P2D renderer in the following + ways:

+ + + +

To learn more about WEBGL mode, check out all the interactive WEBGL + tutorials in the "Tutorials" section of this website, or read the wiki + article "Getting + started with WebGL in p5".

+line: 24 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# WEBGL diff --git a/src/content/reference/en/p5 copy/constants/WEBGL2.mdx b/src/content/reference/en/p5 copy/constants/WEBGL2.mdx new file mode 100644 index 0000000000..68c6ca83fa --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/WEBGL2.mdx @@ -0,0 +1,21 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L45 +title: WEBGL2 +module: Constants +submodule: Constants +file: src/core/constants.js +description: | +

One of the two possible values of a WebGL canvas (either WEBGL or WEBGL2), + which can be used to determine what capabilities the rendering environment + has.

+line: 45 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# WEBGL2 diff --git a/src/content/reference/en/p5 copy/constants/WORD.mdx b/src/content/reference/en/p5 copy/constants/WORD.mdx new file mode 100644 index 0000000000..03f13b4874 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/WORD.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1051 +title: WORD +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1051 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# WORD diff --git a/src/content/reference/en/p5 copy/constrain.mdx b/src/content/reference/en/p5 copy/constrain.mdx new file mode 100644 index 0000000000..d869ce2e74 --- /dev/null +++ b/src/content/reference/en/p5 copy/constrain.mdx @@ -0,0 +1,86 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L91 +title: constrain +module: Math +submodule: Calculation +file: src/math/calculation.js +description: | +

Constrains a number between a minimum and maximum value.

+line: 91 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A black dot drawn on a gray square follows the mouse from left to right. Its movement is constrained to the middle third of the square.'); + } + + function draw() { + background(200); + + let x = constrain(mouseX, 33, 67); + let y = 50; + + strokeWeight(5); + point(x, y); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('Two vertical lines. Two circles move horizontally with the mouse. One circle stops at the vertical lines.'); + } + + function draw() { + background(200); + + // Set boundaries and draw them. + let leftWall = 25; + let rightWall = 75; + line(leftWall, 0, leftWall, 100); + line(rightWall, 0, rightWall, 100); + + // Draw a circle that follows the mouse freely. + fill(255); + circle(mouseX, 33, 9); + + // Draw a circle that's constrained. + let xc = constrain(mouseX, leftWall, rightWall); + fill(0); + circle(xc, 67, 9); + } + +
+class: p5 +params: + - name: 'n' + description: | +

number to constrain.

+ type: Number + - name: low + description: | +

minimum limit.

+ type: Number + - name: high + description: | +

maximum limit.

+ type: Number +return: + description: constrained number. + type: Number +chainable: false +--- + + +# constrain diff --git a/src/content/reference/en/p5 copy/copy.mdx b/src/content/reference/en/p5 copy/copy.mdx new file mode 100644 index 0000000000..059df56434 --- /dev/null +++ b/src/content/reference/en/p5 copy/copy.mdx @@ -0,0 +1,144 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L288 +title: copy +module: Image +submodule: Pixels +file: src/image/pixels.js +description: > +

Copies pixels from a source image to a region of the canvas.

+ +

The first parameter, srcImage, is the + + p5.Image object to blend. The source + image can be + + the canvas itself or a + + p5.Image object. copy() will + scale pixels from + + the source region if it isn't the same size as the destination region.

+ +

The next four parameters, sx, sy, + sw, and sh determine the region + + to copy from the source image. (sx, sy) is the top-left corner of + the + + region. sw and sh are the region's width and + height.

+ +

The next four parameters, dx, dy, + dw, and dh determine the region + + of the canvas to copy into. (dx, dy) is the top-left corner of + the + + region. dw and dh are the region's width and + height.

+line: 288 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/rockies.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Use the mountains as the background. + background(img); + + // Copy a region of pixels to another spot. + copy(img, 7, 22, 10, 10, 35, 25, 50, 50); + + // Outline the copied region. + stroke(255); + noFill(); + square(7, 22, 10); + + describe('An image of a mountain landscape. A square region is outlined in white. A larger square contains a pixelated view of the outlined region.'); + } + +
+class: p5 +overloads: + - line: 288 + params: + - name: srcImage + description: | +

source image.

+ type: p5.Image|p5.Element + - name: sx + description: | +

x-coordinate of the source's upper-left corner.

+ type: Integer + - name: sy + description: | +

y-coordinate of the source's upper-left corner.

+ type: Integer + - name: sw + description: | +

source image width.

+ type: Integer + - name: sh + description: | +

source image height.

+ type: Integer + - name: dx + description: | +

x-coordinate of the destination's upper-left corner.

+ type: Integer + - name: dy + description: | +

y-coordinate of the destination's upper-left corner.

+ type: Integer + - name: dw + description: | +

destination image width.

+ type: Integer + - name: dh + description: | +

destination image height.

+ type: Integer + - line: 345 + params: + - name: sx + description: '' + type: Integer + - name: sy + description: '' + type: Integer + - name: sw + description: '' + type: Integer + - name: sh + description: '' + type: Integer + - name: dx + description: '' + type: Integer + - name: dy + description: '' + type: Integer + - name: dw + description: '' + type: Integer + - name: dh + description: '' + type: Integer +chainable: false +--- + + +# copy diff --git a/src/content/reference/en/p5 copy/cos.mdx b/src/content/reference/en/p5 copy/cos.mdx new file mode 100644 index 0000000000..cd6468fc4f --- /dev/null +++ b/src/content/reference/en/p5 copy/cos.mdx @@ -0,0 +1,107 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L281 +title: cos +module: Math +submodule: Trigonometry +file: src/math/trigonometry.js +description: > +

Calculates the cosine of an angle.

+ +

cos() is useful for many geometric tasks in creative coding. + The values + + returned oscillate between -1 and 1 as the input angle increases. + cos() + + calculates the cosine of an angle, using radians by default, or according to + + if angleMode() setting (RADIANS or + DEGREES).

+line: 281 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A white ball on a string oscillates left and right.'); + } + + function draw() { + background(200); + + // Calculate the coordinates. + let x = 30 * cos(frameCount * 0.05) + 50; + let y = 50; + + // Draw the oscillator. + line(50, y, x, y); + circle(x, y, 20); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + describe('A series of black dots form a wave pattern.'); + } + + function draw() { + // Calculate the coordinates. + let x = frameCount; + let y = 30 * cos(x * 0.1) + 50; + + // Draw the point. + point(x, y); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + describe('A series of black dots form an infinity symbol.'); + } + + function draw() { + // Calculate the coordinates. + let x = 30 * cos(frameCount * 0.1) + 50; + let y = 10 * sin(frameCount * 0.2) + 50; + + // Draw the point. + point(x, y); + } + +
+class: p5 +params: + - name: angle + description: > +

the angle, in radians by default, or according to + + if angleMode() setting (RADIANS or + DEGREES).

+ type: Number +return: + description: cosine of the angle. + type: Number +chainable: false +--- + + +# cos diff --git a/src/content/reference/en/p5 copy/createA.mdx b/src/content/reference/en/p5 copy/createA.mdx new file mode 100644 index 0000000000..669ce45a27 --- /dev/null +++ b/src/content/reference/en/p5 copy/createA.mdx @@ -0,0 +1,93 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L724 +title: createA +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates an element that links to another web page.

+ +

The first parmeter, href, is a string that sets the URL of the + linked + + page.

+ +

The second parameter, html, is a string that sets the inner + HTML of the + + link. It's common to use text, images, or buttons as links.

+ +

The third parameter, target, is optional. It's a string that + tells the + + web browser where to open the link. By default, links open in the current + + browser tab. Passing '_blank' will cause the link to open in a + new + + browser tab. MDN describes a few + + other options.

+line: 724 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an anchor element that links to p5js.org. + let a = createA('https://p5js.org/', 'p5*js'); + a.position(25, 35); + + describe('The text "p5*js" written at the center of a gray square.'); + } + +
+ +
+ + function setup() { + background(200); + + // Create an anchor tag that links to p5js.org. + // Open the link in a new tab. + let a = createA('https://p5js.org/', 'p5*js', '_blank'); + a.position(25, 35); + + describe('The text "p5*js" written at the center of a gray square.'); + } + +
+class: p5 +params: + - name: href + description: | +

URL of linked page.

+ type: String + - name: html + description: | +

inner HTML of link element to display.

+ type: String + - name: target + description: | +

target where the new link should open, + either '_blank', '_self', '_parent', or '_top'.

+ type: String + optional: true +return: + description: new p5.Element object. + type: p5.Element +chainable: false +--- + + +# createA diff --git a/src/content/reference/en/p5 copy/createAudio.mdx b/src/content/reference/en/p5 copy/createAudio.mdx new file mode 100644 index 0000000000..24b3bce36b --- /dev/null +++ b/src/content/reference/en/p5 copy/createAudio.mdx @@ -0,0 +1,83 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L2213 +title: createAudio +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a hidden element for simple audio + playback.

+ +

createAudio() returns a new + + p5.MediaElement object.

+ +

The first parameter, src, is the path the video. If a single + string is + + passed, as in '/assets/video.mp4', a single video is loaded. An + array + + of strings can be used to load the same video in different formats. For + + example, ['/assets/video.mp4', '/assets/video.ogv', + '/assets/video.webm']. + + This is useful for ensuring that the video can play across different + + browsers with different capabilities. See + + MDN + + for more information about supported formats.

+ +

The second parameter, callback, is optional. It's a function + to call once + + the audio is ready to play.

+line: 2213 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + noCanvas(); + + // Load the audio. + let beat = createAudio('/assets/beat.mp3'); + + // Show the default audio controls. + beat.showControls(); + + describe('An audio beat plays when the user double-clicks the square.'); + } + +
+class: p5 +params: + - name: src + description: | +

path to an audio file, or an array of paths + for supporting different browsers.

+ type: 'String|String[]' + optional: true + - name: callback + description: | +

function to call once the audio is ready to play.

+ type: Function + optional: true +return: + description: new p5.MediaElement object. + type: p5.MediaElement +chainable: false +--- + + +# createAudio diff --git a/src/content/reference/en/p5 copy/createButton.mdx b/src/content/reference/en/p5 copy/createButton.mdx new file mode 100644 index 0000000000..9ff2d66faf --- /dev/null +++ b/src/content/reference/en/p5 copy/createButton.mdx @@ -0,0 +1,109 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L924 +title: createButton +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a element.

+ +

The first parameter, label, is a string that sets the label + displayed on + + the button.

+ +

The second parameter, value, is optional. It's a string that + sets the + + button's value. See + + MDN + + for more details.

+line: 924 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a button and place it beneath the canvas. + let button = createButton('click me'); + button.position(0, 100); + + // Call repaint() when the button is pressed. + button.mousePressed(repaint); + + describe('A gray square with a button that says "click me" beneath it. The square changes color when the button is clicked.'); + } + + // Change the background color. + function repaint() { + let g = random(255); + background(g); + } + +
+ +
+ + let button; + + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a button and set its value to 0. + // Place the button beneath the canvas. + button = createButton('click me', 'red'); + button.position(0, 100); + + // Call randomColor() when the button is pressed. + button.mousePressed(randomColor); + + describe('A red square with a button that says "click me" beneath it. The square changes color when the button is clicked.'); + } + + function draw() { + // Use the button's value to set the background color. + let c = button.value(); + background(c); + } + + // Set the button's value to a random color. + function randomColor() { + let c = random(['red', 'green', 'blue', 'yellow']); + button.value(c); + } + +
+class: p5 +params: + - name: label + description: | +

label displayed on the button.

+ type: String + - name: value + description: | +

value of the button.

+ type: String + optional: true +return: + description: new p5.Element object. + type: p5.Element +chainable: false +--- + + +# createButton diff --git a/src/content/reference/en/p5 copy/createCamera.mdx b/src/content/reference/en/p5 copy/createCamera.mdx new file mode 100644 index 0000000000..8fbb13ce5d --- /dev/null +++ b/src/content/reference/en/p5 copy/createCamera.mdx @@ -0,0 +1,99 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L638 +title: createCamera +module: 3D +submodule: Camera +file: src/webgl/p5.Camera.js +description: > +

Creates a new p5.Camera object and + sets it + + as the current (active) camera.

+ +

The new camera is initialized with a default position (0, 0, + 800) and a + + default perspective projection. Its properties can be controlled with + + p5.Camera methods such as + + myCamera.lookAt(0, 0, 0).

+ +

Note: Every 3D sketch starts with a default camera initialized. + + This camera can be controlled with the functions + + camera(), + + perspective(), + + ortho(), and + + frustum() if it's the only camera in the + scene.

+ +

Note: createCamera() can only be used in WebGL mode.

+line: 638 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Double-click to toggle between cameras. + + let cam1; + let cam2; + let usingCam1 = true; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the first camera. + // Keep its default settings. + cam1 = createCamera(); + + // Create the second camera. + // Place it at the top-left. + // Point it at the origin. + cam2 = createCamera(); + cam2.setPosition(400, -400, 800); + cam2.lookAt(0, 0, 0); + + // Set the current camera to cam1. + setCamera(cam1); + + describe('A white cube on a gray background. The camera toggles between frontal and aerial views when the user double-clicks.'); + } + + function draw() { + background(200); + + // Draw the box. + box(); + } + + // Toggle the current camera when the user double-clicks. + function doubleClicked() { + if (usingCam1 === true) { + setCamera(cam2); + usingCam1 = false; + } else { + setCamera(cam1); + usingCam1 = true; + } + } + +
+class: p5 +return: + description: the new camera. + type: p5.Camera +chainable: false +--- + + +# createCamera diff --git a/src/content/reference/en/p5 copy/createCanvas.mdx b/src/content/reference/en/p5 copy/createCanvas.mdx new file mode 100644 index 0000000000..600d7e3545 --- /dev/null +++ b/src/content/reference/en/p5 copy/createCanvas.mdx @@ -0,0 +1,191 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L15 +title: createCanvas +module: Rendering +submodule: Rendering +file: src/core/rendering.js +description: > +

Creates a canvas element on the web page.

+ +

createCanvas() creates the main drawing canvas for a sketch. + It should + + only be called once at the beginning of setup(). + + Calling createCanvas() more than once causes unpredictable + behavior.

+ +

The first two parameters, width and height, are + optional. They set the + + dimensions of the canvas and the values of the + + width and height system + + variables. For example, calling createCanvas(900, 500) creates a + canvas + + that's 900×500 pixels. By default, width and height + are both 100.

+ +

The third parameter is also optional. If either of the constants + P2D or + + WEBGL is passed, as in createCanvas(900, 500, + WEBGL), then it will set + + the sketch's rendering mode. If an existing + + HTMLCanvasElement + + is passed, as in createCanvas(900, 500, myCanvas), then it will + be used + + by the sketch.

+ +

The fourth parameter is also optional. If an existing + + HTMLCanvasElement + + is passed, as in createCanvas(900, 500, WEBGL, myCanvas), then it + will be + + used by the sketch.

+ +

Note: In WebGL mode, the canvas will use a WebGL2 context if it's supported + + by the browser. Check the webglVersion + + system variable to check what version is being used, or call + + setAttributes({ version: 1 }) to create a WebGL1 context.

+line: 15 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Draw a diagonal line. + line(0, 0, width, height); + + describe('A diagonal line drawn from top-left to bottom-right on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 50); + + background(180); + + // Draw a diagonal line. + line(0, 0, width, height); + + describe('A diagonal line drawn from top-left to bottom-right on a gray background.'); + } + +
+ +
+ + // Use WebGL mode. + + function setup() { + createCanvas(100, 100, WEBGL); + + background(180); + + // Draw a diagonal line. + line(-width / 2, -height / 2, width / 2, height / 2); + + describe('A diagonal line drawn from top-left to bottom-right on a gray background.'); + } + +
+ +
+ + function setup() { + // Create a p5.Renderer object. + let cnv = createCanvas(50, 50); + + // Position the canvas. + cnv.position(10, 20); + + background(180); + + // Draw a diagonal line. + line(0, 0, width, height); + + describe('A diagonal line drawn from top-left to bottom-right on a gray background.'); + } + +
+class: p5 +return: + description: new `p5.Renderer` that holds the canvas. + type: p5.Renderer +overloads: + - line: 15 + params: + - name: width + description: | +

width of the canvas. Defaults to 100.

+ type: Number + optional: true + - name: height + description: | +

height of the canvas. Defaults to 100.

+ type: Number + optional: true + - name: renderer + description: | +

either P2D or WEBGL. Defaults to P2D.

+ type: Constant + optional: true + - name: canvas + description: | +

existing canvas element that should be used for the sketch.

+ type: HTMLCanvasElement + optional: true + return: + description: new `p5.Renderer` that holds the canvas. + type: p5.Renderer + - line: 119 + params: + - name: width + description: '' + type: Number + optional: true + - name: height + description: '' + type: Number + optional: true + - name: canvas + description: '' + type: HTMLCanvasElement + optional: true + return: + description: '' + type: p5.Renderer +chainable: false +--- + + +# createCanvas diff --git a/src/content/reference/en/p5 copy/createCapture.mdx b/src/content/reference/en/p5 copy/createCapture.mdx new file mode 100644 index 0000000000..1087d14b1a --- /dev/null +++ b/src/content/reference/en/p5 copy/createCapture.mdx @@ -0,0 +1,189 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L2295 +title: createCapture +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a element that "captures" the audio/video + stream from + + the webcam and microphone.

+ +

createCapture() returns a new + + p5.MediaElement object. Videos are + shown by + + default. They can be hidden by calling capture.hide() and drawn + to the + + canvas using image().

+ +

The first parameter, type, is optional. It sets the type of + capture to + + use. By default, createCapture() captures both audio and video. + If VIDEO + + is passed, as in createCapture(VIDEO), only video will be + captured. + + If AUDIO is passed, as in createCapture(AUDIO), only + audio will be + + captured. A constraints object can also be passed to customize the stream. + + See the + + W3C documentation for possible properties. Different browsers support + different + + properties.

+ +

The 'flipped' property is an optional property which can be set to + {flipped:true} + + to mirror the video output.If it is true then it means that video will be + mirrored + + or flipped and if nothing is mentioned then by default it will be + false.

+ +

The second parameter,callback, is optional. It's a function to + call once + + the capture is ready for use. The callback function should have one + + parameter, stream, that's a + + MediaStream object.

+ +

Note: createCapture() only works when running a sketch locally + or using HTTPS. Learn more + + here + + and here.

+line: 2295 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + noCanvas(); + + // Create the video capture. + createCapture(VIDEO); + + describe('A video stream from the webcam.'); + } + +
+ +
+ + let capture; + + function setup() { + createCanvas(100, 100); + + // Create the video capture and hide the element. + capture = createCapture(VIDEO); + capture.hide(); + + describe('A video stream from the webcam with inverted colors.'); + } + + function draw() { + // Draw the video capture within the canvas. + image(capture, 0, 0, width, width * capture.height / capture.width); + + // Invert the colors in the stream. + filter(INVERT); + } + +
+
+ + let capture; + + function setup() { + createCanvas(100, 100); + + // Create the video capture with mirrored output. + capture = createCapture(VIDEO,{ flipped:true }); + capture.size(100,100); + + describe('A video stream from the webcam with flipped or mirrored output.'); + } + + +
+ +
+ + function setup() { + createCanvas(480, 120); + + // Create a constraints object. + let constraints = { + video: { + mandatory: { + minWidth: 1280, + minHeight: 720 + }, + optional: [{ maxFrameRate: 10 }] + }, + audio: false + }; + + // Create the video capture. + createCapture(constraints); + + describe('A video stream from the webcam.'); + } + +
+class: p5 +params: + - name: type + description: | +

type of capture, either AUDIO or VIDEO, + or a constraints object. Both video and audio + audio streams are captured by default.

+ type: String|Constant|Object + optional: true + - name: flipped + description: > +

flip the capturing video and mirror the output with + {flipped:true}. By + default it is false.

+ type: Object + optional: true + - name: callback + description: | +

function to call once the stream + has loaded.

+ type: Function + optional: true +return: + description: new p5.MediaElement object. + type: p5.MediaElement +chainable: false +--- + + +# createCapture diff --git a/src/content/reference/en/p5 copy/createCheckbox.mdx b/src/content/reference/en/p5 copy/createCheckbox.mdx new file mode 100644 index 0000000000..45335be2d4 --- /dev/null +++ b/src/content/reference/en/p5 copy/createCheckbox.mdx @@ -0,0 +1,131 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1008 +title: createCheckbox +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a checkbox element.

+ +

Checkboxes extend the p5.Element + class with a + + checked() method. Calling myBox.checked() returns + true if it the box + + is checked and false if not.

+ +

The first parameter, label, is optional. It's a string that + sets the label + + to display next to the checkbox.

+ +

The second parameter, value, is also optional. It's a boolean + that sets the + + checkbox's value.

+line: 1008 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let checkbox; + + function setup() { + createCanvas(100, 100); + + // Create a checkbox and place it beneath the canvas. + checkbox = createCheckbox(); + checkbox.position(0, 100); + + describe('A black square with a checkbox beneath it. The square turns white when the box is checked.'); + } + + function draw() { + // Use the checkbox to set the background color. + if (checkbox.checked()) { + background(255); + } else { + background(0); + } + } + +
+ +
+ + let checkbox; + + function setup() { + createCanvas(100, 100); + + // Create a checkbox and place it beneath the canvas. + // Label the checkbox "white". + checkbox = createCheckbox(' white'); + checkbox.position(0, 100); + + describe('A black square with a checkbox labeled "white" beneath it. The square turns white when the box is checked.'); + } + + function draw() { + // Use the checkbox to set the background color. + if (checkbox.checked()) { + background(255); + } else { + background(0); + } + } + +
+ +
+ + let checkbox; + + function setup() { + createCanvas(100, 100); + + // Create a checkbox and place it beneath the canvas. + // Label the checkbox "white" and set its value to true. + checkbox = createCheckbox(' white', true); + checkbox.position(0, 100); + + describe('A white square with a checkbox labeled "white" beneath it. The square turns black when the box is unchecked.'); + } + + function draw() { + // Use the checkbox to set the background color. + if (checkbox.checked()) { + background(255); + } else { + background(0); + } + } + +
+class: p5 +params: + - name: label + description: | +

label displayed after the checkbox.

+ type: String + optional: true + - name: value + description: > +

value of the checkbox. Checked is true and unchecked is + false.

+ type: Boolean + optional: true +return: + description: new p5.Element object. + type: p5.Element +chainable: false +--- + + +# createCheckbox diff --git a/src/content/reference/en/p5 copy/createColorPicker.mdx b/src/content/reference/en/p5 copy/createColorPicker.mdx new file mode 100644 index 0000000000..0c34a0593e --- /dev/null +++ b/src/content/reference/en/p5 copy/createColorPicker.mdx @@ -0,0 +1,101 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1759 +title: createColorPicker +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a color picker element.

+ +

The parameter, value, is optional. If a color string or + + p5.Color object is passed, it will set + the default + + color.

+ +

Color pickers extend the p5.Element + class with a + + couple of helpful methods for managing colors:

+ +
    + +
  • myPicker.value() returns the current color as a hex string in + the format '#rrggbb'.
  • + +
  • myPicker.color() returns the current color as a p5.Color object.
  • + +
+line: 1759 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let myPicker; + + function setup() { + createCanvas(100, 100); + + // Create a color picker and set its position. + myPicker = createColorPicker('deeppink'); + myPicker.position(0, 100); + + describe('A pink square with a color picker beneath it. The square changes color when the user picks a new color.'); + } + + function draw() { + // Use the color picker to paint the background. + let c = myPicker.color(); + background(c); + } + +
+ +
+ + let myPicker; + + function setup() { + createCanvas(100, 100); + + // Create a color picker and set its position. + myPicker = createColorPicker('deeppink'); + myPicker.position(0, 100); + + describe('A number with the format "#rrggbb" is displayed on a pink canvas. The background color and number change when the user picks a new color.'); + } + + function draw() { + // Use the color picker to paint the background. + let c = myPicker.value(); + background(c); + + // Display the current color as a hex string. + text(c, 25, 55); + } + +
+class: p5 +params: + - name: value + description: > +

default color as a CSS color string.

+ type: String|p5.Color + optional: true +return: + description: new p5.Element object. + type: p5.Element +chainable: false +--- + + +# createColorPicker diff --git a/src/content/reference/en/p5 copy/createConvolver.mdx b/src/content/reference/en/p5 copy/createConvolver.mdx new file mode 100644 index 0000000000..89fba3be4e --- /dev/null +++ b/src/content/reference/en/p5 copy/createConvolver.mdx @@ -0,0 +1,78 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L8885 +title: createConvolver +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: | +

Create a p5.Convolver. Accepts a path to a soundfile + that will be used to generate an impulse response.

+line: 8885 +isConstructor: false +itemtype: method +example: + - |- + +
+ let cVerb, sound; + function preload() { + // We have both MP3 and OGG versions of all sound assets + soundFormats('ogg', 'mp3'); + + // Try replacing 'bx-spring' with other soundfiles like + // 'concrete-tunnel' 'small-plate' 'drum' 'beatbox' + cVerb = createConvolver('/assets/bx-spring.mp3'); + + // Try replacing 'Damscray_DancingTiger' with + // 'beat', 'doorbell', lucky_dragons_-_power_melody' + sound = loadSound('/assets/Damscray_DancingTiger.mp3'); + } + + function setup() { + let cnv = createCanvas(100, 100); + cnv.mousePressed(playSound); + background(220); + text('tap to play', 20, 20); + + // disconnect from main output... + sound.disconnect(); + + // ...and process with cVerb + // so that we only hear the convolution + cVerb.process(sound); + } + + function playSound() { + sound.play(); + } +
+class: p5 +params: + - name: path + description: | +

path to a sound file

+ type: String + - name: callback + description: | +

function to call if loading is successful. + The object will be passed in as the argument + to the callback function.

+ type: Function + optional: true + - name: errorCallback + description: | +

function to call if loading is not successful. + A custom error will be passed in as the argument + to the callback function.

+ type: Function + optional: true +return: + description: '' + type: p5.Convolver +chainable: false +--- + + +# createConvolver diff --git a/src/content/reference/en/p5 copy/createDiv.mdx b/src/content/reference/en/p5 copy/createDiv.mdx new file mode 100644 index 0000000000..610e0a4f67 --- /dev/null +++ b/src/content/reference/en/p5 copy/createDiv.mdx @@ -0,0 +1,72 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L491 +title: createDiv +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a

element.

+ +

elements are commonly used as containers for + + other elements.

+ +

The parameter html is optional. It accepts a string that sets + the + + inner HTML of the new

.

+line: 491 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a div element and set its position. + let div = createDiv('p5*js'); + div.position(25, 35); + + describe('A gray square with the text "p5*js" written in its center.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an h3 element within the div. + let div = createDiv('

p5*js

'); + div.position(20, 5); + + describe('A gray square with the text "p5*js" written in its center.'); + } +
+
+class: p5 +params: + - name: html + description: > +

inner HTML for the new <div></div> + element.

+ type: String + optional: true +return: + description: new p5.Element object. + type: p5.Element +chainable: false +--- + + +# createDiv diff --git a/src/content/reference/en/p5 copy/createElement.mdx b/src/content/reference/en/p5 copy/createElement.mdx new file mode 100644 index 0000000000..5969416251 --- /dev/null +++ b/src/content/reference/en/p5 copy/createElement.mdx @@ -0,0 +1,78 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L2493 +title: createElement +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a new p5.Element object.

+ +

The first parameter, tag, is a string an HTML tag such as + 'h5'.

+ +

The second parameter, content, is optional. It's a string that + sets the + + HTML content to insert into the new element. New elements have no content + + by default.

+line: 2493 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an h5 element with nothing in it. + createElement('h5'); + + describe('A gray square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an h5 element with the content "p5*js". + let h5 = createElement('h5', 'p5*js'); + + // Set the element's style and position. + h5.style('color', 'deeppink'); + h5.position(30, 15); + + describe('The text "p5*js" written in pink in the middle of a gray square.'); + } + +
+class: p5 +params: + - name: tag + description: | +

tag for the new element.

+ type: String + - name: content + description: | +

HTML content to insert into the element.

+ type: String + optional: true +return: + description: new p5.Element object. + type: p5.Element +chainable: false +--- + + +# createElement diff --git a/src/content/reference/en/p5 copy/createFileInput.mdx b/src/content/reference/en/p5 copy/createFileInput.mdx new file mode 100644 index 0000000000..295f2a0434 --- /dev/null +++ b/src/content/reference/en/p5 copy/createFileInput.mdx @@ -0,0 +1,138 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1942 +title: createFileInput +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates an element of type + 'file'.

+ +

createFileInput() allows users to select local files for use + in a sketch. + + It returns a p5.File object.

+ +

The first parameter, callback, is a function that's called + when the file + + loads. The callback function should have one parameter, file, + that's a + + p5.File object.

+ +

The second parameter, multiple, is optional. It's a boolean + value that + + allows loading multiple files if set to true. If + true, callback + + will be called once per file.

+line: 1942 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Use the file input to select an image to + // load and display. + let input; + let img; + + function setup() { + createCanvas(100, 100); + + // Create a file input and place it beneath + // the canvas. + input = createFileInput(handleImage); + input.position(0, 100); + + describe('A gray square with a file input beneath it. If the user selects an image file to load, it is displayed on the square.'); + } + + function draw() { + background(200); + + // Draw the image if loaded. + if (img) { + image(img, 0, 0, width, height); + } + } + + // Create an image if the file is an image. + function handleImage(file) { + if (file.type === 'image') { + img = createImg(file.data, ''); + img.hide(); + } else { + img = null; + } + } + +
+ +
+ + // Use the file input to select multiple images + // to load and display. + let input; + let images = []; + + function setup() { + // Create a file input and place it beneath + // the canvas. Allow it to load multiple files. + input = createFileInput(handleImage, true); + input.position(0, 100); + } + + function draw() { + background(200); + + // Draw the images if loaded. Each image + // is drawn 20 pixels lower than the + // previous image. + for (let i = 0; i < images.length; i += 1) { + // Calculate the y-coordinate. + let y = i * 20; + + // Draw the image. + image(images[i], 0, y, 100, 100); + } + + describe('A gray square with a file input beneath it. If the user selects multiple image files to load, they are displayed on the square.'); + } + + // Create an image if the file is an image, + // then add it to the images array. + function handleImage(file) { + if (file.type === 'image') { + let img = createImg(file.data, ''); + img.hide(); + images.push(img); + } + } + +
+class: p5 +params: + - name: callback + description: | +

function to call once the file loads.

+ type: Function + - name: multiple + description: | +

allow multiple files to be selected.

+ type: Boolean + optional: true +return: + description: new p5.File object. + type: p5.File +chainable: false +--- + + +# createFileInput diff --git a/src/content/reference/en/p5 copy/createFilterShader.mdx b/src/content/reference/en/p5 copy/createFilterShader.mdx new file mode 100644 index 0000000000..5c6c9a4ec5 --- /dev/null +++ b/src/content/reference/en/p5 copy/createFilterShader.mdx @@ -0,0 +1,148 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L540 +title: createFilterShader +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Creates a p5.Shader object to be used + with the + + filter() function.

+ +

createFilterShader() works like + + createShader() but has a default + vertex + + shader included. createFilterShader() is intended to be used + along with + + filter() for filtering the contents of a + canvas. + + A filter shader will be applied to the whole canvas instead of just + + p5.Geometry objects.

+ +

The parameter, fragSrc, sets the fragment shader. It’s a + string that + + contains the fragment shader program written in + + GLSL.

+ +

The p5.Shader object that's created + has some + + uniforms that can be set:

+ +
    + +
  • sampler2D tex0, which contains the canvas contents as a + texture.
  • + +
  • vec2 canvasSize, which is the width and height of the canvas, + not including pixel density.
  • + +
  • vec2 texelSize, which is the size of a physical pixel + including pixel density. This is calculated as 1.0 / (width * + density) for the pixel width and 1.0 / (height * density) + for the pixel height.
  • + +
+ +

The p5.Shader that's created also + provides + + varying vec2 vTexCoord, a coordinate with values between 0 and 1. + + vTexCoord describes where on the canvas the pixel will be + drawn.

+ +

For more info about filters and shaders, see Adam Ferriss' repo of shader + examples + + or the Introduction to + Shaders tutorial.

+line: 540 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + let fragSrc = `precision highp float; + void main() { + gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); + }`; + + createCanvas(100, 100, WEBGL); + let s = createFilterShader(fragSrc); + filter(s); + describe('a yellow canvas'); + } + +
+ +
+ + let img, s; + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + function setup() { + let fragSrc = `precision highp float; + + // x,y coordinates, given from the vertex shader + varying vec2 vTexCoord; + + // the canvas contents, given from filter() + uniform sampler2D tex0; + // other useful information from the canvas + uniform vec2 texelSize; + uniform vec2 canvasSize; + // a custom variable from this sketch + uniform float darkness; + + void main() { + // get the color at current pixel + vec4 color = texture2D(tex0, vTexCoord); + // set the output color + color.b = 1.0; + color *= darkness; + gl_FragColor = vec4(color.rgb, 1.0); + }`; + + createCanvas(100, 100, WEBGL); + s = createFilterShader(fragSrc); + } + function draw() { + image(img, -50, -50); + s.setUniform('darkness', 0.5); + filter(s); + describe('a image of bricks tinted dark blue'); + } + +
+class: p5 +params: + - name: fragSrc + description: | +

source code for the fragment shader.

+ type: String +return: + description: new shader object created from the fragment shader. + type: p5.Shader +chainable: false +--- + + +# createFilterShader diff --git a/src/content/reference/en/p5 copy/createFramebuffer.mdx b/src/content/reference/en/p5 copy/createFramebuffer.mdx new file mode 100644 index 0000000000..80d8199779 --- /dev/null +++ b/src/content/reference/en/p5 copy/createFramebuffer.mdx @@ -0,0 +1,208 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L495 +title: createFramebuffer +module: Rendering +submodule: Rendering +file: src/core/rendering.js +description: > +

Creates and a new p5.Framebuffer + object.

+ +

p5.Framebuffer objects are + separate drawing + + surfaces that can be used as textures in WebGL mode. They're similar to + + p5.Graphics objects and generally run + much + + faster when used as textures.

+ +

The parameter, options, is optional. An object can be passed + to configure + + the p5.Framebuffer object. The + available + + properties are:

+ +
    + +
  • format: data format of the texture, either + UNSIGNED_BYTE, FLOAT, or HALF_FLOAT. + Default is UNSIGNED_BYTE.
  • + +
  • channels: whether to store RGB or + RGBA color channels. Default is to match the main canvas which is + RGBA.
  • + +
  • depth: whether to include a depth buffer. Default is + true.
  • + +
  • depthFormat: data format of depth information, either + UNSIGNED_INT or FLOAT. Default is + FLOAT.
  • + +
  • stencil: whether to include a stencil buffer for masking. + depth must be true for this feature to work. + Defaults to the value of depth which is true.
  • + +
  • antialias: whether to perform anti-aliasing. If set to + true, as in { antialias: true }, 2 samples will be + used by default. The number of samples can also be set, as in { + antialias: 4 }. Default is to match setAttributes() which is + false (true in Safari).
  • + +
  • width: width of the p5.Framebuffer object. Default is to + always match the main canvas width.
  • + +
  • height: height of the p5.Framebuffer object. Default is to + always match the main canvas height.
  • + +
  • density: pixel density of the p5.Framebuffer object. Default is to + always match the main canvas pixel density.
  • + +
  • textureFiltering: how to read values from the p5.Framebuffer object. Either + LINEAR (nearby pixels will be interpolated) or + NEAREST (no interpolation). Generally, use LINEAR + when using the texture as an image and NEAREST if reading the + texture as data. Default is LINEAR.
  • + +
+ +

If the width, height, or density + attributes are set, they won't automatically match the main canvas and must be + changed manually.

+ +

Note: createFramebuffer() can only be used in WebGL mode.

+line: 495 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let myBuffer; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Framebuffer object. + myBuffer = createFramebuffer(); + + describe('A grid of white toruses rotating against a dark gray background.'); + } + + function draw() { + background(50); + + // Start drawing to the p5.Framebuffer object. + myBuffer.begin(); + + // Clear the drawing surface. + clear(); + + // Turn on the lights. + lights(); + + // Rotate the coordinate system. + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + + // Style the torus. + noStroke(); + + // Draw the torus. + torus(20); + + // Stop drawing to the p5.Framebuffer object. + myBuffer.end(); + + // Iterate from left to right. + for (let x = -50; x < 50; x += 25) { + // Iterate from top to bottom. + for (let y = -50; y < 50; y += 25) { + // Draw the p5.Framebuffer object to the canvas. + image(myBuffer, x, y, 25, 25); + } + } + } + +
+ +
+ + let myBuffer; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create an options object. + let options = { width: 25, height: 25 }; + + // Create a p5.Framebuffer object. + // Use options for configuration. + myBuffer = createFramebuffer(options); + + describe('A grid of white toruses rotating against a dark gray background.'); + } + + function draw() { + background(50); + + // Start drawing to the p5.Framebuffer object. + myBuffer.begin(); + + // Clear the drawing surface. + clear(); + + // Turn on the lights. + lights(); + + // Rotate the coordinate system. + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + + // Style the torus. + noStroke(); + + // Draw the torus. + torus(5, 2.5); + + // Stop drawing to the p5.Framebuffer object. + myBuffer.end(); + + // Iterate from left to right. + for (let x = -50; x < 50; x += 25) { + // Iterate from top to bottom. + for (let y = -50; y < 50; y += 25) { + // Draw the p5.Framebuffer object to the canvas. + image(myBuffer, x, y); + } + } + } + +
+class: p5 +params: + - name: options + description: | +

configuration options.

+ type: Object + optional: true +return: + description: new framebuffer. + type: p5.Framebuffer +chainable: false +--- + + +# createFramebuffer diff --git a/src/content/reference/en/p5 copy/createGraphics.mdx b/src/content/reference/en/p5 copy/createGraphics.mdx new file mode 100644 index 0000000000..6d75f158f4 --- /dev/null +++ b/src/content/reference/en/p5 copy/createGraphics.mdx @@ -0,0 +1,191 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L370 +title: createGraphics +module: Rendering +submodule: Rendering +file: src/core/rendering.js +description: > +

Creates a p5.Graphics object.

+ +

createGraphics() creates an offscreen drawing canvas (graphics + buffer) + + and returns it as a p5.Graphics + object. Drawing + + to a separate graphics buffer can be helpful for performance and for + + organizing code.

+ +

The first two parameters, width and height, are + optional. They set the + + dimensions of the p5.Graphics object. + For + + example, calling createGraphics(900, 500) creates a graphics + buffer + + that's 900×500 pixels.

+ +

The third parameter is also optional. If either of the constants + P2D or + + WEBGL is passed, as in createGraphics(900, 500, + WEBGL), then it will set + + the p5.Graphics object's rendering + mode. If an + + existing + + HTMLCanvasElement + + is passed, as in createGraphics(900, 500, myCanvas), then it will + be used + + by the graphics buffer.

+ +

The fourth parameter is also optional. If an existing + + HTMLCanvasElement + + is passed, as in createGraphics(900, 500, WEBGL, myCanvas), then + it will be + + used by the graphics buffer.

+ +

Note: In WebGL mode, the p5.Graphics object + + will use a WebGL2 context if it's supported by the browser. Check the + + webglVersion system variable to + check what + + version is being used, or call setAttributes({ version: 1 }) to + create a + + WebGL1 context.

+line: 370 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Double-click to draw the contents of the graphics buffer. + + let pg; + + function setup() { + createCanvas(100, 100); + + background(180); + + // Create the p5.Graphics object. + pg = createGraphics(50, 50); + + // Draw to the graphics buffer. + pg.background(100); + pg.circle(pg.width / 2, pg.height / 2, 20); + + describe('A gray square. A smaller, darker square with a white circle at its center appears when the user double-clicks.'); + } + + // Display the graphics buffer when the user double-clicks. + function doubleClicked() { + if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { + image(pg, 25, 25); + } + } + +
+ +
+ + // Double-click to draw the contents of the graphics buffer. + + let pg; + + function setup() { + createCanvas(100, 100); + + background(180); + + // Create the p5.Graphics object in WebGL mode. + pg = createGraphics(50, 50, WEBGL); + + // Draw to the graphics buffer. + pg.background(100); + pg.lights(); + pg.noStroke(); + pg.rotateX(QUARTER_PI); + pg.rotateY(QUARTER_PI); + pg.torus(15, 5); + + describe('A gray square. A smaller, darker square with a white torus at its center appears when the user double-clicks.'); + } + + // Display the graphics buffer when the user double-clicks. + function doubleClicked() { + if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { + image(pg, 25, 25); + } + } + +
+class: p5 +return: + description: new graphics buffer. + type: p5.Graphics +overloads: + - line: 370 + params: + - name: width + description: | +

width of the graphics buffer.

+ type: Number + - name: height + description: | +

height of the graphics buffer.

+ type: Number + - name: renderer + description: | +

either P2D or WEBGL. Defaults to P2D.

+ type: Constant + optional: true + - name: canvas + description: | +

existing canvas element that should be + used for the graphics buffer..

+ type: HTMLCanvasElement + optional: true + return: + description: new graphics buffer. + type: p5.Graphics + - line: 475 + params: + - name: width + description: '' + type: Number + - name: height + description: '' + type: Number + - name: canvas + description: '' + type: HTMLCanvasElement + optional: true + return: + description: '' + type: p5.Graphics +chainable: false +--- + + +# createGraphics diff --git a/src/content/reference/en/p5 copy/createImage.mdx b/src/content/reference/en/p5 copy/createImage.mdx new file mode 100644 index 0000000000..33c151c315 --- /dev/null +++ b/src/content/reference/en/p5 copy/createImage.mdx @@ -0,0 +1,172 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/image.js#L15 +title: createImage +module: Image +submodule: Image +file: src/image/image.js +description: > +

Creates a new p5.Image object.

+ +

createImage() uses the width and + height parameters to set the new + + p5.Image object's dimensions in pixels. + The new + + p5.Image can be modified by updating its + + pixels array or by calling its + + get() and + + set() methods. The + + loadPixels() method must be + called + + before reading or modifying pixel values. The + + updatePixels() method must be + called + + for updates to take effect.

+ +

Note: The new p5.Image object is + transparent by + + default.

+line: 15 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Image object. + let img = createImage(66, 66); + + // Load the image's pixels into memory. + img.loadPixels(); + + // Set all the image's pixels to black. + for (let x = 0; x < img.width; x += 1) { + for (let y = 0; y < img.height; y += 1) { + img.set(x, y, 0); + } + } + + // Update the image's pixel values. + img.updatePixels(); + + // Draw the image. + image(img, 17, 17); + + describe('A black square drawn in the middle of a gray square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Image object. + let img = createImage(66, 66); + + // Load the image's pixels into memory. + img.loadPixels(); + + // Create a color gradient. + for (let x = 0; x < img.width; x += 1) { + for (let y = 0; y < img.height; y += 1) { + // Calculate the transparency. + let a = map(x, 0, img.width, 0, 255); + + // Create a p5.Color object. + let c = color(0, a); + + // Set the pixel's color. + img.set(x, y, c); + } + } + + // Update the image's pixels. + img.updatePixels(); + + // Display the image. + image(img, 17, 17); + + describe('A square with a horizontal color gradient that transitions from gray to black.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Image object. + let img = createImage(66, 66); + + // Load the pixels into memory. + img.loadPixels(); + // Get the current pixel density. + let d = pixelDensity(); + + // Calculate the pixel that is halfway through the image's pixel array. + let halfImage = 4 * (d * img.width) * (d * img.height / 2); + + // Set half of the image's pixels to black. + for (let i = 0; i < halfImage; i += 4) { + // Red. + img.pixels[i] = 0; + // Green. + img.pixels[i + 1] = 0; + // Blue. + img.pixels[i + 2] = 0; + // Alpha. + img.pixels[i + 3] = 255; + } + + // Update the image's pixels. + img.updatePixels(); + + // Display the image. + image(img, 17, 17); + + describe('A black square drawn in the middle of a gray square.'); + } + +
+class: p5 +params: + - name: width + description: | +

width in pixels.

+ type: Integer + - name: height + description: | +

height in pixels.

+ type: Integer +return: + description: new p5.Image object. + type: p5.Image +chainable: false +--- + + +# createImage diff --git a/src/content/reference/en/p5 copy/createImg.mdx b/src/content/reference/en/p5 copy/createImg.mdx new file mode 100644 index 0000000000..22b71d22c4 --- /dev/null +++ b/src/content/reference/en/p5 copy/createImg.mdx @@ -0,0 +1,115 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L649 +title: createImg +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates an element that can appear outside of the + canvas.

+ +

The first parameter, src, is a string with the path to the + image file. + + src should be a relative path, as in + '/assets/image.png', or a URL, as + + in 'https://example.com/image.png'.

+ +

The second parameter, alt, is a string with the + + alternate text + + for the image. An empty string '' can be used for images that + aren't displayed.

+ +

The third parameter, crossOrigin, is optional. It's a string + that sets the + + crossOrigin property + + of the image. Use 'anonymous' or 'use-credentials' + to fetch the image + + with cross-origin access.

+ +

The fourth parameter, callback, is also optional. It sets a + function to + + call after the image loads. The new image is passed to the callback + + function as a p5.Element object.

+line: 649 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + let img = createImg( + 'https://p5js.org//assets/img/asterisk-01.png', + 'The p5.js magenta asterisk.' + ); + img.position(0, -10); + + describe('A gray square with a magenta asterisk in its center.'); + } + +
+class: p5 +return: + description: new p5.Element object. + type: p5.Element +overloads: + - line: 649 + params: + - name: src + description: | +

relative path or URL for the image.

+ type: String + - name: alt + description: | +

alternate text for the image.

+ type: String + return: + description: new p5.Element object. + type: p5.Element + - line: 693 + params: + - name: src + description: '' + type: String + - name: alt + description: '' + type: String + - name: crossOrigin + description: | +

crossOrigin property to use when fetching the image.

+ type: String + optional: true + - name: successCallback + description: | +

function to call once the image loads. The new image will be passed + to the function as a p5.Element object.

+ type: Function + optional: true + return: + description: new p5.Element object. + type: p5.Element +chainable: false +--- + + +# createImg diff --git a/src/content/reference/en/p5 copy/createInput.mdx b/src/content/reference/en/p5 copy/createInput.mdx new file mode 100644 index 0000000000..3a790ee6b2 --- /dev/null +++ b/src/content/reference/en/p5 copy/createInput.mdx @@ -0,0 +1,118 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1859 +title: createInput +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a text element.

+ +

Call myInput.size() to set the length of the text box.

+ +

The first parameter, value, is optional. It's a string that + sets the + + input's default value. The input is blank by default.

+ +

The second parameter, type, is also optional. It's a string + that + + specifies the type of text being input. See MDN for a full + + list of options. + + The default is 'text'.

+line: 1859 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let myInput; + + function setup() { + createCanvas(100, 100); + + // Create an input element and place it + // beneath the canvas. + myInput = createInput(); + myInput.position(0, 100); + + describe('A gray square with a text box beneath it. The text in the square changes when the user types something new in the input bar.'); + } + + function draw() { + background(200); + + // Use the input to display a message. + let msg = myInput.value(); + text(msg, 25, 55); + } + +
+ +
+ + let myInput; + + function setup() { + createCanvas(100, 100); + + // Create an input element and place it + // beneath the canvas. Set its default + // text to "hello!". + myInput = createInput('hello!'); + myInput.position(0, 100); + + describe('The text "hello!" written at the center of a gray square. A text box beneath the square also says "hello!". The text in the square changes when the user types something new in the input bar.'); + } + + function draw() { + background(200); + + // Use the input to display a message. + let msg = myInput.value(); + text(msg, 25, 55); + } + +
+class: p5 +return: + description: new p5.Element object. + type: p5.Element +overloads: + - line: 1859 + params: + - name: value + description: > +

default value of the input box. Defaults to an empty string + ''.

+ type: String + optional: true + - name: type + description: | +

type of input. Defaults to 'text'.

+ type: String + optional: true + return: + description: new p5.Element object. + type: p5.Element + - line: 1929 + params: + - name: value + description: '' + type: String + optional: true + return: + description: '' + type: p5.Element +chainable: false +--- + + +# createInput diff --git a/src/content/reference/en/p5 copy/createModel.mdx b/src/content/reference/en/p5 copy/createModel.mdx new file mode 100644 index 0000000000..c94e95900f --- /dev/null +++ b/src/content/reference/en/p5 copy/createModel.mdx @@ -0,0 +1,193 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/loading.js#L1132 +title: createModel +module: Shape +submodule: 3D Models +file: src/webgl/loading.js +description: > +

Load a 3d model from an OBJ or STL string.

+ +

OBJ and STL files lack a built-in sense of scale, causing models exported + from different programs to vary in size. + + If your model doesn't display correctly, consider using + loadModel() with normalize set to true + to standardize its size. + + Further adjustments can be made using the scale() function.

+ +

Also, the support for colored STL files is not present. STL files with + color will be + + rendered without color properties.

+ +
    + +
  • Options can include:
  • + +
+ +
    + +
  • modelString: Specifies the plain text string of either an stl + or obj file to be loaded.
  • + +
  • fileType: Defines the file extension of the model.
  • + +
  • normalize: Enables standardized size scaling during loading + if set to true.
  • + +
  • successCallback: Callback for post-loading actions with the + 3D model object.
  • + +
  • failureCallback: Handles errors if model loading fails, + receiving an event error.
  • + +
  • flipU: Flips the U texture coordinates of the model.
  • + +
  • flipV: Flips the V texture coordinates of the model.
  • + +
+line: 1132 +isConstructor: false +itemtype: method +example: + - |- + +
+ + const octahedron_model = ` + v 0.000000E+00 0.000000E+00 40.0000 + v 22.5000 22.5000 0.000000E+00 + v 22.5000 -22.5000 0.000000E+00 + v -22.5000 -22.5000 0.000000E+00 + v -22.5000 22.5000 0.000000E+00 + v 0.000000E+00 0.000000E+00 -40.0000 + f 1 2 3 + f 1 3 4 + f 1 4 5 + f 1 5 2 + f 6 5 4 + f 6 4 3 + f 6 3 2 + f 6 2 5 + `; + //draw a spinning octahedron + let octahedron; + + function setup() { + createCanvas(100, 100, WEBGL); + octahedron = createModel(octahedron_model, '.obj'); + describe('Vertically rotating 3D octahedron.'); + } + + function draw() { + background(200); + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + model(octahedron); + } + +
+class: p5 +return: + description: the p5.Geometry object + type: p5.Geometry +overloads: + - line: 1132 + params: + - name: modelString + description: | +

String of the object to be loaded

+ type: String + - name: fileType + description: | +

The file extension of the model + (.stl, .obj).

+ type: String + optional: true + - name: normalize + description: | +

If true, scale the model to a + standardized size when loading

+ type: Boolean + - name: successCallback + description: | +

Function to be called + once the model is loaded. Will be passed + the 3D model object.

+ type: function(p5.Geometry) + optional: true + - name: failureCallback + description: | +

called with event error if + the model fails to load.

+ type: Function(Event) + optional: true + return: + description: the p5.Geometry object + type: p5.Geometry + - line: 1202 + params: + - name: modelString + description: '' + type: String + - name: fileType + description: '' + type: String + optional: true + - name: successCallback + description: '' + type: function(p5.Geometry) + optional: true + - name: failureCallback + description: '' + type: Function(Event) + optional: true + return: + description: the p5.Geometry object + type: p5.Geometry + - line: 1210 + params: + - name: modelString + description: '' + type: String + - name: fileType + description: '' + type: String + optional: true + - name: options + description: '' + type: Object + optional: true + props: + - name: successCallback + description: '' + type: function(p5.Geometry) + optional: true + - name: failureCallback + description: '' + type: Function(Event) + optional: true + - name: normalize + description: '' + type: Boolean + optional: true + - name: flipU + description: '' + type: Boolean + optional: true + - name: flipV + description: '' + type: Boolean + optional: true + return: + description: the p5.Geometry object + type: p5.Geometry +chainable: false +--- + + +# createModel diff --git a/src/content/reference/en/p5 copy/createNumberDict.mdx b/src/content/reference/en/p5 copy/createNumberDict.mdx new file mode 100644 index 0000000000..952410a222 --- /dev/null +++ b/src/content/reference/en/p5 copy/createNumberDict.mdx @@ -0,0 +1,57 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/data/p5.TypedDict.js#L48 +title: createNumberDict +module: Data +submodule: Dictionary +file: src/data/p5.TypedDict.js +description: > +

Creates a new instance of p5.NumberDict using the key-value pair + or object you provide.

+line: 48 +isConstructor: false +itemtype: method +example: + - |2- + +
+ + function setup() { + let myDictionary = createNumberDict(100, 42); + print(myDictionary.hasKey(100)); // logs true to console + let anotherDictionary = createNumberDict({ 200: 84 }); + print(anotherDictionary.hasKey(200)); // logs true to console + } +
+class: p5 +return: + description: '' + type: p5.NumberDict +overloads: + - line: 48 + params: + - name: key + description: '' + type: Number + - name: value + description: '' + type: Number + return: + description: '' + type: p5.NumberDict + - line: 71 + params: + - name: object + description: | +

object

+ type: Object + return: + description: '' + type: p5.NumberDict +chainable: false +--- + + +# createNumberDict diff --git a/src/content/reference/en/p5 copy/createP.mdx b/src/content/reference/en/p5 copy/createP.mdx new file mode 100644 index 0000000000..6d3005fc37 --- /dev/null +++ b/src/content/reference/en/p5 copy/createP.mdx @@ -0,0 +1,54 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L543 +title: createP +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a paragraph element.

+ +

elements are commonly used for paragraph-length + text.

+ +

The parameter html is optional. It accepts a string that sets + the + + inner HTML of the new

.

+line: 543 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a paragraph element and set its position. + let p = createP('Tell me a story.'); + p.position(5, 0); + + describe('A gray square displaying the text "Tell me a story." written in black.'); + } + +
+class: p5 +params: + - name: html + description: | +

inner HTML for the new <p></p> element.

+ type: String + optional: true +return: + description: new p5.Element object. + type: p5.Element +chainable: false +--- + + +# createP diff --git a/src/content/reference/en/p5 copy/createRadio.mdx b/src/content/reference/en/p5 copy/createRadio.mdx new file mode 100644 index 0000000000..f2b8a2a81c --- /dev/null +++ b/src/content/reference/en/p5 copy/createRadio.mdx @@ -0,0 +1,223 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1440 +title: createRadio +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a radio button element.

+ +

The parameter is optional. If a string is passed, as in + + let myRadio = createSelect('food'), then each radio option will + + have "food" as its name parameter: . + + If an existing

or + + element is passed, as in let myRadio = createSelect(container), + it will + + become the radio button's parent element.

+ +

Radio buttons extend the p5.Element + class with a few + + helpful methods for managing options:

+ +
    + +
  • myRadio.option(value, [label]) adds an option to the menu. + The first parameter, value, is a string that sets the option's + value and label. The second parameter, label, is optional. If + provided, it sets the label displayed for the value. If an option + with value already exists, its label is changed and its value is + returned.
  • + +
  • myRadio.value() returns the currently-selected option's + value.
  • + +
  • myRadio.selected() returns the currently-selected + option.
  • + +
  • myRadio.selected(value) selects the given option and returns + it as an HTMLInputElement.
  • + +
  • myRadio.disable(shouldDisable) Disables the radio button if + true is passed, and enables it if false is + passed.
  • + +
+line: 1440 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let style = document.createElement('style'); + style.innerHTML = ` + .p5-radio label { + display: flex; + align-items: center; + } + .p5-radio input { + margin-right: 5px; + } + `; + document.head.appendChild(style); + + let myRadio; + + function setup() { + createCanvas(100, 100); + + // Create a radio button element and place it + // in the top-left corner. + myRadio = createRadio(); + myRadio.position(0, 0); + myRadio.class('p5-radio'); + myRadio.size(60); + + // Add a few color options. + myRadio.option('red'); + myRadio.option('yellow'); + myRadio.option('blue'); + + // Choose a default option. + myRadio.selected('yellow'); + + describe('A yellow square with three color options listed, "red", "yellow", and "blue". The square changes color when the user selects a new option.'); + } + + function draw() { + // Set the background color using the radio button. + let g = myRadio.value(); + background(g); + } + +
+ +
+ + let myRadio; + + function setup() { + createCanvas(100, 100); + + // Create a radio button element and place it + // in the top-left corner. + myRadio = createRadio(); + myRadio.position(0, 0); + myRadio.size(50); + + // Add a few color options. + // Color values are labeled with + // emotions they evoke. + myRadio.option('red', 'love'); + myRadio.option('yellow', 'joy'); + myRadio.option('blue', 'trust'); + + // Choose a default option. + myRadio.selected('yellow'); + + describe('A yellow square with three options listed, "love", "joy", and "trust". The square changes color when the user selects a new option.'); + } + + function draw() { + // Set the background color using the radio button. + let c = myRadio.value(); + background(c); + } + +
+ +
+ + let myRadio; + + function setup() { + createCanvas(100, 100); + + // Create a radio button element and place it + // in the top-left corner. + myRadio = createRadio(); + myRadio.position(0, 0); + myRadio.class('p5-radio'); + myRadio.size(50); + + // Add a few color options. + myRadio.option('red'); + myRadio.option('yellow'); + myRadio.option('blue'); + + // Choose a default option. + myRadio.selected('yellow'); + + // Create a button and place it beneath the canvas. + let btn = createButton('disable'); + btn.position(0, 100); + + // Call disableRadio() when btn is pressed. + btn.mousePressed(disableRadio); + + describe('A yellow square with three options listed, "red", "yellow", and "blue". The square changes color when the user selects a new option. A "disable" button beneath the canvas disables the color options when pressed.'); + } + + function draw() { + // Set the background color using the radio button. + let c = myRadio.value(); + background(c); + } + + // Disable myRadio. + function disableRadio() { + myRadio.disable(true); + } + +
+class: p5 +return: + description: new p5.Element object. + type: p5.Element +overloads: + - line: 1440 + params: + - name: containerElement + description: > +

container HTML Element, either a + <div></div> + + or <span></span>.

+ type: Object + optional: true + return: + description: new p5.Element object. + type: p5.Element + - line: 1588 + params: + - name: name + description: > +

name parameter assigned to each option's + <input></input> element.

+ type: String + optional: true + return: + description: new p5.Element object. + type: p5.Element + - line: 1593 + params: [] + return: + description: new p5.Element object. + type: p5.Element +chainable: false +--- + + +# createRadio diff --git a/src/content/reference/en/p5 copy/createSelect.mdx b/src/content/reference/en/p5 copy/createSelect.mdx new file mode 100644 index 0000000000..496f4082e6 --- /dev/null +++ b/src/content/reference/en/p5 copy/createSelect.mdx @@ -0,0 +1,235 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1159 +title: createSelect +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a dropdown menu element.

+ +

The parameter is optional. If true is passed, as in + + let mySelect = createSelect(true), then the dropdown will support + + multiple selections. If an existing element + + is passed, as in let mySelect = createSelect(otherSelect), the + existing + + element will be wrapped in a new p5.Element + + object.

+ +

Dropdowns extend the p5.Element + class with a few + + helpful methods for managing options:

+ +
    + +
  • mySelect.option(name, [value]) adds an option to the menu. + The first paremeter, name, is a string that sets the option's + name and value. The second parameter, value, is optional. If + provided, it sets the value that corresponds to the key name. If + an option with name already exists, its value is changed to + value.
  • + +
  • mySelect.value() returns the currently-selected option's + value.
  • + +
  • mySelect.selected() returns the currently-selected + option.
  • + +
  • mySelect.selected(option) selects the given option by + default.
  • + +
  • mySelect.disable() marks the whole dropdown element as + disabled.
  • + +
  • mySelect.disable(option) marks a given option as + disabled.
  • + +
  • mySelect.enable() marks the whole dropdown element as + enabled.
  • + +
  • mySelect.enable(option) marks a given option as enabled.
  • + +
+line: 1159 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let mySelect; + + function setup() { + createCanvas(100, 100); + + // Create a dropdown and place it beneath the canvas. + mySelect = createSelect(); + mySelect.position(0, 100); + + // Add color options. + mySelect.option('red'); + mySelect.option('green'); + mySelect.option('blue'); + mySelect.option('yellow'); + + // Set the selected option to "red". + mySelect.selected('red'); + + describe('A red square with a dropdown menu beneath it. The square changes color when a new color is selected.'); + } + + function draw() { + // Use the selected value to paint the background. + let c = mySelect.selected(); + background(c); + } + +
+ +
+ + let mySelect; + + function setup() { + createCanvas(100, 100); + + // Create a dropdown and place it beneath the canvas. + mySelect = createSelect(); + mySelect.position(0, 100); + + // Add color options. + mySelect.option('red'); + mySelect.option('green'); + mySelect.option('blue'); + mySelect.option('yellow'); + + // Set the selected option to "red". + mySelect.selected('red'); + + // Disable the "yellow" option. + mySelect.disable('yellow'); + + describe('A red square with a dropdown menu beneath it. The square changes color when a new color is selected.'); + } + + function draw() { + // Use the selected value to paint the background. + let c = mySelect.selected(); + background(c); + } + +
+ +
+ + let mySelect; + + function setup() { + createCanvas(100, 100); + + // Create a dropdown and place it beneath the canvas. + mySelect = createSelect(); + mySelect.position(0, 100); + + // Add color options with names and values. + mySelect.option('one', 'red'); + mySelect.option('two', 'green'); + mySelect.option('three', 'blue'); + mySelect.option('four', 'yellow'); + + // Set the selected option to "one". + mySelect.selected('one'); + + describe('A red square with a dropdown menu beneath it. The square changes color when a new color is selected.'); + } + + function draw() { + // Use the selected value to paint the background. + let c = mySelect.selected(); + background(c); + } + +
+ +
+ + // Hold CTRL to select multiple options on Windows and Linux. + // Hold CMD to select multiple options on macOS. + let mySelect; + + function setup() { + createCanvas(100, 100); + + // Create a dropdown and allow multiple selections. + // Place it beneath the canvas. + mySelect = createSelect(true); + mySelect.position(0, 100); + + // Add color options. + mySelect.option('red'); + mySelect.option('green'); + mySelect.option('blue'); + mySelect.option('yellow'); + + describe('A gray square with a dropdown menu beneath it. Colorful circles appear when their color is selected.'); + } + + function draw() { + background(200); + + // Use the selected value(s) to draw circles. + let colors = mySelect.selected(); + for (let i = 0; i < colors.length; i += 1) { + // Calculate the x-coordinate. + let x = 10 + i * 20; + + // Access the color. + let c = colors[i]; + + // Draw the circle. + fill(c); + circle(x, 50, 20); + } + } + +
+class: p5 +return: + description: new p5.Element object. + type: p5.Element +overloads: + - line: 1159 + params: + - name: multiple + description: | +

support multiple selections.

+ type: Boolean + optional: true + return: + description: new p5.Element object. + type: p5.Element + - line: 1324 + params: + - name: existing + description: > +

select element to wrap, either as a p5.Element or + a HTMLSelectElement.

+ type: Object + return: + description: '' + type: p5.Element +chainable: false +--- + + +# createSelect diff --git a/src/content/reference/en/p5 copy/createShader.mdx b/src/content/reference/en/p5 copy/createShader.mdx new file mode 100644 index 0000000000..c595145529 --- /dev/null +++ b/src/content/reference/en/p5 copy/createShader.mdx @@ -0,0 +1,438 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L173 +title: createShader +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Creates a new p5.Shader object.

+ +

Shaders are programs that run on the graphics processing unit (GPU). They + + can process many pixels at the same time, making them fast for many + + graphics tasks. They’re written in a language called + + GLSL + + and run along with the rest of the code in a sketch.

+ +

Once the p5.Shader object is created, + it can be + + used with the shader() function, as in + + shader(myShader). A shader program consists of two parts, a + vertex shader + + and a fragment shader. The vertex shader affects where 3D geometry is drawn + + on the screen and the fragment shader affects color.

+ +

The first parameter, vertSrc, sets the vertex shader. It’s a + string that + + contains the vertex shader program written in GLSL.

+ +

The second parameter, fragSrc, sets the fragment shader. It’s + a string + + that contains the fragment shader program written in GLSL.

+ +

A shader can optionally describe hooks, which are functions in + GLSL that + + users may choose to provide to customize the behavior of the shader using the + + modify() method of + p5.Shader. These are added by + + describing the hooks in a third parameter, options, and + referencing the hooks in + + your vertSrc or fragSrc. Hooks for the vertex or + fragment shader are described under + + the vertex and fragment keys of + options. Each one is an object. where each key is + + the type and name of a hook function, and each value is a string with the + + parameter list and default implementation of the hook. For example, to let + users + + optionally run code at the start of the vertex shader, the options object + could + + include:

+ +
{
+    vertex: {
+      'void beforeVertex': '() {}'
+    }
+  }
+
+  
+ +

Then, in your vertex shader source, you can run a hook by calling a + function + + with the same name prefixed by HOOK_. If you want to check if the + default + + hook has been replaced, maybe to avoid extra overhead, you can check if the + + same name prefixed by AUGMENTED_HOOK_ has been defined:

+ +
void main() {
+    // In most cases, just calling the hook is fine:
+    HOOK_beforeVertex();
+
+    // Alternatively, for more efficiency:
+    #ifdef AUGMENTED_HOOK_beforeVertex
+    HOOK_beforeVertex();
+    #endif
+
+    // Add the rest of your shader code here!
+  }
+
+  
+ +

Note: Only filter shaders can be used in 2D mode. All shaders can be used + + in WebGL mode.

+line: 173 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Note: A "uniform" is a global variable within a shader program. + + // Create a string with the vertex shader program. + // The vertex shader is called for each vertex. + let vertSrc = ` + precision highp float; + uniform mat4 uModelViewMatrix; + uniform mat4 uProjectionMatrix; + attribute vec3 aPosition; + attribute vec2 aTexCoord; + varying vec2 vTexCoord; + + void main() { + vTexCoord = aTexCoord; + vec4 positionVec4 = vec4(aPosition, 1.0); + gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; + } + `; + + // Create a string with the fragment shader program. + // The fragment shader is called for each pixel. + let fragSrc = ` + precision highp float; + + void main() { + // Set each pixel's RGBA value to yellow. + gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); + } + `; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Shader object. + let shaderProgram = createShader(vertSrc, fragSrc); + + // Compile and apply the p5.Shader object. + shader(shaderProgram); + + // Style the drawing surface. + noStroke(); + + // Add a plane as a drawing surface. + plane(100, 100); + + describe('A yellow square.'); + } + +
+ +
+ + // Note: A "uniform" is a global variable within a shader program. + + // Create a string with the vertex shader program. + // The vertex shader is called for each vertex. + let vertSrc = ` + precision highp float; + uniform mat4 uModelViewMatrix; + uniform mat4 uProjectionMatrix; + attribute vec3 aPosition; + attribute vec2 aTexCoord; + varying vec2 vTexCoord; + + void main() { + vTexCoord = aTexCoord; + vec4 positionVec4 = vec4(aPosition, 1.0); + gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; + } + `; + + // Create a string with the fragment shader program. + // The fragment shader is called for each pixel. + let fragSrc = ` + precision highp float; + uniform vec2 p; + uniform float r; + const int numIterations = 500; + varying vec2 vTexCoord; + + void main() { + vec2 c = p + gl_FragCoord.xy * r; + vec2 z = c; + float n = 0.0; + + for (int i = numIterations; i > 0; i--) { + if (z.x * z.x + z.y * z.y > 4.0) { + n = float(i) / float(numIterations); + break; + } + z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c; + } + + gl_FragColor = vec4( + 0.5 - cos(n * 17.0) / 2.0, + 0.5 - cos(n * 13.0) / 2.0, + 0.5 - cos(n * 23.0) / 2.0, + 1.0 + ); + } + `; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Shader object. + let mandelbrot = createShader(vertSrc, fragSrc); + + // Compile and apply the p5.Shader object. + shader(mandelbrot); + + // Set the shader uniform p to an array. + // p is the center point of the Mandelbrot image. + mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); + + // Set the shader uniform r to 0.005. + // r is the size of the image in Mandelbrot-space. + mandelbrot.setUniform('r', 0.005); + + // Style the drawing surface. + noStroke(); + + // Add a plane as a drawing surface. + plane(100, 100); + + describe('A black fractal image on a magenta background.'); + } + +
+ +
+ + // Note: A "uniform" is a global variable within a shader program. + + // Create a string with the vertex shader program. + // The vertex shader is called for each vertex. + let vertSrc = ` + precision highp float; + uniform mat4 uModelViewMatrix; + uniform mat4 uProjectionMatrix; + + attribute vec3 aPosition; + attribute vec2 aTexCoord; + varying vec2 vTexCoord; + + void main() { + vTexCoord = aTexCoord; + vec4 positionVec4 = vec4(aPosition, 1.0); + gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; + } + `; + + // Create a string with the fragment shader program. + // The fragment shader is called for each pixel. + let fragSrc = ` + precision highp float; + uniform vec2 p; + uniform float r; + const int numIterations = 500; + varying vec2 vTexCoord; + + void main() { + vec2 c = p + gl_FragCoord.xy * r; + vec2 z = c; + float n = 0.0; + + for (int i = numIterations; i > 0; i--) { + if (z.x * z.x + z.y * z.y > 4.0) { + n = float(i) / float(numIterations); + break; + } + + z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c; + } + + gl_FragColor = vec4( + 0.5 - cos(n * 17.0) / 2.0, + 0.5 - cos(n * 13.0) / 2.0, + 0.5 - cos(n * 23.0) / 2.0, + 1.0 + ); + } + `; + + let mandelbrot; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Shader object. + mandelbrot = createShader(vertSrc, fragSrc); + + // Apply the p5.Shader object. + shader(mandelbrot); + + // Set the shader uniform p to an array. + // p is the center point of the Mandelbrot image. + mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); + + describe('A fractal image zooms in and out of focus.'); + } + + function draw() { + // Set the shader uniform r to a value that oscillates + // between 0 and 0.005. + // r is the size of the image in Mandelbrot-space. + let radius = 0.005 * (sin(frameCount * 0.01) + 1); + mandelbrot.setUniform('r', radius); + + // Style the drawing surface. + noStroke(); + + // Add a plane as a drawing surface. + plane(100, 100); + } + +
+ +
+ + // A shader with hooks. + let myShader; + + // A shader with modified hooks. + let modifiedShader; + + // Create a string with the vertex shader program. + // The vertex shader is called for each vertex. + let vertSrc = ` + precision highp float; + uniform mat4 uModelViewMatrix; + uniform mat4 uProjectionMatrix; + + attribute vec3 aPosition; + attribute vec2 aTexCoord; + + void main() { + vec4 positionVec4 = vec4(aPosition, 1.0); + gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; + } + `; + + // Create a fragment shader that uses a hook. + let fragSrc = ` + precision highp float; + void main() { + // Let users override the color + gl_FragColor = HOOK_getColor(vec4(1., 0., 0., 1.)); + } + `; + + function setup() { + createCanvas(50, 50, WEBGL); + + // Create a shader with hooks + myShader = createShader(vertSrc, fragSrc, { + fragment: { + 'vec4 getColor': '(vec4 color) { return color; }' + } + }); + + // Make a version of the shader with a hook overridden + modifiedShader = myShader.modify({ + 'vec4 getColor': `(vec4 color) { + return vec4(0., 0., 1., 1.); + }` + }); + } + + function draw() { + noStroke(); + + push(); + shader(myShader); + translate(-width/3, 0); + sphere(10); + pop(); + + push(); + shader(modifiedShader); + translate(width/3, 0); + sphere(10); + pop(); + } + +
+class: p5 +params: + - name: vertSrc + description: | +

source code for the vertex shader.

+ type: String + - name: fragSrc + description: | +

source code for the fragment shader.

+ type: String + - name: options + description: > +

An optional object describing how this shader can + + be augmented with hooks. It can include:

+ +
    + +
  • vertex: An object describing the available vertex shader + hooks.
  • + +
  • fragment: An object describing the available frament + shader hooks.
  • + +
+ type: Object + optional: true +return: + description: |- + new shader object created from the + vertex and fragment shaders. + type: p5.Shader +chainable: false +--- + + +# createShader diff --git a/src/content/reference/en/p5 copy/createSlider.mdx b/src/content/reference/en/p5 copy/createSlider.mdx new file mode 100644 index 0000000000..7bdf510078 --- /dev/null +++ b/src/content/reference/en/p5 copy/createSlider.mdx @@ -0,0 +1,162 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L789 +title: createSlider +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a slider element.

+ +

Range sliders are useful for quickly selecting numbers from a given + range.

+ +

The first two parameters, min and max, are + numbers that set the + + slider's minimum and maximum.

+ +

The third parameter, value, is optional. It's a number that + sets the + + slider's default value.

+ +

The fourth parameter, step, is also optional. It's a number + that sets the + + spacing between each value in the slider's range. Setting step to + 0 + + allows the slider to move smoothly from min to + max.

+line: 789 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let slider; + + function setup() { + createCanvas(100, 100); + + // Create a slider and place it at the top of the canvas. + slider = createSlider(0, 255); + slider.position(10, 10); + slider.size(80); + + describe('A dark gray square with a range slider at the top. The square changes color when the slider is moved.'); + } + + function draw() { + // Use the slider as a grayscale value. + let g = slider.value(); + background(g); + } + +
+ +
+ + let slider; + + function setup() { + createCanvas(100, 100); + + // Create a slider and place it at the top of the canvas. + // Set its default value to 0. + slider = createSlider(0, 255, 0); + slider.position(10, 10); + slider.size(80); + + describe('A black square with a range slider at the top. The square changes color when the slider is moved.'); + } + + function draw() { + // Use the slider as a grayscale value. + let g = slider.value(); + background(g); + } + +
+ +
+ + let slider; + + function setup() { + createCanvas(100, 100); + + // Create a slider and place it at the top of the canvas. + // Set its default value to 0. + // Set its step size to 50. + slider = createSlider(0, 255, 0, 50); + slider.position(10, 10); + slider.size(80); + + describe('A black square with a range slider at the top. The square changes color when the slider is moved.'); + } + + function draw() { + // Use the slider as a grayscale value. + let g = slider.value(); + background(g); + } + +
+ +
+ + let slider; + + function setup() { + createCanvas(100, 100); + + // Create a slider and place it at the top of the canvas. + // Set its default value to 0. + // Set its step size to 0 so that it moves smoothly. + slider = createSlider(0, 255, 0, 0); + slider.position(10, 10); + slider.size(80); + + describe('A black square with a range slider at the top. The square changes color when the slider is moved.'); + } + + function draw() { + // Use the slider as a grayscale value. + let g = slider.value(); + background(g); + } + +
+class: p5 +params: + - name: min + description: | +

minimum value of the slider.

+ type: Number + - name: max + description: | +

maximum value of the slider.

+ type: Number + - name: value + description: | +

default value of the slider.

+ type: Number + optional: true + - name: step + description: | +

size for each step in the slider's range.

+ type: Number + optional: true +return: + description: new p5.Element object. + type: p5.Element +chainable: false +--- + + +# createSlider diff --git a/src/content/reference/en/p5 copy/createSpan.mdx b/src/content/reference/en/p5 copy/createSpan.mdx new file mode 100644 index 0000000000..ed346b35dc --- /dev/null +++ b/src/content/reference/en/p5 copy/createSpan.mdx @@ -0,0 +1,93 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L578 +title: createSpan +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a element.

+ +

elements are commonly used as containers + + for inline elements. For example, a + + can hold part of a sentence that's a + + different style.

+ +

The parameter html is optional. It accepts a string that sets + the + + inner HTML of the new .

+line: 578 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a span element and set its position. + let span = createSpan('p5*js'); + span.position(25, 35); + + describe('A gray square with the text "p5*js" written in its center.'); + } + +
+ +
+ + function setup() { + background(200); + + // Create a div element as a container. + let div = createDiv(); + + // Place the div at the center. + div.position(25, 35); + + // Create a span element. + let s1 = createSpan('p5'); + + // Create a second span element. + let s2 = createSpan('*'); + + // Set the second span's font color. + s2.style('color', 'deeppink'); + + // Create a third span element. + let s3 = createSpan('js'); + + // Add all the spans to the container div. + s1.parent(div); + s2.parent(div); + s3.parent(div); + + describe('A gray square with the text "p5*js" written in black at its center. The asterisk is pink.'); + } + +
+class: p5 +params: + - name: html + description: > +

inner HTML for the new <span></span> + element.

+ type: String + optional: true +return: + description: new p5.Element object. + type: p5.Element +chainable: false +--- + + +# createSpan diff --git a/src/content/reference/en/p5 copy/createStringDict.mdx b/src/content/reference/en/p5 copy/createStringDict.mdx new file mode 100644 index 0000000000..bc080c1276 --- /dev/null +++ b/src/content/reference/en/p5 copy/createStringDict.mdx @@ -0,0 +1,56 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/data/p5.TypedDict.js#L14 +title: createStringDict +module: Data +submodule: Dictionary +file: src/data/p5.TypedDict.js +description: | +

Creates a new instance of p5.StringDict using the key-value pair + or the object you provide.

+line: 14 +isConstructor: false +itemtype: method +example: + - |2- + +
+ + function setup() { + let myDictionary = createStringDict('p5', 'js'); + print(myDictionary.hasKey('p5')); // logs true to console + let anotherDictionary = createStringDict({ happy: 'coding' }); + print(anotherDictionary.hasKey('happy')); // logs true to console + } +
+class: p5 +return: + description: '' + type: p5.StringDict +overloads: + - line: 14 + params: + - name: key + description: '' + type: String + - name: value + description: '' + type: String + return: + description: '' + type: p5.StringDict + - line: 37 + params: + - name: object + description: | +

object

+ type: Object + return: + description: '' + type: p5.StringDict +chainable: false +--- + + +# createStringDict diff --git a/src/content/reference/en/p5 copy/createVector.mdx b/src/content/reference/en/p5 copy/createVector.mdx new file mode 100644 index 0000000000..07ca75ec36 --- /dev/null +++ b/src/content/reference/en/p5 copy/createVector.mdx @@ -0,0 +1,133 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/math.js#L10 +title: createVector +module: Math +submodule: Vector +file: src/math/math.js +description: > +

Creates a new p5.Vector object.

+ +

A vector can be thought of in different ways. In one view, a vector is like + + an arrow pointing in space. Vectors have both magnitude (length) and + + direction. This view is helpful for programming motion.

+ +

A vector's components determine its magnitude and direction. For example, + + calling createVector(3, 4) creates a new + + p5.Vector object with an x-component of + 3 and a + + y-component of 4. From the origin, this vector's tip is 3 units to the + + right and 4 units down.

+ +

p5.Vector objects are often used to + program + + motion because they simplify the math. For example, a moving ball has a + + position and a velocity. Position describes where the ball is in space. The + + ball's position vector extends from the origin to the ball's center. + + Velocity describes the ball's speed and the direction it's moving. If the + + ball is moving straight up, its velocity vector points straight up. Adding + + the ball's velocity vector to its position vector moves it, as in + + pos.add(vel). Vector math relies on methods inside the + + p5.Vector class.

+line: 10 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create p5.Vector objects. + let p1 = createVector(25, 25); + let p2 = createVector(50, 50); + let p3 = createVector(75, 75); + + // Draw the dots. + strokeWeight(5); + point(p1); + point(p2); + point(p3); + + describe('Three black dots form a diagonal line from top left to bottom right.'); + } + +
+ +
+ + let pos; + let vel; + + function setup() { + createCanvas(100, 100); + + // Create p5.Vector objects. + pos = createVector(50, 100); + vel = createVector(0, -1); + + describe('A black dot moves from bottom to top on a gray square. The dot reappears at the bottom when it reaches the top.'); + } + + function draw() { + background(200); + + // Add velocity to position. + pos.add(vel); + + // If the dot reaches the top of the canvas, + // restart from the bottom. + if (pos.y < 0) { + pos.y = 100; + } + + // Draw the dot. + strokeWeight(5); + point(pos); + } + +
+class: p5 +params: + - name: x + description: | +

x component of the vector.

+ type: Number + optional: true + - name: 'y' + description: | +

y component of the vector.

+ type: Number + optional: true + - name: z + description: | +

z component of the vector.

+ type: Number + optional: true +return: + description: new p5.Vector object. + type: p5.Vector +chainable: false +--- + + +# createVector diff --git a/src/content/reference/en/p5 copy/createVideo.mdx b/src/content/reference/en/p5 copy/createVideo.mdx new file mode 100644 index 0000000000..a7053f80a0 --- /dev/null +++ b/src/content/reference/en/p5 copy/createVideo.mdx @@ -0,0 +1,135 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L2115 +title: createVideo +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a element for simple audio/video playback.

+ +

createVideo() returns a new + + p5.MediaElement object. Videos are + shown by + + default. They can be hidden by calling video.hide() and drawn to + the + + canvas using image().

+ +

The first parameter, src, is the path the video. If a single + string is + + passed, as in '/assets/topsecret.mp4', a single video is loaded. + An array + + of strings can be used to load the same video in different formats. For + + example, ['/assets/topsecret.mp4', '/assets/topsecret.ogv', + '/assets/topsecret.webm']. + + This is useful for ensuring that the video can play across different browsers + with + + different capabilities. See + + MDN + + for more information about supported formats.

+ +

The second parameter, callback, is optional. It's a function + to call once + + the video is ready to play.

+line: 2115 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + noCanvas(); + + // Load a video and add it to the page. + // Note: this may not work in some browsers. + let video = createVideo('/assets/small.mp4'); + + // Show the default video controls. + video.showControls(); + + describe('A video of a toy robot with playback controls beneath it.'); + } + +
+ +
+ + function setup() { + noCanvas(); + + // Load a video and add it to the page. + // Provide an array options for different file formats. + let video = createVideo( + ['/assets/small.mp4', '/assets/small.ogv', '/assets/small.webm'] + ); + + // Show the default video controls. + video.showControls(); + + describe('A video of a toy robot with playback controls beneath it.'); + } + +
+ +
+ + let video; + + function setup() { + noCanvas(); + + // Load a video and add it to the page. + // Provide an array options for different file formats. + // Call mute() once the video loads. + video = createVideo( + ['/assets/small.mp4', '/assets/small.ogv', '/assets/small.webm'], + muteVideo + ); + + // Show the default video controls. + video.showControls(); + + describe('A video of a toy robot with playback controls beneath it.'); + } + + // Mute the video once it loads. + function muteVideo() { + video.volume(0); + } + +
+class: p5 +params: + - name: src + description: | +

path to a video file, or an array of paths for + supporting different browsers.

+ type: 'String|String[]' + - name: callback + description: | +

function to call once the video is ready to play.

+ type: Function + optional: true +return: + description: new p5.MediaElement object. + type: p5.MediaElement +chainable: false +--- + + +# createVideo diff --git a/src/content/reference/en/p5 copy/createWriter.mdx b/src/content/reference/en/p5 copy/createWriter.mdx new file mode 100644 index 0000000000..18928ff461 --- /dev/null +++ b/src/content/reference/en/p5 copy/createWriter.mdx @@ -0,0 +1,146 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1444 +title: createWriter +module: IO +submodule: Output +file: src/io/files.js +description: > +

Creates a new p5.PrintWriter + object.

+ +

p5.PrintWriter objects provide a + way to + + save a sequence of text data, called the print stream, to the user's + + computer. They're low-level objects that enable precise control of text + + output. Functions such as + + saveStrings() and + + saveJSON() are easier to use for simple + file + + saving.

+ +

The first parameter, filename, is the name of the file to be + written. If + + a string is passed, as in createWriter('words.txt'), a new + + p5.PrintWriter object will be + created that + + writes to a file named words.txt.

+ +

The second parameter, extension, is optional. If a string is + passed, as + + in createWriter('words', 'csv'), the first parameter will be + interpreted + + as the file name and the second parameter as the extension.

+line: 1444 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(12); + + // Display instructions. + text('Double-click to save', 5, 50, 90); + + describe('The text "Double-click to save" written in black on a gray background.'); + } + + // Save the file when the user double-clicks. + function doubleClicked() { + if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { + // Create a p5.PrintWriter object. + let myWriter = createWriter('xo.txt'); + + // Add some lines to the print stream. + myWriter.print('XOO'); + myWriter.print('OXO'); + myWriter.print('OOX'); + + // Save the file and close the print stream. + myWriter.close(); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(12); + + // Display instructions. + text('Double-click to save', 5, 50, 90); + + describe('The text "Double-click to save" written in black on a gray background.'); + } + + // Save the file when the user double-clicks. + function doubleClicked() { + if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { + // Create a p5.PrintWriter object. + // Use the file format .csv. + let myWriter = createWriter('mauna_loa_co2', 'csv'); + + // Add some lines to the print stream. + myWriter.print('date,ppm_co2'); + myWriter.print('1960-01-01,316.43'); + myWriter.print('1970-01-01,325.06'); + myWriter.print('1980-01-01,337.9'); + myWriter.print('1990-01-01,353.86'); + myWriter.print('2000-01-01,369.45'); + myWriter.print('2020-01-01,413.61'); + + // Save the file and close the print stream. + myWriter.close(); + } + } + +
+class: p5 +params: + - name: name + description: | +

name of the file to create.

+ type: String + - name: extension + description: | +

format to use for the file.

+ type: String + optional: true +return: + description: stream for writing data. + type: p5.PrintWriter +chainable: false +--- + + +# createWriter diff --git a/src/content/reference/en/p5 copy/cursor.mdx b/src/content/reference/en/p5 copy/cursor.mdx new file mode 100644 index 0000000000..8ada3a4379 --- /dev/null +++ b/src/content/reference/en/p5 copy/cursor.mdx @@ -0,0 +1,139 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L209 +title: cursor +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

Changes the cursor's appearance.

+ +

The first parameter, type, sets the type of cursor to display. + The + + built-in options are ARROW, CROSS, + HAND, MOVE, TEXT, and + WAIT. + + cursor() also recognizes standard CSS cursor properties passed as + + strings: 'help', 'wait', 'crosshair', + 'not-allowed', 'zoom-in', + + and 'grab'. If the path to an image is passed, as in + + cursor('/assets/target.png'), then the image will be used as the + cursor. + + Images must be in .cur, .gif, .jpg, .jpeg, or .png format and should be at + most 32 by 32 pixels large.

+ +

The parameters x and y are optional. If an image + is used for the + + cursor, x and y set the location pointed to within + the image. They are + + both 0 by default, so the cursor points to the image's top-left corner. + x + + and y must be less than the image's width and height, + respectively.

+line: 209 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A gray square. The cursor appears as crosshairs.'); + } + + function draw() { + background(200); + + // Set the cursor to crosshairs: + + cursor(CROSS); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A gray square divided into quadrants. The cursor image changes when the mouse moves to each quadrant.'); + } + + function draw() { + background(200); + + // Divide the canvas into quadrants. + line(50, 0, 50, 100); + line(0, 50, 100, 50); + + // Change cursor based on mouse position. + if (mouseX < 50 && mouseY < 50) { + cursor(CROSS); + } else if (mouseX > 50 && mouseY < 50) { + cursor('progress'); + } else if (mouseX > 50 && mouseY > 50) { + cursor('https://avatars0.githubusercontent.com/u/1617169?s=16'); + } else { + cursor('grab'); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('An image of three purple curves follows the mouse. The image shifts when the mouse is pressed.'); + } + + function draw() { + background(200); + + // Change the cursor's active spot + // when the mouse is pressed. + if (mouseIsPressed === true) { + cursor('https://avatars0.githubusercontent.com/u/1617169?s=16', 8, 8); + } else { + cursor('https://avatars0.githubusercontent.com/u/1617169?s=16'); + } + } + +
+class: p5 +params: + - name: type + description: | +

Built-in: either ARROW, CROSS, HAND, MOVE, TEXT, or WAIT. + Native CSS properties: 'grab', 'progress', and so on. + Path to cursor image.

+ type: String|Constant + - name: x + description: | +

horizontal active spot of the cursor.

+ type: Number + optional: true + - name: 'y' + description: | +

vertical active spot of the cursor.

+ type: Number + optional: true +chainable: false +--- + + +# cursor diff --git a/src/content/reference/en/p5 copy/curve.mdx b/src/content/reference/en/p5 copy/curve.mdx new file mode 100644 index 0000000000..9631e551e8 --- /dev/null +++ b/src/content/reference/en/p5 copy/curve.mdx @@ -0,0 +1,272 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L570 +title: curve +module: Shape +submodule: Curves +file: src/core/shape/curves.js +description: > +

Draws a curve using a Catmull-Rom spline.

+ +

Spline curves can form shapes and curves that slope gently. They’re like + + cables that are attached to a set of points. Splines are defined by two + + anchor points and two control points.

+ +

The first two parameters, x1 and y1, set the + first control point. This + + point isn’t drawn and can be thought of as the curve’s starting point.

+ +

The next four parameters, x2, y2, + x3, and y3, set the two anchor + + points. The anchor points are the start and end points of the curve’s + + visible segment.

+ +

The seventh and eighth parameters, x4 and y4, set + the last control + + point. This point isn’t drawn and can be thought of as the curve’s ending + + point.

+ +

Spline curves can also be drawn in 3D using WebGL mode. The 3D version of + + curve() has twelve arguments because each point has x-, y-, and + + z-coordinates.

+line: 570 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw a black spline curve. + noFill(); + strokeWeight(1); + stroke(0); + curve(5, 26, 73, 24, 73, 61, 15, 65); + + // Draw red spline curves from the anchor points to the control points. + stroke(255, 0, 0); + curve(5, 26, 5, 26, 73, 24, 73, 61); + curve(73, 24, 73, 61, 15, 65, 15, 65); + + // Draw the anchor points in black. + strokeWeight(5); + stroke(0); + point(73, 24); + point(73, 61); + + // Draw the control points in red. + stroke(255, 0, 0); + point(5, 26); + point(15, 65); + + describe( + 'A gray square with a curve drawn in three segments. The curve is a sideways U shape with red segments on top and bottom, and a black segment on the right. The endpoints of all the segments are marked with dots.' + ); + } + +
+ +
+ + let x1 = 5; + let y1 = 26; + let isChanging = false; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a curve drawn in three segments. The curve is a sideways U shape with red segments on top and bottom, and a black segment on the right. The endpoints of all the segments are marked with dots.' + ); + } + + function draw() { + background(200); + + // Draw a black spline curve. + noFill(); + strokeWeight(1); + stroke(0); + curve(x1, y1, 73, 24, 73, 61, 15, 65); + + // Draw red spline curves from the anchor points to the control points. + stroke(255, 0, 0); + curve(x1, y1, x1, y1, 73, 24, 73, 61); + curve(73, 24, 73, 61, 15, 65, 15, 65); + + // Draw the anchor points in black. + strokeWeight(5); + stroke(0); + point(73, 24); + point(73, 61); + + // Draw the control points in red. + stroke(255, 0, 0); + point(x1, y1); + point(15, 65); + } + + // Start changing the first control point if the user clicks near it. + function mousePressed() { + if (dist(mouseX, mouseY, x1, y1) < 20) { + isChanging = true; + } + } + + // Stop changing the first control point when the user releases the mouse. + function mouseReleased() { + isChanging = false; + } + + // Update the first control point while the user drags the mouse. + function mouseDragged() { + if (isChanging === true) { + x1 = mouseX; + y1 = mouseY; + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background('skyblue'); + + // Draw the red balloon. + fill('red'); + curve(-150, 275, 50, 60, 50, 60, 250, 275); + + // Draw the balloon string. + line(50, 60, 50, 80); + + describe('A red balloon in a blue sky.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A red balloon in a blue sky.'); + } + + function draw() { + background('skyblue'); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Draw the red balloon. + fill('red'); + curve(-200, 225, 0, 0, 10, 0, 0, 10, 0, 200, 225, 0); + + // Draw the balloon string. + line(0, 10, 0, 0, 30, 0); + } + +
+class: p5 +overloads: + - line: 570 + params: + - name: x1 + description: | +

x-coordinate of the first control point.

+ type: Number + - name: y1 + description: | +

y-coordinate of the first control point.

+ type: Number + - name: x2 + description: | +

x-coordinate of the first anchor point.

+ type: Number + - name: y2 + description: | +

y-coordinate of the first anchor point.

+ type: Number + - name: x3 + description: | +

x-coordinate of the second anchor point.

+ type: Number + - name: y3 + description: | +

y-coordinate of the second anchor point.

+ type: Number + - name: x4 + description: | +

x-coordinate of the second control point.

+ type: Number + - name: y4 + description: | +

y-coordinate of the second control point.

+ type: Number + chainable: 1 + - line: 746 + params: + - name: x1 + description: '' + type: Number + - name: y1 + description: '' + type: Number + - name: z1 + description: | +

z-coordinate of the first control point.

+ type: Number + - name: x2 + description: '' + type: Number + - name: y2 + description: '' + type: Number + - name: z2 + description: | +

z-coordinate of the first anchor point.

+ type: Number + - name: x3 + description: '' + type: Number + - name: y3 + description: '' + type: Number + - name: z3 + description: | +

z-coordinate of the second anchor point.

+ type: Number + - name: x4 + description: '' + type: Number + - name: y4 + description: '' + type: Number + - name: z4 + description: | +

z-coordinate of the second control point.

+ type: Number + chainable: 1 +chainable: true +--- + + +# curve diff --git a/src/content/reference/en/p5 copy/curveDetail.mdx b/src/content/reference/en/p5 copy/curveDetail.mdx new file mode 100644 index 0000000000..796ca5a026 --- /dev/null +++ b/src/content/reference/en/p5 copy/curveDetail.mdx @@ -0,0 +1,117 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L772 +title: curveDetail +module: Shape +submodule: Curves +file: src/core/shape/curves.js +description: > +

Sets the number of segments used to draw spline curves in WebGL mode.

+ +

In WebGL mode, smooth shapes are drawn using many flat segments. Adding + + more flat segments makes shapes appear smoother.

+ +

The parameter, detail, is the number of segments to use while + drawing a + + spline curve. For example, calling curveDetail(5) will use 5 + segments to + + draw curves with the curve() function. By + + default,detail is 20.

+ +

Note: curveDetail() has no effect in 2D mode.

+line: 772 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw a black spline curve. + noFill(); + strokeWeight(1); + stroke(0); + curve(5, 26, 73, 24, 73, 61, 15, 65); + + // Draw red spline curves from the anchor points to the control points. + stroke(255, 0, 0); + curve(5, 26, 5, 26, 73, 24, 73, 61); + curve(73, 24, 73, 61, 15, 65, 15, 65); + + // Draw the anchor points in black. + strokeWeight(5); + stroke(0); + point(73, 24); + point(73, 61); + + // Draw the control points in red. + stroke(255, 0, 0); + point(5, 26); + point(15, 65); + + describe( + 'A gray square with a curve drawn in three segments. The curve is a sideways U shape with red segments on top and bottom, and a black segment on the right. The endpoints of all the segments are marked with dots.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + // Set the curveDetail() to 3. + curveDetail(3); + + // Draw a black spline curve. + noFill(); + strokeWeight(1); + stroke(0); + curve(-45, -24, 0, 23, -26, 0, 23, 11, 0, -35, 15, 0); + + // Draw red spline curves from the anchor points to the control points. + stroke(255, 0, 0); + curve(-45, -24, 0, -45, -24, 0, 23, -26, 0, 23, 11, 0); + curve(23, -26, 0, 23, 11, 0, -35, 15, 0, -35, 15, 0); + + // Draw the anchor points in black. + strokeWeight(5); + stroke(0); + point(23, -26); + point(23, 11); + + // Draw the control points in red. + stroke(255, 0, 0); + point(-45, -24); + point(-35, 15); + + describe( + 'A gray square with a jagged curve drawn in three segments. The curve is a sideways U shape with red segments on top and bottom, and a black segment on the right. The endpoints of all the segments are marked with dots.' + ); + } + +
+class: p5 +params: + - name: resolution + description: | +

number of segments to use. Defaults to 20.

+ type: Number +chainable: true +--- + + +# curveDetail diff --git a/src/content/reference/en/p5 copy/curvePoint.mdx b/src/content/reference/en/p5 copy/curvePoint.mdx new file mode 100644 index 0000000000..761b468ca6 --- /dev/null +++ b/src/content/reference/en/p5 copy/curvePoint.mdx @@ -0,0 +1,160 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L930 +title: curvePoint +module: Shape +submodule: Curves +file: src/core/shape/curves.js +description: > +

Calculates coordinates along a spline curve using interpolation.

+ +

curvePoint() calculates coordinates along a spline curve using + the + + anchor and control points. It expects points in the same order as the + + curve() function. curvePoint() + works one axis + + at a time. Passing the anchor and control points' x-coordinates will + + calculate the x-coordinate of a point on the curve. Passing the anchor and + + control points' y-coordinates will calculate the y-coordinate of a point on + + the curve.

+ +

The first parameter, a, is the coordinate of the first control + point.

+ +

The second and third parameters, b and c, are the + coordinates of the + + anchor points.

+ +

The fourth parameter, d, is the coordinate of the last control + point.

+ +

The fifth parameter, t, is the amount to interpolate along the + curve. 0 + + is the first anchor point, 1 is the second anchor point, and 0.5 is halfway + + between them.

+line: 930 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Set the coordinates for the curve's anchor and control points. + let x1 = 5; + let y1 = 26; + let x2 = 73; + let y2 = 24; + let x3 = 73; + let y3 = 61; + let x4 = 15; + let y4 = 65; + + // Draw the curve. + noFill(); + curve(x1, y1, x2, y2, x3, y3, x4, y4); + + // Draw circles along the curve's path. + fill(255); + + // Top. + let x = curvePoint(x1, x2, x3, x4, 0); + let y = curvePoint(y1, y2, y3, y4, 0); + circle(x, y, 5); + + // Center. + x = curvePoint(x1, x2, x3, x4, 0.5); + y = curvePoint(y1, y2, y3, y4, 0.5); + circle(x, y, 5); + + // Bottom. + x = curvePoint(x1, x2, x3, x4, 1); + y = curvePoint(y1, y2, y3, y4, 1); + circle(x, y, 5); + + describe('A black curve on a gray square. The endpoints and center of the curve are marked with white circles.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A black curve on a gray square. A white circle moves back and forth along the curve.'); + } + + function draw() { + background(200); + + // Set the coordinates for the curve's anchor and control points. + let x1 = 5; + let y1 = 26; + let x2 = 73; + let y2 = 24; + let x3 = 73; + let y3 = 61; + let x4 = 15; + let y4 = 65; + + // Draw the curve. + noFill(); + curve(x1, y1, x2, y2, x3, y3, x4, y4); + + // Calculate the circle's coordinates. + let t = 0.5 * sin(frameCount * 0.01) + 0.5; + let x = curvePoint(x1, x2, x3, x4, t); + let y = curvePoint(y1, y2, y3, y4, t); + + // Draw the circle. + fill(255); + circle(x, y, 5); + } + +
+class: p5 +params: + - name: a + description: | +

coordinate of first control point.

+ type: Number + - name: b + description: | +

coordinate of first anchor point.

+ type: Number + - name: c + description: | +

coordinate of second anchor point.

+ type: Number + - name: d + description: | +

coordinate of second control point.

+ type: Number + - name: t + description: | +

amount to interpolate between 0 and 1.

+ type: Number +return: + description: coordinate of a point on the curve. + type: Number +chainable: false +--- + + +# curvePoint diff --git a/src/content/reference/en/p5 copy/curveTangent.mdx b/src/content/reference/en/p5 copy/curveTangent.mdx new file mode 100644 index 0000000000..005ade9aab --- /dev/null +++ b/src/content/reference/en/p5 copy/curveTangent.mdx @@ -0,0 +1,153 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L1054 +title: curveTangent +module: Shape +submodule: Curves +file: src/core/shape/curves.js +description: > +

Calculates coordinates along a line that's tangent to a spline curve.

+ +

Tangent lines skim the surface of a curve. A tangent line's slope equals + + the curve's slope at the point where it intersects.

+ +

curveTangent() calculates coordinates along a tangent line + using the + + spline curve's anchor and control points. It expects points in the same + + order as the curve() function. + curveTangent() + + works one axis at a time. Passing the anchor and control points' + + x-coordinates will calculate the x-coordinate of a point on the tangent + + line. Passing the anchor and control points' y-coordinates will calculate + + the y-coordinate of a point on the tangent line.

+ +

The first parameter, a, is the coordinate of the first control + point.

+ +

The second and third parameters, b and c, are the + coordinates of the + + anchor points.

+ +

The fourth parameter, d, is the coordinate of the last control + point.

+ +

The fifth parameter, t, is the amount to interpolate along the + curve. 0 + + is the first anchor point, 1 is the second anchor point, and 0.5 is halfway + + between them.

+line: 1054 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Set the coordinates for the curve's anchor and control points. + let x1 = 5; + let y1 = 26; + let x2 = 73; + let y2 = 24; + let x3 = 73; + let y3 = 61; + let x4 = 15; + let y4 = 65; + + // Draw the curve. + noFill(); + curve(x1, y1, x2, y2, x3, y3, x4, y4); + + // Draw tangents along the curve's path. + fill(255); + + // Top circle. + stroke(0); + let x = curvePoint(x1, x2, x3, x4, 0); + let y = curvePoint(y1, y2, y3, y4, 0); + circle(x, y, 5); + + // Top tangent line. + // Scale the tangent point to draw a shorter line. + stroke(255, 0, 0); + let tx = 0.2 * curveTangent(x1, x2, x3, x4, 0); + let ty = 0.2 * curveTangent(y1, y2, y3, y4, 0); + line(x + tx, y + ty, x - tx, y - ty); + + // Center circle. + stroke(0); + x = curvePoint(x1, x2, x3, x4, 0.5); + y = curvePoint(y1, y2, y3, y4, 0.5); + circle(x, y, 5); + + // Center tangent line. + // Scale the tangent point to draw a shorter line. + stroke(255, 0, 0); + tx = 0.2 * curveTangent(x1, x2, x3, x4, 0.5); + ty = 0.2 * curveTangent(y1, y2, y3, y4, 0.5); + line(x + tx, y + ty, x - tx, y - ty); + + // Bottom circle. + stroke(0); + x = curvePoint(x1, x2, x3, x4, 1); + y = curvePoint(y1, y2, y3, y4, 1); + circle(x, y, 5); + + // Bottom tangent line. + // Scale the tangent point to draw a shorter line. + stroke(255, 0, 0); + tx = 0.2 * curveTangent(x1, x2, x3, x4, 1); + ty = 0.2 * curveTangent(y1, y2, y3, y4, 1); + line(x + tx, y + ty, x - tx, y - ty); + + describe( + 'A black curve on a gray square. A white circle moves back and forth along the curve.' + ); + } + +
+class: p5 +params: + - name: a + description: | +

coordinate of first control point.

+ type: Number + - name: b + description: | +

coordinate of first anchor point.

+ type: Number + - name: c + description: | +

coordinate of second anchor point.

+ type: Number + - name: d + description: | +

coordinate of second control point.

+ type: Number + - name: t + description: | +

amount to interpolate between 0 and 1.

+ type: Number +return: + description: coordinate of a point on the tangent line. + type: Number +chainable: false +--- + + +# curveTangent diff --git a/src/content/reference/en/p5 copy/curveTightness.mdx b/src/content/reference/en/p5 copy/curveTightness.mdx new file mode 100644 index 0000000000..506066be18 --- /dev/null +++ b/src/content/reference/en/p5 copy/curveTightness.mdx @@ -0,0 +1,77 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L875 +title: curveTightness +module: Shape +submodule: Curves +file: src/core/shape/curves.js +description: > +

Adjusts the way curve() and + + curveVertex() draw.

+ +

Spline curves are like cables that are attached to a set of points. + + curveTightness() adjusts how tightly the cable is attached to the + points.

+ +

The parameter, tightness, determines how the curve fits to the + vertex + + points. By default, tightness is set to 0. Setting tightness to + 1, + + as in curveTightness(1), connects the curve's points using + straight + + lines. Values in the range from –5 to 5 deform curves while leaving them + + recognizable.

+line: 875 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Move the mouse left and right to see the curve change. + + function setup() { + createCanvas(100, 100); + + describe('A black curve forms a sideways U shape. The curve deforms as the user moves the mouse from left to right'); + } + + function draw() { + background(200); + + // Set the curve's tightness using the mouse. + let t = map(mouseX, 0, 100, -5, 5, true); + curveTightness(t); + + // Draw the curve. + noFill(); + beginShape(); + curveVertex(10, 26); + curveVertex(10, 26); + curveVertex(83, 24); + curveVertex(83, 61); + curveVertex(25, 65); + curveVertex(25, 65); + endShape(); + } + +
+class: p5 +params: + - name: amount + description: | +

amount of tightness.

+ type: Number +chainable: true +--- + + +# curveTightness diff --git a/src/content/reference/en/p5 copy/curveVertex.mdx b/src/content/reference/en/p5 copy/curveVertex.mdx new file mode 100644 index 0000000000..3d928fc0ce --- /dev/null +++ b/src/content/reference/en/p5 copy/curveVertex.mdx @@ -0,0 +1,407 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L832 +title: curveVertex +module: Shape +submodule: Vertex +file: src/core/shape/vertex.js +description: > +

Adds a spline curve segment to a custom shape.

+ +

curveVertex() adds a curved segment to custom shapes. The + spline curves + + it creates are defined like those made by the + + curve() function. + curveVertex() must be called + + between the beginShape() and + + endShape() functions.

+ +

Spline curves can form shapes and curves that slope gently. They’re like + + cables that are attached to a set of points. Splines are defined by two + + anchor points and two control points. curveVertex() must be + called at + + least four times between + + beginShape() and + + endShape() in order to draw a curve:

+ +
beginShape();
+
+
+  // Add the first control point.
+
+  curveVertex(84, 91);
+
+
+  // Add the anchor points to draw between.
+
+  curveVertex(68, 19);
+
+  curveVertex(21, 17);
+
+
+  // Add the second control point.
+
+  curveVertex(32, 91);
+
+
+  endShape();
+
+  
+ +

The code snippet above would only draw the curve between the anchor points, + + similar to the curve() function. The + segments + + between the control and anchor points can be drawn by calling + + curveVertex() with the coordinates of the control points:

+ +
beginShape();
+
+
+  // Add the first control point and draw a segment to it.
+
+  curveVertex(84, 91);
+
+  curveVertex(84, 91);
+
+
+  // Add the anchor points to draw between.
+
+  curveVertex(68, 19);
+
+  curveVertex(21, 17);
+
+
+  // Add the second control point.
+
+  curveVertex(32, 91);
+
+
+  // Uncomment the next line to draw the segment to the second control point.
+
+  // curveVertex(32, 91);
+
+
+  endShape();
+
+  
+ +

The first two parameters, x and y, set the + vertex’s location. For + + example, calling curveVertex(10, 10) adds a point to the curve at + + (10, 10).

+ +

Spline curves can also be drawn in 3D using WebGL mode. The 3D version of + + curveVertex() has three arguments because each point has x-, y-, + and + + z-coordinates. By default, the vertex’s z-coordinate is set to 0.

+ +

Note: curveVertex() won’t work when an argument is passed to + + beginShape().

+line: 832 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the shape. + noFill(); + strokeWeight(1); + + // Start drawing the shape. + beginShape(); + + // Add the first control point. + curveVertex(32, 91); + + // Add the anchor points. + curveVertex(21, 17); + curveVertex(68, 19); + + // Add the second control point. + curveVertex(84, 91); + + // Stop drawing the shape. + endShape(); + + // Style the anchor and control points. + strokeWeight(5); + + // Draw the anchor points in black. + stroke(0); + point(21, 17); + point(68, 19); + + // Draw the control points in red. + stroke(255, 0, 0); + point(32, 91); + point(84, 91); + + describe( + 'A black curve drawn on a gray background. The curve has black dots at its ends. Two red dots appear near the bottom of the canvas.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the shape. + noFill(); + strokeWeight(1); + + // Start drawing the shape. + beginShape(); + + // Add the first control point and draw a segment to it. + curveVertex(32, 91); + curveVertex(32, 91); + + // Add the anchor points. + curveVertex(21, 17); + curveVertex(68, 19); + + // Add the second control point. + curveVertex(84, 91); + + // Stop drawing the shape. + endShape(); + + // Style the anchor and control points. + strokeWeight(5); + + // Draw the anchor points in black. + stroke(0); + point(21, 17); + point(68, 19); + + // Draw the control points in red. + stroke(255, 0, 0); + point(32, 91); + point(84, 91); + + describe( + 'A black curve drawn on a gray background. The curve passes through one red dot and two black dots. Another red dot appears near the bottom of the canvas.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the shape. + noFill(); + strokeWeight(1); + + // Start drawing the shape. + beginShape(); + + // Add the first control point and draw a segment to it. + curveVertex(32, 91); + curveVertex(32, 91); + + // Add the anchor points. + curveVertex(21, 17); + curveVertex(68, 19); + + // Add the second control point and draw a segment to it. + curveVertex(84, 91); + curveVertex(84, 91); + + // Stop drawing the shape. + endShape(); + + // Style the anchor and control points. + strokeWeight(5); + + // Draw the anchor points in black. + stroke(0); + point(21, 17); + point(68, 19); + + // Draw the control points in red. + stroke(255, 0, 0); + point(32, 91); + point(84, 91); + + describe( + 'A black U curve drawn upside down on a gray background. The curve passes from one red dot through two black dots and ends at another red dot.' + ); + } + +
+ +
+ + // Click the mouse near the red dot in the bottom-left corner + // and drag to change the curve's shape. + + let x1 = 32; + let y1 = 91; + let isChanging = false; + + function setup() { + createCanvas(100, 100); + + describe( + 'A black U curve drawn upside down on a gray background. The curve passes from one red dot through two black dots and ends at another red dot.' + ); + } + + function draw() { + background(200); + + // Style the shape. + noFill(); + stroke(0); + strokeWeight(1); + + // Start drawing the shape. + beginShape(); + + // Add the first control point and draw a segment to it. + curveVertex(x1, y1); + curveVertex(x1, y1); + + // Add the anchor points. + curveVertex(21, 17); + curveVertex(68, 19); + + // Add the second control point and draw a segment to it. + curveVertex(84, 91); + curveVertex(84, 91); + + // Stop drawing the shape. + endShape(); + + // Style the anchor and control points. + strokeWeight(5); + + // Draw the anchor points in black. + stroke(0); + point(21, 17); + point(68, 19); + + // Draw the control points in red. + stroke(255, 0, 0); + point(x1, y1); + point(84, 91); + } + + // Start changing the first control point if the user clicks near it. + function mousePressed() { + if (dist(mouseX, mouseY, x1, y1) < 20) { + isChanging = true; + } + } + + // Stop changing the first control point when the user releases the mouse. + function mouseReleased() { + isChanging = false; + } + + // Update the first control point while the user drags the mouse. + function mouseDragged() { + if (isChanging === true) { + x1 = mouseX; + y1 = mouseY; + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + beginShape(); + + // Add the first control point and draw a segment to it. + curveVertex(32, 91); + curveVertex(32, 91); + + // Add the anchor points. + curveVertex(21, 17); + curveVertex(68, 19); + + // Add the second control point. + curveVertex(84, 91); + curveVertex(84, 91); + + // Stop drawing the shape. + endShape(); + + describe('A ghost shape drawn in white on a gray background.'); + } + +
+class: p5 +overloads: + - line: 832 + params: + - name: x + description: | +

x-coordinate of the vertex

+ type: Number + - name: 'y' + description: | +

y-coordinate of the vertex

+ type: Number + chainable: 1 + - line: 1160 + params: + - name: x + description: '' + type: Number + - name: 'y' + description: '' + type: Number + - name: z + description: | +

z-coordinate of the vertex.

+ type: Number + optional: true + chainable: 1 +chainable: true +--- + + +# curveVertex diff --git a/src/content/reference/en/p5 copy/cylinder.mdx b/src/content/reference/en/p5 copy/cylinder.mdx new file mode 100644 index 0000000000..dd81cd687f --- /dev/null +++ b/src/content/reference/en/p5 copy/cylinder.mdx @@ -0,0 +1,282 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L1477 +title: cylinder +module: Shape +submodule: 3D Primitives +file: src/webgl/3d_primitives.js +description: > +

Draws a cylinder.

+ +

A cylinder is a 3D shape with triangular faces that connect a flat bottom + + to a flat top. Cylinders with few faces look like boxes. Cylinders with + + many faces have smooth surfaces.

+ +

The first parameter, radius, is optional. If a + Number is passed, as in + + cylinder(20), it sets the radius of the cylinder’s base. By + default, + + radius is 50.

+ +

The second parameter, height, is also optional. If a + Number is passed, + + as in cylinder(20, 30), it sets the cylinder’s height. By + default, + + height is set to the cylinder’s radius.

+ +

The third parameter, detailX, is also optional. If a + Number is passed, + + as in cylinder(20, 30, 5), it sets the number of edges used to + form the + + cylinder's top and bottom. Using more edges makes the top and bottom look + + more like circles. By default, detailX is 24.

+ +

The fourth parameter, detailY, is also optional. If a + Number is passed, + + as in cylinder(20, 30, 5, 2), it sets the number of triangle + subdivisions + + to use along the y-axis, between cylinder's the top and bottom. All 3D + + shapes are made by connecting triangles to form their surfaces. By default, + + detailY is 1.

+ +

The fifth parameter, bottomCap, is also optional. If a + false is passed, + + as in cylinder(20, 30, 5, 2, false) the cylinder’s bottom won’t + be drawn. + + By default, bottomCap is true.

+ +

The sixth parameter, topCap, is also optional. If a + false is passed, as + + in cylinder(20, 30, 5, 2, false, false) the cylinder’s top won’t + be + + drawn. By default, topCap is true.

+ +

Note: cylinder() can only be used in WebGL mode.

+line: 1477 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cylinder on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cylinder. + cylinder(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cylinder on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cylinder. + // Set its radius and height to 30. + cylinder(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cylinder on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cylinder. + // Set its radius to 30 and height to 50. + cylinder(30, 50); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white box on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cylinder. + // Set its radius to 30 and height to 50. + // Set its detailX to 5. + cylinder(30, 50, 5); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cylinder on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cylinder. + // Set its radius to 30 and height to 50. + // Set its detailX to 24 and detailY to 2. + cylinder(30, 50, 24, 2); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cylinder on a gray background. Its top is missing.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cylinder. + // Set its radius to 30 and height to 50. + // Set its detailX to 24 and detailY to 1. + // Don't draw its bottom. + cylinder(30, 50, 24, 1, false); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cylinder on a gray background. Its top and bottom are missing.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cylinder. + // Set its radius to 30 and height to 50. + // Set its detailX to 24 and detailY to 1. + // Don't draw its bottom or top. + cylinder(30, 50, 24, 1, false, false); + } + +
+class: p5 +params: + - name: radius + description: | +

radius of the cylinder. Defaults to 50.

+ type: Number + optional: true + - name: height + description: > +

height of the cylinder. Defaults to the value of + radius.

+ type: Number + optional: true + - name: detailX + description: | +

number of edges along the top and bottom. Defaults to 24.

+ type: Integer + optional: true + - name: detailY + description: | +

number of triangle subdivisions along the y-axis. Defaults to 1.

+ type: Integer + optional: true + - name: bottomCap + description: > +

whether to draw the cylinder's bottom. Defaults to + true.

+ type: Boolean + optional: true + - name: topCap + description: | +

whether to draw the cylinder's top. Defaults to true.

+ type: Boolean + optional: true +chainable: true +--- + + +# cylinder diff --git a/src/content/reference/en/p5 copy/day.mdx b/src/content/reference/en/p5 copy/day.mdx new file mode 100644 index 0000000000..f029fcb983 --- /dev/null +++ b/src/content/reference/en/p5 copy/day.mdx @@ -0,0 +1,47 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L10 +title: day +module: IO +submodule: Time & Date +file: src/utilities/time_date.js +description: | +

Returns the current day as a number from 1–31.

+line: 10 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Get the current day. + let d = day(); + + // Style the text. + textAlign(LEFT, CENTER); + textSize(12); + textFont('Courier New'); + + // Display the day. + text(`Current day: ${d}`, 20, 50, 60); + + describe(`The text 'Current day: ${d}' written in black on a gray background.`); + } + +
+class: p5 +return: + description: current day between 1 and 31. + type: Integer +chainable: false +--- + + +# day diff --git a/src/content/reference/en/p5 copy/debugMode.mdx b/src/content/reference/en/p5 copy/debugMode.mdx new file mode 100644 index 0000000000..19ccdfb63f --- /dev/null +++ b/src/content/reference/en/p5 copy/debugMode.mdx @@ -0,0 +1,362 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/interaction.js#L471 +title: debugMode +module: 3D +submodule: Interaction +file: src/webgl/interaction.js +description: > +

Adds a grid and an axes icon to clarify orientation in 3D sketches.

+ +

debugMode() adds a grid that shows where the “ground” is in a + sketch. By + + default, the grid will run through the origin (0, 0, 0) of the + sketch + + along the XZ plane. debugMode() also adds an axes icon that + points along + + the positive x-, y-, and z-axes. Calling debugMode() displays the + grid + + and axes icon with their default size and position.

+ +

There are four ways to call debugMode() with optional + parameters to + + customize the debugging environment.

+ +

The first way to call debugMode() has one parameter, + mode. If the + + system constant GRID is passed, as in + debugMode(GRID), then the grid + + will be displayed and the axes icon will be hidden. If the constant + AXES + + is passed, as in debugMode(AXES), then the axes icon will be + displayed + + and the grid will be hidden.

+ +

The second way to call debugMode() has six parameters. The + first + + parameter, mode, selects either GRID or + AXES to be displayed. The + + next five parameters, gridSize, gridDivisions, + xOff, yOff, and + + zOff are optional. They’re numbers that set the appearance of the + grid + + (gridSize and gridDivisions) and the placement of + the axes icon + + (xOff, yOff, and zOff). For example, + calling + + debugMode(20, 5, 10, 10, 10) sets the gridSize to 20 + pixels, the number + + of gridDivisions to 5, and offsets the axes icon by 10 pixels + along the + + x-, y-, and z-axes.

+ +

The third way to call debugMode() has five parameters. The + first + + parameter, mode, selects either GRID or + AXES to be displayed. The + + next four parameters, axesSize, xOff, + yOff, and zOff are optional. + + They’re numbers that set the appearance of the size of the axes icon + + (axesSize) and its placement (xOff, + yOff, and zOff).

+ +

The fourth way to call debugMode() has nine optional + parameters. The + + first five parameters, gridSize, gridDivisions, + gridXOff, gridYOff, + + and gridZOff are numbers that set the appearance of the grid. For + + example, calling debugMode(100, 5, 0, 0, 0) sets the + gridSize to 100, + + the number of gridDivisions to 5, and sets all the offsets to 0 + so that + + the grid is centered at the origin. The next four parameters, + axesSize, + + xOff, yOff, and zOff are numbers that + set the appearance of the size + + of the axes icon (axesSize) and its placement + (axesXOff, axesYOff, + + and axesZOff). For example, calling + + debugMode(100, 5, 0, 0, 0, 50, 10, 10, 10) sets the + gridSize to 100, + + the number of gridDivisions to 5, and sets all the offsets to 0 + so that + + the grid is centered at the origin. It then sets the axesSize to + 50 and + + offsets the icon 10 pixels along each axis.

+line: 471 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + // Enable debug mode. + debugMode(); + + describe('A multicolor box on a gray background. A grid and axes icon are displayed near the box.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the box. + normalMaterial(); + + // Draw the box. + box(20, 40); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + // Enable debug mode. + // Only display the axes icon. + debugMode(AXES); + + describe('A multicolor box on a gray background. A grid and axes icon are displayed near the box.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the box. + normalMaterial(); + + // Draw the box. + box(20, 40); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + // Enable debug mode. + // Only display the grid and customize it: + // - size: 50 + // - divisions: 10 + // - offsets: 0, 20, 0 + debugMode(GRID, 50, 10, 0, 20, 0); + + describe('A multicolor box on a gray background. A grid is displayed below the box.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the box. + normalMaterial(); + + // Draw the box. + box(20, 40); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + // Enable debug mode. + // Display the grid and axes icon and customize them: + // Grid + // ---- + // - size: 50 + // - divisions: 10 + // - offsets: 0, 20, 0 + // Axes + // ---- + // - size: 50 + // - offsets: 0, 0, 0 + debugMode(50, 10, 0, 20, 0, 50, 0, 0, 0); + + describe('A multicolor box on a gray background. A grid is displayed below the box. An axes icon is displayed at the center of the box.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the box. + normalMaterial(); + + // Draw the box. + box(20, 40); + } + +
+class: p5 +overloads: + - line: 471 + params: [] + - line: 650 + params: + - name: mode + description: | +

either GRID or AXES

+ type: Constant + - line: 655 + params: + - name: mode + description: '' + type: Constant + - name: gridSize + description: | +

side length of the grid.

+ type: Number + optional: true + - name: gridDivisions + description: | +

number of divisions in the grid.

+ type: Number + optional: true + - name: xOff + description: | +

offset from origin along the x-axis.

+ type: Number + optional: true + - name: yOff + description: | +

offset from origin along the y-axis.

+ type: Number + optional: true + - name: zOff + description: | +

offset from origin along the z-axis.

+ type: Number + optional: true + - line: 665 + params: + - name: mode + description: '' + type: Constant + - name: axesSize + description: | +

length of axes icon markers.

+ type: Number + optional: true + - name: xOff + description: '' + type: Number + optional: true + - name: yOff + description: '' + type: Number + optional: true + - name: zOff + description: '' + type: Number + optional: true + - line: 674 + params: + - name: gridSize + description: '' + type: Number + optional: true + - name: gridDivisions + description: '' + type: Number + optional: true + - name: gridXOff + description: | +

grid offset from the origin along the x-axis.

+ type: Number + optional: true + - name: gridYOff + description: | +

grid offset from the origin along the y-axis.

+ type: Number + optional: true + - name: gridZOff + description: | +

grid offset from the origin along the z-axis.

+ type: Number + optional: true + - name: axesSize + description: '' + type: Number + optional: true + - name: axesXOff + description: | +

axes icon offset from the origin along the x-axis.

+ type: Number + optional: true + - name: axesYOff + description: | +

axes icon offset from the origin along the y-axis.

+ type: Number + optional: true + - name: axesZOff + description: | +

axes icon offset from the origin along the z-axis.

+ type: Number + optional: true +chainable: false +--- + + +# debugMode diff --git a/src/content/reference/en/p5 copy/degrees.mdx b/src/content/reference/en/p5 copy/degrees.mdx new file mode 100644 index 0000000000..730b361384 --- /dev/null +++ b/src/content/reference/en/p5 copy/degrees.mdx @@ -0,0 +1,53 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L485 +title: degrees +module: Math +submodule: Trigonometry +file: src/math/trigonometry.js +description: | +

Converts an angle measured in radians to its value in degrees.

+

Degrees and radians are both units for measuring angles. There are 360˚ in + one full rotation. A full rotation is 2 × π (about 6.28) radians.

+

The same angle can be expressed in with either unit. For example, 90° is a + quarter of a full rotation. The same angle is 2 × π ÷ 4 + (about 1.57) radians.

+line: 485 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Calculate the angle conversion. + let rad = QUARTER_PI; + let deg = degrees(rad); + + // Display the conversion. + text(`${round(rad, 2)} rad = ${deg}˚`, 10, 50); + + describe('The text "0.79 rad = 45˚".'); + } + +
+class: p5 +params: + - name: radians + description: | +

radians value to convert to degrees.

+ type: Number +return: + description: converted angle. + type: Number +chainable: false +--- + + +# degrees diff --git a/src/content/reference/en/p5 copy/deltaTime.mdx b/src/content/reference/en/p5 copy/deltaTime.mdx new file mode 100644 index 0000000000..0915a014c2 --- /dev/null +++ b/src/content/reference/en/p5 copy/deltaTime.mdx @@ -0,0 +1,68 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L124 +title: deltaTime +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

A Number variable that tracks the number of milliseconds it + took to draw + + the last frame.

+ +

deltaTime contains the amount of time it took + + draw() to execute during the previous frame. + It's + + useful for simulating physics.

+line: 124 +isConstructor: false +itemtype: property +example: + - |- + +
+ + let x = 0; + let speed = 0.05; + + function setup() { + createCanvas(100, 100); + + // Set the frameRate to 30. + frameRate(30); + + describe('A white circle moves from left to right on a gray background. It reappears on the left side when it reaches the right side.'); + } + + function draw() { + background(200); + + // Use deltaTime to calculate + // a change in position. + let deltaX = speed * deltaTime; + + // Update the x variable. + x += deltaX; + + // Reset x to 0 if it's + // greater than 100. + if (x > 100) { + x = 0; + } + + // Use x to set the circle's + // position. + circle(x, 50, 20); + } + +
+class: p5 +type: Integer +--- + + +# deltaTime diff --git a/src/content/reference/en/p5 copy/describe.mdx b/src/content/reference/en/p5 copy/describe.mdx new file mode 100644 index 0000000000..dee815b9f1 --- /dev/null +++ b/src/content/reference/en/p5 copy/describe.mdx @@ -0,0 +1,137 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/accessibility/describe.js#L18 +title: describe +module: Environment +submodule: Environment +file: src/accessibility/describe.js +description: > +

Creates a screen reader-accessible description of the canvas.

+ +

The first parameter, text, is the description of the + canvas.

+ +

The second parameter, display, is optional. It determines how + the + + description is displayed. If LABEL is passed, as in + + describe('A description.', LABEL), the description will be + visible in + + a div element next to the canvas. If FALLBACK is passed, as in + + describe('A description.', FALLBACK), the description will only + be + + visible to screen readers. This is the default mode.

+ +

Read + + Writing + accessible canvas descriptions + + to learn more about making sketches accessible.

+line: 18 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + background('pink'); + + // Draw a heart. + fill('red'); + noStroke(); + circle(67, 67, 20); + circle(83, 67, 20); + triangle(91, 73, 75, 95, 59, 73); + + // Add a general description of the canvas. + describe('A pink square with a red heart in the bottom-right corner.'); + } + +
+ +
+ + function setup() { + background('pink'); + + // Draw a heart. + fill('red'); + noStroke(); + circle(67, 67, 20); + circle(83, 67, 20); + triangle(91, 73, 75, 95, 59, 73); + + // Add a general description of the canvas + // and display it for debugging. + describe('A pink square with a red heart in the bottom-right corner.', LABEL); + } + +
+ +
+ + function draw() { + background(200); + + // The expression + // frameCount % 100 + // causes x to increase from 0 + // to 99, then restart from 0. + let x = frameCount % 100; + + // Draw the circle. + fill(0, 255, 0); + circle(x, 50, 40); + + // Add a general description of the canvas. + describe(`A green circle at (${x}, 50) moves from left to right on a gray square.`); + } + +
+ +
+ + function draw() { + background(200); + + // The expression + // frameCount % 100 + // causes x to increase from 0 + // to 99, then restart from 0. + let x = frameCount % 100; + + // Draw the circle. + fill(0, 255, 0); + circle(x, 50, 40); + + // Add a general description of the canvas + // and display it for debugging. + describe(`A green circle at (${x}, 50) moves from left to right on a gray square.`, LABEL); + } + +
+class: p5 +params: + - name: text + description: | +

description of the canvas.

+ type: String + - name: display + description: | +

either LABEL or FALLBACK.

+ type: Constant + optional: true +chainable: false +--- + + +# describe diff --git a/src/content/reference/en/p5 copy/describeElement.mdx b/src/content/reference/en/p5 copy/describeElement.mdx new file mode 100644 index 0000000000..0b7bc8b330 --- /dev/null +++ b/src/content/reference/en/p5 copy/describeElement.mdx @@ -0,0 +1,127 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/accessibility/describe.js#L162 +title: describeElement +module: Environment +submodule: Environment +file: src/accessibility/describe.js +description: > +

Creates a screen reader-accessible description of elements in the + canvas.

+ +

Elements are shapes or groups of shapes that create meaning together. For + + example, a few overlapping circles could make an "eye" element.

+ +

The first parameter, name, is the name of the element.

+ +

The second parameter, text, is the description of the + element.

+ +

The third parameter, display, is optional. It determines how + the + + description is displayed. If LABEL is passed, as in + + describe('A description.', LABEL), the description will be + visible in + + a div element next to the canvas. Using LABEL creates unhelpful + + duplicates for screen readers. Only use LABEL during development. + If + + FALLBACK is passed, as in describe('A description.', + FALLBACK), the + + description will only be visible to screen readers. This is the default + + mode.

+ +

Read + + Writing + accessible canvas descriptions + + to learn more about making sketches accessible.

+line: 162 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + background('pink'); + + // Describe the first element + // and draw it. + describeElement('Circle', 'A yellow circle in the top-left corner.'); + noStroke(); + fill('yellow'); + circle(25, 25, 40); + + // Describe the second element + // and draw it. + describeElement('Heart', 'A red heart in the bottom-right corner.'); + fill('red'); + circle(66.6, 66.6, 20); + circle(83.2, 66.6, 20); + triangle(91.2, 72.6, 75, 95, 58.6, 72.6); + + // Add a general description of the canvas. + describe('A red heart and yellow circle over a pink background.'); + } + +
+ +
+ + function setup() { + background('pink'); + + // Describe the first element + // and draw it. Display the + // description for debugging. + describeElement('Circle', 'A yellow circle in the top-left corner.', LABEL); + noStroke(); + fill('yellow'); + circle(25, 25, 40); + + // Describe the second element + // and draw it. Display the + // description for debugging. + describeElement('Heart', 'A red heart in the bottom-right corner.', LABEL); + fill('red'); + circle(66.6, 66.6, 20); + circle(83.2, 66.6, 20); + triangle(91.2, 72.6, 75, 95, 58.6, 72.6); + + // Add a general description of the canvas. + describe('A red heart and yellow circle over a pink background.'); + } + +
+class: p5 +params: + - name: name + description: | +

name of the element.

+ type: String + - name: text + description: | +

description of the element.

+ type: String + - name: display + description: | +

either LABEL or FALLBACK.

+ type: Constant + optional: true +chainable: false +--- + + +# describeElement diff --git a/src/content/reference/en/p5 copy/deviceMoved.mdx b/src/content/reference/en/p5 copy/deviceMoved.mdx new file mode 100644 index 0000000000..90e9ce91fb --- /dev/null +++ b/src/content/reference/en/p5 copy/deviceMoved.mdx @@ -0,0 +1,49 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L501 +title: deviceMoved +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

The deviceMoved() function is + called when the device is moved by more than + + the threshold value along X, Y or Z axis. The default threshold is set to 0.5. + + The threshold value can be changed using setMoveThreshold().

+line: 501 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Run this example on a mobile device + // Move the device around + // to change the value. + + let value = 0; + 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; + if (value > 255) { + value = 0; + } + } + +
+class: p5 +chainable: false +--- + + +# deviceMoved diff --git a/src/content/reference/en/p5 copy/deviceOrientation.mdx b/src/content/reference/en/p5 copy/deviceOrientation.mdx new file mode 100644 index 0000000000..a18763fc87 --- /dev/null +++ b/src/content/reference/en/p5 copy/deviceOrientation.mdx @@ -0,0 +1,22 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L11 +title: deviceOrientation +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: | +

The system variable deviceOrientation always contains the orientation of + the device. The value of this variable will either be set 'landscape' + or 'portrait'. If no data is available it will be set to 'undefined'. + either LANDSCAPE or PORTRAIT.

+line: 11 +isConstructor: false +itemtype: property +class: p5 +type: Constant +--- + + +# deviceOrientation diff --git a/src/content/reference/en/p5 copy/deviceShaken.mdx b/src/content/reference/en/p5 copy/deviceShaken.mdx new file mode 100644 index 0000000000..0c1cce17f8 --- /dev/null +++ b/src/content/reference/en/p5 copy/deviceShaken.mdx @@ -0,0 +1,50 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L589 +title: deviceShaken +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

The deviceShaken() function is + called when the device total acceleration + + changes of accelerationX and accelerationY values is more than + + the threshold value. The default threshold is set to 30. + + The threshold value can be changed using setShakeThreshold().

+line: 589 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Run this example on a mobile device + // Shake the device to change the value. + + let value = 0; + 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; + if (value > 255) { + value = 0; + } + } + +
+class: p5 +chainable: false +--- + + +# deviceShaken diff --git a/src/content/reference/en/p5 copy/deviceTurned.mdx b/src/content/reference/en/p5 copy/deviceTurned.mdx new file mode 100644 index 0000000000..28f760eb6f --- /dev/null +++ b/src/content/reference/en/p5 copy/deviceTurned.mdx @@ -0,0 +1,80 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L531 +title: deviceTurned +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

The deviceTurned() function is + called when the device rotates by + + more than 90 degrees continuously.

+ +

The axis that triggers the deviceTurned() method is stored in the + turnAxis + + variable. The deviceTurned() method + can be locked to trigger on any axis: + + X, Y or Z by comparing the turnAxis variable to 'X', 'Y' or 'Z'.

+line: 531 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Run this example on a mobile device + // Rotate the device by 90 degrees + // to change the value. + + let value = 0; + 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) { + value = 255; + } else if (value === 255) { + value = 0; + } + } + +
+
+ + // Run this example on a mobile device + // Rotate the device by 90 degrees in the + // X-axis to change the value. + + let value = 0; + 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') { + if (value === 0) { + value = 255; + } else if (value === 255) { + value = 0; + } + } + } + +
+class: p5 +chainable: false +--- + + +# deviceTurned diff --git a/src/content/reference/en/p5 copy/directionalLight.mdx b/src/content/reference/en/p5 copy/directionalLight.mdx new file mode 100644 index 0000000000..b2b3e011a3 --- /dev/null +++ b/src/content/reference/en/p5 copy/directionalLight.mdx @@ -0,0 +1,277 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L461 +title: directionalLight +module: 3D +submodule: Lights +file: src/webgl/light.js +description: > +

Creates a light that shines in one direction.

+ +

Directional lights don’t shine from a specific point. They’re like a sun + + that shines from somewhere offscreen. The light’s direction is set using + + three (x, y, z) values between -1 and 1. For example, setting a + light’s + + direction as (1, 0, 0) will light p5.Geometry + + objects from the left since the light faces directly to the right. A + + maximum of 5 directional lights can be active at once.

+ +

There are four ways to call directionalLight() with parameters + to set the + + light’s color and direction.

+ +

The first way to call directionalLight() has six parameters. + The first + + three parameters, v1, v2, and v3, set + the light’s color using the + + current colorMode(). The last three + + parameters, x, y, and z, set the + light’s direction. For example, + + directionalLight(255, 0, 0, 1, 0, 0) creates a red (255, 0, + 0) light + + that shines to the right (1, 0, 0).

+ +

The second way to call directionalLight() has four parameters. + The first + + three parameters, v1, v2, and v3, set + the light’s color using the + + current colorMode(). The last + parameter, + + direction sets the light’s direction using a + p5.Vector object. For example, + directionalLight(255, 0, 0, lightDir) creates a red (255, + 0, 0) light + + that shines in the direction the lightDir vector points.

+ +

The third way to call directionalLight() has four parameters. + The first + + parameter, color, sets the light’s color using a + + p5.Color object or an array of color + values. The + + last three parameters, x, y, and z, set + the light’s direction. For + + example, directionalLight(myColor, 1, 0, 0) creates a light that + shines + + to the right (1, 0, 0) with the color value of + myColor.

+ +

The fourth way to call directionalLight() has two parameters. + The first + + parameter, color, sets the light’s color using a + + p5.Color object or an array of color + values. The + + second parameter, direction, sets the light’s direction using a + + p5.Color object. For example, + + directionalLight(myColor, lightDir) creates a light that shines + in the + + direction the lightDir vector points with the color value of + myColor.

+line: 461 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click to turn on the directional light. + + let isLit = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A sphere drawn on a gray background. A red light starts shining from above when the user double-clicks.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Control the light. + if (isLit === true) { + // Add a red directional light from above. + // Use RGB values and XYZ directions. + directionalLight(255, 0, 0, 0, 1, 0); + } + + // Style the sphere. + noStroke(); + + // Draw the sphere. + sphere(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Add a red directional light from above. + // Use a p5.Color object and XYZ directions. + let c = color(255, 0, 0); + directionalLight(c, 0, 1, 0); + + // Style the sphere. + noStroke(); + + // Draw the sphere. + sphere(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Add a red directional light from above. + // Use a p5.Color object and a p5.Vector object. + let c = color(255, 0, 0); + let lightDir = createVector(0, 1, 0); + directionalLight(c, lightDir); + + // Style the sphere. + noStroke(); + + // Draw the sphere. + sphere(30); + } + +
+class: p5 +overloads: + - line: 461 + params: + - name: v1 + description: | +

red or hue value in the current + colorMode().

+ type: Number + - name: v2 + description: | +

green or saturation value in the current + colorMode().

+ type: Number + - name: v3 + description: | +

blue, brightness, or lightness value in the current + colorMode().

+ type: Number + - name: x + description: | +

x-component of the light's direction between -1 and 1.

+ type: Number + - name: 'y' + description: | +

y-component of the light's direction between -1 and 1.

+ type: Number + - name: z + description: | +

z-component of the light's direction between -1 and 1.

+ type: Number + chainable: 1 + - line: 614 + params: + - name: v1 + description: '' + type: Number + - name: v2 + description: '' + type: Number + - name: v3 + description: '' + type: Number + - name: direction + description: | +

direction of the light as a + p5.Vector object.

+ type: p5.Vector + chainable: 1 + - line: 624 + params: + - name: color + description: | +

color as a p5.Color object, + an array of color values, or as a CSS string.

+ type: 'p5.Color|Number[]|String' + - name: x + description: '' + type: Number + - name: 'y' + description: '' + type: Number + - name: z + description: '' + type: Number + chainable: 1 + - line: 634 + params: + - name: color + description: '' + type: 'p5.Color|Number[]|String' + - name: direction + description: '' + type: p5.Vector + chainable: 1 +chainable: true +--- + + +# directionalLight diff --git a/src/content/reference/en/p5 copy/disableFriendlyErrors.mdx b/src/content/reference/en/p5 copy/disableFriendlyErrors.mdx new file mode 100644 index 0000000000..a72ec28678 --- /dev/null +++ b/src/content/reference/en/p5 copy/disableFriendlyErrors.mdx @@ -0,0 +1,55 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L872 +title: disableFriendlyErrors +module: Structure +submodule: Structure +file: src/core/main.js +description: > +

Turns off the parts of the Friendly Error System (FES) that impact + performance.

+ +

The FES + + can cause sketches to draw slowly because it does extra work behind the + + scenes. For example, the FES checks the arguments passed to functions, + + which takes time to process. Disabling the FES can significantly improve + + performance by turning off these checks.

+line: 872 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // Disable the FES. + p5.disableFriendlyErrors = true; + + function setup() { + createCanvas(100, 100); + + background(200); + + // The circle() function requires three arguments. The + // next line would normally display a friendly error that + // points this out. Instead, nothing happens and it fails + // silently. + circle(50, 50); + + describe('A gray square.'); + } + +
+class: p5 +type: Boolean +--- + + +# disableFriendlyErrors diff --git a/src/content/reference/en/p5 copy/displayDensity.mdx b/src/content/reference/en/p5 copy/displayDensity.mdx new file mode 100644 index 0000000000..e52be83ec2 --- /dev/null +++ b/src/content/reference/en/p5 copy/displayDensity.mdx @@ -0,0 +1,55 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L1078 +title: displayDensity +module: Environment +submodule: Environment +file: src/core/environment.js +description: | +

Returns the display's current pixel density.

+line: 1078 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + // Set the pixel density to 1. + pixelDensity(1); + + // Create a canvas and draw + // a circle. + createCanvas(100, 100); + background(200); + circle(50, 50, 70); + + describe('A fuzzy white circle drawn on a gray background. The circle becomes sharper when the mouse is pressed.'); + } + + function mousePressed() { + // Get the current display density. + let d = displayDensity(); + + // Use the display density to set + // the sketch's pixel density. + pixelDensity(d); + + // Paint the background and + // draw a circle. + background(200); + circle(50, 50, 70); + } + +
+class: p5 +return: + description: current pixel density of the display. + type: Number +chainable: false +--- + + +# displayDensity diff --git a/src/content/reference/en/p5 copy/displayHeight.mdx b/src/content/reference/en/p5 copy/displayHeight.mdx new file mode 100644 index 0000000000..d392419e70 --- /dev/null +++ b/src/content/reference/en/p5 copy/displayHeight.mdx @@ -0,0 +1,47 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L621 +title: displayHeight +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

A Number variable that stores the height of the screen + display.

+ +

displayHeight is useful for running full-screen programs. Its + value + + depends on the current pixelDensity().

+ +

Note: The actual screen height can be computed as + + displayHeight * pixelDensity().

+line: 621 +isConstructor: false +itemtype: property +alt: This example does not render anything. +example: + - |- + +
+ + function setup() { + // Set the canvas' width and height + // using the display's dimensions. + createCanvas(displayWidth, displayHeight); + + background(200); + + describe('A gray canvas that is the same size as the display.'); + } + +
+class: p5 +type: Number +--- + + +# displayHeight diff --git a/src/content/reference/en/p5 copy/displayWidth.mdx b/src/content/reference/en/p5 copy/displayWidth.mdx new file mode 100644 index 0000000000..9ab79a09db --- /dev/null +++ b/src/content/reference/en/p5 copy/displayWidth.mdx @@ -0,0 +1,47 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L590 +title: displayWidth +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

A Number variable that stores the width of the screen + display.

+ +

displayWidth is useful for running full-screen programs. Its + value + + depends on the current pixelDensity().

+ +

Note: The actual screen width can be computed as + + displayWidth * pixelDensity().

+line: 590 +isConstructor: false +itemtype: property +alt: This example does not render anything. +example: + - |- + +
+ + function setup() { + // Set the canvas' width and height + // using the display's dimensions. + createCanvas(displayWidth, displayHeight); + + background(200); + + describe('A gray canvas that is the same size as the display.'); + } + +
+class: p5 +type: Number +--- + + +# displayWidth diff --git a/src/content/reference/en/p5 copy/dist.mdx b/src/content/reference/en/p5 copy/dist.mdx new file mode 100644 index 0000000000..60b7155b9b --- /dev/null +++ b/src/content/reference/en/p5 copy/dist.mdx @@ -0,0 +1,121 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L155 +title: dist +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Calculates the distance between two points.

+ +

The version of dist() with four parameters calculates distance + in two + + dimensions.

+ +

The version of dist() with six parameters calculates distance + in three + + dimensions.

+ +

Use p5.Vector.dist() to calculate + the + + distance between two p5.Vector + objects.

+line: 155 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Set the coordinates. + let x1 = 10; + let y1 = 50; + let x2 = 90; + let y2 = 50; + + // Draw the points and a line connecting them. + line(x1, y1, x2, y2); + strokeWeight(5); + point(x1, y1); + point(x2, y2); + + // Calculate the distance. + let d = dist(x1, y1, x2, y2); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the distance. + text(d, 43, 40); + + describe('Two dots connected by a horizontal line. The number 80 is written above the center of the line.'); + } + +
+class: p5 +return: + description: distance between the two points. + type: Number +overloads: + - line: 155 + params: + - name: x1 + description: | +

x-coordinate of the first point.

+ type: Number + - name: y1 + description: | +

y-coordinate of the first point.

+ type: Number + - name: x2 + description: | +

x-coordinate of the second point.

+ type: Number + - name: y2 + description: | +

y-coordinate of the second point.

+ type: Number + return: + description: distance between the two points. + type: Number + - line: 209 + params: + - name: x1 + description: '' + type: Number + - name: y1 + description: '' + type: Number + - name: z1 + description: | +

z-coordinate of the first point.

+ type: Number + - name: x2 + description: '' + type: Number + - name: y2 + description: '' + type: Number + - name: z2 + description: | +

z-coordinate of the second point.

+ type: Number + return: + description: distance between the two points. + type: Number +chainable: false +--- + + +# dist diff --git a/src/content/reference/en/p5 copy/doubleClicked.mdx b/src/content/reference/en/p5 copy/doubleClicked.mdx new file mode 100644 index 0000000000..3e148c677f --- /dev/null +++ b/src/content/reference/en/p5 copy/doubleClicked.mdx @@ -0,0 +1,157 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1599 +title: doubleClicked +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A function that's called once when a mouse button is clicked twice + quickly.

+ +

Declaring the function doubleClicked() sets a code block to + run + + automatically when the user presses and releases the mouse button twice + + quickly:

+ +
function doubleClicked() {
+    // Code to run.
+  }
+
+  
+ +

The mouse system variables, such as mouseX and + + mouseY, will be updated with their most + recent + + value when doubleClicked() is called by p5.js:

+ +
function doubleClicked() {
+    if (mouseX < 50) {
+      // Code to run if the mouse is on the left.
+    }
+
+    if (mouseY > 50) {
+      // Code to run if the mouse is near the bottom.
+    }
+  }
+
+  
+ +

The parameter, event, is optional. + doubleClicked() is always passed a + + MouseEvent + + object with properties that describe the double-click event:

+ +
function doubleClicked(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

On touchscreen devices, code placed in doubleClicked() will + run after two + + touches that occur within a short time.

+ +

Browsers may have default behaviors attached to various mouse events. For + + example, some browsers highlight text when the user moves the mouse while + + pressing a mouse button. To prevent any default behavior for this event, + + add return false; to the end of the function.

+line: 1599 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square changes color when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Toggle the square's color when the user double-clicks. + function doubleClicked() { + if (value === 0) { + value = 255; + } else { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+ +
+ + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black circle at its center. When the user double-clicks on the circle, it changes color to white.' + ); + } + + function draw() { + background(200); + + // Style the circle. + fill(value); + + // Draw the circle. + circle(50, 50, 80); + } + + // Reassign value to 255 when the user double-clicks on the circle. + function doubleClicked() { + if (dist(50, 50, mouseX, mouseY) < 40) { + value = 255; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+class: p5 +params: + - name: event + description: | +

optional MouseEvent argument.

+ type: MouseEvent + optional: true +chainable: false +--- + + +# doubleClicked diff --git a/src/content/reference/en/p5 copy/draw.mdx b/src/content/reference/en/p5 copy/draw.mdx new file mode 100644 index 0000000000..dba2e2b44a --- /dev/null +++ b/src/content/reference/en/p5 copy/draw.mdx @@ -0,0 +1,129 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L176 +title: draw +module: Structure +submodule: Structure +file: src/core/main.js +description: > +

A function that's called repeatedly while the sketch runs.

+ +

Declaring the function draw() sets a code block to run + repeatedly + + once the sketch starts. It’s used to create animations and respond to + + user inputs:

+ +
function draw() {
+    // Code to run repeatedly.
+  }
+
+  
+ +

This is often called the "draw loop" because p5.js calls the code in + + draw() in a loop behind the scenes. By default, + draw() tries to run + + 60 times per second. The actual rate depends on many factors. The + + drawing rate, called the "frame rate", can be controlled by calling + + frameRate(). The number of times + draw() + + has run is stored in the system variable + + frameCount().

+ +

Code placed within draw() begins looping after + + setup() runs. draw() will run + until the user + + closes the sketch. draw() can be stopped by calling the + + noLoop() function. draw() can + be resumed by + + calling the loop() function.

+line: 176 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Paint the background once. + background(200); + + describe( + 'A white circle on a gray background. The circle follows the mouse as the user moves, leaving a trail.' + ); + } + + function draw() { + // Draw circles repeatedly. + circle(mouseX, mouseY, 40); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A white circle on a gray background. The circle follows the mouse as the user moves.' + ); + } + + function draw() { + // Paint the background repeatedly. + background(200); + + // Draw circles repeatedly. + circle(mouseX, mouseY, 40); + } + +
+ +
+ + // Double-click the canvas to change the circle's color. + + function setup() { + createCanvas(100, 100); + + describe( + 'A white circle on a gray background. The circle follows the mouse as the user moves. The circle changes color to pink when the user double-clicks.' + ); + } + + function draw() { + // Paint the background repeatedly. + background(200); + + // Draw circles repeatedly. + circle(mouseX, mouseY, 40); + } + + // Change the fill color when the user double-clicks. + function doubleClicked() { + fill('deeppink'); + } + +
+class: p5 +chainable: false +--- + + +# draw diff --git a/src/content/reference/en/p5 copy/drawingContext.mdx b/src/content/reference/en/p5 copy/drawingContext.mdx new file mode 100644 index 0000000000..3cf1335733 --- /dev/null +++ b/src/content/reference/en/p5 copy/drawingContext.mdx @@ -0,0 +1,78 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L1198 +title: drawingContext +module: Rendering +submodule: Rendering +file: src/core/rendering.js +description: > +

A system variable that provides direct access to the sketch's + + element.

+ +

The element provides many specialized features that + aren't + + included in the p5.js library. The drawingContext system variable + + provides access to these features by exposing the sketch's + + CanvasRenderingContext2D + + object.

+line: 1198 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Style the circle using shadows. + drawingContext.shadowOffsetX = 5; + drawingContext.shadowOffsetY = -5; + drawingContext.shadowBlur = 10; + drawingContext.shadowColor = 'black'; + + // Draw the circle. + circle(50, 50, 40); + + describe("A white circle on a gray background. The circle's edges are shadowy."); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background('skyblue'); + + // Style the circle using a color gradient. + let myGradient = drawingContext.createRadialGradient(50, 50, 3, 50, 50, 40); + myGradient.addColorStop(0, 'yellow'); + myGradient.addColorStop(0.6, 'orangered'); + myGradient.addColorStop(1, 'yellow'); + drawingContext.fillStyle = myGradient; + drawingContext.strokeStyle = 'rgba(0, 0, 0, 0)'; + + // Draw the circle. + circle(50, 50, 40); + + describe('A fiery sun drawn on a light blue background.'); + } + +
+class: p5 +--- + + +# drawingContext diff --git a/src/content/reference/en/p5 copy/ellipse.mdx b/src/content/reference/en/p5 copy/ellipse.mdx new file mode 100644 index 0000000000..6c07765230 --- /dev/null +++ b/src/content/reference/en/p5 copy/ellipse.mdx @@ -0,0 +1,164 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L371 +title: ellipse +module: Shape +submodule: 2D Primitives +file: src/core/shape/2d_primitives.js +description: > +

Draws an ellipse (oval).

+ +

An ellipse is a round shape defined by the x, y, + w, and + + h parameters. x and y set the location + of its center. w and + + h set its width and height. See + + ellipseMode() for other ways to set + + its position.

+ +

If no height is set, the value of width is used for both the width and + + height. If a negative height or width is specified, the absolute value is + + taken.

+ +

The fifth parameter, detail, is also optional. It determines + how many + + vertices are used to draw the ellipse in WebGL mode. The default value is + + 25.

+line: 371 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + ellipse(50, 50, 80, 80); + + describe('A white circle on a gray canvas.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + ellipse(50, 50, 80); + + describe('A white circle on a gray canvas.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + ellipse(50, 50, 80, 40); + + describe('A white ellipse on a gray canvas.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + ellipse(0, 0, 80, 40); + + describe('A white ellipse on a gray canvas.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + // Use 6 vertices. + ellipse(0, 0, 80, 40, 6); + + describe('A white hexagon on a gray canvas.'); + } + +
+class: p5 +overloads: + - line: 371 + params: + - name: x + description: | +

x-coordinate of the center of the ellipse.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the center of the ellipse.

+ type: Number + - name: w + description: | +

width of the ellipse.

+ type: Number + - name: h + description: | +

height of the ellipse.

+ type: Number + optional: true + chainable: 1 + - line: 472 + params: + - name: x + description: '' + type: Number + - name: 'y' + description: '' + type: Number + - name: w + description: '' + type: Number + - name: h + description: '' + type: Number + - name: detail + description: | +

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.

+ type: Integer + optional: true +chainable: true +--- + + +# ellipse diff --git a/src/content/reference/en/p5 copy/ellipseMode.mdx b/src/content/reference/en/p5 copy/ellipseMode.mdx new file mode 100644 index 0000000000..0826de63f4 --- /dev/null +++ b/src/content/reference/en/p5 copy/ellipseMode.mdx @@ -0,0 +1,113 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L12 +title: ellipseMode +module: Shape +submodule: Attributes +file: src/core/shape/attributes.js +description: > +

Changes where ellipses, circles, and arcs are drawn.

+ +

By default, the first two parameters of + + ellipse(), circle(), + + and arc() + + are the x- and y-coordinates of the shape's center. The next parameters set + + the shape's width and height. This is the same as calling + + ellipseMode(CENTER).

+ +

ellipseMode(RADIUS) also uses the first two parameters to set + the x- and + + y-coordinates of the shape's center. The next parameters are half of the + + shapes's width and height. Calling ellipse(0, 0, 10, 15) draws a + shape + + with a width of 20 and height of 30.

+ +

ellipseMode(CORNER) uses the first two parameters as the + upper-left + + corner of the shape. The next parameters are its width and height.

+ +

ellipseMode(CORNERS) uses the first two parameters as the + location of one + + corner of the ellipse's bounding box. The next parameters are the location + + of the opposite corner.

+ +

The argument passed to ellipseMode() must be written in ALL + CAPS because + + the constants CENTER, RADIUS, CORNER, + and CORNERS are defined this + + way. JavaScript is a case-sensitive language.

+line: 12 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // White ellipse. + ellipseMode(RADIUS); + fill(255); + ellipse(50, 50, 30, 30); + + // Gray ellipse. + ellipseMode(CENTER); + fill(100); + ellipse(50, 50, 30, 30); + + describe('A white circle with a gray circle at its center. Both circles have black outlines.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // White ellipse. + ellipseMode(CORNER); + fill(255); + ellipse(25, 25, 50, 50); + + // Gray ellipse. + ellipseMode(CORNERS); + fill(100); + ellipse(25, 25, 50, 50); + + describe('A white circle with a gray circle at its top-left corner. Both circles have black outlines.'); + } + +
+class: p5 +params: + - name: mode + description: | +

either CENTER, RADIUS, CORNER, or CORNERS

+ type: Constant +chainable: true +--- + + +# ellipseMode diff --git a/src/content/reference/en/p5 copy/ellipsoid.mdx b/src/content/reference/en/p5 copy/ellipsoid.mdx new file mode 100644 index 0000000000..56d86709b7 --- /dev/null +++ b/src/content/reference/en/p5 copy/ellipsoid.mdx @@ -0,0 +1,233 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L1965 +title: ellipsoid +module: Shape +submodule: 3D Primitives +file: src/webgl/3d_primitives.js +description: > +

Draws an ellipsoid.

+ +

An ellipsoid is a 3D shape with triangular faces that connect to form a + + round surface. Ellipsoids with few faces look like crystals. Ellipsoids + + with many faces have smooth surfaces and look like eggs. + ellipsoid() + + defines a shape by its radii. This is different from + + ellipse() which uses diameters + + (width and height).

+ +

The first parameter, radiusX, is optional. If a + Number is passed, as in + + ellipsoid(20), it sets the radius of the ellipsoid along the + x-axis. By + + default, radiusX is 50.

+ +

The second parameter, radiusY, is also optional. If a + Number is passed, + + as in ellipsoid(20, 30), it sets the ellipsoid’s radius along the + y-axis. + + By default, radiusY is set to the ellipsoid’s + radiusX.

+ +

The third parameter, radiusZ, is also optional. If a + Number is passed, + + as in ellipsoid(20, 30, 40), it sets the ellipsoid’s radius along + the + + z-axis. By default, radiusZ is set to the ellipsoid’s + radiusY.

+ +

The fourth parameter, detailX, is also optional. If a + Number is passed, + + as in ellipsoid(20, 30, 40, 5), it sets the number of triangle + + subdivisions to use along the x-axis. All 3D shapes are made by connecting + + triangles to form their surfaces. By default, detailX is 24.

+ +

The fifth parameter, detailY, is also optional. If a + Number is passed, + + as in ellipsoid(20, 30, 40, 5, 7), it sets the number of triangle + + subdivisions to use along the y-axis. All 3D shapes are made by connecting + + triangles to form their surfaces. By default, detailY is 16.

+ +

Note: ellipsoid() can only be used in WebGL mode.

+line: 1965 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white sphere on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the ellipsoid. + // Set its radiusX to 30. + ellipsoid(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white ellipsoid on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the ellipsoid. + // Set its radiusX to 30. + // Set its radiusY to 40. + ellipsoid(30, 40); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white ellipsoid on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the ellipsoid. + // Set its radiusX to 30. + // Set its radiusY to 40. + // Set its radiusZ to 50. + ellipsoid(30, 40, 50); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white ellipsoid on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the ellipsoid. + // Set its radiusX to 30. + // Set its radiusY to 40. + // Set its radiusZ to 50. + // Set its detailX to 4. + ellipsoid(30, 40, 50, 4); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white ellipsoid on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the ellipsoid. + // Set its radiusX to 30. + // Set its radiusY to 40. + // Set its radiusZ to 50. + // Set its detailX to 4. + // Set its detailY to 3. + ellipsoid(30, 40, 50, 4, 3); + } + +
+class: p5 +params: + - name: radiusX + description: | +

radius of the ellipsoid along the x-axis. Defaults to 50.

+ type: Number + optional: true + - name: radiusY + description: > +

radius of the ellipsoid along the y-axis. Defaults to + radiusX.

+ type: Number + optional: true + - name: radiusZ + description: > +

radius of the ellipsoid along the z-axis. Defaults to + radiusY.

+ type: Number + optional: true + - name: detailX + description: | +

number of triangle subdivisions along the x-axis. Defaults to 24.

+ type: Integer + optional: true + - name: detailY + description: | +

number of triangle subdivisions along the y-axis. Defaults to 16.

+ type: Integer + optional: true +chainable: true +--- + + +# ellipsoid diff --git a/src/content/reference/en/p5 copy/emissiveMaterial.mdx b/src/content/reference/en/p5 copy/emissiveMaterial.mdx new file mode 100644 index 0000000000..10037c3c86 --- /dev/null +++ b/src/content/reference/en/p5 copy/emissiveMaterial.mdx @@ -0,0 +1,140 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2647 +title: emissiveMaterial +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Sets the emissive color of shapes’ surface material.

+ +

The emissiveMaterial() color sets a color shapes display at + full + + strength, regardless of lighting. This can give the appearance that a shape + + is glowing. However, emissive materials don’t actually emit light that + + can affect surrounding objects.

+ +

emissiveMaterial() can be called three ways with different + parameters to + + set the material’s color.

+ +

The first way to call emissiveMaterial() has one parameter, + gray. + + Grayscale values between 0 and 255, as in emissiveMaterial(50), + can be + + passed to set the material’s color. Higher grayscale values make shapes + + appear brighter.

+ +

The second way to call emissiveMaterial() has one parameter, + color. A + + p5.Color object, an array of color + values, or a + + CSS color string, as in emissiveMaterial('magenta'), can be + passed to set + + the material’s color.

+ +

The third way to call emissiveMaterial() has four parameters, + v1, v2, + + v3, and alpha. alpha is optional. RGBA, + HSBA, or HSLA values can be + + passed to set the material’s colors, as in emissiveMaterial(255, 0, + 0) or + + emissiveMaterial(255, 0, 0, 30). Color values will be interpreted + using + + the current colorMode().

+ +

Note: emissiveMaterial() can only be used in WebGL mode.

+line: 2647 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A red cube drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on a white ambient light. + ambientLight(255, 255, 255); + + // Add a red emissive material using RGB values. + emissiveMaterial(255, 0, 0); + + // Draw the box. + box(); + } + +
+class: p5 +overloads: + - line: 2647 + params: + - name: v1 + description: | +

red or hue value in the current + colorMode().

+ type: Number + - name: v2 + description: | +

green or saturation value in the + current colorMode().

+ type: Number + - name: v3 + description: | +

blue, brightness, or lightness value in the + current colorMode().

+ type: Number + - name: alpha + description: | +

alpha value in the current + colorMode().

+ type: Number + optional: true + chainable: 1 + - line: 2717 + params: + - name: gray + description: | +

grayscale value between 0 (black) and 255 (white).

+ type: Number + chainable: 1 + - line: 2723 + params: + - name: color + description: | +

color as a p5.Color object, + an array of color values, or a CSS string.

+ type: 'p5.Color|Number[]|String' + chainable: 1 +chainable: true +--- + + +# emissiveMaterial diff --git a/src/content/reference/en/p5 copy/endClip.mdx b/src/content/reference/en/p5 copy/endClip.mdx new file mode 100644 index 0000000000..69bf243858 --- /dev/null +++ b/src/content/reference/en/p5 copy/endClip.mdx @@ -0,0 +1,43 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L190 +title: endClip +module: Color +submodule: Setting +file: src/color/setting.js +description: | +

Ends defining a mask that was started with + beginClip().

+line: 190 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a mask. + beginClip(); + triangle(15, 37, 30, 13, 43, 37); + circle(45, 45, 7); + endClip(); + + // Draw a backing shape. + square(5, 5, 45); + + describe('A white triangle and circle on a gray background.'); + } + +
+class: p5 +chainable: false +--- + + +# endClip diff --git a/src/content/reference/en/p5 copy/endContour.mdx b/src/content/reference/en/p5 copy/endContour.mdx new file mode 100644 index 0000000000..5965b72db8 --- /dev/null +++ b/src/content/reference/en/p5 copy/endContour.mdx @@ -0,0 +1,133 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L1224 +title: endContour +module: Shape +submodule: Vertex +file: src/core/shape/vertex.js +description: > +

Stops creating a hole within a flat shape.

+ +

The beginContour() and + endContour() + + functions allow for creating negative space within custom shapes that are + + flat. beginContour() begins adding + vertices + + to a negative space and endContour() stops adding them. + + beginContour() and + endContour() must be + + called between beginShape() and + + endShape().

+ +

Transformations such as translate(), + + rotate(), and scale() + + don't work between beginContour() + and + + endContour(). It's also not possible to use other shapes, such as + + ellipse() or rect(), + + between beginContour() and + endContour().

+ +

Note: The vertices that define a negative space must "wind" in the opposite + + direction from the outer shape. First, draw vertices for the outer shape + + clockwise order. Then, draw vertices for the negative space in + + counter-clockwise order.

+line: 1224 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + beginShape(); + + // Exterior vertices, clockwise winding. + vertex(10, 10); + vertex(90, 10); + vertex(90, 90); + vertex(10, 90); + + // Interior vertices, counter-clockwise winding. + beginContour(); + vertex(30, 30); + vertex(30, 70); + vertex(70, 70); + vertex(70, 30); + endContour(); + + // Stop drawing the shape. + endShape(CLOSE); + + describe('A white square with a square hole in its center drawn on a gray background.'); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white square with a square hole in its center drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Start drawing the shape. + beginShape(); + + // Exterior vertices, clockwise winding. + vertex(-40, -40); + vertex(40, -40); + vertex(40, 40); + vertex(-40, 40); + + // Interior vertices, counter-clockwise winding. + beginContour(); + vertex(-20, -20); + vertex(-20, 20); + vertex(20, 20); + vertex(20, -20); + endContour(); + + // Stop drawing the shape. + endShape(CLOSE); + } + +
+class: p5 +chainable: true +--- + + +# endContour diff --git a/src/content/reference/en/p5 copy/endGeometry.mdx b/src/content/reference/en/p5 copy/endGeometry.mdx new file mode 100644 index 0000000000..bfbeb81c7b --- /dev/null +++ b/src/content/reference/en/p5 copy/endGeometry.mdx @@ -0,0 +1,285 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L266 +title: endGeometry +module: Shape +submodule: 3D Primitives +file: src/webgl/3d_primitives.js +description: > +

Stops adding shapes to a new + + p5.Geometry object and returns the + object.

+ +

The beginGeometry() and endGeometry() + + functions help with creating complex 3D shapes from simpler ones such as + + sphere(). beginGeometry() + begins adding shapes + + to a custom p5.Geometry object and + + endGeometry() stops adding them.

+ +

beginGeometry() and endGeometry() can help + + to make sketches more performant. For example, if a complex 3D shape + + doesn’t change while a sketch runs, then it can be created with + + beginGeometry() and endGeometry(). + + Creating a p5.Geometry object once and + then + + drawing it will run faster than repeatedly drawing the individual pieces.

+ +

See buildGeometry() for another + way to + + build 3D shapes.

+ +

Note: endGeometry() can only be used in WebGL mode.

+line: 266 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Start building the p5.Geometry object. + beginGeometry(); + + // Add a cone. + cone(); + + // Stop building the p5.Geometry object. + shape = endGeometry(); + + describe('A white cone drawn on a gray background.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the p5.Geometry object. + noStroke(); + + // Draw the p5.Geometry object. + model(shape); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the p5.Geometry object. + createArrow(); + + describe('A white arrow drawn on a gray background.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the p5.Geometry object. + noStroke(); + + // Draw the p5.Geometry object. + model(shape); + } + + function createArrow() { + // Start building the p5.Geometry object. + beginGeometry(); + + // Add shapes. + push(); + rotateX(PI); + cone(10); + translate(0, -10, 0); + cylinder(3, 20); + pop(); + + // Stop building the p5.Geometry object. + shape = endGeometry(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let blueArrow; + let redArrow; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the arrows. + redArrow = createArrow('red'); + blueArrow = createArrow('blue'); + + describe('A red arrow and a blue arrow drawn on a gray background. The blue arrow rotates slowly.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the arrows. + noStroke(); + + // Draw the red arrow. + model(redArrow); + + // Translate and rotate the coordinate system. + translate(30, 0, 0); + rotateZ(frameCount * 0.01); + + // Draw the blue arrow. + model(blueArrow); + } + + function createArrow(fillColor) { + // Start building the p5.Geometry object. + beginGeometry(); + + fill(fillColor); + + // Add shapes to the p5.Geometry object. + push(); + rotateX(PI); + cone(10); + translate(0, -10, 0); + cylinder(3, 20); + pop(); + + // Stop building the p5.Geometry object. + let shape = endGeometry(); + + return shape; + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let button; + let particles; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a button to reset the particle system. + button = createButton('Reset'); + + // Call resetModel() when the user presses the button. + button.mousePressed(resetModel); + + // Add the original set of particles. + resetModel(); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the particles. + noStroke(); + + // Draw the particles. + model(particles); + } + + function resetModel() { + // If the p5.Geometry object has already been created, + // free those resources. + if (particles) { + freeGeometry(particles); + } + + // Create a new p5.Geometry object with random spheres. + particles = createParticles(); + } + + function createParticles() { + // Start building the p5.Geometry object. + beginGeometry(); + + // Add shapes. + for (let i = 0; i < 60; i += 1) { + // Calculate random coordinates. + let x = randomGaussian(0, 20); + let y = randomGaussian(0, 20); + let z = randomGaussian(0, 20); + + push(); + // Translate to the particle's coordinates. + translate(x, y, z); + // Draw the particle. + sphere(5); + pop(); + } + + // Stop building the p5.Geometry object. + let shape = endGeometry(); + + return shape; + } + +
+class: p5 +return: + description: new 3D shape. + type: p5.Geometry +chainable: false +--- + + +# endGeometry diff --git a/src/content/reference/en/p5 copy/endShape.mdx b/src/content/reference/en/p5 copy/endShape.mdx new file mode 100644 index 0000000000..198b6d7497 --- /dev/null +++ b/src/content/reference/en/p5 copy/endShape.mdx @@ -0,0 +1,256 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L1344 +title: endShape +module: Shape +submodule: Vertex +file: src/core/shape/vertex.js +description: > +

Stops adding vertices to a custom shape.

+ +

The beginShape() and + endShape() functions + + allow for creating custom shapes in 2D or 3D. + + beginShape() begins adding vertices to + a + + custom shape and endShape() stops adding them.

+ +

The first parameter, mode, is optional. By default, the first + and last + + vertices of a shape aren't connected. If the constant CLOSE is + passed, as + + in endShape(CLOSE), then the first and last vertices will be + connected.

+ +

The second parameter, count, is also optional. In WebGL mode, + it’s more + + efficient to draw many copies of the same shape using a technique called + + instancing. + + The count parameter tells WebGL mode how many copies to draw. For + + example, calling endShape(CLOSE, 400) after drawing a custom + shape will + + make it efficient to draw 400 copies. This feature requires + + writing + a custom shader.

+ +

After calling beginShape(), shapes + can be + + built by calling vertex(), + + bezierVertex(), + + quadraticVertex(), and/or + + curveVertex(). Calling + + endShape() will stop adding vertices to the + + shape. Each shape will be outlined with the current stroke color and filled + + with the current fill color.

+ +

Transformations such as translate(), + + rotate(), and + + scale() don't work between + + beginShape() and + endShape(). It's also not + + possible to use other shapes, such as ellipse() or + + rect(), between + + beginShape() and + endShape().

+line: 1344 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the shapes. + noFill(); + + // Left triangle. + beginShape(); + vertex(20, 20); + vertex(45, 20); + vertex(45, 80); + endShape(CLOSE); + + // Right triangle. + beginShape(); + vertex(50, 20); + vertex(75, 20); + vertex(75, 80); + endShape(); + + describe( + 'Two sets of black lines drawn on a gray background. The three lines on the left form a right triangle. The two lines on the right form a right angle.' + ); + } + +
+ +
+ + function setup() { + createCanvas(200, 100); + + background(240); + + noFill(); + stroke(0); + + // Open shape (left) + beginShape(); + vertex(20, 20); + vertex(80, 20); + vertex(80, 80); + endShape(); // Not closed + + // Closed shape (right) + beginShape(); + vertex(120, 20); + vertex(180, 20); + vertex(180, 80); + endShape(CLOSE); // Closed + + describe( + 'Two right-angled shapes on a light gray background. The left shape is open with three lines. The right shape is closed, forming a triangle.' + ); + } + +
+ +
+ + // Note: A "uniform" is a global variable within a shader program. + + // Create a string with the vertex shader program. + // The vertex shader is called for each vertex. + let vertSrc = `#version 300 es + + precision mediump float; + + in vec3 aPosition; + flat out int instanceID; + + uniform mat4 uModelViewMatrix; + uniform mat4 uProjectionMatrix; + + void main() { + + // Copy the instance ID to the fragment shader. + instanceID = gl_InstanceID; + vec4 positionVec4 = vec4(aPosition, 1.0); + + // gl_InstanceID represents a numeric value for each instance. + // Using gl_InstanceID allows us to move each instance separately. + // Here we move each instance horizontally by ID * 23. + float xOffset = float(gl_InstanceID) * 23.0; + + // Apply the offset to the final position. + gl_Position = uProjectionMatrix * uModelViewMatrix * (positionVec4 - + vec4(xOffset, 0.0, 0.0, 0.0)); + } + `; + + // Create a string with the fragment shader program. + // The fragment shader is called for each pixel. + let fragSrc = `#version 300 es + + precision mediump float; + + out vec4 outColor; + flat in int instanceID; + uniform float numInstances; + + void main() { + vec4 red = vec4(1.0, 0.0, 0.0, 1.0); + vec4 blue = vec4(0.0, 0.0, 1.0, 1.0); + + // Normalize the instance ID. + float normId = float(instanceID) / numInstances; + + // Mix between two colors using the normalized instance ID. + outColor = mix(red, blue, normId); + } + `; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Shader object. + let myShader = createShader(vertSrc, fragSrc); + + background(220); + + // Compile and apply the p5.Shader. + shader(myShader); + + // Set the numInstances uniform. + myShader.setUniform('numInstances', 4); + + // Translate the origin to help align the drawing. + translate(25, -10); + + // Style the shapes. + noStroke(); + + // Draw the shapes. + beginShape(); + vertex(0, 0); + vertex(0, 20); + vertex(20, 20); + vertex(20, 0); + vertex(0, 0); + endShape(CLOSE, 4); + + describe('A row of four squares. Their colors transition from purple on the left to red on the right'); + } + +
+class: p5 +params: + - name: mode + description: | +

use CLOSE to close the shape

+ type: Constant + optional: true + - name: count + description: > +

number of times you want to draw/instance the shape (for WebGL + mode).

+ type: Integer + optional: true +chainable: true +--- + + +# endShape diff --git a/src/content/reference/en/p5 copy/erase.mdx b/src/content/reference/en/p5 copy/erase.mdx new file mode 100644 index 0000000000..24f1397e8e --- /dev/null +++ b/src/content/reference/en/p5 copy/erase.mdx @@ -0,0 +1,123 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1629 +title: erase +module: Color +submodule: Setting +file: src/color/setting.js +description: > +

Starts using shapes to erase parts of the canvas.

+ +

All drawing that follows erase() will subtract from the + canvas, revealing + + the web page underneath. The erased areas will become transparent, allowing + + the content behind the canvas to show through. The + + fill(), stroke(), and + + blendMode() have no effect once + erase() is + + called.

+ +

The erase() function has two optional parameters. The first + parameter + + sets the strength of erasing by the shape's interior. A value of 0 means + + that no erasing will occur. A value of 255 means that the shape's interior + + will fully erase the content underneath. The default value is 255 + + (full strength).

+ +

The second parameter sets the strength of erasing by the shape's edge. A + + value of 0 means that no erasing will occur. A value of 255 means that the + + shape's edge will fully erase the content underneath. The default value is + + 255 (full strength).

+ +

To cancel the erasing effect, use the noErase() + + function.

+ +

erase() has no effect on drawing done with the + + image() and + + background() functions.

+line: 1629 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(100, 100, 250); + + // Draw a pink square. + fill(250, 100, 100); + square(20, 20, 60); + + // Erase a circular area. + erase(); + circle(25, 30, 30); + noErase(); + + describe('A purple canvas with a pink square in the middle. A circle is erased from the top-left, leaving a hole.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(100, 100, 250); + + // Draw a pink square. + fill(250, 100, 100); + square(20, 20, 60); + + // Erase a circular area. + strokeWeight(5); + erase(150, 255); + circle(25, 30, 30); + noErase(); + + describe('A purple canvas with a pink square in the middle. A circle at the top-left partially erases its interior and a fully erases its outline.'); + } + +
+class: p5 +params: + - name: strengthFill + description: | +

a number (0-255) for the strength of erasing under a shape's interior. + Defaults to 255, which is full strength.

+ type: Number + optional: true + - name: strengthStroke + description: | +

a number (0-255) for the strength of erasing under a shape's edge. + Defaults to 255, which is full strength.

+ type: Number + optional: true +chainable: true +--- + + +# erase diff --git a/src/content/reference/en/p5 copy/exitPointerLock.mdx b/src/content/reference/en/p5 copy/exitPointerLock.mdx new file mode 100644 index 0000000000..db8a989422 --- /dev/null +++ b/src/content/reference/en/p5 copy/exitPointerLock.mdx @@ -0,0 +1,82 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1946 +title: exitPointerLock +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

Exits a pointer lock started with + + requestPointerLock.

+ +

Calling requestPointerLock() locks the values of + + mouseX, mouseY, + + pmouseX, and pmouseY. + + Calling exitPointerLock() resumes updating the mouse system + variables.

+ +

Note: Most browsers require an input, such as a click, before calling + + requestPointerLock(). It’s recommended to call + requestPointerLock() in + + an event function such as doubleClicked().

+line: 1946 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let isLocked = false; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a word at its center. The word changes between "Unlocked" and "Locked" when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Tell the user whether the pointer is locked. + if (isLocked === true) { + text('Locked', 50, 50); + } else { + text('Unlocked', 50, 50); + } + } + + // Toggle the pointer lock when the user double-clicks. + function doubleClicked() { + if (isLocked === true) { + exitPointerLock(); + isLocked = false; + } else { + requestPointerLock(); + isLocked = true; + } + } + +
+class: p5 +chainable: false +--- + + +# exitPointerLock diff --git a/src/content/reference/en/p5 copy/exp.mdx b/src/content/reference/en/p5 copy/exp.mdx new file mode 100644 index 0000000000..e75a420dab --- /dev/null +++ b/src/content/reference/en/p5 copy/exp.mdx @@ -0,0 +1,83 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L230 +title: exp +module: Math +submodule: Calculation +file: src/math/calculation.js +description: | +

Calculates the value of Euler's number e (2.71828...) raised to the power + of a number.

+line: 230 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Top-left. + let d = exp(1); + circle(10, 10, d); + + // Left-center. + d = exp(2); + circle(20, 20, d); + + // Right-center. + d = exp(3); + circle(40, 40, d); + + // Bottom-right. + d = exp(4); + circle(80, 80, d); + + describe('A series of circles that grow exponentially from top left to bottom right.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + describe('A series of black dots that grow exponentially from left to right.'); + } + + function draw() { + // Invert the y-axis. + scale(1, -1); + translate(0, -100); + + // Calculate the coordinates. + let x = frameCount; + let y = 0.005 * exp(x * 0.1); + + // Draw a point. + point(x, y); + } + +
+class: p5 +params: + - name: 'n' + description: | +

exponent to raise.

+ type: Number +return: + description: e^n + type: Number +chainable: false +--- + + +# exp diff --git a/src/content/reference/en/p5 copy/fill.mdx b/src/content/reference/en/p5 copy/fill.mdx new file mode 100644 index 0000000000..84f074abd4 --- /dev/null +++ b/src/content/reference/en/p5 copy/fill.mdx @@ -0,0 +1,312 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1000 +title: fill +module: Color +submodule: Setting +file: src/color/setting.js +description: > +

Sets the color used to fill shapes.

+ +

Calling fill(255, 165, 0) or fill('orange') means + all shapes drawn + + after the fill command will be filled with the color orange.

+ +

The version of fill() with one parameter interprets the value + one of + + three ways. If the parameter is a Number, it's interpreted as a + grayscale + + value. If the parameter is a String, it's interpreted as a CSS + color + + string. A p5.Color object can also be + provided to + + set the fill color.

+ +

The version of fill() with three parameters interprets them as + RGB, HSB, + + or HSL colors, depending on the current + + colorMode(). The default color space is + RGB, + + with each value in the range from 0 to 255.

+ +

The version of fill() with four parameters interprets them as + RGBA, HSBA, + + or HSLA colors, depending on the current colorMode(). The last parameter + + sets the alpha (transparency) value.

+line: 1000 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // A grayscale value. + fill(51); + square(20, 20, 60); + + describe('A dark charcoal gray square with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // R, G & B values. + fill(255, 204, 0); + square(20, 20, 60); + + describe('A yellow square with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // R, G, B, and Alpha values. + fill(255, 0, 0, 128); + square(20, 20, 60); + + describe('A semi-transparent red square with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(100); + + // Use HSB color. + colorMode(HSB); + + // H, S & B values. + fill(255, 204, 100); + square(20, 20, 60); + + describe('A royal blue square with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // A CSS named color. + fill('red'); + square(20, 20, 60); + + describe('A red square with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Three-digit hex RGB notation. + fill('#fae'); + square(20, 20, 60); + + describe('A pink square with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Six-digit hex RGB notation. + fill('#A251FA'); + square(20, 20, 60); + + describe('A purple square with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Integer RGB notation. + fill('rgb(0, 255, 0)'); + square(20, 20, 60); + + describe('A bright green square with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Integer RGBA notation. + fill('rgba(0, 255, 0, 0.25)'); + square(20, 20, 60); + + describe('A soft green rectange with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Percentage RGB notation. + fill('rgb(100%, 0%, 10%)'); + square(20, 20, 60); + + describe('A red square with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Percentage RGBA notation. + fill('rgba(100%, 0%, 100%, 0.5)'); + square(20, 20, 60); + + describe('A dark fuchsia square with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // A p5.Color object. + let c = color(0, 0, 255); + fill(c); + square(20, 20, 60); + + describe('A blue square with a black outline.'); + } + +
+class: p5 +overloads: + - line: 1000 + params: + - name: v1 + description: > +

red value if color mode is RGB or hue value if color mode is + HSB.

+ type: Number + - name: v2 + description: > +

green value if color mode is RGB or saturation value if color mode + is HSB.

+ type: Number + - name: v3 + description: > +

blue value if color mode is RGB or brightness value if color mode + is HSB.

+ type: Number + - name: alpha + description: > +

alpha value, controls transparency (0 - transparent, 255 - + opaque).

+ type: Number + optional: true + chainable: 1 + - line: 1225 + params: + - name: value + description: | +

a color string.

+ type: String + chainable: 1 + - line: 1231 + params: + - name: gray + description: | +

a grayscale value.

+ type: Number + - name: alpha + description: '' + type: Number + optional: true + chainable: 1 + - line: 1238 + params: + - name: values + description: | +

an array containing the red, green, blue & + and alpha components of the color.

+ type: 'Number[]' + chainable: 1 + - line: 1245 + params: + - name: color + description: | +

the fill color.

+ type: p5.Color + chainable: 1 +chainable: true +--- + + +# fill diff --git a/src/content/reference/en/p5 copy/filter.mdx b/src/content/reference/en/p5 copy/filter.mdx new file mode 100644 index 0000000000..5496568d48 --- /dev/null +++ b/src/content/reference/en/p5 copy/filter.mdx @@ -0,0 +1,330 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L442 +title: filter +module: Image +submodule: Pixels +file: src/image/pixels.js +description: > +

Applies an image filter to the canvas.

+ +

The preset options are:

+ +

INVERT + + Inverts the colors in the image. No parameter is used.

+ +

GRAY + + Converts the image to grayscale. No parameter is used.

+ +

THRESHOLD + + Converts the image to black and white. Pixels with a grayscale value + + above a given threshold are converted to white. The rest are converted to + + black. The threshold must be between 0.0 (black) and 1.0 (white). If no + + value is specified, 0.5 is used.

+ +

OPAQUE + + Sets the alpha channel to entirely opaque. No parameter is used.

+ +

POSTERIZE + + Limits the number of colors in the image. Each color channel is limited to + + the number of colors specified. Values between 2 and 255 are valid, but + + results are most noticeable with lower values. The default value is 4.

+ +

BLUR + + Blurs the image. The level of blurring is specified by a blur radius. Larger + + values increase the blur. The default value is 4. A gaussian blur is used + + in P2D mode. A box blur is used in WEBGL mode.

+ +

ERODE + + Reduces the light areas. No parameter is used.

+ +

DILATE + + Increases the light areas. No parameter is used.

+ +

filter() uses WebGL in the background by default because it's + faster. + + This can be disabled in P2D mode by adding a false + argument, as in + + filter(BLUR, false). This may be useful to keep computation off + the GPU + + or to work around a lack of WebGL support.

+ +

In WebgL mode, filter() can also use custom shaders. See + + createFilterShader() for more + + information.

+line: 442 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Apply the INVERT filter. + filter(INVERT); + + describe('A blue brick wall.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Apply the GRAY filter. + filter(GRAY); + + describe('A brick wall drawn in grayscale.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Apply the THRESHOLD filter. + filter(THRESHOLD); + + describe('A brick wall drawn in black and white.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Apply the OPAQUE filter. + filter(OPAQUE); + + describe('A red brick wall.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Apply the POSTERIZE filter. + filter(POSTERIZE, 3); + + describe('An image of a red brick wall drawn with limited color palette.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Apply the BLUR filter. + filter(BLUR, 3); + + describe('A blurry image of a red brick wall.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Apply the DILATE filter. + filter(DILATE); + + describe('A red brick wall with bright lines between each brick.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Apply the ERODE filter. + filter(ERODE); + + describe('A red brick wall with faint lines between each brick.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Apply the BLUR filter. + // Don't use WebGL. + filter(BLUR, 3, false); + + describe('A blurry image of a red brick wall.'); + } + +
+class: p5 +overloads: + - line: 442 + params: + - name: filterType + description: | +

either THRESHOLD, GRAY, OPAQUE, INVERT, + POSTERIZE, BLUR, ERODE, DILATE or BLUR.

+ type: Constant + - name: filterParam + description: | +

parameter unique to each filter.

+ type: Number + optional: true + - name: useWebGL + description: | +

flag to control whether to use fast + WebGL filters (GPU) or original image + filters (CPU); defaults to true.

+ type: Boolean + optional: true + - line: 715 + params: + - name: filterType + description: '' + type: Constant + - name: useWebGL + description: '' + type: Boolean + optional: true + - line: 720 + params: + - name: shaderFilter + description: | +

shader that's been loaded, with the + frag shader using a tex0 uniform.

+ type: p5.Shader +chainable: false +--- + + +# filter diff --git a/src/content/reference/en/p5 copy/float.mdx b/src/content/reference/en/p5 copy/float.mdx new file mode 100644 index 0000000000..fffd6bfc1b --- /dev/null +++ b/src/content/reference/en/p5 copy/float.mdx @@ -0,0 +1,116 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L10 +title: float +module: Data +submodule: Conversion +file: src/utilities/conversion.js +description: > +

Converts a String to a floating point (decimal) + Number.

+ +

float() converts strings that resemble numbers, such as + '12.34', into + + numbers.

+ +

The parameter, str, is the string value to convert. For + example, calling + + float('12.34') returns the number 12.34. If an + array of strings is + + passed, as in float(['12.34', '56.78']), then an array of numbers + will be + + returned.

+ +

Note: If a string can't be converted to a number, as in + float('giraffe'), + + then the value NaN (not a number) will be returned.

+line: 10 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let original = '12.3'; + + // Convert the string to a number. + let converted = float(original); + + // Double the converted value. + let twice = converted * 2; + + // Style the text. + textAlign(CENTER, CENTER); + textSize(12); + + // Display the original and converted values. + text(`${original} × 2 = ${twice}`, 50, 50); + + describe('The text "12.3 × 2 = 24.6" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of strings. + let original = ['60', '30', '15']; + + // Convert the strings to numbers. + let diameters = float(original); + + for (let d of diameters) { + // Draw a circle. + circle(50, 50, d); + } + + describe('Three white, concentric circles on a gray background.'); + } + +
+class: p5 +return: + description: converted number. + type: Number +overloads: + - line: 10 + params: + - name: str + description: | +

string to convert.

+ type: String + return: + description: converted number. + type: Number + - line: 80 + params: + - name: ns + description: | +

array of strings to convert.

+ type: 'String[]' + return: + description: converted numbers. + type: 'Number[]' +chainable: false +--- + + +# float diff --git a/src/content/reference/en/p5 copy/floor.mdx b/src/content/reference/en/p5 copy/floor.mdx new file mode 100644 index 0000000000..a9e97965a3 --- /dev/null +++ b/src/content/reference/en/p5 copy/floor.mdx @@ -0,0 +1,57 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L294 +title: floor +module: Math +submodule: Calculation +file: src/math/calculation.js +description: | +

Calculates the closest integer value that is less than or equal to the + value of a number.

+line: 294 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Use RGB color with values from 0 to 1. + colorMode(RGB, 1); + + noStroke(); + + // Draw the left rectangle. + let r = 0.8; + fill(r, 0, 0); + rect(0, 0, 50, 100); + + // Round r down to 0. + r = floor(r); + + // Draw the right rectangle. + fill(r, 0, 0); + rect(50, 0, 50, 100); + + describe('Two rectangles. The one on the left is bright red and the one on the right is black.'); + } + +
+class: p5 +params: + - name: 'n' + description: | +

number to round down.

+ type: Number +return: + description: rounded down number. + type: Integer +chainable: false +--- + + +# floor diff --git a/src/content/reference/en/p5 copy/focused.mdx b/src/content/reference/en/p5 copy/focused.mdx new file mode 100644 index 0000000000..1e95f25927 --- /dev/null +++ b/src/content/reference/en/p5 copy/focused.mdx @@ -0,0 +1,50 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L174 +title: focused +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

A Boolean variable that's true if the browser is + focused and false if + + not.

+ +

Note: The browser window can only receive input if it's focused.

+line: 174 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // Open this example in two separate browser + // windows placed side-by-side to demonstrate. + + function setup() { + createCanvas(100, 100); + + describe('A square changes color from green to red when the browser window is out of focus.'); + } + + function draw() { + // Change the background color + // when the browser window + // goes in/out of focus. + if (focused === true) { + background(0, 255, 0); + } else { + background(255, 0, 0); + } + } + +
+class: p5 +type: Boolean +--- + + +# focused diff --git a/src/content/reference/en/p5 copy/for.mdx b/src/content/reference/en/p5 copy/for.mdx new file mode 100644 index 0000000000..dc71d1c2ca --- /dev/null +++ b/src/content/reference/en/p5 copy/for.mdx @@ -0,0 +1,290 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L1648 +title: for +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: > +

A way to repeat a block of code when the number of iterations is known.

+ +

for loops are helpful for repeating statements a certain + number of times. + + For example, a for loop makes it easy to express the idea + + "draw five lines" like so:

+ +
for (let x = 10; x < 100; x += 20) {
+    line(x, 25, x, 75);
+  }
+
+  
+ +

The loop's header begins with the keyword for. Loops generally + count up + + or count down as they repeat, or iterate. The statements in parentheses + + let x = 10; x < 100; x += 20 tell the loop how it should + repeat:

+ +
    + +
  • let x = 10 tells the loop to start counting at + 10 and keep track of iterations using the variable + x.
  • + +
  • x < 100 tells the loop to count up to, but not including, + 100.
  • + +
  • x += 20 tells the loop to count up by 20 at the + end of each iteration.
  • + +
+ +

The code between the curly braces {} is the loop's body. + Statements in the + + loop body are repeated during each iteration of the loop.

+ +

It's common to create infinite loops accidentally. When this happens, + + sketches may become unresponsive and the web browser may display a warning. + + For example, the following loop never stops iterating because it doesn't + + count up:

+ +
for (let x = 10; x < 100; x = 20) {
+    line(x, 25, x, 75);
+  }
+
+  
+ +

The statement x = 20 keeps the variable x stuck + at 20, which is + + always less than 100.

+ +

for loops can also count down:

+ +
for (let d = 100; d > 0; d -= 10) {
+    circle(50, 50, d);
+  }
+
+  
+ +

for loops can also contain other loops. The following nested + loop draws a + + grid of points:

+ +
// Loop from left to right.
+
+  for (let x = 10; x < 100; x += 10) {
+
+    // Loop from top to bottom.
+    for (let y = 10; y < 100; y += 10) {
+      point(x, y);
+    }
+
+  }
+
+  
+ +

for loops are also helpful for iterating through the elements + of an + + array. For example, it's common to iterate through an array that contains + + information about where or what to draw:

+ +
// Create an array of x-coordinates.
+
+  let xCoordinates = [20, 40, 60];
+
+
+  for (let i = 0; i < xCoordinates.length; i += 1) {
+    // Update the element.
+    xCoordinates[i] += random(-1, 1);
+
+    // Draw a circle.
+    circle(xCoordinates[i], 50, 20);
+  }
+
+  
+ +

If the array's values aren't modified, the for...of statement + can + + simplify the code. They're similar to for loops in Python and + for-each + + loops in C++ and Java. The following loops have the same effect:

+ +
// Draw circles with a for loop.
+
+  let xCoordinates = [20, 40, 60];
+
+
+  for (let i = 0; i < xCoordinates.length; i += 1) {
+    circle(xCoordinates[i], 50, 20);
+  }
+
+  
+ +
// Draw circles with a for...of statement.
+
+  let xCoordinates = [20, 40, 60];
+
+
+  for (let x of xCoordinates) {
+    circle(x, 50, 20);
+  }
+
+  
+ +

In the code snippets above, the variables i and x + have different roles.

+ +

In the first snippet, i counts from 0 up to + 2, which is one less than + + xCoordinates.length. i is used to access the element + in xCoordinates + + at index i.

+ +

In the second code snippet, x isn't keeping track of the + loop's progress + + or an index. During each iteration, x contains the next element + of + + xCoordinates. x starts from the beginning of + xCoordinates (20) and + + updates its value to 40 and then 60 during the next + iterations.

+line: 1648 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('Five black vertical lines on a gray background.'); + } + + function draw() { + background(200); + + // Draw vertical lines using a loop. + for (let x = 10; x < 100; x += 20) { + line(x, 25, x, 75); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('Five white concentric circles drawn on a gray background.'); + } + + function draw() { + background(200); + + // Draw concentric circles using a loop. + for (let d = 100; d > 0; d -= 20) { + circle(50, 50, d); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A grid of black dots on a gray background.'); + } + + function draw() { + background(200); + + // Set the spacing for points on the grid. + let space = 10; + + // Increase the stroke weight. + strokeWeight(3); + + // Loop from the left to the right. + for (let x = space; x < 100; x += space) { + // Loop from the top to the bottom. + for (let y = space; y < 100; y += space) { + point(x, y); + } + } + } + +
+ +
+ + // Declare the variable xCoordinates and assign it an array of numbers. + let xCoordinates = [20, 40, 60, 80]; + + function setup() { + createCanvas(100, 100); + + describe('Four white circles drawn in a horizontal line on a gray background.'); + } + + function draw() { + background(200); + + // Access the element at index i and use it to draw a circle. + for (let i = 0; i < xCoordinates.length; i += 1) { + circle(xCoordinates[i], 50, 20); + } + } + +
+ +
+ + // Declare the variable xCoordinates and assign it an array of numbers. + let xCoordinates = [20, 40, 60, 80]; + + function setup() { + createCanvas(100, 100); + + describe('Four white circles drawn in a horizontal line on a gray background.'); + } + + function draw() { + background(200); + + // Access each element of the array and use it to draw a circle. + for (let x of xCoordinates) { + circle(x, 50, 20); + } + } + +
+class: p5 +--- + + +# for diff --git a/src/content/reference/en/p5 copy/fract.mdx b/src/content/reference/en/p5 copy/fract.mdx new file mode 100644 index 0000000000..399f144c09 --- /dev/null +++ b/src/content/reference/en/p5 copy/fract.mdx @@ -0,0 +1,55 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L1048 +title: fract +module: Math +submodule: Calculation +file: src/math/calculation.js +description: | +

Calculates the fractional part of a number.

+

A number's fractional part includes its decimal values. For example, + fract(12.34) returns 0.34.

+line: 1048 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Original number. + let n = 56.78; + text(n, 50, 33); + + // Fractional part. + let f = fract(n); + text(f, 50, 67); + + describe('The number 56.78 written above the number 0.78.'); + } + +
+class: p5 +params: + - name: 'n' + description: | +

number whose fractional part will be found.

+ type: Number +return: + description: fractional part of n. + type: Number +chainable: false +--- + + +# fract diff --git a/src/content/reference/en/p5 copy/frameCount.mdx b/src/content/reference/en/p5 copy/frameCount.mdx new file mode 100644 index 0000000000..f2d02603a0 --- /dev/null +++ b/src/content/reference/en/p5 copy/frameCount.mdx @@ -0,0 +1,73 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L69 +title: frameCount +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

A Number variable that tracks the number of frames drawn since + the sketch + + started.

+ +

frameCount's value is 0 inside setup(). It + + increments by 1 each time the code in draw() + + finishes executing.

+line: 69 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Display the value of + // frameCount. + textSize(30); + textAlign(CENTER, CENTER); + text(frameCount, 50, 50); + + describe('The number 0 written in black in the middle of a gray square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Set the frameRate to 30. + frameRate(30); + + textSize(30); + textAlign(CENTER, CENTER); + + describe('A number written in black in the middle of a gray square. Its value increases rapidly.'); + } + + function draw() { + background(200); + + // Display the value of + // frameCount. + text(frameCount, 50, 50); + } + +
+class: p5 +type: Integer +--- + + +# frameCount diff --git a/src/content/reference/en/p5 copy/frameRate.mdx b/src/content/reference/en/p5 copy/frameRate.mdx new file mode 100644 index 0000000000..38ccddd0d6 --- /dev/null +++ b/src/content/reference/en/p5 copy/frameRate.mdx @@ -0,0 +1,107 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L330 +title: frameRate +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

Sets the number of frames to draw per second.

+ +

Calling frameRate() with one numeric argument, as in + frameRate(30), + + attempts to draw 30 frames per second (FPS). The target frame rate may not + + be achieved depending on the sketch's processing needs. Most computers + + default to a frame rate of 60 FPS. Frame rates of 24 FPS and above are + + fast enough for smooth animations.

+ +

Calling frameRate() without an argument returns the current + frame rate. + + The value returned is an approximation.

+line: 330 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A white circle on a gray background. The circle moves from left to right in a loop. It slows down when the mouse is pressed.'); + } + + function draw() { + background(200); + + // Set the x variable based + // on the current frameCount. + let x = frameCount % 100; + + // If the mouse is pressed, + // decrease the frame rate. + if (mouseIsPressed === true) { + frameRate(10); + } else { + frameRate(60); + } + + // Use x to set the circle's + // position. + circle(x, 50, 20); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A number written in black on a gray background. The number decreases when the mouse is pressed.'); + } + + function draw() { + background(200); + + // If the mouse is pressed, do lots + // of math to slow down drawing. + if (mouseIsPressed === true) { + for (let i = 0; i < 1000000; i += 1) { + random(); + } + } + + // Get the current frame rate + // and display it. + let fps = frameRate(); + text(fps, 50, 50); + } + +
+class: p5 +overloads: + - line: 330 + params: + - name: fps + description: | +

number of frames to draw per second.

+ type: Number + chainable: 1 + - line: 404 + params: [] + return: + description: current frame rate. + type: Number +chainable: true +--- + + +# frameRate diff --git a/src/content/reference/en/p5 copy/freeGeometry.mdx b/src/content/reference/en/p5 copy/freeGeometry.mdx new file mode 100644 index 0000000000..7af36d8620 --- /dev/null +++ b/src/content/reference/en/p5 copy/freeGeometry.mdx @@ -0,0 +1,152 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L748 +title: freeGeometry +module: Shape +submodule: 3D Primitives +file: src/webgl/3d_primitives.js +description: > +

Clears a p5.Geometry object from + the graphics + + processing unit (GPU) memory.

+ +

p5.Geometry objects can contain + lots of data + + about their vertices, surface normals, colors, and so on. Complex 3D shapes + + can use lots of memory which is a limited resource in many GPUs. Calling + + freeGeometry() can improve performance by freeing a + + p5.Geometry object’s resources from + GPU memory. + + freeGeometry() works with p5.Geometry objects + + created with beginGeometry() and + + endGeometry(), + + buildGeometry(), and + + loadModel().

+ +

The parameter, geometry, is the p5.Geometry + + object to be freed.

+ +

Note: A p5.Geometry object can + still be drawn + + after its resources are cleared from GPU memory. It may take longer to draw + + the first time it’s redrawn.

+ +

Note: freeGeometry() can only be used in WebGL mode.

+line: 748 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + // Create a p5.Geometry object. + beginGeometry(); + cone(); + let shape = endGeometry(); + + // Draw the shape. + model(shape); + + // Free the shape's resources. + freeGeometry(shape); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let button; + let particles; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a button to reset the particle system. + button = createButton('Reset'); + + // Call resetModel() when the user presses the button. + button.mousePressed(resetModel); + + // Add the original set of particles. + resetModel(); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the particles. + noStroke(); + + // Draw the particles. + model(particles); + } + + function resetModel() { + // If the p5.Geometry object has already been created, + // free those resources. + if (particles) { + freeGeometry(particles); + } + + // Create a new p5.Geometry object with random spheres. + particles = buildGeometry(createParticles); + } + + function createParticles() { + for (let i = 0; i < 60; i += 1) { + // Calculate random coordinates. + let x = randomGaussian(0, 20); + let y = randomGaussian(0, 20); + let z = randomGaussian(0, 20); + + push(); + // Translate to the particle's coordinates. + translate(x, y, z); + // Draw the particle. + sphere(5); + pop(); + } + } + +
+class: p5 +params: + - name: geometry + description: | +

3D shape whose resources should be freed.

+ type: p5.Geometry +chainable: false +--- + + +# freeGeometry diff --git a/src/content/reference/en/p5 copy/freqToMidi.mdx b/src/content/reference/en/p5 copy/freqToMidi.mdx new file mode 100644 index 0000000000..12c6e1eff9 --- /dev/null +++ b/src/content/reference/en/p5 copy/freqToMidi.mdx @@ -0,0 +1,29 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L825 +title: freqToMidi +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: | +

Returns the closest MIDI note value for + a given frequency.

+line: 825 +isConstructor: false +itemtype: method +class: p5 +params: + - name: frequency + description: | +

A freqeuncy, for example, the "A" + above Middle C is 440Hz

+ type: Number +return: + description: MIDI note value + type: Number +chainable: false +--- + + +# freqToMidi diff --git a/src/content/reference/en/p5 copy/frustum.mdx b/src/content/reference/en/p5 copy/frustum.mdx new file mode 100644 index 0000000000..01ffd87883 --- /dev/null +++ b/src/content/reference/en/p5 copy/frustum.mdx @@ -0,0 +1,175 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L522 +title: frustum +module: 3D +submodule: Camera +file: src/webgl/p5.Camera.js +description: > +

Sets the frustum of the current camera in a 3D sketch.

+ +

In a frustum projection, shapes that are further from the camera appear + + smaller than shapes that are near the camera. This technique, called + + foreshortening, creates realistic 3D scenes.

+ +

frustum() changes the default camera’s perspective by changing + its + + viewing frustum. The frustum is the volume of space that’s visible to the + + camera. The frustum’s shape is a pyramid with its top cut off. The camera + + is placed where the top of the pyramid should be and points towards the + + base of the pyramid. It views everything within the frustum.

+ +

The first four parameters, left, right, + bottom, and top, set the + + coordinates of the frustum’s sides, bottom, and top. For example, calling + + frustum(-100, 100, 200, -200) creates a frustum that’s 200 pixels + wide + + and 400 pixels tall. By default, these coordinates are set based on the + + sketch’s width and height, as in + + ortho(-width / 20, width / 20, height / 20, -height / 20).

+ +

The last two parameters, near and far, set the + distance of the + + frustum’s near and far plane from the camera. For example, calling + + ortho(-100, 100, 200, -200, 50, 1000) creates a frustum that’s + 200 pixels + + wide, 400 pixels tall, starts 50 pixels from the camera, and ends 1,000 + + pixels from the camera. By default, near is set to 0.1 * 800, + which is + + 1/10th the default distance between the camera and the origin. + far is set + + to 10 * 800, which is 10 times the default distance between the + camera + + and the origin.

+ +

Note: frustum() can only be used in WebGL mode.

+line: 522 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A row of white cubes on a gray background.'); + } + + function draw() { + background(200); + + // Apply the default frustum projection. + frustum(); + + // Translate the origin toward the camera. + translate(-10, 10, 600); + + // Rotate the coordinate system. + rotateY(-0.1); + rotateX(-0.1); + + // Draw the row of boxes. + for (let i = 0; i < 6; i += 1) { + translate(0, 0, -40); + box(10); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Adjust the frustum. + // Center it. + // Set its width and height to 20 pixels. + // Place its near plane 300 pixels from the camera. + // Place its far plane 350 pixels from the camera. + frustum(-10, 10, -10, 10, 300, 350); + + // Translate the origin toward the camera. + translate(-10, 10, 600); + + // Rotate the coordinate system. + rotateY(-0.1); + rotateX(-0.1); + + // Draw the row of boxes. + for (let i = 0; i < 6; i += 1) { + translate(0, 0, -40); + box(10); + } + } + +
+class: p5 +params: + - name: left + description: > +

x-coordinate of the frustum’s left plane. Defaults to -width / + 20.

+ type: Number + optional: true + - name: right + description: > +

x-coordinate of the frustum’s right plane. Defaults to width / + 20.

+ type: Number + optional: true + - name: bottom + description: > +

y-coordinate of the frustum’s bottom plane. Defaults to height / + 20.

+ type: Number + optional: true + - name: top + description: > +

y-coordinate of the frustum’s top plane. Defaults to -height / + 20.

+ type: Number + optional: true + - name: near + description: > +

z-coordinate of the frustum’s near plane. Defaults to 0.1 * + 800.

+ type: Number + optional: true + - name: far + description: > +

z-coordinate of the frustum’s far plane. Defaults to 10 * + 800.

+ type: Number + optional: true +chainable: true +--- + + +# frustum diff --git a/src/content/reference/en/p5 copy/fullscreen.mdx b/src/content/reference/en/p5 copy/fullscreen.mdx new file mode 100644 index 0000000000..1c6b2eb7fe --- /dev/null +++ b/src/content/reference/en/p5 copy/fullscreen.mdx @@ -0,0 +1,63 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L950 +title: fullscreen +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

Toggles full-screen mode or returns the current mode.

+ +

Calling fullscreen(true) makes the sketch full-screen. Calling + + fullscreen(false) makes the sketch its original size.

+ +

Calling fullscreen() without an argument returns + true if the sketch + + is in full-screen mode and false if not.

+ +

Note: Due to browser restrictions, fullscreen() can only be + called with + + user input such as a mouse press.

+line: 950 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + background(200); + + describe('A gray canvas that switches between default and full-screen display when clicked.'); + } + + // If the mouse is pressed, + // toggle full-screen mode. + function mousePressed() { + if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) { + let fs = fullscreen(); + fullscreen(!fs); + } + } + +
+class: p5 +params: + - name: val + description: | +

whether the sketch should be in fullscreen mode.

+ type: Boolean + optional: true +return: + description: current fullscreen state. + type: Boolean +chainable: false +--- + + +# fullscreen diff --git a/src/content/reference/en/p5 copy/function.mdx b/src/content/reference/en/p5 copy/function.mdx new file mode 100644 index 0000000000..e213633c86 --- /dev/null +++ b/src/content/reference/en/p5 copy/function.mdx @@ -0,0 +1,19 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L317 +title: function +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: "

A named group of statements.

\n

Functions\nhelp with organizing and reusing code. For example, functions make it easy\nto express the idea \"Draw a flower.\":

\n
function drawFlower() {\n  // Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(20);\n\n  // Draw a flower emoji.\n  text('\U0001F338', 50, 50);\n}\n
\n

The function header begins with the keyword function. The function's\nname, drawFlower, is followed by parentheses () and curly braces {}.\nThe code between the curly braces is called the function's body. The\nfunction's body runs when the function is called like so:

\n
drawFlower();\n
\n

Functions can accept inputs by adding parameters to their headers.\nParameters are placeholders for values that will be provided when the\nfunction is called. For example, the drawFlower() function could include\na parameter for the flower's size:

\n
function drawFlower(size) {\n  // Style the text.\n  textAlign(CENTER, CENTER);\n\n  // Use the size parameter.\n  textSize(size);\n\n  // Draw a flower emoji.\n  text('\U0001F338', 50, 50);\n}\n
\n

Parameters are part of the function's declaration. Arguments are provided\nby the code that calls a function. When a function is called, arguments are\nassigned to parameters:

\n
// The argument 20 is assigned to the parameter size.\ndrawFlower(20);\n
\n

Functions can have multiple parameters separated by commas. Parameters\ncan have any type. For example, the drawFlower() function could accept\nNumber parameters for the flower's x- and y-coordinates along with its\nsize:

\n
function drawFlower(x, y, size) {\n  // Style the text.\n  textAlign(CENTER, CENTER);\n\n  // Use the size parameter.\n  textSize(size);\n\n  // Draw a flower emoji.\n  // Use the x and y parameters.\n  text('\U0001F338', x, y);\n}\n
\n

Functions can also produce outputs by adding a return statement:

\n
function double(x) {\n  let answer = 2 * x;\n  return answer;\n}\n
\n

The expression following return can produce an output that's used\nelsewhere. For example, the output of the double() function can be\nassigned to a variable:

\n
let six = double(3);\ntext(`3 x 2 = ${six}`, 50, 50);\n
\n" +line: 317 +isConstructor: false +itemtype: property +example: + - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n describe('A pink flower on a gray background.');\n}\n\nfunction draw() {\n background(200);\n\n // Call the drawFlower() function.\n drawFlower();\n}\n\n// Declare a function that draws a flower at the\n// center of the canvas.\nfunction drawFlower() {\n // Style the text.\n textAlign(CENTER, CENTER);\n textSize(20);\n\n // Draw a flower emoji.\n text('\U0001F338', 50, 50);\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n describe('A pink flower on a gray background.');\n}\n\nfunction draw() {\n background(200);\n\n // Call the drawFlower() function and pass values for\n // its position and size.\n drawFlower(50, 50, 20);\n}\n\n// Declare a function that draws a flower at the\n// center of the canvas.\nfunction drawFlower(x, y, size) {\n // Style the text.\n textAlign(CENTER, CENTER);\n\n // Use the size parameter.\n textSize(size);\n\n // Draw a flower emoji.\n // Use the x and y parameters.\n text('\U0001F338', x, y);\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n describe('The message \"Hello, \U0001F30D!\" written on a gray background.');\n}\n\nfunction draw() {\n background(200);\n\n // Create a greeting.\n let greeting = createGreeting('\U0001F30D');\n\n // Style the text.\n textAlign(CENTER, CENTER);\n textSize(16);\n\n // Display the greeting.\n text(greeting, 50, 50);\n}\n\n// Return a string with a personalized greeting.\nfunction createGreeting(name) {\n let message = `Hello, ${name}!`;\n return message;\n}\n\n
" +class: p5 +--- + + +# function diff --git a/src/content/reference/en/p5 copy/get.mdx b/src/content/reference/en/p5 copy/get.mdx new file mode 100644 index 0000000000..42cbb8e7f8 --- /dev/null +++ b/src/content/reference/en/p5 copy/get.mdx @@ -0,0 +1,178 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L820 +title: get +module: Image +submodule: Pixels +file: src/image/pixels.js +description: > +

Gets a pixel or a region of pixels from the canvas.

+ +

get() is easy to use but it's not as fast as + + pixels. Use pixels + + to read many pixel values.

+ +

The version of get() with no parameters returns the entire + canvas.

+ +

The version of get() with two parameters interprets them as + + coordinates. It returns an array with the [R, G, B, A] values of + the + + pixel at the given point.

+ +

The version of get() with four parameters interprets them as + coordinates + + and dimensions. It returns a subsection of the canvas as a + + p5.Image object. The first two parameters + are the + + coordinates for the upper-left corner of the subsection. The last two + + parameters are the width and height of the subsection.

+ +

Use p5.Image.get() to work directly + with + + p5.Image objects.

+line: 820 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/rockies.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Get the entire canvas. + let c = get(); + + // Display half the canvas. + image(c, 50, 0); + + describe('Two identical mountain landscapes shown side-by-side.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/rockies.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Get the color of a pixel. + let c = get(50, 90); + + // Style the square with the pixel's color. + fill(c); + noStroke(); + + // Display the square. + square(25, 25, 50); + + describe('A mountain landscape with an olive green square in its center.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/rockies.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Get a region of the image. + let c = get(0, 0, 50, 50); + + // Display the region. + image(c, 50, 50); + + describe('A mountain landscape drawn on top of another mountain landscape.'); + } + +
+class: p5 +return: + description: subsection as a p5.Image object. + type: p5.Image +overloads: + - line: 820 + params: + - name: x + description: | +

x-coordinate of the pixel.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the pixel.

+ type: Number + - name: w + description: | +

width of the subsection to be returned.

+ type: Number + - name: h + description: | +

height of the subsection to be returned.

+ type: Number + return: + description: subsection as a p5.Image object. + type: p5.Image + - line: 931 + params: [] + return: + description: whole canvas as a p5.Image. + type: p5.Image + - line: 935 + params: + - name: x + description: '' + type: Number + - name: 'y' + description: '' + type: Number + return: + description: 'color of the pixel at (x, y) in array format `[R, G, B, A]`.' + type: 'Number[]' +chainable: false +--- + + +# get diff --git a/src/content/reference/en/p5 copy/getAudioContext.mdx b/src/content/reference/en/p5 copy/getAudioContext.mdx new file mode 100644 index 0000000000..c7291c5cdf --- /dev/null +++ b/src/content/reference/en/p5 copy/getAudioContext.mdx @@ -0,0 +1,56 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L159 +title: getAudioContext +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: >- +

Returns the Audio Context for this sketch. Useful for users + + who would like to dig deeper into the Web Audio API + + .

+ + +

Some browsers require users to startAudioContext + + with a user gesture, such as touchStarted in the example below.

+line: 159 +isConstructor: false +itemtype: method +example: + - |- + +
+ function draw() { + background(255); + textAlign(CENTER); + + if (getAudioContext().state !== 'running') { + text('click to start audio', width/2, height/2); + } else { + text('audio is enabled', width/2, height/2); + } + } + + function touchStarted() { + if (getAudioContext().state !== 'running') { + getAudioContext().resume(); + } + var synth = new p5.MonoSynth(); + synth.play('A4', 0.5, 0, 0.2); + } + +
+class: p5 +return: + description: AudioContext for this sketch + type: Object +chainable: false +--- + + +# getAudioContext diff --git a/src/content/reference/en/p5 copy/getItem.mdx b/src/content/reference/en/p5 copy/getItem.mdx new file mode 100644 index 0000000000..5747f67366 --- /dev/null +++ b/src/content/reference/en/p5 copy/getItem.mdx @@ -0,0 +1,151 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/data/local_storage.js#L164 +title: getItem +module: Data +submodule: LocalStorage +file: src/data/local_storage.js +description: > +

Returns a value in the web browser's local storage.

+ +

Web browsers can save small amounts of data using the built-in + + localStorage object. + + Data stored in localStorage can be retrieved at any point, even + after + + refreshing a page or restarting the browser. Data are stored as key-value + + pairs.

+ +

storeItem() makes it easy to store + values in + + localStorage and getItem() makes it easy to retrieve + them.

+ +

The first parameter, key, is the name of the value to be + stored as a + + string.

+ +

The second parameter, value, is the value to be retrieved a + string. For + + example, calling getItem('size') retrieves the value with the key + size.

+ +

Note: Sensitive data such as passwords or personal information shouldn't be + + stored in localStorage.

+line: 164 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Store the player's name. + storeItem('name', 'Feist'); + + // Store the player's score. + storeItem('score', 1234); + + describe('The text "Feist: 1234" written in black on a gray background.'); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(14); + + // Retrieve the name. + let name = getItem('name'); + + // Retrieve the score. + let score = getItem('score'); + + // Display the score. + text(`${name}: ${score}`, 50, 50); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Create an object. + let p = { x: 50, y: 50 }; + + // Store the object. + storeItem('position', p); + + describe('A white circle on a gray background.'); + } + + function draw() { + background(200); + + // Retrieve the object. + let p = getItem('position'); + + // Draw the circle. + circle(p.x, p.y, 30); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Create a p5.Color object. + let c = color('deeppink'); + + // Store the object. + storeItem('color', c); + + describe('A pink circle on a gray background.'); + } + + function draw() { + background(200); + + // Retrieve the object. + let c = getItem('color'); + + // Style the circle. + fill(c); + + // Draw the circle. + circle(50, 50, 30); + } + +
+class: p5 +params: + - name: key + description: | +

name of the value.

+ type: String +return: + description: stored item. + type: String|Number|Boolean|Object|Array +chainable: false +--- + + +# getItem diff --git a/src/content/reference/en/p5 copy/getOutputVolume.mdx b/src/content/reference/en/p5 copy/getOutputVolume.mdx new file mode 100644 index 0000000000..6542c5edb6 --- /dev/null +++ b/src/content/reference/en/p5 copy/getOutputVolume.mdx @@ -0,0 +1,25 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L726 +title: getOutputVolume +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: | +

Returns a number representing the output volume for sound + in this sketch.

+line: 726 +isConstructor: false +itemtype: method +class: p5 +return: + description: |- + Output volume for sound in this sketch. + Should be between 0.0 (silence) and 1.0. + type: Number +chainable: false +--- + + +# getOutputVolume diff --git a/src/content/reference/en/p5 copy/getTargetFrameRate.mdx b/src/content/reference/en/p5 copy/getTargetFrameRate.mdx new file mode 100644 index 0000000000..10e3c74a4b --- /dev/null +++ b/src/content/reference/en/p5 copy/getTargetFrameRate.mdx @@ -0,0 +1,48 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L447 +title: getTargetFrameRate +module: Environment +submodule: Environment +file: src/core/environment.js +description: | +

Returns the target frame rate.

+

The value is either the system frame rate or the last value passed to + frameRate().

+line: 447 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('The number 20 written in black on a gray background.'); + } + + function draw() { + background(200); + + // Set the frame rate to 20. + frameRate(20); + + // Get the target frame rate and + // display it. + let fps = getTargetFrameRate(); + text(fps, 43, 54); + } + +
+class: p5 +return: + description: _targetFrameRate + type: Number +chainable: false +--- + + +# getTargetFrameRate diff --git a/src/content/reference/en/p5 copy/getURL.mdx b/src/content/reference/en/p5 copy/getURL.mdx new file mode 100644 index 0000000000..01ccdc8e11 --- /dev/null +++ b/src/content/reference/en/p5 copy/getURL.mdx @@ -0,0 +1,46 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L1149 +title: getURL +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

Returns the sketch's current + + URL + + as a String.

+line: 1149 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + background(200); + + // Get the sketch's URL + // and display it. + let url = getURL(); + textWrap(CHAR); + text(url, 0, 40, 100); + + describe('The URL "https://p5js.org/reference/p5/getURL" written in black on a gray background.'); + } + +
+class: p5 +return: + description: url + type: String +chainable: false +--- + + +# getURL diff --git a/src/content/reference/en/p5 copy/getURLParams.mdx b/src/content/reference/en/p5 copy/getURLParams.mdx new file mode 100644 index 0000000000..c08c77f23f --- /dev/null +++ b/src/content/reference/en/p5 copy/getURLParams.mdx @@ -0,0 +1,59 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L1208 +title: getURLParams +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

Returns the current + + URL parameters + + in an Object.

+ +

For example, calling getURLParams() in a sketch hosted at the + URL + + https://p5js.org?year=2014&month=May&day=15 returns + + { year: 2014, month: 'May', day: 15 }.

+line: 1208 +isConstructor: false +itemtype: method +alt: This example does not render anything. +example: + - |- + +
+ + // Imagine this sketch is hosted at the following URL: + // https://p5js.org?year=2014&month=May&day=15 + + function setup() { + background(200); + + // Get the sketch's URL + // parameters and display + // them. + let params = getURLParams(); + text(params.day, 10, 20); + text(params.month, 10, 40); + text(params.year, 10, 60); + + describe('The text "15", "May", and "2014" written in black on separate lines.'); + } + +
+class: p5 +return: + description: URL params + type: Object +chainable: false +--- + + +# getURLParams diff --git a/src/content/reference/en/p5 copy/getURLPath.mdx b/src/content/reference/en/p5 copy/getURLPath.mdx new file mode 100644 index 0000000000..e71b7746ad --- /dev/null +++ b/src/content/reference/en/p5 copy/getURLPath.mdx @@ -0,0 +1,58 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L1175 +title: getURLPath +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

Returns the current + + URL + + path as an Array of Strings.

+ +

For example, consider a sketch hosted at the URL + + https://example.com/sketchbook. Calling getURLPath() + returns + + ['sketchbook']. For a sketch hosted at the URL + + https://example.com/sketchbook/monday, getURLPath() + returns + + ['sketchbook', 'monday'].

+line: 1175 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + background(200); + + // Get the sketch's URL path + // and display the first + // part. + let path = getURLPath(); + text(path[0], 25, 54); + + describe('The word "reference" written in black on a gray background.'); + } + +
+class: p5 +return: + description: path components. + type: 'String[]' +chainable: false +--- + + +# getURLPath diff --git a/src/content/reference/en/p5 copy/green.mdx b/src/content/reference/en/p5 copy/green.mdx new file mode 100644 index 0000000000..72634492fb --- /dev/null +++ b/src/content/reference/en/p5 copy/green.mdx @@ -0,0 +1,159 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L692 +title: green +module: Color +submodule: Creating & Reading +file: src/color/creating_reading.js +description: > +

Gets the green value of a color.

+ +

green() extracts the green value from a + + p5.Color object, an array of color + components, or + + a CSS color string.

+ +

By default, green() returns a color's green value in the range + 0 + + to 255. If the colorMode() is set to + RGB, it + + returns the green value in the given range.

+line: 692 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object. + let c = color(175, 100, 220); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'greenValue' to 100. + let greenValue = green(c); + + // Draw the right rectangle. + fill(0, greenValue, 0); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is dark green.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a color array. + let c = [175, 100, 220]; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'greenValue' to 100. + let greenValue = green(c); + + // Draw the right rectangle. + fill(0, greenValue, 0); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is dark green.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a CSS color string. + let c = 'rgb(175, 100, 220)'; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'greenValue' to 100. + let greenValue = green(c); + + // Draw the right rectangle. + fill(0, greenValue, 0); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is dark green.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use RGB color with values in the range 0-100. + colorMode(RGB, 100); + + // Create a p5.Color object using RGB values. + let c = color(69, 39, 86); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'greenValue' to 39. + let greenValue = green(c); + + // Draw the right rectangle. + fill(0, greenValue, 0); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is dark green.'); + } + +
+class: p5 +params: + - name: color + description: | +

p5.Color object, array of + color components, or CSS color string.

+ type: 'p5.Color|Number[]|String' +return: + description: the green value. + type: Number +chainable: false +--- + + +# green diff --git a/src/content/reference/en/p5 copy/gridOutput.mdx b/src/content/reference/en/p5 copy/gridOutput.mdx new file mode 100644 index 0000000000..c80c3efaf2 --- /dev/null +++ b/src/content/reference/en/p5 copy/gridOutput.mdx @@ -0,0 +1,189 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/accessibility/outputs.js#L161 +title: gridOutput +module: Environment +submodule: Environment +file: src/accessibility/outputs.js +description: > +

Creates a screen reader-accessible description of shapes on the canvas.

+ +

gridOutput() adds a general description, table of shapes, and + list of + + shapes to the web page. The general description includes the canvas size, + + canvas color, and number of shapes. For example, + + gray canvas, 100 by 100 pixels, contains 2 shapes: 1 circle 1 + square.

+ +

gridOutput() uses its table of shapes as a grid. Each shape in + the grid + + is placed in a cell whose row and column correspond to the shape's location + + on the canvas. The grid cells describe the color and type of shape at that + + location. For example, red circle. These descriptions can be + selected + + individually to get more details. This is different from + + textOutput(), which uses its table as + a list.

+ +

A list of shapes follows the table. The list describes the color, type, + + location, and area of each shape. For example, + + red circle, location = middle, area = 3 %.

+ +

The display parameter is optional. It determines how the + description is + + displayed. If LABEL is passed, as in + gridOutput(LABEL), the description + + will be visible in a div element next to the canvas. Using LABEL + creates + + unhelpful duplicates for screen readers. Only use LABEL during + + development. If FALLBACK is passed, as in + gridOutput(FALLBACK), the + + description will only be visible to screen readers. This is the default + + mode.

+ +

Read + + Writing + accessible canvas descriptions + + to learn more about making sketches accessible.

+ +

gridOutput() generates descriptions in English only. Text + drawn with + + text() is not described. Shapes created with + + beginShape() are not described. WEBGL + mode + + and 3D shapes are not supported.

+ +

Use describe() and + + describeElement() for more + control + + over canvas descriptions.

+line: 161 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + // Add the grid description. + gridOutput(); + + // Draw a couple of shapes. + background(200); + fill(255, 0, 0); + circle(20, 20, 20); + fill(0, 0, 255); + square(50, 50, 50); + + // Add a general description of the canvas. + describe('A red circle and a blue square on a gray background.'); + } + +
+ +
+ + function setup() { + // Add the grid description and + // display it for debugging. + gridOutput(LABEL); + + // Draw a couple of shapes. + background(200); + fill(255, 0, 0); + circle(20, 20, 20); + fill(0, 0, 255); + square(50, 50, 50); + + // Add a general description of the canvas. + describe('A red circle and a blue square on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + } + + function draw() { + // Add the grid description. + gridOutput(); + + // Draw a moving circle. + background(200); + let x = frameCount * 0.1; + fill(255, 0, 0); + circle(x, 20, 20); + fill(0, 0, 255); + square(50, 50, 50); + + // Add a general description of the canvas. + describe('A red circle moves from left to right above a blue square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + } + + function draw() { + // Add the grid description and + // display it for debugging. + gridOutput(LABEL); + + // Draw a moving circle. + background(200); + let x = frameCount * 0.1; + fill(255, 0, 0); + circle(x, 20, 20); + fill(0, 0, 255); + square(50, 50, 50); + + // Add a general description of the canvas. + describe('A red circle moves from left to right above a blue square.'); + } + +
+class: p5 +params: + - name: display + description: | +

either FALLBACK or LABEL.

+ type: Constant + optional: true +chainable: false +--- + + +# gridOutput diff --git a/src/content/reference/en/p5 copy/height.mdx b/src/content/reference/en/p5 copy/height.mdx new file mode 100644 index 0000000000..f6321218df --- /dev/null +++ b/src/content/reference/en/p5 copy/height.mdx @@ -0,0 +1,87 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L881 +title: height +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

A Number variable that stores the height of the canvas in + pixels.

+ +

height's default value is 100. Calling + + createCanvas() or + + resizeCanvas() changes the value of + + height. Calling noCanvas() + sets its value to + + 0.

+line: 881 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + background(200); + + // Display the canvas' height. + text(height, 42, 54); + + describe('The number 100 written in black on a gray square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 50); + + background(200); + + // Display the canvas' height. + text(height, 42, 27); + + describe('The number 50 written in black on a gray rectangle.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Display the canvas' height. + text(height, 42, 54); + + describe('The number 100 written in black on a gray square. When the mouse is pressed, the square becomes a rectangle and the number becomes 50.'); + } + + // If the mouse is pressed, reisze + // the canvas and display its new + // height. + function mousePressed() { + if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) { + resizeCanvas(100, 50); + background(200); + text(height, 42, 27); + } + } + +
+class: p5 +type: Number +--- + + +# height diff --git a/src/content/reference/en/p5 copy/hex.mdx b/src/content/reference/en/p5 copy/hex.mdx new file mode 100644 index 0000000000..5475af324a --- /dev/null +++ b/src/content/reference/en/p5 copy/hex.mdx @@ -0,0 +1,166 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L818 +title: hex +module: Data +submodule: Conversion +file: src/utilities/conversion.js +description: > +

Converts a Number to a String with its + hexadecimal value.

+ +

hex() converts a number to a string with its hexadecimal + number value. + + Hexadecimal (hex) numbers are base-16, which means there are 16 unique + + digits. Hex extends the numbers 0–9 with the letters A–F. For example, the + + number 11 (eleven) in base-10 is written as the letter + B in hex.

+ +

The first parameter, n, is the number to convert. For example, + hex(20), + + returns the string '00000014'. If an array is passed, as in + + hex([1, 10, 100]), an array of hexadecimal strings is + returned.

+ +

The second parameter, digits, is optional. If a number is + passed, as in + + hex(20, 2), it sets the number of hexadecimal digits to display. + For + + example, calling hex(20, 2) returns the string + '14'.

+line: 818 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a number variable. + let original = 20; + + // Convert the number to a hex string. + let converted = hex(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(14); + + // Display the original and converted values. + text(`${original} = ${converted}`, 50, 50); + + describe('The text "20 = 00000014" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a number variable. + let original = 20; + + // Convert the number to a hex string. + // Only display two hex digits. + let converted = hex(original, 2); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the original and converted values. + text(`${original} = ${converted}`, 50, 50); + + describe('The text "20 = 14" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of numbers. + let original = [1, 10, 100]; + + // Convert the numbers to hex strings. + // Only use two hex digits. + let converted = hex(original, 2); + + // Style the text. + textAlign(RIGHT, CENTER); + textSize(16); + + // Iterate over the converted values. + for (let i = 0; i < converted.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 25; + + // Display the original and converted values. + text(`${ original[i]} = ${converted[i]}`, 75, y); + } + + describe( + 'The text "1 = 01", "10 = 0A", and "100 = 64" written on three separate lines. The text is in black on a gray background.' + ); + } + +
+class: p5 +return: + description: converted hexadecimal value. + type: String +overloads: + - line: 818 + params: + - name: 'n' + description: | +

value to convert.

+ type: Number + - name: digits + description: | +

number of digits to include.

+ type: Number + optional: true + return: + description: converted hexadecimal value. + type: String + - line: 926 + params: + - name: ns + description: | +

values to convert.

+ type: 'Number[]' + - name: digits + description: '' + type: Number + optional: true + return: + description: converted hexadecimal values. + type: 'String[]' +chainable: false +--- + + +# hex diff --git a/src/content/reference/en/p5 copy/hour.mdx b/src/content/reference/en/p5 copy/hour.mdx new file mode 100644 index 0000000000..802a809d72 --- /dev/null +++ b/src/content/reference/en/p5 copy/hour.mdx @@ -0,0 +1,47 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L44 +title: hour +module: IO +submodule: Time & Date +file: src/utilities/time_date.js +description: | +

Returns the current hour as a number from 0–23.

+line: 44 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Get the current hour. + let h = hour(); + + // Style the text. + textAlign(LEFT, CENTER); + textSize(12); + textFont('Courier New'); + + // Display the hour. + text(`Current hour: ${h}`, 20, 50, 60); + + describe(`The text 'Current hour: ${h}' written in black on a gray background.`); + } + +
+class: p5 +return: + description: current hour between 0 and 23. + type: Integer +chainable: false +--- + + +# hour diff --git a/src/content/reference/en/p5 copy/httpDo.mdx b/src/content/reference/en/p5 copy/httpDo.mdx new file mode 100644 index 0000000000..52d6553248 --- /dev/null +++ b/src/content/reference/en/p5 copy/httpDo.mdx @@ -0,0 +1,150 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1208 +title: httpDo +module: IO +submodule: Input +file: src/io/files.js +description: > +

Method for executing an HTTP request. If data type is not specified, + + p5 will try to guess based on the URL, defaulting to text.

+ + For more advanced use, you may also pass in the path as the first argument + + and a object as the second argument, the signature follows the one specified + + in the Fetch API specification. + + This method is suitable for fetching files up to size of 64MB when "GET" is + used.

+line: 1208 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Examples use USGS Earthquake API: + // https://earthquake.usgs.gov/fdsnws/event/1/#methods + + // displays an animation of all USGS earthquakes + let earthquakes; + let eqFeatureIndex = 0; + + function preload() { + let url = 'https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson'; + httpDo( + url, + { + method: 'GET', + // Other Request options, like special headers for apis + headers: { authorization: 'Bearer secretKey' } + }, + function(res) { + earthquakes = res; + } + ); + } + + function draw() { + // wait until the data is loaded + if (!earthquakes || !earthquakes.features[eqFeatureIndex]) { + return; + } + clear(); + + let feature = earthquakes.features[eqFeatureIndex]; + let mag = feature.properties.mag; + let rad = mag / 11 * ((width + height) / 2); + fill(255, 0, 0, 100); + ellipse(width / 2 + random(-2, 2), height / 2 + random(-2, 2), rad, rad); + + if (eqFeatureIndex >= earthquakes.features.length) { + eqFeatureIndex = 0; + } else { + eqFeatureIndex += 1; + } + } + +
+class: p5 +return: + description: |- + A promise that resolves with the data when the operation + completes successfully or rejects with the error after + one occurs. + type: Promise +overloads: + - line: 1208 + params: + - name: path + description: | +

name of the file or url to load

+ type: String + - name: method + description: | +

either "GET", "POST", or "PUT", + defaults to "GET"

+ type: String + optional: true + - name: datatype + description: | +

"json", "jsonp", "xml", or "text"

+ type: String + optional: true + - name: data + description: | +

param data passed sent with request

+ type: Object + optional: true + - name: callback + description: | +

function to be executed after + httpGet() completes, data is passed in + as first argument

+ type: Function + optional: true + - name: errorCallback + description: | +

function to be executed if + there is an error, response is passed + in as first argument

+ type: Function + optional: true + return: + description: |- + A promise that resolves with the data when the operation + completes successfully or rejects with the error after + one occurs. + type: Promise + - line: 1279 + params: + - name: path + description: '' + type: String + - name: options + description: > +

Request object options as documented in the + "fetch" API + reference

+ type: Object + - name: callback + description: '' + type: Function + optional: true + - name: errorCallback + description: '' + type: Function + optional: true + return: + description: '' + type: Promise +chainable: false +--- + + +# httpDo diff --git a/src/content/reference/en/p5 copy/httpGet.mdx b/src/content/reference/en/p5 copy/httpGet.mdx new file mode 100644 index 0000000000..9e8591e059 --- /dev/null +++ b/src/content/reference/en/p5 copy/httpGet.mdx @@ -0,0 +1,140 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1043 +title: httpGet +module: IO +submodule: Input +file: src/io/files.js +description: > +

Method for executing an HTTP GET request. If data type is not specified, + + p5 will try to guess based on the URL, defaulting to text. This is equivalent + to + + calling httpDo(path, 'GET'). The 'binary' datatype will return + + a Blob object, and the 'arrayBuffer' datatype will return an ArrayBuffer + + which can be used to initialize typed arrays (such as Uint8Array).

+line: 1043 +isConstructor: false +itemtype: method +example: + - |- + +
+ // Examples use USGS Earthquake API: + // https://earthquake.usgs.gov/fdsnws/event/1/#methods + let earthquakes; + function preload() { + // Get the most recent earthquake in the database + let url = + 'https://earthquake.usgs.gov/fdsnws/event/1/query?' + + 'format=geojson&limit=1&orderby=time'; + httpGet(url, 'jsonp', false, function(response) { + // when the HTTP request completes, populate the variable that holds the + // earthquake data used in the visualization. + earthquakes = response; + }); + } + + function draw() { + if (!earthquakes) { + // Wait until the earthquake data has loaded before drawing. + return; + } + background(200); + // Get the magnitude and name of the earthquake out of the loaded JSON + let earthquakeMag = earthquakes.features[0].properties.mag; + let earthquakeName = earthquakes.features[0].properties.place; + ellipse(width / 2, height / 2, earthquakeMag * 10, earthquakeMag * 10); + textAlign(CENTER); + text(earthquakeName, 0, height - 30, width, 30); + noLoop(); + } +
+class: p5 +return: + description: |- + A promise that resolves with the data when the operation + completes successfully or rejects with the error after + one occurs. + type: Promise +overloads: + - line: 1043 + params: + - name: path + description: | +

name of the file or url to load

+ type: String + - name: datatype + description: | +

"json", "jsonp", "binary", "arrayBuffer", + "xml", or "text"

+ type: String + optional: true + - name: data + description: | +

param data passed sent with request

+ type: Object|Boolean + optional: true + - name: callback + description: | +

function to be executed after + httpGet() completes, data is passed in + as first argument

+ type: Function + optional: true + - name: errorCallback + description: | +

function to be executed if + there is an error, response is passed + in as first argument

+ type: Function + optional: true + return: + description: |- + A promise that resolves with the data when the operation + completes successfully or rejects with the error after + one occurs. + type: Promise + - line: 1097 + params: + - name: path + description: '' + type: String + - name: data + description: '' + type: Object|Boolean + - name: callback + description: '' + type: Function + optional: true + - name: errorCallback + description: '' + type: Function + optional: true + return: + description: '' + type: Promise + - line: 1105 + params: + - name: path + description: '' + type: String + - name: callback + description: '' + type: Function + - name: errorCallback + description: '' + type: Function + optional: true + return: + description: '' + type: Promise +chainable: false +--- + + +# httpGet diff --git a/src/content/reference/en/p5 copy/httpPost.mdx b/src/content/reference/en/p5 copy/httpPost.mdx new file mode 100644 index 0000000000..39f4fc75a0 --- /dev/null +++ b/src/content/reference/en/p5 copy/httpPost.mdx @@ -0,0 +1,165 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1119 +title: httpPost +module: IO +submodule: Input +file: src/io/files.js +description: > +

Method for executing an HTTP POST request. If data type is not specified, + + p5 will try to guess based on the URL, defaulting to text. This is equivalent + to + + calling httpDo(path, 'POST').

+line: 1119 +isConstructor: false +itemtype: method +example: + - >- + +
+ + + + // Examples use jsonplaceholder.typicode.com for a Mock Data API + + + let url = 'https://jsonplaceholder.typicode.com/posts'; + + let postData = { userId: 1, title: 'p5 Clicked!', body: 'p5.js is very + cool.' }; + + + function setup() { + createCanvas(100, 100); + background(200); + } + + + function mousePressed() { + httpPost(url, 'json', postData, function(result) { + strokeWeight(2); + text(result.body, mouseX, mouseY); + }); + } + + + +
+ + +
+ + let url = 'ttps://invalidURL'; // A bad URL that will cause errors + + let postData = { title: 'p5 Clicked!', body: 'p5.js is very cool.' }; + + + function setup() { + createCanvas(100, 100); + background(200); + } + + + function mousePressed() { + httpPost( + url, + 'json', + postData, + function(result) { + // ... won't be called + }, + function(error) { + strokeWeight(2); + text(error.toString(), mouseX, mouseY); + } + ); + } + +
+class: p5 +return: + description: |- + A promise that resolves with the data when the operation + completes successfully or rejects with the error after + one occurs. + type: Promise +overloads: + - line: 1119 + params: + - name: path + description: | +

name of the file or url to load

+ type: String + - name: datatype + description: | +

"json", "jsonp", "xml", or "text". + If omitted, httpPost() will guess.

+ type: String + optional: true + - name: data + description: | +

param data passed sent with request

+ type: Object|Boolean + optional: true + - name: callback + description: | +

function to be executed after + httpPost() completes, data is passed in + as first argument

+ type: Function + optional: true + - name: errorCallback + description: | +

function to be executed if + there is an error, response is passed + in as first argument

+ type: Function + optional: true + return: + description: |- + A promise that resolves with the data when the operation + completes successfully or rejects with the error after + one occurs. + type: Promise + - line: 1186 + params: + - name: path + description: '' + type: String + - name: data + description: '' + type: Object|Boolean + - name: callback + description: '' + type: Function + optional: true + - name: errorCallback + description: '' + type: Function + optional: true + return: + description: '' + type: Promise + - line: 1194 + params: + - name: path + description: '' + type: String + - name: callback + description: '' + type: Function + - name: errorCallback + description: '' + type: Function + optional: true + return: + description: '' + type: Promise +chainable: false +--- + + +# httpPost diff --git a/src/content/reference/en/p5 copy/hue.mdx b/src/content/reference/en/p5 copy/hue.mdx new file mode 100644 index 0000000000..6baca2b9ce --- /dev/null +++ b/src/content/reference/en/p5 copy/hue.mdx @@ -0,0 +1,145 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L828 +title: hue +module: Color +submodule: Creating & Reading +file: src/color/creating_reading.js +description: > +

Gets the hue value of a color.

+ +

hue() extracts the hue value from a + + p5.Color object, an array of color + components, or + + a CSS color string.

+ +

Hue describes a color's position on the color wheel. By default, + hue() + + returns a color's HSL hue in the range 0 to 360. If the + + colorMode() is set to HSB or HSL, it + returns the hue + + value in the given mode.

+line: 828 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use HSL color. + colorMode(HSL); + + // Create a p5.Color object. + let c = color(0, 50, 100); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 20, 35, 60); + + // Set 'hueValue' to 0. + let hueValue = hue(c); + + // Draw the right rectangle. + fill(hueValue); + rect(50, 20, 35, 60); + + describe( + 'Two rectangles. The rectangle on the left is salmon pink and the one on the right is black.' + ); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use HSL color. + colorMode(HSL); + + // Create a color array. + let c = [0, 50, 100]; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 20, 35, 60); + + // Set 'hueValue' to 0. + let hueValue = hue(c); + + // Draw the right rectangle. + fill(hueValue); + rect(50, 20, 35, 60); + + describe( + 'Two rectangles. The rectangle on the left is salmon pink and the one on the right is black.' + ); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use HSL color. + colorMode(HSL); + + // Create a CSS color string. + let c = 'rgb(255, 128, 128)'; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 20, 35, 60); + + // Set 'hueValue' to 0. + let hueValue = hue(c); + + // Draw the right rectangle. + fill(hueValue); + rect(50, 20, 35, 60); + + describe( + 'Two rectangles. The rectangle on the left is salmon pink and the one on the right is black.' + ); + } + +
+class: p5 +params: + - name: color + description: | +

p5.Color object, array of + color components, or CSS color string.

+ type: 'p5.Color|Number[]|String' +return: + description: the hue value. + type: Number +chainable: false +--- + + +# hue diff --git a/src/content/reference/en/p5 copy/if.mdx b/src/content/reference/en/p5 copy/if.mdx new file mode 100644 index 0000000000..88228b3ed0 --- /dev/null +++ b/src/content/reference/en/p5 copy/if.mdx @@ -0,0 +1,268 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L110 +title: if +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: > +

A way to choose whether to run a block of code.

+ +

if statements are helpful for running a block of code based on + a + + condition. For example, an if statement makes it easy to express + the + + idea "Draw a circle if the mouse is pressed.":

+ +
if (mouseIsPressed === true) {
+    circle(mouseX, mouseY, 20);
+  }
+
+  
+ +

The statement header begins with the keyword if. The + expression in + + parentheses mouseIsPressed === true is a Boolean + expression that's + + either true or false. The code between the curly + braces {} is the if + + statement's body. The body only runs if the Boolean expression is + true.

+ +

The mouseIsPressed system + variable is + + always true or false, so the code snippet above + could also be written + + as follows:

+ +
if (mouseIsPressed) {
+    circle(mouseX, mouseY, 20);
+  }
+
+  
+ +

An if-else statement adds a block of code that + runs if the Boolean + + expression is false. For example, here's an + if-else statement that + + expresses the idea "Draw a circle if the mouse is pressed. Otherwise, + + display a message.":

+ +
if (mouseIsPressed === true) {
+    // When true.
+    circle(mouseX, mouseY, 20);
+  } else {
+    // When false.
+    text('Click me!', 50, 50);
+  }
+
+  
+ +

There are two possible paths, or branches, in this code snippet. The + + program must follow one branch or the other.

+ +

An else-if statement makes it possible to add + more branches. + + else-if statements run different blocks of code + under different + + conditions. For example, an else-if statement makes + it easy to express + + the idea "If the mouse is on the left, paint the canvas white. If the mouse + + is in the middle, paint the canvas gray. Otherwise, paint the canvas + + black.":

+ +
if (mouseX < 33) {
+    background(255);
+  } else if (mouseX < 67) {
+    background(200);
+  } else {
+    background(0);
+  }
+
+  
+ +

if statements can add as many + else-if statements as needed. However, + + there can only be one else statement and it must be last.

+ +

if statements can also check for multiple conditions at once. + For + + example, the Boolean operator && (AND) checks + whether two expressions + + are both true:

+ +
if (keyIsPressed === true && key === 'p') {
+    text('You pressed the "p" key!', 50, 50);
+  }
+
+  
+ +

If the user is pressing a key AND that key is 'p', then a + message will + + display.

+ +

The Boolean operator || (OR) checks whether at + least one of two + + expressions is true:

+ +
if (keyIsPressed === true || mouseIsPressed ===
+  true) {
+    text('You did something!', 50, 50);
+  }
+
+  
+ +

If the user presses a key, or presses a mouse button, or both, then a + + message will display.

+ +

The body of an if statement can contain another + if statement. This is + + called a "nested if statement." For example, nested + if statements make + + it easy to express the idea "If a key is pressed, then check if the key is + + 'r'. If it is, then set the fill to red.":

+ +
if (keyIsPressed === true) {
+    if (key === 'r') {
+      fill('red');
+    }
+  }
+
+  
+ +

See Boolean and Number + + to learn more about these data types and the operations they support.

+line: 110 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // Click the mouse to show the circle. + + function setup() { + createCanvas(100, 100); + + describe( + 'A white circle on a gray background. The circle follows the mouse user clicks on the canvas.' + ); + } + + function draw() { + background(200); + + if (mouseIsPressed === true) { + circle(mouseX, mouseY, 20); + } + } + +
+ +
+ + // Click the mouse to show different shapes. + + function setup() { + createCanvas(100, 100); + + describe( + 'A white ellipse on a gray background. The ellipse becomes a circle when the user presses the mouse.' + ); + } + + function draw() { + background(200); + + if (mouseIsPressed === true) { + circle(50, 50, 20); + } else { + ellipse(50, 50, 20, 50); + } + } + +
+ +
+ + // Move the mouse to change the background color. + + function setup() { + createCanvas(100, 100); + + describe( + 'A square changes color from white to black as the user moves the mouse from left to right.' + ); + } + + function draw() { + if (mouseX < 33) { + background(255); + } else if (mouseX < 67) { + background(200); + } else { + background(0); + } + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + function setup() { + createCanvas(100, 100); + + describe( + 'A white circle drawn on a gray background. The circle changes color to red when the user presses the "r" key.' + ); + } + + function draw() { + background(200); + + if (keyIsPressed === true) { + if (key === 'r') { + fill('red'); + } + } + + circle(50, 50, 40); + } + +
+class: p5 +--- + + +# if diff --git a/src/content/reference/en/p5 copy/image.mdx b/src/content/reference/en/p5 copy/image.mdx new file mode 100644 index 0000000000..9dbd36fd22 --- /dev/null +++ b/src/content/reference/en/p5 copy/image.mdx @@ -0,0 +1,327 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L888 +title: image +module: Image +submodule: Loading & Displaying +file: src/image/loading_displaying.js +description: > +

Draws an image to the canvas.

+ +

The first parameter, img, is the source image to be drawn. + img can be + + any of the following objects:

+ + + +

The second and third parameters, dx and dy, set + the coordinates of the + + destination image's top left corner. See + + imageMode() for other ways to position + images.

+ +

Here's a diagram that explains how optional parameters work in + image():

+ +

+ +

The fourth and fifth parameters, dw and dh, are + optional. They set the + + the width and height to draw the destination image. By default, + image() + + draws the full source image at its original size.

+ +

The sixth and seventh parameters, sx and sy, are + also optional. + + These coordinates define the top left corner of a subsection to draw from + + the source image.

+ +

The eighth and ninth parameters, sw and sh, are + also optional. + + They define the width and height of a subsection to draw from the source + + image. By default, image() draws the full subsection that begins + at + + (sx, sy) and extends to the edges of the source image.

+ +

The ninth parameter, fit, is also optional. It enables a + subsection of + + the source image to be drawn without affecting its aspect ratio. If + + CONTAIN is passed, the full subsection will appear within the + destination + + rectangle. If COVER is passed, the subsection will completely + cover the + + destination rectangle. This may have the effect of zooming into the + + subsection.

+ +

The tenth and eleventh parameters, xAlign and + yAlign, are also + + optional. They determine how to align the fitted subsection. + xAlign can + + be set to either LEFT, RIGHT, or + CENTER. yAlign can be set to + + either TOP, BOTTOM, or CENTER. By + default, both xAlign and yAlign + + are set to CENTER.

+line: 888 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100); + + background(50); + + // Draw the image. + image(img, 0, 0); + + describe('An image of the underside of a white umbrella with a gridded ceiling above.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100); + + background(50); + + // Draw the image. + image(img, 10, 10); + + describe('An image of the underside of a white umbrella with a gridded ceiling above. The image has dark gray borders on its left and top.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100); + + background(50); + + // Draw the image 50x50. + image(img, 0, 0, 50, 50); + + describe('An image of the underside of a white umbrella with a gridded ceiling above. The image is drawn in the top left corner of a dark gray square.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100); + + background(50); + + // Draw the center of the image. + image(img, 25, 25, 50, 50, 25, 25, 50, 50); + + describe('An image of a gridded ceiling drawn in the center of a dark gray square.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/moonwalk.jpg'); + } + + function setup() { + createCanvas(100, 100); + + background(50); + + // Draw the image and scale it to fit within the canvas. + image(img, 0, 0, width, height, 0, 0, img.width, img.height, CONTAIN); + + describe('An image of an astronaut on the moon. The top and bottom borders of the image are dark gray.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + // Image is 50 x 50 pixels. + img = loadImage('/assets/laDefense50.png'); + } + + function setup() { + createCanvas(100, 100); + + background(50); + + // Draw the image and scale it to cover the canvas. + image(img, 0, 0, width, height, 0, 0, img.width, img.height, COVER); + + describe('A pixelated image of the underside of a white umbrella with a gridded ceiling above.'); + } + +
+class: p5 +overloads: + - line: 888 + params: + - name: img + description: | +

image to display.

+ type: p5.Image|p5.Element|p5.Texture|p5.Framebuffer|p5.FramebufferTexture + - name: x + description: | +

x-coordinate of the top-left corner of the image.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the top-left corner of the image.

+ type: Number + - name: width + description: | +

width to draw the image.

+ type: Number + optional: true + - name: height + description: | +

height to draw the image.

+ type: Number + optional: true + - line: 1074 + params: + - name: img + description: '' + type: p5.Image|p5.Element|p5.Texture|p5.Framebuffer|p5.FramebufferTexture + - name: dx + description: | +

the x-coordinate of the destination + rectangle in which to draw the source image

+ type: Number + - name: dy + description: | +

the y-coordinate of the destination + rectangle in which to draw the source image

+ type: Number + - name: dWidth + description: | +

the width of the destination rectangle

+ type: Number + - name: dHeight + description: | +

the height of the destination rectangle

+ type: Number + - name: sx + description: | +

the x-coordinate of the subsection of the source + image to draw into the destination rectangle

+ type: Number + - name: sy + description: | +

the y-coordinate of the subsection of the source + image to draw into the destination rectangle

+ type: Number + - name: sWidth + description: | +

the width of the subsection of the + source image to draw into the destination + rectangle

+ type: Number + optional: true + - name: sHeight + description: | +

the height of the subsection of the + source image to draw into the destination rectangle

+ type: Number + optional: true + - name: fit + description: | +

either CONTAIN or COVER

+ type: Constant + optional: true + - name: xAlign + description: | +

either LEFT, RIGHT or CENTER default is CENTER

+ type: Constant + optional: true + - name: yAlign + description: | +

either TOP, BOTTOM or CENTER default is CENTER

+ type: Constant + optional: true +chainable: false +--- + + +# image diff --git a/src/content/reference/en/p5 copy/imageLight.mdx b/src/content/reference/en/p5 copy/imageLight.mdx new file mode 100644 index 0000000000..70b001f3e5 --- /dev/null +++ b/src/content/reference/en/p5 copy/imageLight.mdx @@ -0,0 +1,86 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L956 +title: imageLight +module: 3D +submodule: Lights +file: src/webgl/light.js +description: > +

Creates an ambient light from an image.

+ +

imageLight() simulates a light shining from all directions. + The effect is + + like placing the sketch at the center of a giant sphere that uses the image + + as its texture. The image's diffuse light will be affected by + + fill() and the specular reflections will be + + affected by specularMaterial() + and + + shininess().

+ +

The parameter, img, is the p5.Image object to + + use as the light source.

+line: 956 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + let img; + + // Load an image and create a p5.Image object. + function preload() { + img = loadImage('/assets/outdoor_spheremap.jpg'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A sphere floating above a landscape. The surface of the sphere reflects the landscape.'); + } + + function draw() { + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the image as a panorama (360˚ background). + panorama(img); + + // Add a soft ambient light. + ambientLight(50); + + // Add light from the image. + imageLight(img); + + // Style the sphere. + specularMaterial(20); + shininess(100); + noStroke(); + + // Draw the sphere. + sphere(30); + } + +
+class: p5 +params: + - name: img + description: | +

image to use as the light source.

+ type: p5.image +chainable: false +--- + + +# imageLight diff --git a/src/content/reference/en/p5 copy/imageMode.mdx b/src/content/reference/en/p5 copy/imageMode.mdx new file mode 100644 index 0000000000..f7d41c6d54 --- /dev/null +++ b/src/content/reference/en/p5 copy/imageMode.mdx @@ -0,0 +1,129 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L1395 +title: imageMode +module: Image +submodule: Loading & Displaying +file: src/image/loading_displaying.js +description: > +

Changes the location from which images are drawn when + + image() is called.

+ +

By default, the first + + two parameters of image() are the x- and + + y-coordinates of the image's upper-left corner. The next parameters are + + its width and height. This is the same as calling + imageMode(CORNER).

+ +

imageMode(CORNERS) also uses the first two parameters of + + image() as the x- and y-coordinates of the + image's + + top-left corner. The third and fourth parameters are the coordinates of its + + bottom-right corner.

+ +

imageMode(CENTER) uses the first two parameters of + + image() as the x- and y-coordinates of the + image's + + center. The next parameters are its width and height.

+line: 1395 +isConstructor: false +itemtype: method +example: + - |- + + +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Use CORNER mode. + imageMode(CORNER); + + // Display the image. + image(img, 10, 10, 50, 50); + + describe('A square image of a brick wall is drawn at the top left of a gray square.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Use CORNERS mode. + imageMode(CORNERS); + + // Display the image. + image(img, 10, 10, 90, 40); + + describe('An image of a brick wall is drawn on a gray square. The image is squeezed into a small rectangular area.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Use CENTER mode. + imageMode(CENTER); + + // Display the image. + image(img, 50, 50, 80, 80); + + describe('A square image of a brick wall is drawn on a gray square.'); + } + +
+class: p5 +params: + - name: mode + description: | +

either CORNER, CORNERS, or CENTER.

+ type: Constant +chainable: false +--- + + +# imageMode diff --git a/src/content/reference/en/p5 copy/input.mdx b/src/content/reference/en/p5 copy/input.mdx new file mode 100644 index 0000000000..83f71feabc --- /dev/null +++ b/src/content/reference/en/p5 copy/input.mdx @@ -0,0 +1,88 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L405 +title: input +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Calls a function when the element receives input.

+ +

myElement.input() is often used to with text inputs and + sliders. Calling + + myElement.input(false) disables the function.

+line: 405 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let slider; + + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a slider and place it beneath the canvas. + slider = createSlider(0, 255, 200); + slider.position(0, 100); + + // Call repaint() when the slider changes. + slider.input(repaint); + + describe('A gray square with a range slider underneath it. The background changes shades of gray when the slider is moved.'); + } + + // Paint the background using slider's value. + function repaint() { + let g = slider.value(); + background(g); + } + +
+ +
+ + let input; + + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an input and place it beneath the canvas. + input = createInput(''); + input.position(0, 100); + + // Call repaint() when input is detected. + input.input(repaint); + + describe('A gray square with a text input bar beneath it. Any text written in the input appears in the middle of the square.'); + } + + // Paint the background gray and display the input's value. + function repaint() { + background(200); + let msg = input.value(); + text(msg, 5, 50); + } + +
+class: p5 +params: + - name: fxn + description: | +

function to call when input is detected within + the element. + false disables the function.

+ type: Function|Boolean +chainable: true +--- + + +# input diff --git a/src/content/reference/en/p5 copy/int.mdx b/src/content/reference/en/p5 copy/int.mdx new file mode 100644 index 0000000000..5d5fe8826a --- /dev/null +++ b/src/content/reference/en/p5 copy/int.mdx @@ -0,0 +1,169 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L92 +title: int +module: Data +submodule: Conversion +file: src/utilities/conversion.js +description: > +

Converts a Boolean, String, or decimal + Number to an integer.

+ +

int() converts values to integers. Integers are positive or + negative + + numbers without decimals. If the original value has decimals, as in -34.56, + + they're removed to produce an integer such as -34.

+ +

The parameter, n, is the value to convert. If n + is a Boolean, as in + + int(false) or int(true), then the number 0 + (false) or 1 (true) will + + be returned. If n is a string or number, as in + int('45') or + + int(67.89), then an integer will be returned. If an array is + passed, as + + in int([12.34, 56.78]), then an array of integers will be + returned.

+ +

Note: If a value can't be converted to a number, as in + int('giraffe'), + + then the value NaN (not a number) will be returned.

+line: 92 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a Boolean variable. + let original = false; + + // Convert the Boolean to an integer. + let converted = int(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the original and converted values. + text(`${original} : ${converted}`, 50, 50); + + describe('The text "false : 0" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let original = '12.34'; + + // Convert the string to an integer. + let converted = int(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(14); + + // Display the original and converted values. + text(`${original} ≈ ${converted}`, 50, 50); + + describe('The text "12.34 ≈ 12" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a decimal number variable. + let original = 12.34; + + // Convert the decimal number to an integer. + let converted = int(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(14); + + // Display the original and converted values. + text(`${original} ≈ ${converted}`, 50, 50); + + describe('The text "12.34 ≈ 12" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of strings. + let original = ['60', '30', '15']; + + // Convert the strings to integers. + let diameters = int(original); + + for (let d of diameters) { + // Draw a circle. + circle(50, 50, d); + } + + describe('Three white, concentric circles on a gray background.'); + } + +
+class: p5 +return: + description: converted number. + type: Number +overloads: + - line: 92 + params: + - name: 'n' + description: | +

value to convert.

+ type: String|Boolean|Number + return: + description: converted number. + type: Number + - line: 211 + params: + - name: ns + description: | +

values to convert.

+ type: Array + return: + description: converted numbers. + type: 'Number[]' +chainable: false +--- + + +# int diff --git a/src/content/reference/en/p5 copy/isLooping.mdx b/src/content/reference/en/p5 copy/isLooping.mdx new file mode 100644 index 0000000000..622fd77d9b --- /dev/null +++ b/src/content/reference/en/p5 copy/isLooping.mdx @@ -0,0 +1,65 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L224 +title: isLooping +module: Structure +submodule: Structure +file: src/core/structure.js +description: > +

Returns true if the draw loop is running and + false if not.

+ +

By default, draw() tries to run 60 times + per + + second. Calling noLoop() stops + + draw() from repeating. The draw loop can be + + restarted by calling loop().

+ +

The isLooping() function can be used to check whether a sketch + is + + looping, as in isLooping() === true.

+line: 224 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A white circle drawn against a gray background. When the user double-clicks, the circle stops or resumes following the mouse.'); + } + + function draw() { + background(200); + + // Draw the circle at the mouse's position. + circle(mouseX, mouseY, 20); + } + + // Toggle the draw loop when the user double-clicks. + function doubleClicked() { + if (isLooping() === true) { + noLoop(); + } else { + loop(); + } + } + +
+class: p5 +return: + description: '' + type: Boolean +chainable: false +--- + + +# isLooping diff --git a/src/content/reference/en/p5 copy/join.mdx b/src/content/reference/en/p5 copy/join.mdx new file mode 100644 index 0000000000..23222a6db4 --- /dev/null +++ b/src/content/reference/en/p5 copy/join.mdx @@ -0,0 +1,70 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L15 +title: join +module: Data +submodule: String Functions +file: src/utilities/string_functions.js +description: > +

Combines an array of strings into one string.

+ +

The first parameter, list, is the array of strings to + join.

+ +

The second parameter, separator, is the character(s) that + should be used + + to separate the combined strings. For example, calling + + join(myWords, ' : ') would return a string of words each + separated by a + + colon and spaces.

+line: 15 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of strings. + let myWords = ['one', 'two', 'three']; + + // Create a combined string + let combined = join(myWords, ' : '); + + // Style the text. + textAlign(CENTER, CENTER); + + // Display the combined string. + text(combined, 50, 50); + + describe('The text "one : two : three" written in black on a gray canvas.'); + } + +
+class: p5 +params: + - name: list + description: | +

array of strings to combine.

+ type: Array + - name: separator + description: | +

character(s) to place between strings when they're combined.

+ type: String +return: + description: combined string. + type: String +chainable: false +--- + + +# join diff --git a/src/content/reference/en/p5 copy/key.mdx b/src/content/reference/en/p5 copy/key.mdx new file mode 100644 index 0000000000..63fc144fa3 --- /dev/null +++ b/src/content/reference/en/p5 copy/key.mdx @@ -0,0 +1,106 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L102 +title: key +module: Events +submodule: Keyboard +file: src/events/keyboard.js +description: > +

A String system variable that contains the value of the last + key typed.

+ +

The key variable is helpful for checking whether an + + ASCII + + key has been typed. For example, the expression key === "a" + evaluates to + + true if the a key was typed and false + if not. key doesn’t update + + for special keys such as LEFT_ARROW and ENTER. Use + keyCode instead for + + special keys. The keyIsDown() function + should + + be used to check for multiple different key presses at the same time.

+line: 102 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // Click on the canvas to begin detecting key presses. + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square. The last key pressed is displayed at the center.' + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the last key pressed. + text(key, 50, 50); + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + let x = 50; + let y = 50; + + function setup() { + createCanvas(100, 100); + + background(200); + + describe( + 'A gray square with a black circle at its center. The circle moves when the user presses the keys "w", "a", "s", or "d". It leaves a trail as it moves.' + ); + } + + function draw() { + // Update x and y if a key is pressed. + if (keyIsPressed === true) { + if (key === 'w') { + y -= 1; + } else if (key === 's') { + y += 1; + } else if (key === 'a') { + x -= 1; + } else if (key === 'd') { + x += 1; + } + } + + // Style the circle. + fill(0); + + // Draw the circle at (x, y). + circle(x, y, 5); + } + +
+class: p5 +type: String +--- + + +# key diff --git a/src/content/reference/en/p5 copy/keyCode.mdx b/src/content/reference/en/p5 copy/keyCode.mdx new file mode 100644 index 0000000000..808526b788 --- /dev/null +++ b/src/content/reference/en/p5 copy/keyCode.mdx @@ -0,0 +1,128 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L184 +title: keyCode +module: Events +submodule: Keyboard +file: src/events/keyboard.js +description: > +

A Number system variable that contains the code of the last + key typed.

+ +

All keys have a keyCode. For example, the a key + has the keyCode 65. + + The keyCode variable is helpful for checking whether a special + key has + + been typed. For example, the following conditional checks whether the enter + + key has been typed:

+ +
if (keyCode === 13) {
+    // Code to run if the enter key was pressed.
+  }
+
+  
+ +

The same code can be written more clearly using the system variable + ENTER + + which has a value of 13:

+ +
if (keyCode === ENTER) {
+    // Code to run if the enter key was pressed.
+  }
+
+  
+ +

The system variables BACKSPACE, DELETE, + ENTER, RETURN, TAB, + + ESCAPE, SHIFT, CONTROL, + OPTION, ALT, UP_ARROW, + DOWN_ARROW, + + LEFT_ARROW, and RIGHT_ARROW are all helpful + shorthands the key codes of + + special keys. Key codes can be found on websites such as + + keycode.info.

+line: 184 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // Click on the canvas to begin detecting key presses. + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square. The last key pressed and its code are displayed at the center.' + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the last key pressed and its code. + text(`${key} : ${keyCode}`, 50, 50); + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + let x = 50; + let y = 50; + + function setup() { + createCanvas(100, 100); + + background(200); + + describe( + 'A gray square with a black circle at its center. The circle moves when the user presses an arrow key. It leaves a trail as it moves.' + ); + } + + function draw() { + // Update x and y if an arrow key is pressed. + if (keyIsPressed === true) { + if (keyCode === UP_ARROW) { + y -= 1; + } else if (keyCode === DOWN_ARROW) { + y += 1; + } else if (keyCode === LEFT_ARROW) { + x -= 1; + } else if (keyCode === RIGHT_ARROW) { + x += 1; + } + } + + // Style the circle. + fill(0); + + // Draw the circle at (x, y). + circle(x, y, 5); + } + +
+class: p5 +type: Integer +--- + + +# keyCode diff --git a/src/content/reference/en/p5 copy/keyIsDown.mdx b/src/content/reference/en/p5 copy/keyIsDown.mdx new file mode 100644 index 0000000000..8afe4b0bdf --- /dev/null +++ b/src/content/reference/en/p5 copy/keyIsDown.mdx @@ -0,0 +1,142 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L811 +title: keyIsDown +module: Events +submodule: Keyboard +file: src/events/keyboard.js +description: > +

Returns true if the key it’s checking is pressed and + false if not.

+ +

keyIsDown() is helpful when checking for multiple different + key presses. + + For example, keyIsDown() can be used to check if both + LEFT_ARROW and + + UP_ARROW are pressed:

+ +
if (keyIsDown(LEFT_ARROW) &&
+  keyIsDown(UP_ARROW)) {
+    // Move diagonally.
+  }
+
+  
+ +

keyIsDown() can check for key presses using + + keyCode values, as in + keyIsDown(37) or + + keyIsDown(LEFT_ARROW). Key codes can be found on websites such as + + keycode.info.

+line: 811 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click on the canvas to begin detecting key presses. + + let x = 50; + let y = 50; + + function setup() { + createCanvas(100, 100); + + background(200); + + describe( + 'A gray square with a black circle at its center. The circle moves when the user presses an arrow key. It leaves a trail as it moves.' + ); + } + + function draw() { + // Update x and y if an arrow key is pressed. + if (keyIsDown(LEFT_ARROW) === true) { + x -= 1; + } + + if (keyIsDown(RIGHT_ARROW) === true) { + x += 1; + } + + if (keyIsDown(UP_ARROW) === true) { + y -= 1; + } + + if (keyIsDown(DOWN_ARROW) === true) { + y += 1; + } + + // Style the circle. + fill(0); + + // Draw the circle. + circle(x, y, 5); + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + let x = 50; + let y = 50; + + function setup() { + createCanvas(100, 100); + + background(200); + + describe( + 'A gray square with a black circle at its center. The circle moves when the user presses an arrow key. It leaves a trail as it moves.' + ); + } + + function draw() { + // Update x and y if an arrow key is pressed. + if (keyIsDown(37) === true) { + x -= 1; + } + + if (keyIsDown(39) === true) { + x += 1; + } + + if (keyIsDown(38) === true) { + y -= 1; + } + + if (keyIsDown(40) === true) { + y += 1; + } + + // Style the circle. + fill(0); + + // Draw the circle. + circle(x, y, 5); + } + +
+class: p5 +params: + - name: code + description: | +

key to check.

+ type: Number +return: + description: whether the key is down or not. + type: Boolean +chainable: false +--- + + +# keyIsDown diff --git a/src/content/reference/en/p5 copy/keyIsPressed.mdx b/src/content/reference/en/p5 copy/keyIsPressed.mdx new file mode 100644 index 0000000000..0b129c49e8 --- /dev/null +++ b/src/content/reference/en/p5 copy/keyIsPressed.mdx @@ -0,0 +1,105 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L10 +title: keyIsPressed +module: Events +submodule: Keyboard +file: src/events/keyboard.js +description: > +

A Boolean system variable that's true if any key + is currently pressed + + and false if not.

+line: 10 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // Click on the canvas to begin detecting key presses. + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a white square at its center. The white square turns black when the user presses a key.' + ); + } + + function draw() { + background(200); + + // Style the square. + if (keyIsPressed === true) { + fill(0); + } else { + fill(255); + } + + // Draw the square. + square(25, 25, 50); + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a white square at its center. The white square turns black when the user presses a key.' + ); + } + + function draw() { + background(200); + + // Style the square. + if (keyIsPressed) { + fill(0); + } else { + fill(255); + } + + // Draw the square. + square(25, 25, 50); + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with the word "false" at its center. The word switches to "true" when the user presses a key.' + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the value of keyIsPressed. + text(keyIsPressed, 50, 50); + } + +
+class: p5 +type: Boolean +--- + + +# keyIsPressed diff --git a/src/content/reference/en/p5 copy/keyPressed.mdx b/src/content/reference/en/p5 copy/keyPressed.mdx new file mode 100644 index 0000000000..4a4007f09a --- /dev/null +++ b/src/content/reference/en/p5 copy/keyPressed.mdx @@ -0,0 +1,192 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L284 +title: keyPressed +module: Events +submodule: Keyboard +file: src/events/keyboard.js +description: > +

A function that's called once when any key is pressed.

+ +

Declaring the function keyPressed() sets a code block to run + once + + automatically when the user presses any key:

+ +
function keyPressed() {
+    // Code to run.
+  }
+
+  
+ +

The key and keyCode + + variables will be updated with the most recently typed value when + + keyPressed() is called by p5.js:

+ +
function keyPressed() {
+    if (key === 'c') {
+      // Code to run.
+    }
+
+    if (keyCode === ENTER) {
+      // Code to run.
+    }
+  }
+
+  
+ +

The parameter, event, is optional. keyPressed() + is always passed a + + KeyboardEvent + + object with properties that describe the key press event:

+ +
function keyPressed(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

Browsers may have default behaviors attached to various key events. For + + example, some browsers may jump to the bottom of a web page when the + + SPACE key is pressed. To prevent any default behavior for this + event, add + + return false; to the end of the function.

+line: 284 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click on the canvas to begin detecting key presses. + + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square changes color when the user presses a key.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Toggle the background color when the user presses a key. + function keyPressed() { + if (value === 0) { + value = 255; + } else { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a white square at its center. The inner square turns black when the user presses the "b" key. It turns white when the user presses the "a" key.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Reassign value when the user presses the 'a' or 'b' key. + function keyPressed() { + if (key === 'a') { + value = 255; + } else if (key === 'b') { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square turns white when the user presses the left arrow key. It turns black when the user presses the right arrow key.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Toggle the background color when the user presses an arrow key. + function keyPressed() { + if (keyCode === LEFT_ARROW) { + value = 255; + } else if (keyCode === RIGHT_ARROW) { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+class: p5 +params: + - name: event + description: | +

optional KeyboardEvent callback argument.

+ type: KeyboardEvent + optional: true +chainable: false +--- + + +# keyPressed diff --git a/src/content/reference/en/p5 copy/keyReleased.mdx b/src/content/reference/en/p5 copy/keyReleased.mdx new file mode 100644 index 0000000000..e19da953f1 --- /dev/null +++ b/src/content/reference/en/p5 copy/keyReleased.mdx @@ -0,0 +1,188 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L474 +title: keyReleased +module: Events +submodule: Keyboard +file: src/events/keyboard.js +description: > +

A function that's called once when any key is released.

+ +

Declaring the function keyReleased() sets a code block to run + once + + automatically when the user releases any key:

+ +
function keyReleased() {
+    // Code to run.
+  }
+
+  
+ +

The key and keyCode + + variables will be updated with the most recently released value when + + keyReleased() is called by p5.js:

+ +
function keyReleased() {
+    if (key === 'c') {
+      // Code to run.
+    }
+
+    if (keyCode === ENTER) {
+      // Code to run.
+    }
+  }
+
+  
+ +

The parameter, event, is optional. keyReleased() + is always passed a + + KeyboardEvent + + object with properties that describe the key press event:

+ +
function keyReleased(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

Browsers may have default behaviors attached to various key events. To + + prevent any default behavior for this event, add return false; to + the end + + of the function.

+line: 474 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click on the canvas to begin detecting key presses. + + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square changes color when the user releases a key.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Toggle value when the user releases a key. + function keyReleased() { + if (value === 0) { + value = 255; + } else { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square becomes white when the user releases the "w" key.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Set value to 255 the user releases the 'w' key. + function keyReleased() { + if (key === 'w') { + value = 255; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square turns white when the user presses and releases the left arrow key. It turns black when the user presses and releases the right arrow key.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Toggle the background color when the user releases an arrow key. + function keyReleased() { + if (keyCode === LEFT_ARROW) { + value = 255; + } else if (keyCode === RIGHT_ARROW) { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+class: p5 +params: + - name: event + description: | +

optional KeyboardEvent callback argument.

+ type: KeyboardEvent + optional: true +chainable: false +--- + + +# keyReleased diff --git a/src/content/reference/en/p5 copy/keyTyped.mdx b/src/content/reference/en/p5 copy/keyTyped.mdx new file mode 100644 index 0000000000..a591db9e60 --- /dev/null +++ b/src/content/reference/en/p5 copy/keyTyped.mdx @@ -0,0 +1,170 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L655 +title: keyTyped +module: Events +submodule: Keyboard +file: src/events/keyboard.js +description: > +

A function that's called once when keys with printable characters are + pressed.

+ +

Declaring the function keyTyped() sets a code block to run + once + + automatically when the user presses any key with a printable character such + + as a or 1. Modifier keys such as SHIFT, + CONTROL, and the arrow keys + + will be ignored:

+ +
function keyTyped() {
+    // Code to run.
+  }
+
+  
+ +

The key and keyCode + + variables will be updated with the most recently released value when + + keyTyped() is called by p5.js:

+ +
function keyTyped() {
+    // Check for the "c" character using key.
+    if (key === 'c') {
+      // Code to run.
+    }
+
+    // Check for "c" using keyCode.
+    if (keyCode === 67) {
+      // Code to run.
+    }
+  }
+
+  
+ +

The parameter, event, is optional. keyTyped() is + always passed a + + KeyboardEvent + + object with properties that describe the key press event:

+ +
function keyReleased(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

Note: Use the keyPressed() function + and + + keyCode system variable to respond to + modifier + + keys such as ALT.

+ +

Browsers may have default behaviors attached to various key events. To + + prevent any default behavior for this event, add return false; to + the end + + of the function.

+line: 655 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click on the canvas to begin detecting key presses. + // Note: Pressing special keys such as SPACE have no effect. + + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a white square at its center. The inner square changes color when the user presses a key.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Toggle the square's color when the user types a printable key. + function keyTyped() { + if (value === 0) { + value = 255; + } else { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a white square at its center. The inner square turns black when the user types the "b" key. It turns white when the user types the "a" key.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Reassign value when the user types the 'a' or 'b' key. + function keyTyped() { + if (key === 'a') { + value = 255; + } else if (key === 'b') { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+class: p5 +params: + - name: event + description: | +

optional KeyboardEvent callback argument.

+ type: KeyboardEvent + optional: true +chainable: false +--- + + +# keyTyped diff --git a/src/content/reference/en/p5 copy/lerp.mdx b/src/content/reference/en/p5 copy/lerp.mdx new file mode 100644 index 0000000000..84c4b5bc7a --- /dev/null +++ b/src/content/reference/en/p5 copy/lerp.mdx @@ -0,0 +1,122 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L332 +title: lerp +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Calculates a number between two numbers at a specific increment.

+ +

The amt parameter is the amount to interpolate between the two + numbers. + + 0.0 is equal to the first number, 0.1 is very near the first number, 0.5 is + + half-way in between, and 1.0 is equal to the second number. The + lerp() + + function is convenient for creating motion along a straight path and for + + drawing dotted lines.

+ +

If the value of amt is less than 0 or more than 1, + lerp() will return a + + number outside of the original interval. For example, calling + + lerp(0, 10, 1.5) will return 15.

+line: 332 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Declare variables for coordinates. + let a = 20; + let b = 80; + let c = lerp(a, b, 0.2); + let d = lerp(a, b, 0.5); + let e = lerp(a, b, 0.8); + + strokeWeight(5); + + // Draw the original points in black. + stroke(0); + point(a, 50); + point(b, 50); + + // Draw the lerped points in gray. + stroke(100); + point(c, 50); + point(d, 50); + point(e, 50); + + describe('Five points in a horizontal line. The outer points are black and the inner points are gray.'); + } + +
+ +
+ + let x = 50; + let y = 50; + let targetX = 50; + let targetY = 50; + + function setup() { + createCanvas(100, 100); + + background(200); + + describe('A white circle at the center of a gray canvas. The circle moves to where the user clicks, then moves smoothly back to the center.'); + } + + function draw() { + background(220); + + // Move x and y toward the target. + x = lerp(x, targetX, 0.05); + y = lerp(y, targetY, 0.05); + + // Draw the circle. + circle(x, y, 20); + } + + // Set x and y when the user clicks the mouse. + function mouseClicked() { + x = mouseX; + y = mouseY; + } + +
+class: p5 +params: + - name: start + description: | +

first value.

+ type: Number + - name: stop + description: | +

second value.

+ type: Number + - name: amt + description: | +

number.

+ type: Number +return: + description: lerped value. + type: Number +chainable: false +--- + + +# lerp diff --git a/src/content/reference/en/p5 copy/lerpColor.mdx b/src/content/reference/en/p5 copy/lerpColor.mdx new file mode 100644 index 0000000000..d815ba9ddb --- /dev/null +++ b/src/content/reference/en/p5 copy/lerpColor.mdx @@ -0,0 +1,96 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L949 +title: lerpColor +module: Color +submodule: Creating & Reading +file: src/color/creating_reading.js +description: > +

Blends two colors to find a third color between them.

+ +

The amt parameter specifies the amount to interpolate between + the two + + values. 0 is equal to the first color, 0.1 is very near the first color, + + 0.5 is halfway between the two colors, and so on. Negative numbers are set + + to 0. Numbers greater than 1 are set to 1. This differs from the behavior of + + lerp. It's necessary because numbers outside + of the + + interval [0, 1] will produce strange and unexpected colors.

+ +

The way that colors are interpolated depends on the current + + colorMode().

+line: 949 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create p5.Color objects to interpolate between. + let from = color(218, 165, 32); + let to = color(72, 61, 139); + + // Create intermediate colors. + let interA = lerpColor(from, to, 0.33); + let interB = lerpColor(from, to, 0.66); + + // Draw the left rectangle. + noStroke(); + fill(from); + rect(10, 20, 20, 60); + + // Draw the left-center rectangle. + fill(interA); + rect(30, 20, 20, 60); + + // Draw the right-center rectangle. + fill(interB); + rect(50, 20, 20, 60); + + // Draw the right rectangle. + fill(to); + rect(70, 20, 20, 60); + + describe( + 'Four rectangles. From left to right, the rectangles are tan, brown, brownish purple, and purple.' + ); + } + +
+class: p5 +params: + - name: c1 + description: > +

interpolate from this color (any value created by the color() + function).

+ type: p5.Color + - name: c2 + description: > +

interpolate to this color (any value created by the color() + function).

+ type: p5.Color + - name: amt + description: | +

number between 0 and 1.

+ type: Number +return: + description: interpolated color. + type: p5.Color +chainable: false +--- + + +# lerpColor diff --git a/src/content/reference/en/p5 copy/let.mdx b/src/content/reference/en/p5 copy/let.mdx new file mode 100644 index 0000000000..f04902a9b0 --- /dev/null +++ b/src/content/reference/en/p5 copy/let.mdx @@ -0,0 +1,91 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L7 +title: let +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: > +

Declares a new variable.

+ +

A variable is a container for a value. For example, a variable might + + contain a creature's x-coordinate as a Number or its name as a + + String. Variables can change value by reassigning them as + follows:

+ +
// Declare the variable x and assign it the
+  value 10.
+
+  let x = 10;
+
+
+  // Reassign x to 50.
+
+  x = 50;
+
+  
+ +

Variables have block scope. When a variable is declared between curly + + braces {}, it only exists within the block defined by those + braces. For + + example, the following code would throw a ReferenceError because + x is + + declared within the setup() function's block:

+ +
function setup() {
+    createCanvas(100, 100);
+
+    let x = 50;
+  }
+
+
+  function draw() {
+    background(200);
+
+    // x was declared in setup(), so it can't be referenced here.
+    circle(x, 50, 20);
+  }
+
+  
+ +

Variables declared outside of all curly braces {} are in the + global + + scope. A variable that's in the global scope can be used and changed + + anywhere in a sketch:

+ +
let x = 50;
+
+
+  function setup() {
+    createCanvas(100, 100);
+  }
+
+
+  function draw() {
+    background(200);
+
+    // Change the value of x.
+    x += 10;
+
+    circle(x, 50, 20);
+  }
+
+  
+line: 7 +isConstructor: false +itemtype: property +example: + - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(220);\n\n // Style the text.\n textAlign(CENTER);\n textSize(16);\n\n // Create the message variable.\n let message = 'Hello, \U0001F30D!';\n\n // Display the message.\n text(message, 50, 50);\n\n describe('The text \"Hello, \U0001F30D!\" written on a gray background.');\n}\n\n
\n\n
\n\nlet x = 0;\n\nfunction setup() {\n createCanvas(100, 100);\n\n describe('A white circle moves from left to right against a gray background.');\n}\n\nfunction draw() {\n background(220);\n\n // Change the value of x.\n x += 1;\n\n circle(x, 50, 20);\n}\n\n
" +class: p5 +--- + + +# let diff --git a/src/content/reference/en/p5 copy/lightFalloff.mdx b/src/content/reference/en/p5 copy/lightFalloff.mdx new file mode 100644 index 0000000000..e8b8245064 --- /dev/null +++ b/src/content/reference/en/p5 copy/lightFalloff.mdx @@ -0,0 +1,100 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L1161 +title: lightFalloff +module: 3D +submodule: Lights +file: src/webgl/light.js +description: > +

Sets the falloff rate for pointLight() + + and spotLight().

+ +

A light’s falloff describes the intensity of its beam at a distance. For + + example, a lantern has a slow falloff, a flashlight has a medium falloff, + + and a laser pointer has a sharp falloff.

+ +

lightFalloff() has three parameters, constant, + linear, and + + quadratic. They’re numbers used to calculate falloff at a + distance, d, + + as follows:

+ +

falloff = 1 / (constant + d * linear + (d * d) * + quadratic)

+ +

Note: constant, linear, and + quadratic should always be set to values + + greater than 0.

+line: 1161 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click to change the falloff rate. + + let useFalloff = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A sphere drawn against a gray background. The intensity of the light changes when the user double-clicks.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Set the light falloff. + if (useFalloff === true) { + lightFalloff(2, 0, 0); + } + + // Add a white point light from the front. + pointLight(255, 255, 255, 0, 0, 100); + + // Style the sphere. + noStroke(); + + // Draw the sphere. + sphere(30); + } + + // Change the falloff value when the user double-clicks. + function doubleClicked() { + useFalloff = true; + } + +
+class: p5 +params: + - name: constant + description: | +

constant value for calculating falloff.

+ type: Number + - name: linear + description: | +

linear value for calculating falloff.

+ type: Number + - name: quadratic + description: | +

quadratic value for calculating falloff.

+ type: Number +chainable: true +--- + + +# lightFalloff diff --git a/src/content/reference/en/p5 copy/lightness.mdx b/src/content/reference/en/p5 copy/lightness.mdx new file mode 100644 index 0000000000..284523dcc8 --- /dev/null +++ b/src/content/reference/en/p5 copy/lightness.mdx @@ -0,0 +1,168 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L1134 +title: lightness +module: Color +submodule: Creating & Reading +file: src/color/creating_reading.js +description: > +

Gets the lightness value of a color.

+ +

lightness() extracts the HSL lightness value from a + + p5.Color object, an array of color + components, or + + a CSS color string.

+ +

By default, lightness() returns a color's HSL lightness in the + range 0 + + to 100. If the colorMode() is set to + HSL, it + + returns the lightness value in the given range.

+line: 1134 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(50); + + // Use HSL color. + colorMode(HSL); + + // Create a p5.Color object using HSL values. + let c = color(0, 100, 75); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'lightValue' to 75. + let lightValue = lightness(c); + + // Draw the right rectangle. + fill(lightValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is gray.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(50); + + // Use HSL color. + colorMode(HSL); + + // Create a color array. + let c = [0, 100, 75]; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'lightValue' to 75. + let lightValue = lightness(c); + + // Draw the right rectangle. + fill(lightValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is gray.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(50); + + // Use HSL color. + colorMode(HSL); + + // Create a CSS color string. + let c = 'rgb(255, 128, 128)'; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'lightValue' to 75. + let lightValue = lightness(c); + + // Draw the right rectangle. + fill(lightValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is gray.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(50); + + // Use HSL color with values in the range 0-255. + colorMode(HSL, 255); + + // Create a p5.Color object using HSL values. + let c = color(0, 255, 191.5); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'lightValue' to 191.5. + let lightValue = lightness(c); + + // Draw the right rectangle. + fill(lightValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is gray.'); + } + +
+class: p5 +params: + - name: color + description: | +

p5.Color object, array of + color components, or CSS color string.

+ type: 'p5.Color|Number[]|String' +return: + description: the lightness value. + type: Number +chainable: false +--- + + +# lightness diff --git a/src/content/reference/en/p5 copy/lights.mdx b/src/content/reference/en/p5 copy/lights.mdx new file mode 100644 index 0000000000..a7cf3ba7ae --- /dev/null +++ b/src/content/reference/en/p5 copy/lights.mdx @@ -0,0 +1,88 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L1077 +title: lights +module: 3D +submodule: Lights +file: src/webgl/light.js +description: | +

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.

+line: 1077 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click to turn on the lights. + + let isLit = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white box drawn against a gray background. The quality of the light changes when the user double-clicks.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Control the lights. + if (isLit === true) { + lights(); + } + + // Draw the box. + box(); + } + + // Turn on the lights when the user double-clicks. + function doubleClicked() { + isLit = true; + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white box drawn against a gray background.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + ambientLight(128, 128, 128); + directionalLight(128, 128, 128, 0, 0, -1); + + // Draw the box. + box(); + } + +
+class: p5 +chainable: true +--- + + +# lights diff --git a/src/content/reference/en/p5 copy/line.mdx b/src/content/reference/en/p5 copy/line.mdx new file mode 100644 index 0000000000..b225222235 --- /dev/null +++ b/src/content/reference/en/p5 copy/line.mdx @@ -0,0 +1,194 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L564 +title: line +module: Shape +submodule: 2D Primitives +file: src/core/shape/2d_primitives.js +description: > +

Draws a straight line between two points.

+ +

A line's default width is one pixel. The version of line() + with four + + parameters draws the line in 2D. To color a line, use the + + stroke() function. To change its width, + use the + + strokeWeight() function. A line + + can't be filled, so the fill() function + won't + + affect the line's color.

+ +

The version of line() with six parameters allows the line to + be drawn in + + 3D space. Doing so requires adding the WEBGL argument to + + createCanvas().

+line: 564 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + line(30, 20, 85, 75); + + describe( + 'A black line on a gray canvas running from top-center to bottom-right.' + ); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the line. + stroke('magenta'); + strokeWeight(5); + + line(30, 20, 85, 75); + + describe( + 'A thick, magenta line on a gray canvas running from top-center to bottom-right.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Top. + line(30, 20, 85, 20); + + // Right. + stroke(126); + line(85, 20, 85, 75); + + // Bottom. + stroke(255); + line(85, 75, 30, 75); + + describe( + 'Three lines drawn in grayscale on a gray canvas. They form the top, right, and bottom sides of a square.' + ); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + line(-20, -30, 35, 25); + + describe( + 'A black line on a gray canvas running from top-center to bottom-right.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A black line connecting two spheres. The scene spins slowly.'); + } + + function draw() { + background(200); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Draw a line. + line(0, 0, 0, 30, 20, -10); + + // Draw the center sphere. + sphere(10); + + // Translate to the second point. + translate(30, 20, -10); + + // Draw the bottom-right sphere. + sphere(10); + } + +
+class: p5 +overloads: + - line: 564 + params: + - name: x1 + description: | +

the x-coordinate of the first point.

+ type: Number + - name: y1 + description: | +

the y-coordinate of the first point.

+ type: Number + - name: x2 + description: | +

the x-coordinate of the second point.

+ type: Number + - name: y2 + description: | +

the y-coordinate of the second point.

+ type: Number + chainable: 1 + - line: 696 + params: + - name: x1 + description: '' + type: Number + - name: y1 + description: '' + type: Number + - name: z1 + description: | +

the z-coordinate of the first point.

+ type: Number + - name: x2 + description: '' + type: Number + - name: y2 + description: '' + type: Number + - name: z2 + description: | +

the z-coordinate of the second point.

+ type: Number + chainable: 1 +chainable: true +--- + + +# line diff --git a/src/content/reference/en/p5 copy/linePerspective.mdx b/src/content/reference/en/p5 copy/linePerspective.mdx new file mode 100644 index 0000000000..80bf539c73 --- /dev/null +++ b/src/content/reference/en/p5 copy/linePerspective.mdx @@ -0,0 +1,164 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L280 +title: linePerspective +module: 3D +submodule: Camera +file: src/webgl/p5.Camera.js +description: > +

Enables or disables perspective for lines in 3D sketches.

+ +

In WebGL mode, lines can be drawn with a thinner stroke when they’re + + further from the camera. Doing so gives them a more realistic appearance.

+ +

By default, lines are drawn differently based on the type of perspective + + being used:

+ +
    + +
  • perspective() and frustum() simulate a realistic + perspective. In + + these modes, stroke weight is affected by the line’s distance from the + + camera. Doing so results in a more natural appearance. + perspective() is + + the default mode for 3D sketches.
  • + +
  • ortho() doesn’t simulate a realistic perspective. In this + mode, stroke + + weights are consistent regardless of the line’s distance from the camera. + + Doing so results in a more predictable and consistent appearance.
  • + +
+ +

linePerspective() can override the default line drawing + mode.

+ +

The parameter, enable, is optional. It’s a + Boolean value that sets the + + way lines are drawn. If true is passed, as in + linePerspective(true), + + then lines will appear thinner when they are further from the camera. If + + false is passed, as in linePerspective(false), then + lines will have + + consistent stroke weights regardless of their distance from the camera. By + + default, linePerspective() is enabled.

+ +

Calling linePerspective() without passing an argument returns + true if + + it's enabled and false if not.

+ +

Note: linePerspective() can only be used in WebGL mode.

+line: 280 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Double-click the canvas to toggle the line perspective. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'A white cube with black edges on a gray background. Its edges toggle between thick and thin when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Translate the origin toward the camera. + translate(-10, 10, 600); + + // Rotate the coordinate system. + rotateY(-0.1); + rotateX(-0.1); + + // Draw the row of boxes. + for (let i = 0; i < 6; i += 1) { + translate(0, 0, -40); + box(10); + } + } + + // Toggle the line perspective when the user double-clicks. + function doubleClicked() { + let isEnabled = linePerspective(); + linePerspective(!isEnabled); + } + +
+ +
+ + // Double-click the canvas to toggle the line perspective. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'A row of cubes with black edges on a gray background. Their edges toggle between thick and thin when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Use an orthographic projection. + ortho(); + + // Translate the origin toward the camera. + translate(-10, 10, 600); + + // Rotate the coordinate system. + rotateY(-0.1); + rotateX(-0.1); + + // Draw the row of boxes. + for (let i = 0; i < 6; i += 1) { + translate(0, 0, -40); + box(10); + } + } + + // Toggle the line perspective when the user double-clicks. + function doubleClicked() { + let isEnabled = linePerspective(); + linePerspective(!isEnabled); + } + +
+class: p5 +overloads: + - line: 280 + params: + - name: enable + description: | +

whether to enable line perspective.

+ type: Boolean + - line: 392 + params: [] + return: + description: whether line perspective is enabled. + type: Boolean +chainable: false +--- + + +# linePerspective diff --git a/src/content/reference/en/p5 copy/loadBytes.mdx b/src/content/reference/en/p5 copy/loadBytes.mdx new file mode 100644 index 0000000000..8b02c0683e --- /dev/null +++ b/src/content/reference/en/p5 copy/loadBytes.mdx @@ -0,0 +1,56 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L986 +title: loadBytes +module: IO +submodule: Input +file: src/io/files.js +description: | +

This method is suitable for fetching files up to size of 64MB.

+line: 986 +isConstructor: false +itemtype: method +example: + - |- + +
+ let data; + + function preload() { + data = loadBytes('/assets/mammals.xml'); + } + + function setup() { + for (let i = 0; i < 5; i++) { + console.log(data.bytes[i].toString(16)); + } + describe('no image displayed'); + } +
+class: p5 +params: + - name: file + description: | +

name of the file or URL to load

+ type: String + - name: callback + description: | +

function to be executed after loadBytes() + completes

+ type: Function + optional: true + - name: errorCallback + description: | +

function to be executed if there + is an error

+ type: Function + optional: true +return: + description: an object whose 'bytes' property will be the loaded buffer + type: Object +chainable: false +--- + + +# loadBytes diff --git a/src/content/reference/en/p5 copy/loadFont.mdx b/src/content/reference/en/p5 copy/loadFont.mdx new file mode 100644 index 0000000000..86af4b7123 --- /dev/null +++ b/src/content/reference/en/p5 copy/loadFont.mdx @@ -0,0 +1,171 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/loading_displaying.js#L16 +title: loadFont +module: Typography +submodule: Loading & Displaying +file: src/typography/loading_displaying.js +description: > +

Loads a font and creates a p5.Font + object. + + loadFont() can load fonts in either .otf or .ttf format. Loaded + fonts can + + be used to style text on the canvas and in HTML elements.

+ +

The first parameter, path, is the path to a font file. + + Paths to local files should be relative. For example, + + '/assets/inconsolata.otf'. The Inconsolata font used in the + following + + examples can be downloaded for free + + here. + + Paths to remote files should be URLs. For example, + + 'https://example.com/inconsolata.otf'. URLs may be blocked due to + browser + + security.

+ +

The second parameter, successCallback, is optional. If a + function is + + passed, it will be called once the font has loaded. The callback function + + may use the new p5.Font object if + needed.

+ +

The third parameter, failureCallback, is also optional. If a + function is + + passed, it will be called if the font fails to load. The callback function + + may use the error + + Event + + object if needed.

+ +

Fonts can take time to load. Calling loadFont() in + + preload() ensures fonts load before + they're + + used in setup() or + + draw().

+line: 16 +isConstructor: false +itemtype: method +example: + - |- + + +
+ + let font; + + function preload() { + font = loadFont('/assets/inconsolata.otf'); + } + + function setup() { + fill('deeppink'); + textFont(font); + textSize(36); + text('p5*js', 10, 50); + + describe('The text "p5*js" written in pink on a white background.'); + } + +
+ +
+ + function setup() { + loadFont('/assets/inconsolata.otf', font => { + fill('deeppink'); + textFont(font); + textSize(36); + text('p5*js', 10, 50); + + describe('The text "p5*js" written in pink on a white background.'); + }); + } + +
+ +
+ + function setup() { + loadFont('/assets/inconsolata.otf', success, failure); + } + + function success(font) { + fill('deeppink'); + textFont(font); + textSize(36); + text('p5*js', 10, 50); + + describe('The text "p5*js" written in pink on a white background.'); + } + + function failure(event) { + console.error('Oops!', event); + } + +
+ +
+ + function preload() { + loadFont('/assets/inconsolata.otf'); + } + + function setup() { + let p = createP('p5*js'); + p.style('color', 'deeppink'); + p.style('font-family', 'Inconsolata'); + p.style('font-size', '36px'); + p.position(10, 50); + + describe('The text "p5*js" written in pink on a white background.'); + } + +
+class: p5 +params: + - name: path + description: | +

path of the font to be loaded.

+ type: String + - name: successCallback + description: | +

function called with the + p5.Font object after it + loads.

+ type: Function + optional: true + - name: failureCallback + description: | +

function called with the error + Event + object if the font fails to load.

+ type: Function + optional: true +return: + description: p5.Font object. + type: p5.Font +chainable: false +--- + + +# loadFont diff --git a/src/content/reference/en/p5 copy/loadImage.mdx b/src/content/reference/en/p5 copy/loadImage.mdx new file mode 100644 index 0000000000..7e5b8bf0b7 --- /dev/null +++ b/src/content/reference/en/p5 copy/loadImage.mdx @@ -0,0 +1,137 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L18 +title: loadImage +module: Image +submodule: Loading & Displaying +file: src/image/loading_displaying.js +description: > +

Loads an image to create a p5.Image + object.

+ +

loadImage() interprets the first parameter one of three ways. + If the path + + to an image file is provided, loadImage() will load it. Paths to + local + + files should be relative, such as '/assets/thundercat.jpg'. URLs + such as + + 'https://example.com/thundercat.jpg' may be blocked due to + browser + + security. Raw image data can also be passed as a base64 encoded image in + + the form 'data:image/png;base64,arandomsequenceofcharacters'.

+ +

The second parameter is optional. If a function is passed, it will be + + called once the image has loaded. The callback function can optionally use + + the new p5.Image object.

+ +

The third parameter is also optional. If a function is passed, it will be + + called if the image fails to load. The callback function can optionally use + + the event error.

+ +

Images can take time to load. Calling loadImage() in + + preload() ensures images load before + they're + + used in setup() or draw().

+line: 18 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load the image and create a p5.Image object. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Draw the image. + image(img, 0, 0); + + describe('Image of the underside of a white umbrella and a gridded ceiling.'); + } + +
+ +
+ + function setup() { + // Call handleImage() once the image loads. + loadImage('/assets/laDefense.jpg', handleImage); + + describe('Image of the underside of a white umbrella and a gridded ceiling.'); + } + + // Display the image. + function handleImage(img) { + image(img, 0, 0); + } + +
+ +
+ + function setup() { + // Call handleImage() once the image loads or + // call handleError() if an error occurs. + loadImage('/assets/laDefense.jpg', handleImage, handleError); + } + + // Display the image. + function handleImage(img) { + image(img, 0, 0); + + describe('Image of the underside of a white umbrella and a gridded ceiling.'); + } + + // Log the error. + function handleError(event) { + console.error('Oops!', event); + } + +
+class: p5 +params: + - name: path + description: | +

path of the image to be loaded or base64 encoded image.

+ type: String + - name: successCallback + description: | +

function called with + p5.Image once it + loads.

+ type: function(p5.Image) + optional: true + - name: failureCallback + description: | +

function called with event + error if the image fails to load.

+ type: Function(Event) + optional: true +return: + description: the p5.Image object. + type: p5.Image +chainable: false +--- + + +# loadImage diff --git a/src/content/reference/en/p5 copy/loadJSON.mdx b/src/content/reference/en/p5 copy/loadJSON.mdx new file mode 100644 index 0000000000..95fd0552b5 --- /dev/null +++ b/src/content/reference/en/p5 copy/loadJSON.mdx @@ -0,0 +1,288 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L17 +title: loadJSON +module: IO +submodule: Input +file: src/io/files.js +description: > +

Loads a JSON file to create an Object.

+ +

JavaScript Object Notation + + (JSON) + + is a standard format for sending data between applications. The format is + + based on JavaScript objects which have keys and values. JSON files store + + data in an object with strings as keys. Values can be strings, numbers, + + Booleans, arrays, null, or other objects.

+ +

The first parameter, path, is always a string with the path to + the file. + + Paths to local files should be relative, as in + + loadJSON('/assets/data.json'). URLs such as + + 'https://example.com/data.json' may be blocked due to browser + security.

+ +

The second parameter, successCallback, is optional. If a + function is + + passed, as in loadJSON('/assets/data.json', handleData), then the + + handleData() function will be called once the data loads. The + object + + created from the JSON data will be passed to handleData() as its + only argument.

+ +

The third parameter, failureCallback, is also optional. If a + function is + + passed, as in loadJSON('/assets/data.json', handleData, + handleFailure), + + then the handleFailure() function will be called if an error + occurs while + + loading. The Error object will be passed to + handleFailure() as its only + + argument.

+ +

Note: Data can take time to load. Calling loadJSON() within + + preload() ensures data loads before it's + used in + + setup() or draw().

+line: 17 +isConstructor: false +itemtype: method +example: + - |- + + +
+ + let myData; + + // Load the JSON and create an object. + function preload() { + myData = loadJSON('/assets/data.json'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the circle. + fill(myData.color); + noStroke(); + + // Draw the circle. + circle(myData.x, myData.y, myData.d); + + describe('A pink circle on a gray background.'); + } + +
+ +
+ + let myData; + + // Load the JSON and create an object. + function preload() { + myData = loadJSON('/assets/data.json'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object and make it transparent. + let c = color(myData.color); + c.setAlpha(80); + + // Style the circles. + fill(c); + noStroke(); + + // Iterate over the myData.bubbles array. + for (let b of myData.bubbles) { + // Draw a circle for each bubble. + circle(b.x, b.y, b.d); + } + + describe('Several pink bubbles floating in a blue sky.'); + } + +
+ +
+ + let myData; + + // Load the GeoJSON and create an object. + function preload() { + myData = loadJSON('https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Get data about the most recent earthquake. + let quake = myData.features[0].properties; + + // Draw a circle based on the earthquake's magnitude. + circle(50, 50, quake.mag * 10); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(11); + + // Display the earthquake's location. + text(quake.place, 5, 80, 100); + + describe(`A white circle on a gray background. The text "${quake.place}" is written beneath the circle.`); + } + +
+ +
+ + let bigQuake; + + // Load the GeoJSON and preprocess it. + function preload() { + loadJSON( + 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson', + handleData + ); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw a circle based on the earthquake's magnitude. + circle(50, 50, bigQuake.mag * 10); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(11); + + // Display the earthquake's location. + text(bigQuake.place, 5, 80, 100); + + describe(`A white circle on a gray background. The text "${bigQuake.place}" is written beneath the circle.`); + } + + // Find the biggest recent earthquake. + function handleData(data) { + let maxMag = 0; + // Iterate over the earthquakes array. + for (let quake of data.features) { + // Reassign bigQuake if a larger + // magnitude quake is found. + if (quake.properties.mag > maxMag) { + bigQuake = quake.properties; + } + } + } + +
+ +
+ + let bigQuake; + + // Load the GeoJSON and preprocess it. + function preload() { + loadJSON( + 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson', + handleData, + handleError + ); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw a circle based on the earthquake's magnitude. + circle(50, 50, bigQuake.mag * 10); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(11); + + // Display the earthquake's location. + text(bigQuake.place, 5, 80, 100); + + describe(`A white circle on a gray background. The text "${bigQuake.place}" is written beneath the circle.`); + } + + // Find the biggest recent earthquake. + function handleData(data) { + let maxMag = 0; + // Iterate over the earthquakes array. + for (let quake of data.features) { + // Reassign bigQuake if a larger + // magnitude quake is found. + if (quake.properties.mag > maxMag) { + bigQuake = quake.properties; + } + } + } + + // Log any errors to the console. + function handleError(error) { + console.log('Oops!', error); + } + +
+class: p5 +params: + - name: path + description: | +

path of the JSON file to be loaded.

+ type: String + - name: successCallback + description: > +

function to call once the data is loaded. Will be passed the + object.

+ type: Function + optional: true + - name: errorCallback + description: > +

function to call if the data fails to load. Will be passed an + Error event object.

+ type: Function + optional: true +return: + description: object containing the loaded data. + type: Object +chainable: false +--- + + +# loadJSON diff --git a/src/content/reference/en/p5 copy/loadModel.mdx b/src/content/reference/en/p5 copy/loadModel.mdx new file mode 100644 index 0000000000..56b2230e1e --- /dev/null +++ b/src/content/reference/en/p5 copy/loadModel.mdx @@ -0,0 +1,469 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/loading.js#L13 +title: loadModel +module: Shape +submodule: 3D Models +file: src/webgl/loading.js +description: > +

Loads a 3D model to create a + + p5.Geometry object.

+ +

loadModel() can load 3D models from OBJ and STL files. Once + the model is + + loaded, it can be displayed with the + + model() function, as in + model(shape).

+ +

There are three ways to call loadModel() with optional + parameters to help + + process the model.

+ +

The first parameter, path, is always a String + with the path to the + + file. Paths to local files should be relative, as in + + loadModel('/assets/model.obj'). URLs such as + + 'https://example.com/model.obj' may be blocked due to browser + security.

+ +

Note: When loading a .obj file that references materials + stored in + + .mtl files, p5.js will attempt to load and apply those materials. + + To ensure that the .obj file reads the .mtl file + correctly include the + + .mtl file alongside it.

+ +

The first way to call loadModel() has three optional + parameters after the + + file path. The first optional parameter, successCallback, is a + function + + to call once the model loads. For example, + + loadModel('/assets/model.obj', handleModel) will call the + handleModel() + + function once the model loads. The second optional parameter, + + failureCallback, is a function to call if the model fails to + load. For + + example, loadModel('/assets/model.obj', handleModel, + handleFailure) will + + call the handleFailure() function if an error occurs while + loading. The + + third optional parameter, fileType, is the model’s file extension + as a + + string. For example, + + loadModel('/assets/model', handleModel, handleFailure, '.obj') + will try to + + load the file model as a .obj file.

+ +

The second way to call loadModel() has four optional + parameters after the + + file path. The first optional parameter is a Boolean value. If + true is + + passed, as in loadModel('/assets/model.obj', true), then the + model will be + + resized to ensure it fits the canvas. The next three parameters are + + successCallback, failureCallback, and + fileType as described above.

+ +

The third way to call loadModel() has one optional parameter + after the + + file path. The optional parameter, options, is an + Object with options, + + as in loadModel('/assets/model.obj', options). The + options object can + + have the following properties:

+ +
let options = {
+    // Enables standardized size scaling during loading if set to true.
+    normalize: true,
+
+    // Function to call once the model loads.
+    successCallback: handleModel,
+
+    // Function to call if an error occurs while loading.
+    failureCallback: handleError,
+
+    // Model's file extension.
+    fileType: '.stl',
+
+    // Flips the U texture coordinates of the model.
+    flipU: false,
+
+    // Flips the V texture coordinates of the model.
+    flipV: false
+  };
+
+
+  // Pass the options object to loadModel().
+
+  loadModel('/assets/model.obj', options);
+
+  
+ +

Models can take time to load. Calling loadModel() in + + preload() ensures models load before + they're + + used in setup() or draw().

+ +

Note: There’s no support for colored STL files. STL files with color will + + be rendered without color.

+line: 13 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + // Load the file and create a p5.Geometry object. + function preload() { + shape = loadModel('/assets/teapot.obj'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white teapot drawn against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the shape. + model(shape); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + // Load the file and create a p5.Geometry object. + // Normalize the geometry's size to fit the canvas. + function preload() { + shape = loadModel('/assets/teapot.obj', true); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white teapot drawn against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the shape. + model(shape); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + // Load the file and create a p5.Geometry object. + function preload() { + loadModel('/assets/teapot.obj', true, handleModel); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white teapot drawn against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the shape. + model(shape); + } + + // Set the shape variable and log the geometry's + // ID to the console. + function handleModel(data) { + shape = data; + console.log(shape.gid); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + // Load the file and create a p5.Geometry object. + function preload() { + loadModel('/assets/wrong.obj', true, handleModel, handleError); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white teapot drawn against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the shape. + model(shape); + } + + // Set the shape variable and print the geometry's + // ID to the console. + function handleModel(data) { + shape = data; + console.log(shape.gid); + } + + // Print an error message if the file doesn't load. + function handleError(error) { + console.error('Oops!', error); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + // Load the file and create a p5.Geometry object. + function preload() { + loadModel('/assets/teapot.obj', true, handleModel, handleError, '.obj'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white teapot drawn against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the shape. + model(shape); + } + + // Set the shape variable and print the geometry's + // ID to the console. + function handleModel(data) { + shape = data; + console.log(shape.gid); + } + + // Print an error message if the file doesn't load. + function handleError(error) { + console.error('Oops!', error); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + let options = { + normalize: true, + successCallback: handleModel, + failureCallback: handleError, + fileType: '.obj' + }; + + // Load the file and create a p5.Geometry object. + function preload() { + loadModel('/assets/teapot.obj', options); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white teapot drawn against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the shape. + model(shape); + } + + // Set the shape variable and print the geometry's + // ID to the console. + function handleModel(data) { + shape = data; + console.log(shape.gid); + } + + // Print an error message if the file doesn't load. + function handleError(error) { + console.error('Oops!', error); + } + +
+class: p5 +return: + description: the p5.Geometry object + type: p5.Geometry +overloads: + - line: 13 + params: + - name: path + description: | +

path of the model to be loaded.

+ type: String + - name: normalize + description: | +

if true, scale the model to fit the canvas.

+ type: Boolean + - name: successCallback + description: | +

function to call once the model is loaded. Will be passed + the p5.Geometry object.

+ type: function(p5.Geometry) + optional: true + - name: failureCallback + description: > +

function to call if the model fails to load. Will be passed an + Error event object.

+ type: Function(Event) + optional: true + - name: fileType + description: > +

model’s file extension. Either '.obj' or + '.stl'.

+ type: String + optional: true + return: + description: the p5.Geometry object + type: p5.Geometry + - line: 324 + params: + - name: path + description: '' + type: String + - name: successCallback + description: '' + type: function(p5.Geometry) + optional: true + - name: failureCallback + description: '' + type: Function(Event) + optional: true + - name: fileType + description: '' + type: String + optional: true + return: + description: new p5.Geometry object. + type: p5.Geometry + - line: 332 + params: + - name: path + description: '' + type: String + - name: options + description: | +

loading options.

+ type: Object + optional: true + props: + - name: successCallback + description: '' + type: function(p5.Geometry) + optional: true + - name: failureCallback + description: '' + type: Function(Event) + optional: true + - name: fileType + description: '' + type: String + optional: true + - name: normalize + description: '' + type: Boolean + optional: true + - name: flipU + description: '' + type: Boolean + optional: true + - name: flipV + description: '' + type: Boolean + optional: true + return: + description: new p5.Geometry object. + type: p5.Geometry +chainable: false +--- + + +# loadModel diff --git a/src/content/reference/en/p5 copy/loadPixels.mdx b/src/content/reference/en/p5 copy/loadPixels.mdx new file mode 100644 index 0000000000..424a87765f --- /dev/null +++ b/src/content/reference/en/p5 copy/loadPixels.mdx @@ -0,0 +1,61 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L946 +title: loadPixels +module: Image +submodule: Pixels +file: src/image/pixels.js +description: | +

Loads the current value of each pixel on the canvas into the + pixels array.

+

loadPixels() must be called before reading from or writing to + pixels.

+line: 946 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/rockies.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0, 100, 100); + + // Get the pixel density. + let d = pixelDensity(); + + // Calculate the halfway index in the pixels array. + let halfImage = 4 * (d * width) * (d * height / 2); + + // Load the pixels array. + loadPixels(); + + // Copy the top half of the canvas to the bottom. + for (let i = 0; i < halfImage; i += 1) { + pixels[i + halfImage] = pixels[i]; + } + + // Update the canvas. + updatePixels(); + + describe('Two identical images of mountain landscapes, one on top of the other.'); + } + +
+class: p5 +chainable: false +--- + + +# loadPixels diff --git a/src/content/reference/en/p5 copy/loadShader.mdx b/src/content/reference/en/p5 copy/loadShader.mdx new file mode 100644 index 0000000000..1180e6c487 --- /dev/null +++ b/src/content/reference/en/p5 copy/loadShader.mdx @@ -0,0 +1,172 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L12 +title: loadShader +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Loads vertex and fragment shaders to create a + + p5.Shader object.

+ +

Shaders are programs that run on the graphics processing unit (GPU). They + + can process many pixels at the same time, making them fast for many + + graphics tasks. They’re written in a language called + + GLSL + + and run along with the rest of the code in a sketch.

+ +

Once the p5.Shader object is created, + it can be + + used with the shader() function, as in + + shader(myShader). A shader program consists of two files, a + vertex shader + + and a fragment shader. The vertex shader affects where 3D geometry is drawn + + on the screen and the fragment shader affects color.

+ +

loadShader() loads the vertex and fragment shaders from their + .vert and + + .frag files. For example, calling + + loadShader('/assets/shader.vert', '/assets/shader.frag') loads + both + + required shaders and returns a p5.Shader + object.

+ +

The third parameter, successCallback, is optional. If a + function is + + passed, it will be called once the shader has loaded. The callback function + + can use the new p5.Shader object as its + + parameter.

+ +

The fourth parameter, failureCallback, is also optional. If a + function is + + passed, it will be called if the shader fails to load. The callback + + function can use the event error as its parameter.

+ +

Shaders can take time to load. Calling loadShader() in + + preload() ensures shaders load before + they're + + used in setup() or draw().

+ +

Note: Shaders can only be used in WebGL mode.

+line: 12 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Note: A "uniform" is a global variable within a shader program. + + let mandelbrot; + + // Load the shader and create a p5.Shader object. + function preload() { + mandelbrot = loadShader('/assets/shader.vert', '/assets/shader.frag'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + // Compile and apply the p5.Shader object. + shader(mandelbrot); + + // Set the shader uniform p to an array. + mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); + + // Set the shader uniform r to the value 1.5. + mandelbrot.setUniform('r', 1.5); + + // Add a quad as a display surface for the shader. + quad(-1, -1, 1, -1, 1, 1, -1, 1); + + describe('A black fractal image on a magenta background.'); + } + +
+ +
+ + // Note: A "uniform" is a global variable within a shader program. + + let mandelbrot; + + // Load the shader and create a p5.Shader object. + function preload() { + mandelbrot = loadShader('/assets/shader.vert', '/assets/shader.frag'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + // Use the p5.Shader object. + shader(mandelbrot); + + // Set the shader uniform p to an array. + mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); + + describe('A fractal image zooms in and out of focus.'); + } + + function draw() { + // Set the shader uniform r to a value that oscillates between 0 and 2. + mandelbrot.setUniform('r', sin(frameCount * 0.01) + 1); + + // Add a quad as a display surface for the shader. + quad(-1, -1, 1, -1, 1, 1, -1, 1); + } + +
+class: p5 +params: + - name: vertFilename + description: | +

path of the vertex shader to be loaded.

+ type: String + - name: fragFilename + description: | +

path of the fragment shader to be loaded.

+ type: String + - name: successCallback + description: | +

function to call once the shader is loaded. Can be passed the + p5.Shader object.

+ type: Function + optional: true + - name: failureCallback + description: | +

function to call if the shader fails to load. Can be passed an + Error event object.

+ type: Function + optional: true +return: + description: new shader created from the vertex and fragment shader files. + type: p5.Shader +chainable: false +--- + + +# loadShader diff --git a/src/content/reference/en/p5 copy/loadSound.mdx b/src/content/reference/en/p5 copy/loadSound.mdx new file mode 100644 index 0000000000..be9dd1ac29 --- /dev/null +++ b/src/content/reference/en/p5 copy/loadSound.mdx @@ -0,0 +1,78 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L2946 +title: loadSound +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: | +

loadSound() returns a new p5.SoundFile from a specified + path. If called during preload(), the p5.SoundFile will be ready + to play in time for setup() and draw(). If called outside of + preload, the p5.SoundFile will not be ready immediately, so + loadSound accepts a callback as the second parameter. Using a + + local server is recommended when loading external files.

+line: 2946 +isConstructor: false +itemtype: method +example: + - |- + +
+ let mySound; + function preload() { + soundFormats('mp3', 'ogg'); + mySound = loadSound('/assets/doorbell'); + } + + function setup() { + let cnv = createCanvas(100, 100); + cnv.mousePressed(canvasPressed); + background(220); + text('tap here to play', 10, 20); + } + + function canvasPressed() { + // playing a sound file on a user gesture + // is equivalent to `userStartAudio()` + mySound.play(); + } +
+class: p5 +params: + - name: path + description: | +

Path to the sound file, or an array with + paths to soundfiles in multiple formats + i.e. ['sound.ogg', 'sound.mp3']. + Alternately, accepts an object: either + from the HTML5 File API, or a p5.File.

+ type: String|Array + - name: successCallback + description: | +

Name of a function to call once file loads

+ type: Function + optional: true + - name: errorCallback + description: | +

Name of a function to call if there is + an error loading the file.

+ type: Function + optional: true + - name: whileLoading + description: | +

Name of a function to call while file is loading. + This function will receive the percentage loaded + so far, from 0.0 to 1.0.

+ type: Function + optional: true +return: + description: Returns a p5.SoundFile + type: SoundFile +chainable: false +--- + + +# loadSound diff --git a/src/content/reference/en/p5 copy/loadStrings.mdx b/src/content/reference/en/p5 copy/loadStrings.mdx new file mode 100644 index 0000000000..ce011835bc --- /dev/null +++ b/src/content/reference/en/p5 copy/loadStrings.mdx @@ -0,0 +1,188 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L309 +title: loadStrings +module: IO +submodule: Input +file: src/io/files.js +description: > +

Loads a text file to create an Array.

+ +

The first parameter, path, is always a string with the path to + the file. + + Paths to local files should be relative, as in + + loadStrings('/assets/data.txt'). URLs such as + + 'https://example.com/data.txt' may be blocked due to browser + security.

+ +

The second parameter, successCallback, is optional. If a + function is + + passed, as in loadStrings('/assets/data.txt', handleData), then + the + + handleData() function will be called once the data loads. The + array + + created from the text data will be passed to handleData() as its + only + + argument.

+ +

The third parameter, failureCallback, is also optional. If a + function is + + passed, as in loadStrings('/assets/data.txt', handleData, + handleFailure), + + then the handleFailure() function will be called if an error + occurs while + + loading. The Error object will be passed to + handleFailure() as its only + + argument.

+ +

Note: Data can take time to load. Calling loadStrings() within + + preload() ensures data loads before it's + used in + + setup() or draw().

+line: 309 +isConstructor: false +itemtype: method +example: + - |- + + +
+ + let myData; + + // Load the text and create an array. + function preload() { + myData = loadStrings('/assets/test.txt'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Select a random line from the text. + let phrase = random(myData); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(12); + + // Display the text. + text(phrase, 10, 50, 90); + + describe(`The text "${phrase}" written in black on a gray background.`); + } + +
+ +
+ + let lastLine; + + // Load the text and preprocess it. + function preload() { + loadStrings('/assets/test.txt', handleData); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(12); + + // Display the text. + text(lastLine, 10, 50, 90); + + describe('The text "I talk like an orange" written in black on a gray background.'); + } + + // Select the last line from the text. + function handleData(data) { + lastLine = data[data.length - 1]; + } + +
+ +
+ + let lastLine; + + // Load the text and preprocess it. + function preload() { + loadStrings('/assets/test.txt', handleData, handleError); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(12); + + // Display the text. + text(lastLine, 10, 50, 90); + + describe('The text "I talk like an orange" written in black on a gray background.'); + } + + // Select the last line from the text. + function handleData(data) { + lastLine = data[data.length - 1]; + } + + // Log any errors to the console. + function handleError(error) { + console.error('Oops!', error); + } + +
+class: p5 +params: + - name: path + description: | +

path of the text file to be loaded.

+ type: String + - name: successCallback + description: | +

function to call once the data is + loaded. Will be passed the array.

+ type: Function + optional: true + - name: errorCallback + description: | +

function to call if the data fails to + load. Will be passed an Error event + object.

+ type: Function + optional: true +return: + description: new array containing the loaded text. + type: 'String[]' +chainable: false +--- + + +# loadStrings diff --git a/src/content/reference/en/p5 copy/loadTable.mdx b/src/content/reference/en/p5 copy/loadTable.mdx new file mode 100644 index 0000000000..d93e40a3da --- /dev/null +++ b/src/content/reference/en/p5 copy/loadTable.mdx @@ -0,0 +1,124 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L505 +title: loadTable +module: IO +submodule: Input +file: src/io/files.js +description: > +

Reads the contents of a file or URL and creates a p5.Table object with + + its values. If a file is specified, it must be located in the sketch's + + "data" folder. The filename parameter can also be a URL to a file found + + online. By default, the file is assumed to be comma-separated (in CSV + + format). Table only looks for a header row if the 'header' option is + + included.

+ +

This method is asynchronous, meaning it may not finish before the next + + line in your sketch is executed. Calling loadTable() inside preload() + + guarantees to complete the operation before setup() and draw() are called. + + Outside of preload(), you may supply a + callback function to handle the + + object:

+ +

All files loaded and saved use UTF-8 encoding. This method is suitable for + fetching files up to size of 64MB.

+line: 505 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Given the following CSV file called "mammals.csv" + // located in the project's "assets" folder: + // + // id,species,name + // 0,Capra hircus,Goat + // 1,Panthera pardus,Leopard + // 2,Equus zebra,Zebra + + let table; + + function preload() { + //my table is comma separated value "csv" + //and has a header specifying the columns labels + table = loadTable('/assets/mammals.csv', 'csv', 'header'); + //the file can be remote + //table = loadTable("https://p5js.org/reference//assets/mammals.csv", + // "csv", "header"); + } + + function setup() { + //count the columns + print(table.getRowCount() + ' total rows in table'); + print(table.getColumnCount() + ' total columns in table'); + + print(table.getColumn('name')); + //["Goat", "Leopard", "Zebra"] + + //cycle through the table + for (let r = 0; r < table.getRowCount(); r++) + 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"`); + } + +
+class: p5 +params: + - name: filename + description: | +

name of the file or URL to load

+ type: String + - name: extension + description: | +

parse the table by comma-separated values "csv", semicolon-separated + values "ssv", or tab-separated values "tsv"

+ type: String + optional: true + - name: header + description: | +

"header" to indicate table has header row

+ type: String + optional: true + - name: callback + description: | +

function to be executed after + loadTable() completes. On success, the + Table object is passed in as the + first argument.

+ type: Function + optional: true + - name: errorCallback + description: | +

function to be executed if + there is an error, response is passed + in as first argument

+ type: Function + optional: true +return: + description: Table object containing data + type: Object +chainable: false +--- + + +# loadTable diff --git a/src/content/reference/en/p5 copy/loadXML.mdx b/src/content/reference/en/p5 copy/loadXML.mdx new file mode 100644 index 0000000000..859a3c895d --- /dev/null +++ b/src/content/reference/en/p5 copy/loadXML.mdx @@ -0,0 +1,220 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L780 +title: loadXML +module: IO +submodule: Input +file: src/io/files.js +description: > +

Loads an XML file to create a p5.XML + object.

+ +

Extensible Markup Language + + (XML) + + is a standard format for sending data between applications. Like HTML, the + + XML format is based on tags and attributes, as in + + .

+ +

The first parameter, path, is always a string with the path to + the file. + + Paths to local files should be relative, as in + + loadXML('/assets/data.xml'). URLs such as + 'https://example.com/data.xml' + + may be blocked due to browser security.

+ +

The second parameter, successCallback, is optional. If a + function is + + passed, as in loadXML('/assets/data.xml', handleData), then the + + handleData() function will be called once the data loads. The + + p5.XML object created from the data will be + passed + + to handleData() as its only argument.

+ +

The third parameter, failureCallback, is also optional. If a + function is + + passed, as in loadXML('/assets/data.xml', handleData, + handleFailure), then + + the handleFailure() function will be called if an error occurs + while + + loading. The Error object will be passed to + handleFailure() as its only + + argument.

+ +

Note: Data can take time to load. Calling loadXML() within + + preload() ensures data loads before it's + used in + + setup() or draw().

+line: 780 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let myXML; + + // Load the XML and create a p5.XML object. + function preload() { + myXML = loadXML('/assets/animals.xml'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Get an array with all mammal tags. + let mammals = myXML.getChildren('mammal'); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(14); + + // Iterate over the mammals array. + for (let i = 0; i < mammals.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 25; + + // Get the mammal's common name. + let name = mammals[i].getContent(); + + // Display the mammal's name. + text(name, 20, y); + } + + describe( + 'The words "Goat", "Leopard", and "Zebra" written on three separate lines. The text is black on a gray background.' + ); + } + +
+ +
+ + let lastMammal; + + // Load the XML and create a p5.XML object. + function preload() { + loadXML('/assets/animals.xml', handleData); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(CENTER, CENTER); + textFont('Courier New'); + textSize(16); + + // Display the content of the last mammal element. + text(lastMammal, 50, 50); + + describe('The word "Zebra" written in black on a gray background.'); + } + + // Get the content of the last mammal element. + function handleData(data) { + // Get an array with all mammal elements. + let mammals = data.getChildren('mammal'); + + // Get the content of the last mammal. + lastMammal = mammals[mammals.length - 1].getContent(); + } + +
+ +
+ + let lastMammal; + + // Load the XML and preprocess it. + function preload() { + loadXML('/assets/animals.xml', handleData, handleError); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(CENTER, CENTER); + textFont('Courier New'); + textSize(16); + + // Display the content of the last mammal element. + text(lastMammal, 50, 50); + + describe('The word "Zebra" written in black on a gray background.'); + } + + // Get the content of the last mammal element. + function handleData(data) { + // Get an array with all mammal elements. + let mammals = data.getChildren('mammal'); + + // Get the content of the last mammal. + lastMammal = mammals[mammals.length - 1].getContent(); + } + + // Log any errors to the console. + function handleError(error) { + console.error('Oops!', error); + } + +
+class: p5 +params: + - name: path + description: | +

path of the XML file to be loaded.

+ type: String + - name: successCallback + description: | +

function to call once the data is + loaded. Will be passed the + p5.XML object.

+ type: Function + optional: true + - name: errorCallback + description: | +

function to call if the data fails to + load. Will be passed an Error event + object.

+ type: Function + optional: true +return: + description: |- + XML data loaded into a p5.XML + object. + type: p5.XML +chainable: false +--- + + +# loadXML diff --git a/src/content/reference/en/p5 copy/log.mdx b/src/content/reference/en/p5 copy/log.mdx new file mode 100644 index 0000000000..c84c6d5a4b --- /dev/null +++ b/src/content/reference/en/p5 copy/log.mdx @@ -0,0 +1,79 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L423 +title: log +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Calculates the natural logarithm (the base-e logarithm) of a number.

+ +

log() expects the n parameter to be a value + greater than 0 because + + the natural logarithm is defined that way.

+line: 423 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Top-left. + let d = log(50); + circle(33, 33, d); + + // Bottom-right. + d = log(500000000); + circle(67, 67, d); + + describe('Two white circles. The circle at the top-left is small. The circle at the bottom-right is about five times larger.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + describe('A series of black dots that get higher slowly from left to right.'); + } + + function draw() { + // Invert the y-axis. + scale(1, -1); + translate(0, -100); + + // Calculate coordinates. + let x = frameCount; + let y = 15 * log(x); + + // Draw a point. + point(x, y); + } + +
+class: p5 +params: + - name: 'n' + description: | +

number greater than 0.

+ type: Number +return: + description: natural logarithm of n. + type: Number +chainable: false +--- + + +# log diff --git a/src/content/reference/en/p5 copy/loop.mdx b/src/content/reference/en/p5 copy/loop.mdx new file mode 100644 index 0000000000..a73432d2c1 --- /dev/null +++ b/src/content/reference/en/p5 copy/loop.mdx @@ -0,0 +1,111 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L127 +title: loop +module: Structure +submodule: Structure +file: src/core/structure.js +description: > +

Resumes the draw loop after noLoop() + has been + + called.

+ +

By default, draw() tries to run 60 times + per + + second. Calling noLoop() stops + + draw() from repeating. The draw loop can be + + restarted by calling loop().

+ +

The isLooping() function can be used + to check + + whether a sketch is looping, as in isLooping() === true.

+line: 127 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Turn off the draw loop. + noLoop(); + + describe( + 'A white half-circle on the left edge of a gray square. The circle starts moving to the right when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Calculate the circle's x-coordinate. + let x = frameCount; + + // Draw the circle. + circle(x, 50, 20); + } + + // Resume the draw loop when the user double-clicks. + function doubleClicked() { + loop(); + } + +
+ +
+ + let startButton; + let stopButton; + + function setup() { + createCanvas(100, 100); + + // Create the button elements and place them + // beneath the canvas. + startButton = createButton('▶'); + startButton.position(0, 100); + startButton.size(50, 20); + stopButton = createButton('◾'); + stopButton.position(50, 100); + stopButton.size(50, 20); + + // Set functions to call when the buttons are pressed. + startButton.mousePressed(loop); + stopButton.mousePressed(noLoop); + + // Slow the frame rate. + frameRate(5); + + describe( + 'A white circle moves randomly on a gray background. Play and stop buttons are shown beneath the canvas. The circle stops or starts moving when the user presses a button.' + ); + } + + function draw() { + background(200); + + // Calculate the circle's coordinates. + let x = random(0, 100); + let y = random(0, 100); + + // Draw the circle. + // Normally, the circle would move from left to right. + circle(x, y, 20); + } + +
+class: p5 +chainable: false +--- + + +# loop diff --git a/src/content/reference/en/p5 copy/mag.mdx b/src/content/reference/en/p5 copy/mag.mdx new file mode 100644 index 0000000000..4d46565b07 --- /dev/null +++ b/src/content/reference/en/p5 copy/mag.mdx @@ -0,0 +1,84 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L481 +title: mag +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Calculates the magnitude, or length, of a vector.

+ +

A vector can be thought of in different ways. In one view, a vector is a + + point in space. The vector's components, x and y, + are the point's + + coordinates (x, y). A vector's magnitude is the distance from the + origin + + (0, 0) to (x, y). mag(x, y) is a + shortcut for calling + + dist(0, 0, x, y).

+ +

A vector can also be thought of as an arrow pointing in space. This view is + + helpful for programming motion. See p5.Vector for + + more details.

+ +

Use p5.Vector.mag() to calculate + the + + magnitude of a p5.Vector object.

+line: 481 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Set the vector's components. + let x = 30; + let y = 40; + + // Calculate the magnitude. + let m = mag(x, y); + + // Style the text. + textSize(16); + + // Display the vector and its magnitude. + line(0, 0, x, y); + text(m, x, y); + + describe('A diagonal line is drawn from the top left of the canvas. The number 50 is written at the end of the line.'); + } + +
+class: p5 +params: + - name: x + description: | +

first component.

+ type: Number + - name: 'y' + description: | +

second component.

+ type: Number +return: + description: magnitude of vector. + type: Number +chainable: false +--- + + +# mag diff --git a/src/content/reference/en/p5 copy/map.mdx b/src/content/reference/en/p5 copy/map.mdx new file mode 100644 index 0000000000..a94e6e4dd7 --- /dev/null +++ b/src/content/reference/en/p5 copy/map.mdx @@ -0,0 +1,119 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L534 +title: map +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Re-maps a number from one range to another.

+ +

For example, calling map(2, 0, 10, 0, 100) returns 20. The + first three + + arguments set the original value to 2 and the original range from 0 to 10. + + The last two arguments set the target range from 0 to 100. 20's position + + in the target range [0, 100] is proportional to 2's position in the + + original range [0, 10].

+ +

The sixth parameter, withinBounds, is optional. By default, + map() can + + return values outside of the target range. For example, + + map(11, 0, 10, 0, 100) returns 110. Passing true as + the sixth parameter + + constrains the remapped value to the target range. For example, + + map(11, 0, 10, 0, 100, true) returns 100.

+line: 534 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('Two horizontal lines. The top line grows horizontally as the mouse moves to the right. The bottom line also grows horizontally but is scaled to stay on the left half of the canvas.'); + } + + function draw() { + background(200); + + // Draw the top line. + line(0, 25, mouseX, 25); + + // Remap mouseX from [0, 100] to [0, 50]. + let x = map(mouseX, 0, 100, 0, 50); + + // Draw the bottom line. + line(0, 75, x, 75); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A circle changes color from black to white as the mouse moves from left to right.'); + } + + function draw() { + background(200); + + // Remap mouseX from [0, 100] to [0, 255] + let c = map(mouseX, 0, 100, 0, 255); + + // Style the circle. + fill(c); + + // Draw the circle. + circle(50, 50, 20); + } + +
+class: p5 +params: + - name: value + description: | +

the value to be remapped.

+ type: Number + - name: start1 + description: | +

lower bound of the value's current range.

+ type: Number + - name: stop1 + description: | +

upper bound of the value's current range.

+ type: Number + - name: start2 + description: | +

lower bound of the value's target range.

+ type: Number + - name: stop2 + description: | +

upper bound of the value's target range.

+ type: Number + - name: withinBounds + description: | +

constrain the value to the newly mapped range.

+ type: Boolean + optional: true +return: + description: remapped number. + type: Number +chainable: false +--- + + +# map diff --git a/src/content/reference/en/p5 copy/match.mdx b/src/content/reference/en/p5 copy/match.mdx new file mode 100644 index 0000000000..c93425e96d --- /dev/null +++ b/src/content/reference/en/p5 copy/match.mdx @@ -0,0 +1,91 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L60 +title: match +module: Data +submodule: String Functions +file: src/utilities/string_functions.js +description: > +

Applies a regular expression to a string and returns an array with the + + first match.

+ +

match() uses regular expressions (regex) to match patterns in + text. For + + example, the regex abc can be used to search a string for the + exact + + sequence of characters abc. See + + MDN. + + for more information about regexes.

+ +

The first parameter, str, is the string to search.

+ +

The second parameter, regex, is a string with the regular + expression to + + apply. For example, calling match('Hello, p5*js!', '[a-z][0-9]') + would + + return the array ['p5'].

+ +

Note: If no matches are found, null is returned.

+line: 60 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let string = 'Hello, p5*js!'; + + // Match the characters that are lowercase + // letters followed by digits. + let matches = match(string, '[a-z][0-9]'); + + // Print the matches array to the console: + // ['p5'] + print(matches); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the matches. + text(matches, 50, 50); + + describe('The text "p5" written in black on a gray canvas.'); + } + +
+class: p5 +params: + - name: str + description: | +

string to search.

+ type: String + - name: regexp + description: | +

regular expression to match.

+ type: String +return: + description: match if found. + type: 'String[]' +chainable: false +--- + + +# match diff --git a/src/content/reference/en/p5 copy/matchAll.mdx b/src/content/reference/en/p5 copy/matchAll.mdx new file mode 100644 index 0000000000..371d596b61 --- /dev/null +++ b/src/content/reference/en/p5 copy/matchAll.mdx @@ -0,0 +1,107 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L119 +title: matchAll +module: Data +submodule: String Functions +file: src/utilities/string_functions.js +description: > +

Applies a regular expression to a string and returns an array of + matches.

+ +

match() uses regular expressions (regex) to match patterns in + text. For + + example, the regex abc can be used to search a string for the + exact + + sequence of characters abc. See + + MDN. + + for more information about regexes. matchAll() is different from + + match() because it returns every match, not + just + + the first.

+ +

The first parameter, str, is the string to search.

+ +

The second parameter, regex, is a string with the regular + expression to + + apply. For example, calling + + matchAll('p5*js is easier than abc123', '[a-z][0-9]') would + return the + + 2D array [['p5'], ['c1']].

+ +

Note: If no matches are found, an empty array [] is + returned.

+line: 119 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let string = 'p5*js is easier than abc123'; + + // Match the character sequences that are + // lowercase letters followed by digits. + let matches = matchAll(string, '[a-z][0-9]'); + + // Print the matches array to the console: + // [['p5'], ['c1']] + print(matches); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Iterate over the matches array. + for (let i = 0; i < matches.length; i += 1) { + + // Calculate the y-coordainate. + let y = (i + 1) * 33; + + // Display the match. + text(matches[i], 50, y); + } + + describe( + 'The text "p5" and "c1" written on separate lines. The text is black on a gray background.' + ); + } + +
+class: p5 +params: + - name: str + description: | +

string to search.

+ type: String + - name: regexp + description: | +

regular expression to match.

+ type: String +return: + description: matches found. + type: 'String[]' +chainable: false +--- + + +# matchAll diff --git a/src/content/reference/en/p5 copy/max.mdx b/src/content/reference/en/p5 copy/max.mdx new file mode 100644 index 0000000000..0dd0ee142c --- /dev/null +++ b/src/content/reference/en/p5 copy/max.mdx @@ -0,0 +1,104 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L618 +title: max +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Returns the largest value in a sequence of numbers.

+ +

The version of max() with one parameter interprets it as an + array of + + numbers and returns the largest number.

+ +

The version of max() with two or more parameters interprets + them as + + individual numbers and returns the largest number.

+line: 618 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Calculate the maximum of 10, 5, and 20. + let m = max(10, 5, 20); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the max. + text(m, 50, 50); + + describe('The number 20 written in the middle of a gray square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of numbers. + let numbers = [10, 5, 20]; + + // Calculate the maximum of the array. + let m = max(numbers); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the max. + text(m, 50, 50); + + describe('The number 20 written in the middle of a gray square.'); + } + +
+class: p5 +return: + description: maximum number. + type: Number +overloads: + - line: 618 + params: + - name: n0 + description: | +

first number to compare.

+ type: Number + - name: n1 + description: | +

second number to compare.

+ type: Number + return: + description: maximum number. + type: Number + - line: 680 + params: + - name: nums + description: | +

numbers to compare.

+ type: 'Number[]' + return: + description: '' + type: Number +chainable: false +--- + + +# max diff --git a/src/content/reference/en/p5 copy/metalness.mdx b/src/content/reference/en/p5 copy/metalness.mdx new file mode 100644 index 0000000000..ef378bc2a9 --- /dev/null +++ b/src/content/reference/en/p5 copy/metalness.mdx @@ -0,0 +1,142 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L3069 +title: metalness +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Sets the amount of "metalness" of a + + specularMaterial().

+ +

metalness() can make materials appear more metallic. It + affects the way + + materials reflect light sources including + + affects the way materials reflect light sources including + + directionalLight(), + + pointLight(), + + spotLight(), and + + imageLight().

+ +

The parameter, metallic, is a number that sets the amount of + metalness. + + metallic must be greater than 1, which is its default value. + Higher + + values, such as metalness(100), make specular materials appear + more + + metallic.

+line: 3069 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'Two blue spheres drawn on a gray background. White light reflects from their surfaces as the mouse moves. The right sphere is more metallic than the left sphere.' + ); + } + + function draw() { + background(200); + + // Turn on an ambient light. + ambientLight(200); + + // Get the mouse's coordinates. + let mx = mouseX - 50; + let my = mouseY - 50; + + // Turn on a white point light that follows the mouse. + pointLight(255, 255, 255, mx, my, 50); + + // Style the spheres. + noStroke(); + fill(30, 30, 255); + specularMaterial(255); + shininess(20); + + // Draw the left sphere with low metalness. + translate(-25, 0, 0); + metalness(1); + sphere(20); + + // Draw the right sphere with high metalness. + translate(50, 0, 0); + metalness(50); + sphere(20); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let img; + + function preload() { + img = loadImage('/assets/outdoor_spheremap.jpg'); + } + + function setup() { + createCanvas(100 ,100 ,WEBGL); + + describe( + 'Two spheres floating above a landscape. The surface of the spheres reflect the landscape. The right sphere is more reflective than the left sphere.' + ); + } + + function draw() { + // Add the panorama. + panorama(img); + + // Enable orbiting with the mouse. + orbitControl(); + + // Use the image as a light source. + imageLight(img); + + // Style the spheres. + noStroke(); + specularMaterial(50); + shininess(200); + + // Draw the left sphere with low metalness. + translate(-25, 0, 0); + metalness(1); + sphere(20); + + // Draw the right sphere with high metalness. + translate(50, 0, 0); + metalness(50); + sphere(20); + } + +
+class: p5 +params: + - name: metallic + description: | +

amount of metalness.

+ type: Number +chainable: false +--- + + +# metalness diff --git a/src/content/reference/en/p5 copy/midiToFreq.mdx b/src/content/reference/en/p5 copy/midiToFreq.mdx new file mode 100644 index 0000000000..ada29d80ea --- /dev/null +++ b/src/content/reference/en/p5 copy/midiToFreq.mdx @@ -0,0 +1,66 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L841 +title: midiToFreq +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: | +

Returns the frequency value of a MIDI note value. + General MIDI treats notes as integers where middle C + is 60, C# is 61, D is 62 etc. Useful for generating + musical frequencies with oscillators.

+line: 841 +isConstructor: false +itemtype: method +example: + - |- + +
+ let midiNotes = [60, 64, 67, 72]; + let noteIndex = 0; + let midiVal, freq; + + function setup() { + let cnv = createCanvas(100, 100); + cnv.mousePressed(startSound); + osc = new p5.TriOsc(); + env = new p5.Envelope(); + } + + function draw() { + background(220); + text('tap to play', 10, 20); + if (midiVal) { + text('MIDI: ' + midiVal, 10, 40); + text('Freq: ' + freq, 10, 60); + } + } + + function startSound() { + // see also: userStartAudio(); + osc.start(); + + midiVal = midiNotes[noteIndex % midiNotes.length]; + freq = midiToFreq(midiVal); + osc.freq(freq); + env.ramp(osc, 0, 1.0, 0); + + noteIndex++; + } +
+class: p5 +params: + - name: midiNote + description: | +

The number of a MIDI note

+ type: Number +return: + description: Frequency value of the given MIDI note + type: Number +chainable: false +--- + + +# midiToFreq diff --git a/src/content/reference/en/p5 copy/millis.mdx b/src/content/reference/en/p5 copy/millis.mdx new file mode 100644 index 0000000000..18f1ac06d0 --- /dev/null +++ b/src/content/reference/en/p5 copy/millis.mdx @@ -0,0 +1,147 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L112 +title: millis +module: IO +submodule: Time & Date +file: src/utilities/time_date.js +description: > +

Returns the number of milliseconds since a sketch started running.

+ +

millis() keeps track of how long a sketch has been running in + + milliseconds (thousandths of a second). This information is often + + helpful for timing events and animations.

+ +

If a sketch has a + + setup() function, then + millis() begins tracking + + time before the code in setup() runs. If a + + sketch includes a preload() function, + then + + millis() begins tracking time as soon as the code in + + preload() starts running.

+line: 112 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Get the number of milliseconds the sketch has run. + let ms = millis(); + + // Style the text. + textAlign(LEFT, CENTER); + textSize(10); + textFont('Courier New'); + + // Display how long it took setup() to be called. + text(`Startup time: ${round(ms, 2)} ms`, 5, 50, 90); + + describe( + `The text 'Startup time: ${round(ms, 2)} ms' written in black on a gray background.` + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('The text "Running time: S sec" written in black on a gray background. The number S increases as the sketch runs.'); + } + + function draw() { + background(200); + + // Get the number of seconds the sketch has run. + let s = millis() / 1000; + + // Style the text. + textAlign(LEFT, CENTER); + textSize(10); + textFont('Courier New'); + + // Display how long the sketch has run. + text(`Running time: ${nf(s, 1, 1)} sec`, 5, 50, 90); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A white circle oscillates left and right on a gray background.'); + } + + function draw() { + background(200); + + // Get the number of seconds the sketch has run. + let s = millis() / 1000; + + // Calculate an x-coordinate. + let x = 30 * sin(s) + 50; + + // Draw the circle. + circle(x, 50, 30); + } + +
+ +
+ + // Load the GeoJSON. + function preload() { + loadJSON('https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Get the number of milliseconds the sketch has run. + let ms = millis(); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(11); + + // Display how long it took to load the data. + text(`It took ${round(ms, 2)} ms to load the data`, 5, 50, 100); + + describe( + `The text "It took ${round(ms, 2)} ms to load the data" written in black on a gray background.` + ); + } + +
+class: p5 +return: + description: number of milliseconds since starting the sketch. + type: Number +chainable: false +--- + + +# millis diff --git a/src/content/reference/en/p5 copy/min.mdx b/src/content/reference/en/p5 copy/min.mdx new file mode 100644 index 0000000000..67af3b37f1 --- /dev/null +++ b/src/content/reference/en/p5 copy/min.mdx @@ -0,0 +1,104 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L695 +title: min +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Returns the smallest value in a sequence of numbers.

+ +

The version of min() with one parameter interprets it as an + array of + + numbers and returns the smallest number.

+ +

The version of min() with two or more parameters interprets + them as + + individual numbers and returns the smallest number.

+line: 695 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Calculate the minimum of 10, 5, and 20. + let m = min(10, 5, 20); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the min. + text(m, 50, 50); + + describe('The number 5 written in the middle of a gray square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of numbers. + let numbers = [10, 5, 20]; + + // Calculate the minimum of the array. + let m = min(numbers); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the min. + text(m, 50, 50); + + describe('The number 5 written in the middle of a gray square.'); + } + +
+class: p5 +return: + description: minimum number. + type: Number +overloads: + - line: 695 + params: + - name: n0 + description: | +

first number to compare.

+ type: Number + - name: n1 + description: | +

second number to compare.

+ type: Number + return: + description: minimum number. + type: Number + - line: 757 + params: + - name: nums + description: | +

numbers to compare.

+ type: 'Number[]' + return: + description: '' + type: Number +chainable: false +--- + + +# min diff --git a/src/content/reference/en/p5 copy/minute.mdx b/src/content/reference/en/p5 copy/minute.mdx new file mode 100644 index 0000000000..3ac966c800 --- /dev/null +++ b/src/content/reference/en/p5 copy/minute.mdx @@ -0,0 +1,47 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L78 +title: minute +module: IO +submodule: Time & Date +file: src/utilities/time_date.js +description: | +

Returns the current minute as a number from 0–59.

+line: 78 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Get the current minute. + let m = minute(); + + // Style the text. + textAlign(LEFT, CENTER); + textSize(12); + textFont('Courier New'); + + // Display the minute. + text(`Current minute: ${m}`, 10, 50, 80); + + describe(`The text 'Current minute: ${m}' written in black on a gray background.`); + } + +
+class: p5 +return: + description: current minute between 0 and 59. + type: Integer +chainable: false +--- + + +# minute diff --git a/src/content/reference/en/p5 copy/model.mdx b/src/content/reference/en/p5 copy/model.mdx new file mode 100644 index 0000000000..e925350407 --- /dev/null +++ b/src/content/reference/en/p5 copy/model.mdx @@ -0,0 +1,155 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/loading.js#L991 +title: model +module: Shape +submodule: 3D Models +file: src/webgl/loading.js +description: > +

Draws a p5.Geometry object to the + canvas.

+ +

The parameter, model, is the + + p5.Geometry object to draw. + + p5.Geometry objects can be built with + + buildGeometry(), or + + beginGeometry() and + + endGeometry(). They can also be + loaded from + + a file with loadGeometry().

+ +

Note: model() can only be used in WebGL mode.

+line: 991 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the p5.Geometry object. + shape = buildGeometry(createShape); + + describe('A white cone drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the p5.Geometry object. + model(shape); + } + + // Create p5.Geometry object from a single cone. + function createShape() { + cone(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the p5.Geometry object. + shape = buildGeometry(createArrow); + + describe('Two white arrows drawn on a gray background. The arrow on the right rotates slowly.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the arrows. + noStroke(); + + // Draw the p5.Geometry object. + model(shape); + + // Translate and rotate the coordinate system. + translate(30, 0, 0); + rotateZ(frameCount * 0.01); + + // Draw the p5.Geometry object again. + model(shape); + } + + function createArrow() { + // Add shapes to the p5.Geometry object. + push(); + rotateX(PI); + cone(10); + translate(0, -10, 0); + cylinder(3, 20); + pop(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + // Load the file and create a p5.Geometry object. + function preload() { + shape = loadModel('/assets/octahedron.obj'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white octahedron drawn against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the shape. + model(shape); + } + +
+class: p5 +params: + - name: model + description: | +

3D shape to be drawn.

+ type: p5.Geometry +chainable: false +--- + + +# model diff --git a/src/content/reference/en/p5 copy/month.mdx b/src/content/reference/en/p5 copy/month.mdx new file mode 100644 index 0000000000..d2e248235c --- /dev/null +++ b/src/content/reference/en/p5 copy/month.mdx @@ -0,0 +1,47 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L242 +title: month +module: IO +submodule: Time & Date +file: src/utilities/time_date.js +description: | +

Returns the current month as a number from 1–12.

+line: 242 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Get the current month. + let m = month(); + + // Style the text. + textAlign(LEFT, CENTER); + textSize(12); + textFont('Courier New'); + + // Display the month. + text(`Current month: ${m}`, 10, 50, 80); + + describe(`The text 'Current month: ${m}' written in black on a gray background.`); + } + +
+class: p5 +return: + description: current month between 1 and 12. + type: Integer +chainable: false +--- + + +# month diff --git a/src/content/reference/en/p5 copy/mouseButton.mdx b/src/content/reference/en/p5 copy/mouseButton.mdx new file mode 100644 index 0000000000..82128f97a3 --- /dev/null +++ b/src/content/reference/en/p5 copy/mouseButton.mdx @@ -0,0 +1,87 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L687 +title: mouseButton +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A String system variable that contains the value of the last mouse button + + pressed.

+ +

The mouseButton variable is either LEFT, + RIGHT, or CENTER, + + depending on which button was pressed last.

+ +

Note: Different browsers may track mouseButton differently. + See + + MDN + + for more information.

+line: 687 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with black text at its center. The text changes from 0 to either "left" or "right" when the user clicks a mouse button.' + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the mouse button. + text(mouseButton, 50, 50); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + "A gray square. Different shapes appear at its center depending on the mouse button that's clicked." + ); + } + + function draw() { + background(200); + + if (mouseIsPressed === true) { + if (mouseButton === LEFT) { + circle(50, 50, 50); + } + if (mouseButton === RIGHT) { + square(25, 25, 50); + } + if (mouseButton === CENTER) { + triangle(23, 75, 50, 20, 78, 75); + } + } + } + +
+class: p5 +type: Constant +--- + + +# mouseButton diff --git a/src/content/reference/en/p5 copy/mouseClicked.mdx b/src/content/reference/en/p5 copy/mouseClicked.mdx new file mode 100644 index 0000000000..80bd80b0a2 --- /dev/null +++ b/src/content/reference/en/p5 copy/mouseClicked.mdx @@ -0,0 +1,196 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1443 +title: mouseClicked +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A function that's called once after a mouse button is pressed and + released.

+ +

Declaring the function mouseClicked() sets a code block to run + + automatically when the user releases a mouse button after having pressed + + it:

+ +
function mouseClicked() {
+    // Code to run.
+  }
+
+  
+ +

The mouse system variables, such as mouseX and + + mouseY, will be updated with their most + recent + + value when mouseClicked() is called by p5.js:

+ +
function mouseClicked() {
+    if (mouseX < 50) {
+      // Code to run if the mouse is on the left.
+    }
+
+    if (mouseY > 50) {
+      // Code to run if the mouse is near the bottom.
+    }
+  }
+
+  
+ +

The parameter, event, is optional. mouseClicked() + is always passed a + + MouseEvent + + object with properties that describe the mouse click event:

+ +
function mouseClicked(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

On touchscreen devices, mouseClicked() will run when a user’s + touch + + ends if touchEnded() isn’t declared. + If + + touchEnded() is declared, then + + touchEnded() will run when a user’s + touch + + ends and mouseClicked() won’t.

+ +

Browsers may have default behaviors attached to various mouse events. For + + example, some browsers highlight text when the user moves the mouse while + + pressing a mouse button. To prevent any default behavior for this event, + + add return false; to the end of the function.

+ +

Note: mousePressed(), + + mouseReleased(), + + and mouseClicked() are all related. + + mousePressed() runs as soon as the + user + + clicks the mouse. mouseReleased() + runs as + + soon as the user releases the mouse click. mouseClicked() runs + + immediately after mouseReleased().

+line: 1443 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square changes color when the user presses and releases a mouse button.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Toggle the square's color when the user clicks. + function mouseClicked() { + if (value === 0) { + value = 255; + } else { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Style the circle. + fill('orange'); + stroke('royalblue'); + strokeWeight(10); + + describe( + 'An orange circle with a thick, blue border drawn on a gray background. When the user presses and holds the mouse, the border becomes thin and pink. When the user releases the mouse, the border becomes thicker and changes color to blue.' + ); + } + + function draw() { + background(220); + + // Draw the circle. + circle(50, 50, 20); + } + + // Set the stroke color and weight as soon as the user clicks. + function mousePressed() { + stroke('deeppink'); + strokeWeight(3); + } + + // Set the stroke and fill colors as soon as the user releases + // the mouse. + function mouseReleased() { + stroke('royalblue'); + + // This is never visible because fill() is called + // in mouseClicked() which runs immediately after + // mouseReleased(); + fill('limegreen'); + } + + // Set the fill color and stroke weight after + // mousePressed() and mouseReleased() are called. + function mouseClicked() { + fill('orange'); + strokeWeight(10); + } + +
+class: p5 +params: + - name: event + description: | +

optional MouseEvent argument.

+ type: MouseEvent + optional: true +chainable: false +--- + + +# mouseClicked diff --git a/src/content/reference/en/p5 copy/mouseDragged.mdx b/src/content/reference/en/p5 copy/mouseDragged.mdx new file mode 100644 index 0000000000..26fea21fe9 --- /dev/null +++ b/src/content/reference/en/p5 copy/mouseDragged.mdx @@ -0,0 +1,130 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L982 +title: mouseDragged +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A function that's called when the mouse moves while a button is + pressed.

+ +

Declaring the function mouseDragged() sets a code block to run + + automatically when the user clicks and drags the mouse:

+ +
function mouseDragged() {
+    // Code to run.
+  }
+
+  
+ +

The mouse system variables, such as mouseX and + + mouseY, will be updated with their most + recent + + value when mouseDragged() is called by p5.js:

+ +
function mouseDragged() {
+    if (mouseX < 50) {
+      // Code to run if the mouse is on the left.
+    }
+
+    if (mouseY > 50) {
+      // Code to run if the mouse is near the bottom.
+    }
+  }
+
+  
+ +

The parameter, event, is optional. mouseDragged() + is always passed a + + MouseEvent + + object with properties that describe the mouse drag event:

+ +
function mouseDragged(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

On touchscreen devices, mouseDragged() will run when a user + moves a touch + + point if touchMoved() isn’t declared. + If + + touchMoved() is declared, then + + touchMoved() will run when a user + moves a + + touch point and mouseDragged() won’t.

+ +

Browsers may have default behaviors attached to various mouse events. For + + example, some browsers highlight text when the user moves the mouse while + + pressing a mouse button. To prevent any default behavior for this event, + + add return false; to the end of the function.

+line: 982 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square becomes lighter as the user drags the mouse.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + function mouseDragged() { + // Update the grayscale value. + value += 5; + + // Reset the grayscale value. + if (value > 255) { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+class: p5 +params: + - name: event + description: | +

optional MouseEvent argument.

+ type: MouseEvent + optional: true +chainable: false +--- + + +# mouseDragged diff --git a/src/content/reference/en/p5 copy/mouseIsPressed.mdx b/src/content/reference/en/p5 copy/mouseIsPressed.mdx new file mode 100644 index 0000000000..37109eb364 --- /dev/null +++ b/src/content/reference/en/p5 copy/mouseIsPressed.mdx @@ -0,0 +1,73 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L755 +title: mouseIsPressed +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A Boolean system variable that's true if the + mouse is pressed and + + false if not.

+line: 755 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with the word "false" at its center. The word changes to "true" when the user presses a mouse button.' + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the mouseIsPressed variable. + text(mouseIsPressed, 25, 50); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a white square at its center. The inner square turns black when the user presses the mouse.' + ); + } + + function draw() { + background(200); + + // Style the square. + if (mouseIsPressed === true) { + fill(0); + } else { + fill(255); + } + + // Draw the square. + square(25, 25, 50); + } + +
+class: p5 +type: Boolean +--- + + +# mouseIsPressed diff --git a/src/content/reference/en/p5 copy/mouseMoved.mdx b/src/content/reference/en/p5 copy/mouseMoved.mdx new file mode 100644 index 0000000000..14928fdc5e --- /dev/null +++ b/src/content/reference/en/p5 copy/mouseMoved.mdx @@ -0,0 +1,118 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L896 +title: mouseMoved +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A function that's called when the mouse moves.

+ +

Declaring the function mouseMoved() sets a code block to run + + automatically when the user moves the mouse without clicking any mouse + + buttons:

+ +
function mouseMoved() {
+    // Code to run.
+  }
+
+  
+ +

The mouse system variables, such as mouseX and + + mouseY, will be updated with their most + recent + + value when mouseMoved() is called by p5.js:

+ +
function mouseMoved() {
+    if (mouseX < 50) {
+      // Code to run if the mouse is on the left.
+    }
+
+    if (mouseY > 50) {
+      // Code to run if the mouse is near the bottom.
+    }
+  }
+
+  
+ +

The parameter, event, is optional. mouseMoved() + is always passed a + + MouseEvent + + object with properties that describe the mouse move event:

+ +
function mouseMoved(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

Browsers may have default behaviors attached to various mouse events. For + + example, some browsers highlight text when the user moves the mouse while + + pressing a mouse button. To prevent any default behavior for this event, + + add return false; to the end of the function.

+line: 896 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square becomes lighter as the mouse moves.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + function mouseMoved() { + // Update the grayscale value. + value += 5; + + // Reset the grayscale value. + if (value > 255) { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+class: p5 +params: + - name: event + description: | +

optional MouseEvent argument.

+ type: MouseEvent + optional: true +chainable: false +--- + + +# mouseMoved diff --git a/src/content/reference/en/p5 copy/mousePressed.mdx b/src/content/reference/en/p5 copy/mousePressed.mdx new file mode 100644 index 0000000000..81181859c1 --- /dev/null +++ b/src/content/reference/en/p5 copy/mousePressed.mdx @@ -0,0 +1,193 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1098 +title: mousePressed +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A function that's called once when a mouse button is pressed.

+ +

Declaring the function mousePressed() sets a code block to run + + automatically when the user presses a mouse button:

+ +
function mousePressed() {
+    // Code to run.
+  }
+
+  
+ +

The mouse system variables, such as mouseX and + + mouseY, will be updated with their most + recent + + value when mousePressed() is called by p5.js:

+ +
function mousePressed() {
+    if (mouseX < 50) {
+      // Code to run if the mouse is on the left.
+    }
+
+    if (mouseY > 50) {
+      // Code to run if the mouse is near the bottom.
+    }
+  }
+
+  
+ +

The parameter, event, is optional. mousePressed() + is always passed a + + MouseEvent + + object with properties that describe the mouse press event:

+ +
function mousePressed(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

On touchscreen devices, mousePressed() will run when a user’s + touch + + begins if touchStarted() isn’t + declared. If + + touchStarted() is declared, then + + touchStarted() will run when a + user’s touch + + begins and mousePressed() won’t.

+ +

Browsers may have default behaviors attached to various mouse events. For + + example, some browsers highlight text when the user moves the mouse while + + pressing a mouse button. To prevent any default behavior for this event, + + add return false; to the end of the function.

+ +

Note: mousePressed(), mouseReleased(), + + and mouseClicked() are all related. + + mousePressed() runs as soon as the user clicks the mouse. + + mouseReleased() runs as soon as the + user + + releases the mouse click. mouseClicked() + + runs immediately after mouseReleased().

+line: 1098 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square becomes lighter when the user presses a mouse button.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + function mousePressed() { + // Update the grayscale value. + value += 5; + + // Reset the grayscale value. + if (value > 255) { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Style the circle. + fill('orange'); + stroke('royalblue'); + strokeWeight(10); + + describe( + 'An orange circle with a thick, blue border drawn on a gray background. When the user presses and holds the mouse, the border becomes thin and pink. When the user releases the mouse, the border becomes thicker and changes color to blue.' + ); + } + + function draw() { + background(220); + + // Draw the circle. + circle(50, 50, 20); + } + + // Set the stroke color and weight as soon as the user clicks. + function mousePressed() { + stroke('deeppink'); + strokeWeight(3); + } + + // Set the stroke and fill colors as soon as the user releases + // the mouse. + function mouseReleased() { + stroke('royalblue'); + + // This is never visible because fill() is called + // in mouseClicked() which runs immediately after + // mouseReleased(); + fill('limegreen'); + } + + // Set the fill color and stroke weight after + // mousePressed() and mouseReleased() are called. + function mouseClicked() { + fill('orange'); + strokeWeight(10); + } + +
+class: p5 +params: + - name: event + description: | +

optional MouseEvent argument.

+ type: MouseEvent + optional: true +chainable: false +--- + + +# mousePressed diff --git a/src/content/reference/en/p5 copy/mouseReleased.mdx b/src/content/reference/en/p5 copy/mouseReleased.mdx new file mode 100644 index 0000000000..6f52911162 --- /dev/null +++ b/src/content/reference/en/p5 copy/mouseReleased.mdx @@ -0,0 +1,195 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1270 +title: mouseReleased +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A function that's called once when a mouse button is released.

+ +

Declaring the function mouseReleased() sets a code block to + run + + automatically when the user releases a mouse button after having pressed + + it:

+ +
function mouseReleased() {
+    // Code to run.
+  }
+
+  
+ +

The mouse system variables, such as mouseX and + + mouseY, will be updated with their most + recent + + value when mouseReleased() is called by p5.js:

+ +
function mouseReleased() {
+    if (mouseX < 50) {
+      // Code to run if the mouse is on the left.
+    }
+
+    if (mouseY > 50) {
+      // Code to run if the mouse is near the bottom.
+    }
+  }
+
+  
+ +

The parameter, event, is optional. + mouseReleased() is always passed a + + MouseEvent + + object with properties that describe the mouse release event:

+ +
function mouseReleased(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

On touchscreen devices, mouseReleased() will run when a user’s + touch + + ends if touchEnded() isn’t declared. + If + + touchEnded() is declared, then + + touchEnded() will run when a user’s + touch + + ends and mouseReleased() won’t.

+ +

Browsers may have default behaviors attached to various mouse events. For + + example, some browsers highlight text when the user moves the mouse while + + pressing a mouse button. To prevent any default behavior for this event, + + add return false; to the end of the function.

+ +

Note: mousePressed(), + mouseReleased(), + + and mouseClicked() are all related. + + mousePressed() runs as soon as the + user + + clicks the mouse. mouseReleased() runs as soon as the user + releases the + + mouse click. mouseClicked() runs + + immediately after mouseReleased().

+line: 1270 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square becomes lighter when the user presses and releases a mouse button.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + function mouseReleased() { + // Update the grayscale value. + value += 5; + + // Reset the grayscale value. + if (value > 255) { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Style the circle. + fill('orange'); + stroke('royalblue'); + strokeWeight(10); + + describe( + 'An orange circle with a thick, blue border drawn on a gray background. When the user presses and holds the mouse, the border becomes thin and pink. When the user releases the mouse, the border becomes thicker and changes color to blue.' + ); + } + + function draw() { + background(220); + + // Draw the circle. + circle(50, 50, 20); + } + + // Set the stroke color and weight as soon as the user clicks. + function mousePressed() { + stroke('deeppink'); + strokeWeight(3); + } + + // Set the stroke and fill colors as soon as the user releases + // the mouse. + function mouseReleased() { + stroke('royalblue'); + + // This is never visible because fill() is called + // in mouseClicked() which runs immediately after + // mouseReleased(); + fill('limegreen'); + } + + // Set the fill color and stroke weight after + // mousePressed() and mouseReleased() are called. + function mouseClicked() { + fill('orange'); + strokeWeight(10); + } + +
+class: p5 +params: + - name: event + description: | +

optional MouseEvent argument.

+ type: MouseEvent + optional: true +chainable: false +--- + + +# mouseReleased diff --git a/src/content/reference/en/p5 copy/mouseWheel.mdx b/src/content/reference/en/p5 copy/mouseWheel.mdx new file mode 100644 index 0000000000..a659ea3cec --- /dev/null +++ b/src/content/reference/en/p5 copy/mouseWheel.mdx @@ -0,0 +1,162 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1746 +title: mouseWheel +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A function that's called once when the mouse wheel moves.

+ +

Declaring the function mouseWheel() sets a code block to run + + automatically when the user scrolls with the mouse wheel:

+ +
function mouseWheel() {
+    // Code to run.
+  }
+
+  
+ +

The mouse system variables, such as mouseX and + + mouseY, will be updated with their most + recent + + value when mouseWheel() is called by p5.js:

+ +
function mouseWheel() {
+    if (mouseX < 50) {
+      // Code to run if the mouse is on the left.
+    }
+
+    if (mouseY > 50) {
+      // Code to run if the mouse is near the bottom.
+    }
+  }
+
+  
+ +

The parameter, event, is optional. mouseWheel() + is always passed a + + MouseEvent + + object with properties that describe the mouse scroll event:

+ +
function mouseWheel(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

The event object has many properties including + delta, a Number + + containing the distance that the user scrolled. For example, + event.delta + + might have the value 5 when the user scrolls up. event.delta is + positive + + if the user scrolls up and negative if they scroll down. The signs are + + opposite on macOS with "natural" scrolling enabled.

+ +

Browsers may have default behaviors attached to various mouse events. For + + example, some browsers highlight text when the user moves the mouse while + + pressing a mouse button. To prevent any default behavior for this event, + + add return false; to the end of the function.

+ +

Note: On Safari, mouseWheel() may only work as expected if + + return false; is added at the end of the function.

+line: 1746 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let circleSize = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square. A white circle at its center grows up when the user scrolls the mouse wheel.' + ); + } + + function draw() { + background(200); + + // Draw the circle + circle(50, 50, circleSize); + } + + // Increment circleSize when the user scrolls the mouse wheel. + function mouseWheel() { + circleSize += 1; + // Uncomment to prevent any default behavior. + // return false; + } + +
+ +
+ + let direction = ''; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square. An arrow at its center points up when the user scrolls up. The arrow points down when the user scrolls down.' + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Draw an arrow that points where + // the mouse last scrolled. + text(direction, 50, 50); + } + + // Change direction when the user scrolls the mouse wheel. + function mouseWheel(event) { + if (event.delta > 0) { + direction = '▲'; + } else { + direction = '▼'; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+class: p5 +params: + - name: event + description: | +

optional WheelEvent argument.

+ type: WheelEvent + optional: true +chainable: false +--- + + +# mouseWheel diff --git a/src/content/reference/en/p5 copy/mouseX.mdx b/src/content/reference/en/p5 copy/mouseX.mdx new file mode 100644 index 0000000000..7c0ba7f4a3 --- /dev/null +++ b/src/content/reference/en/p5 copy/mouseX.mdx @@ -0,0 +1,124 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L119 +title: mouseX +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A Number system variable that tracks the mouse's horizontal + position.

+ +

mouseX keeps track of the mouse's position relative to the + + top-left corner of the canvas. For example, if the mouse is 50 pixels from + + the left edge of the canvas, then mouseX will be 50.

+ +

If touch is used instead of the mouse, then mouseX will hold + the + + x-coordinate of the most recent touch point.

+line: 119 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe("A vertical black line moves left and right following the mouse's x-position."); + } + + function draw() { + background(200); + + // Draw a vertical line that follows the mouse's x-coordinate. + line(mouseX, 0, mouseX, 100); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe("A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse."); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the mouse's coordinates. + text(`x: ${mouseX} y: ${mouseY}`, 50, 50); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe("A vertical black line moves left and right following the mouse's x-position."); + } + + function draw() { + background(200); + + // Adjust coordinates for WebGL mode. + // The origin (0, 0) is at the center of the canvas. + let mx = mouseX - 50; + + // Draw the line. + line(mx, -50, mx, 50); + } + +
+ +
+ + let font; + + // Load a font for WebGL mode. + function preload() { + font = loadFont('/assets/inconsolata.otf'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + "A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse." + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + textFont(font); + fill(0); + + // Display the mouse's coordinates. + text(`x: ${mouseX} y: ${mouseY}`, 0, 0); + } + +
+class: p5 +type: Number +--- + + +# mouseX diff --git a/src/content/reference/en/p5 copy/mouseY.mdx b/src/content/reference/en/p5 copy/mouseY.mdx new file mode 100644 index 0000000000..dc268025a4 --- /dev/null +++ b/src/content/reference/en/p5 copy/mouseY.mdx @@ -0,0 +1,124 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L226 +title: mouseY +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A Number system variable that tracks the mouse's vertical + position.

+ +

mouseY keeps track of the mouse's position relative to the + + top-left corner of the canvas. For example, if the mouse is 50 pixels from + + the top edge of the canvas, then mouseY will be 50.

+ +

If touch is used instead of the mouse, then mouseY will hold + the + + y-coordinate of the most recent touch point.

+line: 226 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe("A horizontal black line moves up and down following the mouse's y-position."); + } + + function draw() { + background(200); + + // Draw a horizontal line that follows the mouse's y-coordinate. + line(0, mouseY, 100, mouseY); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe("A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse."); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the mouse's coordinates. + text(`x: ${mouseX} y: ${mouseY}`, 50, 50); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe("A horizontal black line moves up and down following the mouse's y-position."); + } + + function draw() { + background(200); + + // Adjust coordinates for WebGL mode. + // The origin (0, 0) is at the center of the canvas. + let my = mouseY - 50; + + // Draw the line. + line(-50, my, 50, my); + } + +
+ +
+ + let font; + + // Load a font for WebGL mode. + function preload() { + font = loadFont('/assets/inconsolata.otf'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + "A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse." + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + textFont(font); + fill(0); + + // Display the mouse's coordinates. + text(`x: ${mouseX} y: ${mouseY}`, 0, 0); + } + +
+class: p5 +type: Number +--- + + +# mouseY diff --git a/src/content/reference/en/p5 copy/movedX.mdx b/src/content/reference/en/p5 copy/movedX.mdx new file mode 100644 index 0000000000..454b577166 --- /dev/null +++ b/src/content/reference/en/p5 copy/movedX.mdx @@ -0,0 +1,78 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L12 +title: movedX +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A Number system variable that tracks the mouse's horizontal + movement.

+ +

movedX tracks how many pixels the mouse moves left or right + between + + frames. movedX will have a negative value if the mouse moves left + between + + frames and a positive value if it moves right. movedX can be + calculated + + as mouseX - pmouseX.

+ +

Note: movedX continues updating even when + + requestPointerLock() is + active. + + But keep in mind that during an active pointer lock, mouseX and pmouseX + + are locked, so movedX is based on + + the + MouseEvent's movementX value + + (which may behave differently in different browsers when the user + + is zoomed in or out).

+line: 12 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square. The text ">>" appears when the user moves the mouse to the right. The text "<<" appears when the user moves the mouse to the left.' + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display >> when movedX is positive and + // << when it's negative. + if (movedX > 0) { + text('>>', 50, 50); + } else if (movedX < 0) { + text('<<', 50, 50); + } + } + +
+class: p5 +type: Number +--- + + +# movedX diff --git a/src/content/reference/en/p5 copy/movedY.mdx b/src/content/reference/en/p5 copy/movedY.mdx new file mode 100644 index 0000000000..00f4a28d5b --- /dev/null +++ b/src/content/reference/en/p5 copy/movedY.mdx @@ -0,0 +1,78 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L62 +title: movedY +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A Number system variable that tracks the mouse's vertical + movement.

+ +

movedY tracks how many pixels the mouse moves up or down + between + + frames. movedY will have a negative value if the mouse moves up + between + + frames and a positive value if it moves down. movedY can be + calculated + + as mouseY - pmouseY.

+ +

Note: movedY continues updating even when + + requestPointerLock() is + active. + + But keep in mind that during an active pointer lock, mouseX and pmouseX + + are locked, so movedX is based on + + the + MouseEvent's movementX value + + (which may behave differently in different browsers when the user + + is zoomed in or out).

+line: 62 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square. The text "▲" appears when the user moves the mouse upward. The text "▼" appears when the user moves the mouse downward.' + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display ▼ when movedY is positive and + // ▲ when it's negative. + if (movedY > 0) { + text('▼', 50, 50); + } else if (movedY < 0) { + text('▲', 50, 50); + } + } + +
+class: p5 +type: Number +--- + + +# movedY diff --git a/src/content/reference/en/p5 copy/nf.mdx b/src/content/reference/en/p5 copy/nf.mdx new file mode 100644 index 0000000000..ab64244d9f --- /dev/null +++ b/src/content/reference/en/p5 copy/nf.mdx @@ -0,0 +1,159 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L199 +title: nf +module: Data +submodule: String Functions +file: src/utilities/string_functions.js +description: > +

Converts a Number into a String with a given + number of digits.

+ +

nf() converts numbers such as 123.45 into strings + formatted with a set + + number of digits, as in '123.4500'.

+ +

The first parameter, num, is the number to convert to a + string. For + + example, calling nf(123.45) returns the string + '123.45'. If an array of + + numbers is passed, as in nf([123.45, 67.89]), an array of + formatted + + strings will be returned.

+ +

The second parameter, left, is optional. If a number is + passed, as in + + nf(123.45, 4), it sets the minimum number of digits to include to + the + + left of the decimal place. If left is larger than the number of + digits in + + num, then unused digits will be set to 0. For example, calling + + nf(123.45, 4) returns the string '0123.45'.

+ +

The third parameter, right, is also optional. If a number is + passed, as + + in nf(123.45, 4, 1), it sets the minimum number of digits to + include to + + the right of the decimal place. If right is smaller than the + number of + + decimal places in num, then num will be rounded to + the given number of + + decimal places. For example, calling nf(123.45, 4, 1) returns the + string + + '0123.5'. If right is larger than the number of decimal places in + num, + + then unused decimal places will be set to 0. For example, calling + + nf(123.45, 4, 3) returns the string '0123.450'.

+ +

When the number is negative, for example, calling nf(-123.45, 5, + 2) + + returns the string '-00123.45'.

+line: 199 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textSize(16); + + // Create a number variable. + let number = 123.45; + + // Display the number as a string. + let formatted = nf(number); + text(formatted, 20, 20); + + let negative = nf(-number, 4, 2); + text(negative, 20, 40); + + // Display the number with four digits + // to the left of the decimal. + let left = nf(number, 4); + text(left, 20, 60); + + // Display the number with four digits + // to the left of the decimal and one + // to the right. + let right = nf(number, 4, 1); + text(right, 20, 80); + + describe( + 'The numbers "123.45", "-0123.45", "0123.45", and "0123.5" written on four separate lines. The text is in black on a gray background.' + ); + } + +
+class: p5 +return: + description: formatted string. + type: String +overloads: + - line: 199 + params: + - name: num + description: | +

number to format.

+ type: Number|String + - name: left + description: | +

number of digits to include to the left of + the decimal point.

+ type: Integer|String + optional: true + - name: right + description: | +

number of digits to include to the right + of the decimal point.

+ type: Integer|String + optional: true + return: + description: formatted string. + type: String + - line: 276 + params: + - name: nums + description: | +

numbers to format.

+ type: 'Number[]' + - name: left + description: '' + type: Integer|String + optional: true + - name: right + description: '' + type: Integer|String + optional: true + return: + description: formatted strings. + type: 'String[]' +chainable: false +--- + + +# nf diff --git a/src/content/reference/en/p5 copy/nfc.mdx b/src/content/reference/en/p5 copy/nfc.mdx new file mode 100644 index 0000000000..ba49f689fa --- /dev/null +++ b/src/content/reference/en/p5 copy/nfc.mdx @@ -0,0 +1,153 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L322 +title: nfc +module: Data +submodule: String Functions +file: src/utilities/string_functions.js +description: > +

Converts a Number into a String with commas to + mark units of 1,000.

+ +

nfc() converts numbers such as 12345 into strings formatted + with commas + + to mark the thousands place, as in '12,345'.

+ +

The first parameter, num, is the number to convert to a + string. For + + example, calling nfc(12345) returns the string + '12,345'.

+ +

The second parameter, right, is optional. If a number is + passed, as in + + nfc(12345, 1), it sets the minimum number of digits to include to + the + + right of the decimal place. If right is smaller than the number + of + + decimal places in num, then num will be rounded to + the given number of + + decimal places. For example, calling nfc(12345.67, 1) returns the + string + + '12,345.7'. If right is larger than the number of + decimal places in + + num, then unused decimal places will be set to 0. For example, + calling + + nfc(12345.67, 3) returns the string + '12,345.670'.

+line: 322 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textSize(16); + + // Create a number variable. + let number = 12345; + + // Display the number as a string. + let commas = nfc(number); + text(commas, 15, 33); + + // Display the number with four digits + // to the left of the decimal. + let decimals = nfc(number, 2); + text(decimals, 15, 67); + + describe( + 'The numbers "12,345" and "12,345.00" written on separate lines. The text is in black on a gray background.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of numbers. + let numbers = [12345, 6789]; + + // Convert the numbers to formatted strings. + let formatted = nfc(numbers); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(14); + + // Iterate over the array. + for (let i = 0; i < formatted.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 33; + + // Display the original and formatted numbers. + text(`${numbers[i]} : ${formatted[i]}`, 50, y); + } + + describe( + 'The text "12345 : 12,345" and "6789 : 6,789" written on two separate lines. The text is in black on a gray background.' + ); + } + +
+class: p5 +return: + description: formatted string. + type: String +overloads: + - line: 322 + params: + - name: num + description: | +

number to format.

+ type: Number|String + - name: right + description: | +

number of digits to include to the right + of the decimal point.

+ type: Integer|String + optional: true + return: + description: formatted string. + type: String + - line: 411 + params: + - name: nums + description: | +

numbers to format.

+ type: 'Number[]' + - name: right + description: '' + type: Integer|String + optional: true + return: + description: formatted strings. + type: 'String[]' +chainable: false +--- + + +# nfc diff --git a/src/content/reference/en/p5 copy/nfp.mdx b/src/content/reference/en/p5 copy/nfp.mdx new file mode 100644 index 0000000000..dbd80ca5d7 --- /dev/null +++ b/src/content/reference/en/p5 copy/nfp.mdx @@ -0,0 +1,188 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L447 +title: nfp +module: Data +submodule: String Functions +file: src/utilities/string_functions.js +description: > +

Converts a Number into a String with a plus or + minus sign.

+ +

nfp() converts numbers such as 123 into strings formatted with + a + or + + - symbol to mark whether they're positive or negative, as in + '+123'.

+ +

The first parameter, num, is the number to convert to a + string. For + + example, calling nfp(123.45) returns the string + '+123.45'. If an array + + of numbers is passed, as in nfp([123.45, -6.78]), an array of + formatted + + strings will be returned.

+ +

The second parameter, left, is optional. If a number is + passed, as in + + nfp(123.45, 4), it sets the minimum number of digits to include + to the + + left of the decimal place. If left is larger than the number of + digits in + + num, then unused digits will be set to 0. For example, calling + + nfp(123.45, 4) returns the string '+0123.45'.

+ +

The third parameter, right, is also optional. If a number is + passed, as + + in nfp(123.45, 4, 1), it sets the minimum number of digits to + include to + + the right of the decimal place. If right is smaller than the + number of + + decimal places in num, then num will be rounded to + the given number of + + decimal places. For example, calling nfp(123.45, 4, 1) returns + the + + string '+0123.5'. If right is larger than the number + of decimal places + + in num, then unused decimal places will be set to 0. For + example, + + calling nfp(123.45, 4, 3) returns the string + '+0123.450'.

+line: 447 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create number variables. + let positive = 123; + let negative = -123; + + // Convert the positive number to a formatted string. + let p = nfp(positive); + + // Convert the negative number to a formatted string + // with four digits to the left of the decimal + // and two digits to the right of the decimal. + let n = nfp(negative, 4, 2); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(14); + + // Display the original and formatted numbers. + text(`${positive} : ${p}`, 50, 33); + text(`${negative} : ${n}`, 50, 67); + + describe( + 'The text "123 : +123" and "-123 : -123.00" written on separate lines. The text is in black on a gray background.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create number variables. + let numbers = [123, -4.56]; + + // Convert the numbers to formatted strings + // with four digits to the left of the decimal + // and one digit to the right of the decimal. + let formatted = nfp(numbers, 4, 1); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(14); + + // Iterate over the array. + for (let i = 0; i < formatted.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 33; + + // Display the original and formatted numbers. + text(`${numbers[i]} : ${formatted[i]}`, 50, y); + } + + describe( + 'The text "123 : +0123.0" and "-4.56 : 00-4.6" written on separate lines. The text is in black on a gray background.' + ); + } + +
+class: p5 +return: + description: formatted string. + type: String +overloads: + - line: 447 + params: + - name: num + description: | +

number to format.

+ type: Number + - name: left + description: | +

number of digits to include to the left of the + decimal point.

+ type: Integer + optional: true + - name: right + description: | +

number of digits to include to the right of the + decimal point.

+ type: Integer + optional: true + return: + description: formatted string. + type: String + - line: 552 + params: + - name: nums + description: | +

numbers to format.

+ type: 'Number[]' + - name: left + description: '' + type: Integer + optional: true + - name: right + description: '' + type: Integer + optional: true + return: + description: formatted strings. + type: 'String[]' +chainable: false +--- + + +# nfp diff --git a/src/content/reference/en/p5 copy/nfs.mdx b/src/content/reference/en/p5 copy/nfs.mdx new file mode 100644 index 0000000000..80c144e391 --- /dev/null +++ b/src/content/reference/en/p5 copy/nfs.mdx @@ -0,0 +1,176 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L573 +title: nfs +module: Data +submodule: String Functions +file: src/utilities/string_functions.js +description: > +

Converts a positive Number into a String with an + extra space in front.

+ +

nfs() converts positive numbers such as 123.45 into strings + formatted + + with an extra space in front, as in ' 123.45'. Doing so can be helpful for + + aligning positive and negative numbers.

+ +

The first parameter, num, is the number to convert to a + string. For + + example, calling nfs(123.45) returns the string ' + 123.45'.

+ +

The second parameter, left, is optional. If a number is + passed, as in + + nfs(123.45, 4), it sets the minimum number of digits to include + to the + + left of the decimal place. If left is larger than the number of + digits in + + num, then unused digits will be set to 0. For example, calling + + nfs(123.45, 4) returns the string ' 0123.45'.

+ +

The third parameter, right, is also optional. If a number is + passed, as + + in nfs(123.45, 4, 1), it sets the minimum number of digits to + include to + + the right of the decimal place. If right is smaller than the + number of + + decimal places in num, then num will be rounded to + the given number of + + decimal places. For example, calling nfs(123.45, 4, 1) returns + the + + string ' 0123.5'. If right is larger than the number + of decimal places + + in num, then unused decimal places will be set to 0. For + example, + + calling nfs(123.45, 4, 3) returns the string ' + 0123.450'.

+line: 573 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create number variables. + let positive = 123; + let negative = -123; + + // Convert the positive number to a formatted string. + let formatted = nfs(positive); + + // Style the text. + textAlign(CENTER, CENTER); + textFont('Courier New'); + textSize(16); + + // Display the negative number and the formatted positive number. + text(negative, 50, 33); + text(formatted, 50, 67); + + describe( + 'The numbers -123 and 123 written on separate lines. The numbers align vertically. The text is in black on a gray background.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a number variable. + let number = 123.45; + + // Convert the positive number to a formatted string. + // Use four digits to the left of the decimal and + // one digit to the right. + let formatted = nfs(number, 4, 1); + + // Style the text. + textAlign(CENTER, CENTER); + textFont('Courier New'); + textSize(16); + + // Display a negative version of the number and + // the formatted positive version. + text('-0123.5', 50, 33); + text(formatted, 50, 67); + + describe( + 'The numbers "-0123.5" and "0123.5" written on separate lines. The numbers align vertically. The text is in black on a gray background.' + ); + } + +
+class: p5 +return: + description: formatted string. + type: String +overloads: + - line: 573 + params: + - name: num + description: | +

number to format.

+ type: Number + - name: left + description: | +

number of digits to include to the left of the + decimal point.

+ type: Integer + optional: true + - name: right + description: | +

number of digits to include to the right of the + decimal point.

+ type: Integer + optional: true + return: + description: formatted string. + type: String + - line: 669 + params: + - name: nums + description: | +

numbers to format.

+ type: Array + - name: left + description: '' + type: Integer + optional: true + - name: right + description: '' + type: Integer + optional: true + return: + description: formatted strings. + type: 'String[]' +chainable: false +--- + + +# nfs diff --git a/src/content/reference/en/p5 copy/noCanvas.mdx b/src/content/reference/en/p5 copy/noCanvas.mdx new file mode 100644 index 0000000000..08fcdda5e5 --- /dev/null +++ b/src/content/reference/en/p5 copy/noCanvas.mdx @@ -0,0 +1,36 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L346 +title: noCanvas +module: Rendering +submodule: Rendering +file: src/core/rendering.js +description: > +

Removes the default canvas.

+ +

By default, a 100×100 pixels canvas is created without needing to call + + createCanvas(). + noCanvas() removes the + + default canvas for sketches that don't need it.

+line: 346 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + noCanvas(); + } + +
+class: p5 +chainable: false +--- + + +# noCanvas diff --git a/src/content/reference/en/p5 copy/noCursor.mdx b/src/content/reference/en/p5 copy/noCursor.mdx new file mode 100644 index 0000000000..37ac72c0cf --- /dev/null +++ b/src/content/reference/en/p5 copy/noCursor.mdx @@ -0,0 +1,38 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L482 +title: noCursor +module: Environment +submodule: Environment +file: src/core/environment.js +description: | +

Hides the cursor from view.

+line: 482 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + // Hide the cursor. + noCursor(); + } + + function draw() { + background(200); + + circle(mouseX, mouseY, 10); + + describe('A white circle on a gray background. The circle follows the mouse as it moves. The cursor is hidden.'); + } + +
+class: p5 +chainable: false +--- + + +# noCursor diff --git a/src/content/reference/en/p5 copy/noDebugMode.mdx b/src/content/reference/en/p5 copy/noDebugMode.mdx new file mode 100644 index 0000000000..19d36eba2b --- /dev/null +++ b/src/content/reference/en/p5 copy/noDebugMode.mdx @@ -0,0 +1,54 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/interaction.js#L725 +title: noDebugMode +module: 3D +submodule: Interaction +file: src/webgl/interaction.js +description: > +

Turns off debugMode() in a 3D + sketch.

+line: 725 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + // Enable debug mode. + debugMode(); + + describe('A multicolor box on a gray background. A grid and axes icon are displayed near the box. They disappear when the user double-clicks.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the box. + normalMaterial(); + + // Draw the box. box(20, 40); + } + + // Disable debug mode when the user double-clicks. + function doubleClicked() { + noDebugMode(); + } + +
+class: p5 +chainable: false +--- + + +# noDebugMode diff --git a/src/content/reference/en/p5 copy/noErase.mdx b/src/content/reference/en/p5 copy/noErase.mdx new file mode 100644 index 0000000000..e959433b77 --- /dev/null +++ b/src/content/reference/en/p5 copy/noErase.mdx @@ -0,0 +1,55 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1716 +title: noErase +module: Color +submodule: Setting +file: src/color/setting.js +description: > +

Ends erasing that was started with erase().

+ +

The fill(), stroke(), and + + blendMode() settings will return to + what they + + were prior to calling erase().

+line: 1716 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(235, 145, 15); + + // Draw the left rectangle. + noStroke(); + fill(30, 45, 220); + rect(30, 10, 10, 80); + + // Erase a circle. + erase(); + circle(50, 50, 60); + noErase(); + + // Draw the right rectangle. + rect(70, 10, 10, 80); + + describe('An orange canvas with two tall blue rectangles. A circular hole in the center erases the rectangle on the left but not the one on the right.'); + } + +
+class: p5 +chainable: true +--- + + +# noErase diff --git a/src/content/reference/en/p5 copy/noFill.mdx b/src/content/reference/en/p5 copy/noFill.mdx new file mode 100644 index 0000000000..67a3979778 --- /dev/null +++ b/src/content/reference/en/p5 copy/noFill.mdx @@ -0,0 +1,73 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1257 +title: noFill +module: Color +submodule: Setting +file: src/color/setting.js +description: > +

Disables setting the fill color for shapes.

+ +

Calling noFill() is the same as making the fill completely + transparent, + + as in fill(0, 0). If both noStroke() and + + noFill() are called, nothing will be drawn to the screen.

+line: 1257 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw the top square. + square(32, 10, 35); + + // Draw the bottom square. + noFill(); + square(32, 55, 35); + + describe('A white square on above an empty square. Both squares have black outlines.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A purple cube wireframe spinning on a black canvas.'); + } + + function draw() { + background(0); + + // Style the box. + noFill(); + stroke(100, 100, 240); + + // Rotate the coordinates. + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + + // Draw the box. + box(45); + } + +
+class: p5 +chainable: true +--- + + +# noFill diff --git a/src/content/reference/en/p5 copy/noLights.mdx b/src/content/reference/en/p5 copy/noLights.mdx new file mode 100644 index 0000000000..1f85888bf6 --- /dev/null +++ b/src/content/reference/en/p5 copy/noLights.mdx @@ -0,0 +1,79 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L1687 +title: noLights +module: 3D +submodule: Lights +file: src/webgl/light.js +description: > +

Removes all lights from the sketch.

+ +

Calling noLights() removes any lights created with + + lights(), + + ambientLight(), + + directionalLight(), + + pointLight(), or + + spotLight(). These functions may be + called + + after noLights() to create a new lighting scheme.

+line: 1687 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('Two spheres drawn against a gray background. The top sphere is white and the bottom sphere is red.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the spheres. + noStroke(); + + // Draw the top sphere. + push(); + translate(0, -25, 0); + sphere(20); + pop(); + + // Turn off the lights. + noLights(); + + // Add a red directional light that points into the screen. + directionalLight(255, 0, 0, 0, 0, -1); + + // Draw the bottom sphere. + push(); + translate(0, 25, 0); + sphere(20); + pop(); + } + +
+class: p5 +chainable: true +--- + + +# noLights diff --git a/src/content/reference/en/p5 copy/noLoop.mdx b/src/content/reference/en/p5 copy/noLoop.mdx new file mode 100644 index 0000000000..fe1897a8cb --- /dev/null +++ b/src/content/reference/en/p5 copy/noLoop.mdx @@ -0,0 +1,139 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L9 +title: noLoop +module: Structure +submodule: Structure +file: src/core/structure.js +description: > +

Stops the code in draw() from running + repeatedly.

+ +

By default, draw() tries to run 60 times + per + + second. Calling noLoop() stops draw() from + + repeating. The draw loop can be restarted by calling + + loop(). draw() can be run + + once by calling redraw().

+ +

The isLooping() function can be used + to check + + whether a sketch is looping, as in isLooping() === true.

+line: 9 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Turn off the draw loop. + noLoop(); + + describe('A white half-circle on the left edge of a gray square.'); + } + + function draw() { + background(200); + + // Calculate the circle's x-coordinate. + let x = frameCount; + + // Draw the circle. + // Normally, the circle would move from left to right. + circle(x, 50, 20); + } + +
+ +
+ + // Double-click to stop the draw loop. + + function setup() { + createCanvas(100, 100); + + // Slow the frame rate. + frameRate(5); + + describe('A white circle moves randomly on a gray background. It stops moving when the user double-clicks.'); + } + + function draw() { + background(200); + + // Calculate the circle's coordinates. + let x = random(0, 100); + let y = random(0, 100); + + // Draw the circle. + // Normally, the circle would move from left to right. + circle(x, y, 20); + } + + // Stop the draw loop when the user double-clicks. + function doubleClicked() { + noLoop(); + } + +
+ +
+ + let startButton; + let stopButton; + + function setup() { + createCanvas(100, 100); + + // Create the button elements and place them + // beneath the canvas. + startButton = createButton('▶'); + startButton.position(0, 100); + startButton.size(50, 20); + stopButton = createButton('◾'); + stopButton.position(50, 100); + stopButton.size(50, 20); + + // Set functions to call when the buttons are pressed. + startButton.mousePressed(loop); + stopButton.mousePressed(noLoop); + + // Slow the frame rate. + frameRate(5); + + describe( + 'A white circle moves randomly on a gray background. Play and stop buttons are shown beneath the canvas. The circle stops or starts moving when the user presses a button.' + ); + } + + function draw() { + background(200); + + // Calculate the circle's coordinates. + let x = random(0, 100); + let y = random(0, 100); + + // Draw the circle. + // Normally, the circle would move from left to right. + circle(x, y, 20); + } + +
+class: p5 +chainable: false +--- + + +# noLoop diff --git a/src/content/reference/en/p5 copy/noSmooth.mdx b/src/content/reference/en/p5 copy/noSmooth.mdx new file mode 100644 index 0000000000..a1af76d10d --- /dev/null +++ b/src/content/reference/en/p5 copy/noSmooth.mdx @@ -0,0 +1,92 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L100 +title: noSmooth +module: Shape +submodule: Attributes +file: src/core/shape/attributes.js +description: > +

Draws certain features with jagged (aliased) edges.

+ +

smooth() is active by default. In 2D + mode, + + noSmooth() is helpful for scaling up images without blurring. The + + functions don't affect shapes or fonts.

+ +

In WebGL mode, noSmooth() causes all shapes to be drawn with + jagged + + (aliased) edges. The functions don't affect images or fonts.

+line: 100 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let heart; + + // Load a pixelated heart image from an image data string. + function preload() { + heart = loadImage('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAAXNSR0IArs4c6QAAAEZJREFUGFd9jcsNACAIQ9tB2MeR3YdBMBBq8CIXPi2vBICIiOwkOedatllqWO6Y8yOWoyuNf1GZwgmf+RRG2YXr+xVFmA8HZ9Mx/KGPMtcAAAAASUVORK5CYII='); + } + + function setup() { + createCanvas(100, 100); + + background(50); + + // Antialiased hearts. + image(heart, 10, 10); + image(heart, 20, 10, 16, 16); + image(heart, 40, 10, 32, 32); + + // Aliased hearts. + noSmooth(); + image(heart, 10, 60); + image(heart, 20, 60, 16, 16); + image(heart, 40, 60, 32, 32); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + circle(0, 0, 80); + + describe('A white circle on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + // Disable smoothing. + noSmooth(); + + background(200); + + circle(0, 0, 80); + + describe('A pixelated white circle on a gray background.'); + } + +
+class: p5 +chainable: true +--- + + +# noSmooth diff --git a/src/content/reference/en/p5 copy/noStroke.mdx b/src/content/reference/en/p5 copy/noStroke.mdx new file mode 100644 index 0000000000..7c4fe80960 --- /dev/null +++ b/src/content/reference/en/p5 copy/noStroke.mdx @@ -0,0 +1,71 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1317 +title: noStroke +module: Color +submodule: Setting +file: src/color/setting.js +description: > +

Disables drawing points, lines, and the outlines of shapes.

+ +

Calling noStroke() is the same as making the stroke completely + transparent, + + as in stroke(0, 0). If both noStroke() and + + noFill() are called, nothing will be drawn + to the + + screen.

+line: 1317 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + noStroke(); + square(20, 20, 60); + + describe('A white square with no outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A pink cube with no edge outlines spinning on a black canvas.'); + } + + function draw() { + background(0); + + // Style the box. + noStroke(); + fill(240, 150, 150); + + // Rotate the coordinates. + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + + // Draw the box. + box(45); + } + +
+class: p5 +chainable: true +--- + + +# noStroke diff --git a/src/content/reference/en/p5 copy/noTint.mdx b/src/content/reference/en/p5 copy/noTint.mdx new file mode 100644 index 0000000000..e3b0aeea19 --- /dev/null +++ b/src/content/reference/en/p5 copy/noTint.mdx @@ -0,0 +1,51 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L1345 +title: noTint +module: Image +submodule: Loading & Displaying +file: src/image/loading_displaying.js +description: > +

Removes the current tint set by tint().

+ +

noTint() restores images to their original colors.

+line: 1345 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Left. + // Tint with a CSS color string. + tint('red'); + image(img, 0, 0); + + // Right. + // Remove the tint. + noTint(); + image(img, 50, 0); + + describe('Two images of an umbrella and a ceiling side-by-side. The image on the left has a red tint.'); + } + +
+class: p5 +chainable: false +--- + + +# noTint diff --git a/src/content/reference/en/p5 copy/noise.mdx b/src/content/reference/en/p5 copy/noise.mdx new file mode 100644 index 0000000000..1b67f49cb9 --- /dev/null +++ b/src/content/reference/en/p5 copy/noise.mdx @@ -0,0 +1,282 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/noise.js#L36 +title: noise +module: Math +submodule: Noise +file: src/math/noise.js +description: > +

Returns random numbers that can be tuned to feel organic.

+ +

Values returned by random() and + + randomGaussian() can change by + large + + amounts between function calls. By contrast, values returned by + noise() + + can be made "smooth". Calls to noise() with similar inputs will + produce + + similar outputs. noise() is used to create textures, motion, + shapes, + + terrains, and so on. Ken Perlin invented noise() while animating + the + + original Tron film in the 1980s.

+ +

noise() always returns values between 0 and 1. It returns the + same value + + for a given input while a sketch is running. noise() produces + different + + results each time a sketch runs. The + + noiseSeed() function can be used to + generate + + the same sequence of Perlin noise values each time a sketch runs.

+ +

The character of the noise can be adjusted in two ways. The first way is to + + scale the inputs. noise() interprets inputs as coordinates. The + sequence + + of noise values will be smoother when the input coordinates are closer. The + + second way is to use the noiseDetail() + + function.

+ +

The version of noise() with one parameter computes noise + values in one + + dimension. This dimension can be thought of as space, as in + noise(x), or + + time, as in noise(t).

+ +

The version of noise() with two parameters computes noise + values in two + + dimensions. These dimensions can be thought of as space, as in + + noise(x, y), or space and time, as in noise(x, + t).

+ +

The version of noise() with three parameters computes noise + values in + + three dimensions. These dimensions can be thought of as space, as in + + noise(x, y, z), or space and time, as in noise(x, y, + t).

+line: 36 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A black dot moves randomly on a gray square.'); + } + + function draw() { + background(200); + + // Calculate the coordinates. + let x = 100 * noise(0.005 * frameCount); + let y = 100 * noise(0.005 * frameCount + 10000); + + // Draw the point. + strokeWeight(5); + point(x, y); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A black dot moves randomly on a gray square.'); + } + + function draw() { + background(200); + + // Set the noise level and scale. + let noiseLevel = 100; + let noiseScale = 0.005; + + // Scale the input coordinate. + let nt = noiseScale * frameCount; + + // Compute the noise values. + let x = noiseLevel * noise(nt); + let y = noiseLevel * noise(nt + 10000); + + // Draw the point. + strokeWeight(5); + point(x, y); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A hilly terrain drawn in gray against a black sky.'); + } + + function draw() { + // Set the noise level and scale. + let noiseLevel = 100; + let noiseScale = 0.02; + + // Scale the input coordinate. + let x = frameCount; + let nx = noiseScale * x; + + // Compute the noise value. + let y = noiseLevel * noise(nx); + + // Draw the line. + line(x, 0, x, y); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A calm sea drawn in gray against a black sky.'); + } + + function draw() { + background(200); + + // Set the noise level and scale. + let noiseLevel = 100; + let noiseScale = 0.002; + + // Iterate from left to right. + for (let x = 0; x < width; x += 1) { + // Scale the input coordinates. + let nx = noiseScale * x; + let nt = noiseScale * frameCount; + + // Compute the noise value. + let y = noiseLevel * noise(nx, nt); + + // Draw the line. + line(x, 0, x, y); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Set the noise level and scale. + let noiseLevel = 255; + let noiseScale = 0.01; + + // Iterate from top to bottom. + for (let y = 0; y < height; y += 1) { + // Iterate from left to right. + for (let x = 0; x < width; x += 1) { + // Scale the input coordinates. + let nx = noiseScale * x; + let ny = noiseScale * y; + + // Compute the noise value. + let c = noiseLevel * noise(nx, ny); + + // Draw the point. + stroke(c); + point(x, y); + } + } + + describe('A gray cloudy pattern.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A gray cloudy pattern that changes.'); + } + + function draw() { + // Set the noise level and scale. + let noiseLevel = 255; + let noiseScale = 0.009; + + // Iterate from top to bottom. + for (let y = 0; y < height; y += 1) { + // Iterate from left to right. + for (let x = 0; x < width; x += 1) { + // Scale the input coordinates. + let nx = noiseScale * x; + let ny = noiseScale * y; + let nt = noiseScale * frameCount; + + // Compute the noise value. + let c = noiseLevel * noise(nx, ny, nt); + + // Draw the point. + stroke(c); + point(x, y); + } + } + } + +
+class: p5 +params: + - name: x + description: | +

x-coordinate in noise space.

+ type: Number + - name: 'y' + description: | +

y-coordinate in noise space.

+ type: Number + optional: true + - name: z + description: | +

z-coordinate in noise space.

+ type: Number + optional: true +return: + description: Perlin noise value at specified coordinates. + type: Number +chainable: false +--- + + +# noise diff --git a/src/content/reference/en/p5 copy/noiseDetail.mdx b/src/content/reference/en/p5 copy/noiseDetail.mdx new file mode 100644 index 0000000000..973ac515ab --- /dev/null +++ b/src/content/reference/en/p5 copy/noiseDetail.mdx @@ -0,0 +1,100 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/noise.js#L331 +title: noiseDetail +module: Math +submodule: Noise +file: src/math/noise.js +description: > +

Adjusts the character of the noise produced by the + + noise() function.

+ +

Perlin noise values are created by adding layers of noise together. The + + noise layers, called octaves, are similar to harmonics in music. Lower + + octaves contribute more to the output signal. They define the overall + + intensity of the noise. Higher octaves create finer-grained details.

+ +

By default, noise values are created by combining four octaves. Each higher + + octave contributes half as much (50% less) compared to its predecessor. + + noiseDetail() changes the number of octaves and the falloff + amount. For + + example, calling noiseDetail(6, 0.25) ensures that + + noise() will use six octaves. Each higher + octave + + will contribute 25% as much (75% less) compared to its predecessor. Falloff + + values between 0 and 1 are valid. However, falloff values greater than 0.5 + + might result in noise values greater than 1.

+line: 331 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Set the noise level and scale. + let noiseLevel = 255; + let noiseScale = 0.02; + + // Iterate from top to bottom. + for (let y = 0; y < height; y += 1) { + // Iterate from left to right. + for (let x = 0; x < width / 2; x += 1) { + // Scale the input coordinates. + let nx = noiseScale * x; + let ny = noiseScale * y; + + // Compute the noise value with six octaves + // and a low falloff factor. + noiseDetail(6, 0.25); + let c = noiseLevel * noise(nx, ny); + + // Draw the left side. + stroke(c); + point(x, y); + + // Compute the noise value with four octaves + // and a high falloff factor. + noiseDetail(4, 0.5); + c = noiseLevel * noise(nx, ny); + + // Draw the right side. + stroke(c); + point(x + 50, y); + } + } + + describe('Two gray cloudy patterns. The pattern on the right is cloudier than the pattern on the left.'); + } + +
+class: p5 +params: + - name: lod + description: | +

number of octaves to be used by the noise.

+ type: Number + - name: falloff + description: | +

falloff factor for each octave.

+ type: Number +chainable: false +--- + + +# noiseDetail diff --git a/src/content/reference/en/p5 copy/noiseSeed.mdx b/src/content/reference/en/p5 copy/noiseSeed.mdx new file mode 100644 index 0000000000..a1f2ce6fbd --- /dev/null +++ b/src/content/reference/en/p5 copy/noiseSeed.mdx @@ -0,0 +1,68 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/noise.js#L405 +title: noiseSeed +module: Math +submodule: Noise +file: src/math/noise.js +description: > +

Sets the seed value for the noise() + function.

+ +

By default, noise() produces different + results + + each time a sketch is run. Calling noiseSeed() with a constant + argument, + + such as noiseSeed(99), makes noise() produce the + + same results each time a sketch is run.

+line: 405 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Set the noise seed for consistent results. + noiseSeed(99); + + describe('A black rectangle that grows randomly, first to the right and then to the left.'); + } + + function draw() { + // Set the noise level and scale. + let noiseLevel = 100; + let noiseScale = 0.005; + + // Scale the input coordinate. + let nt = noiseScale * frameCount; + + // Compute the noise value. + let x = noiseLevel * noise(nt); + + // Draw the line. + line(x, 0, x, height); + } + +
+class: p5 +params: + - name: seed + description: | +

seed value.

+ type: Number +chainable: false +--- + + +# noiseSeed diff --git a/src/content/reference/en/p5 copy/norm.mdx b/src/content/reference/en/p5 copy/norm.mdx new file mode 100644 index 0000000000..d52a73e4c5 --- /dev/null +++ b/src/content/reference/en/p5 copy/norm.mdx @@ -0,0 +1,69 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L772 +title: norm +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Maps a number from one range to a value between 0 and 1.

+ +

For example, norm(2, 0, 10) returns 0.2. 2's position in the + original + + range [0, 10] is proportional to 0.2's position in the range [0, 1]. This + + is the same as calling map(2, 0, 10, 0, 1).

+ +

Numbers outside of the original range are not constrained between 0 and 1. + + Out-of-range values are often intentional and useful.

+line: 772 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Use RGB color with values from 0 to 1. + colorMode(RGB, 1); + + describe('A square changes color from black to red as the mouse moves from left to right.'); + } + + function draw() { + // Calculate the redValue. + let redValue = norm(mouseX, 0, 100); + + // Paint the background. + background(redValue, 0, 0); + } + +
+class: p5 +params: + - name: value + description: | +

incoming value to be normalized.

+ type: Number + - name: start + description: | +

lower bound of the value's current range.

+ type: Number + - name: stop + description: | +

upper bound of the value's current range.

+ type: Number +return: + description: normalized number. + type: Number +chainable: false +--- + + +# norm diff --git a/src/content/reference/en/p5 copy/normal.mdx b/src/content/reference/en/p5 copy/normal.mdx new file mode 100644 index 0000000000..a109745b80 --- /dev/null +++ b/src/content/reference/en/p5 copy/normal.mdx @@ -0,0 +1,250 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L2097 +title: normal +module: Shape +submodule: Vertex +file: src/core/shape/vertex.js +description: > +

Sets the normal vector for vertices in a custom 3D shape.

+ +

3D shapes created with beginShape() + and + + endShape() are made by connecting sets + of + + points called vertices. Each vertex added with + + vertex() has a normal vector that points + away + + from it. The normal vector controls how light reflects off the shape.

+ +

normal() can be called two ways with different parameters to + define the + + normal vector's components.

+ +

The first way to call normal() has three parameters, + x, y, and z. + + If Numbers are passed, as in normal(1, 2, 3), they + set the x-, y-, and + + z-components of the normal vector.

+ +

The second way to call normal() has one parameter, + vector. If a + + p5.Vector object is passed, as in + + normal(myVector), its components will be used to set the normal + vector.

+ +

normal() changes the normal vector of vertices added to a + custom shape + + with vertex(). normal() must + be called between + + the beginShape() and + + endShape() functions, just like + + vertex(). The normal vector set by calling + + normal() will affect all following vertices until + normal() is called + + again:

+ +
beginShape();
+
+
+  // Set the vertex normal.
+
+  normal(-0.4, -0.4, 0.8);
+
+
+  // Add a vertex.
+
+  vertex(-30, -30, 0);
+
+
+  // Set the vertex normal.
+
+  normal(0, 0, 1);
+
+
+  // Add vertices.
+
+  vertex(30, -30, 0);
+
+  vertex(30, 30, 0);
+
+
+  // Set the vertex normal.
+
+  normal(0.4, -0.4, 0.8);
+
+
+  // Add a vertex.
+
+  vertex(-30, 30, 0);
+
+
+  endShape();
+
+  
+line: 2097 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click the and drag the mouse to view the scene from a different angle. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'A colorful square on a black background. The square changes color and rotates when the user drags the mouse. Parts of its surface reflect light in different directions.' + ); + } + + function draw() { + background(0); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the shape. + normalMaterial(); + noStroke(); + + // Draw the shape. + beginShape(); + vertex(-30, -30, 0); + vertex(30, -30, 0); + vertex(30, 30, 0); + vertex(-30, 30, 0); + endShape(); + } + +
+ +
+ + // Click the and drag the mouse to view the scene from a different angle. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'A colorful square on a black background. The square changes color and rotates when the user drags the mouse. Parts of its surface reflect light in different directions.' + ); + } + + function draw() { + background(0); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the shape. + normalMaterial(); + noStroke(); + + // Draw the shape. + // Use normal() to set vertex normals. + beginShape(); + normal(-0.4, -0.4, 0.8); + vertex(-30, -30, 0); + + normal(0, 0, 1); + vertex(30, -30, 0); + vertex(30, 30, 0); + + normal(0.4, -0.4, 0.8); + vertex(-30, 30, 0); + endShape(); + } + +
+ +
+ + // Click the and drag the mouse to view the scene from a different angle. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'A colorful square on a black background. The square changes color and rotates when the user drags the mouse. Parts of its surface reflect light in different directions.' + ); + } + + function draw() { + background(0); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the shape. + normalMaterial(); + noStroke(); + + // Create p5.Vector objects. + let n1 = createVector(-0.4, -0.4, 0.8); + let n2 = createVector(0, 0, 1); + let n3 = createVector(0.4, -0.4, 0.8); + + // Draw the shape. + // Use normal() to set vertex normals. + beginShape(); + normal(n1); + vertex(-30, -30, 0); + + normal(n2); + vertex(30, -30, 0); + vertex(30, 30, 0); + + normal(n3); + vertex(-30, 30, 0); + endShape(); + } + +
+class: p5 +overloads: + - line: 2097 + params: + - name: vector + description: | +

vertex normal as a p5.Vector object.

+ type: p5.Vector + chainable: 1 + - line: 2272 + params: + - name: x + description: | +

x-component of the vertex normal.

+ type: Number + - name: 'y' + description: | +

y-component of the vertex normal.

+ type: Number + - name: z + description: | +

z-component of the vertex normal.

+ type: Number + chainable: 1 +chainable: true +--- + + +# normal diff --git a/src/content/reference/en/p5 copy/normalMaterial.mdx b/src/content/reference/en/p5 copy/normalMaterial.mdx new file mode 100644 index 0000000000..0652b349d4 --- /dev/null +++ b/src/content/reference/en/p5 copy/normalMaterial.mdx @@ -0,0 +1,55 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2365 +title: normalMaterial +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Sets the current material as a normal material.

+ +

A normal material sets surfaces facing the x-axis to red, those facing the + + y-axis to green, and those facing the z-axis to blue. Normal material isn't + + affected by light. It’s often used as a placeholder material when + debugging.

+ +

Note: normalMaterial() can only be used in WebGL mode.

+line: 2365 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A multicolor torus drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the torus. + normalMaterial(); + + // Draw the torus. + torus(30); + } + +
+class: p5 +chainable: true +--- + + +# normalMaterial diff --git a/src/content/reference/en/p5 copy/orbitControl.mdx b/src/content/reference/en/p5 copy/orbitControl.mdx new file mode 100644 index 0000000000..be2fd25452 --- /dev/null +++ b/src/content/reference/en/p5 copy/orbitControl.mdx @@ -0,0 +1,203 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/interaction.js#L11 +title: orbitControl +module: 3D +submodule: Interaction +file: src/webgl/interaction.js +description: > +

Allows the user to orbit around a 3D sketch using a mouse, trackpad, or + + touchscreen.

+ +

3D sketches are viewed through an imaginary camera. Calling + + orbitControl() within the draw() function allows + + the user to change the camera’s position:

+ +
function draw() {
+    background(200);
+
+    // Enable orbiting with the mouse.
+    orbitControl();
+
+    // Rest of sketch.
+  }
+
+  
+ +

Left-clicking and dragging or swipe motion will rotate the camera position + + about the center of the sketch. Right-clicking and dragging or multi-swipe + + will pan the camera position without rotation. Using the mouse wheel + + (scrolling) or pinch in/out will move the camera further or closer from the + + center of the sketch.

+ +

The first three parameters, sensitivityX, + sensitivityY, and + + sensitivityZ, are optional. They’re numbers that set the sketch’s + + sensitivity to movement along each axis. For example, calling + + orbitControl(1, 2, -1) keeps movement along the x-axis at its + default + + value, makes the sketch twice as sensitive to movement along the y-axis, + + and reverses motion along the z-axis. By default, all sensitivity values + + are 1.

+ +

The fourth parameter, options, is also optional. It’s an + object that + + changes the behavior of orbiting. For example, calling + + orbitControl(1, 1, 1, options) keeps the default sensitivity + values while + + changing the behaviors set with options. The object can have the + + following properties:

+ +
let options = {
+    // Setting this to false makes mobile interactions smoother by
+    // preventing accidental interactions with the page while orbiting.
+    // By default, it's true.
+    disableTouchActions: true,
+
+    // Setting this to true makes the camera always rotate in the
+    // direction the mouse/touch is moving.
+    // By default, it's false.
+    freeRotation: false
+  };
+
+
+  orbitControl(1, 1, 1, options);
+
+  
+line: 11 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A multicolor box on a gray background. The camera angle changes when the user interacts using a mouse, trackpad, or touchscreen.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the box. + normalMaterial(); + + // Draw the box. + box(30, 50); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A multicolor box on a gray background. The camera angle changes when the user interacts using a mouse, trackpad, or touchscreen.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + // Make the interactions 3X sensitive. + orbitControl(3, 3, 3); + + // Style the box. + normalMaterial(); + + // Draw the box. + box(30, 50); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A multicolor box on a gray background. The camera angle changes when the user interacts using a mouse, trackpad, or touchscreen.'); + } + + function draw() { + background(200); + + // Create an options object. + let options = { + disableTouchActions: false, + freeRotation: true + }; + + // Enable orbiting with the mouse. + // Prevent accidental touch actions on touchscreen devices + // and enable free rotation. + orbitControl(1, 1, 1, options); + + // Style the box. + normalMaterial(); + + // Draw the box. + box(30, 50); + } + +
+class: p5 +params: + - name: sensitivityX + description: | +

sensitivity to movement along the x-axis. Defaults to 1.

+ type: Number + optional: true + - name: sensitivityY + description: | +

sensitivity to movement along the y-axis. Defaults to 1.

+ type: Number + optional: true + - name: sensitivityZ + description: | +

sensitivity to movement along the z-axis. Defaults to 1.

+ type: Number + optional: true + - name: options + description: | +

object with two optional properties, disableTouchActions + and freeRotation. Both are Booleans. disableTouchActions + defaults to true and freeRotation defaults to false.

+ type: Object + optional: true +chainable: true +--- + + +# orbitControl diff --git a/src/content/reference/en/p5 copy/ortho.mdx b/src/content/reference/en/p5 copy/ortho.mdx new file mode 100644 index 0000000000..5fb384ba48 --- /dev/null +++ b/src/content/reference/en/p5 copy/ortho.mdx @@ -0,0 +1,168 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L412 +title: ortho +module: 3D +submodule: Camera +file: src/webgl/p5.Camera.js +description: > +

Sets an orthographic projection for the current camera in a 3D sketch.

+ +

In an orthographic projection, shapes with the same size always appear the + + same size, regardless of whether they are near or far from the camera.

+ +

ortho() changes the camera’s perspective by changing its + viewing frustum + + from a truncated pyramid to a rectangular prism. The camera is placed in + + front of the frustum and views everything between the frustum’s near plane + + and its far plane. ortho() has six optional parameters to define + the + + frustum.

+ +

The first four parameters, left, right, + bottom, and top, set the + + coordinates of the frustum’s sides, bottom, and top. For example, calling + + ortho(-100, 100, 200, -200) creates a frustum that’s 200 pixels + wide and + + 400 pixels tall. By default, these coordinates are set based on the + + sketch’s width and height, as in + + ortho(-width / 2, width / 2, -height / 2, height / 2).

+ +

The last two parameters, near and far, set the + distance of the + + frustum’s near and far plane from the camera. For example, calling + + ortho(-100, 100, 200, 200, 50, 1000) creates a frustum that’s 200 + pixels + + wide, 400 pixels tall, starts 50 pixels from the camera, and ends 1,000 + + pixels from the camera. By default, near and far are + set to 0 and + + max(width, height) + 800, respectively.

+ +

Note: ortho() can only be used in WebGL mode.

+line: 412 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A row of tiny, white cubes on a gray background. All the cubes appear the same size.'); + } + + function draw() { + background(200); + + // Apply an orthographic projection. + ortho(); + + // Translate the origin toward the camera. + translate(-10, 10, 600); + + // Rotate the coordinate system. + rotateY(-0.1); + rotateX(-0.1); + + // Draw the row of boxes. + for (let i = 0; i < 6; i += 1) { + translate(0, 0, -40); + box(10); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Apply an orthographic projection. + // Center the frustum. + // Set its width and height to 20. + // Place its near plane 300 pixels from the camera. + // Place its far plane 350 pixels from the camera. + ortho(-10, 10, -10, 10, 300, 350); + + // Translate the origin toward the camera. + translate(-10, 10, 600); + + // Rotate the coordinate system. + rotateY(-0.1); + rotateX(-0.1); + + // Draw the row of boxes. + for (let i = 0; i < 6; i += 1) { + translate(0, 0, -40); + box(10); + } + } + +
+class: p5 +params: + - name: left + description: > +

x-coordinate of the frustum’s left plane. Defaults to -width / + 2.

+ type: Number + optional: true + - name: right + description: > +

x-coordinate of the frustum’s right plane. Defaults to width / + 2.

+ type: Number + optional: true + - name: bottom + description: > +

y-coordinate of the frustum’s bottom plane. Defaults to height / + 2.

+ type: Number + optional: true + - name: top + description: > +

y-coordinate of the frustum’s top plane. Defaults to -height / + 2.

+ type: Number + optional: true + - name: near + description: | +

z-coordinate of the frustum’s near plane. Defaults to 0.

+ type: Number + optional: true + - name: far + description: > +

z-coordinate of the frustum’s far plane. Defaults to max(width, + height) + 800.

+ type: Number + optional: true +chainable: true +--- + + +# ortho diff --git a/src/content/reference/en/p5 copy/outputVolume.mdx b/src/content/reference/en/p5 copy/outputVolume.mdx new file mode 100644 index 0000000000..fe618922fb --- /dev/null +++ b/src/content/reference/en/p5 copy/outputVolume.mdx @@ -0,0 +1,51 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L738 +title: outputVolume +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: |- +

Scale the output of all sound in this sketch

+ Scaled between 0.0 (silence) and 1.0 (full volume). + 1.0 is the maximum amplitude of a digital sound, so multiplying + by greater than 1.0 may cause digital distortion. To + fade, provide a rampTime parameter. For more + complex fades, see the Envelope class. + +

Alternately, you can pass in a signal source such as an + oscillator to modulate the amplitude with an audio signal.

+

How This Works: When you load the p5.sound module, it + creates a single instance of p5sound. All sound objects in this + module output to p5sound before reaching your computer's output. + So if you change the amplitude of p5sound, it impacts all of the + sound in this module.

+ +

If no value is provided, returns a Web Audio API Gain Node

+line: 738 +isConstructor: false +itemtype: method +class: p5 +params: + - name: volume + description: | +

Volume (amplitude) between 0.0 + and 1.0 or modulating signal/oscillator

+ type: Number|Object + - name: rampTime + description: | +

Fade for t seconds

+ type: Number + optional: true + - name: timeFromNow + description: | +

Schedule this event to happen at + t seconds in the future

+ type: Number + optional: true +chainable: false +--- + + +# outputVolume diff --git a/src/content/reference/en/p5 copy/p5.Camera.mdx b/src/content/reference/en/p5 copy/p5.Camera.mdx new file mode 100644 index 0000000000..cc2090e329 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Camera.mdx @@ -0,0 +1,659 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L723 +title: p5.Camera +module: 3D +submodule: Camera +file: src/webgl/p5.Camera.js +description: > +

A class to describe a camera for viewing a 3D sketch.

+ +

Each p5.Camera object represents a camera that views a section + of 3D + + space. It stores information about the camera’s position, orientation, and + + projection.

+ +

In WebGL mode, the default camera is a p5.Camera object that + can be + + controlled with the camera(), + + perspective(), + + ortho(), and + + frustum() functions. Additional cameras + can be + + created with createCamera() and + activated + + with setCamera().

+ +

Note: p5.Camera’s methods operate in two coordinate + systems:

+ +
    + +
  • The “world” coordinate system describes positions in terms of their + + relationship to the origin along the x-, y-, and z-axes. For example, + + calling myCamera.setPosition() places the camera in 3D space + using + + "world" coordinates.
  • + +
  • The "local" coordinate system describes positions from the camera's point + + of view: left-right, up-down, and forward-backward. For example, calling + + myCamera.move() moves the camera along its own axes.
  • + +
+line: 723 +isConstructor: true +params: + - name: rendererGL + description: | +

instance of WebGL renderer

+ type: RendererGL +example: + - |- + +
+ + let cam; + let delta = 0.001; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Camera object. + cam = createCamera(); + + // Place the camera at the top-center. + cam.setPosition(0, -400, 800); + + // Point the camera at the origin. + cam.lookAt(0, 0, 0); + + describe( + 'A white cube on a gray background. The cube goes in and out of view as the camera pans left and right.' + ); + } + + function draw() { + background(200); + + // Turn the camera left and right, called "panning". + cam.pan(delta); + + // Switch directions every 120 frames. + if (frameCount % 120 === 0) { + delta *= -1; + } + + // Draw the box. + box(); + } + +
+ +
+ + // Double-click to toggle between cameras. + + let cam1; + let cam2; + let isDefaultCamera = true; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the first camera. + // Keep its default settings. + cam1 = createCamera(); + + // Create the second camera. + // Place it at the top-left. + // Point it at the origin. + cam2 = createCamera(); + cam2.setPosition(400, -400, 800); + cam2.lookAt(0, 0, 0); + + // Set the current camera to cam1. + setCamera(cam1); + + describe( + 'A white cube on a gray background. The camera toggles between frontal and aerial views when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Draw the box. + box(); + } + + // Toggle the current camera when the user double-clicks. + function doubleClicked() { + if (isDefaultCamera === true) { + setCamera(cam2); + isDefaultCamera = false; + } else { + setCamera(cam1); + isDefaultCamera = true; + } + } + +
+methods: + perspective: + description: > +

Sets a perspective projection for the camera.

+ +

In a perspective projection, shapes that are further from the camera + appear + + smaller than shapes that are near the camera. This technique, called + + foreshortening, creates realistic 3D scenes. It’s applied by default in + new + + p5.Camera objects.

+ +

myCamera.perspective() changes the camera’s perspective by + changing its + + viewing frustum. The frustum is the volume of space that’s visible to the + + camera. The frustum’s shape is a pyramid with its top cut off. The camera + + is placed where the top of the pyramid should be and points towards the + + base of the pyramid. It views everything within the frustum.

+ +

The first parameter, fovy, is the camera’s vertical field + of view. It’s + + an angle that describes how tall or narrow a view the camera has. For + + example, calling myCamera.perspective(0.5) sets the camera’s + vertical + + field of view to 0.5 radians. By default, fovy is calculated + based on the + + sketch’s height and the camera’s default z-coordinate, which is 800. The + + formula for the default fovy is 2 * atan(height / 2 / + 800).

+ +

The second parameter, aspect, is the camera’s aspect + ratio. It’s a number + + that describes the ratio of the top plane’s width to its height. For + + example, calling myCamera.perspective(0.5, 1.5) sets the + camera’s field + + of view to 0.5 radians and aspect ratio to 1.5, which would make shapes + + appear thinner on a square canvas. By default, aspect is set + to + + width / height.

+ +

The third parameter, near, is the distance from the camera + to the near + + plane. For example, calling myCamera.perspective(0.5, 1.5, + 100) sets the + + camera’s field of view to 0.5 radians, its aspect ratio to 1.5, and places + + the near plane 100 pixels from the camera. Any shapes drawn less than 100 + + pixels from the camera won’t be visible. By default, near is + set to + + 0.1 * 800, which is 1/10th the default distance between the + camera and + + the origin.

+ +

The fourth parameter, far, is the distance from the camera + to the far + + plane. For example, calling myCamera.perspective(0.5, 1.5, 100, + 10000) + + sets the camera’s field of view to 0.5 radians, its aspect ratio to 1.5, + + places the near plane 100 pixels from the camera, and places the far plane + + 10,000 pixels from the camera. Any shapes drawn more than 10,000 pixels + + from the camera won’t be visible. By default, far is set to + 10 * 800, + + which is 10 times the default distance between the camera and the + origin.

+ path: p5.Camera/perspective + ortho: + description: > +

Sets an orthographic projection for the camera.

+ +

In an orthographic projection, shapes with the same size always appear + the + + same size, regardless of whether they are near or far from the camera.

+ +

myCamera.ortho() changes the camera’s perspective by + changing its viewing + + frustum from a truncated pyramid to a rectangular prism. The frustum is + the + + volume of space that’s visible to the camera. The camera is placed in + front + + of the frustum and views everything within the frustum. + myCamera.ortho() + + has six optional parameters to define the viewing frustum.

+ +

The first four parameters, left, right, + bottom, and top, set the + + coordinates of the frustum’s sides, bottom, and top. For example, calling + + myCamera.ortho(-100, 100, 200, -200) creates a frustum that’s + 200 pixels + + wide and 400 pixels tall. By default, these dimensions are set based on + + the sketch’s width and height, as in + + myCamera.ortho(-width / 2, width / 2, -height / 2, height / + 2).

+ +

The last two parameters, near and far, set + the distance of the + + frustum’s near and far plane from the camera. For example, calling + + myCamera.ortho(-100, 100, 200, -200, 50, 1000) creates a + frustum that’s + + 200 pixels wide, 400 pixels tall, starts 50 pixels from the camera, and + + ends 1,000 pixels from the camera. By default, near and + far are set to + + 0 and max(width, height) + 800, respectively.

+ path: p5.Camera/ortho + frustum: + description: > +

Sets the camera's frustum.

+ +

In a frustum projection, shapes that are further from the camera appear + + smaller than shapes that are near the camera. This technique, called + + foreshortening, creates realistic 3D scenes.

+ +

myCamera.frustum() changes the camera’s perspective by + changing its + + viewing frustum. The frustum is the volume of space that’s visible to the + + camera. The frustum’s shape is a pyramid with its top cut off. The camera + + is placed where the top of the pyramid should be and points towards the + + base of the pyramid. It views everything within the frustum.

+ +

The first four parameters, left, right, + bottom, and top, set the + + coordinates of the frustum’s sides, bottom, and top. For example, calling + + myCamera.frustum(-100, 100, 200, -200) creates a frustum + that’s 200 + + pixels wide and 400 pixels tall. By default, these coordinates are set + + based on the sketch’s width and height, as in + + myCamera.frustum(-width / 20, width / 20, height / 20, -height / + 20).

+ +

The last two parameters, near and far, set + the distance of the + + frustum’s near and far plane from the camera. For example, calling + + myCamera.frustum(-100, 100, 200, -200, 50, 1000) creates a + frustum that’s + + 200 pixels wide, 400 pixels tall, starts 50 pixels from the camera, and + ends + + 1,000 pixels from the camera. By default, near is set to 0.1 * + 800, which + + is 1/10th the default distance between the camera and the origin. + far is + + set to 10 * 800, which is 10 times the default distance + between the + + camera and the origin.

+ path: p5.Camera/frustum + roll: + description: > +

Rotates the camera in a clockwise/counter-clockwise direction.

+ +

Rolling rotates the camera without changing its orientation. The + rotation + + happens in the camera’s "local" space.

+ +

The parameter, angle, is the angle the camera should + rotate. Passing a + + positive angle, as in myCamera.roll(0.001), rotates the + camera in counter-clockwise direction. + + Passing a negative angle, as in myCamera.roll(-0.001), + rotates the + + camera in clockwise direction.

+ +

Note: Angles are interpreted based on the current + + angleMode().

+ path: p5.Camera/roll + pan: + description: > +

Rotates the camera left and right.

+ +

Panning rotates the camera without changing its position. The rotation + + happens in the camera’s "local" space.

+ +

The parameter, angle, is the angle the camera should + rotate. Passing a + + positive angle, as in myCamera.pan(0.001), rotates the camera + to the + + right. Passing a negative angle, as in myCamera.pan(-0.001), + rotates the + + camera to the left.

+ +

Note: Angles are interpreted based on the current + + angleMode().

+ path: p5.Camera/pan + tilt: + description: > +

Rotates the camera up and down.

+ +

Tilting rotates the camera without changing its position. The rotation + + happens in the camera’s "local" space.

+ +

The parameter, angle, is the angle the camera should + rotate. Passing a + + positive angle, as in myCamera.tilt(0.001), rotates the + camera down. + + Passing a negative angle, as in myCamera.tilt(-0.001), + rotates the camera + + up.

+ +

Note: Angles are interpreted based on the current + + angleMode().

+ path: p5.Camera/tilt + lookAt: + description: > +

Points the camera at a location.

+ +

myCamera.lookAt() changes the camera’s orientation without + changing its + + position.

+ +

The parameters, x, y, and z, are + the coordinates in "world" space + + where the camera should point. For example, calling + + myCamera.lookAt(10, 20, 30) points the camera at the + coordinates + + (10, 20, 30).

+ path: p5.Camera/lookAt + camera: + description: > +

Sets the position and orientation of the camera.

+ +

myCamera.camera() allows objects to be viewed from + different angles. It + + has nine parameters that are all optional.

+ +

The first three parameters, x, y, and + z, are the coordinates of the + + camera’s position in "world" space. For example, calling + + myCamera.camera(0, 0, 0) places the camera at the origin + (0, 0, 0). By + + default, the camera is placed at (0, 0, 800).

+ +

The next three parameters, centerX, centerY, + and centerZ are the + + coordinates of the point where the camera faces in "world" space. For + + example, calling myCamera.camera(0, 0, 0, 10, 20, 30) places + the camera + + at the origin (0, 0, 0) and points it at (10, 20, + 30). By default, the + + camera points at the origin (0, 0, 0).

+ +

The last three parameters, upX, upY, and + upZ are the components of + + the "up" vector in "local" space. The "up" vector orients the camera’s + + y-axis. For example, calling + + myCamera.camera(0, 0, 0, 10, 20, 30, 0, -1, 0) places the + camera at the + + origin (0, 0, 0), points it at (10, 20, 30), and + sets the "up" vector + + to (0, -1, 0) which is like holding it upside-down. By + default, the "up" + + vector is (0, 1, 0).

+ path: p5.Camera/camera + move: + description: > +

Moves the camera along its "local" axes without changing its + orientation.

+ +

The parameters, x, y, and z, are + the distances the camera should + + move. For example, calling myCamera.move(10, 20, 30) moves + the camera 10 + + pixels to the right, 20 pixels down, and 30 pixels backward in its "local" + + space.

+ path: p5.Camera/move + setPosition: + description: > +

Sets the camera’s position in "world" space without changing its + + orientation.

+ +

The parameters, x, y, and z, are + the coordinates where the camera + + should be placed. For example, calling myCamera.setPosition(10, 20, + 30) + + places the camera at coordinates (10, 20, 30) in "world" + space.

+ path: p5.Camera/setPosition + set: + description: > +

Sets the camera’s position, orientation, and projection by copying + another + + camera.

+ +

The parameter, cam, is the p5.Camera object + to copy. For example, calling + + cam2.set(cam1) will set cam2 using + cam1’s configuration.

+ path: p5.Camera/set + slerp: + description: > +

Sets the camera’s position and orientation to values that are + in-between + + those of two other cameras.

+ +

myCamera.slerp() uses spherical linear interpolation to + calculate a + + position and orientation that’s in-between two other cameras. Doing so is + + helpful for transitioning smoothly between two perspectives.

+ +

The first two parameters, cam0 and cam1, are + the p5.Camera objects + + that should be used to set the current camera.

+ +

The third parameter, amt, is the amount to interpolate + between cam0 and + + cam1. 0.0 keeps the camera’s position and orientation equal + to cam0’s, + + 0.5 sets them halfway between cam0’s and cam1’s + , and 1.0 sets the + + position and orientation equal to cam1’s.

+ +

For example, calling myCamera.slerp(cam0, cam1, 0.1) sets + cam’s position + + and orientation very close to cam0’s. Calling + + myCamera.slerp(cam0, cam1, 0.9) sets cam’s position and + orientation very + + close to cam1’s.

+ +

Note: All of the cameras must use the same projection.

+ path: p5.Camera/slerp +properties: + eyeX: + description: | +

The camera’s x-coordinate.

+

By default, the camera’s x-coordinate is set to 0 in "world" space.

+ path: p5.Camera/eyeX + eyeY: + description: | +

The camera’s y-coordinate.

+

By default, the camera’s y-coordinate is set to 0 in "world" space.

+ path: p5.Camera/eyeY + eyeZ: + description: > +

The camera’s z-coordinate.

+ +

By default, the camera’s z-coordinate is set to 800 in "world" + space.

+ path: p5.Camera/eyeZ + centerX: + description: > +

The x-coordinate of the place where the camera looks.

+ +

By default, the camera looks at the origin (0, 0, 0) in + "world" space, so + + myCamera.centerX is 0.

+ path: p5.Camera/centerX + centerY: + description: > +

The y-coordinate of the place where the camera looks.

+ +

By default, the camera looks at the origin (0, 0, 0) in + "world" space, so + + myCamera.centerY is 0.

+ path: p5.Camera/centerY + centerZ: + description: > +

The y-coordinate of the place where the camera looks.

+ +

By default, the camera looks at the origin (0, 0, 0) in + "world" space, so + + myCamera.centerZ is 0.

+ path: p5.Camera/centerZ + upX: + description: > +

The x-component of the camera's "up" vector.

+ +

The camera's "up" vector orients its y-axis. By default, the "up" + vector is + + (0, 1, 0), so its x-component is 0 in "local" space.

+ path: p5.Camera/upX + upY: + description: > +

The y-component of the camera's "up" vector.

+ +

The camera's "up" vector orients its y-axis. By default, the "up" + vector is + + (0, 1, 0), so its y-component is 1 in "local" space.

+ path: p5.Camera/upY + upZ: + description: > +

The z-component of the camera's "up" vector.

+ +

The camera's "up" vector orients its y-axis. By default, the "up" + vector is + + (0, 1, 0), so its z-component is 0 in "local" space.

+ path: p5.Camera/upZ +chainable: false +--- + + +# p5.Camera diff --git a/src/content/reference/en/p5 copy/p5.Color.mdx b/src/content/reference/en/p5 copy/p5.Color.mdx new file mode 100644 index 0000000000..b804e5ee95 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Color.mdx @@ -0,0 +1,116 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/p5.Color.js#L318 +title: p5.Color +module: Color +submodule: Creating & Reading +file: src/color/p5.Color.js +description: > +

A class to describe a color.

+ +

Each p5.Color object stores the color mode + + and level maxes that were active during its construction. These values are + + used to interpret the arguments passed to the object's constructor. They + + also determine output formatting such as when + + saturation() is called.

+ +

Color is stored internally as an array of ideal RGBA values in floating + + point form, normalized from 0 to 1. These values are used to calculate the + + closest screen colors, which are RGBA levels from 0 to 255. Screen colors + + are sent to the renderer.

+ +

When different color representations are calculated, the results are cached + + for performance. These values are normalized, floating-point numbers.

+ +

Note: color() is the recommended way to + create an + + instance of this class.

+line: 318 +isConstructor: true +params: + - name: pInst + description: | +

pointer to p5 instance.

+ type: P5 + optional: true + - name: vals + description: | +

an array containing the color values + for red, green, blue and alpha channel + or CSS color.

+ type: 'Number[]|String' +methods: + toString: + description: > +

Returns the color formatted as a String.

+ +

Calling myColor.toString() can be useful for debugging, as + in + + print(myColor.toString()). It's also helpful for using p5.js + with other + + libraries.

+ +

The parameter, format, is optional. If a format string is + passed, as in + + myColor.toString('#rrggbb'), it will determine how the color + string is + + formatted. By default, color strings are formatted as 'rgba(r, g, b, + a)'.

+ path: p5.Color/toString + setRed: + description: > +

Sets the red component of a color.

+ +

The range depends on the colorMode(). In the + + default RGB mode it's between 0 and 255.

+ path: p5.Color/setRed + setGreen: + description: > +

Sets the green component of a color.

+ +

The range depends on the colorMode(). In the + + default RGB mode it's between 0 and 255.

+ path: p5.Color/setGreen + setBlue: + description: > +

Sets the blue component of a color.

+ +

The range depends on the colorMode(). In the + + default RGB mode it's between 0 and 255.

+ path: p5.Color/setBlue + setAlpha: + description: > +

Sets the alpha (transparency) value of a color.

+ +

The range depends on the + + colorMode(). In the default RGB + mode it's + + between 0 and 255.

+ path: p5.Color/setAlpha +chainable: false +--- + + +# p5.Color diff --git a/src/content/reference/en/p5 copy/p5.Element.mdx b/src/content/reference/en/p5 copy/p5.Element.mdx new file mode 100644 index 0000000000..c07b10ae79 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Element.mdx @@ -0,0 +1,545 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/p5.Element.js#L9 +title: p5.Element +module: DOM +submodule: DOM +file: src/core/p5.Element.js +description: > +

A class to describe an + + HTML element.

+ +

Sketches can use many elements. Common elements include the drawing canvas, + + buttons, sliders, webcam feeds, and so on.

+ +

All elements share the methods of the p5.Element class. + They're created + + with functions such as createCanvas() and + + createButton().

+line: 9 +isConstructor: true +params: + - name: elt + description: | +

wrapped DOM element.

+ type: HTMLElement + - name: pInst + description: | +

pointer to p5 instance.

+ type: P5 + optional: true +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a button element and + // place it beneath the canvas. + let btn = createButton('change'); + btn.position(0, 100); + + // Call randomColor() when + // the button is pressed. + btn.mousePressed(randomColor); + + describe('A gray square with a button that says "change" beneath it. The square changes color when the user presses the button.'); + } + + // Paint the background either + // red, yellow, blue, or green. + function randomColor() { + let c = random(['red', 'yellow', 'blue', 'green']); + background(c); + } + +
+methods: + parent: + description: > +

Attaches the element to a parent element.

+ +

For example, a

element may be used as a box to + + hold two pieces of text, a header and a paragraph. The + +
is the parent element of both the header and + + paragraph.

+ +

The parameter parent can have one of three types. + parent can be a + + string with the parent element's ID, as in + + myElement.parent('container'). It can also be another + + p5.Element object, as in + + myElement.parent(myDiv). Finally, parent can be + an HTMLElement + + object, as in myElement.parent(anotherElement).

+ +

Calling myElement.parent() without an argument returns the + element's + + parent.

+ path: p5.Element/parent + id: + description: > +

Sets the element's ID using a given string.

+ +

Calling myElement.id() without an argument returns its ID + as a string.

+ path: p5.Element/id + class: + description: > +

Adds a + + class attribute + + to the element using a given string.

+ +

Calling myElement.class() without an argument returns a + string with its current classes.

+ path: p5.Element/class + mousePressed: + description: > +

Calls a function when the mouse is pressed over the element.

+ +

Calling myElement.mousePressed(false) disables the + function.

+ +

Note: Some mobile browsers may also trigger this event when the element + + receives a quick tap.

+ path: p5.Element/mousePressed + doubleClicked: + description: > +

Calls a function when the mouse is pressed twice over the element.

+ +

Calling myElement.doubleClicked(false) disables the + function.

+ path: p5.Element/doubleClicked + mouseWheel: + description: > +

Calls a function when the mouse wheel scrolls over the element.

+ +

The callback function, fxn, is passed an + event object. event has + + two numeric properties, deltaY and deltaX. + event.deltaY is + + negative if the mouse wheel rotates away from the user. It's positive if + + the mouse wheel rotates toward the user. event.deltaX is + positive if + + the mouse wheel moves to the right. It's negative if the mouse wheel moves + + to the left.

+ +

Calling myElement.mouseWheel(false) disables the + function.

+ path: p5.Element/mouseWheel + mouseReleased: + description: > +

Calls a function when the mouse is released over the element.

+ +

Calling myElement.mouseReleased(false) disables the + function.

+ +

Note: Some mobile browsers may also trigger this event when the element + + receives a quick tap.

+ path: p5.Element/mouseReleased + mouseClicked: + description: > +

Calls a function when the mouse is pressed and released over the + element.

+ +

Calling myElement.mouseReleased(false) disables the + function.

+ +

Note: Some mobile browsers may also trigger this event when the element + + receives a quick tap.

+ path: p5.Element/mouseClicked + mouseMoved: + description: > +

Calls a function when the mouse moves over the element.

+ +

Calling myElement.mouseMoved(false) disables the + function.

+ path: p5.Element/mouseMoved + mouseOver: + description: > +

Calls a function when the mouse moves onto the element.

+ +

Calling myElement.mouseOver(false) disables the + function.

+ path: p5.Element/mouseOver + mouseOut: + description: > +

Calls a function when the mouse moves off the element.

+ +

Calling myElement.mouseOut(false) disables the + function.

+ path: p5.Element/mouseOut + touchStarted: + description: > +

Calls a function when the element is touched.

+ +

Calling myElement.touchStarted(false) disables the + function.

+ +

Note: Touch functions only work on mobile devices.

+ path: p5.Element/touchStarted + touchMoved: + description: > +

Calls a function when the user touches the element and moves.

+ +

Calling myElement.touchMoved(false) disables the + function.

+ +

Note: Touch functions only work on mobile devices.

+ path: p5.Element/touchMoved + touchEnded: + description: > +

Calls a function when the user stops touching the element.

+ +

Calling myElement.touchMoved(false) disables the + function.

+ +

Note: Touch functions only work on mobile devices.

+ path: p5.Element/touchEnded + dragOver: + description: > +

Calls a function when a file is dragged over the element.

+ +

Calling myElement.dragOver(false) disables the + function.

+ path: p5.Element/dragOver + dragLeave: + description: > +

Calls a function when a file is dragged off the element.

+ +

Calling myElement.dragLeave(false) disables the + function.

+ path: p5.Element/dragLeave + addClass: + description: | +

Adds a class to the element.

+ path: p5.Element/addClass + removeClass: + description: | +

Removes a class from the element.

+ path: p5.Element/removeClass + hasClass: + description: | +

Checks if a class is already applied to element.

+ path: p5.Element/hasClass + toggleClass: + description: | +

Toggles whether a class is applied to the element.

+ path: p5.Element/toggleClass + child: + description: > +

Attaches the element as a child of another element.

+ +

myElement.child() accepts either a string ID, DOM node, or + + p5.Element. For example, + + myElement.child(otherElement). If no argument is provided, an + array of + + children DOM nodes is returned.

+ path: p5.Element/child + center: + description: > +

Centers the element either vertically, horizontally, or both.

+ +

center() will center the element relative to its parent or + according to + + the page's body if the element has no parent.

+ +

If no argument is passed, as in myElement.center() the + element is aligned + + both vertically and horizontally.

+ path: p5.Element/center + html: + description: > +

Sets the inner HTML of the element, replacing any existing HTML.

+ +

The second parameter, append, is optional. If + true is passed, as in + + myElement.html('hi', true), the HTML is appended instead of + replacing + + existing HTML.

+ +

If no arguments are passed, as in myElement.html(), the + element's inner + + HTML is returned.

+ path: p5.Element/html + position: + description: > +

Sets the element's position.

+ +

The first two parameters, x and y, set the + element's position relative + + to the top-left corner of the web page.

+ +

The third parameter, positionType, is optional. It sets + the element's + + positioning + scheme. + + positionType is a string that can be either + 'static', 'fixed', + + 'relative', 'sticky', 'initial', or + 'inherit'.

+ +

If no arguments passed, as in myElement.position(), the + method returns + + the element's position in an object, as in { x: 0, y: 0 + }.

+ path: p5.Element/position + style: + description: > +

Applies a style to the element by adding a + + CSS declaration.

+ +

The first parameter, property, is a string. If the name of + a style + + property is passed, as in myElement.style('color'), the + method returns + + the current value as a string or null if it hasn't been set. + If a + + property:style string is passed, as in + + myElement.style('color:deeppink'), the method sets the style + property + + to value.

+ +

The second parameter, value, is optional. It sets the + property's value. + + value can be a string, as in + + myElement.style('color', 'deeppink'), or a + + p5.Color object, as in + + myElement.style('color', myColor).

+ path: p5.Element/style + attribute: + description: > +

Adds an + + attribute + + to the element.

+ +

This method is useful for advanced tasks. Most commonly-used + attributes, + + such as id, can be set with their dedicated methods. For + example, + + nextButton.id('next') sets an element's id + attribute. Calling + + nextButton.attribute('id', 'next') has the same effect.

+ +

The first parameter, attr, is the attribute's name as a + string. Calling + + myElement.attribute('align') returns the attribute's current + value as a + + string or null if it hasn't been set.

+ +

The second parameter, value, is optional. It's a string + used to set the + + attribute's value. For example, calling + + myElement.attribute('align', 'center') sets the element's + horizontal + + alignment to center.

+ path: p5.Element/attribute + removeAttribute: + description: > +

Removes an attribute from the element.

+ +

The parameter attr is the attribute's name as a string. + For example, + + calling myElement.removeAttribute('align') removes its + align + + attribute if it's been set.

+ path: p5.Element/removeAttribute + value: + description: > +

Returns or sets the element's value.

+ +

Calling myElement.value() returns the element's current + value.

+ +

The parameter, value, is an optional number or string. If + provided, + + as in myElement.value(123), it's used to set the element's + value.

+ path: p5.Element/value + show: + description: | +

Shows the current element.

+ path: p5.Element/show + hide: + description: | +

Hides the current element.

+ path: p5.Element/hide + size: + description: > +

Sets the element's width and height.

+ +

Calling myElement.size() without an argument returns the + element's size + + as an object with the properties width and + height. For example, + { width: 20, height: 10 }.

+

The first parameter, width, is optional. It's a number + used to set the + + element's width. Calling myElement.size(10)

+ +

The second parameter, 'height, is also optional. It's a number + used to set the element's height. For example, calling + myElement.size(20, 10)` sets the element's width to 20 pixels and + height + + to 10 pixels.

+ +

The constant AUTO can be used to adjust one dimension at a + time while + + maintaining the aspect ratio, which is width / height. For + example, + + consider an element that's 200 pixels wide and 100 pixels tall. Calling + + myElement.size(20, AUTO) sets the width to 20 pixels and + height to 10 + + pixels.

+ +

Note: In the case of elements that need to load data, such as images, + wait + + to call myElement.size() until after the data loads.

+ path: p5.Element/size + remove: + description: | +

Removes the element, stops all audio/video streams, and removes all + callback functions.

+ path: p5.Element/remove + drop: + description: > +

Calls a function when the user drops a file on the element.

+ +

The first parameter, callback, is a function to call once + the file loads. + + The callback function should have one parameter, file, that's + a + + p5.File object. If the user drops + multiple files on + + the element, callback, is called once for each file.

+ +

The second parameter, fxn, is a function to call when the + browser detects + + one or more dropped files. The callback function should have one + + parameter, event, that's a + + DragEvent.

+ path: p5.Element/drop + draggable: + description: > +

Makes the element draggable.

+ +

The parameter, elmnt, is optional. If another + + p5.Element object is passed, as in + + myElement.draggable(otherElement), the other element will + become draggable.

+ path: p5.Element/draggable +properties: + elt: + description: > +

The element's underlying HTMLElement object.

+ +

The + + HTMLElement + + object's properties and methods can be used directly.

+ path: p5.Element/elt + width: + description: | +

A Number property that stores the element's width.

+ path: p5.Element/width + height: + description: | +

A Number property that stores the element's height.

+ path: p5.Element/height +chainable: false +--- + + +# p5.Element diff --git a/src/content/reference/en/p5 copy/p5.File.mdx b/src/content/reference/en/p5 copy/p5.File.mdx new file mode 100644 index 0000000000..78675c7a98 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.File.mdx @@ -0,0 +1,153 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L5482 +title: p5.File +module: DOM +submodule: DOM +file: src/dom/dom.js +description: | +

A class to describe a file.

+

p5.File objects are used by + myElement.drop() and + created by + createFileInput.

+line: 5482 +isConstructor: true +params: + - name: file + description: | +

wrapped file.

+ type: File +example: + - |- + +
+ + // Use the file input to load a + // file and display its info. + + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a file input and place it beneath the canvas. + // Call displayInfo() when the file loads. + let input = createFileInput(displayInfo); + input.position(0, 100); + + describe('A gray square with a file input beneath it. If the user loads a file, its info is written in black.'); + } + + // Display the p5.File's info once it loads. + function displayInfo(file) { + background(200); + + // Display the p5.File's name. + text(file.name, 10, 10, 80, 40); + + // Display the p5.File's type and subtype. + text(`${file.type}/${file.subtype}`, 10, 70); + + // Display the p5.File's size in bytes. + text(file.size, 10, 90); + } + +
+ +
+ + // Use the file input to select an image to + // load and display. + let img; + + function setup() { + createCanvas(100, 100); + + // Create a file input and place it beneath the canvas. + // Call handleImage() when the file image loads. + let input = createFileInput(handleImage); + input.position(0, 100); + + describe('A gray square with a file input beneath it. If the user selects an image file to load, it is displayed on the square.'); + } + + function draw() { + background(200); + + // Draw the image if it's ready. + if (img) { + image(img, 0, 0, width, height); + } + } + + // Use the p5.File's data once it loads. + function handleImage(file) { + // Check the p5.File's type. + if (file.type === 'image') { + // Create an image using using the p5.File's data. + img = createImg(file.data, ''); + + // Hide the image element so it doesn't appear twice. + img.hide(); + } else { + img = null; + } + } + +
+properties: + file: + description: > +

Underlying + + File + + object. All File properties and methods are accessible.

+ path: p5.File/file + type: + description: > +

The file + + MIME type + + as a string.

+ +

For example, 'image' and 'text' are both MIME + types.

+ path: p5.File/type + subtype: + description: > +

The file subtype as a string.

+ +

For example, a file with an 'image' + + MIME type + + may have a subtype such as png or jpeg.

+ path: p5.File/subtype + name: + description: | +

The file name as a string.

+ path: p5.File/name + size: + description: | +

The number of bytes in the file.

+ path: p5.File/size + data: + description: | +

A string containing the file's data.

+

Data can be either image data, text contents, or a parsed object in the + case of JSON and p5.XML objects.

+ path: p5.File/data +chainable: false +--- + + +# p5.File diff --git a/src/content/reference/en/p5 copy/p5.Font.mdx b/src/content/reference/en/p5 copy/p5.Font.mdx new file mode 100644 index 0000000000..615d0406ee --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Font.mdx @@ -0,0 +1,146 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/p5.Font.js#L13 +title: p5.Font +module: Typography +submodule: Loading & Displaying +file: src/typography/p5.Font.js +description: | +

A class to describe fonts.

+line: 13 +isConstructor: true +params: + - name: pInst + description: | +

pointer to p5 instance.

+ type: P5 + optional: true +example: + - |- + +
+ + let font; + + function preload() { + // Creates a p5.Font object. + font = loadFont('/assets/inconsolata.otf'); + } + + function setup() { + createCanvas(100, 100); + + // Style the text. + fill('deeppink'); + textFont(font); + textSize(36); + + // Display the text. + text('p5*js', 10, 50); + + describe('The text "p5*js" written in pink on a gray background.'); + } + +
+methods: + textBounds: + description: > +

Returns the bounding box for a string of text written using the + font.

+ +

The bounding box is the smallest rectangle that can contain a string of + + text. font.textBounds() returns an object with the bounding + box's + + location and size. For example, calling font.textBounds('p5*js', 5, + 20) + + returns an object in the format + + { x: 5.7, y: 12.1 , w: 9.9, h: 28.6 }. The x and + y properties are + + always the coordinates of the bounding box's top-left corner.

+ +

The first parameter, str, is a string of text. The second + and third + + parameters, x and y, are the text's position. By + default, they set the + + coordinates of the bounding box's bottom-left corner. See + + textAlign() for more ways to align + text.

+ +

The fourth parameter, fontSize, is optional. It sets the + font size used to + + determine the bounding box. By default, font.textBounds() + will use the + + current textSize().

+ path: p5.Font/textBounds + textToPoints: + description: > +

Returns an array of points outlining a string of text written using the + + font.

+ +

Each point object in the array has three properties that describe the + + point's location and orientation, called its path angle. For example, + + { x: 10, y: 20, alpha: 450 }.

+ +

The first parameter, str, is a string of text. The second + and third + + parameters, x and y, are the text's position. By + default, they set the + + coordinates of the bounding box's bottom-left corner. See + + textAlign() for more ways to align + text.

+ +

The fourth parameter, fontSize, is optional. It sets the + text's font + + size. By default, font.textToPoints() will use the current + + textSize().

+ +

The fifth parameter, options, is also optional. + font.textToPoints() + + expects an object with the following properties:

+ +

sampleFactor is the ratio of the text's path length to the + number of + + samples. It defaults to 0.1. Higher values produce more points along the + + path and are more precise.

+ +

simplifyThreshold removes collinear points if it's set to + a number other + + than 0. The value represents the threshold angle to use when determining + + whether two edges are collinear.

+ path: p5.Font/textToPoints +properties: + font: + description: | +

The font's underlying + opentype.js + font object.

+ path: p5.Font/font +chainable: false +--- + + +# p5.Font diff --git a/src/content/reference/en/p5 copy/p5.Framebuffer.mdx b/src/content/reference/en/p5 copy/p5.Framebuffer.mdx new file mode 100644 index 0000000000..8100f48199 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Framebuffer.mdx @@ -0,0 +1,443 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Framebuffer.js#L76 +title: p5.Framebuffer +module: Rendering +file: src/webgl/p5.Framebuffer.js +description: > +

A class to describe a high-performance drawing surface for textures.

+ +

Each p5.Framebuffer object provides a dedicated drawing + surface called + + a framebuffer. They're similar to + + p5.Graphics objects but can run much + faster. + + Performance is improved because the framebuffer shares the same WebGL + + context as the canvas used to create it.

+ +

p5.Framebuffer objects have all the drawing features of the + main + + canvas. Drawing instructions meant for the framebuffer must be placed + + between calls to + + myBuffer.begin() and + + myBuffer.end(). The resulting + image + + can be applied as a texture by passing the p5.Framebuffer object + to the + + texture() function, as in + texture(myBuffer). + + It can also be displayed on the main canvas by passing it to the + + image() function, as in + image(myBuffer, 0, 0).

+ +

Note: createFramebuffer() is + the + + recommended way to create an instance of this class.

+line: 76 +isConstructor: true +params: + - name: target + description: | +

sketch instance or + p5.Graphics + object.

+ type: p5.Graphics|p5 + - name: settings + description: | +

configuration options.

+ type: Object + optional: true +methods: + resize: + description: > +

Resizes the framebuffer to a given width and height.

+ +

The parameters, width and height, set the + dimensions of the + + framebuffer. For example, calling myBuffer.resize(300, 500) + resizes + + the framebuffer to 300×500 pixels, then sets myBuffer.width + to 300 + + and myBuffer.height 500.

+ path: p5.Framebuffer/resize + pixelDensity: + description: > +

Sets the framebuffer's pixel density or returns its current + density.

+ +

Computer displays are grids of little lights called pixels. A display's + + pixel density describes how many pixels it packs into an area. Displays + + with smaller pixels have a higher pixel density and create sharper + + images.

+ +

The parameter, density, is optional. If a number is + passed, as in + + myBuffer.pixelDensity(1), it sets the framebuffer's pixel + density. By + + default, the framebuffer's pixel density will match that of the canvas + + where it was created. All canvases default to match the display's pixel + + density.

+ +

Calling myBuffer.pixelDensity() without an argument + returns its current + + pixel density.

+ path: p5.Framebuffer/pixelDensity + autoSized: + description: > +

Toggles the framebuffer's autosizing mode or returns the current + mode.

+ +

By default, the framebuffer automatically resizes to match the canvas + + that created it. Calling myBuffer.autoSized(false) disables + this + + behavior and calling myBuffer.autoSized(true) re-enables + it.

+ +

Calling myBuffer.autoSized() without an argument returns + true if + + the framebuffer automatically resizes and false if not.

+ path: p5.Framebuffer/autoSized + createCamera: + description: > +

Creates a new + + p5.Camera object to use with the + framebuffer.

+ +

The new camera is initialized with a default position (0, 0, + 800) and a + + default perspective projection. Its properties can be controlled with + + p5.Camera methods such as + myCamera.lookAt(0, 0, 0).

+ +

Framebuffer cameras should be created between calls to + + myBuffer.begin() and + + myBuffer.end() like so:

+ +
let myCamera;
+
+
+      myBuffer.begin();
+
+
+      // Create the camera for the framebuffer.
+
+      myCamera = myBuffer.createCamera();
+
+
+      myBuffer.end();
+
+      
+ +

Calling setCamera() updates the + + framebuffer's projection using the camera. + + resetMatrix() must also be called + for the + + view to change properly:

+ +
myBuffer.begin();
+
+
+      // Set the camera for the framebuffer.
+
+      setCamera(myCamera);
+
+
+      // Reset all transformations.
+
+      resetMatrix();
+
+
+      // Draw stuff...
+
+
+      myBuffer.end();
+
+      
+ path: p5.Framebuffer/createCamera + remove: + description: > +

Deletes the framebuffer from GPU memory.

+ +

Calling myBuffer.remove() frees the GPU memory used by the + framebuffer. + + The framebuffer also uses a bit of memory on the CPU which can be freed + + like so:

+ +
// Delete the framebuffer from GPU memory.
+
+      myBuffer.remove();
+
+
+      // Delete the framebuffer from CPU memory.
+
+      myBuffer = undefined;
+
+      
+ +

Note: All variables that reference the framebuffer must be assigned + + the value undefined to delete the framebuffer from CPU + memory. If any + + variable still refers to the framebuffer, then it won't be garbage + + collected.

+ path: p5.Framebuffer/remove + begin: + description: > +

Begins drawing shapes to the framebuffer.

+ +

myBuffer.begin() and myBuffer.end() + + allow shapes to be drawn to the framebuffer. myBuffer.begin() + begins + + drawing to the framebuffer and + + myBuffer.end() stops drawing + to the + + framebuffer. Changes won't be visible until the framebuffer is displayed + + as an image or texture.

+ path: p5.Framebuffer/begin + end: + description: > +

Stops drawing shapes to the framebuffer.

+ +

myBuffer.begin() and + myBuffer.end() + + allow shapes to be drawn to the framebuffer. + + myBuffer.begin() begins + drawing to + + the framebuffer and myBuffer.end() stops drawing to the + framebuffer. + + Changes won't be visible until the framebuffer is displayed as an image + + or texture.

+ path: p5.Framebuffer/end + draw: + description: > +

Draws to the framebuffer by calling a function that contains drawing + + instructions.

+ +

The parameter, callback, is a function with the drawing + instructions + + for the framebuffer. For example, calling + myBuffer.draw(myFunction) + + will call a function named myFunction() to draw to the + framebuffer. + + Doing so has the same effect as the following:

+ +
myBuffer.begin();
+
+      myFunction();
+
+      myBuffer.end();
+
+      
+ path: p5.Framebuffer/draw + loadPixels: + description: > +

Loads the current value of each pixel in the framebuffer into its + + pixels array.

+ +

myBuffer.loadPixels() must be called before reading from + or writing to + + myBuffer.pixels.

+ path: p5.Framebuffer/loadPixels + get: + description: > +

Gets a pixel or a region of pixels from the framebuffer.

+ +

myBuffer.get() is easy to use but it's not as fast as + + myBuffer.pixels. Use + + myBuffer.pixels to read + many pixel + + values.

+ +

The version of myBuffer.get() with no parameters returns + the entire + + framebuffer as a a p5.Image + object.

+ +

The version of myBuffer.get() with two parameters + interprets them as + + coordinates. It returns an array with the [R, G, B, A] values + of the + + pixel at the given point.

+ +

The version of myBuffer.get() with four parameters + interprets them as + + coordinates and dimensions. It returns a subsection of the framebuffer as + + a p5.Image object. The first two + parameters are + + the coordinates for the upper-left corner of the subsection. The last two + + parameters are the width and height of the subsection.

+ path: p5.Framebuffer/get + updatePixels: + description: > +

Updates the framebuffer with the RGBA values in the + + pixels array.

+ +

myBuffer.updatePixels() only needs to be called after + changing values + + in the myBuffer.pixels + array. Such + + changes can be made directly after calling + + myBuffer.loadPixels().

+ path: p5.Framebuffer/updatePixels +properties: + pixels: + description: > +

An array containing the color of each pixel in the framebuffer.

+ +

myBuffer.loadPixels() + must be + + called before accessing the myBuffer.pixels array. + + myBuffer.updatePixels() + + must be called after any changes are made.

+ +

Note: Updating pixels via this property is slower than drawing to the + + framebuffer directly. Consider using a + + p5.Shader object instead of looping + over + + myBuffer.pixels.

+ path: p5.Framebuffer/pixels + color: + description: > +

An object that stores the framebuffer's color data.

+ +

Each framebuffer uses a + + WebGLTexture + + object internally to store its color data. The myBuffer.color + property + + makes it possible to pass this data directly to other functions. For + + example, calling texture(myBuffer.color) or + + myShader.setUniform('colorTexture', myBuffer.color) may be + helpful for + + advanced use cases.

+ +

Note: By default, a framebuffer's y-coordinates are flipped compared to + + images and videos. It's easy to flip a framebuffer's y-coordinates as + + needed when applying it as a texture. For example, calling + + plane(myBuffer.width, -myBuffer.height) will flip the + framebuffer.

+ path: p5.Framebuffer/color + depth: + description: > +

An object that stores the framebuffer's depth data.

+ +

Each framebuffer uses a + + WebGLTexture + + object internally to store its depth data. The myBuffer.depth + property + + makes it possible to pass this data directly to other functions. For + + example, calling texture(myBuffer.depth) or + + myShader.setUniform('depthTexture', myBuffer.depth) may be + helpful for + + advanced use cases.

+ +

Note: By default, a framebuffer's y-coordinates are flipped compared to + + images and videos. It's easy to flip a framebuffer's y-coordinates as + + needed when applying it as a texture. For example, calling + + plane(myBuffer.width, -myBuffer.height) will flip the + framebuffer.

+ path: p5.Framebuffer/depth +chainable: false +--- + + +# p5.Framebuffer diff --git a/src/content/reference/en/p5 copy/p5.Geometry.mdx b/src/content/reference/en/p5 copy/p5.Geometry.mdx new file mode 100644 index 0000000000..0faa7daf7a --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Geometry.mdx @@ -0,0 +1,793 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Geometry.js#L13 +title: p5.Geometry +module: Shape +submodule: 3D Primitives +file: src/webgl/p5.Geometry.js +description: > +

A class to describe a 3D shape.

+ +

Each p5.Geometry object represents a 3D shape as a set of + connected + + points called vertices. All 3D shapes are made by connecting vertices + to + + form triangles that are stitched together. Each triangular patch on the + + geometry's surface is called a face. The geometry stores information + + about its vertices and faces for use with effects such as lighting and + + texture mapping.

+ +

The first parameter, detailX, is optional. If a number is + passed, as in + + new p5.Geometry(24), it sets the number of triangle subdivisions + to use + + along the geometry's x-axis. By default, detailX is 1.

+ +

The second parameter, detailY, is also optional. If a number + is passed, + + as in new p5.Geometry(24, 16), it sets the number of triangle + + subdivisions to use along the geometry's y-axis. By default, + detailX is + + 1.

+ +

The third parameter, callback, is also optional. If a function + is passed, + + as in new p5.Geometry(24, 16, createShape), it will be called + once to add + + vertices to the new 3D shape.

+line: 13 +isConstructor: true +params: + - name: detailX + description: | +

number of vertices along the x-axis.

+ type: Integer + optional: true + - name: detailY + description: | +

number of vertices along the y-axis.

+ type: Integer + optional: true + - name: callback + description: | +

function to call once the geometry is created.

+ type: Function + optional: true +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + let myGeometry; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Geometry object. + myGeometry = new p5.Geometry(); + + // Create p5.Vector objects to position the vertices. + let v0 = createVector(-40, 0, 0); + let v1 = createVector(0, -40, 0); + let v2 = createVector(40, 0, 0); + + // Add the vertices to the p5.Geometry object's vertices array. + myGeometry.vertices.push(v0, v1, v2); + + describe('A white triangle drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the p5.Geometry object. + model(myGeometry); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let myGeometry; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Geometry object using a callback function. + myGeometry = new p5.Geometry(1, 1, createShape); + + describe('A white triangle drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the p5.Geometry object. + model(myGeometry); + } + + function createShape() { + // Create p5.Vector objects to position the vertices. + let v0 = createVector(-40, 0, 0); + let v1 = createVector(0, -40, 0); + let v2 = createVector(40, 0, 0); + + // "this" refers to the p5.Geometry object being created. + + // Add the vertices to the p5.Geometry object's vertices array. + this.vertices.push(v0, v1, v2); + + // Add an array to list which vertices belong to the face. + // Vertices are listed in clockwise "winding" order from + // left to top to right. + this.faces.push([0, 1, 2]); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let myGeometry; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Geometry object using a callback function. + myGeometry = new p5.Geometry(1, 1, createShape); + + describe('A white triangle drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the p5.Geometry object. + model(myGeometry); + } + + function createShape() { + // Create p5.Vector objects to position the vertices. + let v0 = createVector(-40, 0, 0); + let v1 = createVector(0, -40, 0); + let v2 = createVector(40, 0, 0); + + // "this" refers to the p5.Geometry object being created. + + // Add the vertices to the p5.Geometry object's vertices array. + this.vertices.push(v0, v1, v2); + + // Add an array to list which vertices belong to the face. + // Vertices are listed in clockwise "winding" order from + // left to top to right. + this.faces.push([0, 1, 2]); + + // Compute the surface normals to help with lighting. + this.computeNormals(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + // Adapted from Paul Wheeler's wonderful p5.Geometry tutorial. + // https://www.paulwheeler.us/articles/custom-3d-geometry-in-p5js/ + // CC-BY-SA 4.0 + + let myGeometry; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the p5.Geometry object. + // Set detailX to 48 and detailY to 2. + // >>> try changing them. + myGeometry = new p5.Geometry(48, 2, createShape); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the p5.Geometry object. + strokeWeight(0.2); + + // Draw the p5.Geometry object. + model(myGeometry); + } + + function createShape() { + // "this" refers to the p5.Geometry object being created. + + // Define the Möbius strip with a few parameters. + let spread = 0.1; + let radius = 30; + let stripWidth = 15; + let xInterval = 4 * PI / this.detailX; + let yOffset = -stripWidth / 2; + let yInterval = stripWidth / this.detailY; + + for (let j = 0; j <= this.detailY; j += 1) { + // Calculate the "vertical" point along the strip. + let v = yOffset + yInterval * j; + + for (let i = 0; i <= this.detailX; i += 1) { + // Calculate the angle of rotation around the strip. + let u = i * xInterval; + + // Calculate the coordinates of the vertex. + let x = (radius + v * cos(u / 2)) * cos(u) - sin(u / 2) * 2 * spread; + let y = (radius + v * cos(u / 2)) * sin(u); + if (u < TWO_PI) { + y += sin(u) * spread; + } else { + y -= sin(u) * spread; + } + let z = v * sin(u / 2) + sin(u / 4) * 4 * spread; + + // Create a p5.Vector object to position the vertex. + let vert = createVector(x, y, z); + + // Add the vertex to the p5.Geometry object's vertices array. + this.vertices.push(vert); + } + } + + // Compute the faces array. + this.computeFaces(); + + // Compute the surface normals to help with lighting. + this.computeNormals(); + } + +
+methods: + calculateBoundingBox: + description: > +

Calculates the position and size of the smallest box that contains the + geometry.

+ +

A bounding box is the smallest rectangular prism that contains the + entire + + geometry. It's defined by the box's minimum and maximum coordinates along + + each axis, as well as the size (length) and offset (center).

+ +

Calling myGeometry.calculateBoundingBox() returns an + object with four + + properties that describe the bounding box:

+ +
// Get myGeometry's bounding box.
+
+      let bbox = myGeometry.calculateBoundingBox();
+
+
+      // Print the bounding box to the console.
+
+      console.log(bbox);
+
+
+      // {
+
+      //  // The minimum coordinate along each axis.
+
+      //  min: { x: -1, y: -2, z: -3 },
+
+      //
+
+      //  // The maximum coordinate along each axis.
+
+      //  max: { x: 1, y: 2, z: 3},
+
+      //
+
+      //  // The size (length) along each axis.
+
+      //  size: { x: 2, y: 4, z: 6},
+
+      //
+
+      //  // The offset (center) along each axis.
+
+      //  offset: { x: 0, y: 0, z: 0}
+
+      // }
+
+      
+ path: p5.Geometry/calculateBoundingBox + clearColors: + description: > +

Removes the geometry’s internal colors.

+ +

p5.Geometry objects can be created with "internal colors" + assigned to + + vertices or the entire shape. When a geometry has internal colors, + + fill() has no effect. Calling + + myGeometry.clearColors() allows the + + fill() function to apply color to the + geometry.

+ path: p5.Geometry/clearColors + saveObj: + description: > +

The saveObj() function exports p5.Geometry + objects as + + 3D models in the Wavefront .obj file format. + + This way, you can use the 3D shapes you create in p5.js in other software + + for rendering, animation, 3D printing, or more.

+ +

The exported .obj file will include the faces and vertices of the + p5.Geometry, + + as well as its texture coordinates and normals, if it has them.

+ path: p5.Geometry/saveObj + saveStl: + description: > +

The saveStl() function exports p5.Geometry + objects as + + 3D models in the STL stereolithography file format. + + This way, you can use the 3D shapes you create in p5.js in other software + + for rendering, animation, 3D printing, or more.

+ +

The exported .stl file will include the faces, vertices, and normals of + the p5.Geometry.

+ +

By default, this method saves a text-based .stl file. Alternatively, + you can save a more compact + + but less human-readable binary .stl file by passing { binary: true + } as a second parameter.

+ path: p5.Geometry/saveStl + flipU: + description: > +

Flips the geometry’s texture u-coordinates.

+ +

In order for texture() to work, + the geometry + + needs a way to map the points on its surface to the pixels in a + rectangular + + image that's used as a texture. The geometry's vertex at coordinates + + (x, y, z) maps to the texture image's pixel at coordinates + (u, v).

+ +

The myGeometry.uvs array + stores the + + (u, v) coordinates for each vertex in the order it was added + to the + + geometry. Calling myGeometry.flipU() flips a geometry's + u-coordinates + + so that the texture appears mirrored horizontally.

+ +

For example, a plane's four vertices are added clockwise starting from + the + + top-left corner. Here's how calling myGeometry.flipU() would + change a + + plane's texture coordinates:

+ +
// Print the original texture coordinates.
+
+      // Output: [0, 0, 1, 0, 0, 1, 1, 1]
+
+      console.log(myGeometry.uvs);
+
+
+      // Flip the u-coordinates.
+
+      myGeometry.flipU();
+
+
+      // Print the flipped texture coordinates.
+
+      // Output: [1, 0, 0, 0, 1, 1, 0, 1]
+
+      console.log(myGeometry.uvs);
+
+
+      // Notice the swaps:
+
+      // Top vertices: [0, 0, 1, 0] --> [1, 0, 0, 0]
+
+      // Bottom vertices: [0, 1, 1, 1] --> [1, 1, 0, 1]
+
+      
+ path: p5.Geometry/flipU + flipV: + description: > +

Flips the geometry’s texture v-coordinates.

+ +

In order for texture() to work, + the geometry + + needs a way to map the points on its surface to the pixels in a + rectangular + + image that's used as a texture. The geometry's vertex at coordinates + + (x, y, z) maps to the texture image's pixel at coordinates + (u, v).

+ +

The myGeometry.uvs array + stores the + + (u, v) coordinates for each vertex in the order it was added + to the + + geometry. Calling myGeometry.flipV() flips a geometry's + v-coordinates + + so that the texture appears mirrored vertically.

+ +

For example, a plane's four vertices are added clockwise starting from + the + + top-left corner. Here's how calling myGeometry.flipV() would + change a + + plane's texture coordinates:

+ +
// Print the original texture coordinates.
+
+      // Output: [0, 0, 1, 0, 0, 1, 1, 1]
+
+      console.log(myGeometry.uvs);
+
+
+      // Flip the v-coordinates.
+
+      myGeometry.flipV();
+
+
+      // Print the flipped texture coordinates.
+
+      // Output: [0, 1, 1, 1, 0, 0, 1, 0]
+
+      console.log(myGeometry.uvs);
+
+
+      // Notice the swaps:
+
+      // Left vertices: [0, 0] <--> [1, 0]
+
+      // Right vertices: [1, 0] <--> [1, 1]
+
+      
+ path: p5.Geometry/flipV + computeFaces: + description: > +

Computes the geometry's faces using its vertices.

+ +

All 3D shapes are made by connecting sets of points called + vertices. A + + geometry's surface is formed by connecting vertices to form triangles that + + are stitched together. Each triangular patch on the geometry's surface is + + called a face. myGeometry.computeFaces() performs + the math needed to + + define each face based on the distances between vertices.

+ +

The geometry's vertices are stored as p5.Vector + + objects in the myGeometry.vertices + + array. The geometry's first vertex is the + + p5.Vector object at + myGeometry.vertices[0], + + its second vertex is myGeometry.vertices[1], its third vertex + is + + myGeometry.vertices[2], and so on.

+ +

Calling myGeometry.computeFaces() fills the + + myGeometry.faces array with + three-element + + arrays that list the vertices that form each face. For example, a geometry + + made from a rectangle has two faces because a rectangle is made by joining + + two triangles. myGeometry.faces for a + + rectangle would be the two-dimensional array + + [[0, 1, 2], [2, 1, 3]]. The first face, + myGeometry.faces[0], is the + + array [0, 1, 2] because it's formed by connecting + + myGeometry.vertices[0], + myGeometry.vertices[1],and + + myGeometry.vertices[2]. The second face, + myGeometry.faces[1], is the + + array [2, 1, 3] because it's formed by connecting + + myGeometry.vertices[2], myGeometry.vertices[1], + and + + myGeometry.vertices[3].

+ +

Note: myGeometry.computeFaces() only works when geometries + have four or more vertices.

+ path: p5.Geometry/computeFaces + computeNormals: + description: > +

Calculates the normal vector for each vertex on the geometry.

+ +

All 3D shapes are made by connecting sets of points called + vertices. A + + geometry's surface is formed by connecting vertices to create triangles + + that are stitched together. Each triangular patch on the geometry's + + surface is called a face. + myGeometry.computeNormals() performs the + + math needed to orient each face. Orientation is important for lighting + + and other effects.

+ +

A face's orientation is defined by its normal vector which + points out + + of the face and is normal (perpendicular) to the surface. Calling + + myGeometry.computeNormals() first calculates each face's + normal vector. + + Then it calculates the normal vector for each vertex by averaging the + + normal vectors of the faces surrounding the vertex. The vertex normals + + are stored as p5.Vector objects in + the + + myGeometry.vertexNormals + array.

+ +

The first parameter, shadingType, is optional. Passing the + constant + + FLAT, as in myGeometry.computeNormals(FLAT), + provides neighboring + + faces with their own copies of the vertices they share. Surfaces appear + + tiled with flat shading. Passing the constant SMOOTH, as in + + myGeometry.computeNormals(SMOOTH), makes neighboring faces + reuse their + + shared vertices. Surfaces appear smoother with smooth shading. By + + default, shadingType is FLAT.

+ +

The second parameter, options, is also optional. If an + object with a + + roundToPrecision property is passed, as in + + myGeometry.computeNormals(SMOOTH, { roundToPrecision: 5 }), + it sets the + + number of decimal places to use for calculations. By default, + + roundToPrecision uses 3 decimal places.

+ path: p5.Geometry/computeNormals + normalize: + description: > +

Transforms the geometry's vertices to fit snugly within a 100×100×100 + box + + centered at the origin.

+ +

Calling myGeometry.normalize() translates the geometry's + vertices so that + + they're centered at the origin (0, 0, 0). Then it scales the + vertices so + + that they fill a 100×100×100 box. As a result, small geometries will grow + + and large geometries will shrink.

+ +

Note: myGeometry.normalize() only works when called in the + + setup() function.

+ path: p5.Geometry/normalize +properties: + vertices: + description: > +

An array with the geometry's vertices.

+ +

The geometry's vertices are stored as + + p5.Vector objects in the + myGeometry.vertices + + array. The geometry's first vertex is the + + p5.Vector object at + myGeometry.vertices[0], + + its second vertex is myGeometry.vertices[1], its third vertex + is + + myGeometry.vertices[2], and so on.

+ path: p5.Geometry/vertices + vertexNormals: + description: > +

An array with the vectors that are normal to the geometry's + vertices.

+ +

A face's orientation is defined by its normal vector which + points out + + of the face and is normal (perpendicular) to the surface. Calling + + myGeometry.computeNormals() first calculates each face's + normal + + vector. Then it calculates the normal vector for each vertex by + + averaging the normal vectors of the faces surrounding the vertex. The + + vertex normals are stored as p5.Vector + + objects in the myGeometry.vertexNormals array.

+ path: p5.Geometry/vertexNormals + faces: + description: > +

An array that lists which of the geometry's vertices form each of its + + faces.

+ +

All 3D shapes are made by connecting sets of points called + vertices. A + + geometry's surface is formed by connecting vertices to form triangles + + that are stitched together. Each triangular patch on the geometry's + + surface is called a face.

+ +

The geometry's vertices are stored as + + p5.Vector objects in the + + myGeometry.vertices array. + The + + geometry's first vertex is the p5.Vector + + object at myGeometry.vertices[0], its second vertex is + + myGeometry.vertices[1], its third vertex is + myGeometry.vertices[2], + + and so on.

+ +

For example, a geometry made from a rectangle has two faces because a + + rectangle is made by joining two triangles. myGeometry.faces + for a + + rectangle would be the two-dimensional array [[0, 1, 2], [2, 1, + 3]]. + + The first face, myGeometry.faces[0], is the array [0, + 1, 2] because + + it's formed by connecting myGeometry.vertices[0], + + myGeometry.vertices[1],and + myGeometry.vertices[2]. The second face, + + myGeometry.faces[1], is the array [2, 1, 3] + because it's formed by + + connecting myGeometry.vertices[2], + myGeometry.vertices[1],and + + myGeometry.vertices[3].

+ path: p5.Geometry/faces + uvs: + description: > +

An array that lists the texture coordinates for each of the geometry's + + vertices.

+ +

In order for texture() to work, + the geometry + + needs a way to map the points on its surface to the pixels in a + + rectangular image that's used as a texture. The geometry's vertex at + + coordinates (x, y, z) maps to the texture image's pixel at + coordinates + + (u, v).

+ +

The myGeometry.uvs array stores the (u, v) + coordinates for each + + vertex in the order it was added to the geometry. For example, the + + first vertex, myGeometry.vertices[0], has its (u, + v) coordinates + + stored at myGeometry.uvs[0] and + myGeometry.uvs[1].

+ path: p5.Geometry/uvs +chainable: false +--- + + +# p5.Geometry diff --git a/src/content/reference/en/p5 copy/p5.Graphics.mdx b/src/content/reference/en/p5 copy/p5.Graphics.mdx new file mode 100644 index 0000000000..d0b7c3aff8 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Graphics.mdx @@ -0,0 +1,261 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/p5.Graphics.js#L10 +title: p5.Graphics +module: Rendering +submodule: Rendering +file: src/core/p5.Graphics.js +description: > +

A class to describe a drawing surface that's separate from the main + canvas.

+ +

Each p5.Graphics object provides a dedicated drawing surface + called a + + graphics buffer. Graphics buffers are helpful when drawing should + happen + + offscreen. For example, separate scenes can be drawn offscreen and + + displayed only when needed.

+ +

p5.Graphics objects have nearly all the drawing features of + the main + + canvas. For example, calling the method myGraphics.circle(50, 50, + 20) + + draws to the graphics buffer. The resulting image can be displayed on the + + main canvas by passing the p5.Graphics object to the + + image() function, as in + image(myGraphics, 0, 0).

+ +

Note: createGraphics() is the + recommended + + way to create an instance of this class.

+line: 10 +isConstructor: true +params: + - name: width + description: | +

width of the graphics buffer in pixels.

+ type: Number + - name: height + description: | +

height of the graphics buffer in pixels.

+ type: Number + - name: renderer + description: | +

renderer to use, either P2D or WEBGL.

+ type: Constant + - name: pInst + description: | +

sketch instance.

+ type: P5 + optional: true + - name: canvas + description: | +

existing <canvas> element to use.

+ type: HTMLCanvasElement + optional: true +example: + - |- + +
+ + let pg; + + function setup() { + createCanvas(100, 100); + + // Create a p5.Graphics object. + pg = createGraphics(50, 50); + + // Draw to the p5.Graphics object. + pg.background(100); + pg.circle(25, 25, 20); + + describe('A dark gray square with a white circle at its center drawn on a gray background.'); + } + + function draw() { + background(200); + + // Display the p5.Graphics object. + image(pg, 25, 25); + } + +
+ +
+ + // Click the canvas to display the graphics buffer. + + let pg; + + function setup() { + createCanvas(100, 100); + + // Create a p5.Graphics object. + pg = createGraphics(50, 50); + + describe('A square appears on a gray background when the user presses the mouse. The square cycles between white and black.'); + } + + function draw() { + background(200); + + // Calculate the background color. + let bg = frameCount % 255; + + // Draw to the p5.Graphics object. + pg.background(bg); + + // Display the p5.Graphics object while + // the user presses the mouse. + if (mouseIsPressed === true) { + image(pg, 25, 25); + } + } + +
+methods: + reset: + description: > +

Resets the graphics buffer's transformations and lighting.

+ +

By default, the main canvas resets certain transformation and lighting + + values each time draw() executes. + p5.Graphics + + objects must reset these values manually by calling + myGraphics.reset().

+ path: p5.Graphics/reset + remove: + description: > +

Removes the graphics buffer from the web page.

+ +

Calling myGraphics.remove() removes the graphics buffer's + + element from the web page. The graphics buffer also + uses + + a bit of memory on the CPU that can be freed like so:

+ +
// Remove the graphics buffer from the web
+      page.
+
+      myGraphics.remove();
+
+
+      // Delete the graphics buffer from CPU memory.
+
+      myGraphics = undefined;
+
+      
+ +

Note: All variables that reference the graphics buffer must be assigned + + the value undefined to delete the graphics buffer from CPU + memory. If any + + variable still refers to the graphics buffer, then it won't be garbage + + collected.

+ path: p5.Graphics/remove + createFramebuffer: + description: > +

Creates a new p5.Framebuffer + object with + + the same WebGL context as the graphics buffer.

+ +

p5.Framebuffer objects are + separate drawing + + surfaces that can be used as textures in WebGL mode. They're similar to + + p5.Graphics objects and generally + run much + + faster when used as textures. Creating a + + p5.Framebuffer object in the + same context + + as the graphics buffer makes this speedup possible.

+ +

The parameter, options, is optional. An object can be + passed to configure + + the p5.Framebuffer object. The + available + + properties are:

+ +
    + +
  • format: data format of the texture, either + UNSIGNED_BYTE, FLOAT, or + HALF_FLOAT. Default is UNSIGNED_BYTE.
  • + +
  • channels: whether to store RGB or + RGBA color channels. Default is to match the graphics buffer + which is RGBA.
  • + +
  • depth: whether to include a depth buffer. Default is + true.
  • + +
  • depthFormat: data format of depth information, either + UNSIGNED_INT or FLOAT. Default is + FLOAT.
  • + +
  • stencil: whether to include a stencil buffer for masking. + depth must be true for this feature to work. + Defaults to the value of depth which is + true.
  • + +
  • antialias: whether to perform anti-aliasing. If set to + true, as in { antialias: true }, 2 samples will + be used by default. The number of samples can also be set, as in { + antialias: 4 }. Default is to match setAttributes() which is + false (true in Safari).
  • + +
  • width: width of the p5.Framebuffer object. Default is + to always match the graphics buffer width.
  • + +
  • height: height of the p5.Framebuffer object. Default is + to always match the graphics buffer height.
  • + +
  • density: pixel density of the p5.Framebuffer object. Default is + to always match the graphics buffer pixel density.
  • + +
  • textureFiltering: how to read values from the p5.Framebuffer object. Either + LINEAR (nearby pixels will be interpolated) or + NEAREST (no interpolation). Generally, use + LINEAR when using the texture as an image and + NEAREST if reading the texture as data. Default is + LINEAR.
  • + +
+ +

If the width, height, or density + attributes are set, they won't + + automatically match the graphics buffer and must be changed manually.

+ path: p5.Graphics/createFramebuffer +chainable: false +--- + + +# p5.Graphics diff --git a/src/content/reference/en/p5 copy/p5.Image.mdx b/src/content/reference/en/p5 copy/p5.Image.mdx new file mode 100644 index 0000000000..63e2a668fe --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Image.mdx @@ -0,0 +1,519 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/p5.Image.js#L21 +title: p5.Image +module: Image +submodule: Image +file: src/image/p5.Image.js +description: > +

A class to describe an image.

+ +

Images are rectangular grids of pixels that can be displayed and + modified.

+ +

Existing images can be loaded by calling + + loadImage(). Blank images can be + created by + + calling createImage(). + p5.Image objects + + have methods for common tasks such as applying filters and modifying + + pixel values.

+line: 21 +isConstructor: true +params: + - name: width + description: '' + type: Number + - name: height + description: '' + type: Number +example: + - |- + +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + describe('An image of a brick wall.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Apply the GRAY filter. + img.filter(GRAY); + + // Display the image. + image(img, 0, 0); + + describe('A grayscale image of a brick wall.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Image object. + let img = createImage(66, 66); + + // Load the image's pixels. + img.loadPixels(); + + // Set the pixels to black. + for (let x = 0; x < img.width; x += 1) { + for (let y = 0; y < img.height; y += 1) { + img.set(x, y, 0); + } + } + + // Update the image. + img.updatePixels(); + + // Display the image. + image(img, 17, 17); + + describe('A black square drawn in the middle of a gray square.'); + } + +
+methods: + pixelDensity: + description: | +

Gets or sets the pixel density for high pixel density displays.

+

By default, the density will be set to 1.

+

Call this method with no arguments to get the default density, or pass + in a number to set the density. If a non-positive number is provided, + it defaults to 1.

+ path: p5.Image/pixelDensity + loadPixels: + description: > +

Loads the current value of each pixel in the image into the + img.pixels + + array.

+ +

img.loadPixels() must be called before reading or + modifying pixel + + values.

+ path: p5.Image/loadPixels + updatePixels: + description: > +

Updates the canvas with the RGBA values in the + + img.pixels array.

+ +

img.updatePixels() only needs to be called after changing + values in + + the img.pixels array. Such + changes can be + + made directly after calling + + img.loadPixels() or by + calling + + img.set().

+ +

The optional parameters x, y, + width, and height define a + + subsection of the image to update. Doing so can improve performance in + + some cases.

+ +

If the image was loaded from a GIF, then calling + img.updatePixels() + + will update the pixels in current frame.

+ path: p5.Image/updatePixels + get: + description: > +

Gets a pixel or a region of pixels from the image.

+ +

img.get() is easy to use but it's not as fast as + + img.pixels. Use + + img.pixels to read many pixel + values.

+ +

The version of img.get() with no parameters returns the + entire image.

+ +

The version of img.get() with two parameters, as in + img.get(10, 20), + + interprets them as coordinates. It returns an array with the + + [R, G, B, A] values of the pixel at the given point.

+ +

The version of img.get() with four parameters, as in + + img,get(10, 20, 50, 90), interprets them as + + coordinates and dimensions. The first two parameters are the coordinates + + of the upper-left corner of the subsection. The last two parameters are + + the width and height of the subsection. It returns a subsection of the + + canvas in a new p5.Image object.

+ +

Use img.get() instead of get() to work directly + + with images.

+ path: p5.Image/get + set: + description: > +

Sets the color of one or more pixels within an image.

+ +

img.set() is easy to use but it's not as fast as + + img.pixels. Use + + img.pixels to set many pixel + values.

+ +

img.set() interprets the first two parameters as x- and + y-coordinates. It + + interprets the last parameter as a grayscale value, a [R, G, B, + A] pixel + + array, a p5.Color object, or another + + p5.Image object.

+ +

img.updatePixels() must + be called + + after using img.set() for changes to appear.

+ path: p5.Image/set + resize: + description: > +

Resizes the image to a given width and height.

+ +

The image's original aspect ratio can be kept by passing 0 for either + + width or height. For example, calling + img.resize(50, 0) on an image + + that was 500 × 300 pixels will resize it to 50 × 30 pixels.

+ path: p5.Image/resize + copy: + description: > +

Copies pixels from a source image to this image.

+ +

The first parameter, srcImage, is an optional + + p5.Image object to copy. If a source + image isn't + + passed, then img.copy() can copy a region of this image to + another + + region.

+ +

The next four parameters, sx, sy, + sw, and sh determine the region + + to copy from the source image. (sx, sy) is the top-left + corner of the + + region. sw and sh are the region's width and + height.

+ +

The next four parameters, dx, dy, + dw, and dh determine the region + + of this image to copy into. (dx, dy) is the top-left corner + of the + + region. dw and dh are the region's width and + height.

+ +

Calling img.copy() will scale pixels from the source + region if it isn't + + the same size as the destination region.

+ path: p5.Image/copy + mask: + description: > +

Masks part of the image with another.

+ +

img.mask() uses another p5.Image object's + + alpha channel as the alpha channel for this image. Masks are cumulative + + and can't be removed once applied. If the mask has a different + + pixel density from this image, the mask will be scaled.

+ path: p5.Image/mask + filter: + description: > +

Applies an image filter to the image.

+ +

The preset options are:

+ +

INVERT + + Inverts the colors in the image. No parameter is used.

+ +

GRAY + + Converts the image to grayscale. No parameter is used.

+ +

THRESHOLD + + Converts the image to black and white. Pixels with a grayscale value + + above a given threshold are converted to white. The rest are converted to + + black. The threshold must be between 0.0 (black) and 1.0 (white). If no + + value is specified, 0.5 is used.

+ +

OPAQUE + + Sets the alpha channel to be entirely opaque. No parameter is used.

+ +

POSTERIZE + + Limits the number of colors in the image. Each color channel is limited to + + the number of colors specified. Values between 2 and 255 are valid, but + + results are most noticeable with lower values. The default value is 4.

+ +

BLUR + + Blurs the image. The level of blurring is specified by a blur radius. + Larger + + values increase the blur. The default value is 4. A gaussian blur is used + + in P2D mode. A box blur is used in WEBGL + mode.

+ +

ERODE + + Reduces the light areas. No parameter is used.

+ +

DILATE + + Increases the light areas. No parameter is used.

+ path: p5.Image/filter + blend: + description: > +

Copies a region of pixels from another image into this one.

+ +

The first parameter, srcImage, is the + + p5.Image object to blend.

+ +

The next four parameters, sx, sy, + sw, and sh determine the region + + to blend from the source image. (sx, sy) is the top-left + corner of the + + region. sw and sh are the regions width and + height.

+ +

The next four parameters, dx, dy, + dw, and dh determine the region + + of the canvas to blend into. (dx, dy) is the top-left corner + of the + + region. dw and dh are the regions width and + height.

+ +

The tenth parameter, blendMode, sets the effect used to + blend the images' + + colors. The options are BLEND, DARKEST, + LIGHTEST, DIFFERENCE, + + MULTIPLY, EXCLUSION, SCREEN, + REPLACE, OVERLAY, HARD_LIGHT, + + SOFT_LIGHT, DODGE, BURN, + ADD, or NORMAL.

+ path: p5.Image/blend + save: + description: > +

Saves the image to a file.

+ +

By default, img.save() saves the image as a PNG image + called + + untitled.png.

+ +

The first parameter, filename, is optional. It's a string + that sets the + + file's name. If a file extension is included, as in + + img.save('drawing.png'), then the image will be saved using + that + + format.

+ +

The second parameter, extension, is also optional. It sets + the files format. + + Either 'png' or 'jpg' can be used. For example, + img.save('drawing', 'jpg') + + saves the canvas to a file called drawing.jpg.

+ +

Note: The browser will either save the file immediately or prompt the + user + + with a dialogue window.

+ +

The image will only be downloaded as an animated GIF if it was loaded + + from a GIF file. See saveGif() to + create new + + GIFs.

+ path: p5.Image/save + reset: + description: | +

Restarts an animated GIF at its first frame.

+ path: p5.Image/reset + getCurrentFrame: + description: | +

Gets the index of the current frame in an animated GIF.

+ path: p5.Image/getCurrentFrame + setFrame: + description: | +

Sets the current frame in an animated GIF.

+ path: p5.Image/setFrame + numFrames: + description: | +

Returns the number of frames in an animated GIF.

+ path: p5.Image/numFrames + play: + description: | +

Plays an animated GIF that was paused with + img.pause().

+ path: p5.Image/play + pause: + description: | +

Pauses an animated GIF.

+

The GIF can be resumed by calling + img.play().

+ path: p5.Image/pause + delay: + description: > +

Changes the delay between frames in an animated GIF.

+ +

The first parameter, delay, is the length of the delay in + milliseconds.

+ +

The second parameter, index, is optional. If provided, + only the frame + + at index will have its delay modified. All other frames will + keep + + their default delay.

+ path: p5.Image/delay +properties: + width: + description: | +

The image's width in pixels.

+ path: p5.Image/width + height: + description: | +

The image's height in pixels.

+ path: p5.Image/height + pixels: + description: > +

An array containing the color of each pixel in the image.

+ +

Colors are stored as numbers representing red, green, blue, and alpha + + (RGBA) values. img.pixels is a one-dimensional array for + performance + + reasons.

+ +

Each pixel occupies four elements in the pixels array, one for each + + RGBA value. For example, the pixel at coordinates (0, 0) stores its + + RGBA values at img.pixels[0], img.pixels[1], + img.pixels[2], + + and img.pixels[3], respectively. The next pixel at + coordinates (1, 0) + + stores its RGBA values at img.pixels[4], + img.pixels[5], + + img.pixels[6], and img.pixels[7]. And so on. The + img.pixels array + + for a 100×100 p5.Image object has + + 100 × 100 × 4 = 40,000 elements.

+ +

Accessing the RGBA values for a pixel in the image requires a little + + math as shown in the examples below. The + + img.loadPixels() + + method must be called before accessing the img.pixels array. + The + + img.updatePixels() method + must be + + called after any changes are made.

+ path: p5.Image/pixels +chainable: false +--- + + +# p5.Image diff --git a/src/content/reference/en/p5 copy/p5.MediaElement.mdx b/src/content/reference/en/p5 copy/p5.MediaElement.mdx new file mode 100644 index 0000000000..ee05412502 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.MediaElement.mdx @@ -0,0 +1,258 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L4099 +title: p5.MediaElement +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

A class to handle audio and video.

+ +

p5.MediaElement extends p5.Element with + + methods to handle audio and video. p5.MediaElement objects are + created by + + calling createVideo, + + createAudio, and + + createCapture.

+line: 4099 +isConstructor: true +params: + - name: elt + description: | +

DOM node that is wrapped

+ type: String +example: + - |- + +
+ + let capture; + + function setup() { + createCanvas(100, 100); + + // Create a p5.MediaElement using createCapture(). + capture = createCapture(VIDEO); + capture.hide(); + + describe('A webcam feed with inverted colors.'); + } + + function draw() { + // Display the video stream and invert the colors. + image(capture, 0, 0, width, width * capture.height / capture.width); + filter(INVERT); + } + +
+methods: + play: + description: | +

Plays audio or video from a media element.

+ path: p5.MediaElement/play + stop: + description: > +

Stops a media element and sets its current time to 0.

+ +

Calling media.play() will restart playing audio/video from + the beginning.

+ path: p5.MediaElement/stop + pause: + description: > +

Pauses a media element.

+ +

Calling media.play() will resume playing audio/video from + the moment it paused.

+ path: p5.MediaElement/pause + loop: + description: | +

Plays the audio/video repeatedly in a loop.

+ path: p5.MediaElement/loop + noLoop: + description: | +

Stops the audio/video from playing in a loop.

+

The media will stop when it finishes playing.

+ path: p5.MediaElement/noLoop + autoplay: + description: > +

Sets the audio/video to play once it's loaded.

+ +

The parameter, shouldAutoplay, is optional. Calling + + media.autoplay() without an argument causes the media to play + + automatically. If true is passed, as in + media.autoplay(true), the + + media will automatically play. If false is passed, as in + + media.autoPlay(false), it won't play automatically.

+ path: p5.MediaElement/autoplay + volume: + description: > +

Sets the audio/video volume.

+ +

Calling media.volume() without an argument returns the + current volume + + as a number in the range 0 (off) to 1 (maximum).

+ +

The parameter, val, is optional. It's a number that sets + the volume + + from 0 (off) to 1 (maximum). For example, calling + media.volume(0.5) + + sets the volume to half of its maximum.

+ path: p5.MediaElement/volume + speed: + description: > +

Sets the audio/video playback speed.

+ +

The parameter, val, is optional. It's a number that sets + the playback + + speed. 1 plays the media at normal speed, 0.5 plays it at half speed, 2 + + plays it at double speed, and so on. -1 plays the media at normal speed + + in reverse.

+ +

Calling media.speed() returns the current speed as a + number.

+ +

Note: Not all browsers support backward playback. Even if they do, + + playback might not be smooth.

+ path: p5.MediaElement/speed + time: + description: > +

Sets the media element's playback time.

+ +

The parameter, time, is optional. It's a number that + specifies the + + time, in seconds, to jump to when playback begins.

+ +

Calling media.time() without an argument returns the + number of seconds + + the audio/video has played.

+ +

Note: Time resets to 0 when looping media restarts.

+ path: p5.MediaElement/time + duration: + description: | +

Returns the audio/video's duration in seconds.

+ path: p5.MediaElement/duration + onended: + description: > +

Calls a function when the audio/video reaches the end of its + playback.

+ +

The element is passed as an argument to the callback function.

+ +

Note: The function won't be called if the media is looping.

+ path: p5.MediaElement/onended + connect: + description: > +

Sends the element's audio to an output.

+ +

The parameter, audioNode, can be an AudioNode + or an object from the + + p5.sound library.

+ +

If no element is provided, as in myElement.connect(), the + element + + connects to the main output. All connections are removed by the + + .disconnect() method.

+ +

Note: This method is meant to be used with the p5.sound.js addon + library.

+ path: p5.MediaElement/connect + disconnect: + description: > +

Disconnect all Web Audio routing, including to the main output.

+ +

This is useful if you want to re-route the output through audio + effects, + + for example.

+ path: p5.MediaElement/disconnect + showControls: + description: > +

Show the default + + HTMLMediaElement + + controls.

+ +

Note: The controls vary between web browsers.

+ path: p5.MediaElement/showControls + hideControls: + description: > +

Hide the default + + HTMLMediaElement + + controls.

+ path: p5.MediaElement/hideControls + addCue: + description: > +

Schedules a function to call when the audio/video reaches a specific + time + + during its playback.

+ +

The first parameter, time, is the time, in seconds, when + the function + + should run. This value is passed to callback as its first + argument.

+ +

The second parameter, callback, is the function to call at + the specified + + cue time.

+ +

The third parameter, value, is optional and can be any + type of value. + + value is passed to callback.

+ +

Calling media.addCue() returns an ID as a string. This is + useful for + + removing the cue later.

+ path: p5.MediaElement/addCue + removeCue: + description: | +

Removes a callback based on its ID.

+ path: p5.MediaElement/removeCue + clearCues: + description: | +

Removes all functions scheduled with media.addCue().

+ path: p5.MediaElement/clearCues +properties: + src: + description: | +

Path to the media element's source as a string.

+ path: p5.MediaElement/src +chainable: false +--- + + +# p5.MediaElement diff --git a/src/content/reference/en/p5 copy/p5.NumberDict.mdx b/src/content/reference/en/p5 copy/p5.NumberDict.mdx new file mode 100644 index 0000000000..d385eb1468 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.NumberDict.mdx @@ -0,0 +1,63 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/data/p5.TypedDict.js#L415 +title: p5.NumberDict +module: Data +submodule: Dictionary +file: src/data/p5.TypedDict.js +description: | +

A simple Dictionary class for Numbers.

+line: 415 +isConstructor: true +methods: + add: + description: | +

Add the given number to the value currently stored at the given key. + The sum then replaces the value previously stored in the Dictionary.

+ path: p5.NumberDict/add + sub: + description: > +

Subtract the given number from the value currently stored at the given + key. + + The difference then replaces the value previously stored in the + Dictionary.

+ path: p5.NumberDict/sub + mult: + description: > +

Multiply the given number with the value currently stored at the given + key. + + The product then replaces the value previously stored in the + Dictionary.

+ path: p5.NumberDict/mult + div: + description: > +

Divide the given number with the value currently stored at the given + key. + + The quotient then replaces the value previously stored in the + Dictionary.

+ path: p5.NumberDict/div + minValue: + description: | +

Return the lowest number currently stored in the Dictionary.

+ path: p5.NumberDict/minValue + maxValue: + description: | +

Return the highest number currently stored in the Dictionary.

+ path: p5.NumberDict/maxValue + minKey: + description: | +

Return the lowest key currently used in the Dictionary.

+ path: p5.NumberDict/minKey + maxKey: + description: | +

Return the highest key currently used in the Dictionary.

+ path: p5.NumberDict/maxKey +chainable: false +--- + + +# p5.NumberDict diff --git a/src/content/reference/en/p5 copy/p5.PrintWriter.mdx b/src/content/reference/en/p5 copy/p5.PrintWriter.mdx new file mode 100644 index 0000000000..7662b4f910 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.PrintWriter.mdx @@ -0,0 +1,35 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1565 +title: p5.PrintWriter +module: IO +submodule: Output +file: src/io/files.js +description: > +

A class to describe a print stream.

+ +

Each p5.PrintWriter object provides a way to save a sequence + of text + + data, called the print stream, to the user's computer. It's a + low-level + + object that enables precise control of text output. Functions such as + + saveStrings() and + + saveJSON() are easier to use for simple + file + + saving.

+ +

Note: createWriter() is the + recommended way + + to make an instance of this class.

+line: 1565 +--- + + +# p5.PrintWriter diff --git a/src/content/reference/en/p5 copy/p5.Renderer.mdx b/src/content/reference/en/p5 copy/p5.Renderer.mdx new file mode 100644 index 0000000000..5fa9dd1cd1 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Renderer.mdx @@ -0,0 +1,34 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/p5.Renderer.js#L10 +title: p5.Renderer +module: Rendering +submodule: Rendering +file: src/core/p5.Renderer.js +description: | +

Main graphics and rendering context, as well as the base API + implementation for p5.js "core". To be used as the superclass for + Renderer2D and Renderer3D classes, respectively.

+line: 10 +isConstructor: true +params: + - name: elt + description: | +

DOM node that is wrapped

+ type: HTMLElement + - name: pInst + description: | +

pointer to p5 instance

+ type: P5 + optional: true + - name: isMainCanvas + description: | +

whether we're using it as main canvas

+ type: Boolean + optional: true +chainable: false +--- + + +# p5.Renderer diff --git a/src/content/reference/en/p5 copy/p5.Shader.mdx b/src/content/reference/en/p5 copy/p5.Shader.mdx new file mode 100644 index 0000000000..1730091ac1 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Shader.mdx @@ -0,0 +1,433 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Shader.js#L11 +title: p5.Shader +module: 3D +submodule: Material +file: src/webgl/p5.Shader.js +description: > +

A class to describe a shader program.

+ +

Each p5.Shader object contains a shader program that runs on + the graphics + + processing unit (GPU). Shaders can process many pixels or vertices at the + + same time, making them fast for many graphics tasks. They’re written in a + + language called + + GLSL + + and run along with the rest of the code in a sketch.

+ +

A shader program consists of two files, a vertex shader and a fragment + + shader. The vertex shader affects where 3D geometry is drawn on the screen + + and the fragment shader affects color. Once the p5.Shader object + is + + created, it can be used with the shader() + + function, as in shader(myShader).

+ +

A shader can optionally describe hooks, which are functions in + GLSL that + + users may choose to provide to customize the behavior of the shader. For the + + vertex or the fragment shader, users can pass in an object where each key is + + the type and name of a hook function, and each value is a string with the + + parameter list and default implementation of the hook. For example, to let + users + + optionally run code at the start of the vertex shader, the options object + could + + include:

+ +
{
+    vertex: {
+      'void beforeVertex': '() {}'
+    }
+  }
+
+  
+ +

Then, in your vertex shader source, you can run a hook by calling a + function + + with the same name prefixed by HOOK_:

+ +
void main() {
+    HOOK_beforeVertex();
+    // Add the rest of your shader code here!
+  }
+
+  
+ +

Note: createShader(), + + createFilterShader(), and + + loadShader() are the recommended ways + to + + create an instance of this class.

+line: 11 +isConstructor: true +params: + - name: renderer + description: | +

WebGL context for this shader.

+ type: p5.RendererGL + - name: vertSrc + description: | +

source code for the vertex shader program.

+ type: String + - name: fragSrc + description: | +

source code for the fragment shader program.

+ type: String + - name: options + description: > +

An optional object describing how this shader can + + be augmented with hooks. It can include:

+ +
    + +
  • vertex: An object describing the available vertex shader + hooks.
  • + +
  • fragment: An object describing the available frament + shader hooks.
  • + +
+ type: Object + optional: true +example: + - |- + +
+ + // Note: A "uniform" is a global variable within a shader program. + + // Create a string with the vertex shader program. + // The vertex shader is called for each vertex. + let vertSrc = ` + precision highp float; + uniform mat4 uModelViewMatrix; + uniform mat4 uProjectionMatrix; + + attribute vec3 aPosition; + attribute vec2 aTexCoord; + varying vec2 vTexCoord; + + void main() { + vTexCoord = aTexCoord; + vec4 positionVec4 = vec4(aPosition, 1.0); + gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; + } + `; + + // Create a string with the fragment shader program. + // The fragment shader is called for each pixel. + let fragSrc = ` + precision highp float; + + void main() { + // Set each pixel's RGBA value to yellow. + gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); + } + `; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Shader object. + let myShader = createShader(vertSrc, fragSrc); + + // Apply the p5.Shader object. + shader(myShader); + + // Style the drawing surface. + noStroke(); + + // Add a plane as a drawing surface. + plane(100, 100); + + describe('A yellow square.'); + } + +
+ +
+ + // Note: A "uniform" is a global variable within a shader program. + + let mandelbrot; + + // Load the shader and create a p5.Shader object. + function preload() { + mandelbrot = loadShader('/assets/shader.vert', '/assets/shader.frag'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + // Use the p5.Shader object. + shader(mandelbrot); + + // Set the shader uniform p to an array. + mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); + + describe('A fractal image zooms in and out of focus.'); + } + + function draw() { + // Set the shader uniform r to a value that oscillates between 0 and 2. + mandelbrot.setUniform('r', sin(frameCount * 0.01) + 1); + + // Add a quad as a display surface for the shader. + quad(-1, -1, 1, -1, 1, 1, -1, 1); + } + +
+methods: + inspectHooks: + description: > +

Logs the hooks available in this shader, and their current + implementation.

+ +

Each shader may let you override bits of its behavior. Each bit is + called + + a hook. A hook is either for the vertex shader, if it + affects the + + position of vertices, or in the fragment shader, if it affects + the pixel + + color. This method logs those values to the console, letting you know what + + you are able to use in a call to + + modify().

+ +

For example, this shader will produce the following output:

+ +
myShader = baseMaterialShader().modify({
+        declarations: 'uniform float time;',
+        'vec3 getWorldPosition': `(vec3 pos) {
+          pos.y += 20. * sin(time * 0.001 + pos.x * 0.05);
+          return pos;
+        }`
+      });
+
+      myShader.inspectHooks();
+
+      
+ +
==== Vertex shader hooks: ====
+
+      void beforeVertex() {}
+
+      vec3 getLocalPosition(vec3 position) { return position; }
+
+      [MODIFIED] vec3 getWorldPosition(vec3 pos) {
+            pos.y += 20. * sin(time * 0.001 + pos.x * 0.05);
+            return pos;
+          }
+      vec3 getLocalNormal(vec3 normal) { return normal; }
+
+      vec3 getWorldNormal(vec3 normal) { return normal; }
+
+      vec2 getUV(vec2 uv) { return uv; }
+
+      vec4 getVertexColor(vec4 color) { return color; }
+
+      void afterVertex() {}
+
+
+      ==== Fragment shader hooks: ====
+
+      void beforeFragment() {}
+
+      Inputs getPixelInputs(Inputs inputs) { return inputs; }
+
+      vec4 combineColors(ColorComponents components) {
+                      vec4 color = vec4(0.);
+                      color.rgb += components.diffuse * components.baseColor;
+                      color.rgb += components.ambient * components.ambientColor;
+                      color.rgb += components.specular * components.specularColor;
+                      color.rgb += components.emissive;
+                      color.a = components.opacity;
+                      return color;
+                    }
+      vec4 getFinalColor(vec4 color) { return color; }
+
+      void afterFragment() {}
+
+      
+ path: p5.Shader/inspectHooks + modify: + description: > +

Returns a new shader, based on the original, but with custom snippets + + of shader code replacing default behaviour.

+ +

Each shader may let you override bits of its behavior. Each bit is + called + + a hook. A hook is either for the vertex shader, if it + affects the + + position of vertices, or in the fragment shader, if it affects + the pixel + + color. You can inspect the different hooks available by calling + + yourShader.inspectHooks(). + You can + + also read the reference for the default material, normal material, color, + line, and point shaders to + + see what hooks they have available.

+ +

modify() takes one parameter, hooks, an + object with the hooks you want + + to override. Each key of the hooks object is the name + + of a hook, and the value is a string with the GLSL code for your hook.

+ +

If you supply functions that aren't existing hooks, they will get added + at the start of + + the shader as helper functions so that you can use them in your hooks.

+ +

To add new uniforms to + your shader, you can pass in a uniforms object containing + + the type and name of the uniform as the key, and a default value or + function returning + + a default value as its value. These will be automatically set when the + shader is set + + with shader(yourShader).

+ +

You can also add a declarations key, where the value is a + GLSL string declaring + + custom uniform variables, globals, and functions shared + + between hooks. To add declarations just in a vertex or fragment shader, + add + + vertexDeclarations and fragmentDeclarations + keys.

+ path: p5.Shader/modify + copyToContext: + description: > +

Copies the shader from one drawing context to another.

+ +

Each p5.Shader object must be compiled by calling + + shader() before it can run. + Compilation happens + + in a drawing context which is usually the main canvas or an instance of + + p5.Graphics. A shader can only be + used in the + + context where it was compiled. The copyToContext() method + compiles the + + shader again and copies it to another drawing context where it can be + + reused.

+ +

The parameter, context, is the drawing context where the + shader will be + + used. The shader can be copied to an instance of + + p5.Graphics, as in + + myShader.copyToContext(pg). The shader can also be copied + from a + + p5.Graphics object to the main + canvas using + + the window variable, as in + myShader.copyToContext(window).

+ +

Note: A p5.Shader object created + with + + createShader(), + + createFilterShader(), or + + loadShader() + + can be used directly with a p5.Framebuffer + + object created with + + createFramebuffer(). Both + objects + + have the same context as the main canvas.

+ path: p5.Shader/copyToContext + setUniform: + description: > +

Sets the shader’s uniform (global) variables.

+ +

Shader programs run on the computer’s graphics processing unit (GPU). + + They live in part of the computer’s memory that’s completely separate + + from the sketch that runs them. Uniforms are global variables within a + + shader program. They provide a way to pass values from a sketch running + + on the CPU to a shader program running on the GPU.

+ +

The first parameter, uniformName, is a string with the + uniform’s name. + + For the shader above, uniformName would be + 'r'.

+ +

The second parameter, data, is the value that should be + used to set the + + uniform. For example, calling myShader.setUniform('r', 0.5) + would set + + the r uniform in the shader above to 0.5. data + should match the + + uniform’s type. Numbers, strings, booleans, arrays, and many types of + + images can all be passed to a shader with setUniform().

+ path: p5.Shader/setUniform +chainable: false +--- + + +# p5.Shader diff --git a/src/content/reference/en/p5 copy/p5.StringDict.mdx b/src/content/reference/en/p5 copy/p5.StringDict.mdx new file mode 100644 index 0000000000..5ca466e5d1 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.StringDict.mdx @@ -0,0 +1,15 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/data/p5.TypedDict.js#L397 +title: p5.StringDict +module: Data +submodule: Dictionary +file: src/data/p5.TypedDict.js +description: | +

A simple Dictionary class for Strings.

+line: 397 +--- + + +# p5.StringDict diff --git a/src/content/reference/en/p5 copy/p5.Table.mdx b/src/content/reference/en/p5 copy/p5.Table.mdx new file mode 100644 index 0000000000..41ad72b0d1 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Table.mdx @@ -0,0 +1,213 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/p5.Table.js#L33 +title: p5.Table +module: IO +submodule: Table +file: src/io/p5.Table.js +description: > +

Table objects store data with multiple + rows and columns, much + + like in a traditional spreadsheet. Tables can be generated from + + scratch, dynamically, or using data from an existing file.

+line: 33 +isConstructor: true +params: + - name: rows + description: | +

An array of p5.TableRow objects

+ type: 'p5.TableRow[]' + optional: true +methods: + addRow: + description: > +

Use addRow() to add a new row of + data to a p5.Table object. By + default, + + an empty row is created. Typically, you would store a reference to + + the new row in a TableRow object (see newRow in the example above), + + and then set individual values using set().

+ +

If a p5.TableRow object is + included as a parameter, then that row is + + duplicated and added to the table.

+ path: p5.Table/addRow + removeRow: + description: | +

Removes a row from the table object.

+ path: p5.Table/removeRow + getRow: + description: > +

Returns a reference to the specified p5.TableRow. The reference + + can then be used to get and set values of the selected row.

+ path: p5.Table/getRow + getRows: + description: > +

Gets all rows from the table. Returns an array of p5.TableRows.

+ path: p5.Table/getRows + findRow: + description: | +

Finds the first row in the Table that contains the value + provided, and returns a reference to that row. Even if + multiple rows are possible matches, only the first matching + row is returned. The column to search may be specified by + either its ID or title.

+ path: p5.Table/findRow + findRows: + description: | +

Finds the rows in the Table that contain the value + provided, and returns references to those rows. Returns an + Array, so for must be used to iterate through all the rows, + as shown in the example above. The column to search may be + specified by either its ID or title.

+ path: p5.Table/findRows + matchRow: + description: | +

Finds the first row in the Table that matches the regular + expression provided, and returns a reference to that row. + Even if multiple rows are possible matches, only the first + matching row is returned. The column to search may be + specified by either its ID or title.

+ path: p5.Table/matchRow + matchRows: + description: | +

Finds the rows in the Table that match the regular expression provided, + and returns references to those rows. Returns an array, so for must be + used to iterate through all the rows, as shown in the example. The + column to search may be specified by either its ID or title.

+ path: p5.Table/matchRows + getColumn: + description: | +

Retrieves all values in the specified column, and returns them + as an array. The column may be specified by either its ID or title.

+ path: p5.Table/getColumn + clearRows: + description: | +

Removes all rows from a Table. While all rows are removed, + columns and column titles are maintained.

+ path: p5.Table/clearRows + addColumn: + description: > +

Use addColumn() to add a new + column to a Table object. + + Typically, you will want to specify a title, so the column + + may be easily referenced later by name. (If no title is + + specified, the new column's title will be null.)

+ path: p5.Table/addColumn + getColumnCount: + description: | +

Returns the total number of columns in a Table.

+ path: p5.Table/getColumnCount + getRowCount: + description: | +

Returns the total number of rows in a Table.

+ path: p5.Table/getRowCount + removeTokens: + description: | +

Removes any of the specified characters (or "tokens").

+

If no column is specified, then the values in all columns and + rows are processed. A specific column may be referenced by + either its ID or title.

+ path: p5.Table/removeTokens + trim: + description: | +

Trims leading and trailing whitespace, such as spaces and tabs, + from String table values. If no column is specified, then the + values in all columns and rows are trimmed. A specific column + may be referenced by either its ID or title.

+ path: p5.Table/trim + removeColumn: + description: > +

Use removeColumn() to remove + an existing column from a Table + + object. The column to be removed may be identified by either + + its title (a String) or its index value (an int). + + removeColumn(0) would remove the first column, removeColumn(1) + + would remove the second column, and so on.

+ path: p5.Table/removeColumn + set: + description: | +

Stores a value in the Table's specified row and column. + The row is specified by its ID, while the column may be specified + by either its ID or title.

+ path: p5.Table/set + setNum: + description: | +

Stores a Float value in the Table's specified row and column. + The row is specified by its ID, while the column may be specified + by either its ID or title.

+ path: p5.Table/setNum + setString: + description: | +

Stores a String value in the Table's specified row and column. + The row is specified by its ID, while the column may be specified + by either its ID or title.

+ path: p5.Table/setString + get: + description: | +

Retrieves a value from the Table's specified row and column. + The row is specified by its ID, while the column may be specified by + either its ID or title.

+ path: p5.Table/get + getNum: + description: | +

Retrieves a Float value from the Table's specified row and column. + The row is specified by its ID, while the column may be specified by + either its ID or title.

+ path: p5.Table/getNum + getString: + description: | +

Retrieves a String value from the Table's specified row and column. + The row is specified by its ID, while the column may be specified by + either its ID or title.

+ path: p5.Table/getString + getObject: + description: | +

Retrieves all table data and returns as an object. If a column name is + passed in, each row object will be stored with that attribute as its + title.

+ path: p5.Table/getObject + getArray: + description: > +

Retrieves all table data and returns it as a multidimensional + array.

+ path: p5.Table/getArray +properties: + columns: + description: > +

An array containing the names of the columns in the table, if the + "header" the table is + + loaded with the "header" parameter.

+ path: p5.Table/columns + rows: + description: > +

An array containing the p5.TableRow objects that make up the + + rows of the table. The same result as calling getRows()

+ path: p5.Table/rows +chainable: false +--- + + +# p5.Table diff --git a/src/content/reference/en/p5 copy/p5.TableRow.mdx b/src/content/reference/en/p5 copy/p5.TableRow.mdx new file mode 100644 index 0000000000..00081f9654 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.TableRow.mdx @@ -0,0 +1,66 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/p5.TableRow.js#L9 +title: p5.TableRow +module: IO +submodule: Table +file: src/io/p5.TableRow.js +description: | +

A TableRow object represents a single row of data values, + stored in columns, from a table.

+

A Table Row contains both an ordered array, and an unordered + JSON object.

+line: 9 +isConstructor: true +params: + - name: str + description: | +

optional: populate the row with a + string of values, separated by the + separator

+ type: String + optional: true + - name: separator + description: | +

comma separated values (csv) by default

+ type: String + optional: true +methods: + set: + description: | +

Stores a value in the TableRow's specified column. + The column may be specified by either its ID or title.

+ path: p5.TableRow/set + setNum: + description: | +

Stores a Float value in the TableRow's specified column. + The column may be specified by either its ID or title.

+ path: p5.TableRow/setNum + setString: + description: | +

Stores a String value in the TableRow's specified column. + The column may be specified by either its ID or title.

+ path: p5.TableRow/setString + get: + description: | +

Retrieves a value from the TableRow's specified column. + The column may be specified by either its ID or title.

+ path: p5.TableRow/get + getNum: + description: | +

Retrieves a Float value from the TableRow's specified + column. The column may be specified by either its ID or + title.

+ path: p5.TableRow/getNum + getString: + description: | +

Retrieves an String value from the TableRow's specified + column. The column may be specified by either its ID or + title.

+ path: p5.TableRow/getString +chainable: false +--- + + +# p5.TableRow diff --git a/src/content/reference/en/p5 copy/p5.TypedDict.mdx b/src/content/reference/en/p5 copy/p5.TypedDict.mdx new file mode 100644 index 0000000000..2bcb7b5752 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.TypedDict.mdx @@ -0,0 +1,66 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/data/p5.TypedDict.js#L82 +title: p5.TypedDict +module: Data +submodule: Dictionary +file: src/data/p5.TypedDict.js +description: | +

Base class for all p5.Dictionary types. Specifically + typed Dictionary classes inherit from this class.

+line: 82 +isConstructor: true +methods: + size: + description: > +

Returns the number of key-value pairs currently stored in the + Dictionary.

+ path: p5.TypedDict/size + hasKey: + description: | +

Returns true if the given key exists in the Dictionary, + otherwise returns false.

+ path: p5.TypedDict/hasKey + get: + description: | +

Returns the value stored at the given key.

+ path: p5.TypedDict/get + set: + description: > +

Updates the value associated with the given key in case it already + exists + + in the Dictionary. Otherwise a new key-value pair is added.

+ path: p5.TypedDict/set + create: + description: | +

Creates a new key-value pair in the Dictionary.

+ path: p5.TypedDict/create + clear: + description: | +

Removes all previously stored key-value pairs from the Dictionary.

+ path: p5.TypedDict/clear + remove: + description: > +

Removes the key-value pair stored at the given key from the + Dictionary.

+ path: p5.TypedDict/remove + print: + description: > +

Logs the set of items currently stored in the Dictionary to the + console.

+ path: p5.TypedDict/print + saveTable: + description: | +

Converts the Dictionary into a CSV file for local download.

+ path: p5.TypedDict/saveTable + saveJSON: + description: | +

Converts the Dictionary into a JSON file for local download.

+ path: p5.TypedDict/saveJSON +chainable: false +--- + + +# p5.TypedDict diff --git a/src/content/reference/en/p5 copy/p5.Vector.mdx b/src/content/reference/en/p5 copy/p5.Vector.mdx new file mode 100644 index 0000000000..ff67d7562c --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Vector.mdx @@ -0,0 +1,673 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/p5.Vector.js#L11 +title: p5.Vector +module: Math +submodule: Vector +file: src/math/p5.Vector.js +description: > +

A class to describe a two or three-dimensional vector.

+ +

A vector can be thought of in different ways. In one view, a vector is like + + an arrow pointing in space. Vectors have both magnitude (length) and + + direction.

+ +

p5.Vector objects are often used to program motion because + they simplify + + the math. For example, a moving ball has a position and a velocity. + + Position describes where the ball is in space. The ball's position vector + + extends from the origin to the ball's center. Velocity describes the ball's + + speed and the direction it's moving. If the ball is moving straight up, its + + velocity vector points straight up. Adding the ball's velocity vector to + + its position vector moves it, as in pos.add(vel). Vector math + relies on + + methods inside the p5.Vector class.

+ +

Note: createVector() is the + recommended way + + to make an instance of this class.

+line: 11 +isConstructor: true +params: + - name: x + description: | +

x component of the vector.

+ type: Number + optional: true + - name: 'y' + description: | +

y component of the vector.

+ type: Number + optional: true + - name: z + description: | +

z component of the vector.

+ type: Number + optional: true +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create p5.Vector objects. + let p1 = createVector(25, 25); + let p2 = createVector(75, 75); + + // Style the points. + strokeWeight(5); + + // Draw the first point using a p5.Vector. + point(p1); + + // Draw the second point using a p5.Vector's components. + point(p2.x, p2.y); + + describe('Two black dots on a gray square, one at the top left and the other at the bottom right.'); + } + +
+ +
+ + let pos; + let vel; + + function setup() { + createCanvas(100, 100); + + // Create p5.Vector objects. + pos = createVector(50, 100); + vel = createVector(0, -1); + + describe('A black dot moves from bottom to top on a gray square. The dot reappears at the bottom when it reaches the top.'); + } + + function draw() { + background(200); + + // Add velocity to position. + pos.add(vel); + + // If the dot reaches the top of the canvas, + // restart from the bottom. + if (pos.y < 0) { + pos.y = 100; + } + + // Draw the dot. + strokeWeight(5); + point(pos); + } + +
+methods: + toString: + description: > +

Returns a string representation of a vector.

+ +

Calling toString() is useful for printing vectors to the + console while + + debugging.

+ path: p5.Vector/toString + set: + description: > +

Sets the vector's x, y, and z + components.

+ +

set() can use separate numbers, as in v.set(1, 2, + 3), a + + p5.Vector object, as in + v.set(v2), or an + + array of numbers, as in v.set([1, 2, 3]).

+ +

If a value isn't provided for a component, it will be set to 0. For + + example, v.set(4, 5) sets v.x to 4, + v.y to 5, and v.z to 0. + + Calling set() with no arguments, as in v.set(), + sets all the vector's + + components to 0.

+ path: p5.Vector/set + copy: + description: > +

Returns a copy of the p5.Vector + object.

+ path: p5.Vector/copy + add: + description: > +

Adds to a vector's x, y, and z + components.

+ +

add() can use separate numbers, as in v.add(1, 2, + 3), + + another p5.Vector object, as in + v.add(v2), or + + an array of numbers, as in v.add([1, 2, 3]).

+ +

If a value isn't provided for a component, it won't change. For + + example, v.add(4, 5) adds 4 to v.x, 5 to + v.y, and 0 to v.z. + + Calling add() with no arguments, as in v.add(), + has no effect.

+ +

The static version of add(), as in p5.Vector.add(v2, + v1), returns a new + + p5.Vector object and doesn't change + the + + originals.

+ path: p5.Vector/add + rem: + description: > +

Performs modulo (remainder) division with a vector's x, + y, and z + + components.

+ +

rem() can use separate numbers, as in v.rem(1, 2, + 3), + + another p5.Vector object, as in + v.rem(v2), or + + an array of numbers, as in v.rem([1, 2, 3]).

+ +

If only one value is provided, as in v.rem(2), then all + the components + + will be set to their values modulo 2. If two values are provided, as in + + v.rem(2, 3), then v.z won't change. Calling + rem() with no + + arguments, as in v.rem(), has no effect.

+ +

The static version of rem(), as in p5.Vector.rem(v2, + v1), returns a + + new p5.Vector object and doesn't + change the + + originals.

+ path: p5.Vector/rem + sub: + description: > +

Subtracts from a vector's x, y, and + z components.

+ +

sub() can use separate numbers, as in v.sub(1, 2, + 3), another + + p5.Vector object, as in + v.sub(v2), or an array + + of numbers, as in v.sub([1, 2, 3]).

+ +

If a value isn't provided for a component, it won't change. For + + example, v.sub(4, 5) subtracts 4 from v.x, 5 + from v.y, and 0 from v.z. + + Calling sub() with no arguments, as in v.sub(), + has no effect.

+ +

The static version of sub(), as in p5.Vector.sub(v2, + v1), returns a new + + p5.Vector object and doesn't change + the + + originals.

+ path: p5.Vector/sub + mult: + description: > +

Multiplies a vector's x, y, and + z components.

+ +

mult() can use separate numbers, as in v.mult(1, 2, + 3), another + + p5.Vector object, as in + v.mult(v2), or an array + + of numbers, as in v.mult([1, 2, 3]).

+ +

If only one value is provided, as in v.mult(2), then all + the components + + will be multiplied by 2. If a value isn't provided for a component, it + + won't change. For example, v.mult(4, 5) multiplies + v.x by 4, v.y by 5, + + and v.z by 1. Calling mult() with no arguments, + as in v.mult(), has + + no effect.

+ +

The static version of mult(), as in + p5.Vector.mult(v, 2), returns a new + + p5.Vector object and doesn't change + the + + originals.

+ path: p5.Vector/mult + div: + description: > +

Divides a vector's x, y, and z + components.

+ +

div() can use separate numbers, as in v.div(1, 2, + 3), another + + p5.Vector object, as in + v.div(v2), or an array + + of numbers, as in v.div([1, 2, 3]).

+ +

If only one value is provided, as in v.div(2), then all + the components + + will be divided by 2. If a value isn't provided for a component, it + + won't change. For example, v.div(4, 5) divides + v.x by, v.y by 5, + + and v.z by 1. Calling div() with no arguments, + as in v.div(), has + + no effect.

+ +

The static version of div(), as in p5.Vector.div(v, + 2), returns a new + + p5.Vector object and doesn't change + the + + originals.

+ path: p5.Vector/div + mag: + description: > +

Calculates the magnitude (length) of the vector.

+ +

Use mag() to calculate the magnitude + of a 2D vector + + using components as in mag(x, y).

+ path: p5.Vector/mag + magSq: + description: | +

Calculates the magnitude (length) of the vector squared.

+ path: p5.Vector/magSq + dot: + description: > +

Calculates the dot product of two vectors.

+ +

The dot product is a number that describes the overlap between two + vectors. + + Visually, the dot product can be thought of as the "shadow" one vector + + casts on another. The dot product's magnitude is largest when two vectors + + point in the same or opposite directions. Its magnitude is 0 when two + + vectors form a right angle.

+ +

The version of dot() with one parameter interprets it as + another + + p5.Vector object.

+ +

The version of dot() with multiple parameters interprets + them as the + + x, y, and z components of another + vector.

+ +

The static version of dot(), as in p5.Vector.dot(v1, + v2), is the same + + as calling v1.dot(v2).

+ path: p5.Vector/dot + cross: + description: > +

Calculates the cross product of two vectors.

+ +

The cross product is a vector that points straight out of the plane + created + + by two vectors. The cross product's magnitude is the area of the + parallelogram + + formed by the original two vectors.

+ +

The static version of cross(), as in + p5.Vector.cross(v1, v2), is the same + + as calling v1.cross(v2).

+ path: p5.Vector/cross + dist: + description: > +

Calculates the distance between two points represented by vectors.

+ +

A point's coordinates can be represented by the components of a vector + + that extends from the origin to the point.

+ +

The static version of dist(), as in + p5.Vector.dist(v1, v2), is the same + + as calling v1.dist(v2).

+ +

Use dist() to calculate the distance + between points + + using coordinates as in dist(x1, y1, x2, y2).

+ path: p5.Vector/dist + normalize: + description: > +

Scales the components of a p5.Vector object so + + that its magnitude is 1.

+ +

The static version of normalize(), as in + p5.Vector.normalize(v), + + returns a new p5.Vector object and + doesn't change + + the original.

+ path: p5.Vector/normalize + limit: + description: > +

Limits a vector's magnitude to a maximum value.

+ +

The static version of limit(), as in + p5.Vector.limit(v, 5), returns a + + new p5.Vector object and doesn't + change the + + original.

+ path: p5.Vector/limit + setMag: + description: > +

Sets a vector's magnitude to a given value.

+ +

The static version of setMag(), as in + p5.Vector.setMag(v, 10), returns + + a new p5.Vector object and doesn't + change the + + original.

+ path: p5.Vector/setMag + heading: + description: > +

Calculates the angle a 2D vector makes with the positive x-axis.

+ +

By convention, the positive x-axis has an angle of 0. Angles increase + in + + the clockwise direction.

+ +

If the vector was created with + + createVector(), + heading() returns angles + + in the units of the current angleMode().

+ +

The static version of heading(), as in + p5.Vector.heading(v), works the + + same way.

+ path: p5.Vector/heading + setHeading: + description: > +

Rotates a 2D vector to a specific angle without changing its + magnitude.

+ +

By convention, the positive x-axis has an angle of 0. Angles increase + in + + the clockwise direction.

+ +

If the vector was created with + + createVector(), + setHeading() uses + + the units of the current angleMode().

+ path: p5.Vector/setHeading + rotate: + description: > +

Rotates a 2D vector by an angle without changing its magnitude.

+ +

By convention, the positive x-axis has an angle of 0. Angles increase + in + + the clockwise direction.

+ +

If the vector was created with + + createVector(), + rotate() uses + + the units of the current angleMode().

+ +

The static version of rotate(), as in + p5.Vector.rotate(v, PI), + + returns a new p5.Vector object and + doesn't change + + the original.

+ path: p5.Vector/rotate + angleBetween: + description: > +

Calculates the angle between two vectors.

+ +

The angles returned are signed, which means that + + v1.angleBetween(v2) === -v2.angleBetween(v1).

+ +

If the vector was created with + + createVector(), + angleBetween() returns + + angles in the units of the current + + angleMode().

+ path: p5.Vector/angleBetween + lerp: + description: > +

Calculates new x, y, and z + components that are proportionally the + + same distance between two vectors.

+ +

The amt parameter is the amount to interpolate between the + old vector and + + the new vector. 0.0 keeps all components equal to the old vector's, 0.5 is + + halfway between, and 1.0 sets all components equal to the new + vector's.

+ +

The static version of lerp(), as in + p5.Vector.lerp(v0, v1, 0.5), + + returns a new p5.Vector object and + doesn't change + + the original.

+ path: p5.Vector/lerp + slerp: + description: > +

Calculates a new heading and magnitude that are between two + vectors.

+ +

The amt parameter is the amount to interpolate between the + old vector and + + the new vector. 0.0 keeps the heading and magnitude equal to the old + + vector's, 0.5 sets them halfway between, and 1.0 sets the heading and + + magnitude equal to the new vector's.

+ +

slerp() differs from lerp() because + + it interpolates magnitude. Calling v0.slerp(v1, 0.5) sets + v0's + + magnitude to a value halfway between its original magnitude and + v1's. + + Calling v0.lerp(v1, 0.5) makes no such guarantee.

+ +

The static version of slerp(), as in + p5.Vector.slerp(v0, v1, 0.5), + + returns a new p5.Vector object and + doesn't change + + the original.

+ path: p5.Vector/slerp + reflect: + description: > +

Reflects a vector about a line in 2D or a plane in 3D.

+ +

The orientation of the line or plane is described by a normal vector + that + + points away from the shape.

+ +

The static version of reflect(), as in + p5.Vector.reflect(v, n), + + returns a new p5.Vector object and + doesn't change + + the original.

+ path: p5.Vector/reflect + array: + description: | +

Returns the vector's components as an array of numbers.

+ path: p5.Vector/array + equals: + description: > +

Checks whether all the vector's components are equal to another + vector's.

+ +

equals() returns true if the vector's + components are all the same as another + + vector's and false if not.

+ +

The version of equals() with one parameter interprets it + as another + + p5.Vector object.

+ +

The version of equals() with multiple parameters + interprets them as the + + components of another vector. Any missing parameters are assigned the + value + + 0.

+ +

The static version of equals(), as in + p5.Vector.equals(v0, v1), + + interprets both parameters as p5.Vector objects.

+ path: p5.Vector/equals + fromAngle: + description: | +

Creates a new 2D vector from an angle.

+ path: p5.Vector/fromAngle + fromAngles: + description: | +

Creates a new 3D vector from a pair of ISO spherical angles.

+ path: p5.Vector/fromAngles + random2D: + description: | +

Creates a new 2D unit vector with a random heading.

+ path: p5.Vector/random2D + random3D: + description: | +

Creates a new 3D unit vector with a random heading.

+ path: p5.Vector/random3D + clampToZero: + description: > +

Replaces the components of a p5.Vector that are very close to zero + with zero.

+ +

In computers, handling numbers with decimals can give slightly + imprecise answers due to the way those numbers are represented. + + This can make it hard to check if a number is zero, as it may be close but + not exactly zero. + + This method rounds very close numbers to zero to make those checks + easier

+ +

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON

+ path: p5.Vector/clampToZero +properties: + x: + description: | +

The x component of the vector

+ path: p5.Vector/x + 'y': + description: | +

The y component of the vector

+ path: p5.Vector/y + z: + description: | +

The z component of the vector

+ path: p5.Vector/z +chainable: false +--- + + +# p5.Vector diff --git a/src/content/reference/en/p5 copy/p5.XML.mdx b/src/content/reference/en/p5 copy/p5.XML.mdx new file mode 100644 index 0000000000..71904fded2 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.XML.mdx @@ -0,0 +1,321 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/p5.XML.js#L9 +title: p5.XML +module: IO +submodule: Input +file: src/io/p5.XML.js +description: > +

A class to describe an XML object.

+ +

Each p5.XML object provides an easy way to interact with XML + data. + + Extensible Markup Language + + (XML) + + is a standard format for sending data between applications. Like HTML, the + + XML format is based on tags and attributes, as in + + .

+ +

Note: Use loadXML() to load external + XML files.

+line: 9 +isConstructor: true +example: + - |- + +
+ + let myXML; + + // Load the XML and create a p5.XML object. + function preload() { + myXML = loadXML('/assets/animals.xml'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Get an array with all mammal tags. + let mammals = myXML.getChildren('mammal'); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(14); + + // Iterate over the mammals array. + for (let i = 0; i < mammals.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 25; + + // Get the mammal's common name. + let name = mammals[i].getContent(); + + // Display the mammal's name. + text(name, 20, y); + } + + describe( + 'The words "Goat", "Leopard", and "Zebra" written on three separate lines. The text is black on a gray background.' + ); + } + +
+methods: + getParent: + description: > +

Returns the element's parent element as a new p5.XML + + object.

+ path: p5.XML/getParent + getName: + description: > +

Returns the element's name as a String.

+ +

An XML element's name is given by its tag. For example, the element + + JavaScript has the name + language.

+ path: p5.XML/getName + setName: + description: > +

Sets the element's tag name.

+ +

An XML element's name is given by its tag. For example, the element + + JavaScript has the name + language.

+ +

The parameter, name, is the element's new name as a + string. For example, + + calling myXML.setName('planet') will make the element's new + tag name + + .

+ path: p5.XML/setName + hasChildren: + description: > +

Returns true if the element has child elements and + false if not.

+ path: p5.XML/hasChildren + listChildren: + description: | +

Returns an array with the names of the element's child elements as + Strings.

+ path: p5.XML/listChildren + getChildren: + description: > +

Returns an array with the element's child elements as new + + p5.XML objects.

+ +

The parameter, name, is optional. If a string is passed, + as in + + myXML.getChildren('cat'), then the method will only return + child elements + + with the tag .

+ path: p5.XML/getChildren + getChild: + description: > +

Returns the first matching child element as a new + + p5.XML object.

+ +

The parameter, name, is optional. If a string is passed, + as in + + myXML.getChild('cat'), then the first child element with the + tag + + will be returned. If a number is passed, as in + + myXML.getChild(1), then the child element at that index will + be returned.

+ path: p5.XML/getChild + addChild: + description: > +

Adds a new child element and returns a reference to it.

+ +

The parameter, child, is the p5.XML object to add + + as a child element. For example, calling + myXML.addChild(otherXML) inserts + + otherXML as a child element of myXML.

+ path: p5.XML/addChild + removeChild: + description: > +

Removes the first matching child element.

+ +

The parameter, name, is the child element to remove. If a + string is + + passed, as in myXML.removeChild('cat'), then the first child + element + + with the tag will be removed. If a number is passed, as + in + + myXML.removeChild(1), then the child element at that index + will be + + removed.

+ path: p5.XML/removeChild + getAttributeCount: + description: | +

Returns the number of attributes the element has.

+ path: p5.XML/getAttributeCount + listAttributes: + description: > +

Returns an Array with the names of the element's + attributes.

+ +

Note: Use + + myXML.getString() or + + myXML.getNum() to return an + attribute's value.

+ path: p5.XML/listAttributes + hasAttribute: + description: > +

Returns true if the element has a given attribute and + false if not.

+ +

The parameter, name, is a string with the name of the + attribute being + + checked.

+ +

Note: Use + + myXML.getString() or + + myXML.getNum() to return an + attribute's value.

+ path: p5.XML/hasAttribute + getNum: + description: > +

Return an attribute's value as a Number.

+ +

The first parameter, name, is a string with the name of + the attribute + + being checked. For example, calling myXML.getNum('id') + returns the + + element's id attribute as a number.

+ +

The second parameter, defaultValue, is optional. If a + number is passed, + + as in myXML.getNum('id', -1), it will be returned if the + attribute + + doesn't exist or can't be converted to a number.

+ +

Note: Use + + myXML.getString() or + + myXML.getNum() to return an + attribute's value.

+ path: p5.XML/getNum + getString: + description: > +

Return an attribute's value as a string.

+ +

The first parameter, name, is a string with the name of + the attribute + + being checked. For example, calling myXML.getString('color') + returns the + + element's id attribute as a string.

+ +

The second parameter, defaultValue, is optional. If a + string is passed, + + as in myXML.getString('color', 'deeppink'), it will be + returned if the + + attribute doesn't exist.

+ +

Note: Use + + myXML.getString() or + + myXML.getNum() to return an + attribute's value.

+ path: p5.XML/getString + setAttribute: + description: > +

Sets an attribute to a given value.

+ +

The first parameter, name, is a string with the name of + the attribute + + being set.

+ +

The second parameter, value, is the attribute's new value. + For example, + + calling myXML.setAttribute('id', 123) sets the + id attribute to the + + value 123.

+ path: p5.XML/setAttribute + getContent: + description: > +

Returns the element's content as a String.

+ +

The parameter, defaultValue, is optional. If a string is + passed, as in + + myXML.getContent('???'), it will be returned if the element + has no + + content.

+ path: p5.XML/getContent + setContent: + description: > +

Sets the element's content.

+ +

An element's content is the text between its tags. For example, the + element + + JavaScript has the content + JavaScript.

+ +

The parameter, content, is a string with the element's new + content.

+ path: p5.XML/setContent + serialize: + description: > +

Returns the element as a String.

+ +

myXML.serialize() is useful for sending the element over + the network or + + saving it to a file.

+ path: p5.XML/serialize +chainable: false +--- + + +# p5.XML diff --git a/src/content/reference/en/p5 copy/p5.mdx b/src/content/reference/en/p5 copy/p5.mdx new file mode 100644 index 0000000000..c51b8f8bff --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.mdx @@ -0,0 +1,51 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L12 +title: p5 +module: IO +submodule: Output +file: src/core/main.js +description: > +

This is the p5 instance constructor.

+ +

A p5 instance holds all the properties and methods related to + + a p5 sketch. It expects an incoming sketch closure and it can also + + take an optional node parameter for attaching the generated p5 canvas + + to a node. The sketch closure takes the newly created p5 instance as + + its sole argument and may optionally set preload(), + + setup(), and/or + + draw() properties on it for running a + sketch.

+ +

A p5 sketch can run in "global" or "instance" mode: + + "global" - all properties and methods are attached to the window + + "instance" - all properties and methods are bound to this p5 object

+line: 12 +isConstructor: true +params: + - name: sketch + description: | +

a closure that can set optional preload(), + setup(), and/or draw() properties on the + given p5 instance

+ type: Function(p5) + - name: node + description: | +

element to attach canvas to

+ type: HTMLElement + optional: true +chainable: false +--- + + +# p5 diff --git a/src/content/reference/en/p5 copy/pAccelerationX.mdx b/src/content/reference/en/p5 copy/pAccelerationX.mdx new file mode 100644 index 0000000000..ab1f3e49d1 --- /dev/null +++ b/src/content/reference/en/p5 copy/pAccelerationX.mdx @@ -0,0 +1,21 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L90 +title: pAccelerationX +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: | +

The system variable pAccelerationX always contains the acceleration of the + device along the x axis in the frame previous to the current frame. Value + is represented as meters per second squared.

+line: 90 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# pAccelerationX diff --git a/src/content/reference/en/p5 copy/pAccelerationY.mdx b/src/content/reference/en/p5 copy/pAccelerationY.mdx new file mode 100644 index 0000000000..188ae8f77c --- /dev/null +++ b/src/content/reference/en/p5 copy/pAccelerationY.mdx @@ -0,0 +1,21 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L100 +title: pAccelerationY +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: | +

The system variable pAccelerationY always contains the acceleration of the + device along the y axis in the frame previous to the current frame. Value + is represented as meters per second squared.

+line: 100 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# pAccelerationY diff --git a/src/content/reference/en/p5 copy/pAccelerationZ.mdx b/src/content/reference/en/p5 copy/pAccelerationZ.mdx new file mode 100644 index 0000000000..f291e6b707 --- /dev/null +++ b/src/content/reference/en/p5 copy/pAccelerationZ.mdx @@ -0,0 +1,21 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L110 +title: pAccelerationZ +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: | +

The system variable pAccelerationZ always contains the acceleration of the + device along the z axis in the frame previous to the current frame. Value + is represented as meters per second squared.

+line: 110 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# pAccelerationZ diff --git a/src/content/reference/en/p5 copy/pRotationX.mdx b/src/content/reference/en/p5 copy/pRotationX.mdx new file mode 100644 index 0000000000..03d80f8ae5 --- /dev/null +++ b/src/content/reference/en/p5 copy/pRotationX.mdx @@ -0,0 +1,63 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L234 +title: pRotationX +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

The system variable pRotationX always contains the rotation of the + + device along the x axis in the frame previous to the current frame. + + If the sketch angleMode() is set to + DEGREES, + + the value will be -180 to 180. If it is set to RADIANS, the value will + + be -PI to PI.

+ +

pRotationX can also be used with rotationX to determine the rotate + + direction of the device along the X-axis.

+line: 234 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // A simple if statement looking at whether + // rotationX - pRotationX < 0 is true or not will be + // sufficient for determining the rotate direction + // in most cases. + + // Some extra logic is needed to account for cases where + // the angles wrap around. + let rotateDirection = 'clockwise'; + + // Simple range conversion to make things simpler. + // This is not absolutely necessary but the logic + // will be different in that case. + + let rX = rotationX + 180; + let pRX = pRotationX + 180; + + if ((rX - pRX > 0 && rX - pRX < 270) || rX - pRX < -270) { + rotateDirection = 'clockwise'; + } else if (rX - pRX < 0 || rX - pRX > 270) { + rotateDirection = 'counter-clockwise'; + } + + print(rotateDirection); + describe('no image to display.'); + +
+class: p5 +type: Number +--- + + +# pRotationX diff --git a/src/content/reference/en/p5 copy/pRotationY.mdx b/src/content/reference/en/p5 copy/pRotationY.mdx new file mode 100644 index 0000000000..3a15f47f43 --- /dev/null +++ b/src/content/reference/en/p5 copy/pRotationY.mdx @@ -0,0 +1,62 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L278 +title: pRotationY +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

The system variable pRotationY always contains the rotation of the + + device along the y axis in the frame previous to the current frame. + + If the sketch angleMode() is set to + DEGREES, + + the value will be -90 to 90. If it is set to RADIANS, the value will + + be -PI/2 to PI/2.

+ +

pRotationY can also be used with rotationY to determine the rotate + + direction of the device along the Y-axis.

+line: 278 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // A simple if statement looking at whether + // rotationY - pRotationY < 0 is true or not will be + // sufficient for determining the rotate direction + // in most cases. + + // Some extra logic is needed to account for cases where + // the angles wrap around. + let rotateDirection = 'clockwise'; + + // Simple range conversion to make things simpler. + // This is not absolutely necessary but the logic + // will be different in that case. + + let rY = rotationY + 180; + let pRY = pRotationY + 180; + + if ((rY - pRY > 0 && rY - pRY < 270) || rY - pRY < -270) { + rotateDirection = 'clockwise'; + } else if (rY - pRY < 0 || rY - pRY > 270) { + rotateDirection = 'counter-clockwise'; + } + print(rotateDirection); + describe('no image to display.'); + +
+class: p5 +type: Number +--- + + +# pRotationY diff --git a/src/content/reference/en/p5 copy/pRotationZ.mdx b/src/content/reference/en/p5 copy/pRotationZ.mdx new file mode 100644 index 0000000000..4ae6d5e63f --- /dev/null +++ b/src/content/reference/en/p5 copy/pRotationZ.mdx @@ -0,0 +1,58 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L321 +title: pRotationZ +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

The system variable pRotationZ always contains the rotation of the + + device along the z axis in the frame previous to the current frame. + + If the sketch angleMode() is set to + DEGREES, + + the value will be 0 to 360. If it is set to RADIANS, the value will + + be 0 to 2*PI.

+ +

pRotationZ can also be used with rotationZ to determine the rotate + + direction of the device along the Z-axis.

+line: 321 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // A simple if statement looking at whether + // rotationZ - pRotationZ < 0 is true or not will be + // sufficient for determining the rotate direction + // in most cases. + + // Some extra logic is needed to account for cases where + // the angles wrap around. + let rotateDirection = 'clockwise'; + + if ( + (rotationZ - pRotationZ > 0 && rotationZ - pRotationZ < 270) || + rotationZ - pRotationZ < -270 + ) { + rotateDirection = 'clockwise'; + } else if (rotationZ - pRotationZ < 0 || rotationZ - pRotationZ > 270) { + rotateDirection = 'counter-clockwise'; + } + print(rotateDirection); + describe('no image to display.'); + +
+class: p5 +type: Number +--- + + +# pRotationZ diff --git a/src/content/reference/en/p5 copy/paletteLerp.mdx b/src/content/reference/en/p5 copy/paletteLerp.mdx new file mode 100644 index 0000000000..54e8c9f885 --- /dev/null +++ b/src/content/reference/en/p5 copy/paletteLerp.mdx @@ -0,0 +1,66 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L1079 +title: paletteLerp +module: Color +submodule: Creating & Reading +file: src/color/creating_reading.js +description: > +

Blends multiple colors to find a color between them.

+ +

The amt parameter specifies the amount to interpolate between + the color + + stops which are colors at each amt value "location" with + amt values + + that are between 2 color stops interpolating between them based on its + relative + + distance to both.

+ +

The way that colors are interpolated depends on the current + + colorMode().

+line: 1079 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(400, 400); + } + + function draw() { + // The background goes from white to red to green to blue fill + background(paletteLerp([ + ['white', 0], + ['red', 0.05], + ['green', 0.25], + ['blue', 1] + ], millis() / 10000 % 1)); + } + +
+class: p5 +params: + - name: colors_stops + description: | +

color stops to interpolate from

+ type: '[p5.Color, Number][]' + - name: amt + description: | +

number to use to interpolate relative to color stops

+ type: Number +return: + description: interpolated color. + type: p5.Color +chainable: false +--- + + +# paletteLerp diff --git a/src/content/reference/en/p5 copy/panorama.mdx b/src/content/reference/en/p5 copy/panorama.mdx new file mode 100644 index 0000000000..97ee1fd9ca --- /dev/null +++ b/src/content/reference/en/p5 copy/panorama.mdx @@ -0,0 +1,76 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L1021 +title: panorama +module: 3D +submodule: Lights +file: src/webgl/light.js +description: > +

Creates an immersive 3D background.

+ +

panorama() transforms images containing 360˚ content, such as + maps or + + HDRIs, into immersive 3D backgrounds that surround a sketch. Exploring the + + space requires changing the camera's perspective with functions such as + + orbitControl() or + + camera().

+line: 1021 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + let img; + + // Load an image and create a p5.Image object. + function preload() { + img = loadImage('/assets/outdoor_spheremap.jpg'); + } + + function setup() { + createCanvas(100 ,100 ,WEBGL); + + describe('A sphere floating above a landscape. The surface of the sphere reflects the landscape. The full landscape is viewable in 3D as the user drags the mouse.'); + } + + function draw() { + // Add the panorama. + panorama(img); + + // Enable orbiting with the mouse. + orbitControl(); + + // Use the image as a light source. + imageLight(img); + + // Style the sphere. + noStroke(); + specularMaterial(50); + shininess(200); + metalness(100); + + // Draw the sphere. + sphere(30); + } + +
+class: p5 +params: + - name: img + description: | +

360˚ image to use as the background.

+ type: p5.Image +chainable: false +--- + + +# panorama diff --git a/src/content/reference/en/p5 copy/perspective.mdx b/src/content/reference/en/p5 copy/perspective.mdx new file mode 100644 index 0000000000..21cca35746 --- /dev/null +++ b/src/content/reference/en/p5 copy/perspective.mdx @@ -0,0 +1,194 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L148 +title: perspective +module: 3D +submodule: Camera +file: src/webgl/p5.Camera.js +description: > +

Sets a perspective projection for the current camera in a 3D sketch.

+ +

In a perspective projection, shapes that are further from the camera appear + + smaller than shapes that are near the camera. This technique, called + + foreshortening, creates realistic 3D scenes. It’s applied by default in + + WebGL mode.

+ +

perspective() changes the camera’s perspective by changing its + viewing + + frustum. The frustum is the volume of space that’s visible to the camera. + + Its shape is a pyramid with its top cut off. The camera is placed where + + the top of the pyramid should be and views everything between the frustum’s + + top (near) plane and its bottom (far) plane.

+ +

The first parameter, fovy, is the camera’s vertical field of + view. It’s + + an angle that describes how tall or narrow a view the camera has. For + + example, calling perspective(0.5) sets the camera’s vertical + field of + + view to 0.5 radians. By default, fovy is calculated based on the + sketch’s + + height and the camera’s default z-coordinate, which is 800. The formula for + + the default fovy is 2 * atan(height / 2 / 800).

+ +

The second parameter, aspect, is the camera’s aspect ratio. + It’s a number + + that describes the ratio of the top plane’s width to its height. For + + example, calling perspective(0.5, 1.5) sets the camera’s field of + view to + + 0.5 radians and aspect ratio to 1.5, which would make shapes appear thinner + + on a square canvas. By default, aspect is set to width / + height.

+ +

The third parameter, near, is the distance from the camera to + the near + + plane. For example, calling perspective(0.5, 1.5, 100) sets the + camera’s + + field of view to 0.5 radians, its aspect ratio to 1.5, and places the near + + plane 100 pixels from the camera. Any shapes drawn less than 100 pixels + + from the camera won’t be visible. By default, near is set to 0.1 * + 800, + + which is 1/10th the default distance between the camera and the origin.

+ +

The fourth parameter, far, is the distance from the camera to + the far + + plane. For example, calling perspective(0.5, 1.5, 100, 10000) + sets the + + camera’s field of view to 0.5 radians, its aspect ratio to 1.5, places the + + near plane 100 pixels from the camera, and places the far plane 10,000 + + pixels from the camera. Any shapes drawn more than 10,000 pixels from the + + camera won’t be visible. By default, far is set to 10 * 800, + which is 10 + + times the default distance between the camera and the origin.

+ +

Note: perspective() can only be used in WebGL mode.

+line: 148 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Double-click to squeeze the box. + + let isSqueezed = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white rectangular prism on a gray background. The box appears to become thinner when the user double-clicks.'); + } + + function draw() { + background(200); + + // Place the camera at the top-right. + camera(400, -400, 800); + + if (isSqueezed === true) { + // Set fovy to 0.2. + // Set aspect to 1.5. + perspective(0.2, 1.5); + } + + // Draw the box. + box(); + } + + // Change the camera's perspective when the user double-clicks. + function doubleClicked() { + isSqueezed = true; + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white rectangular prism on a gray background. The prism moves away from the camera until it disappears.'); + } + + function draw() { + background(200); + + // Place the camera at the top-right. + camera(400, -400, 800); + + // Set fovy to 0.2. + // Set aspect to 1.5. + // Set near to 600. + // Set far to 1200. + perspective(0.2, 1.5, 600, 1200); + + // Move the origin away from the camera. + let x = -frameCount; + let y = frameCount; + let z = -2 * frameCount; + translate(x, y, z); + + // Draw the box. + box(); + } + +
+class: p5 +params: + - name: fovy + description: | +

camera frustum vertical field of view. Defaults to + 2 * atan(height / 2 / 800).

+ type: Number + optional: true + - name: aspect + description: | +

camera frustum aspect ratio. Defaults to + width / height.

+ type: Number + optional: true + - name: near + description: | +

distance from the camera to the near clipping plane. + Defaults to 0.1 * 800.

+ type: Number + optional: true + - name: far + description: | +

distance from the camera to the far clipping plane. + Defaults to 10 * 800.

+ type: Number + optional: true +chainable: true +--- + + +# perspective diff --git a/src/content/reference/en/p5 copy/pixelDensity.mdx b/src/content/reference/en/p5 copy/pixelDensity.mdx new file mode 100644 index 0000000000..808ebab227 --- /dev/null +++ b/src/content/reference/en/p5 copy/pixelDensity.mdx @@ -0,0 +1,90 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L1005 +title: pixelDensity +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

Sets the pixel density or returns the current density.

+ +

Computer displays are grids of little lights called pixels. A + + display's pixel density describes how many pixels it packs into an + + area. Displays with smaller pixels have a higher pixel density and create + + sharper images.

+ +

pixelDensity() sets the pixel scaling for high pixel density + displays. + + By default, the pixel density is set to match the display's density. + + Calling pixelDensity(1) turn this off.

+ +

Calling pixelDensity() without an argument returns the current + pixel + + density.

+line: 1005 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + // Set the pixel density to 1. + pixelDensity(1); + + // Create a canvas and draw + // a circle. + createCanvas(100, 100); + background(200); + circle(50, 50, 70); + + describe('A fuzzy white circle on a gray canvas.'); + } + +
+ +
+ + function setup() { + // Set the pixel density to 3. + pixelDensity(3); + + // Create a canvas, paint the + // background, and draw a + // circle. + createCanvas(100, 100); + background(200); + circle(50, 50, 70); + + describe('A sharp white circle on a gray canvas.'); + } + +
+class: p5 +overloads: + - line: 1005 + params: + - name: val + description: | +

desired pixel density.

+ type: Number + optional: true + chainable: 1 + - line: 1059 + params: [] + return: + description: current pixel density of the sketch. + type: Number +chainable: true +--- + + +# pixelDensity diff --git a/src/content/reference/en/p5 copy/pixels.mdx b/src/content/reference/en/p5 copy/pixels.mdx new file mode 100644 index 0000000000..7185d708bf --- /dev/null +++ b/src/content/reference/en/p5 copy/pixels.mdx @@ -0,0 +1,173 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L12 +title: pixels +module: Image +submodule: Pixels +file: src/image/pixels.js +description: > +

An array containing the color of each pixel on the canvas.

+ +

Colors are stored as numbers representing red, green, blue, and alpha + + (RGBA) values. pixels is a one-dimensional array for performance + reasons.

+ +

Each pixel occupies four elements in the pixels array, one for + each RGBA + + value. For example, the pixel at coordinates (0, 0) stores its RGBA values + + at pixels[0], pixels[1], pixels[2], and + pixels[3], respectively. + + The next pixel at coordinates (1, 0) stores its RGBA values at + pixels[4], + + pixels[5], pixels[6], and pixels[7]. + And so on. The pixels array + + for a 100×100 canvas has 100 × 100 × 4 = 40,000 elements.

+ +

Some displays use several smaller pixels to set the color at a single + + point. The pixelDensity() function + returns + + the pixel density of the canvas. High density displays often have a + + pixelDensity() of 2. On such a + display, the + + pixels array for a 100×100 canvas has 200 × 200 × 4 = + + 160,000 elements.

+ +

Accessing the RGBA values for a point on the canvas requires a little math + + as shown below. The loadPixels() + function + + must be called before accessing the pixels array. The + + updatePixels() function must be + called + + after any changes are made.

+line: 12 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Load the pixels array. + loadPixels(); + + // Set the dot's coordinates. + let x = 50; + let y = 50; + + // Get the pixel density. + let d = pixelDensity(); + + // Set the pixel(s) at the center of the canvas black. + for (let i = 0; i < d; i += 1) { + for (let j = 0; j < d; j += 1) { + let index = 4 * ((y * d + j) * width * d + (x * d + i)); + // Red. + pixels[index] = 0; + // Green. + pixels[index + 1] = 0; + // Blue. + pixels[index + 2] = 0; + // Alpha. + pixels[index + 3] = 255; + } + } + + // Update the canvas. + updatePixels(); + + describe('A black dot in the middle of a gray rectangle.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Load the pixels array. + loadPixels(); + + // Get the pixel density. + let d = pixelDensity(); + + // Calculate the halfway index in the pixels array. + let halfImage = 4 * (d * width) * (d * height / 2); + + // Make the top half of the canvas red. + for (let i = 0; i < halfImage; i += 4) { + // Red. + pixels[i] = 255; + // Green. + pixels[i + 1] = 0; + // Blue. + pixels[i + 2] = 0; + // Alpha. + pixels[i + 3] = 255; + } + + // Update the canvas. + updatePixels(); + + describe('A red rectangle drawn above a gray rectangle.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Create a p5.Color object. + let pink = color(255, 102, 204); + + // Load the pixels array. + loadPixels(); + + // Get the pixel density. + let d = pixelDensity(); + + // Calculate the halfway index in the pixels array. + let halfImage = 4 * (d * width) * (d * height / 2); + + // Make the top half of the canvas red. + for (let i = 0; i < halfImage; i += 4) { + pixels[i] = red(pink); + pixels[i + 1] = green(pink); + pixels[i + 2] = blue(pink); + pixels[i + 3] = alpha(pink); + } + + // Update the canvas. + updatePixels(); + + describe('A pink rectangle drawn above a gray rectangle.'); + } + +
+class: p5 +type: 'Number[]' +--- + + +# pixels diff --git a/src/content/reference/en/p5 copy/plane.mdx b/src/content/reference/en/p5 copy/plane.mdx new file mode 100644 index 0000000000..eefeb29b7a --- /dev/null +++ b/src/content/reference/en/p5 copy/plane.mdx @@ -0,0 +1,152 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L866 +title: plane +module: Shape +submodule: 3D Primitives +file: src/webgl/3d_primitives.js +description: > +

Draws a plane.

+ +

A plane is a four-sided, flat shape with every angle measuring 90˚. It’s + + similar to a rectangle and offers advanced drawing features in WebGL mode.

+ +

The first parameter, width, is optional. If a + Number is passed, as in + + plane(20), it sets the plane’s width and height. By default, + width is + + 50.

+ +

The second parameter, height, is also optional. If a + Number is passed, + + as in plane(20, 30), it sets the plane’s height. By default, + height is + + set to the plane’s width.

+ +

The third parameter, detailX, is also optional. If a + Number is passed, + + as in plane(20, 30, 5) it sets the number of triangle + subdivisions to use + + along the x-axis. All 3D shapes are made by connecting triangles to form + + their surfaces. By default, detailX is 1.

+ +

The fourth parameter, detailY, is also optional. If a + Number is passed, + + as in plane(20, 30, 5, 7) it sets the number of triangle + subdivisions to + + use along the y-axis. All 3D shapes are made by connecting triangles to + + form their surfaces. By default, detailY is 1.

+ +

Note: plane() can only be used in WebGL mode.

+line: 866 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white plane on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the plane. + plane(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white plane on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the plane. + // Set its width and height to 30. + plane(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white plane on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the plane. + // Set its width to 30 and height to 50. + plane(30, 50); + } + +
+class: p5 +params: + - name: width + description: | +

width of the plane.

+ type: Number + optional: true + - name: height + description: | +

height of the plane.

+ type: Number + optional: true + - name: detailX + description: | +

number of triangle subdivisions along the x-axis.

+ type: Integer + optional: true + - name: detailY + description: | +

number of triangle subdivisions along the y-axis.

+ type: Integer + optional: true +chainable: true +--- + + +# plane diff --git a/src/content/reference/en/p5 copy/pmouseX.mdx b/src/content/reference/en/p5 copy/pmouseX.mdx new file mode 100644 index 0000000000..5f5e8ff7f7 --- /dev/null +++ b/src/content/reference/en/p5 copy/pmouseX.mdx @@ -0,0 +1,88 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L333 +title: pmouseX +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A Number system variable that tracks the mouse's previous + horizontal + + position.

+ +

pmouseX keeps track of the mouse's position relative to the + + top-left corner of the canvas. Its value is + + mouseX from the previous frame. For + example, if + + the mouse was 50 pixels from the left edge of the canvas during the last + + frame, then pmouseX will be 50.

+ +

If touch is used instead of the mouse, then pmouseX will hold + the + + x-coordinate of the last touch point.

+ +

Note: pmouseX is reset to the current mouseX + + value at the start of each touch event.

+line: 333 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Slow the frame rate. + frameRate(10); + + describe('A line follows the mouse as it moves. The line grows longer with faster movements.'); + } + + function draw() { + background(200); + + line(pmouseX, pmouseY, mouseX, mouseY); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A line follows the mouse as it moves. The line grows longer with faster movements.'); + } + + function draw() { + background(200); + + // Adjust coordinates for WebGL mode. + // The origin (0, 0) is at the center of the canvas. + let pmx = pmouseX - 50; + let pmy = pmouseY - 50; + let mx = mouseX - 50; + let my = mouseY - 50; + + // Draw the line. + line(pmx, pmy, mx, my); + } + +
+class: p5 +type: Number +--- + + +# pmouseX diff --git a/src/content/reference/en/p5 copy/pmouseY.mdx b/src/content/reference/en/p5 copy/pmouseY.mdx new file mode 100644 index 0000000000..558747e43f --- /dev/null +++ b/src/content/reference/en/p5 copy/pmouseY.mdx @@ -0,0 +1,88 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L398 +title: pmouseY +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A Number system variable that tracks the mouse's previous + vertical + + position.

+ +

pmouseY keeps track of the mouse's position relative to the + + top-left corner of the canvas. Its value is + + mouseY from the previous frame. For + example, if + + the mouse was 50 pixels from the top edge of the canvas during the last + + frame, then pmouseY will be 50.

+ +

If touch is used instead of the mouse, then pmouseY will hold + the + + y-coordinate of the last touch point.

+ +

Note: pmouseY is reset to the current mouseY + + value at the start of each touch event.

+line: 398 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Slow the frame rate. + frameRate(10); + + describe('A line follows the mouse as it moves. The line grows longer with faster movements.'); + } + + function draw() { + background(200); + + line(pmouseX, pmouseY, mouseX, mouseY); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A line follows the mouse as it moves. The line grows longer with faster movements.'); + } + + function draw() { + background(200); + + // Adjust coordinates for WebGL mode. + // The origin (0, 0) is at the center of the canvas. + let pmx = pmouseX - 50; + let pmy = pmouseY - 50; + let mx = mouseX - 50; + let my = mouseY - 50; + + // Draw the line. + line(pmx, pmy, mx, my); + } + +
+class: p5 +type: Number +--- + + +# pmouseY diff --git a/src/content/reference/en/p5 copy/point.mdx b/src/content/reference/en/p5 copy/point.mdx new file mode 100644 index 0000000000..7912c06cbb --- /dev/null +++ b/src/content/reference/en/p5 copy/point.mdx @@ -0,0 +1,229 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L721 +title: point +module: Shape +submodule: 2D Primitives +file: src/core/shape/2d_primitives.js +description: > +

Draws a single point in space.

+ +

A point's default width is one pixel. To color a point, use the + + stroke() function. To change its width, + use the + + strokeWeight() function. A point + + can't be filled, so the fill() function + won't + + affect the point's color.

+ +

The version of point() with two parameters allows the point's + location to + + be set with its x- and y-coordinates, as in point(10, 20).

+ +

The version of point() with three parameters allows the point + to be drawn + + in 3D space with x-, y-, and z-coordinates, as in point(10, 20, + 30). + + Doing so requires adding the WEBGL argument to + + createCanvas().

+ +

The version of point() with one parameter allows the point's + location to + + be set with a p5.Vector object.

+line: 721 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + + // Making point to 5 pixels + strokeWeight(5); + + + // Top-left. + point(30, 20); + + // Top-right. + point(85, 20); + + // Bottom-right. + point(85, 75); + + // Bottom-left. + point(30, 75); + + describe( + 'Four small, black points drawn on a gray canvas. The points form the corners of a square.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + + // Making point to 5 pixels. + strokeWeight(5); + + + // Top-left. + point(30, 20); + + // Top-right. + point(70, 20); + + // Style the next points. + stroke('purple'); + strokeWeight(10); + + // Bottom-right. + point(70, 80); + + // Bottom-left. + point(30, 80); + + describe( + 'Four points drawn on a gray canvas. Two are black and two are purple. The points form the corners of a square.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + + // Making point to 5 pixels. + strokeWeight(5); + + + // Top-left. + let a = createVector(30, 20); + point(a); + + // Top-right. + let b = createVector(70, 20); + point(b); + + // Bottom-right. + let c = createVector(70, 80); + point(c); + + // Bottom-left. + let d = createVector(30, 80); + point(d); + + describe( + 'Four small, black points drawn on a gray canvas. The points form the corners of a square.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('Two purple points drawn on a gray canvas.'); + } + + function draw() { + background(200); + + // Style the points. + stroke('purple'); + strokeWeight(10); + + // Top-left. + point(-20, -30); + + // Bottom-right. + point(20, 30); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('Two purple points drawn on a gray canvas. The scene spins slowly.'); + } + + function draw() { + background(200); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Style the points. + stroke('purple'); + strokeWeight(10); + + // Top-left. + point(-20, -30, 0); + + // Bottom-right. + point(20, 30, -50); + } + +
+class: p5 +overloads: + - line: 721 + params: + - name: x + description: | +

the x-coordinate.

+ type: Number + - name: 'y' + description: | +

the y-coordinate.

+ type: Number + - name: z + description: | +

the z-coordinate (for WebGL mode).

+ type: Number + optional: true + chainable: 1 + - line: 900 + params: + - name: coordinateVector + description: | +

the coordinate vector.

+ type: p5.Vector + chainable: 1 +chainable: true +--- + + +# point diff --git a/src/content/reference/en/p5 copy/pointLight.mdx b/src/content/reference/en/p5 copy/pointLight.mdx new file mode 100644 index 0000000000..c6f10715b9 --- /dev/null +++ b/src/content/reference/en/p5 copy/pointLight.mdx @@ -0,0 +1,329 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L683 +title: pointLight +module: 3D +submodule: Lights +file: src/webgl/light.js +description: > +

Creates a light that shines from a point in all directions.

+ +

Point lights are like light bulbs that shine in all directions. They can be + + placed at different positions to achieve different lighting effects. A + + maximum of 5 point lights can be active at once.

+ +

There are four ways to call pointLight() with parameters to + set the + + light’s color and position.

+ +

The first way to call pointLight() has six parameters. The + first three + + parameters, v1, v2, and v3, set the + light’s color using the current + + colorMode(). The last three parameters, + x, + + y, and z, set the light’s position. For example, + + pointLight(255, 0, 0, 50, 0, 0) creates a red (255, 0, + 0) light that + + shines from the coordinates (50, 0, 0).

+ +

The second way to call pointLight() has four parameters. The + first three + + parameters, v1, v2, and v3, set the + light’s color using the current + + colorMode(). The last parameter, + position sets + + the light’s position using a p5.Vector + object. + + For example, pointLight(255, 0, 0, lightPos) creates a red + (255, 0, 0) + + light that shines from the position set by the lightPos + vector.

+ +

The third way to call pointLight() has four parameters. The + first + + parameter, color, sets the light’s color using a + + p5.Color object or an array of color + values. The + + last three parameters, x, y, and z, set + the light’s position. For + + example, directionalLight(myColor, 50, 0, 0) creates a light that + shines + + from the coordinates (50, 0, 0) with the color value of + myColor.

+ +

The fourth way to call pointLight() has two parameters. The + first + + parameter, color, sets the light’s color using a + + p5.Color object or an array of color + values. The + + second parameter, position, sets the light’s position using a + + p5.Vector object. For example, + + directionalLight(myColor, lightPos) creates a light that shines + from the + + position set by the lightPos vector with the color value of + myColor.

+line: 683 +isConstructor: false +itemtype: method +example: + - |- + + +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click to turn on the point light. + + let isLit = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A sphere drawn on a gray background. A red light starts shining from above when the user double-clicks.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Control the light. + if (isLit === true) { + // Add a red point light from above. + // Use RGB values and XYZ coordinates. + pointLight(255, 0, 0, 0, -150, 0); + } + + // Style the sphere. + noStroke(); + + // Draw the sphere. + sphere(30); + } + + // Turn on the point light when the user double-clicks. + function doubleClicked() { + isLit = true; + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Add a red point light from above. + // Use a p5.Color object and XYZ directions. + let c = color(255, 0, 0); + pointLight(c, 0, -150, 0); + + // Style the sphere. + noStroke(); + + // Draw the sphere. + sphere(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Add a red point light from above. + // Use a p5.Color object and a p5.Vector object. + let c = color(255, 0, 0); + let lightPos = createVector(0, -150, 0); + pointLight(c, lightPos); + + // Style the sphere. + noStroke(); + + // Draw the sphere. + sphere(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('Four spheres arranged in a square and drawn on a gray background. The spheres appear bright red toward the center of the square. The color gets darker toward the corners of the square.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Add a red point light that points to the center of the scene. + // Use a p5.Color object and a p5.Vector object. + let c = color(255, 0, 0); + let lightPos = createVector(0, 0, 65); + pointLight(c, lightPos); + + // Style the spheres. + noStroke(); + + // Draw a sphere up and to the left. + push(); + translate(-25, -25, 25); + sphere(10); + pop(); + + // Draw a box up and to the right. + push(); + translate(25, -25, 25); + sphere(10); + pop(); + + // Draw a sphere down and to the left. + push(); + translate(-25, 25, 25); + sphere(10); + pop(); + + // Draw a box down and to the right. + push(); + translate(25, 25, 25); + sphere(10); + pop(); + } + +
+class: p5 +overloads: + - line: 683 + params: + - name: v1 + description: | +

red or hue value in the current + colorMode().

+ type: Number + - name: v2 + description: | +

green or saturation value in the current + colorMode().

+ type: Number + - name: v3 + description: | +

blue, brightness, or lightness value in the current + colorMode().

+ type: Number + - name: x + description: | +

x-coordinate of the light.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the light.

+ type: Number + - name: z + description: | +

z-coordinate of the light.

+ type: Number + chainable: 1 + - line: 890 + params: + - name: v1 + description: '' + type: Number + - name: v2 + description: '' + type: Number + - name: v3 + description: '' + type: Number + - name: position + description: | +

position of the light as a + p5.Vector object.

+ type: p5.Vector + chainable: 1 + - line: 900 + params: + - name: color + description: | +

color as a p5.Color object, + an array of color values, or a CSS string.

+ type: 'p5.Color|Number[]|String' + - name: x + description: '' + type: Number + - name: 'y' + description: '' + type: Number + - name: z + description: '' + type: Number + chainable: 1 + - line: 910 + params: + - name: color + description: '' + type: 'p5.Color|Number[]|String' + - name: position + description: '' + type: p5.Vector + chainable: 1 +chainable: true +--- + + +# pointLight diff --git a/src/content/reference/en/p5 copy/pop.mdx b/src/content/reference/en/p5 copy/pop.mdx new file mode 100644 index 0000000000..72b5c1db21 --- /dev/null +++ b/src/content/reference/en/p5 copy/pop.mdx @@ -0,0 +1,20 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L553 +title: pop +module: Structure +submodule: Structure +file: src/core/structure.js +description: "

Ends a drawing group that contains its own styles and transformations.

\n

By default, styles such as fill() and\ntransformations such as rotate() are applied to\nall drawing that follows. The push() and pop()\nfunctions can limit the effect of styles and transformations to a specific\ngroup of shapes, images, and text. For example, a group of shapes could be\ntranslated to follow the mouse without affecting the rest of the sketch:

\n
// Begin the drawing group.\npush();\n\n// Translate the origin to the mouse's position.\ntranslate(mouseX, mouseY);\n\n// Style the face.\nnoStroke();\nfill('green');\n\n// Draw the face.\ncircle(0, 0, 60);\n\n// Style the eyes.\nfill('white');\n\n// Draw the left eye.\nellipse(-20, -20, 30, 20);\n\n// Draw the right eye.\nellipse(20, -20, 30, 20);\n\n// End the drawing group.\npop();\n\n// Draw a bug.\nlet x = random(0, 100);\nlet y = random(0, 100);\ntext('\U0001F99F', x, y);\n
\n

In the code snippet above, the bug's position isn't affected by\ntranslate(mouseX, mouseY) because that transformation is contained\nbetween push() and pop(). The bug moves around\nthe entire canvas as expected.

\n

Note: push() and pop() are always called as a\npair. Both functions are required to begin and end a drawing group.

\n

push() and pop() can also be nested to create\nsubgroups. For example, the code snippet above could be changed to give\nmore detail to the frog’s eyes:

\n
// Begin the drawing group.\npush();\n\n// Translate the origin to the mouse's position.\ntranslate(mouseX, mouseY);\n\n// Style the face.\nnoStroke();\nfill('green');\n\n// Draw a face.\ncircle(0, 0, 60);\n\n// Style the eyes.\nfill('white');\n\n// Draw the left eye.\npush();\ntranslate(-20, -20);\nellipse(0, 0, 30, 20);\nfill('black');\ncircle(0, 0, 8);\npop();\n\n// Draw the right eye.\npush();\ntranslate(20, -20);\nellipse(0, 0, 30, 20);\nfill('black');\ncircle(0, 0, 8);\npop();\n\n// End the drawing group.\npop();\n\n// Draw a bug.\nlet x = random(0, 100);\nlet y = random(0, 100);\ntext('\U0001F99F', x, y);\n
\n

In this version, the code to draw each eye is contained between its own\npush() and pop() functions. Doing so makes it\neasier to add details in the correct part of a drawing.

\n

push() and pop() contain the effects of the\nfollowing functions:

\n\n

In WebGL mode, push() and pop() contain the\neffects of a few additional styles:

\n\n" +line: 553 +isConstructor: false +itemtype: method +example: + - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Draw the left circle.\n circle(25, 50, 20);\n\n // Begin the drawing group.\n push();\n\n // Translate the origin to the center.\n translate(50, 50);\n\n // Style the circle.\n strokeWeight(5);\n stroke('royalblue');\n fill('orange');\n\n // Draw the circle.\n circle(0, 0, 20);\n\n // End the drawing group.\n pop();\n\n // Draw the right circle.\n circle(75, 50, 20);\n\n describe(\n 'Three circles drawn in a row on a gray background. The left and right circles are white with thin, black borders. The middle circle is orange with a thick, blue border.'\n );\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Slow the frame rate.\n frameRate(24);\n\n describe('A mosquito buzzes in front of a green frog. The frog follows the mouse as the user moves.');\n}\n\nfunction draw() {\n background(200);\n\n // Begin the drawing group.\n push();\n\n // Translate the origin to the mouse's position.\n translate(mouseX, mouseY);\n\n // Style the face.\n noStroke();\n fill('green');\n\n // Draw a face.\n circle(0, 0, 60);\n\n // Style the eyes.\n fill('white');\n\n // Draw the left eye.\n push();\n translate(-20, -20);\n ellipse(0, 0, 30, 20);\n fill('black');\n circle(0, 0, 8);\n pop();\n\n // Draw the right eye.\n push();\n translate(20, -20);\n ellipse(0, 0, 30, 20);\n fill('black');\n circle(0, 0, 8);\n pop();\n\n // End the drawing group.\n pop();\n\n // Draw a bug.\n let x = random(0, 100);\n let y = random(0, 100);\n text('\U0001F99F', x, y);\n}\n\n
\n\n
\n\n// Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n\n describe(\n 'Two spheres drawn on a gray background. The sphere on the left is red and lit from the front. The sphere on the right is a blue wireframe.'\n );\n}\n\nfunction draw() {\n background(200);\n\n // Enable orbiting with the mouse.\n orbitControl();\n\n // Draw the red sphere.\n push();\n translate(-25, 0, 0);\n noStroke();\n directionalLight(255, 0, 0, 0, 0, -1);\n sphere(20);\n pop();\n\n // Draw the blue sphere.\n push();\n translate(25, 0, 0);\n strokeWeight(0.3);\n stroke(0, 0, 255);\n noFill();\n sphere(20);\n pop();\n}\n\n
" +class: p5 +chainable: false +--- + + +# pop diff --git a/src/content/reference/en/p5 copy/pow.mdx b/src/content/reference/en/p5 copy/pow.mdx new file mode 100644 index 0000000000..18201ec3c2 --- /dev/null +++ b/src/content/reference/en/p5 copy/pow.mdx @@ -0,0 +1,67 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L815 +title: pow +module: Math +submodule: Calculation +file: src/math/calculation.js +description: | +

Calculates exponential expressions such as 23.

+

For example, pow(2, 3) evaluates the expression + 2 × 2 × 2. pow(2, -3) evaluates 1 ÷ + (2 × 2 × 2).

+line: 815 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Set the base of the exponent. + let base = 3; + + // Top-left. + let d = pow(base, 1); + circle(10, 10, d); + + // Left-center. + d = pow(base, 2); + circle(20, 20, d); + + // Right-center. + d = pow(base, 3); + circle(40, 40, d); + + // Bottom-right. + d = pow(base, 4); + circle(80, 80, d); + + describe('A series of circles that grow exponentially from top left to bottom right.'); + } + +
+class: p5 +params: + - name: 'n' + description: | +

base of the exponential expression.

+ type: Number + - name: e + description: | +

power by which to raise the base.

+ type: Number +return: + description: n^e. + type: Number +chainable: false +--- + + +# pow diff --git a/src/content/reference/en/p5 copy/preload.mdx b/src/content/reference/en/p5 copy/preload.mdx new file mode 100644 index 0000000000..66d5db4378 --- /dev/null +++ b/src/content/reference/en/p5 copy/preload.mdx @@ -0,0 +1,70 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L41 +title: preload +module: Structure +submodule: Structure +file: src/core/main.js +description: > +

A function that's called once to load assets before the sketch runs.

+ +

Declaring the function preload() sets a code block to run once + + automatically before setup() or + + draw(). It's used to load assets including + + multimedia files, fonts, data, and 3D models:

+ +
function preload() {
+    // Code to run before the rest of the sketch.
+  }
+
+  
+ +

Functions such as loadImage(), + + loadFont(), + + loadJSON(), and + + loadModel() are guaranteed to either + + finish loading or raise an error if they're called within + preload(). + + Doing so ensures that assets are available when the sketch begins + + running.

+line: 41 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load an image and create a p5.Image object. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Draw the image. + image(img, 0, 0); + + describe('A red brick wall.'); + } + +
+class: p5 +chainable: false +--- + + +# preload diff --git a/src/content/reference/en/p5 copy/print.mdx b/src/content/reference/en/p5 copy/print.mdx new file mode 100644 index 0000000000..50137586ae --- /dev/null +++ b/src/content/reference/en/p5 copy/print.mdx @@ -0,0 +1,55 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L21 +title: print +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

Displays text in the web browser's console.

+ +

print() is helpful for printing values while debugging. Each + call to + + print() creates a new line of text.

+ +

Note: Call print('\n') to print a blank line. Calling + print() without + + an argument opens the browser's dialog for printing documents.

+line: 21 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + // Prints "hello, world" to the console. + print('hello, world'); + } + +
+ +
+ + function setup() { + let name = 'ada'; + // Prints "hello, ada" to the console. + print(`hello, ${name}`); + } + +
+class: p5 +params: + - name: contents + description: | +

content to print to the console.

+ type: Any +chainable: false +--- + + +# print diff --git a/src/content/reference/en/p5 copy/push.mdx b/src/content/reference/en/p5 copy/push.mdx new file mode 100644 index 0000000000..ee1a386cee --- /dev/null +++ b/src/content/reference/en/p5 copy/push.mdx @@ -0,0 +1,20 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L269 +title: push +module: Structure +submodule: Structure +file: src/core/structure.js +description: "

Begins a drawing group that contains its own styles and transformations.

\n

By default, styles such as fill() and\ntransformations such as rotate() are applied to\nall drawing that follows. The push() and pop()\nfunctions can limit the effect of styles and transformations to a specific\ngroup of shapes, images, and text. For example, a group of shapes could be\ntranslated to follow the mouse without affecting the rest of the sketch:

\n
// Begin the drawing group.\npush();\n\n// Translate the origin to the mouse's position.\ntranslate(mouseX, mouseY);\n\n// Style the face.\nnoStroke();\nfill('green');\n\n// Draw the face.\ncircle(0, 0, 60);\n\n// Style the eyes.\nfill('white');\n\n// Draw the left eye.\nellipse(-20, -20, 30, 20);\n\n// Draw the right eye.\nellipse(20, -20, 30, 20);\n\n// End the drawing group.\npop();\n\n// Draw a bug.\nlet x = random(0, 100);\nlet y = random(0, 100);\ntext('\U0001F99F', x, y);\n
\n

In the code snippet above, the bug's position isn't affected by\ntranslate(mouseX, mouseY) because that transformation is contained\nbetween push() and pop(). The bug moves around\nthe entire canvas as expected.

\n

Note: push() and pop() are always called as a\npair. Both functions are required to begin and end a drawing group.

\n

push() and pop() can also be nested to create\nsubgroups. For example, the code snippet above could be changed to give\nmore detail to the frog’s eyes:

\n
// Begin the drawing group.\npush();\n\n// Translate the origin to the mouse's position.\ntranslate(mouseX, mouseY);\n\n// Style the face.\nnoStroke();\nfill('green');\n\n// Draw a face.\ncircle(0, 0, 60);\n\n// Style the eyes.\nfill('white');\n\n// Draw the left eye.\npush();\ntranslate(-20, -20);\nellipse(0, 0, 30, 20);\nfill('black');\ncircle(0, 0, 8);\npop();\n\n// Draw the right eye.\npush();\ntranslate(20, -20);\nellipse(0, 0, 30, 20);\nfill('black');\ncircle(0, 0, 8);\npop();\n\n// End the drawing group.\npop();\n\n// Draw a bug.\nlet x = random(0, 100);\nlet y = random(0, 100);\ntext('\U0001F99F', x, y);\n
\n

In this version, the code to draw each eye is contained between its own\npush() and pop() functions. Doing so makes it\neasier to add details in the correct part of a drawing.

\n

push() and pop() contain the effects of the\nfollowing functions:

\n\n

In WebGL mode, push() and pop() contain the\neffects of a few additional styles:

\n\n" +line: 269 +isConstructor: false +itemtype: method +example: + - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Draw the left circle.\n circle(25, 50, 20);\n\n // Begin the drawing group.\n push();\n\n // Translate the origin to the center.\n translate(50, 50);\n\n // Style the circle.\n strokeWeight(5);\n stroke('royalblue');\n fill('orange');\n\n // Draw the circle.\n circle(0, 0, 20);\n\n // End the drawing group.\n pop();\n\n // Draw the right circle.\n circle(75, 50, 20);\n\n describe(\n 'Three circles drawn in a row on a gray background. The left and right circles are white with thin, black borders. The middle circle is orange with a thick, blue border.'\n );\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Slow the frame rate.\n frameRate(24);\n\n describe('A mosquito buzzes in front of a green frog. The frog follows the mouse as the user moves.');\n}\n\nfunction draw() {\n background(200);\n\n // Begin the drawing group.\n push();\n\n // Translate the origin to the mouse's position.\n translate(mouseX, mouseY);\n\n // Style the face.\n noStroke();\n fill('green');\n\n // Draw a face.\n circle(0, 0, 60);\n\n // Style the eyes.\n fill('white');\n\n // Draw the left eye.\n push();\n translate(-20, -20);\n ellipse(0, 0, 30, 20);\n fill('black');\n circle(0, 0, 8);\n pop();\n\n // Draw the right eye.\n push();\n translate(20, -20);\n ellipse(0, 0, 30, 20);\n fill('black');\n circle(0, 0, 8);\n pop();\n\n // End the drawing group.\n pop();\n\n // Draw a bug.\n let x = random(0, 100);\n let y = random(0, 100);\n text('\U0001F99F', x, y);\n}\n\n
\n\n
\n\n// Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n\n describe(\n 'Two spheres drawn on a gray background. The sphere on the left is red and lit from the front. The sphere on the right is a blue wireframe.'\n );\n}\n\nfunction draw() {\n background(200);\n\n // Enable orbiting with the mouse.\n orbitControl();\n\n // Draw the red sphere.\n push();\n translate(-25, 0, 0);\n noStroke();\n directionalLight(255, 0, 0, 0, 0, -1);\n sphere(20);\n pop();\n\n // Draw the blue sphere.\n push();\n translate(25, 0, 0);\n strokeWeight(0.3);\n stroke(0, 0, 255);\n noFill();\n sphere(20);\n pop();\n}\n\n
" +class: p5 +chainable: false +--- + + +# push diff --git a/src/content/reference/en/p5 copy/pwinMouseX.mdx b/src/content/reference/en/p5 copy/pwinMouseX.mdx new file mode 100644 index 0000000000..cb869aea71 --- /dev/null +++ b/src/content/reference/en/p5 copy/pwinMouseX.mdx @@ -0,0 +1,99 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L545 +title: pwinMouseX +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A Number variable that tracks the mouse's previous horizontal + position + + within the browser.

+ +

pwinMouseX keeps track of the mouse's position relative to the + top-left + + corner of the browser window. Its value is + + winMouseX from the previous frame. For + + example, if the mouse was 50 pixels from + + the left edge of the browser during the last frame, then + pwinMouseX will + + be 50.

+ +

On a touchscreen device, pwinMouseX will hold the x-coordinate + of the most + + recent touch point. pwinMouseX is reset to the current + + winMouseX value at the start of each + touch + + event.

+ +

Note: Use pmouseX to track the mouse’s + previous + + x-coordinate within the canvas.

+line: 545 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Slow the frame rate. + frameRate(10); + + describe('A gray square. A white circle at its center grows larger when the mouse moves horizontally.'); + } + + function draw() { + background(200); + + // Calculate the circle's diameter. + let d = winMouseX - pwinMouseX; + + // Draw the circle. + circle(50, 50, d); + } + +
+ +
+ + function setup() { + // Create the canvas and set its position. + let cnv = createCanvas(100, 100); + cnv.position(20, 20); + + describe('A gray square with a number at its center. The number changes as the user moves the mouse vertically.'); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display pwinMouseX. + text(pwinMouseX, 50, 50); + } + +
+class: p5 +type: Number +--- + + +# pwinMouseX diff --git a/src/content/reference/en/p5 copy/pwinMouseY.mdx b/src/content/reference/en/p5 copy/pwinMouseY.mdx new file mode 100644 index 0000000000..2f36580a23 --- /dev/null +++ b/src/content/reference/en/p5 copy/pwinMouseY.mdx @@ -0,0 +1,99 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L616 +title: pwinMouseY +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A Number variable that tracks the mouse's previous vertical + position + + within the browser.

+ +

pwinMouseY keeps track of the mouse's position relative to the + top-left + + corner of the browser window. Its value is + + winMouseY from the previous frame. For + + example, if the mouse was 50 pixels from + + the top edge of the browser during the last frame, then + pwinMouseY will + + be 50.

+ +

On a touchscreen device, pwinMouseY will hold the y-coordinate + of the most + + recent touch point. pwinMouseY is reset to the current + + winMouseY value at the start of each + touch + + event.

+ +

Note: Use pmouseY to track the mouse’s + previous + + y-coordinate within the canvas.

+line: 616 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Slow the frame rate. + frameRate(10); + + describe('A gray square. A white circle at its center grows larger when the mouse moves vertically.'); + } + + function draw() { + background(200); + + // Calculate the circle's diameter. + let d = winMouseY - pwinMouseY; + + // Draw the circle. + circle(50, 50, d); + } + +
+ +
+ + function setup() { + // Create the canvas and set its position. + let cnv = createCanvas(100, 100); + cnv.position(20, 20); + + describe('A gray square with a number at its center. The number changes as the user moves the mouse vertically.'); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display pwinMouseY. + text(pwinMouseY, 50, 50); + } + +
+class: p5 +type: Number +--- + + +# pwinMouseY diff --git a/src/content/reference/en/p5 copy/quad.mdx b/src/content/reference/en/p5 copy/quad.mdx new file mode 100644 index 0000000000..fbc09fa0a3 --- /dev/null +++ b/src/content/reference/en/p5 copy/quad.mdx @@ -0,0 +1,233 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L928 +title: quad +module: Shape +submodule: 2D Primitives +file: src/core/shape/2d_primitives.js +description: > +

Draws a quadrilateral (four-sided shape).

+ +

Quadrilaterals include rectangles, squares, rhombuses, and trapezoids. The + + first pair of parameters (x1, y1) sets the quad's first point. + The next + + three pairs of parameters set the coordinates for its next three points + + (x2, y2), (x3, y3), and (x4, y4). + Points should be added in either + + clockwise or counter-clockwise order.

+ +

The version of quad() with twelve parameters allows the quad + to be drawn + + in 3D space. Doing so requires adding the WEBGL argument to + + createCanvas().

+ +

The thirteenth and fourteenth parameters are optional. In WebGL mode, they + + set the number of segments used to draw the quadrilateral in the x- and + + y-directions. They're both 2 by default.

+line: 928 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + quad(20, 20, 80, 20, 80, 80, 20, 80); + + describe('A white square with a black outline drawn on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + quad(20, 30, 80, 30, 80, 70, 20, 70); + + describe('A white rectangle with a black outline drawn on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + quad(50, 62, 86, 50, 50, 38, 14, 50); + + describe('A white rhombus with a black outline drawn on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + quad(20, 50, 80, 30, 80, 70, 20, 70); + + describe('A white trapezoid with a black outline drawn on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + quad(-30, -30, 30, -30, 30, 30, -30, 30); + + describe('A white square with a black outline drawn on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A wavy white surface spins around on gray canvas.'); + } + + function draw() { + background(200); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Draw the quad. + quad(-30, -30, 0, 30, -30, 0, 30, 30, 20, -30, 30, -20); + } + +
+class: p5 +overloads: + - line: 928 + params: + - name: x1 + description: | +

the x-coordinate of the first point.

+ type: Number + - name: y1 + description: | +

the y-coordinate of the first point.

+ type: Number + - name: x2 + description: | +

the x-coordinate of the second point.

+ type: Number + - name: y2 + description: | +

the y-coordinate of the second point.

+ type: Number + - name: x3 + description: | +

the x-coordinate of the third point.

+ type: Number + - name: y3 + description: | +

the y-coordinate of the third point.

+ type: Number + - name: x4 + description: | +

the x-coordinate of the fourth point.

+ type: Number + - name: y4 + description: | +

the y-coordinate of the fourth point.

+ type: Number + - name: detailX + description: | +

number of segments in the x-direction.

+ type: Integer + optional: true + - name: detailY + description: | +

number of segments in the y-direction.

+ type: Integer + optional: true + chainable: 1 + - line: 1048 + params: + - name: x1 + description: '' + type: Number + - name: y1 + description: '' + type: Number + - name: z1 + description: | +

the z-coordinate of the first point.

+ type: Number + - name: x2 + description: '' + type: Number + - name: y2 + description: '' + type: Number + - name: z2 + description: | +

the z-coordinate of the second point.

+ type: Number + - name: x3 + description: '' + type: Number + - name: y3 + description: '' + type: Number + - name: z3 + description: | +

the z-coordinate of the third point.

+ type: Number + - name: x4 + description: '' + type: Number + - name: y4 + description: '' + type: Number + - name: z4 + description: | +

the z-coordinate of the fourth point.

+ type: Number + - name: detailX + description: '' + type: Integer + optional: true + - name: detailY + description: '' + type: Integer + optional: true + chainable: 1 +chainable: true +--- + + +# quad diff --git a/src/content/reference/en/p5 copy/quadraticVertex.mdx b/src/content/reference/en/p5 copy/quadraticVertex.mdx new file mode 100644 index 0000000000..e319e38769 --- /dev/null +++ b/src/content/reference/en/p5 copy/quadraticVertex.mdx @@ -0,0 +1,303 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L1600 +title: quadraticVertex +module: Shape +submodule: Vertex +file: src/core/shape/vertex.js +description: > +

Adds a quadratic Bézier curve segment to a custom shape.

+ +

quadraticVertex() adds a curved segment to custom shapes. The + Bézier + + curve segments it creates are similar to those made by the + + bezierVertex() function. + + quadraticVertex() must be called between the + + beginShape() and + + endShape() functions. The curved segment + uses + + the previous vertex as the first anchor point, so there must be at least + + one call to vertex() before + quadraticVertex() can + + be used.

+ +

The first two parameters, cx and cy, set the + curve’s control point. + + The control point "pulls" the curve towards its.

+ +

The last two parameters, x3, and y3, set the last + anchor point. The + + last anchor point is where the curve ends.

+ +

Bézier curves can also be drawn in 3D using WebGL mode. The 3D version of + + bezierVertex() has eight arguments because each point has x-, y-, + and + + z-coordinates.

+ +

Note: quadraticVertex() won’t work when an argument is passed + to + + beginShape().

+line: 1600 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the curve. + noFill(); + + // Draw the curve. + beginShape(); + vertex(20, 20); + quadraticVertex(80, 20, 50, 50); + endShape(); + + describe('A black curve drawn on a gray square. The curve starts at the top-left corner and ends at the center.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw the curve. + noFill(); + beginShape(); + vertex(20, 20); + quadraticVertex(80, 20, 50, 50); + endShape(); + + // Draw red lines from the anchor points to the control point. + stroke(255, 0, 0); + line(20, 20, 80, 20); + line(50, 50, 80, 20); + + // Draw the anchor points in black. + strokeWeight(5); + stroke(0); + point(20, 20); + point(50, 50); + + // Draw the control point in red. + stroke(255, 0, 0); + point(80, 20); + + describe('A black curve that starts at the top-left corner and ends at the center. Its anchor and control points are marked with dots. Red lines connect both anchor points to the control point.'); + } + +
+ +
+ + // Click the mouse near the red dot in the top-right corner + // and drag to change the curve's shape. + + let x2 = 80; + let y2 = 20; + let isChanging = false; + + function setup() { + createCanvas(100, 100); + + describe('A black curve that starts at the top-left corner and ends at the center. Its anchor and control points are marked with dots. Red lines connect both anchor points to the control point.'); + } + + function draw() { + background(200); + + // Style the curve. + noFill(); + strokeWeight(1); + stroke(0); + + // Draw the curve. + beginShape(); + vertex(20, 20); + quadraticVertex(x2, y2, 50, 50); + endShape(); + + // Draw red lines from the anchor points to the control point. + stroke(255, 0, 0); + line(20, 20, x2, y2); + line(50, 50, x2, y2); + + // Draw the anchor points in black. + strokeWeight(5); + stroke(0); + point(20, 20); + point(50, 50); + + // Draw the control point in red. + stroke(255, 0, 0); + point(x2, y2); + } + + // Start changing the first control point if the user clicks near it. + function mousePressed() { + if (dist(mouseX, mouseY, x2, y2) < 20) { + isChanging = true; + } + } + + // Stop changing the first control point when the user releases the mouse. + function mouseReleased() { + isChanging = false; + } + + // Update the first control point while the user drags the mouse. + function mouseDragged() { + if (isChanging === true) { + x2 = mouseX; + y2 = mouseY; + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + beginShape(); + + // Add the curved segments. + vertex(20, 20); + quadraticVertex(80, 20, 50, 50); + quadraticVertex(20, 80, 80, 80); + + // Add the straight segments. + vertex(80, 10); + vertex(20, 10); + vertex(20, 20); + + // Stop drawing the shape. + endShape(); + + describe('A white puzzle piece drawn on a gray background.'); + } + +
+ +
+ + // Click the and drag the mouse to view the scene from a different angle. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white puzzle piece on a dark gray background. When the user clicks and drags the scene, the outline of a second puzzle piece is revealed.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the first puzzle piece. + noStroke(); + fill(255); + + // Draw the first puzzle piece. + beginShape(); + vertex(-30, -30, 0); + quadraticVertex(30, -30, 0, 0, 0, 0); + quadraticVertex(-30, 30, 0, 30, 30, 0); + vertex(30, -40, 0); + vertex(-30, -40, 0); + vertex(-30, -30, 0); + endShape(); + + // Style the second puzzle piece. + stroke(255); + noFill(); + + // Draw the second puzzle piece. + beginShape(); + vertex(-30, -30, -20); + quadraticVertex(30, -30, -20, 0, 0, -20); + quadraticVertex(-30, 30, -20, 30, 30, -20); + vertex(30, -40, -20); + vertex(-30, -40, -20); + vertex(-30, -30, -20); + endShape(); + } + +
+class: p5 +overloads: + - line: 1600 + params: + - name: cx + description: | +

x-coordinate of the control point.

+ type: Number + - name: cy + description: | +

y-coordinate of the control point.

+ type: Number + - name: x3 + description: | +

x-coordinate of the anchor point.

+ type: Number + - name: y3 + description: | +

y-coordinate of the anchor point.

+ type: Number + chainable: 1 + - line: 1832 + params: + - name: cx + description: '' + type: Number + - name: cy + description: '' + type: Number + - name: cz + description: | +

z-coordinate of the control point.

+ type: Number + - name: x3 + description: '' + type: Number + - name: y3 + description: '' + type: Number + - name: z3 + description: | +

z-coordinate of the anchor point.

+ type: Number +chainable: true +--- + + +# quadraticVertex diff --git a/src/content/reference/en/p5 copy/radians.mdx b/src/content/reference/en/p5 copy/radians.mdx new file mode 100644 index 0000000000..da0adc1ff7 --- /dev/null +++ b/src/content/reference/en/p5 copy/radians.mdx @@ -0,0 +1,53 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L521 +title: radians +module: Math +submodule: Trigonometry +file: src/math/trigonometry.js +description: | +

Converts an angle measured in degrees to its value in radians.

+

Degrees and radians are both units for measuring angles. There are 360˚ in + one full rotation. A full rotation is 2 × π (about 6.28) radians.

+

The same angle can be expressed in with either unit. For example, 90° is a + quarter of a full rotation. The same angle is 2 × π ÷ 4 + (about 1.57) radians.

+line: 521 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Calculate the angle conversion. + let deg = 45; + let rad = radians(deg); + + // Display the angle conversion. + text(`${deg}˚ = ${round(rad, 3)} rad`, 10, 50); + + describe('The text "45˚ = 0.785 rad".'); + } + +
+class: p5 +params: + - name: degrees + description: | +

degree value to convert to radians.

+ type: Number +return: + description: converted angle. + type: Number +chainable: false +--- + + +# radians diff --git a/src/content/reference/en/p5 copy/random.mdx b/src/content/reference/en/p5 copy/random.mdx new file mode 100644 index 0000000000..aef8e546e8 --- /dev/null +++ b/src/content/reference/en/p5 copy/random.mdx @@ -0,0 +1,48 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/random.js#L86 +title: random +module: Math +submodule: Random +file: src/math/random.js +description: "

Returns a random number or a random element from an array.

\n

random() follows uniform distribution, which means that all outcomes are\nequally likely. When random() is used to generate numbers, all\nnumbers in the output range are equally likely to be returned. When\nrandom() is used to select elements from an array, all elements are\nequally likely to be chosen.

\n

By default, random() produces different results each time a sketch runs.\nThe randomSeed() function can be used to\ngenerate the same sequence of numbers or choices each time a sketch runs.

\n

The version of random() with no parameters returns a random number from 0\nup to but not including 1.

\n

The version of random() with one parameter works one of two ways. If the\nargument passed is a number, random() returns a random number from 0 up\nto but not including the number. For example, calling random(5) returns\nvalues between 0 and 5. If the argument passed is an array, random()\nreturns a random element from that array. For example, calling\nrandom(['\U0001F981', '\U0001F42F', '\U0001F43B']) returns either a lion, tiger, or bear emoji.

\n

The version of random() with two parameters returns a random number from\na given range. The arguments passed set the range's lower and upper bounds.\nFor example, calling random(-5, 10.2) returns values from -5 up to but\nnot including 10.2.

\n" +line: 86 +isConstructor: false +itemtype: method +example: + - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Get random coordinates between 0 and 100.\n let x = random(0, 100);\n let y = random(0, 100);\n\n // Draw a point.\n strokeWeight(5);\n point(x, y);\n\n describe('A black dot appears in a random position on a gray square.');\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Get random coordinates between 0 and 100.\n let x = random(100);\n let y = random(100);\n\n // Draw the point.\n strokeWeight(5);\n point(x, y);\n\n describe('A black dot appears in a random position on a gray square.');\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Create an array of emoji strings.\n let animals = ['\U0001F981', '\U0001F42F', '\U0001F43B'];\n\n // Choose a random element from the array.\n let choice = random(animals);\n\n // Style the text.\n textAlign(CENTER);\n textSize(20);\n\n // Display the emoji.\n text(choice, 50, 50);\n\n describe('An animal face is displayed at random. Either a lion, tiger, or bear.');\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Slow the frame rate.\n frameRate(5);\n\n describe('A black dot moves around randomly on a gray square.');\n}\n\nfunction draw() {\n background(200);\n\n // Get random coordinates between 0 and 100.\n let x = random(100);\n let y = random(100);\n\n // Draw the point.\n strokeWeight(5);\n point(x, y);\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Slow the frame rate.\n frameRate(5);\n\n describe('A black dot moves around randomly in the middle of a gray square.');\n}\n\nfunction draw() {\n background(200);\n\n // Get random coordinates between 45 and 55.\n let x = random(45, 55);\n let y = random(45, 55);\n\n // Draw the point.\n strokeWeight(5);\n point(x, y);\n}\n\n
\n\n
\n\nlet x = 50;\nlet y = 50;\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n describe('A black dot moves around randomly leaving a trail.');\n}\n\nfunction draw() {\n // Update x and y randomly.\n x += random(-1, 1);\n y += random(-1, 1);\n\n // Draw the point.\n point(x, y);\n}\n\n
" +class: p5 +return: + description: random number. + type: Number +overloads: + - line: 86 + params: + - name: min + description: | +

lower bound (inclusive).

+ type: Number + optional: true + - name: max + description: | +

upper bound (exclusive).

+ type: Number + optional: true + return: + description: random number. + type: Number + - line: 259 + params: + - name: choices + description: | +

array to choose from.

+ type: Array + return: + description: random element from the array. + type: '*' +chainable: false +--- + + +# random diff --git a/src/content/reference/en/p5 copy/randomGaussian.mdx b/src/content/reference/en/p5 copy/randomGaussian.mdx new file mode 100644 index 0000000000..24893f378b --- /dev/null +++ b/src/content/reference/en/p5 copy/randomGaussian.mdx @@ -0,0 +1,104 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/random.js#L292 +title: randomGaussian +module: Math +submodule: Random +file: src/math/random.js +description: > +

Returns a random number fitting a Gaussian, or normal, distribution.

+ +

Normal distributions look like bell curves when plotted. Values from a + + normal distribution cluster around a central value called the mean. The + + cluster's standard deviation describes its spread.

+ +

By default, randomGaussian() produces different results each + time a + + sketch runs. The randomSeed() function + can be + + used to generate the same sequence of numbers each time a sketch runs.

+ +

There's no minimum or maximum value that randomGaussian() + might return. + + Values far from the mean are very unlikely and values near the mean are + + very likely.

+ +

The version of randomGaussian() with no parameters returns + values with a + + mean of 0 and standard deviation of 1.

+ +

The version of randomGaussian() with one parameter interprets + the + + argument passed as the mean. The standard deviation is 1.

+ +

The version of randomGaussian() with two parameters interprets + the first + + argument passed as the mean and the second as the standard deviation.

+line: 292 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + describe('Three horizontal black lines are filled in randomly. The top line spans entire canvas. The middle line is very short. The bottom line spans two-thirds of the canvas.'); + } + + function draw() { + // Style the circles. + noStroke(); + fill(0, 10); + + // Uniform distribution between 0 and 100. + let x = random(100); + let y = 25; + circle(x, y, 5); + + // Gaussian distribution with a mean of 50 and sd of 1. + x = randomGaussian(50); + y = 50; + circle(x, y, 5); + + // Gaussian distribution with a mean of 50 and sd of 10. + x = randomGaussian(50, 10); + y = 75; + circle(x, y, 5); + } + +
+class: p5 +params: + - name: mean + description: | +

mean.

+ type: Number + optional: true + - name: sd + description: | +

standard deviation.

+ type: Number + optional: true +return: + description: random number. + type: Number +chainable: false +--- + + +# randomGaussian diff --git a/src/content/reference/en/p5 copy/randomSeed.mdx b/src/content/reference/en/p5 copy/randomSeed.mdx new file mode 100644 index 0000000000..dbd1a6ae3d --- /dev/null +++ b/src/content/reference/en/p5 copy/randomSeed.mdx @@ -0,0 +1,71 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/random.js#L37 +title: randomSeed +module: Math +submodule: Random +file: src/math/random.js +description: > +

Sets the seed value for the random() + and + + randomGaussian() functions.

+ +

By default, random() and + + randomGaussian() produce different + + results each time a sketch is run. Calling randomSeed() with a + constant + + argument, such as randomSeed(99), makes these functions produce + the same + + results each time a sketch is run.

+line: 37 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Get random coordinates. + let x = random(0, 100); + let y = random(0, 100); + + // Draw the white circle. + circle(x, y, 10); + + // Set a random seed for consistency. + randomSeed(99); + + // Get random coordinates. + x = random(0, 100); + y = random(0, 100); + + // Draw the black circle. + fill(0); + circle(x, y, 10); + + describe('A white circle appears at a random position. A black circle appears at (27.4, 25.8).'); + } + +
+class: p5 +params: + - name: seed + description: | +

seed value.

+ type: Number +chainable: false +--- + + +# randomSeed diff --git a/src/content/reference/en/p5 copy/rect.mdx b/src/content/reference/en/p5 copy/rect.mdx new file mode 100644 index 0000000000..6876ab536d --- /dev/null +++ b/src/content/reference/en/p5 copy/rect.mdx @@ -0,0 +1,209 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L1091 +title: rect +module: Shape +submodule: 2D Primitives +file: src/core/shape/2d_primitives.js +description: > +

Draws a rectangle.

+ +

A rectangle is a four-sided shape defined by the x, + y, w, and h + + parameters. x and y set the location of its top-left + corner. w sets + + its width and h sets its height. Every angle in the rectangle + measures + + 90˚. See rectMode() for other ways to + define + + rectangles.

+ +

The version of rect() with five parameters creates a rounded + rectangle. The + + fifth parameter sets the radius for all four corners.

+ +

The version of rect() with eight parameters also creates a + rounded + + rectangle. Each of the last four parameters set the radius of a corner. The + + radii start with the top-left corner and move clockwise around the + + rectangle. If any of these parameters are omitted, they are set to the + + value of the last radius that was set.

+line: 1091 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + rect(30, 20, 55, 55); + + describe('A white square with a black outline on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + rect(30, 20, 55, 40); + + describe('A white rectangle with a black outline on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Give all corners a radius of 20. + rect(30, 20, 55, 50, 20); + + describe('A white rectangle with a black outline and round edges on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Give each corner a unique radius. + rect(30, 20, 55, 50, 20, 15, 10, 5); + + describe('A white rectangle with a black outline and round edges of different radii.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + rect(-20, -30, 55, 55); + + describe('A white square with a black outline on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white square spins around on gray canvas.'); + } + + function draw() { + background(200); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Draw the rectangle. + rect(-20, -30, 55, 55); + } + +
+class: p5 +overloads: + - line: 1091 + params: + - name: x + description: | +

x-coordinate of the rectangle.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the rectangle.

+ type: Number + - name: w + description: | +

width of the rectangle.

+ type: Number + - name: h + description: | +

height of the rectangle.

+ type: Number + optional: true + - name: tl + description: | +

optional radius of top-left corner.

+ type: Number + optional: true + - name: tr + description: | +

optional radius of top-right corner.

+ type: Number + optional: true + - name: br + description: | +

optional radius of bottom-right corner.

+ type: Number + optional: true + - name: bl + description: | +

optional radius of bottom-left corner.

+ type: Number + optional: true + chainable: 1 + - line: 1214 + params: + - name: x + description: '' + type: Number + - name: 'y' + description: '' + type: Number + - name: w + description: '' + type: Number + - name: h + description: '' + type: Number + - name: detailX + description: | +

number of segments in the x-direction (for WebGL mode).

+ type: Integer + optional: true + - name: detailY + description: | +

number of segments in the y-direction (for WebGL mode).

+ type: Integer + optional: true + chainable: 1 +chainable: true +--- + + +# rect diff --git a/src/content/reference/en/p5 copy/rectMode.mdx b/src/content/reference/en/p5 copy/rectMode.mdx new file mode 100644 index 0000000000..5d444cb16e --- /dev/null +++ b/src/content/reference/en/p5 copy/rectMode.mdx @@ -0,0 +1,142 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L184 +title: rectMode +module: Shape +submodule: Attributes +file: src/core/shape/attributes.js +description: > +

Changes where rectangles and squares are drawn.

+ +

By default, the first two parameters of + + rect() and square(), + + are the x- and y-coordinates of the shape's upper left corner. The next + parameters set + + the shape's width and height. This is the same as calling + + rectMode(CORNER).

+ +

rectMode(CORNERS) also uses the first two parameters as the + location of + + one of the corners. The next parameters are the location of the opposite + + corner. This mode only works for rect().

+ +

rectMode(CENTER) uses the first two parameters as the x- and + + y-coordinates of the shape's center. The next parameters are its width and + + height.

+ +

rectMode(RADIUS) also uses the first two parameters as the x- + and + + y-coordinates of the shape's center. The next parameters are + + half of the shape's width and height.

+ +

The argument passed to rectMode() must be written in ALL CAPS + because the + + constants CENTER, RADIUS, CORNER, and + CORNERS are defined this way. + + JavaScript is a case-sensitive language.

+line: 184 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + rectMode(CORNER); + fill(255); + rect(25, 25, 50, 50); + + rectMode(CORNERS); + fill(100); + rect(25, 25, 50, 50); + + describe('A small gray square drawn at the top-left corner of a white square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + rectMode(RADIUS); + fill(255); + rect(50, 50, 30, 30); + + rectMode(CENTER); + fill(100); + rect(50, 50, 30, 30); + + describe('A small gray square drawn at the center of a white square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + rectMode(CORNER); + fill(255); + square(25, 25, 50); + + describe('A white square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + rectMode(RADIUS); + fill(255); + square(50, 50, 30); + + rectMode(CENTER); + fill(100); + square(50, 50, 30); + + describe('A small gray square drawn at the center of a white square.'); + } + +
+class: p5 +params: + - name: mode + description: | +

either CORNER, CORNERS, CENTER, or RADIUS

+ type: Constant +chainable: true +--- + + +# rectMode diff --git a/src/content/reference/en/p5 copy/red.mdx b/src/content/reference/en/p5 copy/red.mdx new file mode 100644 index 0000000000..819478b246 --- /dev/null +++ b/src/content/reference/en/p5 copy/red.mdx @@ -0,0 +1,158 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L1279 +title: red +module: Color +submodule: Creating & Reading +file: src/color/creating_reading.js +description: > +

Gets the red value of a color.

+ +

red() extracts the red value from a + + p5.Color object, an array of color + components, or + + a CSS color string.

+ +

By default, red() returns a color's red value in the range 0 + + to 255. If the colorMode() is set to + RGB, it + + returns the red value in the given range.

+line: 1279 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object. + let c = color(175, 100, 220); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'redValue' to 175. + let redValue = red(c); + + // Draw the right rectangle. + fill(redValue, 0, 0); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is red.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a color array. + let c = [175, 100, 220]; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'redValue' to 175. + let redValue = red(c); + + // Draw the right rectangle. + fill(redValue, 0, 0); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is red.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a CSS color string. + let c = 'rgb(175, 100, 220)'; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'redValue' to 175. + let redValue = red(c); + + // Draw the right rectangle. + fill(redValue, 0, 0); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is red.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use RGB color with values in the range 0-100. + colorMode(RGB, 100); + + // Create a p5.Color object. + let c = color(69, 39, 86); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'redValue' to 69. + let redValue = red(c); + + // Draw the right rectangle. + fill(redValue, 0, 0); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is red.'); + } + +
+class: p5 +params: + - name: color + description: | +

p5.Color object, array of + color components, or CSS color string.

+ type: 'p5.Color|Number[]|String' +return: + description: the red value. + type: Number +chainable: false +--- + + +# red diff --git a/src/content/reference/en/p5 copy/redraw.mdx b/src/content/reference/en/p5 copy/redraw.mdx new file mode 100644 index 0000000000..6519f322f0 --- /dev/null +++ b/src/content/reference/en/p5 copy/redraw.mdx @@ -0,0 +1,117 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L838 +title: redraw +module: Structure +submodule: Structure +file: src/core/structure.js +description: > +

Runs the code in draw() once.

+ +

By default, draw() tries to run 60 times + per + + second. Calling noLoop() stops + + draw() from repeating. Calling + redraw() will + + execute the code in the draw() function a + set + + number of times.

+ +

The parameter, n, is optional. If a number is passed, as in + redraw(5), + + then the draw loop will run the given number of times. By default, + n is + + 1.

+line: 838 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Double-click the canvas to move the circle. + + let x = 0; + + function setup() { + createCanvas(100, 100); + + // Turn off the draw loop. + noLoop(); + + describe( + 'A white half-circle on the left edge of a gray square. The circle moves a little to the right when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Draw the circle. + circle(x, 50, 20); + + // Increment x. + x += 5; + } + + // Run the draw loop when the user double-clicks. + function doubleClicked() { + redraw(); + } + +
+ +
+ + // Double-click the canvas to move the circle. + + let x = 0; + + function setup() { + createCanvas(100, 100); + + // Turn off the draw loop. + noLoop(); + + describe( + 'A white half-circle on the left edge of a gray square. The circle hops to the right when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Draw the circle. + circle(x, 50, 20); + + // Increment x. + x += 5; + } + + // Run the draw loop three times when the user double-clicks. + function doubleClicked() { + redraw(3); + } + +
+class: p5 +params: + - name: 'n' + description: > +

number of times to run draw(). Defaults to + 1.

+ type: Integer + optional: true +chainable: false +--- + + +# redraw diff --git a/src/content/reference/en/p5 copy/remove.mdx b/src/content/reference/en/p5 copy/remove.mdx new file mode 100644 index 0000000000..552822f5a3 --- /dev/null +++ b/src/content/reference/en/p5 copy/remove.mdx @@ -0,0 +1,57 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L559 +title: remove +module: Structure +submodule: Structure +file: src/core/main.js +description: > +

Removes the sketch from the web page.

+ +

Calling remove() stops the draw loop and removes any HTML + elements + + created by the sketch, including the canvas. A new sketch can be + + created by using the p5() constructor, as in + + new p5().

+line: 559 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Double-click to remove the canvas. + + function setup() { + createCanvas(100, 100); + + describe( + 'A white circle on a gray background. The circle follows the mouse as the user moves. The sketch disappears when the user double-clicks.' + ); + } + + function draw() { + // Paint the background repeatedly. + background(200); + + // Draw circles repeatedly. + circle(mouseX, mouseY, 40); + } + + // Remove the sketch when the user double-clicks. + function doubleClicked() { + remove(); + } + +
+class: p5 +chainable: false +--- + + +# remove diff --git a/src/content/reference/en/p5 copy/removeElements.mdx b/src/content/reference/en/p5 copy/removeElements.mdx new file mode 100644 index 0000000000..51e712026b --- /dev/null +++ b/src/content/reference/en/p5 copy/removeElements.mdx @@ -0,0 +1,85 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L256 +title: removeElements +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Removes all elements created by p5.js, including any event handlers.

+ +

There are two exceptions: + + canvas elements created by createCanvas() + + and p5.Render objects created by + + createGraphics().

+line: 256 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a paragraph element and place + // it in the middle of the canvas. + let p = createP('p5*js'); + p.position(25, 25); + + describe('A gray square with the text "p5*js" written in its center. The text disappears when the mouse is pressed.'); + } + + // Remove all elements when the mouse is pressed. + function mousePressed() { + removeElements(); + } + +
+ +
+ + let slider; + + function setup() { + createCanvas(100, 100); + + // Create a paragraph element and place + // it at the top of the canvas. + let p = createP('p5*js'); + p.position(25, 25); + + // Create a slider element and place it + // beneath the canvas. + slider = createSlider(0, 255, 200); + slider.position(0, 100); + + describe('A gray square with the text "p5*js" written in its center and a range slider beneath it. The square changes color when the slider is moved. The text and slider disappear when the square is double-clicked.'); + } + + function draw() { + // Use the slider value to change the background color. + let g = slider.value(); + background(g); + } + + // Remove all elements when the mouse is double-clicked. + function doubleClicked() { + removeElements(); + } + +
+class: p5 +chainable: false +--- + + +# removeElements diff --git a/src/content/reference/en/p5 copy/removeItem.mdx b/src/content/reference/en/p5 copy/removeItem.mdx new file mode 100644 index 0000000000..ba091b00b4 --- /dev/null +++ b/src/content/reference/en/p5 copy/removeItem.mdx @@ -0,0 +1,97 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/data/local_storage.js#L380 +title: removeItem +module: Data +submodule: LocalStorage +file: src/data/local_storage.js +description: > +

Removes an item from the web browser's local storage.

+ +

Web browsers can save small amounts of data using the built-in + + localStorage object. + + Data stored in localStorage can be retrieved at any point, even + after + + refreshing a page or restarting the browser. Data are stored as key-value + + pairs.

+ +

storeItem() makes it easy to store + values in + + localStorage and removeItem() makes it easy to + delete them.

+ +

The parameter, key, is the name of the value to remove as a + string. For + + example, calling removeItem('size') removes the item with the key + size.

+ +

Note: Sensitive data such as passwords or personal information shouldn't be + + stored in localStorage.

+line: 380 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Double-click to remove an item from localStorage. + + function setup() { + createCanvas(100, 100); + + // Store the player's name. + storeItem('name', 'Feist'); + + // Store the player's score. + storeItem('score', 1234); + + describe( + 'The text "Feist: 1234" written in black on a gray background. The text "Feist: null" appears when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(14); + + // Retrieve the name. + let name = getItem('name'); + + // Retrieve the score. + let score = getItem('score'); + + // Display the score. + text(`${name}: ${score}`, 50, 50); + } + + // Remove the word from localStorage when the user double-clicks. + function doubleClicked() { + removeItem('score'); + } + +
+class: p5 +params: + - name: key + description: | +

name of the value to remove.

+ type: String +chainable: false +--- + + +# removeItem diff --git a/src/content/reference/en/p5 copy/requestPointerLock.mdx b/src/content/reference/en/p5 copy/requestPointerLock.mdx new file mode 100644 index 0000000000..621ce063ce --- /dev/null +++ b/src/content/reference/en/p5 copy/requestPointerLock.mdx @@ -0,0 +1,85 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1880 +title: requestPointerLock +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

Locks the mouse pointer to its current position and makes it invisible.

+ +

requestPointerLock() allows the mouse to move forever without + leaving the + + screen. Calling requestPointerLock() locks the values of + + mouseX, mouseY, + + pmouseX, and pmouseY. + + movedX and movedY + + continue updating and can be used to get the distance the mouse moved since + + the last frame was drawn. Calling + + exitPointerLock() resumes + updating the + + mouse system variables.

+ +

Note: Most browsers require an input, such as a click, before calling + + requestPointerLock(). It’s recommended to call + requestPointerLock() in + + an event function such as doubleClicked().

+line: 1880 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let score = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with the text "Score: X" at its center. The score increases when the user moves the mouse upward. It decreases when the user moves the mouse downward.' + ); + } + + function draw() { + background(200); + + // Update the score. + score -= movedY; + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the score. + text(`Score: ${score}`, 50, 50); + } + + // Lock the pointer when the user double-clicks. + function doubleClicked() { + requestPointerLock(); + } + +
+class: p5 +chainable: false +--- + + +# requestPointerLock diff --git a/src/content/reference/en/p5 copy/resetMatrix.mdx b/src/content/reference/en/p5 copy/resetMatrix.mdx new file mode 100644 index 0000000000..af797b49db --- /dev/null +++ b/src/content/reference/en/p5 copy/resetMatrix.mdx @@ -0,0 +1,52 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L246 +title: resetMatrix +module: Transform +submodule: Transform +file: src/core/transform.js +description: | +

Clears all transformations applied to the coordinate system.

+line: 246 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'Two circles drawn on a gray background. A blue circle is at the top-left and a red circle is at the bottom-right.' + ); + } + + function draw() { + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Draw a blue circle at the coordinates (25, 25). + fill('blue'); + circle(25, 25, 20); + + // Clear all transformations. + // The origin is now at the top-left corner. + resetMatrix(); + + // Draw a red circle at the coordinates (25, 25). + fill('red'); + circle(25, 25, 20); + } + +
+class: p5 +chainable: true +--- + + +# resetMatrix diff --git a/src/content/reference/en/p5 copy/resetShader.mdx b/src/content/reference/en/p5 copy/resetShader.mdx new file mode 100644 index 0000000000..850ca0773c --- /dev/null +++ b/src/content/reference/en/p5 copy/resetShader.mdx @@ -0,0 +1,95 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1628 +title: resetShader +module: 3D +submodule: Material +file: src/webgl/material.js +description: | +

Restores the default shaders.

+

resetShader() deactivates any shaders previously applied by + shader().

+

Note: Shaders can only be used in WebGL mode.

+line: 1628 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Create a string with the vertex shader program. + // The vertex shader is called for each vertex. + let vertSrc = ` + attribute vec3 aPosition; + attribute vec2 aTexCoord; + uniform mat4 uProjectionMatrix; + uniform mat4 uModelViewMatrix; + varying vec2 vTexCoord; + + void main() { + vTexCoord = aTexCoord; + vec4 position = vec4(aPosition, 1.0); + gl_Position = uProjectionMatrix * uModelViewMatrix * position; + } + `; + + // Create a string with the fragment shader program. + // The fragment shader is called for each pixel. + let fragSrc = ` + precision mediump float; + varying vec2 vTexCoord; + + void main() { + vec2 uv = vTexCoord; + vec3 color = vec3(uv.x, uv.y, min(uv.x + uv.y, 1.0)); + gl_FragColor = vec4(color, 1.0); + } + `; + + let myShader; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Shader object. + myShader = createShader(vertSrc, fragSrc); + + describe( + 'Two rotating cubes on a gray background. The left one has a blue-purple gradient on each face. The right one is red.' + ); + } + + function draw() { + background(200); + + // Draw a box using the p5.Shader. + // shader() sets the active shader to myShader. + shader(myShader); + push(); + translate(-25, 0, 0); + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + box(width / 4); + pop(); + + // Draw a box using the default fill shader. + // resetShader() restores the default fill shader. + resetShader(); + fill(255, 0, 0); + push(); + translate(25, 0, 0); + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + box(width / 4); + pop(); + } + +
+class: p5 +chainable: true +--- + + +# resetShader diff --git a/src/content/reference/en/p5 copy/resizeCanvas.mdx b/src/content/reference/en/p5 copy/resizeCanvas.mdx new file mode 100644 index 0000000000..fde0561563 --- /dev/null +++ b/src/content/reference/en/p5 copy/resizeCanvas.mdx @@ -0,0 +1,133 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L221 +title: resizeCanvas +module: Rendering +submodule: Rendering +file: src/core/rendering.js +description: > +

Resizes the canvas to a given width and height.

+ +

resizeCanvas() immediately clears the canvas and calls + + redraw(). It's common to call + resizeCanvas() + + within the body of windowResized() + like + + so:

+ +
function windowResized() {
+    resizeCanvas(windowWidth, windowHeight);
+  }
+
+  
+ +

The first two parameters, width and height, set + the dimensions of the + + canvas. They also the values of the width + and + + height system variables. For example, + calling + + resizeCanvas(300, 500) resizes the canvas to 300×500 pixels, then + sets + + width to 300 and + + height 500.

+ +

The third parameter, noRedraw, is optional. If + true is passed, as in + + resizeCanvas(300, 500, true), then the canvas will be canvas to + 300×500 + + pixels but the redraw() function won't be + called + + immediately. By default, redraw() is + called + + immediately when resizeCanvas() finishes executing.

+line: 221 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Double-click to resize the canvas. + + function setup() { + createCanvas(100, 100); + + describe( + 'A white circle drawn on a gray background. The canvas shrinks by half the first time the user double-clicks.' + ); + } + + function draw() { + background(180); + + // Draw a circle at the center of the canvas. + circle(width / 2, height / 2, 20); + } + + // Resize the canvas when the user double-clicks. + function doubleClicked() { + resizeCanvas(50, 50); + } + +
+ +
+ + // Resize the web browser to change the canvas size. + + function setup() { + createCanvas(windowWidth, windowHeight); + + describe('A white circle drawn on a gray background.'); + } + + function draw() { + background(180); + + // Draw a circle at the center of the canvas. + circle(width / 2, height / 2, 20); + } + + // Always resize the canvas to fill the browser window. + function windowResized() { + resizeCanvas(windowWidth, windowHeight); + } + +
+class: p5 +params: + - name: width + description: | +

width of the canvas.

+ type: Number + - name: height + description: | +

height of the canvas.

+ type: Number + - name: noRedraw + description: | +

whether to delay calling + redraw(). Defaults + to false.

+ type: Boolean + optional: true +chainable: false +--- + + +# resizeCanvas diff --git a/src/content/reference/en/p5 copy/reverse.mdx b/src/content/reference/en/p5 copy/reverse.mdx new file mode 100644 index 0000000000..bf7a6571ac --- /dev/null +++ b/src/content/reference/en/p5 copy/reverse.mdx @@ -0,0 +1,43 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L141 +title: reverse +module: Data +submodule: Array Functions +file: src/utilities/array_functions.js +description: | +

Reverses the order of an array, maps to Array.reverse()

+line: 141 +deprecated: >- + Use array.reverse() + instead. +isConstructor: false +itemtype: method +example: + - |- + +
+ function setup() { + let myArray = ['A', 'B', 'C']; + print(myArray); // ['A','B','C'] + + reverse(myArray); + print(myArray); // ['C','B','A'] + } +
+class: p5 +params: + - name: list + description: | +

Array to reverse

+ type: Array +return: + description: the reversed list + type: Array +chainable: false +--- + + +# reverse diff --git a/src/content/reference/en/p5 copy/rotate.mdx b/src/content/reference/en/p5 copy/rotate.mdx new file mode 100644 index 0000000000..bbb4f8e5f8 --- /dev/null +++ b/src/content/reference/en/p5 copy/rotate.mdx @@ -0,0 +1,226 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L289 +title: rotate +module: Transform +submodule: Transform +file: src/core/transform.js +description: > +

Rotates the coordinate system.

+ +

By default, the positive x-axis points to the right and the positive y-axis + + points downward. The rotate() function changes this orientation + by + + rotating the coordinate system about the origin. Everything drawn after + + rotate() is called will appear to be rotated.

+ +

The first parameter, angle, is the amount to rotate. For + example, calling + + rotate(1) rotates the coordinate system clockwise 1 radian which + is + + nearly 57˚. rotate() interprets angle values using the current + + angleMode().

+ +

The second parameter, axis, is optional. It's used to orient + 3D rotations + + in WebGL mode. If a p5.Vector is passed, + as in + + rotate(QUARTER_PI, myVector), then the coordinate system will + rotate + + QUARTER_PI radians about myVector. If an array of + vector components is + + passed, as in rotate(QUARTER_PI, [1, 0, 0]), then the coordinate + system + + will rotate QUARTER_PI radians about a vector with the components + + [1, 0, 0].

+ +

By default, transformations accumulate. For example, calling + rotate(1) + + twice has the same effect as calling rotate(2) once. The + + push() and pop() functions + + can be used to isolate transformations within distinct drawing groups.

+ +

Note: Transformations are reset at the beginning of the draw loop. Calling + + rotate(1) inside the draw() + function won't cause + + shapes to spin.

+line: 289 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe( + "A white rectangle on a gray background. The rectangle's long axis runs from top-left to bottom-right." + ); + } + + function draw() { + background(200); + + // Rotate the coordinate system 1/8 turn. + rotate(QUARTER_PI); + + // Draw a rectangle at coordinates (50, 0). + rect(50, 0, 40, 20); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + "A white rectangle on a gray background. The rectangle's long axis runs from top-left to bottom-right." + ); + } + + function draw() { + background(200); + + // Rotate the coordinate system 1/16 turn. + rotate(QUARTER_PI / 2); + + // Rotate the coordinate system another 1/16 turn. + rotate(QUARTER_PI / 2); + + // Draw a rectangle at coordinates (50, 0). + rect(50, 0, 40, 20); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Use degrees. + angleMode(DEGREES); + + describe( + "A white rectangle on a gray background. The rectangle's long axis runs from top-left to bottom-right." + ); + } + + function draw() { + background(200); + + // Rotate the coordinate system 1/8 turn. + rotate(45); + + // Draw a rectangle at coordinates (50, 0). + rect(50, 0, 40, 20); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A white rectangle on a gray background. The rectangle rotates slowly about the top-left corner. It disappears and reappears periodically.' + ); + } + + function draw() { + background(200); + + // Rotate the coordinate system a little more each frame. + let angle = frameCount * 0.01; + rotate(angle); + + // Draw a rectangle at coordinates (50, 0). + rect(50, 0, 40, 20); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe("A cube on a gray background. The cube's front face points to the top-right."); + } + + function draw() { + background(200); + + // Rotate the coordinate system 1/8 turn about + // the axis [1, 1, 0]. + let axis = createVector(1, 1, 0); + rotate(QUARTER_PI, axis); + + // Draw a box. + box(); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe("A cube on a gray background. The cube's front face points to the top-right."); + } + + function draw() { + background(200); + + // Rotate the coordinate system 1/8 turn about + // the axis [1, 1, 0]. + let axis = [1, 1, 0]; + rotate(QUARTER_PI, axis); + + // Draw a box. + box(); + } + +
+class: p5 +params: + - name: angle + description: > +

angle of rotation in the current angleMode().

+ type: Number + - name: axis + description: | +

axis to rotate about in 3D.

+ type: 'p5.Vector|Number[]' + optional: true +chainable: true +--- + + +# rotate diff --git a/src/content/reference/en/p5 copy/rotateX.mdx b/src/content/reference/en/p5 copy/rotateX.mdx new file mode 100644 index 0000000000..c519976bce --- /dev/null +++ b/src/content/reference/en/p5 copy/rotateX.mdx @@ -0,0 +1,161 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L470 +title: rotateX +module: Transform +submodule: Transform +file: src/core/transform.js +description: > +

Rotates the coordinate system about the x-axis in WebGL mode.

+ +

The parameter, angle, is the amount to rotate. For example, + calling + + rotateX(1) rotates the coordinate system about the x-axis by 1 + radian. + + rotateX() interprets angle values using the current + + angleMode().

+ +

By default, transformations accumulate. For example, calling + rotateX(1) + + twice has the same effect as calling rotateX(2) once. The + + push() and pop() functions + + can be used to isolate transformations within distinct drawing groups.

+ +

Note: Transformations are reset at the beginning of the draw loop. Calling + + rotateX(1) inside the draw() + function won't cause + + shapes to spin.

+line: 470 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system 1/8 turn. + rotateX(QUARTER_PI); + + // Draw a box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system 1/16 turn. + rotateX(QUARTER_PI / 2); + + // Rotate the coordinate system 1/16 turn. + rotateX(QUARTER_PI / 2); + + // Draw a box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + // Use degrees. + angleMode(DEGREES); + + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system 1/8 turn. + rotateX(45); + + // Draw a box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube rotates slowly against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system a little more each frame. + let angle = frameCount * 0.01; + rotateX(angle); + + // Draw a box. + box(); + } + +
+class: p5 +params: + - name: angle + description: > +

angle of rotation in the current angleMode().

+ type: Number +chainable: true +--- + + +# rotateX diff --git a/src/content/reference/en/p5 copy/rotateY.mdx b/src/content/reference/en/p5 copy/rotateY.mdx new file mode 100644 index 0000000000..c7976c5a44 --- /dev/null +++ b/src/content/reference/en/p5 copy/rotateY.mdx @@ -0,0 +1,161 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L606 +title: rotateY +module: Transform +submodule: Transform +file: src/core/transform.js +description: > +

Rotates the coordinate system about the y-axis in WebGL mode.

+ +

The parameter, angle, is the amount to rotate. For example, + calling + + rotateY(1) rotates the coordinate system about the y-axis by 1 + radian. + + rotateY() interprets angle values using the current + + angleMode().

+ +

By default, transformations accumulate. For example, calling + rotateY(1) + + twice has the same effect as calling rotateY(2) once. The + + push() and pop() functions + + can be used to isolate transformations within distinct drawing groups.

+ +

Note: Transformations are reset at the beginning of the draw loop. Calling + + rotateY(1) inside the draw() + function won't cause + + shapes to spin.

+line: 606 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system 1/8 turn. + rotateY(QUARTER_PI); + + // Draw a box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system 1/16 turn. + rotateY(QUARTER_PI / 2); + + // Rotate the coordinate system 1/16 turn. + rotateY(QUARTER_PI / 2); + + // Draw a box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + // Use degrees. + angleMode(DEGREES); + + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system 1/8 turn. + rotateY(45); + + // Draw a box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube rotates slowly against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system a little more each frame. + let angle = frameCount * 0.01; + rotateY(angle); + + // Draw a box. + box(); + } + +
+class: p5 +params: + - name: angle + description: > +

angle of rotation in the current angleMode().

+ type: Number +chainable: true +--- + + +# rotateY diff --git a/src/content/reference/en/p5 copy/rotateZ.mdx b/src/content/reference/en/p5 copy/rotateZ.mdx new file mode 100644 index 0000000000..317bd7fe88 --- /dev/null +++ b/src/content/reference/en/p5 copy/rotateZ.mdx @@ -0,0 +1,161 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L742 +title: rotateZ +module: Transform +submodule: Transform +file: src/core/transform.js +description: > +

Rotates the coordinate system about the z-axis in WebGL mode.

+ +

The parameter, angle, is the amount to rotate. For example, + calling + + rotateZ(1) rotates the coordinate system about the z-axis by 1 + radian. + + rotateZ() interprets angle values using the current + + angleMode().

+ +

By default, transformations accumulate. For example, calling + rotateZ(1) + + twice has the same effect as calling rotateZ(2) once. The + + push() and pop() functions + + can be used to isolate transformations within distinct drawing groups.

+ +

Note: Transformations are reset at the beginning of the draw loop. Calling + + rotateZ(1) inside the draw() + function won't cause + + shapes to spin.

+line: 742 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system 1/8 turn. + rotateZ(QUARTER_PI); + + // Draw a box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system 1/16 turn. + rotateZ(QUARTER_PI / 2); + + // Rotate the coordinate system 1/16 turn. + rotateZ(QUARTER_PI / 2); + + // Draw a box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + // Use degrees. + angleMode(DEGREES); + + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system 1/8 turn. + rotateZ(45); + + // Draw a box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube rotates slowly against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system a little more each frame. + let angle = frameCount * 0.01; + rotateZ(angle); + + // Draw a box. + box(); + } + +
+class: p5 +params: + - name: angle + description: > +

angle of rotation in the current angleMode().

+ type: Number +chainable: true +--- + + +# rotateZ diff --git a/src/content/reference/en/p5 copy/rotationX.mdx b/src/content/reference/en/p5 copy/rotationX.mdx new file mode 100644 index 0000000000..98dfd287dc --- /dev/null +++ b/src/content/reference/en/p5 copy/rotationX.mdx @@ -0,0 +1,45 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L131 +title: rotationX +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: | +

The system variable rotationX always contains the rotation of the + device along the x axis. If the sketch + angleMode() is set to DEGREES, the value will be -180 to 180. If + it is set to RADIANS, the value will be -PI to PI.

+

Note: The order the rotations are called is important, ie. if used + together, it must be called in the order Z-X-Y or there might be + unexpected behaviour.

+line: 131 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + } + + function draw() { + background(200); + //rotateZ(radians(rotationZ)); + rotateX(radians(rotationX)); + //rotateY(radians(rotationY)); + box(200, 200, 200); + describe(`red horizontal line right, green vertical line bottom. + black background.`); + } + +
+class: p5 +type: Number +--- + + +# rotationX diff --git a/src/content/reference/en/p5 copy/rotationY.mdx b/src/content/reference/en/p5 copy/rotationY.mdx new file mode 100644 index 0000000000..f06a033bb7 --- /dev/null +++ b/src/content/reference/en/p5 copy/rotationY.mdx @@ -0,0 +1,45 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L164 +title: rotationY +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: | +

The system variable rotationY always contains the rotation of the + device along the y axis. If the sketch + angleMode() is set to DEGREES, the value will be -90 to 90. If + it is set to RADIANS, the value will be -PI/2 to PI/2.

+

Note: The order the rotations are called is important, ie. if used + together, it must be called in the order Z-X-Y or there might be + unexpected behaviour.

+line: 164 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + } + + function draw() { + background(200); + //rotateZ(radians(rotationZ)); + //rotateX(radians(rotationX)); + rotateY(radians(rotationY)); + box(200, 200, 200); + describe(`red horizontal line right, green vertical line bottom. + black background.`); + } + +
+class: p5 +type: Number +--- + + +# rotationY diff --git a/src/content/reference/en/p5 copy/rotationZ.mdx b/src/content/reference/en/p5 copy/rotationZ.mdx new file mode 100644 index 0000000000..47d6d965aa --- /dev/null +++ b/src/content/reference/en/p5 copy/rotationZ.mdx @@ -0,0 +1,47 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L197 +title: rotationZ +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: | +

The system variable rotationZ always contains the rotation of the + device along the z axis. If the sketch + angleMode() is set to DEGREES, the value will be 0 to 360. If + it is set to RADIANS, the value will be 0 to 2*PI.

+

Unlike rotationX and rotationY, this variable is available for devices + with a built-in compass only.

+

Note: The order the rotations are called is important, ie. if used + together, it must be called in the order Z-X-Y or there might be + unexpected behaviour.

+line: 197 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + } + + function draw() { + background(200); + rotateZ(radians(rotationZ)); + //rotateX(radians(rotationX)); + //rotateY(radians(rotationY)); + box(200, 200, 200); + describe(`red horizontal line right, green vertical line bottom. + black background.`); + } + +
+class: p5 +type: Number +--- + + +# rotationZ diff --git a/src/content/reference/en/p5 copy/round.mdx b/src/content/reference/en/p5 copy/round.mdx new file mode 100644 index 0000000000..3f6efea6eb --- /dev/null +++ b/src/content/reference/en/p5 copy/round.mdx @@ -0,0 +1,88 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L861 +title: round +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Calculates the integer closest to a number.

+ +

For example, round(133.8) returns the value 134.

+ +

The second parameter, decimals, is optional. It sets the + number of + + decimal places to use when rounding. For example, round(12.34, 1) + returns + + 12.3. decimals is 0 by default.

+line: 861 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Round a number. + let x = round(4.2); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the rounded number. + text(x, 50, 50); + + describe('The number 4 written in middle of the canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Round a number to 2 decimal places. + let x = round(12.782383, 2); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the rounded number. + text(x, 50, 50); + + describe('The number 12.78 written in middle of canvas.'); + } + +
+class: p5 +params: + - name: 'n' + description: | +

number to round.

+ type: Number + - name: decimals + description: | +

number of decimal places to round to, default is 0.

+ type: Number + optional: true +return: + description: rounded number. + type: Integer +chainable: false +--- + + +# round diff --git a/src/content/reference/en/p5 copy/sampleRate.mdx b/src/content/reference/en/p5 copy/sampleRate.mdx new file mode 100644 index 0000000000..3608ee22be --- /dev/null +++ b/src/content/reference/en/p5 copy/sampleRate.mdx @@ -0,0 +1,26 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L811 +title: sampleRate +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: | +

Returns a number representing the sample rate, in samples per second, + of all sound objects in this audio context. It is determined by the + sampling rate of your operating system's sound card, and it is not + currently possile to change. + It is often 44100, or twice the range of human hearing.

+line: 811 +isConstructor: false +itemtype: method +class: p5 +return: + description: samplerate samples per second + type: Number +chainable: false +--- + + +# sampleRate diff --git a/src/content/reference/en/p5 copy/saturation.mdx b/src/content/reference/en/p5 copy/saturation.mdx new file mode 100644 index 0000000000..7552fe927d --- /dev/null +++ b/src/content/reference/en/p5 copy/saturation.mdx @@ -0,0 +1,201 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L1415 +title: saturation +module: Color +submodule: Creating & Reading +file: src/color/creating_reading.js +description: > +

Gets the saturation value of a color.

+ +

saturation() extracts the saturation value from a + + p5.Color object, an array of color + components, or + + a CSS color string.

+ +

Saturation is scaled differently in HSB and HSL. By default, + saturation() + + returns a color's HSL saturation in the range 0 to 100. If the + + colorMode() is set to HSB or HSL, it + returns the + + saturation value in the given mode.

+line: 1415 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(50); + + // Use HSB color. + colorMode(HSB); + + // Create a p5.Color object. + let c = color(0, 50, 100); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'satValue' to 50. + let satValue = saturation(c); + + // Draw the right rectangle. + fill(satValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is dark gray.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(50); + + // Use HSB color. + colorMode(HSB); + + // Create a color array. + let c = [0, 50, 100]; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'satValue' to 100. + let satValue = saturation(c); + + // Draw the right rectangle. + fill(satValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is gray.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(50); + + // Use HSB color. + colorMode(HSB); + + // Create a CSS color string. + let c = 'rgb(255, 128, 128)'; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'satValue' to 100. + let satValue = saturation(c); + + // Draw the right rectangle. + fill(satValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is gray.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(50); + + // Use HSL color. + colorMode(HSL); + + // Create a p5.Color object. + let c = color(0, 100, 75); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'satValue' to 100. + let satValue = saturation(c); + + // Draw the right rectangle. + fill(satValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is white.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(50); + + // Use HSL color with values in the range 0-255. + colorMode(HSL, 255); + + // Create a p5.Color object. + let c = color(0, 255, 191.5); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'satValue' to 255. + let satValue = saturation(c); + + // Draw the right rectangle. + fill(satValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is white.'); + } + +
+class: p5 +params: + - name: color + description: | +

p5.Color object, array of + color components, or CSS color string.

+ type: 'p5.Color|Number[]|String' +return: + description: the saturation value + type: Number +chainable: false +--- + + +# saturation diff --git a/src/content/reference/en/p5 copy/save.mdx b/src/content/reference/en/p5 copy/save.mdx new file mode 100644 index 0000000000..fb8b67cd74 --- /dev/null +++ b/src/content/reference/en/p5 copy/save.mdx @@ -0,0 +1,140 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1835 +title: save +module: IO +submodule: Output +file: src/io/files.js +description: > +

Saves a given element(image, text, json, csv, wav, or html) to the client's + + computer. The first parameter can be a pointer to element we want to save. + + The element can be one of p5.Element,an + Array of + + Strings, an Array of JSON, a JSON object, a p5.Table + + , a p5.Image, or a p5.SoundFile + (requires + + p5.sound). The second parameter is a filename (including extension).The + + third parameter is for options specific to this type of object. This method + + will save a file that fits the given parameters. + + If it is called without specifying an element, by default it will save the + + whole canvas as an image file. You can optionally specify a filename as + + the first parameter in such a case. + + Note that it is not recommended to + + call this method within draw, as it will open a new save dialog on every + + render.

+line: 1835 +isConstructor: false +itemtype: method +example: + - |2- + +
+ // Saves the canvas as an image + cnv = createCanvas(300, 300); + save(cnv, 'myCanvas.jpg'); + + // 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.'); +
+ +
+ let myTable = new p5.Table(); + // Saves table as html file + save(myTable, 'myTable.html'); + + // Comma Separated Values + save(myTable, 'myTable.csv'); + + // Tab Separated Values + save(myTable, 'myTable.tsv'); + + describe(`An example showing how to save a table in formats of + HTML, CSV and TSV.`); +
+ +
+ let myJSON = { a: 1, b: true }; + + // Saves pretty JSON + save(myJSON, 'my.json'); + + // 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.`); +
+class: p5 +params: + - name: objectOrFilename + description: | +

If filename is provided, will + save canvas as an image with + either png or jpg extension + depending on the filename. + If object is provided, will + save depending on the object + and filename (see examples + above).

+ type: Object|String + optional: true + - name: filename + description: | +

If an object is provided as the first + parameter, then the second parameter + indicates the filename, + and should include an appropriate + file extension (see examples above).

+ type: String + optional: true + - name: options + description: | +

Additional options depend on + filetype. For example, when saving JSON, + true indicates that the + output will be optimized for filesize, + rather than readability.

+ type: Boolean|String + optional: true +chainable: false +--- + + +# save diff --git a/src/content/reference/en/p5 copy/saveCanvas.mdx b/src/content/reference/en/p5 copy/saveCanvas.mdx new file mode 100644 index 0000000000..159bf101ce --- /dev/null +++ b/src/content/reference/en/p5 copy/saveCanvas.mdx @@ -0,0 +1,166 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/image.js#L153 +title: saveCanvas +module: Image +submodule: Image +file: src/image/image.js +description: > +

Saves the current canvas as an image.

+ +

By default, saveCanvas() saves the canvas as a PNG image + called + + untitled.png.

+ +

The first parameter, filename, is optional. It's a string that + sets the + + file's name. If a file extension is included, as in + + saveCanvas('drawing.png'), then the image will be saved using + that + + format.

+ +

The second parameter, extension, is also optional. It sets the + files format. + + Either 'png', 'webp', or 'jpg' can be + used. For example, saveCanvas('drawing', 'jpg') + + saves the canvas to a file called drawing.jpg.

+ +

Note: The browser will either save the file immediately or prompt the user + + with a dialogue window.

+line: 153 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + background(255); + + // Save the canvas to 'untitled.png'. + saveCanvas(); + + describe('A white square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(255); + + // Save the canvas to 'myCanvas.jpg'. + saveCanvas('myCanvas.jpg'); + + describe('A white square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(255); + + // Save the canvas to 'myCanvas.jpg'. + saveCanvas('myCanvas', 'jpg'); + + describe('A white square.'); + } + +
+ +
+ + function setup() { + let cnv = createCanvas(100, 100); + + background(255); + + // Save the canvas to 'untitled.png'. + saveCanvas(cnv); + + describe('A white square.'); + } + +
+ +
+ + function setup() { + let cnv = createCanvas(100, 100); + + background(255); + + // Save the canvas to 'myCanvas.jpg'. + saveCanvas(cnv, 'myCanvas.jpg'); + + describe('A white square.'); + } + +
+ +
+ + function setup() { + let cnv = createCanvas(100, 100); + + background(255); + + // Save the canvas to 'myCanvas.jpg'. + saveCanvas(cnv, 'myCanvas', 'jpg'); + + describe('A white square.'); + } + +
+class: p5 +overloads: + - line: 153 + params: + - name: selectedCanvas + description: | +

reference to a + specific HTML5 canvas element.

+ type: p5.Framebuffer|p5.Element|HTMLCanvasElement + - name: filename + description: | +

file name. Defaults to 'untitled'.

+ type: String + optional: true + - name: extension + description: > +

file extension, either 'png', 'webp', or 'jpg'. Defaults to + 'png'.

+ type: String + optional: true + - line: 267 + params: + - name: filename + description: '' + type: String + optional: true + - name: extension + description: '' + type: String + optional: true +chainable: false +--- + + +# saveCanvas diff --git a/src/content/reference/en/p5 copy/saveFrames.mdx b/src/content/reference/en/p5 copy/saveFrames.mdx new file mode 100644 index 0000000000..72b8d7d987 --- /dev/null +++ b/src/content/reference/en/p5 copy/saveFrames.mdx @@ -0,0 +1,175 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/image.js#L561 +title: saveFrames +module: Image +submodule: Image +file: src/image/image.js +description: > +

Captures a sequence of frames from the canvas that can be saved as + images.

+ +

saveFrames() creates an array of frame objects. Each frame is + stored as + + an object with its file type, file name, and image data as a string. For + + example, the first saved frame might have the following properties:

+ +

{ ext: 'png', filename: 'frame0', imageData: + 'data:image/octet-stream;base64, abc123' }.

+ +

The first parameter, filename, sets the prefix for the file + names. For + + example, setting the prefix to 'frame' would generate the image + files + + frame0.png, frame1.png, and so on.

+ +

The second parameter, extension, sets the file type to either + 'png' or + + 'jpg'.

+ +

The third parameter, duration, sets the duration to record in + seconds. + + The maximum duration is 15 seconds.

+ +

The fourth parameter, framerate, sets the number of frames to + record per + + second. The maximum frame rate value is 22. Limits are placed on + duration + + and framerate to avoid using too much memory. Recording large + canvases + + can easily crash sketches or even web browsers.

+ +

The fifth parameter, callback, is optional. If a function is + passed, + + image files won't be saved by default. The callback function can be used + + to process an array containing the data for each captured frame. The array + + of image data contains a sequence of objects with three properties for each + + frame: imageData, filename, and + extension.

+ +

Note: Frames are downloaded as individual image files by default.

+line: 561 +isConstructor: false +itemtype: method +example: + - >- + +
+ + + + function setup() { + createCanvas(100, 100); + + describe('A square repeatedly changes color from blue to pink.'); + } + + + function draw() { + let r = frameCount % 255; + let g = 50; + let b = 100; + background(r, g, b); + } + + + // Save the frames when the user presses the 's' key. + + function keyPressed() { + if (key === 's') { + saveFrames('frame', 'png', 1, 5); + } + } + + + +
+ + +
+ + + + function setup() { + createCanvas(100, 100); + + describe('A square repeatedly changes color from blue to pink.'); + } + + + function draw() { + let r = frameCount % 255; + let g = 50; + let b = 100; + background(r, g, b); + } + + + // Print 5 frames when the user presses the mouse. + + function mousePressed() { + saveFrames('frame', 'png', 1, 5, printFrames); + } + + + // Prints an array of objects containing raw image data, filenames, and + extensions. + + function printFrames(frames) { + for (let frame of frames) { + print(frame); + } + } + + + +
+class: p5 +params: + - name: filename + description: | +

prefix of file name.

+ type: String + - name: extension + description: | +

file extension, either 'jpg' or 'png'.

+ type: String + - name: duration + description: > +

duration in seconds to record. This parameter will be constrained to be + less or equal to 15.

+ type: Number + - name: framerate + description: > +

number of frames to save per second. This parameter will be constrained + to be less or equal to 22.

+ type: Number + - name: callback + description: | +

callback function that will be executed + to handle the image data. This function + should accept an array as argument. The + array will contain the specified number of + frames of objects. Each object has three + properties: imageData, filename, and extension.

+ type: Function(Array) + optional: true +chainable: false +--- + + +# saveFrames diff --git a/src/content/reference/en/p5 copy/saveGif.mdx b/src/content/reference/en/p5 copy/saveGif.mdx new file mode 100644 index 0000000000..9b520993ac --- /dev/null +++ b/src/content/reference/en/p5 copy/saveGif.mdx @@ -0,0 +1,119 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L204 +title: saveGif +module: Image +submodule: Loading & Displaying +file: src/image/loading_displaying.js +description: > +

Generates a gif from a sketch and saves it to a file.

+ +

saveGif() may be called in setup() or at any + + point while a sketch is running.

+ +

The first parameter, fileName, sets the gif's file name.

+ +

The second parameter, duration, sets the gif's duration in + seconds.

+ +

The third parameter, options, is optional. If an object is + passed, + + saveGif() will use its properties to customize the gif. + saveGif() + + recognizes the properties delay, units, + silent, + + notificationDuration, and notificationID.

+line: 204 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A circle drawn in the middle of a gray square. The circle changes color from black to white, then repeats.'); + } + + function draw() { + background(200); + + // Style the circle. + let c = frameCount % 255; + fill(c); + + // Display the circle. + circle(50, 50, 25); + } + + // Save a 5-second gif when the user presses the 's' key. + function keyPressed() { + if (key === 's') { + saveGif('mySketch', 5); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A circle drawn in the middle of a gray square. The circle changes color from black to white, then repeats.'); + } + + function draw() { + background(200); + + // Style the circle. + let c = frameCount % 255; + fill(c); + + // Display the circle. + circle(50, 50, 25); + } + + // Save a 5-second gif when the user presses the 's' key. + // Wait 1 second after the key press before recording. + function keyPressed() { + if (key === 's') { + saveGif('mySketch', 5, { delay: 1 }); + } + } + +
+class: p5 +params: + - name: filename + description: | +

file name of gif.

+ type: String + - name: duration + description: | +

duration in seconds to capture from the sketch.

+ type: Number + - name: options + description: | +

an object that can contain five more properties: + delay, a Number specifying how much time to wait before recording; + units, a String that can be either 'seconds' or 'frames'. By default it's 'seconds’; + silent, a Boolean that defines presence of progress notifications. By default it’s false; + notificationDuration, a Number that defines how long in seconds the final notification + will live. By default it's 0, meaning the notification will never be removed; + notificationID, a String that specifies the id of the notification's DOM element. By default it’s 'progressBar’.

+ type: Object + optional: true +chainable: false +--- + + +# saveGif diff --git a/src/content/reference/en/p5 copy/saveJSON.mdx b/src/content/reference/en/p5 copy/saveJSON.mdx new file mode 100644 index 0000000000..d5e664d0b2 --- /dev/null +++ b/src/content/reference/en/p5 copy/saveJSON.mdx @@ -0,0 +1,170 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1979 +title: saveJSON +module: IO +submodule: Output +file: src/io/files.js +description: > +

Saves an Object or Array to a JSON file.

+ +

JavaScript Object Notation + + (JSON) + + is a standard format for sending data between applications. The format is + + based on JavaScript objects which have keys and values. JSON files store + + data in an object with strings as keys. Values can be strings, numbers, + + Booleans, arrays, null, or other objects.

+ +

The first parameter, json, is the data to save. The data can + be an array, + + as in [1, 2, 3], or an object, as in + + { x: 50, y: 50, color: 'deeppink' }.

+ +

The second parameter, filename, is a string that sets the + file's name. + + For example, calling saveJSON([1, 2, 3], 'data.json') saves the + array + + [1, 2, 3] to a file called data.json on the user's + computer.

+ +

The third parameter, optimize, is optional. If + true is passed, as in + + saveJSON([1, 2, 3], 'data.json', true), then all unneeded + whitespace will + + be removed to reduce the file size.

+ +

Note: The browser will either save the file immediately or prompt the user + + with a dialogue window.

+line: 1979 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(12); + + // Display instructions. + text('Double-click to save', 5, 50, 90); + + describe('The text "Double-click to save" written in black on a gray background.'); + } + + // Save the file when the user double-clicks. + function doubleClicked() { + if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { + // Create an array. + let data = [1, 2, 3]; + + // Save the JSON file. + saveJSON(data, 'numbers.json'); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(12); + + // Display instructions. + text('Double-click to save', 5, 50, 90); + + describe('The text "Double-click to save" written in black on a gray background.'); + } + + // Save the file when the user double-clicks. + function doubleClicked() { + if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { + // Create an object. + let data = { x: mouseX, y: mouseY }; + + // Save the JSON file. + saveJSON(data, 'state.json'); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(12); + + // Display instructions. + text('Double-click to save', 5, 50, 90); + + describe('The text "Double-click to save" written in black on a gray background.'); + } + + // Save the file when the user double-clicks. + function doubleClicked() { + if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { + // Create an object. + let data = { x: mouseX, y: mouseY }; + + // Save the JSON file and reduce its size. + saveJSON(data, 'state.json', true); + } + } + +
+class: p5 +params: + - name: json + description: | +

data to save.

+ type: Array|Object + - name: filename + description: | +

name of the file to be saved.

+ type: String + - name: optimize + description: | +

whether to trim unneeded whitespace. Defaults + to true.

+ type: Boolean + optional: true +chainable: false +--- + + +# saveJSON diff --git a/src/content/reference/en/p5 copy/saveSound.mdx b/src/content/reference/en/p5 copy/saveSound.mdx new file mode 100644 index 0000000000..3e8e7d0667 --- /dev/null +++ b/src/content/reference/en/p5 copy/saveSound.mdx @@ -0,0 +1,35 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L1145 +title: saveSound +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: > +

Save a p5.SoundFile as a .wav file. The browser will prompt the user + + to download the file to their device. + + For uploading audio to a server, use + + p5.SoundFile.saveBlob.

+line: 1145 +isConstructor: false +itemtype: method +class: p5 +params: + - name: soundFile + description: | +

p5.SoundFile that you wish to save

+ type: p5.SoundFile + - name: fileName + description: | +

name of the resulting .wav file.

+ type: String +chainable: false +--- + + +# saveSound diff --git a/src/content/reference/en/p5 copy/saveStrings.mdx b/src/content/reference/en/p5 copy/saveStrings.mdx new file mode 100644 index 0000000000..36c6c448a2 --- /dev/null +++ b/src/content/reference/en/p5 copy/saveStrings.mdx @@ -0,0 +1,185 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L2118 +title: saveStrings +module: IO +submodule: Output +file: src/io/files.js +description: > +

Saves an Array of Strings to a file, one per + line.

+ +

The first parameter, list, is an array with the strings to + save.

+ +

The second parameter, filename, is a string that sets the + file's name. + + For example, calling saveStrings(['0', '01', '011'], 'data.txt') + saves + + the array ['0', '01', '011'] to a file called + data.txt on the user's + + computer.

+ +

The third parameter, extension, is optional. If a string is + passed, as in + + saveStrings(['0', '01', '01'], 'data', 'txt')`, the second + parameter will + + be interpreted as the file name and the third parameter as the extension.

+ +

The fourth parameter, isCRLF, is also optional, If + true is passed, as + + in saveStrings(['0', '01', '011'], 'data', 'txt', true), then two + + characters, \r\n , will be added to the end of each string to + create new + + lines in the saved file. \r is a carriage return (CR) and + \n is a line + + feed (LF). By default, only \n (line feed) is added to each + string in + + order to create new lines.

+ +

Note: The browser will either save the file immediately or prompt the user + + with a dialogue window.

+line: 2118 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(12); + + // Display instructions. + text('Double-click to save', 5, 50, 90); + + describe('The text "Double-click to save" written in black on a gray background.'); + } + + // Save the file when the user double-clicks. + function doubleClicked() { + if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { + // Create an array. + let data = ['0', '01', '011']; + + // Save the text file. + saveStrings(data, 'data.txt'); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(12); + + // Display instructions. + text('Double-click to save', 5, 50, 90); + + describe('The text "Double-click to save" written in black on a gray background.'); + } + + // Save the file when the user double-clicks. + function doubleClicked() { + if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { + // Create an array. + // ASCII art courtesy Wikipedia: + // https://en.wikipedia.org/wiki/ASCII_art + let data = [' (\\_/) ', "(='.'=)", '(")_(")']; + + // Save the text file. + saveStrings(data, 'cat', 'txt'); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(12); + + // Display instructions. + text('Double-click to save', 5, 50, 90); + + describe('The text "Double-click to save" written in black on a gray background.'); + } + + // Save the file when the user double-clicks. + function doubleClicked() { + if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { + // Create an array. + // +--+ + // / /| + // +--+ + + // | |/ + // +--+ + let data = [' +--+', ' / /|', '+--+ +', '| |/', '+--+']; + + // Save the text file. + // Use CRLF for line endings. + saveStrings(data, 'box', 'txt', true); + } + } + +
+class: p5 +params: + - name: list + description: | +

data to save.

+ type: 'String[]' + - name: filename + description: | +

name of file to be saved.

+ type: String + - name: extension + description: | +

format to use for the file.

+ type: String + optional: true + - name: isCRLF + description: | +

whether to add \r\n to the end of each + string. Defaults to false.

+ type: Boolean + optional: true +chainable: false +--- + + +# saveStrings diff --git a/src/content/reference/en/p5 copy/saveTable.mdx b/src/content/reference/en/p5 copy/saveTable.mdx new file mode 100644 index 0000000000..dd6e64ea4d --- /dev/null +++ b/src/content/reference/en/p5 copy/saveTable.mdx @@ -0,0 +1,70 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L2275 +title: saveTable +module: IO +submodule: Output +file: src/io/files.js +description: > +

Writes the contents of a Table object + to a file. Defaults to a + + text file with comma-separated-values ('csv') but can also + + use tab separation ('tsv'), or generate an HTML table ('html'). + + The file saving process and location of the saved file will + + vary between web browsers.

+line: 2275 +isConstructor: false +itemtype: method +example: + - |- + +
+ let table; + + function setup() { + table = new p5.Table(); + + table.addColumn('id'); + table.addColumn('species'); + table.addColumn('name'); + + let newRow = table.addRow(); + newRow.setNum('id', table.getRowCount() - 1); + newRow.setString('species', 'Panthera leo'); + newRow.setString('name', 'Lion'); + + // 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 +
+class: p5 +params: + - name: Table + description: | +

the Table object to save to a file

+ type: p5.Table + - name: filename + description: | +

the filename to which the Table should be saved

+ type: String + - name: options + description: | +

can be one of "tsv", "csv", or "html"

+ type: String + optional: true +chainable: false +--- + + +# saveTable diff --git a/src/content/reference/en/p5 copy/scale.mdx b/src/content/reference/en/p5 copy/scale.mdx new file mode 100644 index 0000000000..a459477d80 --- /dev/null +++ b/src/content/reference/en/p5 copy/scale.mdx @@ -0,0 +1,231 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L878 +title: scale +module: Transform +submodule: Transform +file: src/core/transform.js +description: > +

Scales the coordinate system.

+ +

By default, shapes are drawn at their original scale. A rectangle that's 50 + + pixels wide appears to take up half the width of a 100 pixel-wide canvas. + + The scale() function can shrink or stretch the coordinate system + so that + + shapes appear at different sizes. There are two ways to call + scale() with + + parameters that set the scale factor(s).

+ +

The first way to call scale() uses numbers to set the amount + of scaling. + + The first parameter, s, sets the amount to scale each axis. For + example, + + calling scale(2) stretches the x-, y-, and z-axes by a factor of + 2. The + + next two parameters, y and z, are optional. They set + the amount to + + scale the y- and z-axes. For example, calling scale(2, 0.5, 1) + stretches + + the x-axis by a factor of 2, shrinks the y-axis by a factor of 0.5, and + + leaves the z-axis unchanged.

+ +

The second way to call scale() uses a p5.Vector + + object to set the scale factors. For example, calling + scale(myVector) + + uses the x-, y-, and z-components of myVector to set the amount + of + + scaling along the x-, y-, and z-axes. Doing so is the same as calling + + scale(myVector.x, myVector.y, myVector.z).

+ +

By default, transformations accumulate. For example, calling + scale(1) + + twice has the same effect as calling scale(2) once. The + + push() and pop() functions + + can be used to isolate transformations within distinct drawing groups.

+ +

Note: Transformations are reset at the beginning of the draw loop. Calling + + scale(2) inside the draw() + function won't cause + + shapes to grow continuously.

+line: 878 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'Two white squares on a gray background. The larger square appears at the top-center. The smaller square appears at the top-left.' + ); + } + + function draw() { + background(200); + + // Draw a square at (30, 20). + square(30, 20, 40); + + // Scale the coordinate system by a factor of 0.5. + scale(0.5); + + // Draw a square at (30, 20). + // It appears at (15, 10) after scaling. + square(30, 20, 40); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A rectangle and a square drawn in white on a gray background.'); + } + + function draw() { + background(200); + + // Draw a square at (30, 20). + square(30, 20, 40); + + // Scale the coordinate system by factors of + // 0.5 along the x-axis and + // 1.3 along the y-axis. + scale(0.5, 1.3); + + // Draw a square at (30, 20). + // It appears as a rectangle at (15, 26) after scaling. + square(30, 20, 40); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A rectangle and a square drawn in white on a gray background.'); + } + + function draw() { + background(200); + + // Draw a square at (30, 20). + square(30, 20, 40); + + // Create a p5.Vector object. + let v = createVector(0.5, 1.3); + + // Scale the coordinate system by factors of + // 0.5 along the x-axis and + // 1.3 along the y-axis. + scale(v); + + // Draw a square at (30, 20). + // It appears as a rectangle at (15, 26) after scaling. + square(30, 20, 40); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'A red box and a blue box drawn on a gray background. The red box appears embedded in the blue box.' + ); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the spheres. + noStroke(); + + // Draw the red sphere. + fill('red'); + box(); + + // Scale the coordinate system by factors of + // 0.5 along the x-axis and + // 1.3 along the y-axis and + // 2 along the z-axis. + scale(0.5, 1.3, 2); + + // Draw the blue sphere. + fill('blue'); + box(); + } + +
+class: p5 +overloads: + - line: 878 + params: + - name: s + description: | +

amount to scale along the positive x-axis.

+ type: 'Number|p5.Vector|Number[]' + - name: 'y' + description: > +

amount to scale along the positive y-axis. Defaults to + s.

+ type: Number + optional: true + - name: z + description: > +

amount to scale along the positive z-axis. Defaults to + y.

+ type: Number + optional: true + chainable: 1 + - line: 1039 + params: + - name: scales + description: | +

vector whose components should be used to scale.

+ type: 'p5.Vector|Number[]' + chainable: 1 +chainable: true +--- + + +# scale diff --git a/src/content/reference/en/p5 copy/second.mdx b/src/content/reference/en/p5 copy/second.mdx new file mode 100644 index 0000000000..e29042801c --- /dev/null +++ b/src/content/reference/en/p5 copy/second.mdx @@ -0,0 +1,47 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L277 +title: second +module: IO +submodule: Time & Date +file: src/utilities/time_date.js +description: | +

Returns the current second as a number from 0–59.

+line: 277 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Get the current second. + let s = second(); + + // Style the text. + textAlign(LEFT, CENTER); + textSize(12); + textFont('Courier New'); + + // Display the second. + text(`Current second: ${s}`, 10, 50, 80); + + describe(`The text 'Current second: ${s}' written in black on a gray background.`); + } + +
+class: p5 +return: + description: current second between 0 and 59. + type: Integer +chainable: false +--- + + +# second diff --git a/src/content/reference/en/p5 copy/select.mdx b/src/content/reference/en/p5 copy/select.mdx new file mode 100644 index 0000000000..0ace11ab0d --- /dev/null +++ b/src/content/reference/en/p5 copy/select.mdx @@ -0,0 +1,113 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L21 +title: select +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Searches the page for the first element that matches the given + + CSS selector string.

+ +

The selector string can be an ID, class, tag name, or a combination. + + select() returns a p5.Element object if it + + finds a match and null if not.

+ +

The second parameter, container, is optional. It specifies a + container to + + search within. container can be CSS selector string, a + + p5.Element object, or an + + HTMLElement object.

+line: 21 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + background(200); + + // Select the canvas by its tag. + let cnv = select('canvas'); + cnv.style('border', '5px deeppink dashed'); + + describe('A gray square with a dashed pink border.'); + } + +
+ +
+ + function setup() { + let cnv = createCanvas(100, 100); + + // Add a class attribute to the canvas. + cnv.class('pinkborder'); + + background(200); + + // Select the canvas by its class. + cnv = select('.pinkborder'); + + // Style its border. + cnv.style('border', '5px deeppink dashed'); + + describe('A gray square with a dashed pink border.'); + } + +
+ +
+ + function setup() { + let cnv = createCanvas(100, 100); + + // Set the canvas' ID. + cnv.id('mycanvas'); + + background(200); + + // Select the canvas by its ID. + cnv = select('#mycanvas'); + + // Style its border. + cnv.style('border', '5px deeppink dashed'); + + describe('A gray square with a dashed pink border.'); + } + +
+class: p5 +params: + - name: selectors + description: | +

CSS selector string of element to search for.

+ type: String + - name: container + description: | +

CSS selector string, p5.Element, or + HTMLElement to search within.

+ type: String|p5.Element|HTMLElement + optional: true +return: + description: p5.Element containing the element. + type: p5.Element|null +chainable: false +--- + + +# select diff --git a/src/content/reference/en/p5 copy/selectAll.mdx b/src/content/reference/en/p5 copy/selectAll.mdx new file mode 100644 index 0000000000..ccd1f3329f --- /dev/null +++ b/src/content/reference/en/p5 copy/selectAll.mdx @@ -0,0 +1,121 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L109 +title: selectAll +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Searches the page for all elements that matches the given + + CSS selector string.

+ +

The selector string can be an ID, class, tag name, or a combination. + + selectAll() returns an array of p5.Element + + objects if it finds any matches and an empty array if none are found.

+ +

The second parameter, container, is optional. It specifies a + container to + + search within. container can be CSS selector string, a + + p5.Element object, or an + + HTMLElement object.

+line: 109 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Create three buttons. + createButton('1'); + createButton('2'); + createButton('3'); + + // Select the buttons by their tag. + let buttons = selectAll('button'); + + // Position the buttons. + for (let i = 0; i < 3; i += 1) { + buttons[i].position(0, i * 30); + } + + describe('Three buttons stacked vertically. The buttons are labeled, "1", "2", and "3".'); + } + +
+ +
+ + function setup() { + // Create three buttons and position them. + let b1 = createButton('1'); + b1.position(0, 0); + let b2 = createButton('2'); + b2.position(0, 30); + let b3 = createButton('3'); + b3.position(0, 60); + + // Add a class attribute to each button. + b1.class('btn'); + b2.class('btn btn-pink'); + b3.class('btn'); + + // Select the buttons by their class. + let buttons = selectAll('.btn'); + let pinkButtons = selectAll('.btn-pink'); + + // Style the selected buttons. + buttons.forEach(setFont); + pinkButtons.forEach(setColor); + + describe('Three buttons stacked vertically. The buttons are labeled, "1", "2", and "3". Buttons "1" and "3" are gray. Button "2" is pink.'); + } + + // Set a button's font to Comic Sans MS. + function setFont(btn) { + btn.style('font-family', 'Comic Sans MS'); + } + + // Set a button's background and font color. + function setColor(btn) { + btn.style('background', 'deeppink'); + btn.style('color', 'white'); + } + +
+class: p5 +params: + - name: selectors + description: | +

CSS selector string of element to search for.

+ type: String + - name: container + description: | +

CSS selector string, p5.Element, or + HTMLElement to search within.

+ type: String|p5.Element|HTMLElement + optional: true +return: + description: >- + array of p5.Elements containing any elements + found. + type: 'p5.Element[]' +chainable: false +--- + + +# selectAll diff --git a/src/content/reference/en/p5 copy/set.mdx b/src/content/reference/en/p5 copy/set.mdx new file mode 100644 index 0000000000..caa9e75a66 --- /dev/null +++ b/src/content/reference/en/p5 copy/set.mdx @@ -0,0 +1,157 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L997 +title: set +module: Image +submodule: Pixels +file: src/image/pixels.js +description: > +

Sets the color of a pixel or draws an image to the canvas.

+ +

set() is easy to use but it's not as fast as + + pixels. Use pixels + + to set many pixel values.

+ +

set() interprets the first two parameters as x- and + y-coordinates. It + + interprets the last parameter as a grayscale value, a [R, G, B, + A] pixel + + array, a p5.Color object, or a + + p5.Image object. If an image is passed, + the first + + two parameters set the coordinates for the image's upper-left corner, + + regardless of the current imageMode().

+ +

updatePixels() must be called + after using + + set() for changes to appear.

+line: 997 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Set four pixels to black. + set(30, 20, 0); + set(85, 20, 0); + set(85, 75, 0); + set(30, 75, 0); + + // Update the canvas. + updatePixels(); + + describe('Four black dots arranged in a square drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object. + let black = color(0); + + // Set four pixels to black. + set(30, 20, black); + set(85, 20, black); + set(85, 75, black); + set(30, 75, black); + + // Update the canvas. + updatePixels(); + + describe('Four black dots arranged in a square drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(255); + + // Draw a horizontal color gradient. + for (let x = 0; x < 100; x += 1) { + for (let y = 0; y < 100; y += 1) { + // Calculate the grayscale value. + let c = map(x, 0, 100, 0, 255); + + // Set the pixel using the grayscale value. + set(x, y, c); + } + } + + // Update the canvas. + updatePixels(); + + describe('A horizontal color gradient from black to white.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/rockies.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Use the image to set all pixels. + set(0, 0, img); + + // Update the canvas. + updatePixels(); + + describe('An image of a mountain landscape.'); + } + +
+class: p5 +params: + - name: x + description: | +

x-coordinate of the pixel.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the pixel.

+ type: Number + - name: c + description: | +

grayscale value | pixel array | + p5.Color object | p5.Image to copy.

+ type: 'Number|Number[]|Object' +chainable: false +--- + + +# set diff --git a/src/content/reference/en/p5 copy/setAttributes.mdx b/src/content/reference/en/p5 copy/setAttributes.mdx new file mode 100644 index 0000000000..368bc49c6c --- /dev/null +++ b/src/content/reference/en/p5 copy/setAttributes.mdx @@ -0,0 +1,163 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.RendererGL.js#L118 +title: setAttributes +module: Rendering +submodule: Rendering +file: src/webgl/p5.RendererGL.js +description: | +

Set attributes for the WebGL Drawing context. + This is a way of adjusting how the WebGL + renderer works to fine-tune the display and performance.

+

Note that this will reinitialize the drawing context + if called after the WebGL canvas is made.

+

If an object is passed as the parameter, all attributes + not declared in the object will be set to defaults.

+

The available attributes are: +
+ alpha - indicates if the canvas contains an alpha buffer + default is true

+

depth - indicates whether the drawing buffer has a depth buffer + of at least 16 bits - default is true

+

stencil - indicates whether the drawing buffer has a stencil buffer + of at least 8 bits

+

antialias - indicates whether or not to perform anti-aliasing + default is false (true in Safari)

+

premultipliedAlpha - indicates that the page compositor will assume + the drawing buffer contains colors with pre-multiplied alpha + default is true

+

preserveDrawingBuffer - if true the buffers will not be cleared and + and will preserve their values until cleared or overwritten by author + (note that p5 clears automatically on draw loop) + default is true

+

perPixelLighting - if true, per-pixel lighting will be used in the + lighting shader otherwise per-vertex lighting is used. + default is true.

+

version - either 1 or 2, to specify which WebGL version to ask for. By + default, WebGL 2 will be requested. If WebGL2 is not available, it will + fall back to WebGL 1. You can check what version is used with by looking at + the global webglVersion property.

+line: 118 +isConstructor: false +itemtype: method +alt: a rotating cube with smoother edges +example: + - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + } + + function draw() { + background(255); + push(); + rotateZ(frameCount * 0.02); + rotateX(frameCount * 0.02); + rotateY(frameCount * 0.02); + fill(0, 0, 0); + box(50); + pop(); + } + +
+
+ Now with the antialias attribute set to true. +
+
+ + function setup() { + setAttributes('antialias', true); + createCanvas(100, 100, WEBGL); + } + + function draw() { + background(255); + push(); + rotateZ(frameCount * 0.02); + rotateX(frameCount * 0.02); + rotateY(frameCount * 0.02); + fill(0, 0, 0); + box(50); + pop(); + } + +
+ +
+ + // press the mouse button to disable perPixelLighting + function setup() { + createCanvas(100, 100, WEBGL); + noStroke(); + fill(255); + } + + let lights = [ + { c: '#f00', t: 1.12, p: 1.91, r: 0.2 }, + { c: '#0f0', t: 1.21, p: 1.31, r: 0.2 }, + { c: '#00f', t: 1.37, p: 1.57, r: 0.2 }, + { c: '#ff0', t: 1.12, p: 1.91, r: 0.7 }, + { c: '#0ff', t: 1.21, p: 1.31, r: 0.7 }, + { c: '#f0f', t: 1.37, p: 1.57, r: 0.7 } + ]; + + function draw() { + let t = millis() / 1000 + 1000; + background(0); + directionalLight(color('#222'), 1, 1, 1); + + for (let i = 0; i < lights.length; i++) { + let light = lights[i]; + pointLight( + color(light.c), + p5.Vector.fromAngles(t * light.t, t * light.p, width * light.r) + ); + } + + specularMaterial(255); + sphere(width * 0.1); + + rotateX(t * 0.77); + rotateY(t * 0.83); + rotateZ(t * 0.91); + torus(width * 0.3, width * 0.07, 24, 10); + } + + function mousePressed() { + setAttributes('perPixelLighting', false); + noStroke(); + fill(255); + } + function mouseReleased() { + setAttributes('perPixelLighting', true); + noStroke(); + fill(255); + } + +
+class: p5 +overloads: + - line: 118 + params: + - name: key + description: | +

Name of attribute

+ type: String + - name: value + description: | +

New value of named attribute

+ type: Boolean + - line: 262 + params: + - name: obj + description: | +

object with key-value pairs

+ type: Object +chainable: false +--- + + +# setAttributes diff --git a/src/content/reference/en/p5 copy/setBPM.mdx b/src/content/reference/en/p5 copy/setBPM.mdx new file mode 100644 index 0000000000..d2e94a6c5d --- /dev/null +++ b/src/content/reference/en/p5 copy/setBPM.mdx @@ -0,0 +1,29 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L9084 +title: setBPM +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: | +

Set the global tempo, in beats per minute, for all + p5.Parts. This method will impact all active p5.Parts.

+line: 9084 +isConstructor: false +itemtype: method +class: p5 +params: + - name: BPM + description: | +

Beats Per Minute

+ type: Number + - name: rampTime + description: | +

Seconds from now

+ type: Number +chainable: false +--- + + +# setBPM diff --git a/src/content/reference/en/p5 copy/setCamera.mdx b/src/content/reference/en/p5 copy/setCamera.mdx new file mode 100644 index 0000000000..bd4727d474 --- /dev/null +++ b/src/content/reference/en/p5 copy/setCamera.mdx @@ -0,0 +1,81 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L3897 +title: setCamera +module: 3D +submodule: Camera +file: src/webgl/p5.Camera.js +description: > +

Sets the current (active) camera of a 3D sketch.

+ +

setCamera() allows for switching between multiple cameras + created with + + createCamera().

+ +

Note: setCamera() can only be used in WebGL mode.

+line: 3897 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Double-click to toggle between cameras. + + let cam1; + let cam2; + let usingCam1 = true; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the first camera. + // Keep its default settings. + cam1 = createCamera(); + + // Create the second camera. + // Place it at the top-left. + // Point it at the origin. + cam2 = createCamera(); + cam2.setPosition(400, -400, 800); + cam2.lookAt(0, 0, 0); + + // Set the current camera to cam1. + setCamera(cam1); + + describe('A white cube on a gray background. The camera toggles between frontal and aerial views when the user double-clicks.'); + } + + function draw() { + background(200); + + // Draw the box. + box(); + } + + // Toggle the current camera when the user double-clicks. + function doubleClicked() { + if (usingCam1 === true) { + setCamera(cam2); + usingCam1 = false; + } else { + setCamera(cam1); + usingCam1 = true; + } + } + +
+class: p5 +params: + - name: cam + description: | +

camera that should be made active.

+ type: p5.Camera +chainable: false +--- + + +# setCamera diff --git a/src/content/reference/en/p5 copy/setMoveThreshold.mdx b/src/content/reference/en/p5 copy/setMoveThreshold.mdx new file mode 100644 index 0000000000..3b90fb5f4d --- /dev/null +++ b/src/content/reference/en/p5 copy/setMoveThreshold.mdx @@ -0,0 +1,59 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L417 +title: setMoveThreshold +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

The setMoveThreshold() + function is used to set the movement threshold for + + the deviceMoved() function. The + default threshold is set to 0.5.

+line: 417 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Run this example on a mobile device + // You will need to move the device incrementally further + // the closer the square's color gets to white in order to change the value. + + let value = 0; + let threshold = 0.5; + function setup() { + setMoveThreshold(threshold); + } + 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; + threshold = threshold + 0.1; + if (value > 255) { + value = 0; + threshold = 30; + } + setMoveThreshold(threshold); + } + +
+class: p5 +params: + - name: value + description: | +

The threshold value

+ type: Number +chainable: false +--- + + +# setMoveThreshold diff --git a/src/content/reference/en/p5 copy/setShakeThreshold.mdx b/src/content/reference/en/p5 copy/setShakeThreshold.mdx new file mode 100644 index 0000000000..30af9eadb0 --- /dev/null +++ b/src/content/reference/en/p5 copy/setShakeThreshold.mdx @@ -0,0 +1,59 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L459 +title: setShakeThreshold +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

The setShakeThreshold() + function is used to set the movement threshold for + + the deviceShaken() function. The + default threshold is set to 30.

+line: 459 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Run this example on a mobile device + // You will need to shake the device more firmly + // the closer the box's fill gets to white in order to change the value. + + let value = 0; + let threshold = 30; + function setup() { + setShakeThreshold(threshold); + } + 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; + threshold = threshold + 5; + if (value > 255) { + value = 0; + threshold = 30; + } + setShakeThreshold(threshold); + } + +
+class: p5 +params: + - name: value + description: | +

The threshold value

+ type: Number +chainable: false +--- + + +# setShakeThreshold diff --git a/src/content/reference/en/p5 copy/setup.mdx b/src/content/reference/en/p5 copy/setup.mdx new file mode 100644 index 0000000000..6a71ea6a0f --- /dev/null +++ b/src/content/reference/en/p5 copy/setup.mdx @@ -0,0 +1,111 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L87 +title: setup +module: Structure +submodule: Structure +file: src/core/main.js +description: > +

A function that's called once when the sketch begins running.

+ +

Declaring the function setup() sets a code block to run once + + automatically when the sketch starts running. It's used to perform + + setup tasks such as creating the canvas and initializing variables:

+ +
function setup() {
+    // Code to run once at the start of the sketch.
+  }
+
+  
+ +

Code placed in setup() will run once before code placed in + + draw() begins looping. If the + + preload() is declared, then + setup() will + + run immediately after preload() finishes + + loading assets.

+ +

Note: setup() doesn’t have to be declared, but it’s common + practice to do so.

+line: 87 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw the circle. + circle(50, 50, 40); + + describe('A white circle on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Paint the background once. + background(200); + + describe( + 'A white circle on a gray background. The circle follows the mouse as the user moves, leaving a trail.' + ); + } + + function draw() { + // Draw circles repeatedly. + circle(mouseX, mouseY, 40); + } + +
+ +
+ + let img; + + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Draw the image. + image(img, 0, 0); + + describe( + 'A white circle on a brick wall. The circle follows the mouse as the user moves, leaving a trail.' + ); + } + + function draw() { + // Style the circle. + noStroke(); + + // Draw the circle. + circle(mouseX, mouseY, 10); + } + +
+class: p5 +chainable: false +--- + + +# setup diff --git a/src/content/reference/en/p5 copy/shader.mdx b/src/content/reference/en/p5 copy/shader.mdx new file mode 100644 index 0000000000..c8213d9261 --- /dev/null +++ b/src/content/reference/en/p5 copy/shader.mdx @@ -0,0 +1,244 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L682 +title: shader +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Sets the p5.Shader object to apply + while drawing.

+ +

Shaders are programs that run on the graphics processing unit (GPU). They + + can process many pixels or vertices at the same time, making them fast for + + many graphics tasks. They’re written in a language called + + GLSL + + and run along with the rest of the code in a sketch. + + p5.Shader objects can be created using + the + + createShader() and + + loadShader() functions.

+ +

The parameter, s, is the p5.Shader object to + + apply. For example, calling shader(myShader) applies + myShader to + + process each pixel on the canvas. The shader will be used for:

+ +
    + +
  • Fills when a texture is enabled if it includes a uniform + sampler2D.
  • + +
  • Fills when lights are enabled if it includes the attribute + aNormal, or if it has any of the following uniforms: + uUseLighting, uAmbientLightCount, + uDirectionalLightCount, uPointLightCount, + uAmbientColor, uDirectionalDiffuseColors, + uDirectionalSpecularColors, uPointLightLocation, + uPointLightDiffuseColors, uPointLightSpecularColors, + uLightingDirection, or uSpecular.
  • + +
  • Fills whenever there are no lights or textures.
  • + +
  • Strokes if it includes the uniform uStrokeWeight.
  • + +
+ +

The source code from a p5.Shader + object's + + fragment and vertex shaders will be compiled the first time it's passed to + + shader(). See + + MDN + + for more information about compiling shaders.

+ +

Calling resetShader() restores a + sketch’s + + default shaders.

+ +

Note: Shaders can only be used in WebGL mode.

+line: 682 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Note: A "uniform" is a global variable within a shader program. + + // Create a string with the vertex shader program. + // The vertex shader is called for each vertex. + let vertSrc = ` + precision highp float; + uniform mat4 uModelViewMatrix; + uniform mat4 uProjectionMatrix; + + attribute vec3 aPosition; + attribute vec2 aTexCoord; + varying vec2 vTexCoord; + + void main() { + vTexCoord = aTexCoord; + vec4 positionVec4 = vec4(aPosition, 1.0); + gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; + } + `; + + // Create a string with the fragment shader program. + // The fragment shader is called for each pixel. + let fragSrc = ` + precision highp float; + + void main() { + // Set each pixel's RGBA value to yellow. + gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); + } + `; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Shader object. + let shaderProgram = createShader(vertSrc, fragSrc); + + // Apply the p5.Shader object. + shader(shaderProgram); + + // Style the drawing surface. + noStroke(); + + // Add a plane as a drawing surface. + plane(100, 100); + + describe('A yellow square.'); + } + +
+ +
+ + // Note: A "uniform" is a global variable within a shader program. + + let mandelbrot; + + // Load the shader and create a p5.Shader object. + function preload() { + mandelbrot = loadShader('/assets/shader.vert', '/assets/shader.frag'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + // Use the p5.Shader object. + shader(mandelbrot); + + // Set the shader uniform p to an array. + mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); + + describe('A fractal image zooms in and out of focus.'); + } + + function draw() { + // Set the shader uniform r to a value that oscillates between 0 and 2. + mandelbrot.setUniform('r', sin(frameCount * 0.01) + 1); + + // Add a quad as a display surface for the shader. + quad(-1, -1, 1, -1, 1, 1, -1, 1); + } + +
+ +
+ + // Note: A "uniform" is a global variable within a shader program. + + let redGreen; + let orangeBlue; + let showRedGreen = false; + + // Load the shader and create two separate p5.Shader objects. + function preload() { + redGreen = loadShader('/assets/shader.vert', '/assets/shader-gradient.frag'); + orangeBlue = loadShader('/assets/shader.vert', '/assets/shader-gradient.frag'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + // Initialize the redGreen shader. + shader(redGreen); + + // Set the redGreen shader's center and background color. + redGreen.setUniform('colorCenter', [1.0, 0.0, 0.0]); + redGreen.setUniform('colorBackground', [0.0, 1.0, 0.0]); + + // Initialize the orangeBlue shader. + shader(orangeBlue); + + // Set the orangeBlue shader's center and background color. + orangeBlue.setUniform('colorCenter', [1.0, 0.5, 0.0]); + orangeBlue.setUniform('colorBackground', [0.226, 0.0, 0.615]); + + describe( + 'The scene toggles between two circular gradients when the user double-clicks. An orange and blue gradient vertically, and red and green gradient moves horizontally.' + ); + } + + function draw() { + // Update the offset values for each shader. + // Move orangeBlue vertically. + // Move redGreen horizontally. + orangeBlue.setUniform('offset', [0, sin(frameCount * 0.01) + 1]); + redGreen.setUniform('offset', [sin(frameCount * 0.01), 1]); + + if (showRedGreen === true) { + shader(redGreen); + } else { + shader(orangeBlue); + } + + // Style the drawing surface. + noStroke(); + + // Add a quad as a drawing surface. + quad(-1, -1, 1, -1, 1, 1, -1, 1); + } + + // Toggle between shaders when the user double-clicks. + function doubleClicked() { + showRedGreen = !showRedGreen; + } + +
+class: p5 +params: + - name: s + description: | +

p5.Shader object + to apply.

+ type: p5.Shader +chainable: true +--- + + +# shader diff --git a/src/content/reference/en/p5 copy/shearX.mdx b/src/content/reference/en/p5 copy/shearX.mdx new file mode 100644 index 0000000000..244fea83e2 --- /dev/null +++ b/src/content/reference/en/p5 copy/shearX.mdx @@ -0,0 +1,105 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L1069 +title: shearX +module: Transform +submodule: Transform +file: src/core/transform.js +description: > +

Shears the x-axis so that shapes appear skewed.

+ +

By default, the x- and y-axes are perpendicular. The shearX() + function + + transforms the coordinate system so that x-coordinates are translated while + + y-coordinates are fixed.

+ +

The first parameter, angle, is the amount to shear. For + example, calling + + shearX(1) transforms all x-coordinates using the formula + + x = x + y * tan(angle). shearX() interprets angle + values using the + + current angleMode().

+ +

By default, transformations accumulate. For example, calling + + shearX(1) twice has the same effect as calling + shearX(2) once. The + + push() and + + pop() functions can be used to isolate + + transformations within distinct drawing groups.

+ +

Note: Transformations are reset at the beginning of the draw loop. Calling + + shearX(1) inside the draw() + function won't + + cause shapes to shear continuously.

+line: 1069 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A white quadrilateral on a gray background.'); + } + + function draw() { + background(200); + + // Shear the coordinate system along the x-axis. + shearX(QUARTER_PI); + + // Draw the square. + square(0, 0, 50); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Use degrees. + angleMode(DEGREES); + + describe('A white quadrilateral on a gray background.'); + } + + function draw() { + background(200); + + // Shear the coordinate system along the x-axis. + shearX(45); + + // Draw the square. + square(0, 0, 50); + } + +
+class: p5 +params: + - name: angle + description: > +

angle to shear by in the current angleMode().

+ type: Number +chainable: true +--- + + +# shearX diff --git a/src/content/reference/en/p5 copy/shearY.mdx b/src/content/reference/en/p5 copy/shearY.mdx new file mode 100644 index 0000000000..007a8b4bfa --- /dev/null +++ b/src/content/reference/en/p5 copy/shearY.mdx @@ -0,0 +1,105 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L1146 +title: shearY +module: Transform +submodule: Transform +file: src/core/transform.js +description: > +

Shears the y-axis so that shapes appear skewed.

+ +

By default, the x- and y-axes are perpendicular. The shearY() + function + + transforms the coordinate system so that y-coordinates are translated while + + x-coordinates are fixed.

+ +

The first parameter, angle, is the amount to shear. For + example, calling + + shearY(1) transforms all y-coordinates using the formula + + y = y + x * tan(angle). shearY() interprets angle + values using the + + current angleMode().

+ +

By default, transformations accumulate. For example, calling + + shearY(1) twice has the same effect as calling + shearY(2) once. The + + push() and + + pop() functions can be used to isolate + + transformations within distinct drawing groups.

+ +

Note: Transformations are reset at the beginning of the draw loop. Calling + + shearY(1) inside the draw() + function won't + + cause shapes to shear continuously.

+line: 1146 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A white quadrilateral on a gray background.'); + } + + function draw() { + background(200); + + // Shear the coordinate system along the y-axis. + shearY(QUARTER_PI); + + // Draw the square. + square(0, 0, 50); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Use degrees. + angleMode(DEGREES); + + describe('A white quadrilateral on a gray background.'); + } + + function draw() { + background(200); + + // Shear the coordinate system along the y-axis. + shearY(45); + + // Draw the square. + square(0, 0, 50); + } + +
+class: p5 +params: + - name: angle + description: > +

angle to shear by in the current angleMode().

+ type: Number +chainable: true +--- + + +# shearY diff --git a/src/content/reference/en/p5 copy/shininess.mdx b/src/content/reference/en/p5 copy/shininess.mdx new file mode 100644 index 0000000000..a093e246c8 --- /dev/null +++ b/src/content/reference/en/p5 copy/shininess.mdx @@ -0,0 +1,86 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2998 +title: shininess +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Sets the amount of gloss ("shininess") of a + + specularMaterial().

+ +

Shiny materials focus reflected light more than dull materials. + + shininess() affects the way materials reflect light sources + including + + directionalLight(), + + pointLight(), + + and spotLight().

+ +

The parameter, shine, is a number that sets the amount of + shininess. + + shine must be greater than 1, which is its default value.

+line: 2998 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'Two red spheres drawn on a gray background. White light reflects from their surfaces as the mouse moves. The right sphere is shinier than the left sphere.' + ); + } + + function draw() { + background(200); + + // Turn on a red ambient light. + ambientLight(255, 0, 0); + + // Get the mouse's coordinates. + let mx = mouseX - 50; + let my = mouseY - 50; + + // Turn on a white point light that follows the mouse. + pointLight(255, 255, 255, mx, my, 50); + + // Style the sphere. + noStroke(); + + // Add a specular material with a grayscale value. + specularMaterial(255); + + // Draw the left sphere with low shininess. + translate(-25, 0, 0); + shininess(10); + sphere(20); + + // Draw the right sphere with high shininess. + translate(50, 0, 0); + shininess(100); + sphere(20); + } + +
+class: p5 +params: + - name: shine + description: | +

amount of shine.

+ type: Number +chainable: true +--- + + +# shininess diff --git a/src/content/reference/en/p5 copy/shorten.mdx b/src/content/reference/en/p5 copy/shorten.mdx new file mode 100644 index 0000000000..a1018f7fb8 --- /dev/null +++ b/src/content/reference/en/p5 copy/shorten.mdx @@ -0,0 +1,44 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L161 +title: shorten +module: Data +submodule: Array Functions +file: src/utilities/array_functions.js +description: | +

Decreases an array by one element and returns the shortened array, + maps to Array.pop().

+line: 161 +deprecated: >- + Use array.pop() + instead. +isConstructor: false +itemtype: method +example: + - |- + +
+ function setup() { + let myArray = ['A', 'B', 'C']; + print(myArray); // ['A', 'B', 'C'] + let newArray = shorten(myArray); + print(myArray); // ['A','B','C'] + print(newArray); // ['A','B'] + } +
+class: p5 +params: + - name: list + description: | +

Array to shorten

+ type: Array +return: + description: shortened Array + type: Array +chainable: false +--- + + +# shorten diff --git a/src/content/reference/en/p5 copy/shuffle.mdx b/src/content/reference/en/p5 copy/shuffle.mdx new file mode 100644 index 0000000000..a4ead252ef --- /dev/null +++ b/src/content/reference/en/p5 copy/shuffle.mdx @@ -0,0 +1,132 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L185 +title: shuffle +module: Data +submodule: Array Functions +file: src/utilities/array_functions.js +description: > +

Shuffles the elements of an array.

+ +

The first parameter, array, is the array to be shuffled. For + example, + + calling shuffle(myArray) will shuffle the elements of + myArray. By + + default, the original array won’t be modified. Instead, a copy will be + + created, shuffled, and returned.

+ +

The second parameter, modify, is optional. If + true is passed, as in + + shuffle(myArray, true), then the array will be shuffled in place + without + + making a copy.

+line: 185 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of colors. + let colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']; + + // Create a shuffled copy of the array. + let shuffledColors = shuffle(colors); + + // Draw a row of circles using the original array. + for (let i = 0; i < colors.length; i += 1) { + // Calculate the x-coordinate. + let x = (i + 1) * 12.5; + + // Style the circle. + let c = colors[i]; + fill(c); + + // Draw the circle. + circle(x, 33, 10); + } + + // Draw a row of circles using the original array. + for (let i = 0; i < shuffledColors.length; i += 1) { + // Calculate the x-coordinate. + let x = (i + 1) * 12.5; + + // Style the circle. + let c = shuffledColors[i]; + fill(c); + + // Draw the circle. + circle(x, 67, 10); + } + + describe( + 'Two rows of circles on a gray background. The top row follows the color sequence ROYGBIV. The bottom row has all the same colors but they are shuffled.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of colors. + let colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']; + + // Shuffle the array. + shuffle(colors, true); + + // Draw a row of circles using the original array. + for (let i = 0; i < colors.length; i += 1) { + // Calculate the x-coordinate. + let x = (i + 1) * 12.5; + + // Style the circle. + let c = colors[i]; + fill(c); + + // Draw the circle. + circle(x, 50, 10); + } + + describe( + 'A row of colorful circles on a gray background. Their sequence changes each time the sketch runs.' + ); + } + +
+class: p5 +params: + - name: array + description: | +

array to shuffle.

+ type: Array + - name: bool + description: > +

if true, shuffle the original array in place. Defaults to + false.

+ type: Boolean + optional: true +return: + description: shuffled array. + type: Array +chainable: false +--- + + +# shuffle diff --git a/src/content/reference/en/p5 copy/sin.mdx b/src/content/reference/en/p5 copy/sin.mdx new file mode 100644 index 0000000000..7f0cba972d --- /dev/null +++ b/src/content/reference/en/p5 copy/sin.mdx @@ -0,0 +1,107 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L363 +title: sin +module: Math +submodule: Trigonometry +file: src/math/trigonometry.js +description: > +

Calculates the sine of an angle.

+ +

sin() is useful for many geometric tasks in creative coding. + The values + + returned oscillate between -1 and 1 as the input angle increases. + sin() + + calculates the sine of an angle, using radians by default, or according to + + if angleMode() setting (RADIANS or + DEGREES).

+line: 363 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A white ball on a string oscillates up and down.'); + } + + function draw() { + background(200); + + // Calculate the coordinates. + let x = 50; + let y = 30 * sin(frameCount * 0.05) + 50; + + // Draw the oscillator. + line(50, y, x, y); + circle(x, y, 20); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + describe('A series of black dots form a wave pattern.'); + } + + function draw() { + // Calculate the coordinates. + let x = frameCount; + let y = 30 * sin(x * 0.1) + 50; + + // Draw the point. + point(x, y); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + describe('A series of black dots form an infinity symbol.'); + } + + function draw() { + // Calculate the coordinates. + let x = 30 * cos(frameCount * 0.1) + 50; + let y = 10 * sin(frameCount * 0.2) + 50; + + // Draw the point. + point(x, y); + } + +
+class: p5 +params: + - name: angle + description: > +

the angle, in radians by default, or according to + + if angleMode() setting (RADIANS or + DEGREES).

+ type: Number +return: + description: sine of the angle. + type: Number +chainable: false +--- + + +# sin diff --git a/src/content/reference/en/p5 copy/smooth.mdx b/src/content/reference/en/p5 copy/smooth.mdx new file mode 100644 index 0000000000..2c42bda62c --- /dev/null +++ b/src/content/reference/en/p5 copy/smooth.mdx @@ -0,0 +1,94 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L303 +title: smooth +module: Shape +submodule: Attributes +file: src/core/shape/attributes.js +description: > +

Draws certain features with smooth (antialiased) edges.

+ +

smooth() is active by default. In 2D mode, + + noSmooth() is helpful for scaling up + images + + without blurring. The functions don't affect shapes or fonts.

+ +

In WebGL mode, noSmooth() causes all + shapes to + + be drawn with jagged (aliased) edges. The functions don't affect images or + + fonts.

+line: 303 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let heart; + + // Load a pixelated heart image from an image data string. + function preload() { + heart = loadImage('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAAXNSR0IArs4c6QAAAEZJREFUGFd9jcsNACAIQ9tB2MeR3YdBMBBq8CIXPi2vBICIiOwkOedatllqWO6Y8yOWoyuNf1GZwgmf+RRG2YXr+xVFmA8HZ9Mx/KGPMtcAAAAASUVORK5CYII='); + } + + function setup() { + createCanvas(100, 100); + + background(50); + + // Antialiased hearts. + image(heart, 10, 10); + image(heart, 20, 10, 16, 16); + image(heart, 40, 10, 32, 32); + + // Aliased hearts. + noSmooth(); + image(heart, 10, 60); + image(heart, 20, 60, 16, 16); + image(heart, 40, 60, 32, 32); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + circle(0, 0, 80); + + describe('A white circle on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + // Disable smoothing. + noSmooth(); + + background(200); + + circle(0, 0, 80); + + describe('A pixelated white circle on a gray background.'); + } + +
+class: p5 +chainable: true +--- + + +# smooth diff --git a/src/content/reference/en/p5 copy/sort.mdx b/src/content/reference/en/p5 copy/sort.mdx new file mode 100644 index 0000000000..c2249d926a --- /dev/null +++ b/src/content/reference/en/p5 copy/sort.mdx @@ -0,0 +1,63 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L300 +title: sort +module: Data +submodule: Array Functions +file: src/utilities/array_functions.js +description: | +

Sorts an array of numbers from smallest to largest, or puts an array of + words in alphabetical order. The original array is not modified; a + re-ordered array is returned. The count parameter states the number of + elements to sort. For example, if there are 12 elements in an array and + count is set to 5, only the first 5 elements in the array will be sorted.

+line: 300 +deprecated: >- + Use array.sort() + instead. +isConstructor: false +itemtype: method +example: + - |- + +
+ function setup() { + let words = ['banana', 'apple', 'pear', 'lime']; + print(words); // ['banana', 'apple', 'pear', 'lime'] + let count = 4; // length of array + + words = sort(words, count); + print(words); // ['apple', 'banana', 'lime', 'pear'] + } +
+
+ function setup() { + let numbers = [2, 6, 1, 5, 14, 9, 8, 12]; + print(numbers); // [2, 6, 1, 5, 14, 9, 8, 12] + let count = 5; // Less than the length of the array + + numbers = sort(numbers, count); + print(numbers); // [1,2,5,6,14,9,8,12] + } +
+class: p5 +params: + - name: list + description: | +

Array to sort

+ type: Array + - name: count + description: | +

number of elements to sort, starting from 0

+ type: Integer + optional: true +return: + description: the sorted list + type: Array +chainable: false +--- + + +# sort diff --git a/src/content/reference/en/p5 copy/soundFormats.mdx b/src/content/reference/en/p5 copy/soundFormats.mdx new file mode 100644 index 0000000000..6bc28fe726 --- /dev/null +++ b/src/content/reference/en/p5 copy/soundFormats.mdx @@ -0,0 +1,51 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L925 +title: soundFormats +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: | +

List the SoundFile formats that you will include. LoadSound + will search your directory for these extensions, and will pick + a format that is compatable with the client's web browser. + Here is a free online file + converter.

+line: 925 +isConstructor: false +itemtype: method +example: + - |- + +
+ function preload() { + // set the global sound formats + soundFormats('mp3', 'ogg'); + + // load either beatbox.mp3, or .ogg, depending on browser + mySound = loadSound('/assets/beatbox.mp3'); + } + + function setup() { + let cnv = createCanvas(100, 100); + background(220); + text('sound loaded! tap to play', 10, 20, width - 20); + cnv.mousePressed(function() { + mySound.play(); + }); + } +
+class: p5 +params: + - name: formats + description: | +

i.e. 'mp3', 'wav', 'ogg'

+ type: String + optional: true + multiple: true +chainable: false +--- + + +# soundFormats diff --git a/src/content/reference/en/p5 copy/soundOut.mdx b/src/content/reference/en/p5 copy/soundOut.mdx new file mode 100644 index 0000000000..2f418a829c --- /dev/null +++ b/src/content/reference/en/p5 copy/soundOut.mdx @@ -0,0 +1,26 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L782 +title: soundOut +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: > +

p5.soundOut is the p5.sound final output bus. It sends output + to + + the destination of this window's web audio context. It contains + + Web Audio API nodes including a dyanmicsCompressor (.limiter), + + and Gain Nodes for .input and .output.

+line: 782 +isConstructor: false +itemtype: property +class: p5 +type: Object +--- + + +# soundOut diff --git a/src/content/reference/en/p5 copy/specularColor.mdx b/src/content/reference/en/p5 copy/specularColor.mdx new file mode 100644 index 0000000000..b23e834ca7 --- /dev/null +++ b/src/content/reference/en/p5 copy/specularColor.mdx @@ -0,0 +1,308 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L205 +title: specularColor +module: 3D +submodule: Lights +file: src/webgl/light.js +description: > +

Sets the specular color for lights.

+ +

specularColor() affects lights that bounce off a surface in a + preferred + + direction. These lights include + + directionalLight(), + + pointLight(), and + + spotLight(). The function helps to + create + + highlights on p5.Geometry objects that + are + + styled with specularMaterial(). + If a + + geometry does not use + + specularMaterial(), then + + specularColor() will have no effect.

+ +

Note: specularColor() doesn’t affect lights that bounce in all + + directions, including ambientLight() + and + + imageLight().

+ +

There are three ways to call specularColor() with optional + parameters to + + set the specular highlight color.

+ +

The first way to call specularColor() has two optional + parameters, gray + + and alpha. Grayscale and alpha values between 0 and 255, as in + + specularColor(50) or specularColor(50, 80), can be + passed to set the + + specular highlight color.

+ +

The second way to call specularColor() has one optional + parameter, + + color. A p5.Color object, an + array of color + + values, or a CSS color string can be passed to set the specular highlight + + color.

+ +

The third way to call specularColor() has four optional + parameters, v1, + + v2, v3, and alpha. RGBA, HSBA, or HSLA + values, as in + + specularColor(255, 0, 0, 80), can be passed to set the specular + highlight + + color. Color values will be interpreted using the current + + colorMode().

+line: 205 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white sphere drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // No specular color. + // Draw the sphere. + sphere(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click the canvas to add a point light. + + let isLit = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A sphere drawn on a gray background. A spotlight starts shining when the user double-clicks.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the sphere. + noStroke(); + specularColor(100); + specularMaterial(255, 255, 255); + + // Control the light. + if (isLit === true) { + // Add a white point light from the top-right. + pointLight(255, 255, 255, 30, -20, 40); + } + + // Draw the sphere. + sphere(30); + } + + // Turn on the point light when the user double-clicks. + function doubleClicked() { + isLit = true; + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A black sphere drawn on a gray background. An area on the surface of the sphere is highlighted in blue.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Add a specular highlight. + // Use a p5.Color object. + let c = color('dodgerblue'); + specularColor(c); + + // Add a white point light from the top-right. + pointLight(255, 255, 255, 30, -20, 40); + + // Style the sphere. + noStroke(); + + // Add a white specular material. + specularMaterial(255, 255, 255); + + // Draw the sphere. + sphere(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A black sphere drawn on a gray background. An area on the surface of the sphere is highlighted in blue.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Add a specular highlight. + // Use a CSS color string. + specularColor('#1E90FF'); + + // Add a white point light from the top-right. + pointLight(255, 255, 255, 30, -20, 40); + + // Style the sphere. + noStroke(); + + // Add a white specular material. + specularMaterial(255, 255, 255); + + // Draw the sphere. + sphere(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A black sphere drawn on a gray background. An area on the surface of the sphere is highlighted in blue.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Add a specular highlight. + // Use RGB values. + specularColor(30, 144, 255); + + // Add a white point light from the top-right. + pointLight(255, 255, 255, 30, -20, 40); + + // Style the sphere. + noStroke(); + + // Add a white specular material. + specularMaterial(255, 255, 255); + + // Draw the sphere. + sphere(30); + } + +
+class: p5 +overloads: + - line: 205 + params: + - name: v1 + description: | +

red or hue value in the current + colorMode().

+ type: Number + - name: v2 + description: | +

green or saturation value in the current + colorMode().

+ type: Number + - name: v3 + description: | +

blue, brightness, or lightness value in the current + colorMode().

+ type: Number + chainable: 1 + - line: 423 + params: + - name: gray + description: | +

grayscale value between 0 and 255.

+ type: Number + chainable: 1 + - line: 429 + params: + - name: value + description: | +

color as a CSS string.

+ type: String + chainable: 1 + - line: 435 + params: + - name: values + description: | +

color as an array of RGBA, HSBA, or HSLA + values.

+ type: 'Number[]' + chainable: 1 + - line: 442 + params: + - name: color + description: | +

color as a p5.Color object.

+ type: p5.Color + chainable: 1 +chainable: true +--- + + +# specularColor diff --git a/src/content/reference/en/p5 copy/specularMaterial.mdx b/src/content/reference/en/p5 copy/specularMaterial.mdx new file mode 100644 index 0000000000..57e8977cf5 --- /dev/null +++ b/src/content/reference/en/p5 copy/specularMaterial.mdx @@ -0,0 +1,311 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2743 +title: specularMaterial +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Sets the specular color of shapes’ surface material.

+ +

The specularMaterial() color sets the components of light + color that + + glossy coats on shapes will reflect. For example, calling + + specularMaterial(255, 255, 0) would cause a shape to reflect red + and + + green light, but not blue light.

+ +

Unlike ambientMaterial(), + + specularMaterial() will reflect the full color of light sources + including + + directionalLight(), + + pointLight(), + + and spotLight(). This is what gives it + shapes + + their "shiny" appearance. The material’s shininess can be controlled by the + + shininess() function.

+ +

specularMaterial() can be called three ways with different + parameters to + + set the material’s color.

+ +

The first way to call specularMaterial() has one parameter, + gray. + + Grayscale values between 0 and 255, as in specularMaterial(50), + can be + + passed to set the material’s color. Higher grayscale values make shapes + + appear brighter.

+ +

The second way to call specularMaterial() has one parameter, + color. A + + p5.Color> object, an array of color values, + or a CSS + + color string, as in specularMaterial('magenta'), can be passed to + set the + + material’s color.

+ +

The third way to call specularMaterial() has four parameters, + v1, v2, + + v3, and alpha. alpha is optional. RGBA, + HSBA, or HSLA values can be + + passed to set the material’s colors, as in specularMaterial(255, 0, + 0) or + + specularMaterial(255, 0, 0, 30). Color values will be interpreted + using + + the current colorMode().

+line: 2743 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click the canvas to apply a specular material. + + let isGlossy = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A red torus drawn on a gray background. It becomes glossy when the user double-clicks.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on a white point light at the top-right. + pointLight(255, 255, 255, 30, -40, 30); + + // Add a glossy coat if the user has double-clicked. + if (isGlossy === true) { + specularMaterial(255); + shininess(50); + } + + // Style the torus. + noStroke(); + fill(255, 0, 0); + + // Draw the torus. + torus(30); + } + + // Make the torus glossy when the user double-clicks. + function doubleClicked() { + isGlossy = true; + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click the canvas to apply a specular material. + + let isGlossy = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'A red torus drawn on a gray background. It becomes glossy and reflects green light when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on a white point light at the top-right. + pointLight(255, 255, 255, 30, -40, 30); + + // Add a glossy green coat if the user has double-clicked. + if (isGlossy === true) { + specularMaterial(0, 255, 0); + shininess(50); + } + + // Style the torus. + noStroke(); + fill(255, 0, 0); + + // Draw the torus. + torus(30); + } + + // Make the torus glossy when the user double-clicks. + function doubleClicked() { + isGlossy = true; + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click the canvas to apply a specular material. + + let isGlossy = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'A red torus drawn on a gray background. It becomes glossy and reflects green light when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on a white point light at the top-right. + pointLight(255, 255, 255, 30, -40, 30); + + // Add a glossy green coat if the user has double-clicked. + if (isGlossy === true) { + // Create a p5.Color object. + let c = color('green'); + specularMaterial(c); + shininess(50); + } + + // Style the torus. + noStroke(); + fill(255, 0, 0); + + // Draw the torus. + torus(30); + } + + // Make the torus glossy when the user double-clicks. + function doubleClicked() { + isGlossy = true; + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click the canvas to apply a specular material. + + let isGlossy = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'A red torus drawn on a gray background. It becomes glossy and reflects green light when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on a white point light at the top-right. + pointLight(255, 255, 255, 30, -40, 30); + + // Add a glossy green coat if the user has double-clicked. + if (isGlossy === true) { + specularMaterial('#00FF00'); + shininess(50); + } + + // Style the torus. + noStroke(); + fill(255, 0, 0); + + // Draw the torus. + torus(30); + } + + // Make the torus glossy when the user double-clicks. + function doubleClicked() { + isGlossy = true; + } + +
+class: p5 +overloads: + - line: 2743 + params: + - name: gray + description: | +

grayscale value between 0 (black) and 255 (white).

+ type: Number + - name: alpha + description: | +

alpha value in the current current + colorMode().

+ type: Number + optional: true + chainable: 1 + - line: 2966 + params: + - name: v1 + description: | +

red or hue value in + the current colorMode().

+ type: Number + - name: v2 + description: | +

green or saturation value + in the current colorMode().

+ type: Number + - name: v3 + description: | +

blue, brightness, or lightness value + in the current colorMode().

+ type: Number + - name: alpha + description: '' + type: Number + optional: true + chainable: 1 + - line: 2978 + params: + - name: color + description: | +

color as a p5.Color object, + an array of color values, or a CSS string.

+ type: 'p5.Color|Number[]|String' + chainable: 1 +chainable: true +--- + + +# specularMaterial diff --git a/src/content/reference/en/p5 copy/sphere.mdx b/src/content/reference/en/p5 copy/sphere.mdx new file mode 100644 index 0000000000..c2ceca44ad --- /dev/null +++ b/src/content/reference/en/p5 copy/sphere.mdx @@ -0,0 +1,165 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L1227 +title: sphere +module: Shape +submodule: 3D Primitives +file: src/webgl/3d_primitives.js +description: > +

Draws a sphere.

+ +

A sphere is a 3D shape with triangular faces that connect to form a round + + surface. Spheres with few faces look like crystals. Spheres with many faces + + have smooth surfaces and look like balls.

+ +

The first parameter, radius, is optional. If a + Number is passed, as in + + sphere(20), it sets the radius of the sphere. By default, + radius is 50.

+ +

The second parameter, detailX, is also optional. If a + Number is passed, + + as in sphere(20, 5), it sets the number of triangle subdivisions + to use + + along the x-axis. All 3D shapes are made by connecting triangles to form + + their surfaces. By default, detailX is 24.

+ +

The third parameter, detailY, is also optional. If a + Number is passed, + + as in sphere(20, 5, 2), it sets the number of triangle + subdivisions to + + use along the y-axis. All 3D shapes are made by connecting triangles to + + form their surfaces. By default, detailY is 16.

+ +

Note: sphere() can only be used in WebGL mode.

+line: 1227 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white sphere on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the sphere. + sphere(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white sphere on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the sphere. + // Set its radius to 30. + sphere(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white sphere on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the sphere. + // Set its radius to 30. + // Set its detailX to 6. + sphere(30, 6); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white sphere on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the sphere. + // Set its radius to 30. + // Set its detailX to 24. + // Set its detailY to 4. + sphere(30, 24, 4); + } + +
+class: p5 +params: + - name: radius + description: | +

radius of the sphere. Defaults to 50.

+ type: Number + optional: true + - name: detailX + description: | +

number of triangle subdivisions along the x-axis. Defaults to 24.

+ type: Integer + optional: true + - name: detailY + description: | +

number of triangle subdivisions along the y-axis. Defaults to 16.

+ type: Integer + optional: true +chainable: true +--- + + +# sphere diff --git a/src/content/reference/en/p5 copy/splice.mdx b/src/content/reference/en/p5 copy/splice.mdx new file mode 100644 index 0000000000..866bc4ddef --- /dev/null +++ b/src/content/reference/en/p5 copy/splice.mdx @@ -0,0 +1,58 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L346 +title: splice +module: Data +submodule: Array Functions +file: src/utilities/array_functions.js +description: | +

Inserts a value or an array of values into an existing array. The first + parameter specifies the initial array to be modified, and the second + parameter defines the data to be inserted. The third parameter is an index + value which specifies the array position from which to insert data. + (Remember that array index numbering starts at zero, so the first position + is 0, the second position is 1, and so on.)

+line: 346 +deprecated: >- + Use array.splice() + instead. +isConstructor: false +itemtype: method +example: + - |- + +
+ function setup() { + let myArray = [0, 1, 2, 3, 4]; + let insArray = ['A', 'B', 'C']; + print(myArray); // [0, 1, 2, 3, 4] + print(insArray); // ['A','B','C'] + + splice(myArray, insArray, 3); + print(myArray); // [0,1,2,'A','B','C',3,4] + } +
+class: p5 +params: + - name: list + description: | +

Array to splice into

+ type: Array + - name: value + description: | +

value to be spliced in

+ type: Any + - name: position + description: | +

in the array from which to insert data

+ type: Integer +return: + description: the list + type: Array +chainable: false +--- + + +# splice diff --git a/src/content/reference/en/p5 copy/split.mdx b/src/content/reference/en/p5 copy/split.mdx new file mode 100644 index 0000000000..60b7944313 --- /dev/null +++ b/src/content/reference/en/p5 copy/split.mdx @@ -0,0 +1,87 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L690 +title: split +module: Data +submodule: String Functions +file: src/utilities/string_functions.js +description: > +

Splits a String into pieces and returns an array containing + the pieces.

+ +

The first parameter, value, is the string to split.

+ +

The second parameter, delim, is the character(s) that should + be used to + + split the string. For example, calling + + split('rock...paper...scissors', '...') would return the array + + ['rock', 'paper', 'scissors'] because there are three periods + ... + + between each word.

+line: 690 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let string = 'rock...paper...scissors'; + + // Split the string at each ... + let words = split(string, '...'); + + // Print the array to the console: + // ["rock", "paper", "scissors"] + print(words); + + // Style the text. + textAlign(CENTER, CENTER); + textFont('Courier New'); + textSize(16); + + // Iterate over the words array. + for (let i = 0; i < words.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 25; + + // Display the word. + text(words[i], 50, y); + } + + describe( + 'The words "rock", "paper", and "scissors" written on separate lines. The text is black on a gray background.' + ); + } + +
+class: p5 +params: + - name: value + description: | +

the String to be split

+ type: String + - name: delim + description: | +

the String used to separate the data

+ type: String +return: + description: Array of Strings + type: 'String[]' +chainable: false +--- + + +# split diff --git a/src/content/reference/en/p5 copy/splitTokens.mdx b/src/content/reference/en/p5 copy/splitTokens.mdx new file mode 100644 index 0000000000..95d6ef4f8e --- /dev/null +++ b/src/content/reference/en/p5 copy/splitTokens.mdx @@ -0,0 +1,180 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L751 +title: splitTokens +module: Data +submodule: String Functions +file: src/utilities/string_functions.js +description: > +

Splits a String into pieces and returns an array containing + the pieces.

+ +

splitTokens() is an enhanced version of + + split(). It can split a string when any + characters + + from a list are detected.

+ +

The first parameter, value, is the string to split.

+ +

The second parameter, delim, is optional. It sets the + character(s) that + + should be used to split the string. delim can be a single string, + as in + + splitTokens('rock...paper...scissors...shoot', '...'), or an + array of + + strings, as in + + splitTokens('rock;paper,scissors...shoot, [';', ',', '...']). By + default, + + if no delim characters are specified, then any whitespace + character is + + used to split. Whitespace characters include tab (\t), line feed + (\n), + + carriage return (\r), form feed (\f), and space.

+line: 751 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let string = 'rock paper scissors shoot'; + + // Split the string at each space. + let words = splitTokens(string); + + // Print the array to the console. + print(words); + + // Style the text. + textAlign(CENTER, CENTER); + textFont('Courier New'); + textSize(12); + + // Iterate over the words array. + for (let i = 0; i < words.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 20; + + // Display the word. + text(words[i], 50, y); + } + + describe( + 'The words "rock", "paper", "scissors", and "shoot" written on separate lines. The text is black on a gray background.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let string = 'rock...paper...scissors...shoot'; + + // Split the string at each ... + let words = splitTokens(string, '...'); + + // Print the array to the console. + print(words); + + // Style the text. + textAlign(CENTER, CENTER); + textFont('Courier New'); + textSize(12); + + // Iterate over the words array. + for (let i = 0; i < words.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 20; + + // Display the word. + text(words[i], 50, y); + } + + describe( + 'The words "rock", "paper", "scissors", and "shoot" written on separate lines. The text is black on a gray background.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let string = 'rock;paper,scissors...shoot'; + + // Split the string at each semicolon, comma, or ... + let words = splitTokens(string, [';', ',', '...']); + + // Print the array to the console. + print(words); + + // Style the text. + textAlign(CENTER, CENTER); + textFont('Courier New'); + textSize(12); + + // Iterate over the words array. + for (let i = 0; i < words.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 20; + + // Display the word. + text(words[i], 50, y); + } + + describe( + 'The words "rock", "paper", "scissors", and "shoot" written on separate lines. The text is black on a gray background.' + ); + } + +
+class: p5 +params: + - name: value + description: | +

string to split.

+ type: String + - name: delim + description: | +

character(s) to use for splitting the string.

+ type: String + optional: true +return: + description: separated strings. + type: 'String[]' +chainable: false +--- + + +# splitTokens diff --git a/src/content/reference/en/p5 copy/spotLight.mdx b/src/content/reference/en/p5 copy/spotLight.mdx new file mode 100644 index 0000000000..3d221dc8f4 --- /dev/null +++ b/src/content/reference/en/p5 copy/spotLight.mdx @@ -0,0 +1,398 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L1272 +title: spotLight +module: 3D +submodule: Lights +file: src/webgl/light.js +description: > +

Creates a light that shines from a point in one direction.

+ +

Spot lights are like flashlights that shine in one direction creating a + + cone of light. The shape of the cone can be controlled using the angle and + + concentration parameters. A maximum of 5 spot lights can be active at + once.

+ +

There are eight ways to call spotLight() with parameters to + set the + + light’s color, position, direction. For example, + + spotLight(255, 0, 0, 0, 0, 0, 1, 0, 0) creates a red (255, + 0, 0) light + + at the origin (0, 0, 0) that points to the right (1, 0, + 0).

+ +

The angle parameter is optional. It sets the radius of the + light cone. + + For example, spotLight(255, 0, 0, 0, 0, 0, 1, 0, 0, PI / 16) + creates a + + red (255, 0, 0) light at the origin (0, 0, 0) that + points to the right + + (1, 0, 0) with an angle of PI / 16 radians. By + default, angle is + + PI / 3 radians.

+ +

The concentration parameter is also optional. It focuses the + light + + towards the center of the light cone. For example, + + spotLight(255, 0, 0, 0, 0, 0, 1, 0, 0, PI / 16, 50) creates a red + + (255, 0, 0) light at the origin (0, 0, 0) that + points to the right + + (1, 0, 0) with an angle of PI / 16 radians at + concentration of 50. By + + default, concentration is 100.

+line: 1272 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click to adjust the spotlight. + + let isLit = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white sphere drawn on a gray background. A red spotlight starts shining when the user double-clicks.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Control the spotlight. + if (isLit === true) { + // Add a red spot light that shines into the screen. + // Set its angle to PI / 32 radians. + spotLight(255, 0, 0, 0, 0, 100, 0, 0, -1, PI / 32); + } + + // Draw the sphere. + sphere(30); + } + + // Turn on the spotlight when the user double-clicks. + function doubleClicked() { + isLit = true; + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click to adjust the spotlight. + + let isLit = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white sphere drawn on a gray background. A red spotlight starts shining when the user double-clicks.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Control the spotlight. + if (isLit === true) { + // Add a red spot light that shines into the screen. + // Set its angle to PI / 3 radians (default). + // Set its concentration to 1000. + let c = color(255, 0, 0); + let position = createVector(0, 0, 100); + let direction = createVector(0, 0, -1); + spotLight(c, position, direction, PI / 3, 1000); + } + + // Draw the sphere. + sphere(30); + } + + // Turn on the spotlight when the user double-clicks. + function doubleClicked() { + isLit = true; + } + +
+class: p5 +overloads: + - line: 1272 + params: + - name: v1 + description: | +

red or hue value in the current + colorMode().

+ type: Number + - name: v2 + description: | +

green or saturation value in the current + colorMode().

+ type: Number + - name: v3 + description: | +

blue, brightness, or lightness value in the current + colorMode().

+ type: Number + - name: x + description: | +

x-coordinate of the light.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the light.

+ type: Number + - name: z + description: | +

z-coordinate of the light.

+ type: Number + - name: rx + description: | +

x-component of light direction between -1 and 1.

+ type: Number + - name: ry + description: | +

y-component of light direction between -1 and 1.

+ type: Number + - name: rz + description: | +

z-component of light direction between -1 and 1.

+ type: Number + - name: angle + description: | +

angle of the light cone. Defaults to PI / 3.

+ type: Number + optional: true + - name: concentration + description: | +

concentration of the light. Defaults to 100.

+ type: Number + optional: true + chainable: 1 + - line: 1399 + params: + - name: color + description: | +

color as a p5.Color object, + an array of color values, or a CSS string.

+ type: 'p5.Color|Number[]|String' + - name: position + description: > +

position of the light as a p5.Vector + object.

+ type: p5.Vector + - name: direction + description: > +

direction of light as a p5.Vector + object.

+ type: p5.Vector + - name: angle + description: '' + type: Number + optional: true + - name: concentration + description: '' + type: Number + optional: true + - line: 1408 + params: + - name: v1 + description: '' + type: Number + - name: v2 + description: '' + type: Number + - name: v3 + description: '' + type: Number + - name: position + description: '' + type: p5.Vector + - name: direction + description: '' + type: p5.Vector + - name: angle + description: '' + type: Number + optional: true + - name: concentration + description: '' + type: Number + optional: true + - line: 1418 + params: + - name: color + description: '' + type: 'p5.Color|Number[]|String' + - name: x + description: '' + type: Number + - name: 'y' + description: '' + type: Number + - name: z + description: '' + type: Number + - name: direction + description: '' + type: p5.Vector + - name: angle + description: '' + type: Number + optional: true + - name: concentration + description: '' + type: Number + optional: true + - line: 1428 + params: + - name: color + description: '' + type: 'p5.Color|Number[]|String' + - name: position + description: '' + type: p5.Vector + - name: rx + description: '' + type: Number + - name: ry + description: '' + type: Number + - name: rz + description: '' + type: Number + - name: angle + description: '' + type: Number + optional: true + - name: concentration + description: '' + type: Number + optional: true + - line: 1438 + params: + - name: v1 + description: '' + type: Number + - name: v2 + description: '' + type: Number + - name: v3 + description: '' + type: Number + - name: x + description: '' + type: Number + - name: 'y' + description: '' + type: Number + - name: z + description: '' + type: Number + - name: direction + description: '' + type: p5.Vector + - name: angle + description: '' + type: Number + optional: true + - name: concentration + description: '' + type: Number + optional: true + - line: 1450 + params: + - name: v1 + description: '' + type: Number + - name: v2 + description: '' + type: Number + - name: v3 + description: '' + type: Number + - name: position + description: '' + type: p5.Vector + - name: rx + description: '' + type: Number + - name: ry + description: '' + type: Number + - name: rz + description: '' + type: Number + - name: angle + description: '' + type: Number + optional: true + - name: concentration + description: '' + type: Number + optional: true + - line: 1462 + params: + - name: color + description: '' + type: 'p5.Color|Number[]|String' + - name: x + description: '' + type: Number + - name: 'y' + description: '' + type: Number + - name: z + description: '' + type: Number + - name: rx + description: '' + type: Number + - name: ry + description: '' + type: Number + - name: rz + description: '' + type: Number + - name: angle + description: '' + type: Number + optional: true + - name: concentration + description: '' + type: Number + optional: true +chainable: true +--- + + +# spotLight diff --git a/src/content/reference/en/p5 copy/sq.mdx b/src/content/reference/en/p5 copy/sq.mdx new file mode 100644 index 0000000000..da0f2c4024 --- /dev/null +++ b/src/content/reference/en/p5 copy/sq.mdx @@ -0,0 +1,83 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L928 +title: sq +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Calculates the square of a number.

+ +

Squaring a number means multiplying the number by itself. For example, + + sq(3) evaluates 3 × 3 which is 9. sq(-3) evaluates + -3 × -3 + + which is also 9. Multiplying two negative numbers produces a positive + + number. The value returned by sq() is always positive.

+line: 928 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Top-left. + let d = sq(3); + circle(33, 33, d); + + // Bottom-right. + d = sq(6); + circle(67, 67, d); + + describe('Two white circles. The circle at the top-left is small. The circle at the bottom-right is four times larger.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + describe('A series of black dots that get higher quickly from left to right.'); + } + + function draw() { + // Invert the y-axis. + scale(1, -1); + translate(0, -100); + + // Calculate the coordinates. + let x = frameCount; + let y = 0.01 * sq(x); + + // Draw the point. + point(x, y); + } + +
+class: p5 +params: + - name: 'n' + description: | +

number to square.

+ type: Number +return: + description: squared number. + type: Number +chainable: false +--- + + +# sq diff --git a/src/content/reference/en/p5 copy/sqrt.mdx b/src/content/reference/en/p5 copy/sqrt.mdx new file mode 100644 index 0000000000..5e239f6fe4 --- /dev/null +++ b/src/content/reference/en/p5 copy/sqrt.mdx @@ -0,0 +1,84 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L988 +title: sqrt +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Calculates the square root of a number.

+ +

A number's square root can be multiplied by itself to produce the original + + number. For example, sqrt(9) returns 3 because 3 × 3 = 9. + sqrt() + + always returns a positive value. sqrt() doesn't work with + negative arguments + + such as sqrt(-9).

+line: 988 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Top-left. + let d = sqrt(16); + circle(33, 33, d); + + // Bottom-right. + d = sqrt(1600); + circle(67, 67, d); + + describe('Two white circles. The circle at the top-left is small. The circle at the bottom-right is ten times larger.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + describe('A series of black dots that get higher slowly from left to right.'); + } + + function draw() { + // Invert the y-axis. + scale(1, -1); + translate(0, -100); + + // Calculate the coordinates. + let x = frameCount; + let y = 5 * sqrt(x); + + // Draw the point. + point(x, y); + } + +
+class: p5 +params: + - name: 'n' + description: | +

non-negative number to square root.

+ type: Number +return: + description: square root of number. + type: Number +chainable: false +--- + + +# sqrt diff --git a/src/content/reference/en/p5 copy/square.mdx b/src/content/reference/en/p5 copy/square.mdx new file mode 100644 index 0000000000..1e94a0087d --- /dev/null +++ b/src/content/reference/en/p5 copy/square.mdx @@ -0,0 +1,163 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L1229 +title: square +module: Shape +submodule: 2D Primitives +file: src/core/shape/2d_primitives.js +description: > +

Draws a square.

+ +

A square is a four-sided shape defined by the x, + y, and s + + parameters. x and y set the location of its top-left + corner. s sets + + its width and height. Every angle in the square measures 90˚ and all its + + sides are the same length. See rectMode() for + + other ways to define squares.

+ +

The version of square() with four parameters creates a rounded + square. + + The fourth parameter sets the radius for all four corners.

+ +

The version of square() with seven parameters also creates a + rounded + + square. Each of the last four parameters set the radius of a corner. The + + radii start with the top-left corner and move clockwise around the + + square. If any of these parameters are omitted, they are set to the + + value of the last radius that was set.

+line: 1229 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + square(30, 20, 55); + + describe('A white square with a black outline in on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Give all corners a radius of 20. + square(30, 20, 55, 20); + + describe( + 'A white square with a black outline and round edges on a gray canvas.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Give each corner a unique radius. + square(30, 20, 55, 20, 15, 10, 5); + + describe('A white square with a black outline and round edges of different radii.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + square(-20, -30, 55); + + describe('A white square with a black outline in on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white square spins around on gray canvas.'); + } + + function draw() { + background(200); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Draw the square. + square(-20, -30, 55); + } + +
+class: p5 +params: + - name: x + description: | +

x-coordinate of the square.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the square.

+ type: Number + - name: s + description: | +

side size of the square.

+ type: Number + - name: tl + description: | +

optional radius of top-left corner.

+ type: Number + optional: true + - name: tr + description: | +

optional radius of top-right corner.

+ type: Number + optional: true + - name: br + description: | +

optional radius of bottom-right corner.

+ type: Number + optional: true + - name: bl + description: | +

optional radius of bottom-left corner.

+ type: Number + optional: true +chainable: true +--- + + +# square diff --git a/src/content/reference/en/p5 copy/storeItem.mdx b/src/content/reference/en/p5 copy/storeItem.mdx new file mode 100644 index 0000000000..8552634c5a --- /dev/null +++ b/src/content/reference/en/p5 copy/storeItem.mdx @@ -0,0 +1,149 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/data/local_storage.js#L10 +title: storeItem +module: Data +submodule: LocalStorage +file: src/data/local_storage.js +description: > +

Stores a value in the web browser's local storage.

+ +

Web browsers can save small amounts of data using the built-in + + localStorage object. + + Data stored in localStorage can be retrieved at any point, even + after + + refreshing a page or restarting the browser. Data are stored as key-value + + pairs.

+ +

storeItem() makes it easy to store values in + localStorage and + + getItem() makes it easy to retrieve + them.

+ +

The first parameter, key, is the name of the value to be + stored as a + + string.

+ +

The second parameter, value, is the value to be stored. Values + can have + + any type.

+ +

Note: Sensitive data such as passwords or personal information shouldn't be + + stored in localStorage.

+line: 10 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Store the player's name. + storeItem('name', 'Feist'); + + // Store the player's score. + storeItem('score', 1234); + + describe('The text "Feist: 1234" written in black on a gray background.'); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(14); + + // Retrieve the name. + let name = getItem('name'); + + // Retrieve the score. + let score = getItem('score'); + + // Display the score. + text(`${name}: ${score}`, 50, 50); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Create an object. + let p = { x: 50, y: 50 }; + + // Store the object. + storeItem('position', p); + + describe('A white circle on a gray background.'); + } + + function draw() { + background(200); + + // Retrieve the object. + let p = getItem('position'); + + // Draw the circle. + circle(p.x, p.y, 30); + } + +
+ + function setup() { + createCanvas(100, 100); + + // Create a p5.Color object. + let c = color('deeppink'); + + // Store the object. + storeItem('color', c); + + describe('A pink circle on a gray background.'); + } + + function draw() { + background(200); + + // Retrieve the object. + let c = getItem('color'); + + // Style the circle. + fill(c); + + // Draw the circle. + circle(50, 50, 30); + } + + +class: p5 +params: + - name: key + description: | +

name of the value.

+ type: String + - name: value + description: | +

value to be stored.

+ type: String|Number|Boolean|Object|Array +chainable: false +--- + + +# storeItem diff --git a/src/content/reference/en/p5 copy/str.mdx b/src/content/reference/en/p5 copy/str.mdx new file mode 100644 index 0000000000..c487979761 --- /dev/null +++ b/src/content/reference/en/p5 copy/str.mdx @@ -0,0 +1,135 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L232 +title: str +module: Data +submodule: Conversion +file: src/utilities/conversion.js +description: > +

Converts a Boolean or Number to + String.

+ +

str() converts values to strings. See the + + String reference page for guidance on + using + + template literals instead.

+ +

The parameter, n, is the value to convert. If n + is a Boolean, as in + + str(false) or str(true), then the value will be + returned as a string, + + as in 'false' or 'true'. If n is a + number, as in str(123), then its + + value will be returned as a string, as in '123'. If an array is + passed, + + as in str([12.34, 56.78]), then an array of strings will be + returned.

+line: 232 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a Boolean variable. + let original = false; + + // Convert the Boolean to a string. + let converted = str(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the original and converted values. + text(`${original} : ${converted}`, 50, 50); + + describe('The text "false : false" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a number variable. + let original = 123; + + // Convert the number to a string. + let converted = str(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the original and converted values. + text(`${original} = ${converted}`, 50, 50); + + describe('The text "123 = 123" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of numbers. + let original = [12, 34, 56]; + + // Convert the numbers to strings. + let strings = str(original); + + // Create an empty string variable. + let final = ''; + + // Concatenate all the strings. + for (let s of strings) { + final += s; + } + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the concatenated string. + text(final, 50, 50); + + describe('The text "123456" written in black on a gray background.'); + } + +
+class: p5 +params: + - name: 'n' + description: | +

value to convert.

+ type: String|Boolean|Number +return: + description: converted string. + type: String +chainable: false +--- + + +# str diff --git a/src/content/reference/en/p5 copy/stroke.mdx b/src/content/reference/en/p5 copy/stroke.mdx new file mode 100644 index 0000000000..bf086f9b66 --- /dev/null +++ b/src/content/reference/en/p5 copy/stroke.mdx @@ -0,0 +1,311 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1373 +title: stroke +module: Color +submodule: Setting +file: src/color/setting.js +description: > +

Sets the color used to draw points, lines, and the outlines of shapes.

+ +

Calling stroke(255, 165, 0) or stroke('orange') + means all shapes drawn + + after calling stroke() will be outlined with the color orange. + The way + + these parameters are interpreted may be changed with the + + colorMode() function.

+ +

The version of stroke() with one parameter interprets the + value one of + + three ways. If the parameter is a Number, it's interpreted as a + grayscale + + value. If the parameter is a String, it's interpreted as a CSS + color + + string. A p5.Color object can also be + provided to + + set the stroke color.

+ +

The version of stroke() with two parameters interprets the + first one as a + + grayscale value. The second parameter sets the alpha (transparency) value.

+ +

The version of stroke() with three parameters interprets them + as RGB, HSB, + + or HSL colors, depending on the current colorMode().

+ +

The version of stroke() with four parameters interprets them + as RGBA, HSBA, + + or HSLA colors, depending on the current colorMode(). The last + parameter + + sets the alpha (transparency) value.

+line: 1373 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // A grayscale value. + strokeWeight(4); + stroke(51); + square(20, 20, 60); + + describe('A white square with a dark charcoal gray outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // R, G & B values. + stroke(255, 204, 0); + strokeWeight(4); + square(20, 20, 60); + + describe('A white square with a yellow outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use HSB color. + colorMode(HSB); + + // H, S & B values. + strokeWeight(4); + stroke(255, 204, 100); + square(20, 20, 60); + + describe('A white square with a royal blue outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // A CSS named color. + stroke('red'); + strokeWeight(4); + square(20, 20, 60); + + describe('A white square with a red outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Three-digit hex RGB notation. + stroke('#fae'); + strokeWeight(4); + square(20, 20, 60); + + describe('A white square with a pink outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Six-digit hex RGB notation. + stroke('#222222'); + strokeWeight(4); + square(20, 20, 60); + + describe('A white square with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Integer RGB notation. + stroke('rgb(0, 255, 0)'); + strokeWeight(4); + square(20, 20, 60); + + describe('A whiite square with a bright green outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Integer RGBA notation. + stroke('rgba(0, 255, 0, 0.25)'); + strokeWeight(4); + square(20, 20, 60); + + describe('A white square with a soft green outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Percentage RGB notation. + stroke('rgb(100%, 0%, 10%)'); + strokeWeight(4); + square(20, 20, 60); + + describe('A white square with a red outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Percentage RGBA notation. + stroke('rgba(100%, 0%, 100%, 0.5)'); + strokeWeight(4); + square(20, 20, 60); + + describe('A white square with a dark fuchsia outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // A p5.Color object. + stroke(color(0, 0, 255)); + strokeWeight(4); + square(20, 20, 60); + + describe('A white square with a blue outline.'); + } + +
+class: p5 +overloads: + - line: 1373 + params: + - name: v1 + description: > +

red value if color mode is RGB or hue value if color mode is + HSB.

+ type: Number + - name: v2 + description: > +

green value if color mode is RGB or saturation value if color mode + is HSB.

+ type: Number + - name: v3 + description: > +

blue value if color mode is RGB or brightness value if color mode + is HSB.

+ type: Number + - name: alpha + description: > +

alpha value, controls transparency (0 - transparent, 255 - + opaque).

+ type: Number + optional: true + chainable: 1 + - line: 1596 + params: + - name: value + description: | +

a color string.

+ type: String + chainable: 1 + - line: 1602 + params: + - name: gray + description: | +

a grayscale value.

+ type: Number + - name: alpha + description: '' + type: Number + optional: true + chainable: 1 + - line: 1609 + params: + - name: values + description: | +

an array containing the red, green, blue, + and alpha components of the color.

+ type: 'Number[]' + chainable: 1 + - line: 1616 + params: + - name: color + description: | +

the stroke color.

+ type: p5.Color + chainable: 1 +chainable: true +--- + + +# stroke diff --git a/src/content/reference/en/p5 copy/strokeCap.mdx b/src/content/reference/en/p5 copy/strokeCap.mdx new file mode 100644 index 0000000000..80965419ab --- /dev/null +++ b/src/content/reference/en/p5 copy/strokeCap.mdx @@ -0,0 +1,67 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L388 +title: strokeCap +module: Shape +submodule: Attributes +file: src/core/shape/attributes.js +description: > +

Sets the style for rendering the ends of lines.

+ +

The caps for line endings are either rounded (ROUND), squared + + (SQUARE), or extended (PROJECT). The default cap is + ROUND.

+ +

The argument passed to strokeCap() must be written in ALL CAPS + because + + the constants ROUND, SQUARE, and + PROJECT are defined this way. + + JavaScript is a case-sensitive language.

+line: 388 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + strokeWeight(12); + + // Top. + strokeCap(ROUND); + line(20, 30, 80, 30); + + // Middle. + strokeCap(SQUARE); + line(20, 50, 80, 50); + + // Bottom. + strokeCap(PROJECT); + line(20, 70, 80, 70); + + describe( + 'Three horizontal lines. The top line has rounded ends, the middle line has squared ends, and the bottom line has longer, squared ends.' + ); + } + +
+class: p5 +params: + - name: cap + description: | +

either ROUND, SQUARE, or PROJECT

+ type: Constant +chainable: true +--- + + +# strokeCap diff --git a/src/content/reference/en/p5 copy/strokeJoin.mdx b/src/content/reference/en/p5 copy/strokeJoin.mdx new file mode 100644 index 0000000000..46a8a9206f --- /dev/null +++ b/src/content/reference/en/p5 copy/strokeJoin.mdx @@ -0,0 +1,114 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L442 +title: strokeJoin +module: Shape +submodule: Attributes +file: src/core/shape/attributes.js +description: > +

Sets the style of the joints that connect line segments.

+ +

Joints are either mitered (MITER), beveled + (BEVEL), or rounded + + (ROUND). The default joint is MITER in 2D mode and + ROUND in WebGL + + mode.

+ +

The argument passed to strokeJoin() must be written in ALL + CAPS because + + the constants MITER, BEVEL, and ROUND + are defined this way. + + JavaScript is a case-sensitive language.

+line: 442 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the line. + noFill(); + strokeWeight(10); + strokeJoin(MITER); + + // Draw the line. + beginShape(); + vertex(35, 20); + vertex(65, 50); + vertex(35, 80); + endShape(); + + describe('A right-facing arrowhead shape with a pointed tip in center of canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the line. + noFill(); + strokeWeight(10); + strokeJoin(BEVEL); + + // Draw the line. + beginShape(); + vertex(35, 20); + vertex(65, 50); + vertex(35, 80); + endShape(); + + describe('A right-facing arrowhead shape with a flat tip in center of canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the line. + noFill(); + strokeWeight(10); + strokeJoin(ROUND); + + // Draw the line. + beginShape(); + vertex(35, 20); + vertex(65, 50); + vertex(35, 80); + endShape(); + + describe('A right-facing arrowhead shape with a rounded tip in center of canvas.'); + } + +
+class: p5 +params: + - name: join + description: | +

either MITER, BEVEL, or ROUND

+ type: Constant +chainable: true +--- + + +# strokeJoin diff --git a/src/content/reference/en/p5 copy/strokeWeight.mdx b/src/content/reference/en/p5 copy/strokeWeight.mdx new file mode 100644 index 0000000000..82ebfc13d5 --- /dev/null +++ b/src/content/reference/en/p5 copy/strokeWeight.mdx @@ -0,0 +1,77 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L541 +title: strokeWeight +module: Shape +submodule: Attributes +file: src/core/shape/attributes.js +description: > +

Sets the width of the stroke used for points, lines, and the outlines of + + shapes.

+ +

Note: strokeWeight() is affected by transformations, + especially calls to + + scale().

+line: 541 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Top. + line(20, 20, 80, 20); + + // Middle. + strokeWeight(4); + line(20, 40, 80, 40); + + // Bottom. + strokeWeight(10); + line(20, 70, 80, 70); + + describe('Three horizontal black lines. The top line is thin, the middle is medium, and the bottom is thick.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Top. + line(20, 20, 80, 20); + + // Scale by a factor of 5. + scale(5); + + // Bottom. Coordinates are adjusted for scaling. + line(4, 8, 16, 8); + + describe('Two horizontal black lines. The top line is thin and the bottom is five times thicker than the top.'); + } + +
+class: p5 +params: + - name: weight + description: | +

the weight of the stroke (in pixels).

+ type: Number +chainable: true +--- + + +# strokeWeight diff --git a/src/content/reference/en/p5 copy/subset.mdx b/src/content/reference/en/p5 copy/subset.mdx new file mode 100644 index 0000000000..1cf7cb7f4e --- /dev/null +++ b/src/content/reference/en/p5 copy/subset.mdx @@ -0,0 +1,59 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L381 +title: subset +module: Data +submodule: Array Functions +file: src/utilities/array_functions.js +description: | +

Extracts an array of elements from an existing array. The list parameter + defines the array from which the elements will be copied, and the start + and count parameters specify which elements to extract. If no count is + given, elements will be extracted from the start to the end of the array. + When specifying the start, remember that the first array element is 0. + This function does not change the source array.

+line: 381 +deprecated: >- + Use array.slice() + instead. +isConstructor: false +itemtype: method +example: + - |- + +
+ function setup() { + let myArray = [1, 2, 3, 4, 5]; + print(myArray); // [1, 2, 3, 4, 5] + + let sub1 = subset(myArray, 0, 3); + let sub2 = subset(myArray, 2, 2); + print(sub1); // [1,2,3] + print(sub2); // [3,4] + } +
+class: p5 +params: + - name: list + description: | +

Array to extract from

+ type: Array + - name: start + description: | +

position to begin

+ type: Integer + - name: count + description: | +

number of values to extract

+ type: Integer + optional: true +return: + description: Array of extracted elements + type: Array +chainable: false +--- + + +# subset diff --git a/src/content/reference/en/p5 copy/tan.mdx b/src/content/reference/en/p5 copy/tan.mdx new file mode 100644 index 0000000000..376d093f33 --- /dev/null +++ b/src/content/reference/en/p5 copy/tan.mdx @@ -0,0 +1,66 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L445 +title: tan +module: Math +submodule: Trigonometry +file: src/math/trigonometry.js +description: > +

Calculates the tangent of an angle.

+ +

tan() is useful for many geometric tasks in creative coding. + The values + + returned range from -Infinity to Infinity and repeat periodically as the + + input angle increases. tan() calculates the tan of an angle, + using radians + + by default, or according to + + if angleMode() setting (RADIANS or + DEGREES).

+line: 445 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + describe('A series of identical curves drawn with black dots. Each curve starts from the top of the canvas, continues down at a slight angle, flattens out at the middle of the canvas, then continues to the bottom.'); + } + + function draw() { + // Calculate the coordinates. + let x = frameCount; + let y = 5 * tan(x * 0.1) + 50; + + // Draw the point. + point(x, y); + } + +
+class: p5 +params: + - name: angle + description: > +

the angle, in radians by default, or according to + + if angleMode() setting (RADIANS or + DEGREES).

+ type: Number +return: + description: tangent of the angle. + type: Number +chainable: false +--- + + +# tan diff --git a/src/content/reference/en/p5 copy/text.mdx b/src/content/reference/en/p5 copy/text.mdx new file mode 100644 index 0000000000..eea293bfd8 --- /dev/null +++ b/src/content/reference/en/p5 copy/text.mdx @@ -0,0 +1,96 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/loading_displaying.js#L182 +title: text +module: Typography +submodule: Loading & Displaying +file: src/typography/loading_displaying.js +description: > +

Draws text to the canvas.

+ +

The first parameter, str, is the text to be drawn. The second + and third + + parameters, x and y, set the coordinates of the + text's bottom-left + + corner. See textAlign() for other ways + to + + align text.

+ +

The fourth and fifth parameters, maxWidth and + maxHeight, are optional. + + They set the dimensions of the invisible rectangle containing the text. By + + default, they set its maximum width and height. See + + rectMode() for other ways to define the + + rectangular text box. Text will wrap to fit within the text box. Text + + outside of the box won't be drawn.

+ +

Text can be styled a few ways. Call the fill() + + function to set the text's fill color. Call + + stroke() and + + strokeWeight() to set the text's + outline. + + Call textSize() and + + textFont() to set the text's size and + font, + + respectively.

+ +

Note: WEBGL mode only supports fonts loaded with + + loadFont(). Calling + + stroke() has no effect in + WEBGL mode.

+line: 182 +isConstructor: false +itemtype: method +example: + - "\n
\n\nfunction setup() {\n background(200);\n text('hi', 50, 50);\n\n describe('The text \"hi\" written in black in the middle of a gray square.');\n}\n\n
\n\n
\n\nfunction setup() {\n background('skyblue');\n textSize(100);\n text('\U0001F308', 0, 100);\n\n describe('A rainbow in a blue sky.');\n}\n\n
\n\n
\n\nfunction setup() {\n textSize(32);\n fill(255);\n stroke(0);\n strokeWeight(4);\n text('hi', 50, 50);\n\n describe('The text \"hi\" written in white with a black outline.');\n}\n\n
\n\n
\n\nfunction setup() {\n background('black');\n textSize(22);\n fill('yellow');\n text('rainbows', 6, 20);\n fill('cornflowerblue');\n text('rainbows', 6, 45);\n fill('tomato');\n text('rainbows', 6, 70);\n fill('limegreen');\n text('rainbows', 6, 95);\n\n describe('The text \"rainbows\" written on several lines, each in a different color.');\n}\n\n
\n\n
\n\nfunction setup() {\n background(200);\n let s = 'The quick brown fox jumps over the lazy dog.';\n text(s, 10, 10, 70, 80);\n\n describe('The sample text \"The quick brown fox...\" written in black across several lines.');\n}\n\n
\n\n
\n\nfunction setup() {\n background(200);\n rectMode(CENTER);\n let s = 'The quick brown fox jumps over the lazy dog.';\n text(s, 50, 50, 70, 80);\n\n describe('The sample text \"The quick brown fox...\" written in black across several lines.');\n}\n\n
\n\n
\n\nlet font;\n\nfunction preload() {\n font = loadFont('/assets/inconsolata.otf');\n}\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n textFont(font);\n textSize(32);\n textAlign(CENTER, CENTER);\n}\n\nfunction draw() {\n background(0);\n rotateY(frameCount / 30);\n text('p5*js', 0, 0);\n\n describe('The text \"p5*js\" written in white and spinning in 3D.');\n}\n\n
" +class: p5 +params: + - name: str + description: | +

text to be displayed.

+ type: String|Object|Array|Number|Boolean + - name: x + description: | +

x-coordinate of the text box.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the text box.

+ type: Number + - name: maxWidth + description: | +

maximum width of the text box. See + rectMode() for + other options.

+ type: Number + optional: true + - name: maxHeight + description: | +

maximum height of the text box. See + rectMode() for + other options.

+ type: Number + optional: true +chainable: true +--- + + +# text diff --git a/src/content/reference/en/p5 copy/textAlign.mdx b/src/content/reference/en/p5 copy/textAlign.mdx new file mode 100644 index 0000000000..3899f22842 --- /dev/null +++ b/src/content/reference/en/p5 copy/textAlign.mdx @@ -0,0 +1,135 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L11 +title: textAlign +module: Typography +submodule: Attributes +file: src/typography/attributes.js +description: > +

Sets the way text is aligned when text() + is called.

+ +

By default, calling text('hi', 10, 20) places the bottom-left + corner of + + the text's bounding box at (10, 20).

+ +

The first parameter, horizAlign, changes the way + + text() interprets x-coordinates. By default, + the + + x-coordinate sets the left edge of the bounding box. textAlign() + accepts + + the following values for horizAlign: LEFT, + CENTER, or RIGHT.

+ +

The second parameter, vertAlign, is optional. It changes the + way + + text() interprets y-coordinates. By default, + the + + y-coordinate sets the bottom edge of the bounding box. + textAlign() + + accepts the following values for vertAlign: TOP, + BOTTOM, CENTER, + + or BASELINE.

+line: 11 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw a vertical line. + strokeWeight(0.5); + line(50, 0, 50, 100); + + // Top line. + textSize(16); + textAlign(RIGHT); + text('ABCD', 50, 30); + + // Middle line. + textAlign(CENTER); + text('EFGH', 50, 50); + + // Bottom line. + textAlign(LEFT); + text('IJKL', 50, 70); + + describe('The letters ABCD displayed at top-left, EFGH at center, and IJKL at bottom-right. A vertical line divides the canvas in half.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + strokeWeight(0.5); + + // First line. + line(0, 12, width, 12); + textAlign(CENTER, TOP); + text('TOP', 50, 12); + + // Second line. + line(0, 37, width, 37); + textAlign(CENTER, CENTER); + text('CENTER', 50, 37); + + // Third line. + line(0, 62, width, 62); + textAlign(CENTER, BASELINE); + text('BASELINE', 50, 62); + + // Fourth line. + line(0, 97, width, 97); + textAlign(CENTER, BOTTOM); + text('BOTTOM', 50, 97); + + describe('The words "TOP", "CENTER", "BASELINE", and "BOTTOM" each drawn relative to a horizontal line. Their positions demonstrate different vertical alignments.'); + } + +
+class: p5 +overloads: + - line: 11 + params: + - name: horizAlign + description: | +

horizontal alignment, either LEFT, + CENTER, or RIGHT.

+ type: Constant + - name: vertAlign + description: | +

vertical alignment, either TOP, + BOTTOM, CENTER, or BASELINE.

+ type: Constant + optional: true + chainable: 1 + - line: 98 + params: [] + return: + description: '' + type: Object +chainable: true +--- + + +# textAlign diff --git a/src/content/reference/en/p5 copy/textAscent.mdx b/src/content/reference/en/p5 copy/textAscent.mdx new file mode 100644 index 0000000000..b81a657de6 --- /dev/null +++ b/src/content/reference/en/p5 copy/textAscent.mdx @@ -0,0 +1,71 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L337 +title: textAscent +module: Typography +submodule: Attributes +file: src/typography/attributes.js +description: | +

Calculates the ascent of the current font at its current size.

+

The ascent represents the distance, in pixels, of the tallest character + above the baseline.

+line: 337 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let font; + + function preload() { + font = loadFont('/assets/inconsolata.otf'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textFont(font); + + // Different for each font. + let fontScale = 0.8; + + let baseY = 75; + strokeWeight(0.5); + + // Draw small text. + textSize(24); + text('dp', 0, baseY); + + // Draw baseline and ascent. + let a = textAscent() * fontScale; + line(0, baseY, 23, baseY); + line(23, baseY - a, 23, baseY); + + // Draw large text. + textSize(48); + text('dp', 45, baseY); + + // Draw baseline and ascent. + a = textAscent() * fontScale; + line(45, baseY, 91, baseY); + line(91, baseY - a, 91, baseY); + + describe('The letters "dp" written twice in different sizes. Each version has a horizontal baseline. A vertical line extends upward from each baseline to the top of the "d".'); + } + +
+class: p5 +return: + description: ascent measured in units of pixels. + type: Number +chainable: false +--- + + +# textAscent diff --git a/src/content/reference/en/p5 copy/textDescent.mdx b/src/content/reference/en/p5 copy/textDescent.mdx new file mode 100644 index 0000000000..15837acff3 --- /dev/null +++ b/src/content/reference/en/p5 copy/textDescent.mdx @@ -0,0 +1,71 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L396 +title: textDescent +module: Typography +submodule: Attributes +file: src/typography/attributes.js +description: | +

Calculates the descent of the current font at its current size.

+

The descent represents the distance, in pixels, of the character with the + longest descender below the baseline.

+line: 396 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let font; + + function preload() { + font = loadFont('/assets/inconsolata.otf'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the font. + textFont(font); + + // Different for each font. + let fontScale = 0.9; + + let baseY = 75; + strokeWeight(0.5); + + // Draw small text. + textSize(24); + text('dp', 0, baseY); + + // Draw baseline and descent. + let d = textDescent() * fontScale; + line(0, baseY, 23, baseY); + line(23, baseY, 23, baseY + d); + + // Draw large text. + textSize(48); + text('dp', 45, baseY); + + // Draw baseline and descent. + d = textDescent() * fontScale; + line(45, baseY, 91, baseY); + line(91, baseY, 91, baseY + d); + + describe('The letters "dp" written twice in different sizes. Each version has a horizontal baseline. A vertical line extends downward from each baseline to the bottom of the "p".'); + } + +
+class: p5 +return: + description: descent measured in units of pixels. + type: Number +chainable: false +--- + + +# textDescent diff --git a/src/content/reference/en/p5 copy/textFont.mdx b/src/content/reference/en/p5 copy/textFont.mdx new file mode 100644 index 0000000000..e5e9fa8da1 --- /dev/null +++ b/src/content/reference/en/p5 copy/textFont.mdx @@ -0,0 +1,127 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/loading_displaying.js#L335 +title: textFont +module: Typography +submodule: Loading & Displaying +file: src/typography/loading_displaying.js +description: > +

Sets the font used by the text() + function.

+ +

The first parameter, font, sets the font. + textFont() recognizes either + + a p5.Font object or a string with the name + of a + + system font. For example, 'Courier New'.

+ +

The second parameter, size, is optional. It sets the font size + in pixels. + + This has the same effect as calling textSize().

+ +

Note: WEBGL mode only supports fonts loaded with + + loadFont().

+line: 335 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + background(200); + textFont('Courier New'); + textSize(24); + text('hi', 35, 55); + + describe('The text "hi" written in a black, monospace font on a gray background.'); + } + +
+ +
+ + function setup() { + background('black'); + fill('palegreen'); + textFont('Courier New', 10); + text('You turn to the left and see a door. Do you enter?', 5, 5, 90, 90); + text('>', 5, 70); + + describe('A text prompt from a game is written in a green, monospace font on a black background.'); + } + +
+ +
+ + function setup() { + background(200); + textFont('Verdana'); + let currentFont = textFont(); + text(currentFont, 25, 50); + + describe('The text "Verdana" written in a black, sans-serif font on a gray background.'); + } + +
+ +
+ + let fontRegular; + let fontItalic; + let fontBold; + + function preload() { + fontRegular = loadFont('/assets/Regular.otf'); + fontItalic = loadFont('/assets/Italic.ttf'); + fontBold = loadFont('/assets/Bold.ttf'); + } + + function setup() { + background(200); + textFont(fontRegular); + text('I am Normal', 10, 30); + textFont(fontItalic); + text('I am Italic', 10, 50); + textFont(fontBold); + text('I am Bold', 10, 70); + + describe('The statements "I am Normal", "I am Italic", and "I am Bold" written in black on separate lines. The statements have normal, italic, and bold fonts, respectively.'); + } + +
+class: p5 +return: + description: current font or p5 Object. + type: Object +overloads: + - line: 335 + params: [] + return: + description: current font or p5 Object. + type: Object + - line: 418 + params: + - name: font + description: | +

font as a p5.Font object or a string.

+ type: Object|String + - name: size + description: | +

font size in pixels.

+ type: Number + optional: true + chainable: 1 +chainable: false +--- + + +# textFont diff --git a/src/content/reference/en/p5 copy/textLeading.mdx b/src/content/reference/en/p5 copy/textLeading.mdx new file mode 100644 index 0000000000..3b5a22d9a2 --- /dev/null +++ b/src/content/reference/en/p5 copy/textLeading.mdx @@ -0,0 +1,63 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L107 +title: textLeading +module: Typography +submodule: Attributes +file: src/typography/attributes.js +description: > +

Sets the spacing between lines of text when + + text() is called.

+ +

Note: Spacing is measured in pixels.

+ +

Calling textLeading() without an argument returns the current + spacing.

+line: 107 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // "\n" starts a new line of text. + let lines = 'one\ntwo'; + + // Left. + text(lines, 10, 25); + + // Right. + textLeading(30); + text(lines, 70, 25); + + describe('The words "one" and "two" written on separate lines twice. The words on the left have less vertical spacing than the words on the right.'); + } + +
+class: p5 +overloads: + - line: 107 + params: + - name: leading + description: | +

spacing between lines of text in units of pixels.

+ type: Number + chainable: 1 + - line: 142 + params: [] + return: + description: '' + type: Number +chainable: true +--- + + +# textLeading diff --git a/src/content/reference/en/p5 copy/textOutput.mdx b/src/content/reference/en/p5 copy/textOutput.mdx new file mode 100644 index 0000000000..62ea4cb4b5 --- /dev/null +++ b/src/content/reference/en/p5 copy/textOutput.mdx @@ -0,0 +1,186 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/accessibility/outputs.js#L10 +title: textOutput +module: Environment +submodule: Environment +file: src/accessibility/outputs.js +description: > +

Creates a screen reader-accessible description of shapes on the canvas.

+ +

textOutput() adds a general description, list of shapes, and + + table of shapes to the web page. The general description includes the + + canvas size, canvas color, and number of shapes. For example, + + Your output is a, 100 by 100 pixels, gray canvas containing the + following 2 shapes:.

+ +

A list of shapes follows the general description. The list describes the + + color, location, and area of each shape. For example, + + a red circle at middle covering 3% of the canvas. Each shape can + be + + selected to get more details.

+ +

textOutput() uses its table of shapes as a list. The table + describes the + + shape, color, location, coordinates and area. For example, + + red circle location = middle area = 3%. This is different from + + gridOutput(), which uses its table as + a grid.

+ +

The display parameter is optional. It determines how the + description is + + displayed. If LABEL is passed, as in + textOutput(LABEL), the description + + will be visible in a div element next to the canvas. Using LABEL + creates + + unhelpful duplicates for screen readers. Only use LABEL during + + development. If FALLBACK is passed, as in + textOutput(FALLBACK), the + + description will only be visible to screen readers. This is the default + + mode.

+ +

Read + + Writing + accessible canvas descriptions + + to learn more about making sketches accessible.

+ +

textOutput() generates descriptions in English only. Text + drawn with + + text() is not described. Shapes created with + + beginShape() are not described. WEBGL + mode + + and 3D shapes are not supported.

+ +

Use describe() and + + describeElement() for more + control + + over canvas descriptions.

+line: 10 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + // Add the text description. + textOutput(); + + // Draw a couple of shapes. + background(200); + fill(255, 0, 0); + circle(20, 20, 20); + fill(0, 0, 255); + square(50, 50, 50); + + // Add a general description of the canvas. + describe('A red circle and a blue square on a gray background.'); + } + +
+ +
+ + function setup() { + // Add the text description and + // display it for debugging. + textOutput(LABEL); + + // Draw a couple of shapes. + background(200); + fill(255, 0, 0); + circle(20, 20, 20); + fill(0, 0, 255); + square(50, 50, 50); + + // Add a general description of the canvas. + describe('A red circle and a blue square on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + } + + function draw() { + // Add the text description. + textOutput(); + + // Draw a moving circle. + background(200); + let x = frameCount * 0.1; + fill(255, 0, 0); + circle(x, 20, 20); + fill(0, 0, 255); + square(50, 50, 50); + + // Add a general description of the canvas. + describe('A red circle moves from left to right above a blue square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + } + + function draw() { + // Add the text description and + // display it for debugging. + textOutput(LABEL); + + // Draw a moving circle. + background(200); + let x = frameCount * 0.1; + fill(255, 0, 0); + circle(x, 20, 20); + fill(0, 0, 255); + square(50, 50, 50); + + // Add a general description of the canvas. + describe('A red circle moves from left to right above a blue square.'); + } + +
+class: p5 +params: + - name: display + description: | +

either FALLBACK or LABEL.

+ type: Constant + optional: true +chainable: false +--- + + +# textOutput diff --git a/src/content/reference/en/p5 copy/textSize.mdx b/src/content/reference/en/p5 copy/textSize.mdx new file mode 100644 index 0000000000..df77510315 --- /dev/null +++ b/src/content/reference/en/p5 copy/textSize.mdx @@ -0,0 +1,65 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L151 +title: textSize +module: Typography +submodule: Attributes +file: src/typography/attributes.js +description: > +

Sets the font size when + + text() is called.

+ +

Note: Font size is measured in pixels.

+ +

Calling textSize() without an argument returns the current + size.

+line: 151 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Top. + textSize(12); + text('Font Size 12', 10, 30); + + // Middle. + textSize(14); + text('Font Size 14', 10, 60); + + // Bottom. + textSize(16); + text('Font Size 16', 10, 90); + + describe('The text "Font Size 12" drawn small, "Font Size 14" drawn medium, and "Font Size 16" drawn large.'); + } + +
+class: p5 +overloads: + - line: 151 + params: + - name: size + description: | +

size of the letters in units of pixels.

+ type: Number + chainable: 1 + - line: 188 + params: [] + return: + description: '' + type: Number +chainable: true +--- + + +# textSize diff --git a/src/content/reference/en/p5 copy/textStyle.mdx b/src/content/reference/en/p5 copy/textStyle.mdx new file mode 100644 index 0000000000..572ca0454c --- /dev/null +++ b/src/content/reference/en/p5 copy/textStyle.mdx @@ -0,0 +1,79 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L197 +title: textStyle +module: Typography +submodule: Attributes +file: src/typography/attributes.js +description: > +

Sets the style for system fonts when + + text() is called.

+ +

The parameter, style, can be either NORMAL, + ITALIC, BOLD, or + + BOLDITALIC.

+ +

textStyle() may be overridden by CSS styling. This function + doesn't + + affect fonts loaded with loadFont().

+line: 197 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textSize(12); + textAlign(CENTER); + + // First row. + textStyle(NORMAL); + text('Normal', 50, 15); + + // Second row. + textStyle(ITALIC); + text('Italic', 50, 40); + + // Third row. + textStyle(BOLD); + text('Bold', 50, 65); + + // Fourth row. + textStyle(BOLDITALIC); + text('Bold Italic', 50, 90); + + describe('The words "Normal" displayed normally, "Italic" in italic, "Bold" in bold, and "Bold Italic" in bold italics.'); + } + +
+class: p5 +overloads: + - line: 197 + params: + - name: style + description: | +

styling for text, either NORMAL, + ITALIC, BOLD or BOLDITALIC.

+ type: Constant + chainable: 1 + - line: 244 + params: [] + return: + description: '' + type: String +chainable: true +--- + + +# textStyle diff --git a/src/content/reference/en/p5 copy/textWidth.mdx b/src/content/reference/en/p5 copy/textWidth.mdx new file mode 100644 index 0000000000..00721b0fee --- /dev/null +++ b/src/content/reference/en/p5 copy/textWidth.mdx @@ -0,0 +1,83 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L253 +title: textWidth +module: Typography +submodule: Attributes +file: src/typography/attributes.js +description: | +

Calculates the maximum width of a string of text drawn when + text() is called.

+line: 253 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textSize(28); + strokeWeight(0.5); + + // Calculate the text width. + let s = 'yoyo'; + let w = textWidth(s); + + // Display the text. + text(s, 22, 55); + + // Underline the text. + line(22, 55, 22 + w, 55); + + describe('The word "yoyo" underlined.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textSize(28); + strokeWeight(0.5); + + // Calculate the text width. + // "\n" starts a new line. + let s = 'yo\nyo'; + let w = textWidth(s); + + // Display the text. + text(s, 22, 55); + + // Underline the text. + line(22, 55, 22 + w, 55); + + describe('The word "yo" written twice, one copy beneath the other. The words are divided by a horizontal line.'); + } + +
+class: p5 +params: + - name: str + description: | +

string of text to measure.

+ type: String +return: + description: width measured in units of pixels. + type: Number +chainable: false +--- + + +# textWidth diff --git a/src/content/reference/en/p5 copy/textWrap.mdx b/src/content/reference/en/p5 copy/textWrap.mdx new file mode 100644 index 0000000000..0ba2b556a7 --- /dev/null +++ b/src/content/reference/en/p5 copy/textWrap.mdx @@ -0,0 +1,111 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L462 +title: textWrap +module: Typography +submodule: Attributes +file: src/typography/attributes.js +description: > +

Sets the style for wrapping text when + + text() is called.

+ +

The parameter, style, can be one of the following values:

+ +

WORD starts new lines of text at spaces. If a string of text + doesn't + + have spaces, it may overflow the text box and the canvas. This is the + + default style.

+ +

CHAR starts new lines as needed to stay within the text + box.

+ +

textWrap() only works when the maximum width is set for a text + box. For + + example, calling text('Have a wonderful day', 0, 10, 100) sets + the + + maximum width to 100 pixels.

+ +

Calling textWrap() without an argument returns the current + style.

+line: 462 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textSize(20); + textWrap(WORD); + + // Display the text. + text('Have a wonderful day', 0, 10, 100); + + describe('The text "Have a wonderful day" written across three lines.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textSize(20); + textWrap(CHAR); + + // Display the text. + text('Have a wonderful day', 0, 10, 100); + + describe('The text "Have a wonderful day" written across two lines.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textSize(20); + textWrap(CHAR); + + // Display the text. + text('祝你有美好的一天', 0, 10, 100); + + describe('The text "祝你有美好的一天" written across two lines.'); + } + +
+class: p5 +params: + - name: style + description: | +

text wrapping style, either WORD or CHAR.

+ type: Constant +return: + description: style + type: String +chainable: false +--- + + +# textWrap diff --git a/src/content/reference/en/p5 copy/texture.mdx b/src/content/reference/en/p5 copy/texture.mdx new file mode 100644 index 0000000000..7258f53ace --- /dev/null +++ b/src/content/reference/en/p5 copy/texture.mdx @@ -0,0 +1,207 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1716 +title: texture +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Sets the texture that will be used on shapes.

+ +

A texture is like a skin that wraps around a shape. texture() + works with + + built-in shapes, such as square() and + + sphere(), and custom shapes created with + + functions such as buildGeometry(). + To + + texture a geometry created with beginShape(), + + uv coordinates must be passed to each + + vertex() call.

+ +

The parameter, tex, is the texture to apply. + texture() can use a range + + of sources including images, videos, and offscreen renderers such as + + p5.Graphics and + + p5.Framebuffer objects.

+ +

To texture a geometry created with beginShape(), + + you will need to specify uv coordinates in vertex().

+ +

Note: texture() can only be used in WebGL mode.

+line: 1716 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load an image and create a p5.Image object. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A spinning cube with an image of a ceiling on each face.'); + } + + function draw() { + background(0); + + // Rotate around the x-, y-, and z-axes. + rotateZ(frameCount * 0.01); + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + + // Apply the image as a texture. + texture(img); + + // Draw the box. + box(50); + } + +
+ +
+ + let pg; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Graphics object. + pg = createGraphics(100, 100); + + // Draw a circle to the p5.Graphics object. + pg.background(200); + pg.circle(50, 50, 30); + + describe('A spinning cube with circle at the center of each face.'); + } + + function draw() { + background(0); + + // Rotate around the x-, y-, and z-axes. + rotateZ(frameCount * 0.01); + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + + // Apply the p5.Graphics object as a texture. + texture(pg); + + // Draw the box. + box(50); + } + +
+ +
+ + let vid; + + // Load a video and create a p5.MediaElement object. + function preload() { + vid = createVideo('/assets/fingers.mov'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + // Hide the video. + vid.hide(); + + // Set the video to loop. + vid.loop(); + + describe('A rectangle with video as texture'); + } + + function draw() { + background(0); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Apply the video as a texture. + texture(vid); + + // Draw the rectangle. + rect(-40, -40, 80, 80); + } + +
+ +
+ + let vid; + + // Load a video and create a p5.MediaElement object. + function preload() { + vid = createVideo('/assets/fingers.mov'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + // Hide the video. + vid.hide(); + + // Set the video to loop. + vid.loop(); + + describe('A rectangle with video as texture'); + } + + function draw() { + background(0); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Set the texture mode. + textureMode(NORMAL); + + // Apply the video as a texture. + texture(vid); + + // Draw a custom shape using uv coordinates. + beginShape(); + vertex(-40, -40, 0, 0); + vertex(40, -40, 1, 0); + vertex(40, 40, 1, 1); + vertex(-40, 40, 0, 1); + endShape(); + } + +
+class: p5 +params: + - name: tex + description: | +

media to use as the texture.

+ type: >- + p5.Image|p5.MediaElement|p5.Graphics|p5.Texture|p5.Framebuffer|p5.FramebufferTexture +chainable: true +--- + + +# texture diff --git a/src/content/reference/en/p5 copy/textureMode.mdx b/src/content/reference/en/p5 copy/textureMode.mdx new file mode 100644 index 0000000000..397d1856b9 --- /dev/null +++ b/src/content/reference/en/p5 copy/textureMode.mdx @@ -0,0 +1,254 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1903 +title: textureMode +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Changes the coordinate system used for textures when they’re applied to + + custom shapes.

+ +

In order for texture() to work, a + shape needs a + + way to map the points on its surface to the pixels in an image. Built-in + + shapes such as rect() and + + box() already have these texture mappings + based on + + their vertices. Custom shapes created with + + vertex() require texture mappings to be + passed as + + uv coordinates.

+ +

Each call to vertex() must include 5 + arguments, + + as in vertex(x, y, z, u, v), to map the vertex at coordinates + (x, y, z) + + to the pixel at coordinates (u, v) within an image. For example, + the + + corners of a rectangular image are mapped to the corners of a rectangle by + default:

+ +
// Apply the image as a texture.
+
+  texture(img);
+
+
+  // Draw the rectangle.
+
+  rect(0, 0, 30, 50);
+
+  
+ +

If the image in the code snippet above has dimensions of 300 x 500 pixels, + + the same result could be achieved as follows:

+ +
// Apply the image as a texture.
+
+  texture(img);
+
+
+  // Draw the rectangle.
+
+  beginShape();
+
+
+  // Top-left.
+
+  // u: 0, v: 0
+
+  vertex(0, 0, 0, 0, 0);
+
+
+  // Top-right.
+
+  // u: 300, v: 0
+
+  vertex(30, 0, 0, 300, 0);
+
+
+  // Bottom-right.
+
+  // u: 300, v: 500
+
+  vertex(30, 50, 0, 300, 500);
+
+
+  // Bottom-left.
+
+  // u: 0, v: 500
+
+  vertex(0, 50, 0, 0, 500);
+
+
+  endShape();
+
+  
+ +

textureMode() changes the coordinate system for uv + coordinates.

+ +

The parameter, mode, accepts two possible constants. If + NORMAL is + + passed, as in textureMode(NORMAL), then the texture’s uv + coordinates can + + be provided in the range 0 to 1 instead of the image’s dimensions. This can + + be helpful for using the same code for multiple images of different sizes. + + For example, the code snippet above could be rewritten as follows:

+ +
// Set the texture mode to use normalized
+  coordinates.
+
+  textureMode(NORMAL);
+
+
+  // Apply the image as a texture.
+
+  texture(img);
+
+
+  // Draw the rectangle.
+
+  beginShape();
+
+
+  // Top-left.
+
+  // u: 0, v: 0
+
+  vertex(0, 0, 0, 0, 0);
+
+
+  // Top-right.
+
+  // u: 1, v: 0
+
+  vertex(30, 0, 0, 1, 0);
+
+
+  // Bottom-right.
+
+  // u: 1, v: 1
+
+  vertex(30, 50, 0, 1, 1);
+
+
+  // Bottom-left.
+
+  // u: 0, v: 1
+
+  vertex(0, 50, 0, 0, 1);
+
+
+  endShape();
+
+  
+ +

By default, mode is IMAGE, which scales uv + coordinates to the + + dimensions of the image. Calling textureMode(IMAGE) applies the + default.

+ +

Note: textureMode() can only be used in WebGL mode.

+line: 1903 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load an image and create a p5.Image object. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('An image of a ceiling against a black background.'); + } + + function draw() { + background(0); + + // Apply the image as a texture. + texture(img); + + // Draw the custom shape. + // Use the image's width and height as uv coordinates. + beginShape(); + vertex(-30, -30, 0, 0); + vertex(30, -30, img.width, 0); + vertex(30, 30, img.width, img.height); + vertex(-30, 30, 0, img.height); + endShape(); + } + +
+ +
+ + let img; + + // Load an image and create a p5.Image object. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('An image of a ceiling against a black background.'); + } + + function draw() { + background(0); + + // Set the texture mode. + textureMode(NORMAL); + + // Apply the image as a texture. + texture(img); + + // Draw the custom shape. + // Use normalized uv coordinates. + beginShape(); + vertex(-30, -30, 0, 0); + vertex(30, -30, 1, 0); + vertex(30, 30, 1, 1); + vertex(-30, 30, 0, 1); + endShape(); + } + +
+class: p5 +params: + - name: mode + description: | +

either IMAGE or NORMAL.

+ type: Constant +chainable: false +--- + + +# textureMode diff --git a/src/content/reference/en/p5 copy/textureWrap.mdx b/src/content/reference/en/p5 copy/textureWrap.mdx new file mode 100644 index 0000000000..6734a5325b --- /dev/null +++ b/src/content/reference/en/p5 copy/textureWrap.mdx @@ -0,0 +1,370 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2082 +title: textureWrap +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Changes the way textures behave when a shape’s uv coordinates go beyond the + + texture.

+ +

In order for texture() to work, a + shape needs a + + way to map the points on its surface to the pixels in an image. Built-in + + shapes such as rect() and + + box() already have these texture mappings + based on + + their vertices. Custom shapes created with + + vertex() require texture mappings to be + passed as + + uv coordinates.

+ +

Each call to vertex() must include 5 + arguments, + + as in vertex(x, y, z, u, v), to map the vertex at coordinates + (x, y, z) + + to the pixel at coordinates (u, v) within an image. For example, + the + + corners of a rectangular image are mapped to the corners of a rectangle by + default:

+ +
// Apply the image as a texture.
+
+  texture(img);
+
+
+  // Draw the rectangle.
+
+  rect(0, 0, 30, 50);
+
+  
+ +

If the image in the code snippet above has dimensions of 300 x 500 pixels, + + the same result could be achieved as follows:

+ +
// Apply the image as a texture.
+
+  texture(img);
+
+
+  // Draw the rectangle.
+
+  beginShape();
+
+
+  // Top-left.
+
+  // u: 0, v: 0
+
+  vertex(0, 0, 0, 0, 0);
+
+
+  // Top-right.
+
+  // u: 300, v: 0
+
+  vertex(30, 0, 0, 300, 0);
+
+
+  // Bottom-right.
+
+  // u: 300, v: 500
+
+  vertex(30, 50, 0, 300, 500);
+
+
+  // Bottom-left.
+
+  // u: 0, v: 500
+
+  vertex(0, 50, 0, 0, 500);
+
+
+  endShape();
+
+  
+ +

textureWrap() controls how textures behave when their uv's go + beyond the + + texture. Doing so can produce interesting visual effects such as tiling. + + For example, the custom shape above could have u-coordinates are greater + + than the image’s width:

+ +
// Apply the image as a texture.
+
+  texture(img);
+
+
+  // Draw the rectangle.
+
+  beginShape();
+
+  vertex(0, 0, 0, 0, 0);
+
+
+  // Top-right.
+
+  // u: 600
+
+  vertex(30, 0, 0, 600, 0);
+
+
+  // Bottom-right.
+
+  // u: 600
+
+  vertex(30, 50, 0, 600, 500);
+
+
+  vertex(0, 50, 0, 0, 500);
+
+  endShape();
+
+  
+ +

The u-coordinates of 600 are greater than the texture image’s width of 300. + + This creates interesting possibilities.

+ +

The first parameter, wrapX, accepts three possible constants. + If CLAMP + + is passed, as in textureWrap(CLAMP), the pixels at the edge of + the + + texture will extend to the shape’s edges. If REPEAT is passed, as + in + + textureWrap(REPEAT), the texture will tile repeatedly until + reaching the + + shape’s edges. If MIRROR is passed, as in + textureWrap(MIRROR), the + + texture will tile repeatedly until reaching the shape’s edges, flipping + + its orientation between tiles. By default, textures CLAMP.

+ +

The second parameter, wrapY, is optional. It accepts the same + three + + constants, CLAMP, REPEAT, and MIRROR. + If one of these constants is + + passed, as in textureWRAP(MIRROR, REPEAT), then the texture will + MIRROR + + horizontally and REPEAT vertically. By default, + wrapY will be set to + + the same value as wrapX.

+ +

Note: textureWrap() can only be used in WebGL mode.

+line: 2082 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + function preload() { + img = loadImage('/assets/rockies128.jpg'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'An image of a landscape occupies the top-left corner of a square. Its edge colors smear to cover the other thre quarters of the square.' + ); + } + + function draw() { + background(0); + + // Set the texture mode. + textureMode(NORMAL); + + // Set the texture wrapping. + // Note: CLAMP is the default mode. + textureWrap(CLAMP); + + // Apply the image as a texture. + texture(img); + + // Style the shape. + noStroke(); + + // Draw the shape. + // Use uv coordinates > 1. + beginShape(); + vertex(-30, -30, 0, 0, 0); + vertex(30, -30, 0, 2, 0); + vertex(30, 30, 0, 2, 2); + vertex(-30, 30, 0, 0, 2); + endShape(); + } + +
+ +
+ + let img; + + function preload() { + img = loadImage('/assets/rockies128.jpg'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('Four identical images of a landscape arranged in a grid.'); + } + + function draw() { + background(0); + + // Set the texture mode. + textureMode(NORMAL); + + // Set the texture wrapping. + textureWrap(REPEAT); + + // Apply the image as a texture. + texture(img); + + // Style the shape. + noStroke(); + + // Draw the shape. + // Use uv coordinates > 1. + beginShape(); + vertex(-30, -30, 0, 0, 0); + vertex(30, -30, 0, 2, 0); + vertex(30, 30, 0, 2, 2); + vertex(-30, 30, 0, 0, 2); + endShape(); + } + +
+ +
+ + let img; + + function preload() { + img = loadImage('/assets/rockies128.jpg'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'Four identical images of a landscape arranged in a grid. The images are reflected horizontally and vertically, creating a kaleidoscope effect.' + ); + } + + function draw() { + background(0); + + // Set the texture mode. + textureMode(NORMAL); + + // Set the texture wrapping. + textureWrap(MIRROR); + + // Apply the image as a texture. + texture(img); + + // Style the shape. + noStroke(); + + // Draw the shape. + // Use uv coordinates > 1. + beginShape(); + vertex(-30, -30, 0, 0, 0); + vertex(30, -30, 0, 2, 0); + vertex(30, 30, 0, 2, 2); + vertex(-30, 30, 0, 0, 2); + endShape(); + } + +
+ +
+ + let img; + + function preload() { + img = loadImage('/assets/rockies128.jpg'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'Four identical images of a landscape arranged in a grid. The top row and bottom row are reflections of each other.' + ); + } + + function draw() { + background(0); + + // Set the texture mode. + textureMode(NORMAL); + + // Set the texture wrapping. + textureWrap(REPEAT, MIRROR); + + // Apply the image as a texture. + texture(img); + + // Style the shape. + noStroke(); + + // Draw the shape. + // Use uv coordinates > 1. + beginShape(); + vertex(-30, -30, 0, 0, 0); + vertex(30, -30, 0, 2, 0); + vertex(30, 30, 0, 2, 2); + vertex(-30, 30, 0, 0, 2); + endShape(); + } + +
+class: p5 +params: + - name: wrapX + description: | +

either CLAMP, REPEAT, or MIRROR

+ type: Constant + - name: wrapY + description: | +

either CLAMP, REPEAT, or MIRROR

+ type: Constant + optional: true +chainable: false +--- + + +# textureWrap diff --git a/src/content/reference/en/p5 copy/tint.mdx b/src/content/reference/en/p5 copy/tint.mdx new file mode 100644 index 0000000000..e99dee4431 --- /dev/null +++ b/src/content/reference/en/p5 copy/tint.mdx @@ -0,0 +1,201 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L1192 +title: tint +module: Image +submodule: Loading & Displaying +file: src/image/loading_displaying.js +description: > +

Tints images using a color.

+ +

The version of tint() with one parameter interprets it one of + four ways. + + If the parameter is a number, it's interpreted as a grayscale value. If the + + parameter is a string, it's interpreted as a CSS color string. An array of + + [R, G, B, A] values or a p5.Color object can + + also be used to set the tint color.

+ +

The version of tint() with two parameters uses the first one + as a + + grayscale value and the second as an alpha value. For example, calling + + tint(255, 128) will make an image 50% transparent.

+ +

The version of tint() with three parameters interprets them as + RGB or + + HSB values, depending on the current + + colorMode(). The optional fourth + parameter + + sets the alpha value. For example, tint(255, 0, 0, 100) will give + images + + a red tint and make them transparent.

+line: 1192 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Left image. + image(img, 0, 0); + + // Right image. + // Tint with a CSS color string. + tint('red'); + image(img, 50, 0); + + describe('Two images of an umbrella and a ceiling side-by-side. The image on the right has a red tint.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Left image. + image(img, 0, 0); + + // Right image. + // Tint with RGB values. + tint(255, 0, 0); + image(img, 50, 0); + + describe('Two images of an umbrella and a ceiling side-by-side. The image on the right has a red tint.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Left. + image(img, 0, 0); + + // Right. + // Tint with RGBA values. + tint(255, 0, 0, 100); + image(img, 50, 0); + + describe('Two images of an umbrella and a ceiling side-by-side. The image on the right has a transparent red tint.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Left. + image(img, 0, 0); + + // Right. + // Tint with grayscale and alpha values. + tint(255, 180); + image(img, 50, 0); + + describe('Two images of an umbrella and a ceiling side-by-side. The image on the right is transparent.'); + } + +
+class: p5 +overloads: + - line: 1192 + params: + - name: v1 + description: | +

red or hue value.

+ type: Number + - name: v2 + description: | +

green or saturation value.

+ type: Number + - name: v3 + description: | +

blue or brightness.

+ type: Number + - name: alpha + description: '' + type: Number + optional: true + - line: 1318 + params: + - name: value + description: | +

CSS color string.

+ type: String + - line: 1323 + params: + - name: gray + description: | +

grayscale value.

+ type: Number + - name: alpha + description: '' + type: Number + optional: true + - line: 1329 + params: + - name: values + description: | +

array containing the red, green, blue & + alpha components of the color.

+ type: 'Number[]' + - line: 1335 + params: + - name: color + description: | +

the tint color

+ type: p5.Color +chainable: false +--- + + +# tint diff --git a/src/content/reference/en/p5 copy/torus.mdx b/src/content/reference/en/p5 copy/torus.mdx new file mode 100644 index 0000000000..f0e2740d59 --- /dev/null +++ b/src/content/reference/en/p5 copy/torus.mdx @@ -0,0 +1,200 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L2183 +title: torus +module: Shape +submodule: 3D Primitives +file: src/webgl/3d_primitives.js +description: > +

Draws a torus.

+ +

A torus is a 3D shape with triangular faces that connect to form a ring. + + Toruses with few faces look flattened. Toruses with many faces have smooth + + surfaces.

+ +

The first parameter, radius, is optional. If a + Number is passed, as in + + torus(30), it sets the radius of the ring. By default, + radius is 50.

+ +

The second parameter, tubeRadius, is also optional. If a + Number is + + passed, as in torus(30, 15), it sets the radius of the tube. By + default, + + tubeRadius is 10.

+ +

The third parameter, detailX, is also optional. If a + Number is passed, + + as in torus(30, 15, 5), it sets the number of edges used to draw + the hole + + of the torus. Using more edges makes the hole look more like a circle. By + + default, detailX is 24.

+ +

The fourth parameter, detailY, is also optional. If a + Number is passed, + + as in torus(30, 15, 5, 7), it sets the number of triangle + subdivisions to + + use while filling in the torus’ height. By default, detailY is + 16.

+ +

Note: torus() can only be used in WebGL mode.

+line: 2183 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white torus on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the torus. + torus(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white torus on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the torus. + // Set its radius to 30. + torus(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white torus on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the torus. + // Set its radius to 30 and tubeRadius to 15. + torus(30, 15); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white torus on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the torus. + // Set its radius to 30 and tubeRadius to 15. + // Set its detailX to 5. + torus(30, 15, 5); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white torus on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the torus. + // Set its radius to 30 and tubeRadius to 15. + // Set its detailX to 5. + // Set its detailY to 3. + torus(30, 15, 5, 3); + } + +
+class: p5 +params: + - name: radius + description: | +

radius of the torus. Defaults to 50.

+ type: Number + optional: true + - name: tubeRadius + description: | +

radius of the tube. Defaults to 10.

+ type: Number + optional: true + - name: detailX + description: | +

number of edges that form the hole. Defaults to 24.

+ type: Integer + optional: true + - name: detailY + description: | +

number of triangle subdivisions along the y-axis. Defaults to 16.

+ type: Integer + optional: true +chainable: true +--- + + +# torus diff --git a/src/content/reference/en/p5 copy/touchEnded.mdx b/src/content/reference/en/p5 copy/touchEnded.mdx new file mode 100644 index 0000000000..aebb308dc1 --- /dev/null +++ b/src/content/reference/en/p5 copy/touchEnded.mdx @@ -0,0 +1,196 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/touch.js#L468 +title: touchEnded +module: Events +submodule: Touch +file: src/events/touch.js +description: > +

A function that's called once each time a screen touch ends.

+ +

Declaring the function touchEnded() sets a code block to run + + automatically when the user stops touching a touchscreen device:

+ +
function touchEnded() {
+    // Code to run.
+  }
+
+  
+ +

The touches array will be updated with + the most + + recent touch points when touchEnded() is called by p5.js:

+ +
function touchEnded() {
+    // Paint over the background.
+    background(200);
+
+    // Mark each remaining touch point when the user stops
+    // a touch.
+    for (let touch of touches) {
+      circle(touch.x, touch.y, 40);
+    }
+  }
+
+  
+ +

The parameter, event, is optional. touchEnded() will be passed + a + + TouchEvent + + object with properties that describe the touch event:

+ +
function touchEnded(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

On touchscreen devices, mouseReleased() will + + run when the user’s touch ends if touchEnded() isn’t declared. If + + touchEnded() is declared, then touchEnded() will run + when a user’s + + touch ends and mouseReleased() + won’t.

+ +

Note: touchStarted(), + + touchEnded(), and touchMoved() are all + + related. touchStarted() runs as soon + as the + + user touches a touchscreen device. touchEnded() runs as soon as + the user + + ends a touch. touchMoved() runs + repeatedly as + + the user moves any touch points.

+line: 468 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // On a touchscreen device, touch the canvas using one or more fingers + // at the same time. + + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square switches color between black and white each time the user stops touching the screen.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Toggle colors when a touch ends. + function touchEnded() { + if (value === 0) { + value = 255; + } else { + value = 0; + } + } + +
+ +
+ + // On a touchscreen device, touch the canvas using one or more fingers + // at the same time. + + let bgColor = 50; + let fillColor = 255; + let borderWidth = 0.5; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with the number 0 at the top-center. The number tracks the number of places the user is touching the screen. Circles appear at each touch point and change style in response to events.' + ); + } + + function draw() { + background(bgColor); + + // Style the text. + textAlign(CENTER); + textSize(16); + fill(0); + noStroke(); + + // Display the number of touch points. + text(touches.length, 50, 20); + + // Style the touch points. + fill(fillColor); + stroke(0); + strokeWeight(borderWidth); + + // Display the touch points as circles. + for (let touch of touches) { + circle(touch.x, touch.y, 40); + } + } + + // Set the background color to a random grayscale value. + function touchStarted() { + bgColor = random(80, 255); + } + + // Set the fill color to a random grayscale value. + function touchEnded() { + fillColor = random(0, 255); + } + + // Set the stroke weight. + function touchMoved() { + // Increment the border width. + borderWidth += 0.1; + + // Reset the border width once it's too thick. + if (borderWidth > 20) { + borderWidth = 0.5; + } + } + +
+class: p5 +params: + - name: event + description: | +

optional TouchEvent argument.

+ type: TouchEvent + optional: true +chainable: false +--- + + +# touchEnded diff --git a/src/content/reference/en/p5 copy/touchMoved.mdx b/src/content/reference/en/p5 copy/touchMoved.mdx new file mode 100644 index 0000000000..80c23b81f8 --- /dev/null +++ b/src/content/reference/en/p5 copy/touchMoved.mdx @@ -0,0 +1,198 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/touch.js#L295 +title: touchMoved +module: Events +submodule: Touch +file: src/events/touch.js +description: > +

A function that's called when the user touches the screen and moves.

+ +

Declaring the function touchMoved() sets a code block to run + + automatically when the user touches a touchscreen device and moves:

+ +
function touchMoved() {
+    // Code to run.
+  }
+
+  
+ +

The touches array will be updated with + the most + + recent touch points when touchMoved() is called by p5.js:

+ +
function touchMoved() {
+    // Paint over the background.
+    background(200);
+
+    // Mark each touch point while the user moves.
+    for (let touch of touches) {
+      circle(touch.x, touch.y, 40);
+    }
+  }
+
+  
+ +

The parameter, event, is optional. touchMoved() will be passed + a + + TouchEvent + + object with properties that describe the touch event:

+ +
function touchMoved(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

On touchscreen devices, mouseDragged() will + + run when the user’s touch points move if touchMoved() isn’t + declared. If + + touchMoved() is declared, then touchMoved() will run + when a user’s + + touch points move and mouseDragged() + won’t.

+ +

Note: touchStarted(), + + touchEnded(), and + + touchMoved() are all related. + + touchStarted() runs as soon as the + user + + touches a touchscreen device. touchEnded() + + runs as soon as the user ends a touch. touchMoved() runs + repeatedly as + + the user moves any touch points.

+line: 295 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // On a touchscreen device, touch the canvas using one or more fingers + // at the same time. + + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square becomes lighter when the user touches the screen and moves.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + function touchMoved() { + // Update the grayscale value. + value += 5; + + // Reset the grayscale value. + if (value > 255) { + value = 0; + } + } + +
+ +
+ + // On a touchscreen device, touch the canvas using one or more fingers + // at the same time. + + let bgColor = 50; + let fillColor = 255; + let borderWidth = 0.5; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with the number 0 at the top-center. The number tracks the number of places the user is touching the screen. Circles appear at each touch point and change style in response to events.' + ); + } + + function draw() { + background(bgColor); + + // Style the text. + textAlign(CENTER); + textSize(16); + fill(0); + noStroke(); + + // Display the number of touch points. + text(touches.length, 50, 20); + + // Style the touch points. + fill(fillColor); + stroke(0); + strokeWeight(borderWidth); + + // Display the touch points as circles. + for (let touch of touches) { + circle(touch.x, touch.y, 40); + } + } + + // Set the background color to a random grayscale value. + function touchStarted() { + bgColor = random(80, 255); + } + + // Set the fill color to a random grayscale value. + function touchEnded() { + fillColor = random(0, 255); + } + + // Set the stroke weight. + function touchMoved() { + // Increment the border width. + borderWidth += 0.1; + + // Reset the border width once it's too thick. + if (borderWidth > 20) { + borderWidth = 0.5; + } + } + +
+class: p5 +params: + - name: event + description: | +

optional TouchEvent argument.

+ type: TouchEvent + optional: true +chainable: false +--- + + +# touchMoved diff --git a/src/content/reference/en/p5 copy/touchStarted.mdx b/src/content/reference/en/p5 copy/touchStarted.mdx new file mode 100644 index 0000000000..fc33b1f1c5 --- /dev/null +++ b/src/content/reference/en/p5 copy/touchStarted.mdx @@ -0,0 +1,197 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/touch.js#L125 +title: touchStarted +module: Events +submodule: Touch +file: src/events/touch.js +description: > +

A function that's called once each time the user touches the screen.

+ +

Declaring a function called touchStarted() sets a code block + to run + + automatically each time the user begins touching a touchscreen device:

+ +
function touchStarted() {
+    // Code to run.
+  }
+
+  
+ +

The touches array will be updated with + the most + + recent touch points when touchStarted() is called by p5.js:

+ +
function touchStarted() {
+    // Paint over the background.
+    background(200);
+
+    // Mark each touch point once with a circle.
+    for (let touch of touches) {
+      circle(touch.x, touch.y, 40);
+    }
+  }
+
+  
+ +

The parameter, event, is optional. touchStarted() will be + passed a + + TouchEvent + + object with properties that describe the touch event:

+ +
function touchStarted(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

On touchscreen devices, mousePressed() will + + run when a user’s touch starts if touchStarted() isn’t declared. + If + + touchStarted() is declared, then touchStarted() will + run when a user’s + + touch starts and mousePressed() + won’t.

+ +

Note: touchStarted(), touchEnded(), and + + touchMoved() are all related. + + touchStarted() runs as soon as the user touches a touchscreen + device. + + touchEnded() runs as soon as the user + ends a + + touch. touchMoved() runs repeatedly as + the + + user moves any touch points.

+line: 125 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // On a touchscreen device, touch the canvas using one or more fingers + // at the same time. + + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square switches color between black and white each time the user touches the screen.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Toggle colors with each touch. + function touchStarted() { + if (value === 0) { + value = 255; + } else { + value = 0; + } + } + +
+ +
+ + // On a touchscreen device, touch the canvas using one or more fingers + // at the same time. + + let bgColor = 50; + let fillColor = 255; + let borderWidth = 0.5; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with the number 0 at the top-center. The number tracks the number of places the user is touching the screen. Circles appear at each touch point and change style in response to events.' + ); + } + + function draw() { + background(bgColor); + + // Style the text. + textAlign(CENTER); + textSize(16); + fill(0); + noStroke(); + + // Display the number of touch points. + text(touches.length, 50, 20); + + // Style the touch points. + fill(fillColor); + stroke(0); + strokeWeight(borderWidth); + + // Display the touch points as circles. + for (let touch of touches) { + circle(touch.x, touch.y, 40); + } + } + + // Set the background color to a random grayscale value. + function touchStarted() { + bgColor = random(80, 255); + } + + // Set the fill color to a random grayscale value. + function touchEnded() { + fillColor = random(0, 255); + } + + // Set the stroke weight. + function touchMoved() { + // Increment the border width. + borderWidth += 0.1; + + // Reset the border width once it's too thick. + if (borderWidth > 20) { + borderWidth = 0.5; + } + } + +
+class: p5 +params: + - name: event + description: | +

optional TouchEvent argument.

+ type: TouchEvent + optional: true +chainable: false +--- + + +# touchStarted diff --git a/src/content/reference/en/p5 copy/touches.mdx b/src/content/reference/en/p5 copy/touches.mdx new file mode 100644 index 0000000000..7ad03e1610 --- /dev/null +++ b/src/content/reference/en/p5 copy/touches.mdx @@ -0,0 +1,102 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/touch.js#L10 +title: touches +module: Events +submodule: Touch +file: src/events/touch.js +description: > +

An Array of all the current touch points on a touchscreen + device.

+ +

The touches array is empty by default. When the user touches + their + + screen, a new touch point is tracked and added to the array. Touch points + + are Objects with the following properties:

+ +
// Iterate over the touches array.
+
+  for (let touch of touches) {
+    // x-coordinate relative to the top-left
+    // corner of the canvas.
+    console.log(touch.x);
+
+    // y-coordinate relative to the top-left
+    // corner of the canvas.
+    console.log(touch.y);
+
+    // x-coordinate relative to the top-left
+    // corner of the browser.
+    console.log(touch.winX);
+
+    // y-coordinate relative to the top-left
+    // corner of the browser.
+    console.log(touch.winY);
+
+    // ID number
+    console.log(touch.id);
+  }
+
+  
+line: 10 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // On a touchscreen device, touch the canvas using one or more fingers + // at the same time. + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square. White circles appear where the user touches the square.' + ); + } + + function draw() { + background(200); + + // Draw a circle at each touch point. + for (let touch of touches) { + circle(touch.x, touch.y, 40); + } + } + +
+ +
+ + // On a touchscreen device, touch the canvas using one or more fingers + // at the same time. + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square. Labels appear where the user touches the square, displaying the coordinates.' + ); + } + + function draw() { + background(200); + + // Draw a label above each touch point. + for (let touch of touches) { + text(`${touch.x}, ${touch.y}`, touch.x, touch.y - 40); + } + } + +
+class: p5 +type: 'Object[]' +--- + + +# touches diff --git a/src/content/reference/en/p5 copy/translate.mdx b/src/content/reference/en/p5 copy/translate.mdx new file mode 100644 index 0000000000..dd725eb199 --- /dev/null +++ b/src/content/reference/en/p5 copy/translate.mdx @@ -0,0 +1,241 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L1223 +title: translate +module: Transform +submodule: Transform +file: src/core/transform.js +description: > +

Translates the coordinate system.

+ +

By default, the origin (0, 0) is at the sketch's top-left + corner in 2D + + mode and center in WebGL mode. The translate() function shifts + the origin + + to a different position. Everything drawn after translate() is + called + + will appear to be shifted. There are two ways to call translate() + with + + parameters that set the origin's position.

+ +

The first way to call translate() uses numbers to set the + amount of + + translation. The first two parameters, x and y, set + the amount to + + translate along the positive x- and y-axes. For example, calling + + translate(20, 30) translates the origin 20 pixels along the + x-axis and 30 + + pixels along the y-axis. The third parameter, z, is optional. It + sets the + + amount to translate along the positive z-axis. For example, calling + + translate(20, 30, 40) translates the origin 20 pixels along the + x-axis, + + 30 pixels along the y-axis, and 40 pixels along the z-axis.

+ +

The second way to call translate() uses a + + p5.Vector object to set the amount of + + translation. For example, calling translate(myVector) uses the + x-, y-, + + and z-components of myVector to set the amount to translate along + the x-, + + y-, and z-axes. Doing so is the same as calling + + translate(myVector.x, myVector.y, myVector.z).

+ +

By default, transformations accumulate. For example, calling + + translate(10, 0) twice has the same effect as calling + + translate(20, 0) once. The push() and + + pop() functions can be used to isolate + + transformations within distinct drawing groups.

+ +

Note: Transformations are reset at the beginning of the draw loop. Calling + + translate(10, 0) inside the draw() function won't + + cause shapes to move continuously.

+line: 1223 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A white circle on a gray background.'); + } + + function draw() { + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Draw a circle at coordinates (0, 0). + circle(0, 0, 40); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'Two circles drawn on a gray background. The blue circle on the right overlaps the red circle at the center.' + ); + } + + function draw() { + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Draw the red circle. + fill('red'); + circle(0, 0, 40); + + // Translate the origin to the right. + translate(25, 0); + + // Draw the blue circle. + fill('blue'); + circle(0, 0, 40); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A white circle moves slowly from left to right on a gray background.'); + } + + function draw() { + background(200); + + // Calculate the x-coordinate. + let x = frameCount * 0.2; + + // Translate the origin. + translate(x, 50); + + // Draw a circle at coordinates (0, 0). + circle(0, 0, 40); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A white circle on a gray background.'); + } + + function draw() { + background(200); + + // Create a p5.Vector object. + let v = createVector(50, 50); + + // Translate the origin by the vector. + translate(v); + + // Draw a circle at coordinates (0, 0). + circle(0, 0, 40); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'Two spheres sitting side-by-side on gray background. The sphere at the center is red. The sphere on the right is blue.' + ); + } + + function draw() { + background(200); + + // Turn on the lights. + lights(); + + // Style the spheres. + noStroke(); + + // Draw the red sphere. + fill('red'); + sphere(10); + + // Translate the origin to the right. + translate(30, 0, 0); + + // Draw the blue sphere. + fill('blue'); + sphere(10); + } + +
+class: p5 +overloads: + - line: 1223 + params: + - name: x + description: | +

amount to translate along the positive x-axis.

+ type: Number + - name: 'y' + description: | +

amount to translate along the positive y-axis.

+ type: Number + - name: z + description: | +

amount to translate along the positive z-axis.

+ type: Number + optional: true + chainable: 1 + - line: 1394 + params: + - name: vector + description: | +

vector by which to translate.

+ type: p5.Vector + chainable: 1 +chainable: true +--- + + +# translate diff --git a/src/content/reference/en/p5 copy/triangle.mdx b/src/content/reference/en/p5 copy/triangle.mdx new file mode 100644 index 0000000000..08f1afb223 --- /dev/null +++ b/src/content/reference/en/p5 copy/triangle.mdx @@ -0,0 +1,104 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L1385 +title: triangle +module: Shape +submodule: 2D Primitives +file: src/core/shape/2d_primitives.js +description: > +

Draws a triangle.

+ +

A triangle is a three-sided shape defined by three points. The + + first two parameters specify the triangle's first point (x1, y1). + The + + middle two parameters specify its second point (x2, y2). And the + last two + + parameters specify its third point (x3, y3).

+line: 1385 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + triangle(30, 75, 58, 20, 86, 75); + + describe('A white triangle with a black outline on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + triangle(-20, 25, 8, -30, 36, 25); + + describe('A white triangle with a black outline on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white triangle spins around on a gray canvas.'); + } + + function draw() { + background(200); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Draw the triangle. + triangle(-20, 25, 8, -30, 36, 25); + } + +
+class: p5 +params: + - name: x1 + description: | +

x-coordinate of the first point.

+ type: Number + - name: y1 + description: | +

y-coordinate of the first point.

+ type: Number + - name: x2 + description: | +

x-coordinate of the second point.

+ type: Number + - name: y2 + description: | +

y-coordinate of the second point.

+ type: Number + - name: x3 + description: | +

x-coordinate of the third point.

+ type: Number + - name: y3 + description: | +

y-coordinate of the third point.

+ type: Number +chainable: true +--- + + +# triangle diff --git a/src/content/reference/en/p5 copy/trim.mdx b/src/content/reference/en/p5 copy/trim.mdx new file mode 100644 index 0000000000..a782306725 --- /dev/null +++ b/src/content/reference/en/p5 copy/trim.mdx @@ -0,0 +1,113 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L916 +title: trim +module: Data +submodule: String Functions +file: src/utilities/string_functions.js +description: > +

Removes whitespace from the start and end of a String without + changing the middle.

+ +

trim() trims + + whitespace characters + + such as spaces, carriage returns, tabs, Unicode "nbsp" character.

+ +

The parameter, str, is the string to trim. If a single string + is passed, + + as in trim(' pad '), a single string is returned. If an array + of + + strings is passed, as in trim([' pad ', '\n space \n']), an + array of + + strings is returned.

+line: 916 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let string = ' p5*js '; + + // Trim the whitespace. + let trimmed = trim(string); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the text. + text(`Hello, ${trimmed}!`, 50, 50); + + describe('The text "Hello, p5*js!" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of strings. + let strings = [' wide ', '\n open ', '\n spaces ']; + + // Trim the whitespace. + let trimmed = trim(strings); + + // Style the text. + textAlign(CENTER, CENTER); + textFont('Courier New'); + textSize(10); + + // Display the text. + text(`${trimmed[0]} ${trimmed[1]} ${trimmed[2]}`, 50, 50); + + describe('The text "wide open spaces" written in black on a gray background.'); + } + +
+class: p5 +return: + description: trimmed string. + type: String +overloads: + - line: 916 + params: + - name: str + description: | +

string to trim.

+ type: String + return: + description: trimmed string. + type: String + - line: 984 + params: + - name: strs + description: | +

strings to trim.

+ type: 'String[]' + return: + description: trimmed strings. + type: 'String[]' +chainable: false +--- + + +# trim diff --git a/src/content/reference/en/p5 copy/turnAxis.mdx b/src/content/reference/en/p5 copy/turnAxis.mdx new file mode 100644 index 0000000000..e8dc93e115 --- /dev/null +++ b/src/content/reference/en/p5 copy/turnAxis.mdx @@ -0,0 +1,54 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L378 +title: turnAxis +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

When a device is rotated, the axis that triggers the deviceTurned() + + method is stored in the turnAxis variable. The turnAxis variable is only + defined within + + the scope of deviceTurned().

+line: 378 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // Run this example on a mobile device + // Rotate the device by 90 degrees in the + // X-axis to change the value. + + let value = 0; + 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') { + if (value === 0) { + value = 255; + } else if (value === 255) { + value = 0; + } + } + } + +
+class: p5 +type: String +--- + + +# turnAxis diff --git a/src/content/reference/en/p5 copy/types/Array.mdx b/src/content/reference/en/p5 copy/types/Array.mdx new file mode 100644 index 0000000000..17fe1c2ed3 --- /dev/null +++ b/src/content/reference/en/p5 copy/types/Array.mdx @@ -0,0 +1,269 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L1140 +title: Array +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: > +

A list that keeps several pieces of data in order.

+ +

Arrays are helpful for storing related data. They can contain data of any + + type. For example, an array could contain a list of someone's favorite + + colors as strings. Arrays are created as follows:

+ +
let myArray = ['deeppink', 'darkorchid',
+  'magenta'];
+
+  
+ +

Each piece of data in an array is called an element. Each element has an + + address, or index, within its array. The variable myArray refers + to an + + array with three String elements, + 'deeppink', + + 'darkorchid', and 'magenta'. Arrays are + zero-indexed, which means + + that 'deeppink' is at index 0, 'darkorchid' is at + index 1, and + + 'magenta' is at index 2. Array elements can be accessed using + their + + indices as follows:

+ +
let zeroth = myArray[0]; // 'deeppink'
+
+  let first = myArray[1]; // 'darkorchid'
+
+  let second = myArray[2]; // 'magenta'
+
+  
+ +

Elements can be added to the end of an array by calling the + + push() + + method as follows:

+ +
myArray.push('lavender');
+
+
+  let third = myArray[3]; // 'lavender'
+
+  
+ +

See MDN + + for more information about arrays.

+line: 1140 +isConstructor: false +itemtype: property +example: + - >- + +
+ + + + // Declare the variable xCoordinates and assign it an array + + // with three numeric elements. + + let xCoordinates = [25, 50, 75]; + + + function setup() { + createCanvas(100, 100); + + describe( + 'Three white circles drawn in a horizontal line on a gray background.' + ); + } + + + function draw() { + background(200); + + // Access the element at index 0, which is 25. + circle(xCoordinates[0], 50, 20); + + // Access the element at index 1, which is 50. + circle(xCoordinates[1], 50, 20); + + // Access the element at index 2, which is 75. + circle(xCoordinates[2], 50, 20); + } + + + +
+ + +
+ + + + // Declare the variable xCoordinates and assign it an array with three + numeric elements. + + let xCoordinates = [20, 40, 60]; + + + // Add another element to the end of the array. + + xCoordinates.push(80); + + + function setup() { + createCanvas(100, 100); + + describe('Four white circles drawn in a horizontal line on a gray background.'); + } + + + function draw() { + background(200); + + // Access the element at index 0, which is 20. + circle(xCoordinates[0], 50, 20); + + // Access the element at index 1, which is 40. + circle(xCoordinates[1], 50, 20); + + // Access the element at index 2, which is 60. + circle(xCoordinates[2], 50, 20); + + // Access the element at index 3, which is 80. + circle(xCoordinates[3], 50, 20); + } + + + +
+ + +
+ + + + // Declare the variable xCoordinates and assign it an empty array. + + let xCoordinates = []; + + + function setup() { + createCanvas(100, 100); + + // Add elements to the array using a loop. + for (let x = 20; x < 100; x += 20) { + xCoordinates.push(x); + } + + describe('Four white circles drawn in a horizontal line on a gray background.'); + } + + + function draw() { + background(200); + + // Access the element at index i and use it to draw a circle. + for (let i = 0; i < xCoordinates.length; i += 1) { + circle(xCoordinates[i], 50, 20); + } + } + + + +
+ + +
+ + + + // Declare the variable xCoordinates and assign it an empty array. + + let xCoordinates = []; + + + function setup() { + createCanvas(100, 100); + + // Add elements to the array using a loop. + for (let x = 20; x < 100; x += 20) { + xCoordinates.push(x); + } + + describe('Four white circles drawn in a horizontal line on a gray background.'); + } + + + function draw() { + background(200); + + // Access each element of the array and use it to draw a circle. + for (let x of xCoordinates) { + circle(x, 50, 20); + } + } + + + +
+ + +
+ + + + // Declare the variable xCoordinates and assign it an empty array. + + let xCoordinates = []; + + + function setup() { + createCanvas(100, 100); + + // Add elements to the array using a loop. + for (let x = 20; x < 100; x += 20) { + xCoordinates.push(x); + } + + describe( + 'Four white circles in a horizontal line on a gray background. The circles move randomly.' + ); + } + + + function draw() { + background(200); + + for (let i = 0; i < xCoordinates.length; i += 1) { + // Update the element at index i. + xCoordinates[i] += random(-1, 1); + + // Use the element at index i to draw a circle. + circle(xCoordinates[i], 50, 20); + } + } + + + +
+class: p5 +--- + + +# Array diff --git a/src/content/reference/en/p5 copy/types/Boolean.mdx b/src/content/reference/en/p5 copy/types/Boolean.mdx new file mode 100644 index 0000000000..01d02c8de2 --- /dev/null +++ b/src/content/reference/en/p5 copy/types/Boolean.mdx @@ -0,0 +1,273 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L502 +title: Boolean +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: > +

A value that's either true or false.

+ +

Boolean values help to make decisions in code. They appear any + time a + + logical condition is checked. For example, the condition + + "Is a mouse button being pressed?" must be either true or + + false:

+ +
// If the user presses the mouse, draw a circle
+  at
+
+  // the mouse's location.
+
+  if (mouseIsPressed === true) {
+    circle(mouseX, mouseY, 20);
+  }
+
+  
+ +

The if statement checks whether + + mouseIsPressed is + true and draws a + + circle if it is. Boolean expressions such as mouseIsPressed + === true + + evaluate to one of the two possible Boolean values: + true or false.

+ +

The === operator (EQUAL) checks whether two values are equal. + If they + + are, the expression evaluates to true. Otherwise, it evaluates to + + false.

+ +

Note: There's also a == operator with two = + instead of three. Don't use + + it.

+ +

The mouseIsPressed system + variable is + + always true or false, so the code snippet above + could also be written + + as follows:

+ +
if (mouseIsPressed) {
+    circle(mouseX, mouseY, 20);
+  }
+
+  
+ +

The !== operator (NOT EQUAL) checks whether two values are not + equal, as + + in the following example:

+ +
if (2 + 2 !== 4) {
+    text('War is peace.', 50, 50);
+  }
+
+  
+ +

Starting from the left, the arithmetic expression 2 + 2 + produces the + + value 4. The Boolean expression 4 !== 4 + evaluates to false because + + 4 is equal to itself. As a result, the if + statement's body is skipped.

+ +

Note: There's also a != operator with one = + instead of two. Don't use + + it.

+ +

The Boolean operator && (AND) checks whether two + expressions are both + + true:

+ +
if (keyIsPressed === true && key === 'p') {
+    text('You pressed the "p" key!', 50, 50);
+  }
+
+  
+ +

If the user is pressing a key AND that key is 'p', then a + message will + + display.

+ +

The Boolean operator || (OR) checks whether at + least one of two + + expressions is true:

+ +
if (keyIsPressed === true || mouseIsPressed ===
+  true) {
+    text('You did something!', 50, 50);
+  }
+
+  
+ +

If the user presses a key, or presses a mouse button, or both, then a + + message will display.

+ +

The following truth table summarizes a few common scenarios with + && and + + ||:

+ +
true && true  // true
+
+  true && false // false
+
+  false && false // false
+
+  true || true  // true
+
+  true || false // true
+
+  false || false // false
+
+  
+ +

The relational operators >, << code="">, + >=, and <=< code=""> also produce Boolean + + values:

+ +
2 > 1 // true
+
+  2 < 1 // false
+
+  2 >= 2 // true
+
+  2 <= 2="" true="" <="" code=""/>
+ +

See if for more information about + if statements and + + Number for more information about + Numbers.

+line: 502 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A gray square. When the user presses the mouse, a circle appears at that location.'); + } + + function draw() { + background(200); + + // If the user presses the mouse, draw a circle at that location. + if (mouseIsPressed) { + circle(mouseX, mouseY, 20); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A gray square. When the user presses the mouse, a circle appears at that location.'); + } + + function draw() { + background(200); + + // If the user presses the mouse, draw a circle at that location. + if (mouseIsPressed === true) { + circle(mouseX, mouseY, 20); + } + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + function setup() { + createCanvas(100, 100); + + describe('A gray square that turns pink when the user presses the mouse or a key.'); + } + + function draw() { + background(200); + + // If the user presses the mouse, change the background color. + if (mouseIsPressed === true || keyIsPressed === true) { + background('deeppink'); + } + } + +
+ +
+ + // Click the canvas to begin detecting key presses. + + // Create a Boolean variable. + let isPlaying = false; + + function setup() { + createCanvas(100, 100); + + describe( + 'The message "Begin?\nY or N" written in green on a black background. The message "Good luck!" appears when they press the "y" key.' + ); + } + + function draw() { + background(0); + + // Style the text. + textAlign(CENTER, CENTER); + textFont('Courier New'); + textSize(16); + fill(0, 255, 0); + + // Display a different message when the user begins playing. + if (isPlaying === false) { + text('Begin?', 50, 40); + text('Y or N', 50, 60); + } else { + text('Good luck!', 50, 50); + } + } + + // Start playing when the user presses the 'y' key. + function keyPressed() { + if (key === 'y') { + isPlaying = true; + } + } + +
+class: p5 +--- + + +# Boolean diff --git a/src/content/reference/en/p5 copy/types/Number.mdx b/src/content/reference/en/p5 copy/types/Number.mdx new file mode 100644 index 0000000000..3dfa850720 --- /dev/null +++ b/src/content/reference/en/p5 copy/types/Number.mdx @@ -0,0 +1,201 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L853 +title: Number +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: > +

A number that can be positive, negative, or zero.

+ +

The Number data type is useful for describing values such as + position, + + size, and color. A number can be an integer such as 20 or a decimal number + + such as 12.34. For example, a circle's position and size can be described + + by three numbers:

+ +
circle(50, 50, 20);
+
+  
+ +
circle(50, 50, 12.34);
+
+  
+ +

Numbers support basic arithmetic and follow the standard order of + + operations: Parentheses, Exponents, Multiplication, Division, Addition, + + and Subtraction (PEMDAS). For example, it's common to use arithmetic + + operators with p5.js' system variables that are numbers:

+ +
// Draw a circle at the center.
+
+  circle(width / 2, height / 2, 20);
+
+  
+ +
// Draw a circle that moves from left to right.
+
+  circle(frameCount * 0.01, 50, 20);
+
+  
+ +

Here's a quick overview of the arithmetic operators:

+ +
1 + 2 // Add
+
+  1 - 2 // Subtract
+
+  1 * 2 // Multiply
+
+  1 / 2 // Divide
+
+  1 % 2 // Remainder
+
+  1 ** 2 // Exponentiate
+
+  
+ +

It's common to update a number variable using arithmetic. For example, an + + object's location can be updated like so:

+ +
x = x + 1;
+
+  
+ +

The statement above adds 1 to a variable x using the + + operator. The + + addition assignment operator += expresses the same idea:

+ +
x += 1;
+
+  
+ +

Here's a quick overview of the assignment operators:

+ +
x += 2 // Addition assignment
+
+  x -= 2 // Subtraction assignment
+
+  x *= 2 // Multiplication assignment
+
+  x /= 2 // Division assignment
+
+  x %= 2 // Remainder assignment
+
+  
+ +

Numbers can be compared using the + + relational operators + + >, << code="">, >=, <=< code="">, + ===, and !==. For example, a sketch's + + frameCount can be used as a + timer:

+ +
if (frameCount > 1000) {
+    text('Game over!', 50, 50);
+  }
+
+  
+ +

An expression such as frameCount > 1000 evaluates to a + Boolean value + + that's either true or false. The relational + operators all produce + + Boolean values:

+ +
2 > 1 // true
+
+  2 < 1 // false
+
+  2 >= 2 // true
+
+  2 <= 2="" true="" !="=" false="" <="" code=""/>
+ +

See Boolean for more information about + comparisons and conditions.

+ +

Note: There are also == and != operators with one + fewer =. Don't use them.

+ +

Expressions with numbers can also produce special values when something + + goes wrong:

+ +
sqrt(-1) // NaN
+
+  1 / 0 // Infinity
+
+  
+ +

The value NaN stands for + + Not-A-Number. + + NaN appears when calculations or conversions don't work. + Infinity is a + + value that's larger than any number. It appears during certain + + calculations.

+line: 853 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw a circle at the center. + circle(50, 50, 70); + + // Draw a smaller circle at the center. + circle(width / 2, height / 2, 30); + + describe('Two concentric, white circles drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A white circle travels from left to right on a gray background.'); + } + + function draw() { + background(200); + + circle(frameCount * 0.05, 50, 20); + } + +
+class: p5 +--- + + +# Number diff --git a/src/content/reference/en/p5 copy/types/Object.mdx b/src/content/reference/en/p5 copy/types/Object.mdx new file mode 100644 index 0000000000..c5c9adf8bb --- /dev/null +++ b/src/content/reference/en/p5 copy/types/Object.mdx @@ -0,0 +1,91 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L999 +title: Object +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: "

A container for data that's stored as key-value pairs.

\n

Objects help to organize related data of any type, including other objects.\nA value stored in an object can be accessed by name, called its key. Each\nkey-value pair is called a \"property.\" Objects are similar to dictionaries\nin Python and maps in Java and Ruby.

\n

For example, an object could contain the location, size, and appearance of\na dog:

\n
// Declare the dog variable and assign it an object.\nlet dog = { x: 50, y: 50, size: 20, emoji: '\U0001F436' };\n\n// Style the text.\ntextAlign(CENTER, CENTER);\ntextSize(dog.size);\n\n// Draw the dog.\ntext(dog.emoji, dog.x, dog.y);\n
\n

The variable dog is assigned an object with four properties. Objects\nare declared with curly braces {}. Values can be accessed using the dot\noperator, as in dog.size. In the example above, the key size\ncorresponds to the value 20. Objects can also be empty to start:

\n
// Declare a cat variable and assign it an empty object.\nlet cat = {};\n\n// Add properties to the object.\ncat.x = 50;\ncat.y = 50;\ncat.size = 20;\ncat.emoji = '\U0001F431';\n\n// Style the text.\ntextAlign(CENTER, CENTER);\ntextSize(cat.size);\n\n// Draw the cat.\ntext(cat.emoji, cat.x, cat.y);\n
\n

An object's data can be updated while a sketch runs. For example, the cat\ncould run away from the dog by updating its location:

\n
// Run to the right.\ncat.x += 5;\n
\n

If needed, an object's values can be accessed using square brackets []\nand strings instead of dot notation:

\n
// Run to the right.\ncat[\"x\"] += 5;\n
\n

This syntax can be helpful when the key's name has spaces, as in\ncat['height (m)'].

\n" +line: 999 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // Declare the variable data and assign it an object with three properties. + let data = { x: 50, y: 50, d: 20 }; + + function setup() { + createCanvas(100, 100); + + describe('A white circle on a gray background.'); + } + + function draw() { + background(200); + + // Access the object's values using the . operator. + circle(data.x, data.y, data.d); + } + +
+ +
+ + // Declare the variable data and assign it an object with three properties. + let data = { x: 50, y: 50, d: 20 }; + + // Add another property for color. + data.color = 'deeppink'; + + function setup() { + createCanvas(100, 100); + + describe('A pink circle on a gray background.'); + } + + function draw() { + background(200); + + // Access the object's values using the . operator. + fill(data.color); + circle(data.x, data.y, data.d); + } + +
+ +
+ + // Declare the variable data and assign it an object with three properties. + let data = { x: 50, y: 50, d: 20 }; + + // Add another property for color. + data.color = 'deeppink'; + + function setup() { + createCanvas(100, 100); + + describe('A white circle on a gray background.'); + } + + function draw() { + background(200); + + // Access the object's values using the . operator. + fill(data.color); + circle(data.x, data.y, data.d); + + // Update the object's x and y properties. + data.x += random(-1, 1); + data.y += random(-1, 1); + } + +
+class: p5 +--- + + +# Object diff --git a/src/content/reference/en/p5 copy/types/String.mdx b/src/content/reference/en/p5 copy/types/String.mdx new file mode 100644 index 0000000000..e62a9a8b9c --- /dev/null +++ b/src/content/reference/en/p5 copy/types/String.mdx @@ -0,0 +1,153 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L710 +title: String +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: > +

A sequence of text characters.

+ +

The String data type is helpful for working with text. For + example, a + + string could contain a welcome message:

+ +
// Use a string literal.
+
+  text('Hello!', 10, 10);
+
+  
+ +
// Create a string variable.
+
+  let message = 'Hello!';
+
+
+  // Use the string variable.
+
+  text(message, 10, 10);
+
+  
+ +

The most common way to create strings is to use some form of quotations as + + follows:

+ +
text("hi", 50, 50);
+
+  
+ +
text('hi', 50, 50);
+
+  
+ +
text(`hi`, 50, 50);
+
+  
+ +

"hi", 'hi', and hi are all string + literals. A "literal" means a + + value was actually written, as in text('hi', 50, 50). By + contrast, + + text(message, 50, 50) uses the variable message, so + it isn't a string + + literal.

+ +

Single quotes '' and double quotes "" mean the + same thing. It's nice to + + have the option for cases when a string contains one type of quote:

+ +
text("What's up?", 50, 50);
+
+  
+ +
text('Air quotes make you look "cool."', 50,
+  50);
+
+  
+ +

Backticks `` create template literals. Template literals have + many uses. + + For example, they can contain both single and double quotes as needed:

+ +
text(`"Don't you forget about me"`,  10, 10);
+
+  
+ +

Template literals are helpful when strings are created from variables like + + so:

+ +
let size = random(10, 20);
+
+  circle(50, 50, size);
+
+
+  text(`The circle's diameter is ${size} pixels.`,  10, 10);
+
+  
+ +

The size variable's value will replace ${size} + when the string is + + created. ${} is a placeholder for any value. That means an + expression can + + be used, as in ${round(PI, 3)}. All of the following are valid + template + + literals:

+ +
text(`π is about ${round(PI, 2)} pixels.`,  10,
+  10);
+
+  text(`It's ${mouseX < width / 2} that I'm on the left half of the canvas.`, 
+  10, 30);
+
+  
+ +

Template literals can include several variables:

+ +
let x = random(0, 100);
+
+  let y = random(0, 100);
+
+  let size = random(10, 20);
+
+  circle(x, y, size);
+
+
+  text(`The circle at (${x}, ${y}) has a diameter of ${size} pixels.`,  10, 10);
+
+  
+ +

Template literals are also helpful for creating multi-line text like + so:

+ +
let poem = `My sketch doesn't run;
+
+  it waits for me patiently
+
+  while bugs point the way.`;
+
+
+  text(poem, 10, 10);
+
+  
+line: 710 +isConstructor: false +itemtype: property +example: + - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Style the text.\n textAlign(CENTER, CENTER);\n textSize(20);\n\n // Display a welcome message.\n text('Hello!', 50, 50);\n\n describe('The text \"Hello!\" written on a gray background.');\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Style the text.\n textAlign(CENTER, CENTER);\n textSize(20);\n\n // Create a string variable.\n let world = '\U0001F30D';\n\n // Display a welcome message using a template string.\n text(`Hello, ${world}!`, 50, 50);\n\n describe('The text \"Hello, \U0001F30D!\" written on a gray background.');\n}\n\n
" +class: p5 +--- + + +# String diff --git a/src/content/reference/en/p5 copy/unchar.mdx b/src/content/reference/en/p5 copy/unchar.mdx new file mode 100644 index 0000000000..8ef044b393 --- /dev/null +++ b/src/content/reference/en/p5 copy/unchar.mdx @@ -0,0 +1,114 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L731 +title: unchar +module: Data +submodule: Conversion +file: src/utilities/conversion.js +description: > +

Converts a single-character String to a + Number.

+ +

unchar() converts single-character strings to their + corresponding + + integer (whole number).

+ +

The parameter, n, is the character to convert. For example, + + unchar('A'), returns the number 65. If an array is passed, as in + + unchar(['A', 'B', 'C']), an array of integers is returned.

+line: 731 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let original = 'A'; + + // Convert the string to a number. + let converted = unchar(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the original and converted values. + text(`${original} : ${converted}`, 50, 50); + + describe('The text "A : 65" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of characters. + let original = ['A', 'B', 'C']; + + // Convert the string to a number. + let converted = unchar(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Iterate over elements of the converted array. + for (let i = 0; i < converted.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 25; + + // Display the original and converted values. + text(`${original[i]} : ${converted[i]}`, 50, y); + } + + describe( + 'The text "A : 65", "B : 66", and "C :67" written on three separate lines. The text is in black on a gray background.' + ); + } + +
+class: p5 +return: + description: converted number. + type: Number +overloads: + - line: 731 + params: + - name: 'n' + description: | +

value to convert.

+ type: String + return: + description: converted number. + type: Number + - line: 805 + params: + - name: ns + description: | +

values to convert.

+ type: 'String[]' + return: + description: converted numbers. + type: 'Number[]' +chainable: false +--- + + +# unchar diff --git a/src/content/reference/en/p5 copy/unhex.mdx b/src/content/reference/en/p5 copy/unhex.mdx new file mode 100644 index 0000000000..5c507abc4c --- /dev/null +++ b/src/content/reference/en/p5 copy/unhex.mdx @@ -0,0 +1,121 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L956 +title: unhex +module: Data +submodule: Conversion +file: src/utilities/conversion.js +description: > +

Converts a String with a hexadecimal value to a + Number.

+ +

unhex() converts a string with its hexadecimal number value to + a number. + + Hexadecimal (hex) numbers are base-16, which means there are 16 unique + + digits. Hex extends the numbers 0–9 with the letters A–F. For example, the + + number 11 (eleven) in base-10 is written as the letter + B in hex.

+ +

The first parameter, n, is the hex string to convert. For + example, + + unhex('FF'), returns the number 255. If an array is passed, as in + + unhex(['00', '80', 'FF']), an array of numbers is returned.

+line: 956 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a a hex string variable + let original = 'FF'; + + // Convert the hex string to a number. + let converted = unhex(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the original and converted values. + text(`${original} = ${converted}`, 50, 50); + + describe('The text "FF = 255" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of numbers. + let original = ['00', '80', 'FF']; + + // Convert the numbers to hex strings. + // Only use two hex digits. + let converted = unhex(original, 2); + + // Style the text. + textAlign(RIGHT, CENTER); + textSize(16); + + // Iterate over the converted values. + for (let i = 0; i < converted.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 25; + + // Display the original and converted values. + text(`${ original[i]} = ${converted[i]}`, 80, y); + } + + describe( + 'The text "00 = 0", "80 = 128", and "FF = 255" written on three separate lines. The text is in black on a gray background.' + ); + } + +
+class: p5 +return: + description: converted number. + type: Number +overloads: + - line: 956 + params: + - name: 'n' + description: | +

value to convert.

+ type: String + return: + description: converted number. + type: Number + - line: 1033 + params: + - name: ns + description: | +

values to convert.

+ type: 'String[]' + return: + description: converted numbers. + type: 'Number[]' +chainable: false +--- + + +# unhex diff --git a/src/content/reference/en/p5 copy/updatePixels.mdx b/src/content/reference/en/p5 copy/updatePixels.mdx new file mode 100644 index 0000000000..5de892374b --- /dev/null +++ b/src/content/reference/en/p5 copy/updatePixels.mdx @@ -0,0 +1,94 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L1118 +title: updatePixels +module: Image +submodule: Pixels +file: src/image/pixels.js +description: > +

Updates the canvas with the RGBA values in the + + pixels array.

+ +

updatePixels() only needs to be called after changing values + in the + + pixels array. Such changes can be made + directly + + after calling loadPixels() or by + calling + + set().

+line: 1118 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/rockies.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0, 100, 100); + + // Get the pixel density. + let d = pixelDensity(); + + // Calculate the halfway index in the pixels array. + let halfImage = 4 * (d * width) * (d * height / 2); + + // Load the pixels array. + loadPixels(); + + // Copy the top half of the canvas to the bottom. + for (let i = 0; i < halfImage; i += 1) { + pixels[i + halfImage] = pixels[i]; + } + + // Update the canvas. + updatePixels(); + + describe('Two identical images of mountain landscapes, one on top of the other.'); + } + +
+class: p5 +params: + - name: x + description: | +

x-coordinate of the upper-left corner of region + to update.

+ type: Number + optional: true + - name: 'y' + description: | +

y-coordinate of the upper-left corner of region + to update.

+ type: Number + optional: true + - name: w + description: | +

width of region to update.

+ type: Number + optional: true + - name: h + description: | +

height of region to update.

+ type: Number + optional: true +chainable: false +--- + + +# updatePixels diff --git a/src/content/reference/en/p5 copy/userStartAudio.mdx b/src/content/reference/en/p5 copy/userStartAudio.mdx new file mode 100644 index 0000000000..076d8537c5 --- /dev/null +++ b/src/content/reference/en/p5 copy/userStartAudio.mdx @@ -0,0 +1,99 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L198 +title: userStartAudio +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: >- +

It is not only a good practice to give users control over starting + + audio. This policy is enforced by many web browsers, including iOS and + + Google Chrome, which create the Web Audio API's + + Audio Context + + in a suspended state.

+ + +

In these browser-specific policies, sound will not play until a user + + interaction event (i.e. mousePressed()) explicitly resumes + + the AudioContext, or starts an audio node. This can be accomplished by + + calling start() on a p5.Oscillator, + + play() on a p5.SoundFile, or simply + + userStartAudio().

+ + +

userStartAudio() starts the AudioContext on a user + + gesture. The default behavior will enable audio on any + + mouseUp or touchEnd event. It can also be placed in a specific + + interaction function, such as mousePressed() as in the + + example below. This method utilizes + + StartAudioContext + + , a library by Yotam Mann (MIT Licence, 2016).

+line: 198 +isConstructor: false +itemtype: method +example: + - |- + +
+ function setup() { + // mimics the autoplay policy + getAudioContext().suspend(); + + let mySynth = new p5.MonoSynth(); + + // This won't play until the context has resumed + mySynth.play('A6'); + } + function draw() { + background(220); + textAlign(CENTER, CENTER); + text(getAudioContext().state, width/2, height/2); + } + function mousePressed() { + userStartAudio(); + } +
+class: p5 +params: + - name: elements + description: | +

This argument can be an Element, + Selector String, NodeList, p5.Element, + jQuery Element, or an Array of any of those.

+ type: Element|Array + optional: true + - name: callback + description: | +

Callback to invoke when the AudioContext + has started

+ type: Function + optional: true +return: + description: |- + Returns a Promise that resolves when + the AudioContext state is 'running' + type: Promise +chainable: false +--- + + +# userStartAudio diff --git a/src/content/reference/en/p5 copy/vertex.mdx b/src/content/reference/en/p5 copy/vertex.mdx new file mode 100644 index 0000000000..92d5bb9138 --- /dev/null +++ b/src/content/reference/en/p5 copy/vertex.mdx @@ -0,0 +1,242 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L1881 +title: vertex +module: Shape +submodule: Vertex +file: src/core/shape/vertex.js +description: > +

Adds a vertex to a custom shape.

+ +

vertex() sets the coordinates of vertices drawn between the + + beginShape() and + + endShape() functions.

+ +

The first two parameters, x and y, set the x- and + y-coordinates of the + + vertex.

+ +

The third parameter, z, is optional. It sets the z-coordinate + of the + + vertex in WebGL mode. By default, z is 0.

+ +

The fourth and fifth parameters, u and v, are + also optional. They set + + the u- and v-coordinates for the vertex’s texture when used with + + endShape(). By default, u + and v are both 0.

+line: 1881 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the shape. + strokeWeight(3); + + // Start drawing the shape. + // Only draw the vertices. + beginShape(POINTS); + + // Add the vertices. + vertex(30, 20); + vertex(85, 20); + vertex(85, 75); + vertex(30, 75); + + // Stop drawing the shape. + endShape(); + + describe('Four black dots that form a square are drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + beginShape(); + + // Add vertices. + vertex(30, 20); + vertex(85, 20); + vertex(85, 75); + vertex(30, 75); + + // Stop drawing the shape. + endShape(CLOSE); + + describe('A white square on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + // Start drawing the shape. + beginShape(); + + // Add vertices. + vertex(-20, -30, 0); + vertex(35, -30, 0); + vertex(35, 25, 0); + vertex(-20, 25, 0); + + // Stop drawing the shape. + endShape(CLOSE); + + describe('A white square on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white square spins around slowly on a gray background.'); + } + + function draw() { + background(200); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Start drawing the shape. + beginShape(); + + // Add vertices. + vertex(-20, -30, 0); + vertex(35, -30, 0); + vertex(35, 25, 0); + vertex(-20, 25, 0); + + // Stop drawing the shape. + endShape(CLOSE); + } + +
+ +
+ + let img; + + // Load an image to apply as a texture. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A photograph of a ceiling rotates slowly against a gray background.'); + } + + function draw() { + background(200); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Style the shape. + noStroke(); + + // Apply the texture. + texture(img); + textureMode(NORMAL); + + // Start drawing the shape + beginShape(); + + // Add vertices. + vertex(-20, -30, 0, 0, 0); + vertex(35, -30, 0, 1, 0); + vertex(35, 25, 0, 1, 1); + vertex(-20, 25, 0, 0, 1); + + // Stop drawing the shape. + endShape(); + } + +
+class: p5 +overloads: + - line: 1881 + params: + - name: x + description: | +

x-coordinate of the vertex.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the vertex.

+ type: Number + chainable: 1 + - line: 2052 + params: + - name: x + description: '' + type: Number + - name: 'y' + description: '' + type: Number + - name: z + description: | +

z-coordinate of the vertex. Defaults to 0.

+ type: Number + optional: true + chainable: 1 + - line: 2059 + params: + - name: x + description: '' + type: Number + - name: 'y' + description: '' + type: Number + - name: z + description: '' + type: Number + optional: true + - name: u + description: | +

u-coordinate of the vertex's texture. Defaults to 0.

+ type: Number + optional: true + - name: v + description: | +

v-coordinate of the vertex's texture. Defaults to 0.

+ type: Number + optional: true + chainable: 1 +chainable: true +--- + + +# vertex diff --git a/src/content/reference/en/p5 copy/webglVersion.mdx b/src/content/reference/en/p5 copy/webglVersion.mdx new file mode 100644 index 0000000000..1909f94a86 --- /dev/null +++ b/src/content/reference/en/p5 copy/webglVersion.mdx @@ -0,0 +1,105 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L508 +title: webglVersion +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

A String variable with the WebGL version in use.

+ +

webglVersion's value equals one of the following string + constants:

+ +
    + +
  • WEBGL2 whose value is 'webgl2',
  • + +
  • WEBGL whose value is 'webgl', or
  • + +
  • P2D whose value is 'p2d'. This is the default + for 2D sketches.
  • + +
+ +

See setAttributes() for ways to + set the + + WebGL version.

+line: 508 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + background(200); + + // Display the current WebGL version. + text(webglVersion, 42, 54); + + describe('The text "p2d" written in black on a gray background.'); + } + +
+ +
+ + let font; + + function preload() { + // Load a font to use. + font = loadFont('/assets/inconsolata.otf'); + } + + function setup() { + // Create a canvas using WEBGL mode. + createCanvas(100, 50, WEBGL); + background(200); + + // Display the current WebGL version. + fill(0); + textFont(font); + text(webglVersion, -15, 5); + + describe('The text "webgl2" written in black on a gray background.'); + } + +
+ +
+ + let font; + + function preload() { + // Load a font to use. + font = loadFont('/assets/inconsolata.otf'); + } + + function setup() { + // Create a canvas using WEBGL mode. + createCanvas(100, 50, WEBGL); + + // Set WebGL to version 1. + setAttributes({ version: 1 }); + + background(200); + + // Display the current WebGL version. + fill(0); + textFont(font); + text(webglVersion, -14, 5); + + describe('The text "webgl" written in black on a gray background.'); + } + +
+class: p5 +type: String +--- + + +# webglVersion diff --git a/src/content/reference/en/p5 copy/while.mdx b/src/content/reference/en/p5 copy/while.mdx new file mode 100644 index 0000000000..5fdcb2985a --- /dev/null +++ b/src/content/reference/en/p5 copy/while.mdx @@ -0,0 +1,161 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L1872 +title: while +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: > +

A way to repeat a block of code.

+ +

while loops are helpful for repeating statements while a + condition is + + true. They're like if statements that repeat. For + example, a while + + loop makes it easy to express the idea "draw several lines" like so:

+ +
// Declare a variable to keep track of
+  iteration.
+
+  let x = 10;
+
+
+  // Repeat as long as x < 100
+
+  while (x < 100) {
+    line(x, 25, x, 75);
+
+    // Increment by 20.
+    x += 20;
+  }
+
+  
+ +

The loop's header begins with the keyword while. Loops + generally count up + + or count down as they repeat, or iterate. The statement in parentheses + + x < 100 is a condition the loop checks each time it iterates. If + the + + condition is true, the loop runs the code between the curly + braces {}, + + The code between the curly braces is called the loop's body. If the + + condition is false, the body is skipped and the loop is + stopped.

+ +

It's common to create infinite loops accidentally. For example, the + + following loop never stops iterating because it doesn't count up:

+ +
// Declare a variable to keep track of
+  iteration.
+
+  let x = 10;
+
+
+  // Repeat as long as x < 100
+
+  while (x < 100) {
+    line(x, 25, x, 75);
+  }
+
+
+  // This should be in the loop's body!
+
+  x += 20;
+
+  
+ +

The statement x += 20 appears after the loop's body. That + means the + + variable x is stuck at 10, which is always less + than 100.

+ +

while loops are useful when the number of iterations isn't + known in + + advance. For example, concentric circles could be drawn at random + + increments:

+ +
let d = 100;
+
+  let minSize = 5;
+
+
+  while (d > minSize) {
+    circle(50, 50, d);
+    d -= random(10);
+  }
+
+  
+line: 1872 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('Five black vertical lines on a gray background.'); + } + + function draw() { + background(200); + + // Declare a variable to keep track of iteration. + let x = 10; + + // Repeat as long as x < 100 + while (x < 100) { + line(x, 25, x, 75); + + // Increment by 20. + x += 20; + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Slow the frame rate. + frameRate(5); + + describe( + "A gray square with several concentric circles at the center. The circles' sizes decrease at random increments." + ); + } + + function draw() { + background(200); + + let d = 100; + let minSize = 5; + + while (d > minSize) { + circle(50, 50, d); + d -= random(5, 15); + } + } + +
+class: p5 +--- + + +# while diff --git a/src/content/reference/en/p5 copy/width.mdx b/src/content/reference/en/p5 copy/width.mdx new file mode 100644 index 0000000000..0eb6ad07bb --- /dev/null +++ b/src/content/reference/en/p5 copy/width.mdx @@ -0,0 +1,87 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L812 +title: width +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

A Number variable that stores the width of the canvas in + pixels.

+ +

width's default value is 100. Calling + + createCanvas() or + + resizeCanvas() changes the value of + + width. Calling noCanvas() + sets its value to + + 0.

+line: 812 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + background(200); + + // Display the canvas' width. + text(width, 42, 54); + + describe('The number 100 written in black on a gray square.'); + } + +
+ +
+ + function setup() { + createCanvas(50, 100); + + background(200); + + // Display the canvas' width. + text(width, 21, 54); + + describe('The number 50 written in black on a gray rectangle.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Display the canvas' width. + text(width, 42, 54); + + describe('The number 100 written in black on a gray square. When the mouse is pressed, the square becomes a rectangle and the number becomes 50.'); + } + + // If the mouse is pressed, reisze + // the canvas and display its new + // width. + function mousePressed() { + if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) { + resizeCanvas(50, 100); + background(200); + text(width, 21, 54); + } + } + +
+class: p5 +type: Number +--- + + +# width diff --git a/src/content/reference/en/p5 copy/winMouseX.mdx b/src/content/reference/en/p5 copy/winMouseX.mdx new file mode 100644 index 0000000000..ae7dbc3fac --- /dev/null +++ b/src/content/reference/en/p5 copy/winMouseX.mdx @@ -0,0 +1,61 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L463 +title: winMouseX +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A Number variable that tracks the mouse's horizontal position + within the + + browser.

+ +

winMouseX keeps track of the mouse's position relative to the + top-left + + corner of the browser window. For example, if the mouse is 50 pixels from + + the left edge of the browser, then winMouseX will be 50.

+ +

On a touchscreen device, winMouseX will hold the x-coordinate + of the most + + recent touch point.

+ +

Note: Use mouseX to track the mouse’s + + x-coordinate within the canvas.

+line: 463 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe("A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse."); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the mouse's coordinates within the browser window. + text(`x: ${winMouseX} y: ${winMouseY}`, 50, 50); + } + +
+class: p5 +type: Number +--- + + +# winMouseX diff --git a/src/content/reference/en/p5 copy/winMouseY.mdx b/src/content/reference/en/p5 copy/winMouseY.mdx new file mode 100644 index 0000000000..32c59cba4c --- /dev/null +++ b/src/content/reference/en/p5 copy/winMouseY.mdx @@ -0,0 +1,61 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L504 +title: winMouseY +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A Number variable that tracks the mouse's vertical position + within the + + browser.

+ +

winMouseY keeps track of the mouse's position relative to the + top-left + + corner of the browser window. For example, if the mouse is 50 pixels from + + the top edge of the browser, then winMouseY will be 50.

+ +

On a touchscreen device, winMouseY will hold the y-coordinate + of the most + + recent touch point.

+ +

Note: Use mouseY to track the mouse’s + + y-coordinate within the canvas.

+line: 504 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe("A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse."); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the mouse's coordinates within the browser window. + text(`x: ${winMouseX} y: ${winMouseY}`, 50, 50); + } + +
+class: p5 +type: Number +--- + + +# winMouseY diff --git a/src/content/reference/en/p5 copy/windowHeight.mdx b/src/content/reference/en/p5 copy/windowHeight.mdx new file mode 100644 index 0000000000..829ac3d76b --- /dev/null +++ b/src/content/reference/en/p5 copy/windowHeight.mdx @@ -0,0 +1,43 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L680 +title: windowHeight +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

A Number variable that stores the height of the browser's + viewport.

+ +

The layout viewport + + is the area within the browser that's available for drawing.

+line: 680 +isConstructor: false +itemtype: property +alt: This example does not render anything. +example: + - |- + +
+ + function setup() { + // Set the canvas' width and height + // using the browser's dimensions. + createCanvas(windowWidth, windowHeight); + + background(200); + + describe('A gray canvas that takes up the entire browser window.'); + } + +
+class: p5 +type: Number +--- + + +# windowHeight diff --git a/src/content/reference/en/p5 copy/windowResized.mdx b/src/content/reference/en/p5 copy/windowResized.mdx new file mode 100644 index 0000000000..aed52e6b4b --- /dev/null +++ b/src/content/reference/en/p5 copy/windowResized.mdx @@ -0,0 +1,64 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L708 +title: windowResized +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

A function that's called when the browser window is resized.

+ +

Code placed in the body of windowResized() will run when the + + browser window's size changes. It's a good place to call + + resizeCanvas() or make other + + adjustments to accommodate the new window size.

+ +

The event parameter is optional. If added to the function + declaration, it + + can be used for debugging or other purposes.

+line: 708 +isConstructor: false +itemtype: method +alt: This example does not render anything. +example: + - |- + +
+ + function setup() { + createCanvas(windowWidth, windowHeight); + + describe('A gray canvas with a white circle at its center. The canvas takes up the entire browser window. It changes size to match the browser window.'); + } + + function draw() { + background(200); + + // Draw a circle at the center. + circle(width / 2, height / 2, 50); + } + + // Resize the canvas when the + // browser's size changes. + function windowResized() { + resizeCanvas(windowWidth, windowHeight); + } + +
+class: p5 +params: + - name: event + description: | +

optional resize Event.

+ type: Event + optional: true +chainable: false +--- + + +# windowResized diff --git a/src/content/reference/en/p5 copy/windowWidth.mdx b/src/content/reference/en/p5 copy/windowWidth.mdx new file mode 100644 index 0000000000..26ec5fc2a9 --- /dev/null +++ b/src/content/reference/en/p5 copy/windowWidth.mdx @@ -0,0 +1,43 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L652 +title: windowWidth +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

A Number variable that stores the width of the browser's + viewport.

+ +

The layout viewport + + is the area within the browser that's available for drawing.

+line: 652 +isConstructor: false +itemtype: property +alt: This example does not render anything. +example: + - |- + +
+ + function setup() { + // Set the canvas' width and height + // using the browser's dimensions. + createCanvas(windowWidth, windowHeight); + + background(200); + + describe('A gray canvas that takes up the entire browser window.'); + } + +
+class: p5 +type: Number +--- + + +# windowWidth diff --git a/src/content/reference/en/p5 copy/year.mdx b/src/content/reference/en/p5 copy/year.mdx new file mode 100644 index 0000000000..04efa83189 --- /dev/null +++ b/src/content/reference/en/p5 copy/year.mdx @@ -0,0 +1,47 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L311 +title: year +module: IO +submodule: Time & Date +file: src/utilities/time_date.js +description: | +

Returns the current year as a number such as 1999.

+line: 311 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Get the current year. + let y = year(); + + // Style the text. + textAlign(LEFT, CENTER); + textSize(12); + textFont('Courier New'); + + // Display the year. + text(`Current year: ${y}`, 10, 50, 80); + + describe(`The text 'Current year: ${y}' written in black on a gray background.`); + } + +
+class: p5 +return: + description: current year. + type: Integer +chainable: false +--- + + +# year From 3b72493014c0363244fe40bd2d6756fdb6624220 Mon Sep 17 00:00:00 2001 From: Aashish Panthi Date: Mon, 29 Jun 2026 23:41:45 +0545 Subject: [PATCH 14/16] Refactor translation tracker documentation and logic to clarify stub generation limits per language; remove test files. --- .github/actions/translation-tracker/README.md | 4 +- .../actions/translation-tracker/workflows.js | 28 +- src/content/reference/en/p5 copy/abs.mdx | 61 -- .../reference/en/p5 copy/accelerationX.mdx | 37 - .../reference/en/p5 copy/accelerationY.mdx | 37 - .../reference/en/p5 copy/accelerationZ.mdx | 37 - src/content/reference/en/p5 copy/acos.mdx | 86 -- src/content/reference/en/p5 copy/alpha.mdx | 120 --- .../reference/en/p5 copy/ambientLight.mdx | 241 ------ .../reference/en/p5 copy/ambientMaterial.mdx | 269 ------ .../reference/en/p5 copy/angleMode.mdx | 219 ----- src/content/reference/en/p5 copy/append.mdx | 48 -- .../reference/en/p5 copy/applyMatrix.mdx | 347 -------- src/content/reference/en/p5 copy/arc.mdx | 274 ------ .../reference/en/p5 copy/arrayCopy.mdx | 95 --- src/content/reference/en/p5 copy/asin.mdx | 86 -- src/content/reference/en/p5 copy/atan.mdx | 86 -- src/content/reference/en/p5 copy/atan2.mdx | 106 --- .../reference/en/p5 copy/background.mdx | 336 -------- .../reference/en/p5 copy/baseColorShader.mdx | 178 ---- .../en/p5 copy/baseMaterialShader.mdx | 418 --------- .../reference/en/p5 copy/baseNormalShader.mdx | 211 ----- .../reference/en/p5 copy/baseStrokeShader.mdx | 356 -------- .../reference/en/p5 copy/beginClip.mdx | 208 ----- .../reference/en/p5 copy/beginContour.mdx | 134 --- .../reference/en/p5 copy/beginGeometry.mdx | 281 ------- .../reference/en/p5 copy/beginShape.mdx | 449 ---------- src/content/reference/en/p5 copy/bezier.mdx | 273 ------ .../reference/en/p5 copy/bezierDetail.mdx | 121 --- .../reference/en/p5 copy/bezierPoint.mdx | 162 ---- .../reference/en/p5 copy/bezierTangent.mdx | 155 ---- .../reference/en/p5 copy/bezierVertex.mdx | 337 -------- src/content/reference/en/p5 copy/blend.mdx | 214 ----- .../reference/en/p5 copy/blendMode.mdx | 541 ------------ src/content/reference/en/p5 copy/blue.mdx | 158 ---- src/content/reference/en/p5 copy/boolean.mdx | 157 ---- src/content/reference/en/p5 copy/box.mdx | 186 ---- .../reference/en/p5 copy/brightness.mdx | 168 ---- .../reference/en/p5 copy/buildGeometry.mdx | 263 ------ src/content/reference/en/p5 copy/byte.mdx | 180 ---- src/content/reference/en/p5 copy/camera.mdx | 200 ----- src/content/reference/en/p5 copy/ceil.mdx | 65 -- src/content/reference/en/p5 copy/changed.mdx | 87 -- src/content/reference/en/p5 copy/char.mdx | 152 ---- src/content/reference/en/p5 copy/circle.mdx | 77 -- src/content/reference/en/p5 copy/class.mdx | 19 - src/content/reference/en/p5 copy/clear.mdx | 108 --- .../reference/en/p5 copy/clearDepth.mdx | 113 --- .../reference/en/p5 copy/clearStorage.mdx | 81 -- src/content/reference/en/p5 copy/clip.mdx | 225 ----- src/content/reference/en/p5 copy/color.mdx | 349 -------- .../reference/en/p5 copy/colorMode.mdx | 271 ------ src/content/reference/en/p5 copy/concat.mdx | 54 -- src/content/reference/en/p5 copy/cone.mdx | 265 ------ src/content/reference/en/p5 copy/console.mdx | 99 --- .../reference/en/p5 copy/constants/ADD.mdx | 18 - .../reference/en/p5 copy/constants/ALT.mdx | 18 - .../reference/en/p5 copy/constants/ARROW.mdx | 18 - .../reference/en/p5 copy/constants/AUTO.mdx | 25 - .../reference/en/p5 copy/constants/AXES.mdx | 18 - .../en/p5 copy/constants/BACKSPACE.mdx | 18 - .../en/p5 copy/constants/BASELINE.mdx | 18 - .../reference/en/p5 copy/constants/BEVEL.mdx | 18 - .../reference/en/p5 copy/constants/BEZIER.mdx | 18 - .../reference/en/p5 copy/constants/BLEND.mdx | 18 - .../reference/en/p5 copy/constants/BLUR.mdx | 18 - .../reference/en/p5 copy/constants/BOLD.mdx | 18 - .../en/p5 copy/constants/BOLDITALIC.mdx | 18 - .../reference/en/p5 copy/constants/BOTTOM.mdx | 18 - .../reference/en/p5 copy/constants/BURN.mdx | 18 - .../reference/en/p5 copy/constants/CENTER.mdx | 18 - .../reference/en/p5 copy/constants/CHAR.mdx | 18 - .../reference/en/p5 copy/constants/CHORD.mdx | 18 - .../reference/en/p5 copy/constants/CLAMP.mdx | 18 - .../reference/en/p5 copy/constants/CLOSE.mdx | 18 - .../en/p5 copy/constants/CONTAIN.mdx | 18 - .../en/p5 copy/constants/CONTROL.mdx | 18 - .../reference/en/p5 copy/constants/CORNER.mdx | 18 - .../en/p5 copy/constants/CORNERS.mdx | 18 - .../reference/en/p5 copy/constants/COVER.mdx | 18 - .../reference/en/p5 copy/constants/CROSS.mdx | 18 - .../reference/en/p5 copy/constants/CURVE.mdx | 18 - .../en/p5 copy/constants/DARKEST.mdx | 18 - .../en/p5 copy/constants/DEGREES.mdx | 59 -- .../reference/en/p5 copy/constants/DELETE.mdx | 18 - .../en/p5 copy/constants/DIFFERENCE.mdx | 18 - .../reference/en/p5 copy/constants/DILATE.mdx | 18 - .../reference/en/p5 copy/constants/DODGE.mdx | 18 - .../en/p5 copy/constants/DOWN_ARROW.mdx | 18 - .../reference/en/p5 copy/constants/ENTER.mdx | 18 - .../reference/en/p5 copy/constants/ERODE.mdx | 18 - .../reference/en/p5 copy/constants/ESCAPE.mdx | 18 - .../en/p5 copy/constants/EXCLUSION.mdx | 18 - .../en/p5 copy/constants/FALLBACK.mdx | 18 - .../reference/en/p5 copy/constants/FILL.mdx | 18 - .../reference/en/p5 copy/constants/FLAT.mdx | 18 - .../reference/en/p5 copy/constants/FLOAT.mdx | 18 - .../reference/en/p5 copy/constants/GRAY.mdx | 18 - .../reference/en/p5 copy/constants/GRID.mdx | 18 - .../en/p5 copy/constants/HALF_FLOAT.mdx | 18 - .../en/p5 copy/constants/HALF_PI.mdx | 109 --- .../reference/en/p5 copy/constants/HAND.mdx | 18 - .../en/p5 copy/constants/HARD_LIGHT.mdx | 18 - .../reference/en/p5 copy/constants/HSB.mdx | 24 - .../reference/en/p5 copy/constants/HSL.mdx | 18 - .../reference/en/p5 copy/constants/IMAGE.mdx | 18 - .../en/p5 copy/constants/IMMEDIATE.mdx | 18 - .../reference/en/p5 copy/constants/INVERT.mdx | 18 - .../reference/en/p5 copy/constants/ITALIC.mdx | 18 - .../reference/en/p5 copy/constants/LABEL.mdx | 18 - .../en/p5 copy/constants/LANDSCAPE.mdx | 18 - .../reference/en/p5 copy/constants/LEFT.mdx | 18 - .../en/p5 copy/constants/LEFT_ARROW.mdx | 18 - .../en/p5 copy/constants/LIGHTEST.mdx | 18 - .../reference/en/p5 copy/constants/LINEAR.mdx | 18 - .../reference/en/p5 copy/constants/LINES.mdx | 18 - .../en/p5 copy/constants/LINE_LOOP.mdx | 18 - .../en/p5 copy/constants/LINE_STRIP.mdx | 18 - .../reference/en/p5 copy/constants/MIRROR.mdx | 18 - .../reference/en/p5 copy/constants/MITER.mdx | 18 - .../reference/en/p5 copy/constants/MOVE.mdx | 18 - .../en/p5 copy/constants/MULTIPLY.mdx | 18 - .../en/p5 copy/constants/NEAREST.mdx | 18 - .../reference/en/p5 copy/constants/NORMAL.mdx | 18 - .../reference/en/p5 copy/constants/OPAQUE.mdx | 18 - .../reference/en/p5 copy/constants/OPEN.mdx | 18 - .../reference/en/p5 copy/constants/OPTION.mdx | 18 - .../en/p5 copy/constants/OVERLAY.mdx | 18 - .../reference/en/p5 copy/constants/P2D.mdx | 19 - .../reference/en/p5 copy/constants/PI.mdx | 108 --- .../reference/en/p5 copy/constants/PIE.mdx | 18 - .../reference/en/p5 copy/constants/POINTS.mdx | 18 - .../en/p5 copy/constants/PORTRAIT.mdx | 18 - .../en/p5 copy/constants/POSTERIZE.mdx | 18 - .../en/p5 copy/constants/PROJECT.mdx | 18 - .../en/p5 copy/constants/QUADRATIC.mdx | 18 - .../reference/en/p5 copy/constants/QUADS.mdx | 18 - .../en/p5 copy/constants/QUAD_STRIP.mdx | 18 - .../en/p5 copy/constants/QUARTER_PI.mdx | 109 --- .../en/p5 copy/constants/RADIANS.mdx | 66 -- .../reference/en/p5 copy/constants/RADIUS.mdx | 18 - .../reference/en/p5 copy/constants/REMOVE.mdx | 18 - .../reference/en/p5 copy/constants/REPEAT.mdx | 18 - .../en/p5 copy/constants/REPLACE.mdx | 18 - .../reference/en/p5 copy/constants/RETURN.mdx | 18 - .../reference/en/p5 copy/constants/RGB.mdx | 18 - .../reference/en/p5 copy/constants/RGBA.mdx | 18 - .../reference/en/p5 copy/constants/RIGHT.mdx | 18 - .../en/p5 copy/constants/RIGHT_ARROW.mdx | 18 - .../reference/en/p5 copy/constants/ROUND.mdx | 18 - .../reference/en/p5 copy/constants/SCREEN.mdx | 18 - .../reference/en/p5 copy/constants/SHIFT.mdx | 18 - .../reference/en/p5 copy/constants/SMOOTH.mdx | 18 - .../en/p5 copy/constants/SOFT_LIGHT.mdx | 18 - .../reference/en/p5 copy/constants/SQUARE.mdx | 18 - .../reference/en/p5 copy/constants/STROKE.mdx | 18 - .../en/p5 copy/constants/SUBTRACT.mdx | 18 - .../reference/en/p5 copy/constants/TAB.mdx | 18 - .../reference/en/p5 copy/constants/TAU.mdx | 114 --- .../reference/en/p5 copy/constants/TESS.mdx | 18 - .../reference/en/p5 copy/constants/TEXT.mdx | 18 - .../en/p5 copy/constants/TEXTURE.mdx | 18 - .../en/p5 copy/constants/THRESHOLD.mdx | 18 - .../reference/en/p5 copy/constants/TOP.mdx | 18 - .../en/p5 copy/constants/TRIANGLES.mdx | 18 - .../en/p5 copy/constants/TRIANGLE_FAN.mdx | 18 - .../en/p5 copy/constants/TRIANGLE_STRIP.mdx | 18 - .../reference/en/p5 copy/constants/TWO_PI.mdx | 114 --- .../en/p5 copy/constants/UNSIGNED_BYTE.mdx | 18 - .../en/p5 copy/constants/UNSIGNED_INT.mdx | 18 - .../en/p5 copy/constants/UP_ARROW.mdx | 18 - .../en/p5 copy/constants/VERSION.mdx | 19 - .../reference/en/p5 copy/constants/WAIT.mdx | 18 - .../reference/en/p5 copy/constants/WEBGL.mdx | 91 -- .../reference/en/p5 copy/constants/WEBGL2.mdx | 21 - .../reference/en/p5 copy/constants/WORD.mdx | 18 - .../reference/en/p5 copy/constrain.mdx | 86 -- src/content/reference/en/p5 copy/copy.mdx | 144 ---- src/content/reference/en/p5 copy/cos.mdx | 107 --- src/content/reference/en/p5 copy/createA.mdx | 93 -- .../reference/en/p5 copy/createAudio.mdx | 83 -- .../reference/en/p5 copy/createButton.mdx | 109 --- .../reference/en/p5 copy/createCamera.mdx | 99 --- .../reference/en/p5 copy/createCanvas.mdx | 191 ----- .../reference/en/p5 copy/createCapture.mdx | 189 ----- .../reference/en/p5 copy/createCheckbox.mdx | 131 --- .../en/p5 copy/createColorPicker.mdx | 101 --- .../reference/en/p5 copy/createConvolver.mdx | 78 -- .../reference/en/p5 copy/createDiv.mdx | 72 -- .../reference/en/p5 copy/createElement.mdx | 78 -- .../reference/en/p5 copy/createFileInput.mdx | 138 --- .../en/p5 copy/createFilterShader.mdx | 148 ---- .../en/p5 copy/createFramebuffer.mdx | 208 ----- .../reference/en/p5 copy/createGraphics.mdx | 191 ----- .../reference/en/p5 copy/createImage.mdx | 172 ---- .../reference/en/p5 copy/createImg.mdx | 115 --- .../reference/en/p5 copy/createInput.mdx | 118 --- .../reference/en/p5 copy/createModel.mdx | 193 ----- .../reference/en/p5 copy/createNumberDict.mdx | 57 -- src/content/reference/en/p5 copy/createP.mdx | 54 -- .../reference/en/p5 copy/createRadio.mdx | 223 ----- .../reference/en/p5 copy/createSelect.mdx | 235 ------ .../reference/en/p5 copy/createShader.mdx | 438 ---------- .../reference/en/p5 copy/createSlider.mdx | 162 ---- .../reference/en/p5 copy/createSpan.mdx | 93 -- .../reference/en/p5 copy/createStringDict.mdx | 56 -- .../reference/en/p5 copy/createVector.mdx | 133 --- .../reference/en/p5 copy/createVideo.mdx | 135 --- .../reference/en/p5 copy/createWriter.mdx | 146 ---- src/content/reference/en/p5 copy/cursor.mdx | 139 --- src/content/reference/en/p5 copy/curve.mdx | 272 ------ .../reference/en/p5 copy/curveDetail.mdx | 117 --- .../reference/en/p5 copy/curvePoint.mdx | 160 ---- .../reference/en/p5 copy/curveTangent.mdx | 153 ---- .../reference/en/p5 copy/curveTightness.mdx | 77 -- .../reference/en/p5 copy/curveVertex.mdx | 407 --------- src/content/reference/en/p5 copy/cylinder.mdx | 282 ------- src/content/reference/en/p5 copy/day.mdx | 47 -- .../reference/en/p5 copy/debugMode.mdx | 362 -------- src/content/reference/en/p5 copy/degrees.mdx | 53 -- .../reference/en/p5 copy/deltaTime.mdx | 68 -- src/content/reference/en/p5 copy/describe.mdx | 137 --- .../reference/en/p5 copy/describeElement.mdx | 127 --- .../reference/en/p5 copy/deviceMoved.mdx | 49 -- .../en/p5 copy/deviceOrientation.mdx | 22 - .../reference/en/p5 copy/deviceShaken.mdx | 50 -- .../reference/en/p5 copy/deviceTurned.mdx | 80 -- .../reference/en/p5 copy/directionalLight.mdx | 277 ------ .../en/p5 copy/disableFriendlyErrors.mdx | 55 -- .../reference/en/p5 copy/displayDensity.mdx | 55 -- .../reference/en/p5 copy/displayHeight.mdx | 47 -- .../reference/en/p5 copy/displayWidth.mdx | 47 -- src/content/reference/en/p5 copy/dist.mdx | 121 --- .../reference/en/p5 copy/doubleClicked.mdx | 157 ---- src/content/reference/en/p5 copy/draw.mdx | 129 --- .../reference/en/p5 copy/drawingContext.mdx | 78 -- src/content/reference/en/p5 copy/ellipse.mdx | 164 ---- .../reference/en/p5 copy/ellipseMode.mdx | 113 --- .../reference/en/p5 copy/ellipsoid.mdx | 233 ----- .../reference/en/p5 copy/emissiveMaterial.mdx | 140 ---- src/content/reference/en/p5 copy/endClip.mdx | 43 - .../reference/en/p5 copy/endContour.mdx | 133 --- .../reference/en/p5 copy/endGeometry.mdx | 285 ------- src/content/reference/en/p5 copy/endShape.mdx | 256 ------ src/content/reference/en/p5 copy/erase.mdx | 123 --- .../reference/en/p5 copy/exitPointerLock.mdx | 82 -- src/content/reference/en/p5 copy/exp.mdx | 83 -- src/content/reference/en/p5 copy/fill.mdx | 312 ------- src/content/reference/en/p5 copy/filter.mdx | 330 -------- src/content/reference/en/p5 copy/float.mdx | 116 --- src/content/reference/en/p5 copy/floor.mdx | 57 -- src/content/reference/en/p5 copy/focused.mdx | 50 -- src/content/reference/en/p5 copy/for.mdx | 290 ------- src/content/reference/en/p5 copy/fract.mdx | 55 -- .../reference/en/p5 copy/frameCount.mdx | 73 -- .../reference/en/p5 copy/frameRate.mdx | 107 --- .../reference/en/p5 copy/freeGeometry.mdx | 152 ---- .../reference/en/p5 copy/freqToMidi.mdx | 29 - src/content/reference/en/p5 copy/frustum.mdx | 175 ---- .../reference/en/p5 copy/fullscreen.mdx | 63 -- src/content/reference/en/p5 copy/function.mdx | 19 - src/content/reference/en/p5 copy/get.mdx | 178 ---- .../reference/en/p5 copy/getAudioContext.mdx | 56 -- src/content/reference/en/p5 copy/getItem.mdx | 151 ---- .../reference/en/p5 copy/getOutputVolume.mdx | 25 - .../en/p5 copy/getTargetFrameRate.mdx | 48 -- src/content/reference/en/p5 copy/getURL.mdx | 46 - .../reference/en/p5 copy/getURLParams.mdx | 59 -- .../reference/en/p5 copy/getURLPath.mdx | 58 -- src/content/reference/en/p5 copy/green.mdx | 159 ---- .../reference/en/p5 copy/gridOutput.mdx | 189 ----- src/content/reference/en/p5 copy/height.mdx | 87 -- src/content/reference/en/p5 copy/hex.mdx | 166 ---- src/content/reference/en/p5 copy/hour.mdx | 47 -- src/content/reference/en/p5 copy/httpDo.mdx | 150 ---- src/content/reference/en/p5 copy/httpGet.mdx | 140 ---- src/content/reference/en/p5 copy/httpPost.mdx | 165 ---- src/content/reference/en/p5 copy/hue.mdx | 145 ---- src/content/reference/en/p5 copy/if.mdx | 268 ------ src/content/reference/en/p5 copy/image.mdx | 327 -------- .../reference/en/p5 copy/imageLight.mdx | 86 -- .../reference/en/p5 copy/imageMode.mdx | 129 --- src/content/reference/en/p5 copy/input.mdx | 88 -- src/content/reference/en/p5 copy/int.mdx | 169 ---- .../reference/en/p5 copy/isLooping.mdx | 65 -- src/content/reference/en/p5 copy/join.mdx | 70 -- src/content/reference/en/p5 copy/key.mdx | 106 --- src/content/reference/en/p5 copy/keyCode.mdx | 128 --- .../reference/en/p5 copy/keyIsDown.mdx | 142 ---- .../reference/en/p5 copy/keyIsPressed.mdx | 105 --- .../reference/en/p5 copy/keyPressed.mdx | 192 ----- .../reference/en/p5 copy/keyReleased.mdx | 188 ----- src/content/reference/en/p5 copy/keyTyped.mdx | 170 ---- src/content/reference/en/p5 copy/lerp.mdx | 122 --- .../reference/en/p5 copy/lerpColor.mdx | 96 --- src/content/reference/en/p5 copy/let.mdx | 91 -- .../reference/en/p5 copy/lightFalloff.mdx | 100 --- .../reference/en/p5 copy/lightness.mdx | 168 ---- src/content/reference/en/p5 copy/lights.mdx | 88 -- src/content/reference/en/p5 copy/line.mdx | 194 ----- .../reference/en/p5 copy/linePerspective.mdx | 164 ---- .../reference/en/p5 copy/loadBytes.mdx | 56 -- src/content/reference/en/p5 copy/loadFont.mdx | 171 ---- .../reference/en/p5 copy/loadImage.mdx | 137 --- src/content/reference/en/p5 copy/loadJSON.mdx | 288 ------- .../reference/en/p5 copy/loadModel.mdx | 469 ----------- .../reference/en/p5 copy/loadPixels.mdx | 61 -- .../reference/en/p5 copy/loadShader.mdx | 172 ---- .../reference/en/p5 copy/loadSound.mdx | 78 -- .../reference/en/p5 copy/loadStrings.mdx | 188 ----- .../reference/en/p5 copy/loadTable.mdx | 124 --- src/content/reference/en/p5 copy/loadXML.mdx | 220 ----- src/content/reference/en/p5 copy/log.mdx | 79 -- src/content/reference/en/p5 copy/loop.mdx | 111 --- src/content/reference/en/p5 copy/mag.mdx | 84 -- src/content/reference/en/p5 copy/map.mdx | 119 --- src/content/reference/en/p5 copy/match.mdx | 91 -- src/content/reference/en/p5 copy/matchAll.mdx | 107 --- src/content/reference/en/p5 copy/max.mdx | 104 --- .../reference/en/p5 copy/metalness.mdx | 142 ---- .../reference/en/p5 copy/midiToFreq.mdx | 66 -- src/content/reference/en/p5 copy/millis.mdx | 147 ---- src/content/reference/en/p5 copy/min.mdx | 104 --- src/content/reference/en/p5 copy/minute.mdx | 47 -- src/content/reference/en/p5 copy/model.mdx | 155 ---- src/content/reference/en/p5 copy/month.mdx | 47 -- .../reference/en/p5 copy/mouseButton.mdx | 87 -- .../reference/en/p5 copy/mouseClicked.mdx | 196 ----- .../reference/en/p5 copy/mouseDragged.mdx | 130 --- .../reference/en/p5 copy/mouseIsPressed.mdx | 73 -- .../reference/en/p5 copy/mouseMoved.mdx | 118 --- .../reference/en/p5 copy/mousePressed.mdx | 193 ----- .../reference/en/p5 copy/mouseReleased.mdx | 195 ----- .../reference/en/p5 copy/mouseWheel.mdx | 162 ---- src/content/reference/en/p5 copy/mouseX.mdx | 124 --- src/content/reference/en/p5 copy/mouseY.mdx | 124 --- src/content/reference/en/p5 copy/movedX.mdx | 78 -- src/content/reference/en/p5 copy/movedY.mdx | 78 -- src/content/reference/en/p5 copy/nf.mdx | 159 ---- src/content/reference/en/p5 copy/nfc.mdx | 153 ---- src/content/reference/en/p5 copy/nfp.mdx | 188 ----- src/content/reference/en/p5 copy/nfs.mdx | 176 ---- src/content/reference/en/p5 copy/noCanvas.mdx | 36 - src/content/reference/en/p5 copy/noCursor.mdx | 38 - .../reference/en/p5 copy/noDebugMode.mdx | 54 -- src/content/reference/en/p5 copy/noErase.mdx | 55 -- src/content/reference/en/p5 copy/noFill.mdx | 73 -- src/content/reference/en/p5 copy/noLights.mdx | 79 -- src/content/reference/en/p5 copy/noLoop.mdx | 139 --- src/content/reference/en/p5 copy/noSmooth.mdx | 92 -- src/content/reference/en/p5 copy/noStroke.mdx | 71 -- src/content/reference/en/p5 copy/noTint.mdx | 51 -- src/content/reference/en/p5 copy/noise.mdx | 282 ------- .../reference/en/p5 copy/noiseDetail.mdx | 100 --- .../reference/en/p5 copy/noiseSeed.mdx | 68 -- src/content/reference/en/p5 copy/norm.mdx | 69 -- src/content/reference/en/p5 copy/normal.mdx | 250 ------ .../reference/en/p5 copy/normalMaterial.mdx | 55 -- .../reference/en/p5 copy/orbitControl.mdx | 203 ----- src/content/reference/en/p5 copy/ortho.mdx | 168 ---- .../reference/en/p5 copy/outputVolume.mdx | 51 -- .../reference/en/p5 copy/p5.Camera.mdx | 659 --------------- src/content/reference/en/p5 copy/p5.Color.mdx | 116 --- .../reference/en/p5 copy/p5.Element.mdx | 545 ------------ src/content/reference/en/p5 copy/p5.File.mdx | 153 ---- src/content/reference/en/p5 copy/p5.Font.mdx | 146 ---- .../reference/en/p5 copy/p5.Framebuffer.mdx | 443 ---------- .../reference/en/p5 copy/p5.Geometry.mdx | 793 ------------------ .../reference/en/p5 copy/p5.Graphics.mdx | 261 ------ src/content/reference/en/p5 copy/p5.Image.mdx | 519 ------------ .../reference/en/p5 copy/p5.MediaElement.mdx | 258 ------ .../reference/en/p5 copy/p5.NumberDict.mdx | 63 -- .../reference/en/p5 copy/p5.PrintWriter.mdx | 35 - .../reference/en/p5 copy/p5.Renderer.mdx | 34 - .../reference/en/p5 copy/p5.Shader.mdx | 433 ---------- .../reference/en/p5 copy/p5.StringDict.mdx | 15 - src/content/reference/en/p5 copy/p5.Table.mdx | 213 ----- .../reference/en/p5 copy/p5.TableRow.mdx | 66 -- .../reference/en/p5 copy/p5.TypedDict.mdx | 66 -- .../reference/en/p5 copy/p5.Vector.mdx | 673 --------------- src/content/reference/en/p5 copy/p5.XML.mdx | 321 ------- src/content/reference/en/p5 copy/p5.mdx | 51 -- .../reference/en/p5 copy/pAccelerationX.mdx | 21 - .../reference/en/p5 copy/pAccelerationY.mdx | 21 - .../reference/en/p5 copy/pAccelerationZ.mdx | 21 - .../reference/en/p5 copy/pRotationX.mdx | 63 -- .../reference/en/p5 copy/pRotationY.mdx | 62 -- .../reference/en/p5 copy/pRotationZ.mdx | 58 -- .../reference/en/p5 copy/paletteLerp.mdx | 66 -- src/content/reference/en/p5 copy/panorama.mdx | 76 -- .../reference/en/p5 copy/perspective.mdx | 194 ----- .../reference/en/p5 copy/pixelDensity.mdx | 90 -- src/content/reference/en/p5 copy/pixels.mdx | 173 ---- src/content/reference/en/p5 copy/plane.mdx | 152 ---- src/content/reference/en/p5 copy/pmouseX.mdx | 88 -- src/content/reference/en/p5 copy/pmouseY.mdx | 88 -- src/content/reference/en/p5 copy/point.mdx | 229 ----- .../reference/en/p5 copy/pointLight.mdx | 329 -------- src/content/reference/en/p5 copy/pop.mdx | 20 - src/content/reference/en/p5 copy/pow.mdx | 67 -- src/content/reference/en/p5 copy/preload.mdx | 70 -- src/content/reference/en/p5 copy/print.mdx | 55 -- src/content/reference/en/p5 copy/push.mdx | 20 - .../reference/en/p5 copy/pwinMouseX.mdx | 99 --- .../reference/en/p5 copy/pwinMouseY.mdx | 99 --- src/content/reference/en/p5 copy/quad.mdx | 233 ----- .../reference/en/p5 copy/quadraticVertex.mdx | 303 ------- src/content/reference/en/p5 copy/radians.mdx | 53 -- src/content/reference/en/p5 copy/random.mdx | 48 -- .../reference/en/p5 copy/randomGaussian.mdx | 104 --- .../reference/en/p5 copy/randomSeed.mdx | 71 -- src/content/reference/en/p5 copy/rect.mdx | 209 ----- src/content/reference/en/p5 copy/rectMode.mdx | 142 ---- src/content/reference/en/p5 copy/red.mdx | 158 ---- src/content/reference/en/p5 copy/redraw.mdx | 117 --- src/content/reference/en/p5 copy/remove.mdx | 57 -- .../reference/en/p5 copy/removeElements.mdx | 85 -- .../reference/en/p5 copy/removeItem.mdx | 97 --- .../en/p5 copy/requestPointerLock.mdx | 85 -- .../reference/en/p5 copy/resetMatrix.mdx | 52 -- .../reference/en/p5 copy/resetShader.mdx | 95 --- .../reference/en/p5 copy/resizeCanvas.mdx | 133 --- src/content/reference/en/p5 copy/reverse.mdx | 43 - src/content/reference/en/p5 copy/rotate.mdx | 226 ----- src/content/reference/en/p5 copy/rotateX.mdx | 161 ---- src/content/reference/en/p5 copy/rotateY.mdx | 161 ---- src/content/reference/en/p5 copy/rotateZ.mdx | 161 ---- .../reference/en/p5 copy/rotationX.mdx | 45 - .../reference/en/p5 copy/rotationY.mdx | 45 - .../reference/en/p5 copy/rotationZ.mdx | 47 -- src/content/reference/en/p5 copy/round.mdx | 88 -- .../reference/en/p5 copy/sampleRate.mdx | 26 - .../reference/en/p5 copy/saturation.mdx | 201 ----- src/content/reference/en/p5 copy/save.mdx | 140 ---- .../reference/en/p5 copy/saveCanvas.mdx | 166 ---- .../reference/en/p5 copy/saveFrames.mdx | 175 ---- src/content/reference/en/p5 copy/saveGif.mdx | 119 --- src/content/reference/en/p5 copy/saveJSON.mdx | 170 ---- .../reference/en/p5 copy/saveSound.mdx | 35 - .../reference/en/p5 copy/saveStrings.mdx | 185 ---- .../reference/en/p5 copy/saveTable.mdx | 70 -- src/content/reference/en/p5 copy/scale.mdx | 231 ----- src/content/reference/en/p5 copy/second.mdx | 47 -- src/content/reference/en/p5 copy/select.mdx | 113 --- .../reference/en/p5 copy/selectAll.mdx | 121 --- src/content/reference/en/p5 copy/set.mdx | 157 ---- .../reference/en/p5 copy/setAttributes.mdx | 163 ---- src/content/reference/en/p5 copy/setBPM.mdx | 29 - .../reference/en/p5 copy/setCamera.mdx | 81 -- .../reference/en/p5 copy/setMoveThreshold.mdx | 59 -- .../en/p5 copy/setShakeThreshold.mdx | 59 -- src/content/reference/en/p5 copy/setup.mdx | 111 --- src/content/reference/en/p5 copy/shader.mdx | 244 ------ src/content/reference/en/p5 copy/shearX.mdx | 105 --- src/content/reference/en/p5 copy/shearY.mdx | 105 --- .../reference/en/p5 copy/shininess.mdx | 86 -- src/content/reference/en/p5 copy/shorten.mdx | 44 - src/content/reference/en/p5 copy/shuffle.mdx | 132 --- src/content/reference/en/p5 copy/sin.mdx | 107 --- src/content/reference/en/p5 copy/smooth.mdx | 94 --- src/content/reference/en/p5 copy/sort.mdx | 63 -- .../reference/en/p5 copy/soundFormats.mdx | 51 -- src/content/reference/en/p5 copy/soundOut.mdx | 26 - .../reference/en/p5 copy/specularColor.mdx | 308 ------- .../reference/en/p5 copy/specularMaterial.mdx | 311 ------- src/content/reference/en/p5 copy/sphere.mdx | 165 ---- src/content/reference/en/p5 copy/splice.mdx | 58 -- src/content/reference/en/p5 copy/split.mdx | 87 -- .../reference/en/p5 copy/splitTokens.mdx | 180 ---- .../reference/en/p5 copy/spotLight.mdx | 398 --------- src/content/reference/en/p5 copy/sq.mdx | 83 -- src/content/reference/en/p5 copy/sqrt.mdx | 84 -- src/content/reference/en/p5 copy/square.mdx | 163 ---- .../reference/en/p5 copy/storeItem.mdx | 149 ---- src/content/reference/en/p5 copy/str.mdx | 135 --- src/content/reference/en/p5 copy/stroke.mdx | 311 ------- .../reference/en/p5 copy/strokeCap.mdx | 67 -- .../reference/en/p5 copy/strokeJoin.mdx | 114 --- .../reference/en/p5 copy/strokeWeight.mdx | 77 -- src/content/reference/en/p5 copy/subset.mdx | 59 -- src/content/reference/en/p5 copy/tan.mdx | 66 -- src/content/reference/en/p5 copy/text.mdx | 96 --- .../reference/en/p5 copy/textAlign.mdx | 135 --- .../reference/en/p5 copy/textAscent.mdx | 71 -- .../reference/en/p5 copy/textDescent.mdx | 71 -- src/content/reference/en/p5 copy/textFont.mdx | 127 --- .../reference/en/p5 copy/textLeading.mdx | 63 -- .../reference/en/p5 copy/textOutput.mdx | 186 ---- src/content/reference/en/p5 copy/textSize.mdx | 65 -- .../reference/en/p5 copy/textStyle.mdx | 79 -- .../reference/en/p5 copy/textWidth.mdx | 83 -- src/content/reference/en/p5 copy/textWrap.mdx | 111 --- src/content/reference/en/p5 copy/texture.mdx | 207 ----- .../reference/en/p5 copy/textureMode.mdx | 254 ------ .../reference/en/p5 copy/textureWrap.mdx | 370 -------- src/content/reference/en/p5 copy/tint.mdx | 201 ----- src/content/reference/en/p5 copy/torus.mdx | 200 ----- .../reference/en/p5 copy/touchEnded.mdx | 196 ----- .../reference/en/p5 copy/touchMoved.mdx | 198 ----- .../reference/en/p5 copy/touchStarted.mdx | 197 ----- src/content/reference/en/p5 copy/touches.mdx | 102 --- .../reference/en/p5 copy/translate.mdx | 241 ------ src/content/reference/en/p5 copy/triangle.mdx | 104 --- src/content/reference/en/p5 copy/trim.mdx | 113 --- src/content/reference/en/p5 copy/turnAxis.mdx | 54 -- .../reference/en/p5 copy/types/Array.mdx | 269 ------ .../reference/en/p5 copy/types/Boolean.mdx | 273 ------ .../reference/en/p5 copy/types/Number.mdx | 201 ----- .../reference/en/p5 copy/types/Object.mdx | 91 -- .../reference/en/p5 copy/types/String.mdx | 153 ---- src/content/reference/en/p5 copy/unchar.mdx | 114 --- src/content/reference/en/p5 copy/unhex.mdx | 121 --- .../reference/en/p5 copy/updatePixels.mdx | 94 --- .../reference/en/p5 copy/userStartAudio.mdx | 99 --- src/content/reference/en/p5 copy/vertex.mdx | 242 ------ .../reference/en/p5 copy/webglVersion.mdx | 105 --- src/content/reference/en/p5 copy/while.mdx | 161 ---- src/content/reference/en/p5 copy/width.mdx | 87 -- .../reference/en/p5 copy/winMouseX.mdx | 61 -- .../reference/en/p5 copy/winMouseY.mdx | 61 -- .../reference/en/p5 copy/windowHeight.mdx | 43 - .../reference/en/p5 copy/windowResized.mdx | 64 -- .../reference/en/p5 copy/windowWidth.mdx | 43 - src/content/reference/en/p5 copy/year.mdx | 47 -- 524 files changed, 22 insertions(+), 60145 deletions(-) delete mode 100644 src/content/reference/en/p5 copy/abs.mdx delete mode 100644 src/content/reference/en/p5 copy/accelerationX.mdx delete mode 100644 src/content/reference/en/p5 copy/accelerationY.mdx delete mode 100644 src/content/reference/en/p5 copy/accelerationZ.mdx delete mode 100644 src/content/reference/en/p5 copy/acos.mdx delete mode 100644 src/content/reference/en/p5 copy/alpha.mdx delete mode 100644 src/content/reference/en/p5 copy/ambientLight.mdx delete mode 100644 src/content/reference/en/p5 copy/ambientMaterial.mdx delete mode 100644 src/content/reference/en/p5 copy/angleMode.mdx delete mode 100644 src/content/reference/en/p5 copy/append.mdx delete mode 100644 src/content/reference/en/p5 copy/applyMatrix.mdx delete mode 100644 src/content/reference/en/p5 copy/arc.mdx delete mode 100644 src/content/reference/en/p5 copy/arrayCopy.mdx delete mode 100644 src/content/reference/en/p5 copy/asin.mdx delete mode 100644 src/content/reference/en/p5 copy/atan.mdx delete mode 100644 src/content/reference/en/p5 copy/atan2.mdx delete mode 100644 src/content/reference/en/p5 copy/background.mdx delete mode 100644 src/content/reference/en/p5 copy/baseColorShader.mdx delete mode 100644 src/content/reference/en/p5 copy/baseMaterialShader.mdx delete mode 100644 src/content/reference/en/p5 copy/baseNormalShader.mdx delete mode 100644 src/content/reference/en/p5 copy/baseStrokeShader.mdx delete mode 100644 src/content/reference/en/p5 copy/beginClip.mdx delete mode 100644 src/content/reference/en/p5 copy/beginContour.mdx delete mode 100644 src/content/reference/en/p5 copy/beginGeometry.mdx delete mode 100644 src/content/reference/en/p5 copy/beginShape.mdx delete mode 100644 src/content/reference/en/p5 copy/bezier.mdx delete mode 100644 src/content/reference/en/p5 copy/bezierDetail.mdx delete mode 100644 src/content/reference/en/p5 copy/bezierPoint.mdx delete mode 100644 src/content/reference/en/p5 copy/bezierTangent.mdx delete mode 100644 src/content/reference/en/p5 copy/bezierVertex.mdx delete mode 100644 src/content/reference/en/p5 copy/blend.mdx delete mode 100644 src/content/reference/en/p5 copy/blendMode.mdx delete mode 100644 src/content/reference/en/p5 copy/blue.mdx delete mode 100644 src/content/reference/en/p5 copy/boolean.mdx delete mode 100644 src/content/reference/en/p5 copy/box.mdx delete mode 100644 src/content/reference/en/p5 copy/brightness.mdx delete mode 100644 src/content/reference/en/p5 copy/buildGeometry.mdx delete mode 100644 src/content/reference/en/p5 copy/byte.mdx delete mode 100644 src/content/reference/en/p5 copy/camera.mdx delete mode 100644 src/content/reference/en/p5 copy/ceil.mdx delete mode 100644 src/content/reference/en/p5 copy/changed.mdx delete mode 100644 src/content/reference/en/p5 copy/char.mdx delete mode 100644 src/content/reference/en/p5 copy/circle.mdx delete mode 100644 src/content/reference/en/p5 copy/class.mdx delete mode 100644 src/content/reference/en/p5 copy/clear.mdx delete mode 100644 src/content/reference/en/p5 copy/clearDepth.mdx delete mode 100644 src/content/reference/en/p5 copy/clearStorage.mdx delete mode 100644 src/content/reference/en/p5 copy/clip.mdx delete mode 100644 src/content/reference/en/p5 copy/color.mdx delete mode 100644 src/content/reference/en/p5 copy/colorMode.mdx delete mode 100644 src/content/reference/en/p5 copy/concat.mdx delete mode 100644 src/content/reference/en/p5 copy/cone.mdx delete mode 100644 src/content/reference/en/p5 copy/console.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/ADD.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/ALT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/ARROW.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/AUTO.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/AXES.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/BACKSPACE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/BASELINE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/BEVEL.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/BEZIER.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/BLEND.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/BLUR.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/BOLD.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/BOLDITALIC.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/BOTTOM.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/BURN.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/CENTER.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/CHAR.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/CHORD.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/CLAMP.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/CLOSE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/CONTAIN.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/CONTROL.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/CORNER.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/CORNERS.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/COVER.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/CROSS.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/CURVE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/DARKEST.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/DEGREES.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/DELETE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/DIFFERENCE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/DILATE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/DODGE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/DOWN_ARROW.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/ENTER.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/ERODE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/ESCAPE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/EXCLUSION.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/FALLBACK.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/FILL.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/FLAT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/FLOAT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/GRAY.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/GRID.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/HALF_FLOAT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/HALF_PI.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/HAND.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/HARD_LIGHT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/HSB.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/HSL.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/IMAGE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/IMMEDIATE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/INVERT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/ITALIC.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/LABEL.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/LANDSCAPE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/LEFT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/LEFT_ARROW.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/LIGHTEST.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/LINEAR.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/LINES.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/LINE_LOOP.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/LINE_STRIP.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/MIRROR.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/MITER.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/MOVE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/MULTIPLY.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/NEAREST.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/NORMAL.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/OPAQUE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/OPEN.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/OPTION.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/OVERLAY.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/P2D.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/PI.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/PIE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/POINTS.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/PORTRAIT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/POSTERIZE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/PROJECT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/QUADRATIC.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/QUADS.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/QUAD_STRIP.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/QUARTER_PI.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/RADIANS.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/RADIUS.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/REMOVE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/REPEAT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/REPLACE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/RETURN.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/RGB.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/RGBA.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/RIGHT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/RIGHT_ARROW.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/ROUND.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/SCREEN.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/SHIFT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/SMOOTH.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/SOFT_LIGHT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/SQUARE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/STROKE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/SUBTRACT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/TAB.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/TAU.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/TESS.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/TEXT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/TEXTURE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/THRESHOLD.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/TOP.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/TRIANGLES.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/TRIANGLE_FAN.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/TRIANGLE_STRIP.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/TWO_PI.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/UNSIGNED_BYTE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/UNSIGNED_INT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/UP_ARROW.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/VERSION.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/WAIT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/WEBGL.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/WEBGL2.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/WORD.mdx delete mode 100644 src/content/reference/en/p5 copy/constrain.mdx delete mode 100644 src/content/reference/en/p5 copy/copy.mdx delete mode 100644 src/content/reference/en/p5 copy/cos.mdx delete mode 100644 src/content/reference/en/p5 copy/createA.mdx delete mode 100644 src/content/reference/en/p5 copy/createAudio.mdx delete mode 100644 src/content/reference/en/p5 copy/createButton.mdx delete mode 100644 src/content/reference/en/p5 copy/createCamera.mdx delete mode 100644 src/content/reference/en/p5 copy/createCanvas.mdx delete mode 100644 src/content/reference/en/p5 copy/createCapture.mdx delete mode 100644 src/content/reference/en/p5 copy/createCheckbox.mdx delete mode 100644 src/content/reference/en/p5 copy/createColorPicker.mdx delete mode 100644 src/content/reference/en/p5 copy/createConvolver.mdx delete mode 100644 src/content/reference/en/p5 copy/createDiv.mdx delete mode 100644 src/content/reference/en/p5 copy/createElement.mdx delete mode 100644 src/content/reference/en/p5 copy/createFileInput.mdx delete mode 100644 src/content/reference/en/p5 copy/createFilterShader.mdx delete mode 100644 src/content/reference/en/p5 copy/createFramebuffer.mdx delete mode 100644 src/content/reference/en/p5 copy/createGraphics.mdx delete mode 100644 src/content/reference/en/p5 copy/createImage.mdx delete mode 100644 src/content/reference/en/p5 copy/createImg.mdx delete mode 100644 src/content/reference/en/p5 copy/createInput.mdx delete mode 100644 src/content/reference/en/p5 copy/createModel.mdx delete mode 100644 src/content/reference/en/p5 copy/createNumberDict.mdx delete mode 100644 src/content/reference/en/p5 copy/createP.mdx delete mode 100644 src/content/reference/en/p5 copy/createRadio.mdx delete mode 100644 src/content/reference/en/p5 copy/createSelect.mdx delete mode 100644 src/content/reference/en/p5 copy/createShader.mdx delete mode 100644 src/content/reference/en/p5 copy/createSlider.mdx delete mode 100644 src/content/reference/en/p5 copy/createSpan.mdx delete mode 100644 src/content/reference/en/p5 copy/createStringDict.mdx delete mode 100644 src/content/reference/en/p5 copy/createVector.mdx delete mode 100644 src/content/reference/en/p5 copy/createVideo.mdx delete mode 100644 src/content/reference/en/p5 copy/createWriter.mdx delete mode 100644 src/content/reference/en/p5 copy/cursor.mdx delete mode 100644 src/content/reference/en/p5 copy/curve.mdx delete mode 100644 src/content/reference/en/p5 copy/curveDetail.mdx delete mode 100644 src/content/reference/en/p5 copy/curvePoint.mdx delete mode 100644 src/content/reference/en/p5 copy/curveTangent.mdx delete mode 100644 src/content/reference/en/p5 copy/curveTightness.mdx delete mode 100644 src/content/reference/en/p5 copy/curveVertex.mdx delete mode 100644 src/content/reference/en/p5 copy/cylinder.mdx delete mode 100644 src/content/reference/en/p5 copy/day.mdx delete mode 100644 src/content/reference/en/p5 copy/debugMode.mdx delete mode 100644 src/content/reference/en/p5 copy/degrees.mdx delete mode 100644 src/content/reference/en/p5 copy/deltaTime.mdx delete mode 100644 src/content/reference/en/p5 copy/describe.mdx delete mode 100644 src/content/reference/en/p5 copy/describeElement.mdx delete mode 100644 src/content/reference/en/p5 copy/deviceMoved.mdx delete mode 100644 src/content/reference/en/p5 copy/deviceOrientation.mdx delete mode 100644 src/content/reference/en/p5 copy/deviceShaken.mdx delete mode 100644 src/content/reference/en/p5 copy/deviceTurned.mdx delete mode 100644 src/content/reference/en/p5 copy/directionalLight.mdx delete mode 100644 src/content/reference/en/p5 copy/disableFriendlyErrors.mdx delete mode 100644 src/content/reference/en/p5 copy/displayDensity.mdx delete mode 100644 src/content/reference/en/p5 copy/displayHeight.mdx delete mode 100644 src/content/reference/en/p5 copy/displayWidth.mdx delete mode 100644 src/content/reference/en/p5 copy/dist.mdx delete mode 100644 src/content/reference/en/p5 copy/doubleClicked.mdx delete mode 100644 src/content/reference/en/p5 copy/draw.mdx delete mode 100644 src/content/reference/en/p5 copy/drawingContext.mdx delete mode 100644 src/content/reference/en/p5 copy/ellipse.mdx delete mode 100644 src/content/reference/en/p5 copy/ellipseMode.mdx delete mode 100644 src/content/reference/en/p5 copy/ellipsoid.mdx delete mode 100644 src/content/reference/en/p5 copy/emissiveMaterial.mdx delete mode 100644 src/content/reference/en/p5 copy/endClip.mdx delete mode 100644 src/content/reference/en/p5 copy/endContour.mdx delete mode 100644 src/content/reference/en/p5 copy/endGeometry.mdx delete mode 100644 src/content/reference/en/p5 copy/endShape.mdx delete mode 100644 src/content/reference/en/p5 copy/erase.mdx delete mode 100644 src/content/reference/en/p5 copy/exitPointerLock.mdx delete mode 100644 src/content/reference/en/p5 copy/exp.mdx delete mode 100644 src/content/reference/en/p5 copy/fill.mdx delete mode 100644 src/content/reference/en/p5 copy/filter.mdx delete mode 100644 src/content/reference/en/p5 copy/float.mdx delete mode 100644 src/content/reference/en/p5 copy/floor.mdx delete mode 100644 src/content/reference/en/p5 copy/focused.mdx delete mode 100644 src/content/reference/en/p5 copy/for.mdx delete mode 100644 src/content/reference/en/p5 copy/fract.mdx delete mode 100644 src/content/reference/en/p5 copy/frameCount.mdx delete mode 100644 src/content/reference/en/p5 copy/frameRate.mdx delete mode 100644 src/content/reference/en/p5 copy/freeGeometry.mdx delete mode 100644 src/content/reference/en/p5 copy/freqToMidi.mdx delete mode 100644 src/content/reference/en/p5 copy/frustum.mdx delete mode 100644 src/content/reference/en/p5 copy/fullscreen.mdx delete mode 100644 src/content/reference/en/p5 copy/function.mdx delete mode 100644 src/content/reference/en/p5 copy/get.mdx delete mode 100644 src/content/reference/en/p5 copy/getAudioContext.mdx delete mode 100644 src/content/reference/en/p5 copy/getItem.mdx delete mode 100644 src/content/reference/en/p5 copy/getOutputVolume.mdx delete mode 100644 src/content/reference/en/p5 copy/getTargetFrameRate.mdx delete mode 100644 src/content/reference/en/p5 copy/getURL.mdx delete mode 100644 src/content/reference/en/p5 copy/getURLParams.mdx delete mode 100644 src/content/reference/en/p5 copy/getURLPath.mdx delete mode 100644 src/content/reference/en/p5 copy/green.mdx delete mode 100644 src/content/reference/en/p5 copy/gridOutput.mdx delete mode 100644 src/content/reference/en/p5 copy/height.mdx delete mode 100644 src/content/reference/en/p5 copy/hex.mdx delete mode 100644 src/content/reference/en/p5 copy/hour.mdx delete mode 100644 src/content/reference/en/p5 copy/httpDo.mdx delete mode 100644 src/content/reference/en/p5 copy/httpGet.mdx delete mode 100644 src/content/reference/en/p5 copy/httpPost.mdx delete mode 100644 src/content/reference/en/p5 copy/hue.mdx delete mode 100644 src/content/reference/en/p5 copy/if.mdx delete mode 100644 src/content/reference/en/p5 copy/image.mdx delete mode 100644 src/content/reference/en/p5 copy/imageLight.mdx delete mode 100644 src/content/reference/en/p5 copy/imageMode.mdx delete mode 100644 src/content/reference/en/p5 copy/input.mdx delete mode 100644 src/content/reference/en/p5 copy/int.mdx delete mode 100644 src/content/reference/en/p5 copy/isLooping.mdx delete mode 100644 src/content/reference/en/p5 copy/join.mdx delete mode 100644 src/content/reference/en/p5 copy/key.mdx delete mode 100644 src/content/reference/en/p5 copy/keyCode.mdx delete mode 100644 src/content/reference/en/p5 copy/keyIsDown.mdx delete mode 100644 src/content/reference/en/p5 copy/keyIsPressed.mdx delete mode 100644 src/content/reference/en/p5 copy/keyPressed.mdx delete mode 100644 src/content/reference/en/p5 copy/keyReleased.mdx delete mode 100644 src/content/reference/en/p5 copy/keyTyped.mdx delete mode 100644 src/content/reference/en/p5 copy/lerp.mdx delete mode 100644 src/content/reference/en/p5 copy/lerpColor.mdx delete mode 100644 src/content/reference/en/p5 copy/let.mdx delete mode 100644 src/content/reference/en/p5 copy/lightFalloff.mdx delete mode 100644 src/content/reference/en/p5 copy/lightness.mdx delete mode 100644 src/content/reference/en/p5 copy/lights.mdx delete mode 100644 src/content/reference/en/p5 copy/line.mdx delete mode 100644 src/content/reference/en/p5 copy/linePerspective.mdx delete mode 100644 src/content/reference/en/p5 copy/loadBytes.mdx delete mode 100644 src/content/reference/en/p5 copy/loadFont.mdx delete mode 100644 src/content/reference/en/p5 copy/loadImage.mdx delete mode 100644 src/content/reference/en/p5 copy/loadJSON.mdx delete mode 100644 src/content/reference/en/p5 copy/loadModel.mdx delete mode 100644 src/content/reference/en/p5 copy/loadPixels.mdx delete mode 100644 src/content/reference/en/p5 copy/loadShader.mdx delete mode 100644 src/content/reference/en/p5 copy/loadSound.mdx delete mode 100644 src/content/reference/en/p5 copy/loadStrings.mdx delete mode 100644 src/content/reference/en/p5 copy/loadTable.mdx delete mode 100644 src/content/reference/en/p5 copy/loadXML.mdx delete mode 100644 src/content/reference/en/p5 copy/log.mdx delete mode 100644 src/content/reference/en/p5 copy/loop.mdx delete mode 100644 src/content/reference/en/p5 copy/mag.mdx delete mode 100644 src/content/reference/en/p5 copy/map.mdx delete mode 100644 src/content/reference/en/p5 copy/match.mdx delete mode 100644 src/content/reference/en/p5 copy/matchAll.mdx delete mode 100644 src/content/reference/en/p5 copy/max.mdx delete mode 100644 src/content/reference/en/p5 copy/metalness.mdx delete mode 100644 src/content/reference/en/p5 copy/midiToFreq.mdx delete mode 100644 src/content/reference/en/p5 copy/millis.mdx delete mode 100644 src/content/reference/en/p5 copy/min.mdx delete mode 100644 src/content/reference/en/p5 copy/minute.mdx delete mode 100644 src/content/reference/en/p5 copy/model.mdx delete mode 100644 src/content/reference/en/p5 copy/month.mdx delete mode 100644 src/content/reference/en/p5 copy/mouseButton.mdx delete mode 100644 src/content/reference/en/p5 copy/mouseClicked.mdx delete mode 100644 src/content/reference/en/p5 copy/mouseDragged.mdx delete mode 100644 src/content/reference/en/p5 copy/mouseIsPressed.mdx delete mode 100644 src/content/reference/en/p5 copy/mouseMoved.mdx delete mode 100644 src/content/reference/en/p5 copy/mousePressed.mdx delete mode 100644 src/content/reference/en/p5 copy/mouseReleased.mdx delete mode 100644 src/content/reference/en/p5 copy/mouseWheel.mdx delete mode 100644 src/content/reference/en/p5 copy/mouseX.mdx delete mode 100644 src/content/reference/en/p5 copy/mouseY.mdx delete mode 100644 src/content/reference/en/p5 copy/movedX.mdx delete mode 100644 src/content/reference/en/p5 copy/movedY.mdx delete mode 100644 src/content/reference/en/p5 copy/nf.mdx delete mode 100644 src/content/reference/en/p5 copy/nfc.mdx delete mode 100644 src/content/reference/en/p5 copy/nfp.mdx delete mode 100644 src/content/reference/en/p5 copy/nfs.mdx delete mode 100644 src/content/reference/en/p5 copy/noCanvas.mdx delete mode 100644 src/content/reference/en/p5 copy/noCursor.mdx delete mode 100644 src/content/reference/en/p5 copy/noDebugMode.mdx delete mode 100644 src/content/reference/en/p5 copy/noErase.mdx delete mode 100644 src/content/reference/en/p5 copy/noFill.mdx delete mode 100644 src/content/reference/en/p5 copy/noLights.mdx delete mode 100644 src/content/reference/en/p5 copy/noLoop.mdx delete mode 100644 src/content/reference/en/p5 copy/noSmooth.mdx delete mode 100644 src/content/reference/en/p5 copy/noStroke.mdx delete mode 100644 src/content/reference/en/p5 copy/noTint.mdx delete mode 100644 src/content/reference/en/p5 copy/noise.mdx delete mode 100644 src/content/reference/en/p5 copy/noiseDetail.mdx delete mode 100644 src/content/reference/en/p5 copy/noiseSeed.mdx delete mode 100644 src/content/reference/en/p5 copy/norm.mdx delete mode 100644 src/content/reference/en/p5 copy/normal.mdx delete mode 100644 src/content/reference/en/p5 copy/normalMaterial.mdx delete mode 100644 src/content/reference/en/p5 copy/orbitControl.mdx delete mode 100644 src/content/reference/en/p5 copy/ortho.mdx delete mode 100644 src/content/reference/en/p5 copy/outputVolume.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Camera.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Color.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Element.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.File.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Font.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Framebuffer.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Geometry.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Graphics.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Image.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.MediaElement.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.NumberDict.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.PrintWriter.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Renderer.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Shader.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.StringDict.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Table.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.TableRow.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.TypedDict.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Vector.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.XML.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.mdx delete mode 100644 src/content/reference/en/p5 copy/pAccelerationX.mdx delete mode 100644 src/content/reference/en/p5 copy/pAccelerationY.mdx delete mode 100644 src/content/reference/en/p5 copy/pAccelerationZ.mdx delete mode 100644 src/content/reference/en/p5 copy/pRotationX.mdx delete mode 100644 src/content/reference/en/p5 copy/pRotationY.mdx delete mode 100644 src/content/reference/en/p5 copy/pRotationZ.mdx delete mode 100644 src/content/reference/en/p5 copy/paletteLerp.mdx delete mode 100644 src/content/reference/en/p5 copy/panorama.mdx delete mode 100644 src/content/reference/en/p5 copy/perspective.mdx delete mode 100644 src/content/reference/en/p5 copy/pixelDensity.mdx delete mode 100644 src/content/reference/en/p5 copy/pixels.mdx delete mode 100644 src/content/reference/en/p5 copy/plane.mdx delete mode 100644 src/content/reference/en/p5 copy/pmouseX.mdx delete mode 100644 src/content/reference/en/p5 copy/pmouseY.mdx delete mode 100644 src/content/reference/en/p5 copy/point.mdx delete mode 100644 src/content/reference/en/p5 copy/pointLight.mdx delete mode 100644 src/content/reference/en/p5 copy/pop.mdx delete mode 100644 src/content/reference/en/p5 copy/pow.mdx delete mode 100644 src/content/reference/en/p5 copy/preload.mdx delete mode 100644 src/content/reference/en/p5 copy/print.mdx delete mode 100644 src/content/reference/en/p5 copy/push.mdx delete mode 100644 src/content/reference/en/p5 copy/pwinMouseX.mdx delete mode 100644 src/content/reference/en/p5 copy/pwinMouseY.mdx delete mode 100644 src/content/reference/en/p5 copy/quad.mdx delete mode 100644 src/content/reference/en/p5 copy/quadraticVertex.mdx delete mode 100644 src/content/reference/en/p5 copy/radians.mdx delete mode 100644 src/content/reference/en/p5 copy/random.mdx delete mode 100644 src/content/reference/en/p5 copy/randomGaussian.mdx delete mode 100644 src/content/reference/en/p5 copy/randomSeed.mdx delete mode 100644 src/content/reference/en/p5 copy/rect.mdx delete mode 100644 src/content/reference/en/p5 copy/rectMode.mdx delete mode 100644 src/content/reference/en/p5 copy/red.mdx delete mode 100644 src/content/reference/en/p5 copy/redraw.mdx delete mode 100644 src/content/reference/en/p5 copy/remove.mdx delete mode 100644 src/content/reference/en/p5 copy/removeElements.mdx delete mode 100644 src/content/reference/en/p5 copy/removeItem.mdx delete mode 100644 src/content/reference/en/p5 copy/requestPointerLock.mdx delete mode 100644 src/content/reference/en/p5 copy/resetMatrix.mdx delete mode 100644 src/content/reference/en/p5 copy/resetShader.mdx delete mode 100644 src/content/reference/en/p5 copy/resizeCanvas.mdx delete mode 100644 src/content/reference/en/p5 copy/reverse.mdx delete mode 100644 src/content/reference/en/p5 copy/rotate.mdx delete mode 100644 src/content/reference/en/p5 copy/rotateX.mdx delete mode 100644 src/content/reference/en/p5 copy/rotateY.mdx delete mode 100644 src/content/reference/en/p5 copy/rotateZ.mdx delete mode 100644 src/content/reference/en/p5 copy/rotationX.mdx delete mode 100644 src/content/reference/en/p5 copy/rotationY.mdx delete mode 100644 src/content/reference/en/p5 copy/rotationZ.mdx delete mode 100644 src/content/reference/en/p5 copy/round.mdx delete mode 100644 src/content/reference/en/p5 copy/sampleRate.mdx delete mode 100644 src/content/reference/en/p5 copy/saturation.mdx delete mode 100644 src/content/reference/en/p5 copy/save.mdx delete mode 100644 src/content/reference/en/p5 copy/saveCanvas.mdx delete mode 100644 src/content/reference/en/p5 copy/saveFrames.mdx delete mode 100644 src/content/reference/en/p5 copy/saveGif.mdx delete mode 100644 src/content/reference/en/p5 copy/saveJSON.mdx delete mode 100644 src/content/reference/en/p5 copy/saveSound.mdx delete mode 100644 src/content/reference/en/p5 copy/saveStrings.mdx delete mode 100644 src/content/reference/en/p5 copy/saveTable.mdx delete mode 100644 src/content/reference/en/p5 copy/scale.mdx delete mode 100644 src/content/reference/en/p5 copy/second.mdx delete mode 100644 src/content/reference/en/p5 copy/select.mdx delete mode 100644 src/content/reference/en/p5 copy/selectAll.mdx delete mode 100644 src/content/reference/en/p5 copy/set.mdx delete mode 100644 src/content/reference/en/p5 copy/setAttributes.mdx delete mode 100644 src/content/reference/en/p5 copy/setBPM.mdx delete mode 100644 src/content/reference/en/p5 copy/setCamera.mdx delete mode 100644 src/content/reference/en/p5 copy/setMoveThreshold.mdx delete mode 100644 src/content/reference/en/p5 copy/setShakeThreshold.mdx delete mode 100644 src/content/reference/en/p5 copy/setup.mdx delete mode 100644 src/content/reference/en/p5 copy/shader.mdx delete mode 100644 src/content/reference/en/p5 copy/shearX.mdx delete mode 100644 src/content/reference/en/p5 copy/shearY.mdx delete mode 100644 src/content/reference/en/p5 copy/shininess.mdx delete mode 100644 src/content/reference/en/p5 copy/shorten.mdx delete mode 100644 src/content/reference/en/p5 copy/shuffle.mdx delete mode 100644 src/content/reference/en/p5 copy/sin.mdx delete mode 100644 src/content/reference/en/p5 copy/smooth.mdx delete mode 100644 src/content/reference/en/p5 copy/sort.mdx delete mode 100644 src/content/reference/en/p5 copy/soundFormats.mdx delete mode 100644 src/content/reference/en/p5 copy/soundOut.mdx delete mode 100644 src/content/reference/en/p5 copy/specularColor.mdx delete mode 100644 src/content/reference/en/p5 copy/specularMaterial.mdx delete mode 100644 src/content/reference/en/p5 copy/sphere.mdx delete mode 100644 src/content/reference/en/p5 copy/splice.mdx delete mode 100644 src/content/reference/en/p5 copy/split.mdx delete mode 100644 src/content/reference/en/p5 copy/splitTokens.mdx delete mode 100644 src/content/reference/en/p5 copy/spotLight.mdx delete mode 100644 src/content/reference/en/p5 copy/sq.mdx delete mode 100644 src/content/reference/en/p5 copy/sqrt.mdx delete mode 100644 src/content/reference/en/p5 copy/square.mdx delete mode 100644 src/content/reference/en/p5 copy/storeItem.mdx delete mode 100644 src/content/reference/en/p5 copy/str.mdx delete mode 100644 src/content/reference/en/p5 copy/stroke.mdx delete mode 100644 src/content/reference/en/p5 copy/strokeCap.mdx delete mode 100644 src/content/reference/en/p5 copy/strokeJoin.mdx delete mode 100644 src/content/reference/en/p5 copy/strokeWeight.mdx delete mode 100644 src/content/reference/en/p5 copy/subset.mdx delete mode 100644 src/content/reference/en/p5 copy/tan.mdx delete mode 100644 src/content/reference/en/p5 copy/text.mdx delete mode 100644 src/content/reference/en/p5 copy/textAlign.mdx delete mode 100644 src/content/reference/en/p5 copy/textAscent.mdx delete mode 100644 src/content/reference/en/p5 copy/textDescent.mdx delete mode 100644 src/content/reference/en/p5 copy/textFont.mdx delete mode 100644 src/content/reference/en/p5 copy/textLeading.mdx delete mode 100644 src/content/reference/en/p5 copy/textOutput.mdx delete mode 100644 src/content/reference/en/p5 copy/textSize.mdx delete mode 100644 src/content/reference/en/p5 copy/textStyle.mdx delete mode 100644 src/content/reference/en/p5 copy/textWidth.mdx delete mode 100644 src/content/reference/en/p5 copy/textWrap.mdx delete mode 100644 src/content/reference/en/p5 copy/texture.mdx delete mode 100644 src/content/reference/en/p5 copy/textureMode.mdx delete mode 100644 src/content/reference/en/p5 copy/textureWrap.mdx delete mode 100644 src/content/reference/en/p5 copy/tint.mdx delete mode 100644 src/content/reference/en/p5 copy/torus.mdx delete mode 100644 src/content/reference/en/p5 copy/touchEnded.mdx delete mode 100644 src/content/reference/en/p5 copy/touchMoved.mdx delete mode 100644 src/content/reference/en/p5 copy/touchStarted.mdx delete mode 100644 src/content/reference/en/p5 copy/touches.mdx delete mode 100644 src/content/reference/en/p5 copy/translate.mdx delete mode 100644 src/content/reference/en/p5 copy/triangle.mdx delete mode 100644 src/content/reference/en/p5 copy/trim.mdx delete mode 100644 src/content/reference/en/p5 copy/turnAxis.mdx delete mode 100644 src/content/reference/en/p5 copy/types/Array.mdx delete mode 100644 src/content/reference/en/p5 copy/types/Boolean.mdx delete mode 100644 src/content/reference/en/p5 copy/types/Number.mdx delete mode 100644 src/content/reference/en/p5 copy/types/Object.mdx delete mode 100644 src/content/reference/en/p5 copy/types/String.mdx delete mode 100644 src/content/reference/en/p5 copy/unchar.mdx delete mode 100644 src/content/reference/en/p5 copy/unhex.mdx delete mode 100644 src/content/reference/en/p5 copy/updatePixels.mdx delete mode 100644 src/content/reference/en/p5 copy/userStartAudio.mdx delete mode 100644 src/content/reference/en/p5 copy/vertex.mdx delete mode 100644 src/content/reference/en/p5 copy/webglVersion.mdx delete mode 100644 src/content/reference/en/p5 copy/while.mdx delete mode 100644 src/content/reference/en/p5 copy/width.mdx delete mode 100644 src/content/reference/en/p5 copy/winMouseX.mdx delete mode 100644 src/content/reference/en/p5 copy/winMouseY.mdx delete mode 100644 src/content/reference/en/p5 copy/windowHeight.mdx delete mode 100644 src/content/reference/en/p5 copy/windowResized.mdx delete mode 100644 src/content/reference/en/p5 copy/windowWidth.mdx delete mode 100644 src/content/reference/en/p5 copy/year.mdx diff --git a/.github/actions/translation-tracker/README.md b/.github/actions/translation-tracker/README.md index 2385e729d1..90ffdf1275 100644 --- a/.github/actions/translation-tracker/README.md +++ b/.github/actions/translation-tracker/README.md @@ -54,7 +54,7 @@ GENERATE_STUBS=true \ GITHUB_TOKEN=your_token GITHUB_REPOSITORY=youruser/p5.js-website \ node .github/actions/translation-tracker/index.js -# Single language or full scan (STUB_MAX_FILES is global across all languages) +# Single language or full scan (STUB_MAX_FILES applies per language) GENERATE_STUBS=true STUB_FULL_SCAN=true STUB_MAX_FILES=10 STUB_LANGUAGES=es,hi \ GITHUB_TOKEN=your_token GITHUB_REPOSITORY=youruser/p5.js-website \ node .github/actions/translation-tracker/index.js @@ -82,7 +82,7 @@ Manual stub run: Actions → **Translation Stub Generator** → Run workflow → | `STUB_CONTENT_TYPES` | Comma-separated (default: `reference`) | | `STUB_FULL_SCAN` | `true` = all English files, not just latest commit | | `STUB_DRY_RUN` | `true` = write to `stub-preview/`, no PR | -| `STUB_MAX_FILES` | Max stubs per run, total across all languages (default: `50`) | +| `STUB_MAX_FILES` | Max stubs per language per run (default: `50`) | | `STUB_OUTPUT_DIR` | Custom dry-run output directory | ## What stubs contain diff --git a/.github/actions/translation-tracker/workflows.js b/.github/actions/translation-tracker/workflows.js index 43f8d6efc8..e75a9483cc 100644 --- a/.github/actions/translation-tracker/workflows.js +++ b/.github/actions/translation-tracker/workflows.js @@ -250,6 +250,7 @@ async function runStubGeneration(githubTracker, options = {}) { console.log(` Languages: ${languages.join(', ')}`); console.log(` Content types: ${contentTypes.join(', ')}`); console.log(` Scan: ${fullScan ? 'all English files' : 'changed files only'}`); + console.log(` Max stubs per language: ${maxFiles}`); const missing = findMissingTranslations(contentTypes, languages, { fullScan, @@ -267,23 +268,34 @@ async function runStubGeneration(githubTracker, options = {}) { console.log(` Expected: ${item.translationPath}`); }); - const limited = missing.slice(0, maxFiles); - if (limited.length < missing.length) { - console.log(`\n⚠️ Limiting to ${maxFiles} stub(s) (STUB_MAX_FILES). Re-run to process more.`); - } - const byLanguage = new Map(); - for (const item of limited) { + for (const item of missing) { if (!byLanguage.has(item.language)) { byLanguage.set(item.language, []); } byLanguage.get(item.language).push(item); } + let wasLimited = false; + const limitedByLanguage = new Map(); + for (const [language, items] of byLanguage) { + const capped = items.slice(0, maxFiles); + if (capped.length < items.length) { + wasLimited = true; + } + if (capped.length > 0) { + limitedByLanguage.set(language, capped); + } + } + + if (wasLimited) { + console.log(`\n⚠️ Limiting to ${maxFiles} stub(s) per language (STUB_MAX_FILES). Re-run to process more.`); + } + const prsCreated = []; let stubsWritten = 0; - for (const [language, items] of byLanguage) { + for (const [language, items] of limitedByLanguage) { const langName = githubTracker ? githubTracker.getLanguageDisplayName(language) : getLanguageDisplayName(language); console.log(`\n📝 Generating ${items.length} stub(s) for ${langName}:`); @@ -329,7 +341,7 @@ async function runStubGeneration(githubTracker, options = {}) { console.log(` - ${pr.language}: PR #${pr.prNumber} (${pr.fileCount} file(s))`); console.log(` URL: ${pr.prUrl}`); }); - } else if (!dryRun && stubsWritten === 0 && limited.length > 0) { + } else if (!dryRun && stubsWritten === 0 && limitedByLanguage.size > 0) { console.log(`\n💡 Stubs were not written. Check GITHUB_TOKEN permissions (contents + pull-requests write).`); } diff --git a/src/content/reference/en/p5 copy/abs.mdx b/src/content/reference/en/p5 copy/abs.mdx deleted file mode 100644 index 1bdb6895ff..0000000000 --- a/src/content/reference/en/p5 copy/abs.mdx +++ /dev/null @@ -1,61 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L10 -title: abs -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Calculates the absolute value of a number.

- -

A number's absolute value is its distance from zero on the number line. - - -5 and 5 are both five units away from zero, so calling abs(-5) - and - - abs(5) both return 5. The absolute value of a number is always - positive.

-line: 10 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A gray square with a vertical black line that divides it in half. A white rectangle gets taller when the user moves the mouse away from the line.'); - } - - function draw() { - background(200); - - // Divide the canvas. - line(50, 0, 50, 100); - - // Calculate the mouse's distance from the middle. - let h = abs(mouseX - 50); - - // Draw a rectangle based on the mouse's distance - // from the middle. - rect(0, 100 - h, 100, h); - } - -
-class: p5 -params: - - name: 'n' - description: | -

number to compute.

- type: Number -return: - description: absolute value of given number. - type: Number -chainable: false ---- - - -# abs diff --git a/src/content/reference/en/p5 copy/accelerationX.mdx b/src/content/reference/en/p5 copy/accelerationX.mdx deleted file mode 100644 index 6a47fc46ce..0000000000 --- a/src/content/reference/en/p5 copy/accelerationX.mdx +++ /dev/null @@ -1,37 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L23 -title: accelerationX -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

The system variable accelerationX always contains the acceleration of the - - device along the x axis. Value is represented as meters per second - squared.

-line: 23 -isConstructor: false -itemtype: property -example: - - |- - -
- - // Move a touchscreen device to register - // acceleration changes. - function draw() { - background(220, 50); - fill('magenta'); - ellipse(width / 2, height / 2, accelerationX); - describe('Magnitude of device acceleration is displayed as ellipse size.'); - } - -
-class: p5 -type: Number ---- - - -# accelerationX diff --git a/src/content/reference/en/p5 copy/accelerationY.mdx b/src/content/reference/en/p5 copy/accelerationY.mdx deleted file mode 100644 index bf5f54e39b..0000000000 --- a/src/content/reference/en/p5 copy/accelerationY.mdx +++ /dev/null @@ -1,37 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L45 -title: accelerationY -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

The system variable accelerationY always contains the acceleration of the - - device along the y axis. Value is represented as meters per second - squared.

-line: 45 -isConstructor: false -itemtype: property -example: - - |- - -
- - // Move a touchscreen device to register - // acceleration changes. - function draw() { - background(220, 50); - fill('magenta'); - ellipse(width / 2, height / 2, accelerationY); - describe('Magnitude of device acceleration is displayed as ellipse size'); - } - -
-class: p5 -type: Number ---- - - -# accelerationY diff --git a/src/content/reference/en/p5 copy/accelerationZ.mdx b/src/content/reference/en/p5 copy/accelerationZ.mdx deleted file mode 100644 index 11e5cbb53e..0000000000 --- a/src/content/reference/en/p5 copy/accelerationZ.mdx +++ /dev/null @@ -1,37 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L67 -title: accelerationZ -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

The system variable accelerationZ always contains the acceleration of the - - device along the z axis. Value is represented as meters per second - squared.

-line: 67 -isConstructor: false -itemtype: property -example: - - |- - -
- - // Move a touchscreen device to register - // acceleration changes. - function draw() { - background(220, 50); - fill('magenta'); - ellipse(width / 2, height / 2, accelerationZ); - describe('Magnitude of device acceleration is displayed as ellipse size'); - } - -
-class: p5 -type: Number ---- - - -# accelerationZ diff --git a/src/content/reference/en/p5 copy/acos.mdx b/src/content/reference/en/p5 copy/acos.mdx deleted file mode 100644 index c9ed943f5e..0000000000 --- a/src/content/reference/en/p5 copy/acos.mdx +++ /dev/null @@ -1,86 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L18 -title: acos -module: Math -submodule: Trigonometry -file: src/math/trigonometry.js -description: > -

Calculates the arc cosine of a number.

- -

acos() is the inverse of cos(). It expects - - arguments in the range -1 to 1. By default, acos() returns values - in the - - range 0 to π (about 3.14). If the - - angleMode() is DEGREES, - then values are - - returned in the range 0 to 180.

-line: 18 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Calculate cos() and acos() values. - let a = PI; - let c = cos(a); - let ac = acos(c); - - // Display the values. - text(`${round(a, 3)}`, 35, 25); - text(`${round(c, 3)}`, 35, 50); - text(`${round(ac, 3)}`, 35, 75); - - describe('The numbers 3.142, -1, and 3.142 written on separate rows.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Calculate cos() and acos() values. - let a = PI + QUARTER_PI; - let c = cos(a); - let ac = acos(c); - - // Display the values. - text(`${round(a, 3)}`, 35, 25); - text(`${round(c, 3)}`, 35, 50); - text(`${round(ac, 3)}`, 35, 75); - - describe('The numbers 3.927, -0.707, and 2.356 written on separate rows.'); - } - -
-class: p5 -params: - - name: value - description: | -

value whose arc cosine is to be returned.

- type: Number -return: - description: arc cosine of the given value. - type: Number -chainable: false ---- - - -# acos diff --git a/src/content/reference/en/p5 copy/alpha.mdx b/src/content/reference/en/p5 copy/alpha.mdx deleted file mode 100644 index c1a87aa78d..0000000000 --- a/src/content/reference/en/p5 copy/alpha.mdx +++ /dev/null @@ -1,120 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L16 -title: alpha -module: Color -submodule: Creating & Reading -file: src/color/creating_reading.js -description: > -

Gets the alpha (transparency) value of a color.

- -

alpha() extracts the alpha value from a - - p5.Color object, an array of color - components, or - - a CSS color string.

-line: 16 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object. - let c = color(0, 126, 255, 102); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'alphaValue' to 102. - let alphaValue = alpha(c); - - // Draw the right rectangle. - fill(alphaValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light blue and the right one is charcoal gray.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a color array. - let c = [0, 126, 255, 102]; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'alphaValue' to 102. - let alphaValue = alpha(c); - - // Draw the left rectangle. - fill(alphaValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light blue and the right one is charcoal gray.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a CSS color string. - let c = 'rgba(0, 126, 255, 0.4)'; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'alphaValue' to 102. - let alphaValue = alpha(c); - - // Draw the right rectangle. - fill(alphaValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light blue and the right one is charcoal gray.'); - } - -
-class: p5 -params: - - name: color - description: | -

p5.Color object, array of - color components, or CSS color string.

- type: 'p5.Color|Number[]|String' -return: - description: the alpha value. - type: Number -chainable: false ---- - - -# alpha diff --git a/src/content/reference/en/p5 copy/ambientLight.mdx b/src/content/reference/en/p5 copy/ambientLight.mdx deleted file mode 100644 index 09f9159592..0000000000 --- a/src/content/reference/en/p5 copy/ambientLight.mdx +++ /dev/null @@ -1,241 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L10 -title: ambientLight -module: 3D -submodule: Lights -file: src/webgl/light.js -description: > -

Creates a light that shines from all directions.

- -

Ambient light does not come from one direction. Instead, 3D shapes are - - lit evenly from all sides. Ambient lights are almost always used in - - combination with other types of lights.

- -

There are three ways to call ambientLight() with optional - parameters to - - set the light’s color.

- -

The first way to call ambientLight() has two parameters, - gray and - - alpha. alpha is optional. Grayscale and alpha values - between 0 and 255 - - can be passed to set the ambient light’s color, as in - ambientLight(50) or - - ambientLight(50, 30).

- -

The second way to call ambientLight() has one parameter, - color. A - - p5.Color object, an array of color - values, or a - - CSS color string, as in ambientLight('magenta'), can be passed to - set the - - ambient light’s color.

- -

The third way to call ambientLight() has four parameters, - v1, v2, - - v3, and alpha. alpha is optional. RGBA, - HSBA, or HSLA values can be - - passed to set the ambient light’s colors, as in ambientLight(255, 0, - 0) - - or ambientLight(255, 0, 0, 30). Color values will be interpreted - using - - the current colorMode().

-line: 10 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click the canvas to turn on the light. - - let isLit = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A sphere drawn against a gray background. The sphere appears to change color when the user double-clicks.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Control the light. - if (isLit === true) { - // Use a grayscale value of 80. - ambientLight(80); - } - - // Draw the sphere. - sphere(30); - } - - // Turn on the ambient light when the user double-clicks. - function doubleClicked() { - isLit = true; - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A faded magenta sphere drawn against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - // Use a p5.Color object. - let c = color('orchid'); - ambientLight(c); - - // Draw the sphere. - sphere(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A faded magenta sphere drawn against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - // Use a CSS color string. - ambientLight('#DA70D6'); - - // Draw the sphere. - sphere(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A faded magenta sphere drawn against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - // Use RGB values - ambientLight(218, 112, 214); - - // Draw the sphere. - sphere(30); - } - -
-class: p5 -overloads: - - line: 10 - params: - - name: v1 - description: | -

red or hue value in the current - colorMode().

- type: Number - - name: v2 - description: | -

green or saturation value in the current - colorMode().

- type: Number - - name: v3 - description: | -

blue, brightness, or lightness value in the current - colorMode().

- type: Number - - name: alpha - description: | -

alpha (transparency) value in the current - colorMode().

- type: Number - optional: true - chainable: 1 - - line: 164 - params: - - name: gray - description: | -

grayscale value between 0 and 255.

- type: Number - - name: alpha - description: '' - type: Number - optional: true - chainable: 1 - - line: 171 - params: - - name: value - description: | -

color as a CSS string.

- type: String - chainable: 1 - - line: 177 - params: - - name: values - description: | -

color as an array of RGBA, HSBA, or HSLA - values.

- type: 'Number[]' - chainable: 1 - - line: 184 - params: - - name: color - description: | -

color as a p5.Color object.

- type: p5.Color - chainable: 1 -chainable: true ---- - - -# ambientLight diff --git a/src/content/reference/en/p5 copy/ambientMaterial.mdx b/src/content/reference/en/p5 copy/ambientMaterial.mdx deleted file mode 100644 index 8b96f24260..0000000000 --- a/src/content/reference/en/p5 copy/ambientMaterial.mdx +++ /dev/null @@ -1,269 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2416 -title: ambientMaterial -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Sets the ambient color of shapes’ surface material.

- -

The ambientMaterial() color sets the components of the - - ambientLight() color that shapes - will - - reflect. For example, calling ambientMaterial(255, 255, 0) would - cause a - - shape to reflect red and green light, but not blue light.

- -

ambientMaterial() can be called three ways with different - parameters to - - set the material’s color.

- -

The first way to call ambientMaterial() has one parameter, - gray. - - Grayscale values between 0 and 255, as in ambientMaterial(50), - can be - - passed to set the material’s color. Higher grayscale values make shapes - - appear brighter.

- -

The second way to call ambientMaterial() has one parameter, - color. A - - p5.Color object, an array of color - values, or a - - CSS color string, as in ambientMaterial('magenta'), can be passed - to set - - the material’s color.

- -

The third way to call ambientMaterial() has three parameters, - v1, v2, - - and v3. RGB, HSB, or HSL values, as in ambientMaterial(255, - 0, 0), can - - be passed to set the material’s colors. Color values will be interpreted - - using the current colorMode().

- -

Note: ambientMaterial() can only be used in WebGL mode.

-line: 2416 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A magenta cube drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on a magenta ambient light. - ambientLight(255, 0, 255); - - // Draw the box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A purple cube drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on a magenta ambient light. - ambientLight(255, 0, 255); - - // Add a dark gray ambient material. - ambientMaterial(150); - - // Draw the box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A red cube drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on a magenta ambient light. - ambientLight(255, 0, 255); - - // Add a yellow ambient material using RGB values. - ambientMaterial(255, 255, 0); - - // Draw the box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A red cube drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on a magenta ambient light. - ambientLight(255, 0, 255); - - // Add a yellow ambient material using a p5.Color object. - let c = color(255, 255, 0); - ambientMaterial(c); - - // Draw the box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A red cube drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on a magenta ambient light. - ambientLight(255, 0, 255); - - // Add a yellow ambient material using a color string. - ambientMaterial('yellow'); - - // Draw the box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A yellow cube drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on a white ambient light. - ambientLight(255, 255, 255); - - // Add a yellow ambient material using a color string. - ambientMaterial('yellow'); - - // Draw the box. - box(); - } - -
-class: p5 -overloads: - - line: 2416 - params: - - name: v1 - description: | -

red or hue value in the current - colorMode().

- type: Number - - name: v2 - description: | -

green or saturation value in the - current colorMode().

- type: Number - - name: v3 - description: | -

blue, brightness, or lightness value in the - current colorMode().

- type: Number - chainable: 1 - - line: 2621 - params: - - name: gray - description: | -

grayscale value between 0 (black) and 255 (white).

- type: Number - chainable: 1 - - line: 2627 - params: - - name: color - description: | -

color as a p5.Color object, - an array of color values, or a CSS string.

- type: 'p5.Color|Number[]|String' - chainable: 1 -chainable: true ---- - - -# ambientMaterial diff --git a/src/content/reference/en/p5 copy/angleMode.mdx b/src/content/reference/en/p5 copy/angleMode.mdx deleted file mode 100644 index 3401a563cd..0000000000 --- a/src/content/reference/en/p5 copy/angleMode.mdx +++ /dev/null @@ -1,219 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L557 -title: angleMode -module: Math -submodule: Trigonometry -file: src/math/trigonometry.js -description: > -

Changes the unit system used to measure angles.

- -

Degrees and radians are both units for measuring angles. There are 360˚ in - - one full rotation. A full rotation is 2 × π (about 6.28) radians.

- -

Functions such as rotate() and - - sin() expect angles measured radians by - default. - - Calling angleMode(DEGREES) switches to degrees. Calling - - angleMode(RADIANS) switches back to radians.

- -

Calling angleMode() with no arguments returns current angle - mode, which - - is either RADIANS or DEGREES.

-line: 557 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Rotate 1/8 turn. - rotate(QUARTER_PI); - - // Draw a line. - line(0, 0, 80, 0); - - describe('A diagonal line radiating from the top-left corner of a square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use degrees. - angleMode(DEGREES); - - // Rotate 1/8 turn. - rotate(45); - - // Draw a line. - line(0, 0, 80, 0); - - describe('A diagonal line radiating from the top-left corner of a square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(50); - - // Calculate the angle to rotate. - let angle = TWO_PI / 7; - - // Move the origin to the center. - translate(50, 50); - - // Style the flower. - noStroke(); - fill(255, 50); - - // Draw the flower. - for (let i = 0; i < 7; i += 1) { - ellipse(0, 0, 80, 20); - rotate(angle); - } - - describe('A translucent white flower on a dark background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(50); - - // Use degrees. - angleMode(DEGREES); - - // Calculate the angle to rotate. - let angle = 360 / 7; - - // Move the origin to the center. - translate(50, 50); - - // Style the flower. - noStroke(); - fill(255, 50); - - // Draw the flower. - for (let i = 0; i < 7; i += 1) { - ellipse(0, 0, 80, 20); - rotate(angle); - } - - describe('A translucent white flower on a dark background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A white ball on a string oscillates left and right.'); - } - - function draw() { - background(200); - - // Calculate the coordinates. - let x = 30 * cos(frameCount * 0.05) + 50; - let y = 50; - - // Draw the oscillator. - line(50, y, x, y); - circle(x, y, 20); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Use degrees. - angleMode(DEGREES); - - describe('A white ball on a string oscillates left and right.'); - } - - function draw() { - background(200); - - // Calculate the coordinates. - let x = 30 * cos(frameCount * 2.86) + 50; - let y = 50; - - // Draw the oscillator. - line(50, y, x, y); - circle(x, y, 20); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw the upper line. - rotate(PI / 6); - line(0, 0, 80, 0); - - // Use degrees. - angleMode(DEGREES); - - // Draw the lower line. - rotate(30); - line(0, 0, 80, 0); - - describe('Two diagonal lines radiating from the top-left corner of a square. The lines are oriented 30 degrees from the edges of the square and 30 degrees apart from each other.'); - } - -
-class: p5 -overloads: - - line: 557 - params: - - name: mode - description: | -

either RADIANS or DEGREES.

- type: Constant - - line: 743 - params: [] - return: - description: mode either RADIANS or DEGREES - type: Constant -chainable: false ---- - - -# angleMode diff --git a/src/content/reference/en/p5 copy/append.mdx b/src/content/reference/en/p5 copy/append.mdx deleted file mode 100644 index 4e0bbeb5eb..0000000000 --- a/src/content/reference/en/p5 copy/append.mdx +++ /dev/null @@ -1,48 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L10 -title: append -module: Data -submodule: Array Functions -file: src/utilities/array_functions.js -description: | -

Adds a value to the end of an array. Extends the length of - the array by one. Maps to Array.push().

-line: 10 -deprecated: >- - Use array.push(value) - instead. -isConstructor: false -itemtype: method -example: - - |- - -
- function setup() { - let myArray = ['Mango', 'Apple', 'Papaya']; - print(myArray); // ['Mango', 'Apple', 'Papaya'] - - append(myArray, 'Peach'); - print(myArray); // ['Mango', 'Apple', 'Papaya', 'Peach'] - } -
-class: p5 -params: - - name: array - description: | -

Array to append

- type: Array - - name: value - description: | -

to be added to the Array

- type: Any -return: - description: the array that was appended to - type: Array -chainable: false ---- - - -# append diff --git a/src/content/reference/en/p5 copy/applyMatrix.mdx b/src/content/reference/en/p5 copy/applyMatrix.mdx deleted file mode 100644 index b105ed75da..0000000000 --- a/src/content/reference/en/p5 copy/applyMatrix.mdx +++ /dev/null @@ -1,347 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L11 -title: applyMatrix -module: Transform -submodule: Transform -file: src/core/transform.js -description: > -

Applies a transformation matrix to the coordinate system.

- -

Transformations such as - - translate(), - - rotate(), and - - scale() - - use matrix-vector multiplication behind the scenes. A table of numbers, - - called a matrix, encodes each transformation. The values in the matrix - - then multiply each point on the canvas, which is represented by a vector.

- -

applyMatrix() allows for many transformations to be applied at - once. See - - Wikipedia - - and MDN - - for more details about transformations.

- -

There are two ways to call applyMatrix() in two and three - dimensions.

- -

In 2D mode, the parameters a, b, c, - d, e, and f, correspond to - - elements in the following transformation matrix:

- -
- -

The transformation matrix used when applyMatrix is called in 2D
-  mode.

- -
- -

The numbers can be passed individually, as in - - applyMatrix(2, 0, 0, 0, 2, 0). They can also be passed in an - array, as in - - applyMatrix([2, 0, 0, 0, 2, 0]).

- -

In 3D mode, the parameters a, b, c, - d, e, f, g, - h, i, - - j, k, l, m, - n, o, and p correspond to elements in - the - - following transformation matrix:

- -

The transformation matrix used when applyMatrix is called in 3D
-  mode.

- -

The numbers can be passed individually, as in - - applyMatrix(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1). They - can - - also be passed in an array, as in - - applyMatrix([2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, - 1]).

- -

By default, transformations accumulate. The - - push() and pop() functions - - can be used to isolate transformations within distinct drawing groups.

- -

Note: Transformations are reset at the beginning of the draw loop. Calling - - applyMatrix() inside the draw() - function won't - - cause shapes to transform continuously.

-line: 11 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A white circle on a gray background.'); - } - - function draw() { - background(200); - - // Translate the origin to the center. - applyMatrix(1, 0, 0, 1, 50, 50); - - // Draw the circle at coordinates (0, 0). - circle(0, 0, 40); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A white circle on a gray background.'); - } - - function draw() { - background(200); - - // Translate the origin to the center. - let m = [1, 0, 0, 1, 50, 50]; - applyMatrix(m); - - // Draw the circle at coordinates (0, 0). - circle(0, 0, 40); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe("A white rectangle on a gray background. The rectangle's long axis runs from top-left to bottom-right."); - } - - function draw() { - background(200); - - // Rotate the coordinate system 1/8 turn. - let angle = QUARTER_PI; - let ca = cos(angle); - let sa = sin(angle); - applyMatrix(ca, sa, -sa, ca, 0, 0); - - // Draw a rectangle at coordinates (50, 0). - rect(50, 0, 40, 20); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - 'Two white squares on a gray background. The larger square appears at the top-center. The smaller square appears at the top-left.' - ); - } - - function draw() { - background(200); - - // Draw a square at (30, 20). - square(30, 20, 40); - - // Scale the coordinate system by a factor of 0.5. - applyMatrix(0.5, 0, 0, 0.5, 0, 0); - - // Draw a square at (30, 20). - // It appears at (15, 10) after scaling. - square(30, 20, 40); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A white quadrilateral on a gray background.'); - } - - function draw() { - background(200); - - // Calculate the shear factor. - let angle = QUARTER_PI; - let shearFactor = 1 / tan(HALF_PI - angle); - - // Shear the coordinate system along the x-axis. - applyMatrix(1, 0, shearFactor, 1, 0, 0); - - // Draw the square. - square(0, 0, 50); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube rotates slowly against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system a little more each frame. - let angle = frameCount * 0.01; - let ca = cos(angle); - let sa = sin(angle); - applyMatrix(ca, 0, sa, 0, 0, 1, 0, 0, -sa, 0, ca, 0, 0, 0, 0, 1); - - // Draw a box. - box(); - } - -
-class: p5 -overloads: - - line: 11 - params: - - name: arr - description: > -

an array containing the elements of the transformation matrix. Its - length should be either 6 (2D) or 16 (3D).

- type: Array - chainable: 1 - - line: 206 - params: - - name: a - description: | -

an element of the transformation matrix.

- type: Number - - name: b - description: | -

an element of the transformation matrix.

- type: Number - - name: c - description: | -

an element of the transformation matrix.

- type: Number - - name: d - description: | -

an element of the transformation matrix.

- type: Number - - name: e - description: | -

an element of the transformation matrix.

- type: Number - - name: f - description: | -

an element of the transformation matrix.

- type: Number - chainable: 1 - - line: 216 - params: - - name: a - description: '' - type: Number - - name: b - description: '' - type: Number - - name: c - description: '' - type: Number - - name: d - description: '' - type: Number - - name: e - description: '' - type: Number - - name: f - description: '' - type: Number - - name: g - description: | -

an element of the transformation matrix.

- type: Number - - name: h - description: | -

an element of the transformation matrix.

- type: Number - - name: i - description: | -

an element of the transformation matrix.

- type: Number - - name: j - description: | -

an element of the transformation matrix.

- type: Number - - name: k - description: | -

an element of the transformation matrix.

- type: Number - - name: l - description: | -

an element of the transformation matrix.

- type: Number - - name: m - description: | -

an element of the transformation matrix.

- type: Number - - name: 'n' - description: | -

an element of the transformation matrix.

- type: Number - - name: o - description: | -

an element of the transformation matrix.

- type: Number - - name: p - description: | -

an element of the transformation matrix.

- type: Number - chainable: 1 -chainable: true ---- - - -# applyMatrix diff --git a/src/content/reference/en/p5 copy/arc.mdx b/src/content/reference/en/p5 copy/arc.mdx deleted file mode 100644 index ee50708815..0000000000 --- a/src/content/reference/en/p5 copy/arc.mdx +++ /dev/null @@ -1,274 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L102 -title: arc -module: Shape -submodule: 2D Primitives -file: src/core/shape/2d_primitives.js -description: > -

Draws an arc.

- -

An arc is a section of an ellipse defined by the x, - y, w, and - - h parameters. x and y set the location - of the arc's center. w and - - h set the arc's width and height. See - - ellipse() and - - ellipseMode() for more details.

- -

The fifth and sixth parameters, start and stop, - set the angles - - between which to draw the arc. Arcs are always drawn clockwise from - - start to stop. The fifth and sixth parameters, start - and stop, set the - - angles between which to draw the arc. By default, angles are given in radians, - but if angleMode - - (DEGREES) is set, the function interprets the values in degrees.

- -

The seventh parameter, mode, is optional. It determines the - arc's fill - - style. The fill modes are a semi-circle (OPEN), a closed - semi-circle - - (CHORD), or a closed pie segment (PIE).

- -

The eighth parameter, detail, is also optional. It determines - how many - - vertices are used to draw the arc in WebGL mode. The default value is 25.

-line: 102 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - arc(50, 50, 80, 80, 0, PI + HALF_PI); - - describe('A white circle on a gray canvas. The top-right quarter of the circle is missing.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - arc(50, 50, 80, 40, 0, PI + HALF_PI); - - describe('A white ellipse on a gray canvas. The top-right quarter of the ellipse is missing.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Bottom-right. - arc(50, 55, 50, 50, 0, HALF_PI); - - noFill(); - - // Bottom-left. - arc(50, 55, 60, 60, HALF_PI, PI); - - // Top-left. - arc(50, 55, 70, 70, PI, PI + QUARTER_PI); - - // Top-right. - arc(50, 55, 80, 80, PI + QUARTER_PI, TWO_PI); - - describe( - 'A shattered outline of an circle with a quarter of a white circle at the bottom-right.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Default fill mode. - arc(50, 50, 80, 80, 0, PI + QUARTER_PI); - - describe('A white circle with the top-right third missing. The bottom is outlined in black.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // OPEN fill mode. - arc(50, 50, 80, 80, 0, PI + QUARTER_PI, OPEN); - - describe( - 'A white circle missing a section from the top-right. The bottom is outlined in black.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // CHORD fill mode. - arc(50, 50, 80, 80, 0, PI + QUARTER_PI, CHORD); - - describe('A white circle with a black outline missing a section from the top-right.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // PIE fill mode. - arc(50, 50, 80, 80, 0, PI + QUARTER_PI, PIE); - - describe('A white circle with a black outline. The top-right third is missing.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - // PIE fill mode. - arc(0, 0, 80, 80, 0, PI + QUARTER_PI, PIE); - - describe('A white circle with a black outline. The top-right third is missing.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - // PIE fill mode with 5 vertices. - arc(0, 0, 80, 80, 0, PI + QUARTER_PI, PIE, 5); - - describe('A white circle with a black outline. The top-right third is missing.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A yellow circle on a black background. The circle opens and closes its mouth.'); - } - - function draw() { - background(0); - - // Style the arc. - noStroke(); - fill(255, 255, 0); - - // Update start and stop angles. - let biteSize = PI / 16; - let startAngle = biteSize * sin(frameCount * 0.1) + biteSize; - let endAngle = TWO_PI - startAngle; - - // Draw the arc. - arc(50, 50, 80, 80, startAngle, endAngle, PIE); - } - -
-class: p5 -params: - - name: x - description: | -

x-coordinate of the arc's ellipse.

- type: Number - - name: 'y' - description: | -

y-coordinate of the arc's ellipse.

- type: Number - - name: w - description: | -

width of the arc's ellipse by default.

- type: Number - - name: h - description: | -

height of the arc's ellipse by default.

- type: Number - - name: start - description: | -

angle to start the arc, specified in radians.

- type: Number - - name: stop - description: | -

angle to stop the arc, specified in radians.

- type: Number - - name: mode - description: | -

optional parameter to determine the way of drawing - the arc. either CHORD, PIE, or OPEN.

- type: Constant - optional: true - - name: detail - description: | -

optional parameter for WebGL mode only. This is to - specify the number of vertices that makes up the - perimeter of the arc. Default value is 25. Won't - draw a stroke for a detail of more than 50.

- type: Integer - optional: true -chainable: true ---- - - -# arc diff --git a/src/content/reference/en/p5 copy/arrayCopy.mdx b/src/content/reference/en/p5 copy/arrayCopy.mdx deleted file mode 100644 index 2d149d1ed3..0000000000 --- a/src/content/reference/en/p5 copy/arrayCopy.mdx +++ /dev/null @@ -1,95 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L35 -title: arrayCopy -module: Data -submodule: Array Functions -file: src/utilities/array_functions.js -description: > -

Copies an array (or part of an array) to another array. The src array is - - copied to the dst array, beginning at the position specified by - - srcPosition and into the position specified by dstPosition. The number of - - elements to copy is determined by length. Note that copying values - - overwrites existing values in the destination array. To append values - - instead of overwriting them, use concat().

- -

The simplified version with only two arguments, arrayCopy(src, dst), - - copies an entire array to another of the same size. It is equivalent to - - arrayCopy(src, 0, dst, 0, src.length).

- -

Using this function is far more efficient for copying array data than - - iterating through a for() loop and copying each element individually.

-line: 35 -deprecated: >- - Use arr1.copyWithin(arr2) - instead. -isConstructor: false -itemtype: method -example: - - |- - -
- let src = ['A', 'B', 'C']; - let dst = [1, 2, 3]; - let srcPosition = 1; - let dstPosition = 0; - let length = 2; - - print(src); // ['A', 'B', 'C'] - print(dst); // [ 1 , 2 , 3 ] - - arrayCopy(src, srcPosition, dst, dstPosition, length); - print(dst); // ['B', 'C', 3] -
-class: p5 -overloads: - - line: 35 - params: - - name: src - description: | -

the source Array

- type: Array - - name: srcPosition - description: | -

starting position in the source Array

- type: Integer - - name: dst - description: | -

the destination Array

- type: Array - - name: dstPosition - description: | -

starting position in the destination Array

- type: Integer - - name: length - description: | -

number of Array elements to be copied

- type: Integer - - line: 73 - params: - - name: src - description: '' - type: Array - - name: dst - description: '' - type: Array - - name: length - description: '' - type: Integer - optional: true -chainable: false ---- - - -# arrayCopy diff --git a/src/content/reference/en/p5 copy/asin.mdx b/src/content/reference/en/p5 copy/asin.mdx deleted file mode 100644 index 78518c0050..0000000000 --- a/src/content/reference/en/p5 copy/asin.mdx +++ /dev/null @@ -1,86 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L80 -title: asin -module: Math -submodule: Trigonometry -file: src/math/trigonometry.js -description: > -

Calculates the arc sine of a number.

- -

asin() is the inverse of sin(). It expects input - - values in the range of -1 to 1. By default, asin() returns values - in the - - range -π ÷ 2 (about -1.57) to π ÷ 2 (about 1.57). If - - the angleMode() is DEGREES - then values are - - returned in the range -90 to 90.

-line: 80 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Calculate sin() and asin() values. - let a = PI / 3; - let s = sin(a); - let as = asin(s); - - // Display the values. - text(`${round(a, 3)}`, 35, 25); - text(`${round(s, 3)}`, 35, 50); - text(`${round(as, 3)}`, 35, 75); - - describe('The numbers 1.047, 0.866, and 1.047 written on separate rows.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Calculate sin() and asin() values. - let a = PI + PI / 3; - let s = sin(a); - let as = asin(s); - - // Display the values. - text(`${round(a, 3)}`, 35, 25); - text(`${round(s, 3)}`, 35, 50); - text(`${round(as, 3)}`, 35, 75); - - describe('The numbers 4.189, -0.866, and -1.047 written on separate rows.'); - } - -
-class: p5 -params: - - name: value - description: | -

value whose arc sine is to be returned.

- type: Number -return: - description: arc sine of the given value. - type: Number -chainable: false ---- - - -# asin diff --git a/src/content/reference/en/p5 copy/atan.mdx b/src/content/reference/en/p5 copy/atan.mdx deleted file mode 100644 index 86b3874bb0..0000000000 --- a/src/content/reference/en/p5 copy/atan.mdx +++ /dev/null @@ -1,86 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L142 -title: atan -module: Math -submodule: Trigonometry -file: src/math/trigonometry.js -description: > -

Calculates the arc tangent of a number.

- -

atan() is the inverse of tan(). It expects input - - values in the range of -Infinity to Infinity. By default, atan() - returns - - values in the range -π ÷ 2 (about -1.57) to π ÷ 2 - - (about 1.57). If the angleMode() is - DEGREES - - then values are returned in the range -90 to 90.

-line: 142 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Calculate tan() and atan() values. - let a = PI / 3; - let t = tan(a); - let at = atan(t); - - // Display the values. - text(`${round(a, 3)}`, 35, 25); - text(`${round(t, 3)}`, 35, 50); - text(`${round(at, 3)}`, 35, 75); - - describe('The numbers 1.047, 1.732, and 1.047 written on separate rows.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Calculate tan() and atan() values. - let a = PI + PI / 3; - let t = tan(a); - let at = atan(t); - - // Display the values. - text(`${round(a, 3)}`, 35, 25); - text(`${round(t, 3)}`, 35, 50); - text(`${round(at, 3)}`, 35, 75); - - describe('The numbers 4.189, 1.732, and 1.047 written on separate rows.'); - } - -
-class: p5 -params: - - name: value - description: | -

value whose arc tangent is to be returned.

- type: Number -return: - description: arc tangent of the given value. - type: Number -chainable: false ---- - - -# atan diff --git a/src/content/reference/en/p5 copy/atan2.mdx b/src/content/reference/en/p5 copy/atan2.mdx deleted file mode 100644 index 200b49516b..0000000000 --- a/src/content/reference/en/p5 copy/atan2.mdx +++ /dev/null @@ -1,106 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L204 -title: atan2 -module: Math -submodule: Trigonometry -file: src/math/trigonometry.js -description: > -

Calculates the angle formed by a point, the origin, and the positive - - x-axis.

- -

atan2() is most often used for orienting geometry to the - mouse's - - position, as in atan2(mouseY, mouseX). The first parameter is the - point's - - y-coordinate and the second parameter is its x-coordinate.

- -

By default, atan2() returns values in the range - - -π (about -3.14) to π (3.14). If the - - angleMode() is DEGREES, - then values are - - returned in the range -180 to 180.

-line: 204 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A rectangle at the top-left of the canvas rotates with mouse movements.'); - } - - function draw() { - background(200); - - // Calculate the angle between the mouse - // and the origin. - let a = atan2(mouseY, mouseX); - - // Rotate. - rotate(a); - - // Draw the shape. - rect(0, 0, 60, 10); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A rectangle at the center of the canvas rotates with mouse movements.'); - } - - function draw() { - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Get the mouse's coordinates relative to the origin. - let x = mouseX - 50; - let y = mouseY - 50; - - // Calculate the angle between the mouse and the origin. - let a = atan2(y, x); - - // Rotate. - rotate(a); - - // Draw the shape. - rect(-30, -5, 60, 10); - } - -
-class: p5 -params: - - name: 'y' - description: | -

y-coordinate of the point.

- type: Number - - name: x - description: | -

x-coordinate of the point.

- type: Number -return: - description: arc tangent of the given point. - type: Number -chainable: false ---- - - -# atan2 diff --git a/src/content/reference/en/p5 copy/background.mdx b/src/content/reference/en/p5 copy/background.mdx deleted file mode 100644 index 6250c60339..0000000000 --- a/src/content/reference/en/p5 copy/background.mdx +++ /dev/null @@ -1,336 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L414 -title: background -module: Color -submodule: Setting -file: src/color/setting.js -description: > -

Sets the color used for the background of the canvas.

- -

By default, the background is transparent. background() is - typically used - - within draw() to clear the display window at - the - - beginning of each frame. It can also be used inside - - setup() to set the background on the first - frame - - of animation.

- -

The version of background() with one parameter interprets the - value one - - of four ways. If the parameter is a Number, it's interpreted as a - grayscale - - value. If the parameter is a String, it's interpreted as a CSS - color string. - - RGB, RGBA, HSL, HSLA, hex, and named color strings are supported. If the - - parameter is a p5.Color object, it will - be used as - - the background color. If the parameter is a - - p5.Image object, it will be used as the - background - - image.

- -

The version of background() with two parameters interprets the - first one - - as a grayscale value. The second parameter sets the alpha (transparency) - - value.

- -

The version of background() with three parameters interprets - them as RGB, - - HSB, or HSL colors, depending on the current - - colorMode(). By default, colors are - specified - - in RGB values. Calling background(255, 204, 0) sets the - background a bright - - yellow color.

- -

The version of background() with four parameters interprets - them as RGBA, - - HSBA, or HSLA colors, depending on the current - - colorMode(). The last parameter sets - the alpha - - (transparency) value.

-line: 414 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // A grayscale value. - background(51); - - describe('A canvas with a dark charcoal gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // A grayscale value and an alpha value. - background(51, 0.4); - describe('A canvas with a transparent gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // R, G & B values. - background(255, 204, 0); - - describe('A canvas with a yellow background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // R, G, B, and Alpha values. - background(255, 0, 0, 128); - - describe('A canvas with a semi-transparent red background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Use HSB color. - colorMode(HSB); - - // H, S & B values. - background(255, 204, 100); - - describe('A canvas with a royal blue background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // A CSS named color. - background('red'); - - describe('A canvas with a red background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Three-digit hex RGB notation. - background('#fae'); - - describe('A canvas with a pink background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Six-digit hex RGB notation. - background('#222222'); - - describe('A canvas with a black background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Integer RGB notation. - background('rgb(0, 255, 0)'); - - describe('A canvas with a bright green background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Integer RGBA notation. - background('rgba(0, 255, 0, 0.25)'); - - describe('A canvas with a transparent green background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Percentage RGB notation. - background('rgb(100%, 0%, 10%)'); - - describe('A canvas with a red background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Percentage RGBA notation. - background('rgba(100%, 0%, 100%, 0.5)'); - - describe('A canvas with a transparent purple background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // A p5.Color object. - let c = color(0, 0, 255); - background(c); - - describe('A canvas with a blue background.'); - } - -
-class: p5 -overloads: - - line: 414 - params: - - name: color - description: > -

any value created by the color() - function

- type: p5.Color - chainable: 1 - - line: 626 - params: - - name: colorstring - description: | -

color string, possible formats include: integer - rgb() or rgba(), percentage rgb() or rgba(), - 3-digit hex, 6-digit hex.

- type: String - - name: a - description: | -

opacity of the background relative to current - color range (default is 0-255).

- type: Number - optional: true - chainable: 1 - - line: 636 - params: - - name: gray - description: | -

specifies a value between white and black.

- type: Number - - name: a - description: '' - type: Number - optional: true - chainable: 1 - - line: 643 - params: - - name: v1 - description: > -

red value if color mode is RGB, or hue value if color mode is - HSB.

- type: Number - - name: v2 - description: > -

green value if color mode is RGB, or saturation value if color mode - is HSB.

- type: Number - - name: v3 - description: > -

blue value if color mode is RGB, or brightness value if color mode - is HSB.

- type: Number - - name: a - description: '' - type: Number - optional: true - chainable: 1 - - line: 652 - params: - - name: values - description: | -

an array containing the red, green, blue - and alpha components of the color.

- type: 'Number[]' - chainable: 1 - - line: 659 - params: - - name: image - description: | -

image created with loadImage() - or createImage(), - to set as background. - (must be same size as the sketch window).

- type: p5.Image - - name: a - description: '' - type: Number - optional: true - chainable: 1 -chainable: true ---- - - -# background diff --git a/src/content/reference/en/p5 copy/baseColorShader.mdx b/src/content/reference/en/p5 copy/baseColorShader.mdx deleted file mode 100644 index a608e4d5ce..0000000000 --- a/src/content/reference/en/p5 copy/baseColorShader.mdx +++ /dev/null @@ -1,178 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1292 -title: baseColorShader -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Get the shader used when no lights or materials are applied.

- -

You can call baseColorShader().modify() - - and change any of the following hooks:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HookDescription
void beforeVertexCalled at the start of the vertex shader.
vec3 getLocalPositionUpdate the position of vertices before transforms are applied. It takes in - vec3 position and must return a modified version.
vec3 getWorldPositionUpdate the position of vertices after transforms are applied. It takes in - vec3 position and pust return a modified version.
vec3 getLocalNormalUpdate the normal before transforms are applied. It takes in vec3 - normal and must return a modified version.
vec3 getWorldNormalUpdate the normal after transforms are applied. It takes in vec3 - normal and must return a modified version.
vec2 getUVUpdate the texture coordinates. It takes in vec2 uv and must - return a modified version.
vec4 getVertexColorUpdate the color of each vertex. It takes in a vec4 color and - must return a modified version.
void afterVertexCalled at the end of the vertex shader.
void beforeFragmentCalled at the start of the fragment shader.
vec4 getFinalColorUpdate the final color after mixing. It takes in a vec4 color - and must return a modified version.
void afterFragmentCalled at the end of the fragment shader.
- -

Most of the time, you will need to write your hooks in GLSL ES version 300. - If you - - are using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.

- -

Call baseColorShader().inspectHooks() to see all the possible - hooks and - - their default implementations.

-line: 1292 -isConstructor: false -itemtype: method -example: - - |- - -
- - let myShader; - - function setup() { - createCanvas(200, 200, WEBGL); - myShader = baseColorShader().modify({ - uniforms: { - 'float time': () => millis() - }, - 'vec3 getWorldPosition': `(vec3 pos) { - pos.y += 20. * sin(time * 0.001 + pos.x * 0.05); - return pos; - }` - }); - } - - function draw() { - background(255); - shader(myShader); - noStroke(); - fill('red'); - circle(0, 0, 50); - } - -
-class: p5 -return: - description: The color shader - type: p5.Shader -chainable: false -beta: true ---- - - -# baseColorShader diff --git a/src/content/reference/en/p5 copy/baseMaterialShader.mdx b/src/content/reference/en/p5 copy/baseMaterialShader.mdx deleted file mode 100644 index d41248d1aa..0000000000 --- a/src/content/reference/en/p5 copy/baseMaterialShader.mdx +++ /dev/null @@ -1,418 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L886 -title: baseMaterialShader -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Get the default shader used with lights, materials, - - and textures.

- -

You can call baseMaterialShader().modify() - - and change any of the following hooks:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HookDescription
- - -

void beforeVertex

- -
- - -

Called at the start of the vertex shader.

- -
- - -

vec3 getLocalPosition

- -
- - -

Update the position of vertices before transforms are applied. It takes in - vec3 position and must return a modified version.

- -
- - -

vec3 getWorldPosition

- -
- - -

Update the position of vertices after transforms are applied. It takes in - vec3 position and pust return a modified version.

- -
- - -

vec3 getLocalNormal

- -
- - -

Update the normal before transforms are applied. It takes in vec3 - normal and must return a modified version.

- -
- - -

vec3 getWorldNormal

- -
- - -

Update the normal after transforms are applied. It takes in vec3 - normal and must return a modified version.

- -
- - -

vec2 getUV

- -
- - -

Update the texture coordinates. It takes in vec2 uv and must - return a modified version.

- -
- - -

vec4 getVertexColor

- -
- - -

Update the color of each vertex. It takes in a vec4 color and - must return a modified version.

- -
- - -

void afterVertex

- -
- - -

Called at the end of the vertex shader.

- -
- - -

void beforeFragment

- -
- - -

Called at the start of the fragment shader.

- -
- - -

Inputs getPixelInputs

- -
- - -

Update the per-pixel inputs of the material. It takes in an - Inputs struct, which includes:

- -
    - -
  • vec3 normal, the direction pointing out of the surface
  • - -
  • vec2 texCoord, a vector where x and - y are between 0 and 1 describing the spot on a texture the pixel - is mapped to, as a fraction of the texture size
  • - -
  • vec3 ambientLight, the ambient light color on the vertex
  • - -
  • vec4 color, the base material color of the pixel
  • - -
  • vec3 ambientMaterial, the color of the pixel when affected by - ambient light
  • - -
  • vec3 specularMaterial, the color of the pixel when reflecting - specular highlights
  • - -
  • vec3 emissiveMaterial, the light color emitted by the - pixel
  • - -
  • float shininess, a number representing how sharp specular - reflections should be, from 1 to infinity
  • - -
  • float metalness, a number representing how mirrorlike the - material should be, between 0 and 1 - - The struct can be modified and returned.
- - -

vec4 combineColors

- -
- - -

Take in a ColorComponents struct containing all the different - components of light, and combining them into - - a single final color. The struct contains:

- -
    - -
  • vec3 baseColor, the base color of the pixel
  • - -
  • float opacity, the opacity between 0 and 1 that it should be - drawn at
  • - -
  • vec3 ambientColor, the color of the pixel when affected by - ambient light
  • - -
  • vec3 specularColor, the color of the pixel when affected by - specular reflections
  • - -
  • vec3 diffuse, the amount of diffused light hitting the - pixel
  • - -
  • vec3 ambient, the amount of ambient light hitting the - pixel
  • - -
  • vec3 specular, the amount of specular reflection hitting the - pixel
  • - -
  • vec3 emissive, the amount of light emitted by the pixel
  • - -
- -
- - -

vec4 getFinalColor

- -
- - -

Update the final color after mixing. It takes in a vec4 color - and must return a modified version.

- -
- - -

void afterFragment

- -
- - -

Called at the end of the fragment shader.

- -
- - -

Most of the time, you will need to write your hooks in GLSL ES version 300. - If you - - are using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.

- -

Call baseMaterialShader().inspectHooks() to see all the - possible hooks and - - their default implementations.

-line: 886 -isConstructor: false -itemtype: method -example: - - |- - -
- - let myShader; - - function setup() { - createCanvas(200, 200, WEBGL); - myShader = baseMaterialShader().modify({ - uniforms: { - 'float time': () => millis() - }, - 'vec3 getWorldPosition': `(vec3 pos) { - pos.y += 20.0 * sin(time * 0.001 + pos.x * 0.05); - return pos; - }` - }); - } - - function draw() { - background(255); - shader(myShader); - lights(); - noStroke(); - fill('red'); - sphere(50); - } - -
- - |- - -
- - let myShader; - - function setup() { - createCanvas(200, 200, WEBGL); - myShader = baseMaterialShader().modify({ - declarations: 'vec3 myNormal;', - 'Inputs getPixelInputs': `(Inputs inputs) { - myNormal = inputs.normal; - return inputs; - }`, - 'vec4 getFinalColor': `(vec4 color) { - return mix( - vec4(1.0, 1.0, 1.0, 1.0), - color, - abs(dot(myNormal, vec3(0.0, 0.0, 1.0))) - ); - }` - }); - } - - function draw() { - background(255); - rotateY(millis() * 0.001); - shader(myShader); - lights(); - noStroke(); - fill('red'); - torus(30); - } - -
- - |- - -
- - let myShader; - let environment; - - function preload() { - environment = loadImage('/assets/outdoor_spheremap.jpg'); - } - - function setup() { - createCanvas(200, 200, WEBGL); - myShader = baseMaterialShader().modify({ - 'Inputs getPixelInputs': `(Inputs inputs) { - float factor = - sin( - inputs.texCoord.x * ${TWO_PI} + - inputs.texCoord.y * ${TWO_PI} - ) * 0.4 + 0.5; - inputs.shininess = mix(1., 100., factor); - inputs.metalness = factor; - return inputs; - }` - }); - } - - function draw() { - panorama(environment); - ambientLight(100); - imageLight(environment); - rotateY(millis() * 0.001); - shader(myShader); - noStroke(); - fill(255); - specularMaterial(150); - sphere(50); - } - -
- - |- - -
- - let myShader; - - function setup() { - createCanvas(200, 200, WEBGL); - myShader = baseMaterialShader().modify({ - 'Inputs getPixelInputs': `(Inputs inputs) { - vec3 newNormal = inputs.normal; - // Simple bump mapping: adjust the normal based on position - newNormal.x += 0.2 * sin( - sin( - inputs.texCoord.y * ${TWO_PI} * 10.0 + - inputs.texCoord.x * ${TWO_PI} * 25.0 - ) - ); - newNormal.y += 0.2 * sin( - sin( - inputs.texCoord.x * ${TWO_PI} * 10.0 + - inputs.texCoord.y * ${TWO_PI} * 25.0 - ) - ); - inputs.normal = normalize(newNormal); - return inputs; - }` - }); - } - - function draw() { - background(255); - shader(myShader); - ambientLight(150); - pointLight( - 255, 255, 255, - 100*cos(frameCount*0.04), -50, 100*sin(frameCount*0.04) - ); - noStroke(); - fill('red'); - shininess(200); - specularMaterial(255); - sphere(50); - } - -
-class: p5 -return: - description: The material shader - type: p5.Shader -chainable: false -beta: true ---- - - -# baseMaterialShader diff --git a/src/content/reference/en/p5 copy/baseNormalShader.mdx b/src/content/reference/en/p5 copy/baseNormalShader.mdx deleted file mode 100644 index 4eac6e9109..0000000000 --- a/src/content/reference/en/p5 copy/baseNormalShader.mdx +++ /dev/null @@ -1,211 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1197 -title: baseNormalShader -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Get the shader used by normalMaterial().

- -

You can call baseNormalShader().modify() - - and change any of the following hooks:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HookDescription
void beforeVertexCalled at the start of the vertex shader.
vec3 getLocalPositionUpdate the position of vertices before transforms are applied. It takes in - vec3 position and must return a modified version.
vec3 getWorldPositionUpdate the position of vertices after transforms are applied. It takes in - vec3 position and pust return a modified version.
vec3 getLocalNormalUpdate the normal before transforms are applied. It takes in vec3 - normal and must return a modified version.
vec3 getWorldNormalUpdate the normal after transforms are applied. It takes in vec3 - normal and must return a modified version.
vec2 getUVUpdate the texture coordinates. It takes in vec2 uv and must - return a modified version.
vec4 getVertexColorUpdate the color of each vertex. It takes in a vec4 color and - must return a modified version.
void afterVertexCalled at the end of the vertex shader.
void beforeFragmentCalled at the start of the fragment shader.
vec4 getFinalColorUpdate the final color after mixing. It takes in a vec4 color - and must return a modified version.
void afterFragmentCalled at the end of the fragment shader.
- -

Most of the time, you will need to write your hooks in GLSL ES version 300. - If you - - are using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.

- -

Call baseNormalShader().inspectHooks() to see all the possible - hooks and - - their default implementations.

-line: 1197 -isConstructor: false -itemtype: method -example: - - |- - -
- - let myShader; - - function setup() { - createCanvas(200, 200, WEBGL); - myShader = baseNormalShader().modify({ - uniforms: { - 'float time': () => millis() - }, - 'vec3 getWorldPosition': `(vec3 pos) { - pos.y += 20. * sin(time * 0.001 + pos.x * 0.05); - return pos; - }` - }); - } - - function draw() { - background(255); - shader(myShader); - noStroke(); - sphere(50); - } - -
- - |- - -
- - let myShader; - - function setup() { - createCanvas(200, 200, WEBGL); - myShader = baseNormalShader().modify({ - 'vec3 getWorldNormal': '(vec3 normal) { return abs(normal); }', - 'vec4 getFinalColor': `(vec4 color) { - // Map the r, g, and b values of the old normal to new colors - // instead of just red, green, and blue: - vec3 newColor = - color.r * vec3(89.0, 240.0, 232.0) / 255.0 + - color.g * vec3(240.0, 237.0, 89.0) / 255.0 + - color.b * vec3(205.0, 55.0, 222.0) / 255.0; - newColor = newColor / (color.r + color.g + color.b); - return vec4(newColor, 1.0) * color.a; - }` - }); - } - - function draw() { - background(255); - shader(myShader); - noStroke(); - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.015); - box(100); - } - -
-class: p5 -return: - description: The `normalMaterial` shader - type: p5.Shader -chainable: false -beta: true ---- - - -# baseNormalShader diff --git a/src/content/reference/en/p5 copy/baseStrokeShader.mdx b/src/content/reference/en/p5 copy/baseStrokeShader.mdx deleted file mode 100644 index f2bfb42be5..0000000000 --- a/src/content/reference/en/p5 copy/baseStrokeShader.mdx +++ /dev/null @@ -1,356 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1355 -title: baseStrokeShader -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Get the shader used when drawing the strokes of shapes.

- -

You can call baseStrokeShader().modify() - - and change any of the following hooks:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HookDescription
- - -

void beforeVertex

- -
- - -

Called at the start of the vertex shader.

- -
- - -

vec3 getLocalPosition

- -
- - -

Update the position of vertices before transforms are applied. It takes in - vec3 position and must return a modified version.

- -
- - -

vec3 getWorldPosition

- -
- - -

Update the position of vertices after transforms are applied. It takes in - vec3 position and pust return a modified version.

- -
- - -

float getStrokeWeight

- -
- - -

Update the stroke weight. It takes in float weight and pust - return a modified version.

- -
- - -

vec2 getLineCenter

- -
- - -

Update the center of the line. It takes in vec2 center and - must return a modified version.

- -
- - -

vec2 getLinePosition

- -
- - -

Update the position of each vertex on the edge of the line. It takes in - vec2 position and must return a modified version.

- -
- - -

vec4 getVertexColor

- -
- - -

Update the color of each vertex. It takes in a vec4 color and - must return a modified version.

- -
- - -

void afterVertex

- -
- - -

Called at the end of the vertex shader.

- -
- - -

void beforeFragment

- -
- - -

Called at the start of the fragment shader.

- -
- - -

Inputs getPixelInputs

- -
- - -

Update the inputs to the shader. It takes in a struct Inputs - inputs, which includes:

- -
    - -
  • vec4 color, the color of the stroke
  • - -
  • vec2 tangent, the direction of the stroke in screen - space
  • - -
  • vec2 center, the coordinate of the center of the stroke in - screen space p5.js pixels
  • - -
  • vec2 position, the coordinate of the current pixel in screen - space p5.js pixels
  • - -
  • float strokeWeight, the thickness of the stroke in p5.js - pixels
  • - -
- -
- - -

bool shouldDiscard

- -
- - -

Caps and joins are made by discarded pixels in the fragment shader to carve - away unwanted areas. Use this to change this logic. It takes in a bool - willDiscard and must return a modified version.

- -
- - -

vec4 getFinalColor

- -
- - -

Update the final color after mixing. It takes in a vec4 color - and must return a modified version.

- -
- - -

void afterFragment

- -
- - -

Called at the end of the fragment shader.

- -
- - -

Most of the time, you will need to write your hooks in GLSL ES version 300. - If you - - are using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.

- -

Call baseStrokeShader().inspectHooks() to see all the possible - hooks and - - their default implementations.

-line: 1355 -isConstructor: false -itemtype: method -example: - - |- - -
- - let myShader; - - function setup() { - createCanvas(200, 200, WEBGL); - myShader = baseStrokeShader().modify({ - 'Inputs getPixelInputs': `(Inputs inputs) { - float opacity = 1.0 - smoothstep( - 0.0, - 15.0, - length(inputs.position - inputs.center) - ); - inputs.color *= opacity; - return inputs; - }` - }); - } - - function draw() { - background(255); - shader(myShader); - strokeWeight(30); - line( - -width/3, - sin(millis()*0.001) * height/4, - width/3, - sin(millis()*0.001 + 1) * height/4 - ); - } - -
- - |- - -
- - let myShader; - - function setup() { - createCanvas(200, 200, WEBGL); - myShader = baseStrokeShader().modify({ - uniforms: { - 'float time': () => millis() - }, - declarations: 'vec3 myPosition;', - 'vec3 getWorldPosition': `(vec3 pos) { - myPosition = pos; - return pos; - }`, - 'float getStrokeWeight': `(float w) { - // Add a somewhat random offset to the weight - // that varies based on position and time - float scale = 0.8 + 0.2*sin(10.0 * sin( - floor(time/250.) + - myPosition.x*0.01 + - myPosition.y*0.01 - )); - return w * scale; - }` - }); - } - - function draw() { - background(255); - shader(myShader); - myShader.setUniform('time', millis()); - strokeWeight(10); - beginShape(); - for (let i = 0; i <= 50; i++) { - let r = map(i, 0, 50, 0, width/3); - let x = r*cos(i*0.2); - let y = r*sin(i*0.2); - vertex(x, y); - } - endShape(); - } - -
- - |- - -
- - let myShader; - - function setup() { - createCanvas(200, 200, WEBGL); - myShader = baseStrokeShader().modify({ - 'float random': `(vec2 p) { - vec3 p3 = fract(vec3(p.xyx) * .1031); - p3 += dot(p3, p3.yzx + 33.33); - return fract((p3.x + p3.y) * p3.z); - }`, - 'Inputs getPixelInputs': `(Inputs inputs) { - // Replace alpha in the color with dithering by - // randomly setting pixel colors to 0 based on opacity - float a = inputs.color.a; - inputs.color.a = 1.0; - inputs.color *= random(inputs.position.xy) > a ? 0.0 : 1.0; - return inputs; - }` - }); - } - - function draw() { - background(255); - shader(myShader); - strokeWeight(10); - beginShape(); - for (let i = 0; i <= 50; i++) { - stroke( - 0, - 255 - * map(i, 0, 20, 0, 1, true) - * map(i, 30, 50, 1, 0, true) - ); - vertex( - map(i, 0, 50, -1, 1) * width/3, - 50 * sin(i/10 + frameCount/100) - ); - } - endShape(); - } - -
-class: p5 -return: - description: The stroke shader - type: p5.Shader -chainable: false -beta: true ---- - - -# baseStrokeShader diff --git a/src/content/reference/en/p5 copy/beginClip.mdx b/src/content/reference/en/p5 copy/beginClip.mdx deleted file mode 100644 index ebad022a68..0000000000 --- a/src/content/reference/en/p5 copy/beginClip.mdx +++ /dev/null @@ -1,208 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L13 -title: beginClip -module: Color -submodule: Setting -file: src/color/setting.js -description: > -

Starts defining a shape that will mask any shapes drawn afterward.

- -

Any shapes drawn between beginClip() and - - endClip() will add to the mask shape. The - mask - - will apply to anything drawn after endClip().

- -

The parameter, options, is optional. If an object with an - invert - - property is passed, as in beginClip({ invert: true }), it will be - used to - - set the masking mode. { invert: true } inverts the mask, creating - holes - - in shapes that are masked. invert is false by - default.

- -

Masks can be contained between the - - push() and pop() functions. - - Doing so allows unmasked shapes to be drawn after masked shapes.

- -

Masks can also be defined in a callback function that's passed to - - clip().

-line: 13 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a mask. - beginClip(); - triangle(15, 37, 30, 13, 43, 37); - circle(45, 45, 7); - endClip(); - - // Draw a backing shape. - square(5, 5, 45); - - describe('A white triangle and circle on a gray background.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an inverted mask. - beginClip({ invert: true }); - triangle(15, 37, 30, 13, 43, 37); - circle(45, 45, 7); - endClip(); - - // Draw a backing shape. - square(5, 5, 45); - - describe('A white square at the top-left corner of a gray square. The white square has a triangle and a circle cut out of it.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - noStroke(); - - // Draw a masked shape. - push(); - // Create a mask. - beginClip(); - triangle(15, 37, 30, 13, 43, 37); - circle(45, 45, 7); - endClip(); - - // Draw a backing shape. - square(5, 5, 45); - pop(); - - // Translate the origin to the center. - translate(50, 50); - - // Draw an inverted masked shape. - push(); - // Create an inverted mask. - beginClip({ invert: true }); - triangle(15, 37, 30, 13, 43, 37); - circle(45, 45, 7); - endClip(); - - // Draw a backing shape. - square(5, 5, 45); - pop(); - - describe('In the top left, a white triangle and circle. In the bottom right, a white square with a triangle and circle cut out of it.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A silhouette of a rotating torus colored fuchsia.'); - } - - function draw() { - background(200); - - // Create a mask. - beginClip(); - push(); - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - scale(0.5); - torus(30, 15); - pop(); - endClip(); - - // Draw a backing shape. - noStroke(); - fill('fuchsia'); - plane(100); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A silhouette of a rotating torus colored with a gradient from cyan to purple.'); - } - - function draw() { - background(200); - - // Create a mask. - beginClip(); - push(); - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - scale(0.5); - torus(30, 15); - pop(); - endClip(); - - // Draw a backing shape. - noStroke(); - beginShape(QUAD_STRIP); - fill(0, 255, 255); - vertex(-width / 2, -height / 2); - vertex(width / 2, -height / 2); - fill(100, 0, 100); - vertex(-width / 2, height / 2); - vertex(width / 2, height / 2); - endShape(); - } - -
-class: p5 -params: - - name: options - description: | -

an object containing clip settings.

- type: Object - optional: true -chainable: false ---- - - -# beginClip diff --git a/src/content/reference/en/p5 copy/beginContour.mdx b/src/content/reference/en/p5 copy/beginContour.mdx deleted file mode 100644 index 5ecd6d1437..0000000000 --- a/src/content/reference/en/p5 copy/beginContour.mdx +++ /dev/null @@ -1,134 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L20 -title: beginContour -module: Shape -submodule: Vertex -file: src/core/shape/vertex.js -description: > -

Begins creating a hole within a flat shape.

- -

The beginContour() and endContour() - - functions allow for creating negative space within custom shapes that are - - flat. beginContour() begins adding vertices to a negative space - and - - endContour() stops adding them. - - beginContour() and endContour() must be - - called between beginShape() and - - endShape().

- -

Transformations such as translate(), - - rotate(), and scale() - - don't work between beginContour() and - - endContour(). It's also not possible - to use - - other shapes, such as ellipse() or - - rect(), between beginContour() - and - - endContour().

- -

Note: The vertices that define a negative space must "wind" in the opposite - - direction from the outer shape. First, draw vertices for the outer shape - - clockwise order. Then, draw vertices for the negative space in - - counter-clockwise order.

-line: 20 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - beginShape(); - - // Exterior vertices, clockwise winding. - vertex(10, 10); - vertex(90, 10); - vertex(90, 90); - vertex(10, 90); - - // Interior vertices, counter-clockwise winding. - beginContour(); - vertex(30, 30); - vertex(30, 70); - vertex(70, 70); - vertex(70, 30); - endContour(); - - // Stop drawing the shape. - endShape(CLOSE); - - describe('A white square with a square hole in its center drawn on a gray background.'); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white square with a square hole in its center drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Start drawing the shape. - beginShape(); - - // Exterior vertices, clockwise winding. - vertex(-40, -40); - vertex(40, -40); - vertex(40, 40); - vertex(-40, 40); - - // Interior vertices, counter-clockwise winding. - beginContour(); - vertex(-20, -20); - vertex(-20, 20); - vertex(20, 20); - vertex(20, -20); - endContour(); - - // Stop drawing the shape. - endShape(CLOSE); - } - -
-class: p5 -chainable: true ---- - - -# beginContour diff --git a/src/content/reference/en/p5 copy/beginGeometry.mdx b/src/content/reference/en/p5 copy/beginGeometry.mdx deleted file mode 100644 index 3fdf211bd3..0000000000 --- a/src/content/reference/en/p5 copy/beginGeometry.mdx +++ /dev/null @@ -1,281 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L13 -title: beginGeometry -module: Shape -submodule: 3D Primitives -file: src/webgl/3d_primitives.js -description: > -

Begins adding shapes to a new - - p5.Geometry object.

- -

The beginGeometry() and endGeometry() - - functions help with creating complex 3D shapes from simpler ones such as - - sphere(). beginGeometry() - begins adding shapes - - to a custom p5.Geometry object and - - endGeometry() stops adding them.

- -

beginGeometry() and endGeometry() can help - - to make sketches more performant. For example, if a complex 3D shape - - doesn’t change while a sketch runs, then it can be created with - - beginGeometry() and endGeometry(). - - Creating a p5.Geometry object once and - then - - drawing it will run faster than repeatedly drawing the individual pieces.

- -

See buildGeometry() for another - way to - - build 3D shapes.

- -

Note: beginGeometry() can only be used in WebGL mode.

-line: 13 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Start building the p5.Geometry object. - beginGeometry(); - - // Add a cone. - cone(); - - // Stop building the p5.Geometry object. - shape = endGeometry(); - - describe('A white cone drawn on a gray background.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the p5.Geometry object. - noStroke(); - - // Draw the p5.Geometry object. - model(shape); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the p5.Geometry object. - createArrow(); - - describe('A white arrow drawn on a gray background.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the p5.Geometry object. - noStroke(); - - // Draw the p5.Geometry object. - model(shape); - } - - function createArrow() { - // Start building the p5.Geometry object. - beginGeometry(); - - // Add shapes. - push(); - rotateX(PI); - cone(10); - translate(0, -10, 0); - cylinder(3, 20); - pop(); - - // Stop building the p5.Geometry object. - shape = endGeometry(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let blueArrow; - let redArrow; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the arrows. - redArrow = createArrow('red'); - blueArrow = createArrow('blue'); - - describe('A red arrow and a blue arrow drawn on a gray background. The blue arrow rotates slowly.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the arrows. - noStroke(); - - // Draw the red arrow. - model(redArrow); - - // Translate and rotate the coordinate system. - translate(30, 0, 0); - rotateZ(frameCount * 0.01); - - // Draw the blue arrow. - model(blueArrow); - } - - function createArrow(fillColor) { - // Start building the p5.Geometry object. - beginGeometry(); - - fill(fillColor); - - // Add shapes to the p5.Geometry object. - push(); - rotateX(PI); - cone(10); - translate(0, -10, 0); - cylinder(3, 20); - pop(); - - // Stop building the p5.Geometry object. - let shape = endGeometry(); - - return shape; - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let button; - let particles; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a button to reset the particle system. - button = createButton('Reset'); - - // Call resetModel() when the user presses the button. - button.mousePressed(resetModel); - - // Add the original set of particles. - resetModel(); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the particles. - noStroke(); - - // Draw the particles. - model(particles); - } - - function resetModel() { - // If the p5.Geometry object has already been created, - // free those resources. - if (particles) { - freeGeometry(particles); - } - - // Create a new p5.Geometry object with random spheres. - particles = createParticles(); - } - - function createParticles() { - // Start building the p5.Geometry object. - beginGeometry(); - - // Add shapes. - for (let i = 0; i < 60; i += 1) { - // Calculate random coordinates. - let x = randomGaussian(0, 20); - let y = randomGaussian(0, 20); - let z = randomGaussian(0, 20); - - push(); - // Translate to the particle's coordinates. - translate(x, y, z); - // Draw the particle. - sphere(5); - pop(); - } - - // Stop building the p5.Geometry object. - let shape = endGeometry(); - - return shape; - } - -
-class: p5 -chainable: false ---- - - -# beginGeometry diff --git a/src/content/reference/en/p5 copy/beginShape.mdx b/src/content/reference/en/p5 copy/beginShape.mdx deleted file mode 100644 index d8642333db..0000000000 --- a/src/content/reference/en/p5 copy/beginShape.mdx +++ /dev/null @@ -1,449 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L129 -title: beginShape -module: Shape -submodule: Vertex -file: src/core/shape/vertex.js -description: > -

Begins adding vertices to a custom shape.

- -

The beginShape() and endShape() functions - - allow for creating custom shapes in 2D or 3D. beginShape() begins - adding - - vertices to a custom shape and endShape() stops - - adding them.

- -

The parameter, kind, sets the kind of shape to make. By - default, any - - irregular polygon can be drawn. The available modes for kind are:

- -
    - -
  • POINTS to draw a series of points.
  • - -
  • LINES to draw a series of unconnected line segments.
  • - -
  • TRIANGLES to draw a series of separate triangles.
  • - -
  • TRIANGLE_FAN to draw a series of connected triangles sharing - the first vertex in a fan-like fashion.
  • - -
  • TRIANGLE_STRIP to draw a series of connected triangles in - strip fashion.
  • - -
  • QUADS to draw a series of separate quadrilaterals - (quads).
  • - -
  • QUAD_STRIP to draw quad strip using adjacent edges to form - the next quad.
  • - -
  • TESS to create a filling curve by explicit tessellation - (WebGL only).
  • - -
- -

After calling beginShape(), shapes can be built by calling - - vertex(), - - bezierVertex(), - - quadraticVertex(), and/or - - curveVertex(). Calling - - endShape() will stop adding vertices to - the - - shape. Each shape will be outlined with the current stroke color and filled - - with the current fill color.

- -

Transformations such as translate(), - - rotate(), and - - scale() don't work between - beginShape() and - - endShape(). It's also not possible to - use - - other shapes, such as ellipse() or - - rect(), between beginShape() - and - - endShape().

-line: 129 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - beginShape(); - - // Add vertices. - vertex(30, 20); - vertex(85, 20); - vertex(85, 75); - vertex(30, 75); - - // Stop drawing the shape. - endShape(CLOSE); - - describe('A white square on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - // Only draw the vertices (points). - beginShape(POINTS); - - // Add vertices. - vertex(30, 20); - vertex(85, 20); - vertex(85, 75); - vertex(30, 75); - - // Stop drawing the shape. - endShape(); - - describe('Four black dots that form a square are drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - // Only draw lines between alternating pairs of vertices. - beginShape(LINES); - - // Add vertices. - vertex(30, 20); - vertex(85, 20); - vertex(85, 75); - vertex(30, 75); - - // Stop drawing the shape. - endShape(); - - describe('Two horizontal black lines on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the shape. - noFill(); - - // Start drawing the shape. - beginShape(); - - // Add vertices. - vertex(30, 20); - vertex(85, 20); - vertex(85, 75); - vertex(30, 75); - - // Stop drawing the shape. - endShape(); - - describe('Three black lines form a sideways U shape on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the shape. - noFill(); - - // Start drawing the shape. - beginShape(); - - // Add vertices. - vertex(30, 20); - vertex(85, 20); - vertex(85, 75); - vertex(30, 75); - - // Stop drawing the shape. - // Connect the first and last vertices. - endShape(CLOSE); - - describe('A black outline of a square drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - // Draw a series of triangles. - beginShape(TRIANGLES); - - // Left triangle. - vertex(30, 75); - vertex(40, 20); - vertex(50, 75); - - // Right triangle. - vertex(60, 20); - vertex(70, 75); - vertex(80, 20); - - // Stop drawing the shape. - endShape(); - - describe('Two white triangles drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - // Draw a series of triangles. - beginShape(TRIANGLE_STRIP); - - // Add vertices. - vertex(30, 75); - vertex(40, 20); - vertex(50, 75); - vertex(60, 20); - vertex(70, 75); - vertex(80, 20); - vertex(90, 75); - - // Stop drawing the shape. - endShape(); - - describe('Five white triangles that are interleaved drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - // Draw a series of triangles that share their first vertex. - beginShape(TRIANGLE_FAN); - - // Add vertices. - vertex(57.5, 50); - vertex(57.5, 15); - vertex(92, 50); - vertex(57.5, 85); - vertex(22, 50); - vertex(57.5, 15); - - // Stop drawing the shape. - endShape(); - - describe('Four white triangles form a square are drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - // Draw a series of quadrilaterals. - beginShape(QUADS); - - // Left rectangle. - vertex(30, 20); - vertex(30, 75); - vertex(50, 75); - vertex(50, 20); - - // Right rectangle. - vertex(65, 20); - vertex(65, 75); - vertex(85, 75); - vertex(85, 20); - - // Stop drawing the shape. - endShape(); - - describe('Two white rectangles drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - // Draw a series of quadrilaterals. - beginShape(QUAD_STRIP); - - // Add vertices. - vertex(30, 20); - vertex(30, 75); - vertex(50, 20); - vertex(50, 75); - vertex(65, 20); - vertex(65, 75); - vertex(85, 20); - vertex(85, 75); - - // Stop drawing the shape. - endShape(); - - describe('Three white rectangles that share edges are drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - // Start drawing the shape. - // Draw a series of quadrilaterals. - beginShape(TESS); - - // Add the vertices. - vertex(-30, -30, 0); - vertex(30, -30, 0); - vertex(30, -10, 0); - vertex(-10, -10, 0); - vertex(-10, 10, 0); - vertex(30, 10, 0); - vertex(30, 30, 0); - vertex(-30, 30, 0); - - // Stop drawing the shape. - // Connect the first and last vertices. - endShape(CLOSE); - - describe('A blocky C shape drawn in white on a gray background.'); - } - -
- -
- - // Click and drag with the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A blocky C shape drawn in red, blue, and green on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Start drawing the shape. - // Draw a series of quadrilaterals. - beginShape(TESS); - - // Add the vertices. - fill('red'); - stroke('red'); - vertex(-30, -30, 0); - vertex(30, -30, 0); - vertex(30, -10, 0); - fill('green'); - stroke('green'); - vertex(-10, -10, 0); - vertex(-10, 10, 0); - vertex(30, 10, 0); - fill('blue'); - stroke('blue'); - vertex(30, 30, 0); - vertex(-30, 30, 0); - - // Stop drawing the shape. - // Connect the first and last vertices. - endShape(CLOSE); - } - -
-class: p5 -params: - - name: kind - description: | -

either POINTS, LINES, TRIANGLES, TRIANGLE_FAN - TRIANGLE_STRIP, QUADS, QUAD_STRIP or TESS.

- type: Constant - optional: true -chainable: true ---- - - -# beginShape diff --git a/src/content/reference/en/p5 copy/bezier.mdx b/src/content/reference/en/p5 copy/bezier.mdx deleted file mode 100644 index 50c15330b7..0000000000 --- a/src/content/reference/en/p5 copy/bezier.mdx +++ /dev/null @@ -1,273 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L13 -title: bezier -module: Shape -submodule: Curves -file: src/core/shape/curves.js -description: > -

Draws a Bézier curve.

- -

Bézier curves can form shapes and curves that slope gently. They're defined - - by two anchor points and two control points. Bézier curves provide more - - control than the spline curves created with the - - curve() function.

- -

The first two parameters, x1 and y1, set the - first anchor point. The - - first anchor point is where the curve starts.

- -

The next four parameters, x2, y2, - x3, and y3, set the two control - - points. The control points "pull" the curve towards them.

- -

The seventh and eighth parameters, x4 and y4, set - the last anchor - - point. The last anchor point is where the curve ends.

- -

Bézier curves can also be drawn in 3D using WebGL mode. The 3D version of - - bezier() has twelve arguments because each point has x-, y-, - - and z-coordinates.

-line: 13 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw the anchor points in black. - stroke(0); - strokeWeight(5); - point(85, 20); - point(15, 80); - - // Draw the control points in red. - stroke(255, 0, 0); - point(10, 10); - point(90, 90); - - // Draw a black bezier curve. - noFill(); - stroke(0); - strokeWeight(1); - bezier(85, 20, 10, 10, 90, 90, 15, 80); - - // Draw red lines from the anchor points to the control points. - stroke(255, 0, 0); - line(85, 20, 10, 10); - line(15, 80, 90, 90); - - describe( - 'A gray square with three curves. A black s-curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' - ); - } - -
- -
- - // Click the mouse near the red dot in the top-left corner - // and drag to change the curve's shape. - - let x2 = 10; - let y2 = 10; - let isChanging = false; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with three curves. A black s-curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' - ); - } - - function draw() { - background(200); - - // Draw the anchor points in black. - stroke(0); - strokeWeight(5); - point(85, 20); - point(15, 80); - - // Draw the control points in red. - stroke(255, 0, 0); - point(x2, y2); - point(90, 90); - - // Draw a black bezier curve. - noFill(); - stroke(0); - strokeWeight(1); - bezier(85, 20, x2, y2, 90, 90, 15, 80); - - // Draw red lines from the anchor points to the control points. - stroke(255, 0, 0); - line(85, 20, x2, y2); - line(15, 80, 90, 90); - } - - // Start changing the first control point if the user clicks near it. - function mousePressed() { - if (dist(mouseX, mouseY, x2, y2) < 20) { - isChanging = true; - } - } - - // Stop changing the first control point when the user releases the mouse. - function mouseReleased() { - isChanging = false; - } - - // Update the first control point while the user drags the mouse. - function mouseDragged() { - if (isChanging === true) { - x2 = mouseX; - y2 = mouseY; - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background('skyblue'); - - // Draw the red balloon. - fill('red'); - bezier(50, 60, 5, 15, 95, 15, 50, 60); - - // Draw the balloon string. - line(50, 60, 50, 80); - - describe('A red balloon in a blue sky.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A red balloon in a blue sky. The balloon rotates slowly, revealing that it is flat.'); - } - - function draw() { - background('skyblue'); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Draw the red balloon. - fill('red'); - bezier(0, 0, 0, -45, -45, 0, 45, -45, 0, 0, 0, 0); - - // Draw the balloon string. - line(0, 0, 0, 0, 20, 0); - } - -
-class: p5 -overloads: - - line: 13 - params: - - name: x1 - description: | -

x-coordinate of the first anchor point.

- type: Number - - name: y1 - description: | -

y-coordinate of the first anchor point.

- type: Number - - name: x2 - description: | -

x-coordinate of the first control point.

- type: Number - - name: y2 - description: | -

y-coordinate of the first control point.

- type: Number - - name: x3 - description: | -

x-coordinate of the second control point.

- type: Number - - name: y3 - description: | -

y-coordinate of the second control point.

- type: Number - - name: x4 - description: | -

x-coordinate of the second anchor point.

- type: Number - - name: y4 - description: | -

y-coordinate of the second anchor point.

- type: Number - chainable: 1 - - line: 191 - params: - - name: x1 - description: '' - type: Number - - name: y1 - description: '' - type: Number - - name: z1 - description: | -

z-coordinate of the first anchor point.

- type: Number - - name: x2 - description: '' - type: Number - - name: y2 - description: '' - type: Number - - name: z2 - description: | -

z-coordinate of the first control point.

- type: Number - - name: x3 - description: '' - type: Number - - name: y3 - description: '' - type: Number - - name: z3 - description: | -

z-coordinate of the second control point.

- type: Number - - name: x4 - description: '' - type: Number - - name: y4 - description: '' - type: Number - - name: z4 - description: | -

z-coordinate of the second anchor point.

- type: Number - chainable: 1 -chainable: true ---- - - -# bezier diff --git a/src/content/reference/en/p5 copy/bezierDetail.mdx b/src/content/reference/en/p5 copy/bezierDetail.mdx deleted file mode 100644 index b4f895a3fc..0000000000 --- a/src/content/reference/en/p5 copy/bezierDetail.mdx +++ /dev/null @@ -1,121 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L221 -title: bezierDetail -module: Shape -submodule: Curves -file: src/core/shape/curves.js -description: > -

Sets the number of segments used to draw Bézier curves in WebGL mode.

- -

In WebGL mode, smooth shapes are drawn using many flat segments. Adding - - more flat segments makes shapes appear smoother.

- -

The parameter, detail, is the number of segments to use while - drawing a - - Bézier curve. For example, calling bezierDetail(5) will use 5 - segments to - - draw curves with the bezier() function. By - - default,detail is 20.

- -

Note: bezierDetail() has no effect in 2D mode.

-line: 221 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Draw the original curve. - - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw the anchor points in black. - stroke(0); - strokeWeight(5); - point(85, 20); - point(15, 80); - - // Draw the control points in red. - stroke(255, 0, 0); - point(10, 10); - point(90, 90); - - // Draw a black bezier curve. - noFill(); - stroke(0); - strokeWeight(1); - bezier(85, 20, 10, 10, 90, 90, 15, 80); - - // Draw red lines from the anchor points to the control points. - stroke(255, 0, 0); - line(85, 20, 10, 10); - line(15, 80, 90, 90); - - describe( - 'A gray square with three curves. A black s-curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' - ); - } - -
- -
- - // Draw the curve with less detail. - - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - // Set the curveDetail() to 5. - bezierDetail(5); - - // Draw the anchor points in black. - stroke(0); - strokeWeight(5); - point(35, -30, 0); - point(-35, 30, 0); - - // Draw the control points in red. - stroke(255, 0, 0); - point(-40, -40, 0); - point(40, 40, 0); - - // Draw a black bezier curve. - noFill(); - stroke(0); - strokeWeight(1); - bezier(35, -30, 0, -40, -40, 0, 40, 40, 0, -35, 30, 0); - - // Draw red lines from the anchor points to the control points. - stroke(255, 0, 0); - line(35, -30, -40, -40); - line(-35, 30, 40, 40); - - describe( - 'A gray square with three curves. A black s-curve is drawn with jagged segments. Two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' - ); - } - -
-class: p5 -params: - - name: detail - description: | -

number of segments to use. Defaults to 20.

- type: Number -chainable: true ---- - - -# bezierDetail diff --git a/src/content/reference/en/p5 copy/bezierPoint.mdx b/src/content/reference/en/p5 copy/bezierPoint.mdx deleted file mode 100644 index a42c171121..0000000000 --- a/src/content/reference/en/p5 copy/bezierPoint.mdx +++ /dev/null @@ -1,162 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L324 -title: bezierPoint -module: Shape -submodule: Curves -file: src/core/shape/curves.js -description: > -

Calculates coordinates along a Bézier curve using interpolation.

- -

bezierPoint() calculates coordinates along a Bézier curve - using the - - anchor and control points. It expects points in the same order as the - - bezier() function. - bezierPoint() works one axis - - at a time. Passing the anchor and control points' x-coordinates will - - calculate the x-coordinate of a point on the curve. Passing the anchor and - - control points' y-coordinates will calculate the y-coordinate of a point on - - the curve.

- -

The first parameter, a, is the coordinate of the first anchor - point.

- -

The second and third parameters, b and c, are the - coordinates of the - - control points.

- -

The fourth parameter, d, is the coordinate of the last anchor - point.

- -

The fifth parameter, t, is the amount to interpolate along the - curve. 0 - - is the first anchor point, 1 is the second anchor point, and 0.5 is halfway - - between them.

-line: 324 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Set the coordinates for the curve's anchor and control points. - let x1 = 85; - let x2 = 10; - let x3 = 90; - let x4 = 15; - let y1 = 20; - let y2 = 10; - let y3 = 90; - let y4 = 80; - - // Style the curve. - noFill(); - - // Draw the curve. - bezier(x1, y1, x2, y2, x3, y3, x4, y4); - - // Draw circles along the curve's path. - fill(255); - - // Top-right. - let x = bezierPoint(x1, x2, x3, x4, 0); - let y = bezierPoint(y1, y2, y3, y4, 0); - circle(x, y, 5); - - // Center. - x = bezierPoint(x1, x2, x3, x4, 0.5); - y = bezierPoint(y1, y2, y3, y4, 0.5); - circle(x, y, 5); - - // Bottom-left. - x = bezierPoint(x1, x2, x3, x4, 1); - y = bezierPoint(y1, y2, y3, y4, 1); - circle(x, y, 5); - - describe('A black s-curve on a gray square. The endpoints and center of the curve are marked with white circles.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A black s-curve on a gray square. A white circle moves back and forth along the curve.'); - } - - function draw() { - background(200); - - // Set the coordinates for the curve's anchor and control points. - let x1 = 85; - let x2 = 10; - let x3 = 90; - let x4 = 15; - let y1 = 20; - let y2 = 10; - let y3 = 90; - let y4 = 80; - - // Draw the curve. - noFill(); - bezier(x1, y1, x2, y2, x3, y3, x4, y4); - - // Calculate the circle's coordinates. - let t = 0.5 * sin(frameCount * 0.01) + 0.5; - let x = bezierPoint(x1, x2, x3, x4, t); - let y = bezierPoint(y1, y2, y3, y4, t); - - // Draw the circle. - fill(255); - circle(x, y, 5); - } - -
-class: p5 -params: - - name: a - description: | -

coordinate of first anchor point.

- type: Number - - name: b - description: | -

coordinate of first control point.

- type: Number - - name: c - description: | -

coordinate of second control point.

- type: Number - - name: d - description: | -

coordinate of second anchor point.

- type: Number - - name: t - description: | -

amount to interpolate between 0 and 1.

- type: Number -return: - description: coordinate of the point on the curve. - type: Number -chainable: false ---- - - -# bezierPoint diff --git a/src/content/reference/en/p5 copy/bezierTangent.mdx b/src/content/reference/en/p5 copy/bezierTangent.mdx deleted file mode 100644 index 8fb0edfaa8..0000000000 --- a/src/content/reference/en/p5 copy/bezierTangent.mdx +++ /dev/null @@ -1,155 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L450 -title: bezierTangent -module: Shape -submodule: Curves -file: src/core/shape/curves.js -description: > -

Calculates coordinates along a line that's tangent to a Bézier curve.

- -

Tangent lines skim the surface of a curve. A tangent line's slope equals - - the curve's slope at the point where it intersects.

- -

bezierTangent() calculates coordinates along a tangent line - using the - - Bézier curve's anchor and control points. It expects points in the same - - order as the bezier() function. - bezierTangent() - - works one axis at a time. Passing the anchor and control points' - - x-coordinates will calculate the x-coordinate of a point on the tangent - - line. Passing the anchor and control points' y-coordinates will calculate - - the y-coordinate of a point on the tangent line.

- -

The first parameter, a, is the coordinate of the first anchor - point.

- -

The second and third parameters, b and c, are the - coordinates of the - - control points.

- -

The fourth parameter, d, is the coordinate of the last anchor - point.

- -

The fifth parameter, t, is the amount to interpolate along the - curve. 0 - - is the first anchor point, 1 is the second anchor point, and 0.5 is halfway - - between them.

-line: 450 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Set the coordinates for the curve's anchor and control points. - let x1 = 85; - let x2 = 10; - let x3 = 90; - let x4 = 15; - let y1 = 20; - let y2 = 10; - let y3 = 90; - let y4 = 80; - - // Style the curve. - noFill(); - - // Draw the curve. - bezier(x1, y1, x2, y2, x3, y3, x4, y4); - - // Draw tangents along the curve's path. - fill(255); - - // Top-right circle. - stroke(0); - let x = bezierPoint(x1, x2, x3, x4, 0); - let y = bezierPoint(y1, y2, y3, y4, 0); - circle(x, y, 5); - - // Top-right tangent line. - // Scale the tangent point to draw a shorter line. - stroke(255, 0, 0); - let tx = 0.1 * bezierTangent(x1, x2, x3, x4, 0); - let ty = 0.1 * bezierTangent(y1, y2, y3, y4, 0); - line(x + tx, y + ty, x - tx, y - ty); - - // Center circle. - stroke(0); - x = bezierPoint(x1, x2, x3, x4, 0.5); - y = bezierPoint(y1, y2, y3, y4, 0.5); - circle(x, y, 5); - - // Center tangent line. - // Scale the tangent point to draw a shorter line. - stroke(255, 0, 0); - tx = 0.1 * bezierTangent(x1, x2, x3, x4, 0.5); - ty = 0.1 * bezierTangent(y1, y2, y3, y4, 0.5); - line(x + tx, y + ty, x - tx, y - ty); - - // Bottom-left circle. - stroke(0); - x = bezierPoint(x1, x2, x3, x4, 1); - y = bezierPoint(y1, y2, y3, y4, 1); - circle(x, y, 5); - - // Bottom-left tangent. - // Scale the tangent point to draw a shorter line. - stroke(255, 0, 0); - tx = 0.1 * bezierTangent(x1, x2, x3, x4, 1); - ty = 0.1 * bezierTangent(y1, y2, y3, y4, 1); - line(x + tx, y + ty, x - tx, y - ty); - - describe( - 'A black s-curve on a gray square. The endpoints and center of the curve are marked with white circles. Red tangent lines extend from the white circles.' - ); - } - -
-class: p5 -params: - - name: a - description: | -

coordinate of first anchor point.

- type: Number - - name: b - description: | -

coordinate of first control point.

- type: Number - - name: c - description: | -

coordinate of second control point.

- type: Number - - name: d - description: | -

coordinate of second anchor point.

- type: Number - - name: t - description: | -

amount to interpolate between 0 and 1.

- type: Number -return: - description: coordinate of a point on the tangent line. - type: Number -chainable: false ---- - - -# bezierTangent diff --git a/src/content/reference/en/p5 copy/bezierVertex.mdx b/src/content/reference/en/p5 copy/bezierVertex.mdx deleted file mode 100644 index f4b5fb57cb..0000000000 --- a/src/content/reference/en/p5 copy/bezierVertex.mdx +++ /dev/null @@ -1,337 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L543 -title: bezierVertex -module: Shape -submodule: Vertex -file: src/core/shape/vertex.js -description: > -

Adds a Bézier curve segment to a custom shape.

- -

bezierVertex() adds a curved segment to custom shapes. The - Bézier curves - - it creates are defined like those made by the - - bezier() function. - bezierVertex() must be - - called between the - - beginShape() and - - endShape() functions. The curved segment - uses - - the previous vertex as the first anchor point, so there must be at least - - one call to vertex() before - bezierVertex() can - - be used.

- -

The first four parameters, x2, y2, - x3, and y3, set the curve’s two - - control points. The control points "pull" the curve towards them.

- -

The fifth and sixth parameters, x4, and y4, set - the last anchor point. - - The last anchor point is where the curve ends.

- -

Bézier curves can also be drawn in 3D using WebGL mode. The 3D version of - - bezierVertex() has eight arguments because each point has x-, y-, - and - - z-coordinates.

- -

Note: bezierVertex() won’t work when an argument is passed to - - beginShape().

-line: 543 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the shape. - noFill(); - - // Start drawing the shape. - beginShape(); - - // Add the first anchor point. - vertex(30, 20); - - // Add the Bézier vertex. - bezierVertex(80, 0, 80, 75, 30, 75); - - // Stop drawing the shape. - endShape(); - - describe('A black C curve on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw the anchor points in black. - stroke(0); - strokeWeight(5); - point(30, 20); - point(30, 75); - - // Draw the control points in red. - stroke(255, 0, 0); - point(80, 0); - point(80, 75); - - // Style the shape. - noFill(); - stroke(0); - strokeWeight(1); - - // Start drawing the shape. - beginShape(); - - // Add the first anchor point. - vertex(30, 20); - - // Add the Bézier vertex. - bezierVertex(80, 0, 80, 75, 30, 75); - - // Stop drawing the shape. - endShape(); - - // Draw red lines from the anchor points to the control points. - stroke(255, 0, 0); - line(30, 20, 80, 0); - line(30, 75, 80, 75); - - describe( - 'A gray square with three curves. A black curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' - ); - } - -
- -
- - // Click the mouse near the red dot in the top-right corner - // and drag to change the curve's shape. - - let x2 = 80; - let y2 = 0; - let isChanging = false; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with three curves. A black curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' - ); - } - - function draw() { - background(200); - - // Draw the anchor points in black. - stroke(0); - strokeWeight(5); - point(30, 20); - point(30, 75); - - // Draw the control points in red. - stroke(255, 0, 0); - point(x2, y2); - point(80, 75); - - // Style the shape. - noFill(); - stroke(0); - strokeWeight(1); - - // Start drawing the shape. - beginShape(); - - // Add the first anchor point. - vertex(30, 20); - - // Add the Bézier vertex. - bezierVertex(x2, y2, 80, 75, 30, 75); - - // Stop drawing the shape. - endShape(); - - // Draw red lines from the anchor points to the control points. - stroke(255, 0, 0); - line(30, 20, x2, y2); - line(30, 75, 80, 75); - } - - // Start changing the first control point if the user clicks near it. - function mousePressed() { - if (dist(mouseX, mouseY, x2, y2) < 20) { - isChanging = true; - } - } - - // Stop changing the first control point when the user releases the mouse. - function mouseReleased() { - isChanging = false; - } - - // Update the first control point while the user drags the mouse. - function mouseDragged() { - if (isChanging === true) { - x2 = mouseX; - y2 = mouseY; - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - beginShape(); - - // Add the first anchor point. - vertex(30, 20); - - // Add the Bézier vertices. - bezierVertex(80, 0, 80, 75, 30, 75); - bezierVertex(50, 80, 60, 25, 30, 20); - - // Stop drawing the shape. - endShape(); - - describe('A crescent moon shape drawn in white on a gray background.'); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A crescent moon shape drawn in white on a blue background. When the user drags the mouse, the scene rotates and a second moon is revealed.'); - } - - function draw() { - background('midnightblue'); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the moons. - noStroke(); - fill('lemonchiffon'); - - // Draw the first moon. - beginShape(); - vertex(-20, -30, 0); - bezierVertex(30, -50, 0, 30, 25, 0, -20, 25, 0); - bezierVertex(0, 30, 0, 10, -25, 0, -20, -30, 0); - endShape(); - - // Draw the second moon. - beginShape(); - vertex(-20, -30, -20); - bezierVertex(30, -50, -20, 30, 25, -20, -20, 25, -20); - bezierVertex(0, 30, -20, 10, -25, -20, -20, -30, -20); - endShape(); - } - -
-class: p5 -overloads: - - line: 543 - params: - - name: x2 - description: | -

x-coordinate of the first control point.

- type: Number - - name: y2 - description: | -

y-coordinate of the first control point.

- type: Number - - name: x3 - description: | -

x-coordinate of the second control point.

- type: Number - - name: y3 - description: | -

y-coordinate of the second control point.

- type: Number - - name: x4 - description: | -

x-coordinate of the anchor point.

- type: Number - - name: y4 - description: | -

y-coordinate of the anchor point.

- type: Number - chainable: 1 - - line: 792 - params: - - name: x2 - description: '' - type: Number - - name: y2 - description: '' - type: Number - - name: z2 - description: | -

z-coordinate of the first control point.

- type: Number - - name: x3 - description: '' - type: Number - - name: y3 - description: '' - type: Number - - name: z3 - description: | -

z-coordinate of the second control point.

- type: Number - - name: x4 - description: '' - type: Number - - name: y4 - description: '' - type: Number - - name: z4 - description: | -

z-coordinate of the anchor point.

- type: Number - chainable: 1 -chainable: true ---- - - -# bezierVertex diff --git a/src/content/reference/en/p5 copy/blend.mdx b/src/content/reference/en/p5 copy/blend.mdx deleted file mode 100644 index 53e9a94dc9..0000000000 --- a/src/content/reference/en/p5 copy/blend.mdx +++ /dev/null @@ -1,214 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L148 -title: blend -module: Image -submodule: Pixels -file: src/image/pixels.js -description: > -

Copies a region of pixels from one image to another.

- -

The first parameter, srcImage, is the - - p5.Image object to blend.

- -

The next four parameters, sx, sy, - sw, and sh determine the region - - to blend from the source image. (sx, sy) is the top-left corner - of the - - region. sw and sh are the regions width and - height.

- -

The next four parameters, dx, dy, - dw, and dh determine the region - - of the canvas to blend into. (dx, dy) is the top-left corner of - the - - region. dw and dh are the regions width and - height.

- -

The tenth parameter, blendMode, sets the effect used to blend - the images' - - colors. The options are BLEND, DARKEST, - LIGHTEST, DIFFERENCE, - - MULTIPLY, EXCLUSION, SCREEN, - REPLACE, OVERLAY, HARD_LIGHT, - - SOFT_LIGHT, DODGE, BURN, - ADD, or NORMAL

-line: 148 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img0; - let img1; - - // Load the images. - function preload() { - img0 = loadImage('/assets/rockies.jpg'); - img1 = loadImage('/assets/bricks_third.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Use the mountains as the background. - background(img0); - - // Display the bricks. - image(img1, 0, 0); - - // Display the bricks faded into the landscape. - blend(img1, 0, 0, 33, 100, 67, 0, 33, 100, LIGHTEST); - - describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears faded on the right of the image.'); - } - -
- -
- - let img0; - let img1; - - // Load the images. - function preload() { - img0 = loadImage('/assets/rockies.jpg'); - img1 = loadImage('/assets/bricks_third.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Use the mountains as the background. - background(img0); - - // Display the bricks. - image(img1, 0, 0); - - // Display the bricks partially transparent. - blend(img1, 0, 0, 33, 100, 67, 0, 33, 100, DARKEST); - - describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears transparent on the right of the image.'); - } - -
- -
- - let img0; - let img1; - - // Load the images. - function preload() { - img0 = loadImage('/assets/rockies.jpg'); - img1 = loadImage('/assets/bricks_third.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Use the mountains as the background. - background(img0); - - // Display the bricks. - image(img1, 0, 0); - - // Display the bricks washed out into the landscape. - blend(img1, 0, 0, 33, 100, 67, 0, 33, 100, ADD); - - describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears washed out on the right of the image.'); - } - -
-class: p5 -overloads: - - line: 148 - params: - - name: srcImage - description: | -

source image.

- type: p5.Image - - name: sx - description: | -

x-coordinate of the source's upper-left corner.

- type: Integer - - name: sy - description: | -

y-coordinate of the source's upper-left corner.

- type: Integer - - name: sw - description: | -

source image width.

- type: Integer - - name: sh - description: | -

source image height.

- type: Integer - - name: dx - description: | -

x-coordinate of the destination's upper-left corner.

- type: Integer - - name: dy - description: | -

y-coordinate of the destination's upper-left corner.

- type: Integer - - name: dw - description: | -

destination image width.

- type: Integer - - name: dh - description: | -

destination image height.

- type: Integer - - name: blendMode - description: | -

the blend mode. either - BLEND, DARKEST, LIGHTEST, DIFFERENCE, - MULTIPLY, EXCLUSION, SCREEN, REPLACE, OVERLAY, HARD_LIGHT, - SOFT_LIGHT, DODGE, BURN, ADD or NORMAL.

- type: Constant - - line: 267 - params: - - name: sx - description: '' - type: Integer - - name: sy - description: '' - type: Integer - - name: sw - description: '' - type: Integer - - name: sh - description: '' - type: Integer - - name: dx - description: '' - type: Integer - - name: dy - description: '' - type: Integer - - name: dw - description: '' - type: Integer - - name: dh - description: '' - type: Integer - - name: blendMode - description: '' - type: Constant -chainable: false ---- - - -# blend diff --git a/src/content/reference/en/p5 copy/blendMode.mdx b/src/content/reference/en/p5 copy/blendMode.mdx deleted file mode 100644 index 8f6365b78d..0000000000 --- a/src/content/reference/en/p5 copy/blendMode.mdx +++ /dev/null @@ -1,541 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L720 -title: blendMode -module: Rendering -submodule: Rendering -file: src/core/rendering.js -description: > -

Sets the way colors blend when added to the canvas.

- -

By default, drawing with a solid color paints over the current pixel values - - on the canvas. blendMode() offers many options for blending - colors.

- -

Shapes, images, and text can be used as sources for drawing to the canvas. - - A source pixel changes the color of the canvas pixel where it's drawn. The - - final color results from blending the source pixel's color with the canvas - - pixel's color. RGB color values from the source and canvas pixels are - - compared, added, subtracted, multiplied, and divided to create different - - effects. Red values with red values, greens with greens, and blues with - - blues.

- -

The parameter, mode, sets the blend mode. For example, calling - - blendMode(ADD) sets the blend mode to ADD. The - following blend modes - - are available in both 2D and WebGL mode:

- -
    - -
  • BLEND: color values from the source overwrite the canvas. - This is the default mode.
  • - -
  • ADD: color values from the source are added to values from - the canvas.
  • - -
  • DARKEST: keeps the darkest color value.
  • - -
  • LIGHTEST: keeps the lightest color value.
  • - -
  • EXCLUSION: similar to DIFFERENCE but with less - contrast.
  • - -
  • MULTIPLY: color values from the source are multiplied with - values from the canvas. The result is always darker.
  • - -
  • SCREEN: all color values are inverted, then multiplied, then - inverted again. The result is always lighter. (Opposite of - MULTIPLY)
  • - -
  • REPLACE: the last source drawn completely replaces the rest - of the canvas.
  • - -
  • REMOVE: overlapping pixels are removed by making them - completely transparent.
  • - -
- -

The following blend modes are only available in 2D mode:

- -
    - -
  • DIFFERENCE: color values from the source are subtracted from - the values from the canvas. If the difference is a negative number, it's made - positive.
  • - -
  • OVERLAY: combines MULTIPLY and - SCREEN. Dark values in the canvas get darker and light values get - lighter.
  • - -
  • HARD_LIGHT: combines MULTIPLY and - SCREEN. Dark values in the source get darker and light values get - lighter.
  • - -
  • SOFT_LIGHT: a softer version of HARD_LIGHT.
  • - -
  • DODGE: lightens light tones and increases contrast. Divides - the canvas color values by the inverted color values from the source.
  • - -
  • BURN: darkens dark tones and increases contrast. Divides the - source color values by the inverted color values from the canvas, then inverts - the result.
  • - -
- -

The following blend modes are only available in WebGL mode:

- -
    - -
  • SUBTRACT: RGB values from the source are subtracted from the - values from the canvas. If the difference is a negative number, it's made - positive. Alpha (transparency) values from the source and canvas are - added.
  • - -
-line: 720 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Use the default blend mode. - blendMode(BLEND); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('A Sky Blue line and a Deep Rose line form an X on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(HARD_LIGHT); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('An ocean blue line and a hot pink line form an X on a gray background. The area where they overlap is Magenta purple.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(ADD); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('An icy blue line and a light lavender line form an X on a gray background. The area where they overlap is white.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(DARKEST); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('A steel blue line and a cranberry line form an X on a gray background. The area where they overlap is deep purple.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(BURN); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('A cobalt blue line and a burgundy line form an X on a gray background. The area where they overlap is black.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(LIGHTEST); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('A pale lavender line and a soft beige line form an X on a gray background. The area where they overlap is pale lilac.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(EXCLUSION); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('An earthy brown line and a muted sage line form an X on a gray background. The area where they overlap is sage green.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(MULTIPLY); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('A slate blue line and a plum line form an X on a gray background. The area where they overlap is dark Indigo.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(SCREEN); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('A baby blue line and a peach pink line form an X on a gray background. The area where they overlap is misty lilac.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(REPLACE); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('A diagonal deep rose line.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(REMOVE); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('The silhouette of an X is missing from a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(DIFFERENCE); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('A light burgundy line and a forest green line form an X on a gray background. The area where they overlap is dark cocoa.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(OVERLAY); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('A cornflower blue line and a light rose line form an X on a gray background. The area where they overlap is violet.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(SOFT_LIGHT); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('A pale sky line and a rose blush line form an X on a gray background. The area where they overlap is lavender.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(DODGE); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('An aqua blue line and a light pink line form an X on a gray background. The area where they overlap is white.'); - } - -
- -
- - function setup() { - // Create a canvas with WEBGL mode. - createCanvas(100, 100, WEBGL); - - // Set the background color. - background(180); - - // Set the blend mode to SUBTRACT. - blendMode(SUBTRACT); - - // Style the lines. - strokeWeight(30); - - // Draw the blue line. - stroke('#1a85ff'); - line(-25, -25, 25, 25); - - // Draw the red line. - stroke('#d41159'); - line(25, -25, -25, 25); - - describe('A burnt orange and a sea green line form an X on a gray background. The area where they overlap is forest green.'); - } - -
-class: p5 -params: - - name: mode - description: | -

blend mode to set. - either BLEND, DARKEST, LIGHTEST, DIFFERENCE, MULTIPLY, - EXCLUSION, SCREEN, REPLACE, OVERLAY, HARD_LIGHT, - SOFT_LIGHT, DODGE, BURN, ADD, REMOVE or SUBTRACT

- type: Constant -chainable: false ---- - - -# blendMode diff --git a/src/content/reference/en/p5 copy/blue.mdx b/src/content/reference/en/p5 copy/blue.mdx deleted file mode 100644 index d3e05aae37..0000000000 --- a/src/content/reference/en/p5 copy/blue.mdx +++ /dev/null @@ -1,158 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L117 -title: blue -module: Color -submodule: Creating & Reading -file: src/color/creating_reading.js -description: > -

Gets the blue value of a color.

- -

blue() extracts the blue value from a - - p5.Color object, an array of color - components, or - - a CSS color string.

- -

By default, blue() returns a color's blue value in the range 0 - - to 255. If the colorMode() is set to - RGB, it - - returns the blue value in the given range.

-line: 117 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object using RGB values. - let c = color(175, 100, 220); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'blueValue' to 220. - let blueValue = blue(c); - - // Draw the right rectangle. - fill(0, 0, blueValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is royal blue.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a color array. - let c = [175, 100, 220]; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'blueValue' to 220. - let blueValue = blue(c); - - // Draw the right rectangle. - fill(0, 0, blueValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is royal blue.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a CSS color string. - let c = 'rgb(175, 100, 220)'; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'blueValue' to 220. - let blueValue = blue(c); - - // Draw the right rectangle. - fill(0, 0, blueValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is royal blue.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use RGB color with values in the range 0-100. - colorMode(RGB, 100); - - // Create a p5.Color object using RGB values. - let c = color(69, 39, 86); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'blueValue' to 86. - let blueValue = blue(c); - - // Draw the right rectangle. - fill(0, 0, blueValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is royal blue.'); - } - -
-class: p5 -params: - - name: color - description: | -

p5.Color object, array of - color components, or CSS color string.

- type: 'p5.Color|Number[]|String' -return: - description: the blue value. - type: Number -chainable: false ---- - - -# blue diff --git a/src/content/reference/en/p5 copy/boolean.mdx b/src/content/reference/en/p5 copy/boolean.mdx deleted file mode 100644 index 8eab48af5f..0000000000 --- a/src/content/reference/en/p5 copy/boolean.mdx +++ /dev/null @@ -1,157 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L341 -title: boolean -module: Data -submodule: Conversion -file: src/utilities/conversion.js -description: > -

Converts a String or Number to a - Boolean.

- -

boolean() converts values to true or - false.

- -

The parameter, n, is the value to convert. If n - is a string, then - - boolean('true') will return true and every other - string value will - - return false. If n is a number, then - boolean(0) will return false - - and every other numeric value will return true. If an array is - passed, as - - in boolean([0, 1, 'true', 'blue']), then an array of Boolean - values will - - be returned.

-line: 341 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a number variable. - let original = 0; - - // Convert the number to a Boolean value. - let converted = boolean(original); - - // Style the circle based on the converted value. - if (converted === true) { - fill('blue'); - } else { - fill('red'); - } - - // Draw the circle. - circle(50, 50, 40); - - describe('A red circle on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let original = 'true'; - - // Convert the string to a Boolean value. - let converted = boolean(original); - - // Style the circle based on the converted value. - if (converted === true) { - fill('blue'); - } else { - fill('red'); - } - - // Draw the circle. - circle(50, 50, 40); - - describe('A blue circle on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of values. - let original = [0, 'hi', 123, 'true']; - - // Convert the array to a Boolean values. - let converted = boolean(original); - - // Iterate over the array of converted Boolean values. - for (let i = 0; i < converted.length; i += 1) { - - // Style the circle based on the converted value. - if (converted[i] === true) { - fill('blue'); - } else { - fill('red'); - } - - // Calculate the x-coordinate. - let x = (i + 1) * 20; - - // Draw the circle. - circle(x, 50, 15); - } - - describe( - 'A row of circles on a gray background. The two circles on the left are red and the two on the right are blue.' - ); - } - -
-class: p5 -return: - description: converted Boolean value. - type: Boolean -overloads: - - line: 341 - params: - - name: 'n' - description: | -

value to convert.

- type: String|Boolean|Number - return: - description: converted Boolean value. - type: Boolean - - line: 451 - params: - - name: ns - description: | -

values to convert.

- type: Array - return: - description: converted Boolean values. - type: 'Boolean[]' -chainable: false ---- - - -# boolean diff --git a/src/content/reference/en/p5 copy/box.mdx b/src/content/reference/en/p5 copy/box.mdx deleted file mode 100644 index a4f5282947..0000000000 --- a/src/content/reference/en/p5 copy/box.mdx +++ /dev/null @@ -1,186 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L1009 -title: box -module: Shape -submodule: 3D Primitives -file: src/webgl/3d_primitives.js -description: > -

Draws a box (rectangular prism).

- -

A box is a 3D shape with six faces. Each face makes a 90˚ with four - - neighboring faces.

- -

The first parameter, width, is optional. If a - Number is passed, as in - - box(20), it sets the box’s width and height. By default, - width is 50.

- -

The second parameter, height, is also optional. If a - Number is passed, - - as in box(20, 30), it sets the box’s height. By default, - height is set - - to the box’s width.

- -

The third parameter, depth, is also optional. If a - Number is passed, as - - in box(20, 30, 40), it sets the box’s depth. By default, - depth is set - - to the box’s height.

- -

The fourth parameter, detailX, is also optional. If a - Number is passed, - - as in box(20, 30, 40, 5), it sets the number of triangle - subdivisions to - - use along the x-axis. All 3D shapes are made by connecting triangles to - - form their surfaces. By default, detailX is 1.

- -

The fifth parameter, detailY, is also optional. If a number is - passed, as - - in box(20, 30, 40, 5, 7), it sets the number of triangle - subdivisions to - - use along the y-axis. All 3D shapes are made by connecting triangles to - - form their surfaces. By default, detailY is 1.

- -

Note: box() can only be used in WebGL mode.

-line: 1009 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white box on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white box on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the box. - // Set its width and height to 30. - box(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white box on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the box. - // Set its width to 30 and height to 50. - box(30, 50); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white box on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the box. - // Set its width to 30, height to 50, and depth to 10. - box(30, 50, 10); - } - -
-class: p5 -params: - - name: width - description: | -

width of the box.

- type: Number - optional: true - - name: height - description: | -

height of the box.

- type: Number - optional: true - - name: depth - description: | -

depth of the box.

- type: Number - optional: true - - name: detailX - description: | -

number of triangle subdivisions along the x-axis.

- type: Integer - optional: true - - name: detailY - description: | -

number of triangle subdivisions along the y-axis.

- type: Integer - optional: true -chainable: true ---- - - -# box diff --git a/src/content/reference/en/p5 copy/brightness.mdx b/src/content/reference/en/p5 copy/brightness.mdx deleted file mode 100644 index 2860cbf226..0000000000 --- a/src/content/reference/en/p5 copy/brightness.mdx +++ /dev/null @@ -1,168 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L253 -title: brightness -module: Color -submodule: Creating & Reading -file: src/color/creating_reading.js -description: > -

Gets the brightness value of a color.

- -

brightness() extracts the HSB brightness value from a - - p5.Color object, an array of color - components, or - - a CSS color string.

- -

By default, brightness() returns a color's HSB brightness in - the range 0 - - to 100. If the colorMode() is set to - HSB, it - - returns the brightness value in the given range.

-line: 253 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use HSB color. - colorMode(HSB); - - // Create a p5.Color object. - let c = color(0, 50, 100); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'brightValue' to 100. - let brightValue = brightness(c); - - // Draw the right rectangle. - fill(brightValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is white.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use HSB color. - colorMode(HSB); - - // Create a color array. - let c = [0, 50, 100]; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'brightValue' to 100. - let brightValue = brightness(c); - - // Draw the right rectangle. - fill(brightValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is white.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use HSB color. - colorMode(HSB); - - // Create a CSS color string. - let c = 'rgb(255, 128, 128)'; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'brightValue' to 100. - let brightValue = brightness(c); - - // Draw the right rectangle. - fill(brightValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is white.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use HSB color with values in the range 0-255. - colorMode(HSB, 255); - - // Create a p5.Color object. - let c = color(0, 127, 255); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'brightValue' to 255. - let brightValue = brightness(c); - - // Draw the right rectangle. - fill(brightValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is white.'); - } - -
-class: p5 -params: - - name: color - description: | -

p5.Color object, array of - color components, or CSS color string.

- type: 'p5.Color|Number[]|String' -return: - description: the brightness value. - type: Number -chainable: false ---- - - -# brightness diff --git a/src/content/reference/en/p5 copy/buildGeometry.mdx b/src/content/reference/en/p5 copy/buildGeometry.mdx deleted file mode 100644 index ef58d7b650..0000000000 --- a/src/content/reference/en/p5 copy/buildGeometry.mdx +++ /dev/null @@ -1,263 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L520 -title: buildGeometry -module: Shape -submodule: 3D Primitives -file: src/webgl/3d_primitives.js -description: > -

Creates a custom p5.Geometry object - from - - simpler 3D shapes.

- -

buildGeometry() helps with creating complex 3D shapes from - simpler ones - - such as sphere(). It can help to make - sketches - - more performant. For example, if a complex 3D shape doesn’t change while a - - sketch runs, then it can be created with buildGeometry(). - Creating a - - p5.Geometry object once and then - drawing it - - will run faster than repeatedly drawing the individual pieces.

- -

The parameter, callback, is a function with the drawing - instructions for - - the new p5.Geometry object. It will be - called - - once to create the new 3D shape.

- -

See beginGeometry() and - - endGeometry() for another way to - build 3D - - shapes.

- -

Note: buildGeometry() can only be used in WebGL mode.

-line: 520 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the p5.Geometry object. - shape = buildGeometry(createShape); - - describe('A white cone drawn on a gray background.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the p5.Geometry object. - noStroke(); - - // Draw the p5.Geometry object. - model(shape); - } - - // Create p5.Geometry object from a single cone. - function createShape() { - cone(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the arrow. - shape = buildGeometry(createArrow); - - describe('A white arrow drawn on a gray background.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the arrow. - noStroke(); - - // Draw the arrow. - model(shape); - } - - function createArrow() { - // Add shapes to the p5.Geometry object. - push(); - rotateX(PI); - cone(10); - translate(0, -10, 0); - cylinder(3, 20); - pop(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the p5.Geometry object. - shape = buildGeometry(createArrow); - - describe('Two white arrows drawn on a gray background. The arrow on the right rotates slowly.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the arrows. - noStroke(); - - // Draw the p5.Geometry object. - model(shape); - - // Translate and rotate the coordinate system. - translate(30, 0, 0); - rotateZ(frameCount * 0.01); - - // Draw the p5.Geometry object again. - model(shape); - } - - function createArrow() { - // Add shapes to the p5.Geometry object. - push(); - rotateX(PI); - cone(10); - translate(0, -10, 0); - cylinder(3, 20); - pop(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let button; - let particles; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a button to reset the particle system. - button = createButton('Reset'); - - // Call resetModel() when the user presses the button. - button.mousePressed(resetModel); - - // Add the original set of particles. - resetModel(); - - describe('A set of white spheres on a gray background. The spheres are positioned randomly. Their positions reset when the user presses the Reset button.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the particles. - noStroke(); - - // Draw the particles. - model(particles); - } - - function resetModel() { - // If the p5.Geometry object has already been created, - // free those resources. - if (particles) { - freeGeometry(particles); - } - - // Create a new p5.Geometry object with random spheres. - particles = buildGeometry(createParticles); - } - - function createParticles() { - for (let i = 0; i < 60; i += 1) { - // Calculate random coordinates. - let x = randomGaussian(0, 20); - let y = randomGaussian(0, 20); - let z = randomGaussian(0, 20); - - push(); - // Translate to the particle's coordinates. - translate(x, y, z); - // Draw the particle. - sphere(5); - pop(); - } - } - -
-class: p5 -params: - - name: callback - description: | -

function that draws the shape.

- type: Function -return: - description: new 3D shape. - type: p5.Geometry -chainable: false ---- - - -# buildGeometry diff --git a/src/content/reference/en/p5 copy/byte.mdx b/src/content/reference/en/p5 copy/byte.mdx deleted file mode 100644 index 0a6f3234a4..0000000000 --- a/src/content/reference/en/p5 copy/byte.mdx +++ /dev/null @@ -1,180 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L468 -title: byte -module: Data -submodule: Conversion -file: src/utilities/conversion.js -description: > -

Converts a Boolean, String, or - Number to its byte value.

- -

byte() converts a value to an integer (whole number) between - -128 and - - 127. Values greater than 127 wrap around while negative values are - - unchanged. For example, 128 becomes -128 and -129 remains the same.

- -

The parameter, n, is the value to convert. If n - is a Boolean, as in - - byte(false) or byte(true), the number 0 - (false) or 1 (true) will be - - returned. If n is a string or number, as in - byte('256') or byte(256), - - then the byte value will be returned. Decimal values are ignored. If an - - array is passed, as in byte([true, 123, '456']), then an array of - byte - - values will be returned.

- -

Note: If a value can't be converted to a number, as in - byte('giraffe'), - - then the value NaN (not a number) will be returned.

-line: 468 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a Boolean variable. - let original = true; - - // Convert the Boolean to its byte value. - let converted = byte(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the original and converted values. - text(`${original} : ${converted}`, 50, 50); - - describe('The text "true : 1" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let original = '256'; - - // Convert the string to its byte value. - let converted = byte(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the original and converted values. - text(`${original} : ${converted}`, 50, 50); - - describe('The text "256 : 0" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a number variable. - let original = 256; - - // Convert the number to its byte value. - let converted = byte(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the original and converted values. - text(`${original} : ${converted}`, 50, 50); - - describe('The text "256 : 0" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of values. - let original = [false, '64', 383]; - - // Convert the array elements to their byte values. - let converted = byte(original); - - // Iterate over the converted array elements. - for (let i = 0; i < converted.length; i += 1) { - - // Style the circle. - fill(converted[i]); - - // Calculate the x-coordinate. - let x = (i + 1) * 25; - - // Draw the circle. - circle(x, 50, 20); - } - - describe( - 'Three gray circles on a gray background. The circles get lighter from left to right.' - ); - } - -
-class: p5 -return: - description: converted byte value. - type: Number -overloads: - - line: 468 - params: - - name: 'n' - description: | -

value to convert.

- type: String|Boolean|Number - return: - description: converted byte value. - type: Number - - line: 598 - params: - - name: ns - description: | -

values to convert.

- type: Array - return: - description: converted byte values. - type: 'Number[]' -chainable: false ---- - - -# byte diff --git a/src/content/reference/en/p5 copy/camera.mdx b/src/content/reference/en/p5 copy/camera.mdx deleted file mode 100644 index 55f983385e..0000000000 --- a/src/content/reference/en/p5 copy/camera.mdx +++ /dev/null @@ -1,200 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L13 -title: camera -module: 3D -submodule: Camera -file: src/webgl/p5.Camera.js -description: > -

Sets the position and orientation of the current camera in a 3D sketch.

- -

camera() allows objects to be viewed from different angles. It - has nine - - parameters that are all optional.

- -

The first three parameters, x, y, and - z, are the coordinates of the - - camera’s position. For example, calling camera(0, 0, 0) places - the camera - - at the origin (0, 0, 0). By default, the camera is placed at - - (0, 0, 800).

- -

The next three parameters, centerX, centerY, and - centerZ are the - - coordinates of the point where the camera faces. For example, calling - - camera(0, 0, 0, 10, 20, 30) places the camera at the origin - (0, 0, 0) - - and points it at (10, 20, 30). By default, the camera points at - the - - origin (0, 0, 0).

- -

The last three parameters, upX, upY, and - upZ are the components of - - the "up" vector. The "up" vector orients the camera’s y-axis. For example, - - calling camera(0, 0, 0, 10, 20, 30, 0, -1, 0) places the camera - at the - - origin (0, 0, 0), points it at (10, 20, 30), and - sets the "up" vector - - to (0, -1, 0) which is like holding it upside-down. By default, - the "up" - - vector is (0, 1, 0).

- -

Note: camera() can only be used in WebGL mode.

-line: 13 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Move the camera to the top-right. - camera(200, -400, 800); - - // Draw the box. - box(); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube apperas to sway left and right on a gray background.'); - } - - function draw() { - background(200); - - // Calculate the camera's x-coordinate. - let x = 400 * cos(frameCount * 0.01); - - // Orbit the camera around the box. - camera(x, -400, 800); - - // Draw the box. - box(); - } - -
- -
- - // Adjust the range sliders to change the camera's position. - - let xSlider; - let ySlider; - let zSlider; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create slider objects to set the camera's coordinates. - xSlider = createSlider(-400, 400, 400); - xSlider.position(0, 100); - xSlider.size(100); - ySlider = createSlider(-400, 400, -200); - ySlider.position(0, 120); - ySlider.size(100); - zSlider = createSlider(0, 1600, 800); - zSlider.position(0, 140); - zSlider.size(100); - - describe( - 'A white cube drawn against a gray background. Three range sliders appear beneath the image. The camera position changes when the user moves the sliders.' - ); - } - - function draw() { - background(200); - - // Get the camera's coordinates from the sliders. - let x = xSlider.value(); - let y = ySlider.value(); - let z = zSlider.value(); - - // Move the camera. - camera(x, y, z); - - // Draw the box. - box(); - } - -
-class: p5 -params: - - name: x - description: | -

x-coordinate of the camera. Defaults to 0.

- type: Number - optional: true - - name: 'y' - description: | -

y-coordinate of the camera. Defaults to 0.

- type: Number - optional: true - - name: z - description: | -

z-coordinate of the camera. Defaults to 800.

- type: Number - optional: true - - name: centerX - description: | -

x-coordinate of the point the camera faces. Defaults to 0.

- type: Number - optional: true - - name: centerY - description: | -

y-coordinate of the point the camera faces. Defaults to 0.

- type: Number - optional: true - - name: centerZ - description: | -

z-coordinate of the point the camera faces. Defaults to 0.

- type: Number - optional: true - - name: upX - description: | -

x-component of the camera’s "up" vector. Defaults to 0.

- type: Number - optional: true - - name: upY - description: | -

y-component of the camera’s "up" vector. Defaults to 1.

- type: Number - optional: true - - name: upZ - description: | -

z-component of the camera’s "up" vector. Defaults to 0.

- type: Number - optional: true -chainable: true ---- - - -# camera diff --git a/src/content/reference/en/p5 copy/ceil.mdx b/src/content/reference/en/p5 copy/ceil.mdx deleted file mode 100644 index 45c17468bf..0000000000 --- a/src/content/reference/en/p5 copy/ceil.mdx +++ /dev/null @@ -1,65 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L48 -title: ceil -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Calculates the closest integer value that is greater than or equal to a - - number.

- -

For example, calling ceil(9.03) and ceil(9.97) - both return the value - - 10.

-line: 48 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use RGB color with values from 0 to 1. - colorMode(RGB, 1); - - noStroke(); - - // Draw the left rectangle. - let r = 0.3; - fill(r, 0, 0); - rect(0, 0, 50, 100); - - // Round r up to 1. - r = ceil(r); - - // Draw the right rectangle. - fill(r, 0, 0); - rect(50, 0, 50, 100); - - describe('Two rectangles. The one on the left is dark red and the one on the right is bright red.'); - } - -
-class: p5 -params: - - name: 'n' - description: | -

number to round up.

- type: Number -return: - description: rounded up number. - type: Integer -chainable: false ---- - - -# ceil diff --git a/src/content/reference/en/p5 copy/changed.mdx b/src/content/reference/en/p5 copy/changed.mdx deleted file mode 100644 index 45289630e9..0000000000 --- a/src/content/reference/en/p5 copy/changed.mdx +++ /dev/null @@ -1,87 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L330 -title: changed -module: DOM -submodule: DOM -file: src/dom/dom.js -description: | -

Calls a function when the element changes.

-

Calling myElement.changed(false) disables the function.

-line: 330 -isConstructor: false -itemtype: method -example: - - |- - -
- - let dropdown; - - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a dropdown menu and add a few color options. - dropdown = createSelect(); - dropdown.position(0, 0); - dropdown.option('red'); - dropdown.option('green'); - dropdown.option('blue'); - - // Call paintBackground() when the color option changes. - dropdown.changed(paintBackground); - - describe('A gray square with a dropdown menu at the top. The square changes color when an option is selected.'); - } - - // Paint the background with the selected color. - function paintBackground() { - let c = dropdown.value(); - background(c); - } - -
- -
- - let checkbox; - - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a checkbox and place it beneath the canvas. - checkbox = createCheckbox(' circle'); - checkbox.position(0, 100); - - // Call repaint() when the checkbox changes. - checkbox.changed(repaint); - - describe('A gray square with a checkbox underneath it that says "circle". A white circle appears when the box is checked and disappears otherwise.'); - } - - // Paint the background gray and determine whether to draw a circle. - function repaint() { - background(200); - if (checkbox.checked() === true) { - circle(50, 50, 30); - } - } - -
-class: p5 -params: - - name: fxn - description: | -

function to call when the element changes. - false disables the function.

- type: Function|Boolean -chainable: true ---- - - -# changed diff --git a/src/content/reference/en/p5 copy/char.mdx b/src/content/reference/en/p5 copy/char.mdx deleted file mode 100644 index e01e22a9f7..0000000000 --- a/src/content/reference/en/p5 copy/char.mdx +++ /dev/null @@ -1,152 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L612 -title: char -module: Data -submodule: Conversion -file: src/utilities/conversion.js -description: > -

Converts a Number or String to a single-character - String.

- -

char() converts numbers to their single-character string - representations.

- -

The parameter, n, is the value to convert. If a number is - passed, as in - - char(65), the corresponding single-character string is returned. - If a - - string is passed, as in char('65'), the string is converted to an - integer - - (whole number) and the corresponding single-character string is returned. - - If an array is passed, as in char([65, 66, 67]), an array of - - single-character strings is returned.

- -

See MDN - - for more information about conversions.

-line: 612 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a number variable. - let original = 65; - - // Convert the number to a char. - let converted = char(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the original and converted values. - text(`${original} : ${converted}`, 50, 50); - - describe('The text "65 : A" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let original = '65'; - - // Convert the string to a char. - let converted = char(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the original and converted values. - text(`${original} : ${converted}`, 50, 50); - - describe('The text "65 : A" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of numbers. - let original = ['65', 66, '67']; - - // Convert the string to a char. - let converted = char(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Iterate over elements of the converted array. - for (let i = 0; i < converted.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 25; - - // Display the original and converted values. - text(`${original[i]} : ${converted[i]}`, 50, y); - } - - describe( - 'The text "65 : A", "66 : B", and "67 : C" written on three separate lines. The text is in black on a gray background.' - ); - } - -
-class: p5 -return: - description: converted single-character string. - type: String -overloads: - - line: 612 - params: - - name: 'n' - description: | -

value to convert.

- type: String|Number - return: - description: converted single-character string. - type: String - - line: 716 - params: - - name: ns - description: | -

values to convert.

- type: Array - return: - description: converted single-character strings. - type: 'String[]' -chainable: false ---- - - -# char diff --git a/src/content/reference/en/p5 copy/circle.mdx b/src/content/reference/en/p5 copy/circle.mdx deleted file mode 100644 index 46069bea74..0000000000 --- a/src/content/reference/en/p5 copy/circle.mdx +++ /dev/null @@ -1,77 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L488 -title: circle -module: Shape -submodule: 2D Primitives -file: src/core/shape/2d_primitives.js -description: > -

Draws a circle.

- -

A circle is a round shape defined by the x, y, - and d parameters. - - x and y set the location of its center. - d sets its width and height (diameter). - - Every point on the circle's edge is the same distance, 0.5 * d, - from its center. - - 0.5 * d (half the diameter) is the circle's radius. - - See ellipseMode() for other ways to - set its position.

-line: 488 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - circle(50, 50, 25); - - describe('A white circle with black outline in the middle of a gray canvas.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - circle(0, 0, 25); - - describe('A white circle with black outline in the middle of a gray canvas.'); - } - -
-class: p5 -params: - - name: x - description: | -

x-coordinate of the center of the circle.

- type: Number - - name: 'y' - description: | -

y-coordinate of the center of the circle.

- type: Number - - name: d - description: | -

diameter of the circle.

- type: Number -chainable: true ---- - - -# circle diff --git a/src/content/reference/en/p5 copy/class.mdx b/src/content/reference/en/p5 copy/class.mdx deleted file mode 100644 index 94b64b75c2..0000000000 --- a/src/content/reference/en/p5 copy/class.mdx +++ /dev/null @@ -1,19 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L1329 -title: class -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: "

A template for creating objects of a particular type.

\n

Classes can make it easier to program with objects. For example, a Frog\nclass could create objects that behave like frogs. Each object created\nusing a class is called an instance of that class. All instances of a class\nare the same type. Here's an example of creating an instance of a Frog\nclass:

\n
let fifi = new Frog(50, 50, 20);\n
\n

The variable fifi refers to an instance of the Frog class. The keyword\nnew is used to call the Frog class' constructor in the statement\nnew Frog(). Altogether, a new Frog object was created and assigned to\nthe variable fifi. Classes are templates, so they can be used to create\nmore than one instance:

\n
// First Frog instance.\nlet frog1 = new Frog(25, 50, 10);\n\n// Second Frog instance.\nlet frog2 = new Frog(75, 50, 10);\n
\n

A simple Frog class could be declared as follows:

\n
class Frog {\n  constructor(x, y, size) {\n    // This code runs once when an instance is created.\n    this.x = x;\n    this.y = y;\n    this.size = size;\n  }\n\n  show() {\n    // This code runs once when myFrog.show() is called.\n    textAlign(CENTER, CENTER);\n    textSize(this.size);\n    text('\U0001F438', this.x, this.y);\n  }\n\n  hop() {\n    // This code runs once when myFrog.hop() is called.\n    this.x += random(-10, 10);\n    this.y += random(-10, 10);\n  }\n}\n
\n

Class declarations begin with the keyword class followed by the class\nname, such as Frog, and curly braces {}. Class names should use\nPascalCase and can't have spaces in their names. For example, naming a\nclass Kermit The Frog with spaces between each word would throw a\nSyntaxError. The code between the curly braces {} defines the class.

\n

Functions that belong to a class are called methods. constructor(),\nshow(), and hop() are methods in the Frog class. Methods define an\nobject's behavior. Methods can accept parameters and return values, just\nlike functions. Note that methods don't use the function keyword.

\n

constructor() is a special method that's called once when an instance of\nthe class is created. The statement new Frog() calls the Frog class'\nconstructor() method.

\n

A class definition is a template for instances. The keyword this refers\nto an instance's data and methods. For example, each Frog instance has\nunique coordinates stored in this.x and this.y. The show() method\nuses those coordinates to draw the frog. The hop() method updates those\ncoordinates when called. Once a Frog instance is created, its data and\nmethods can be accessed using the dot operator . as follows:

\n
// Draw a lily pad.\nfill('green');\nstroke('green');\ncircle(fifi.x, fifi.y, 2 * fifi.size);\n\n// Show the Frog.\nfifi.show();\n\n// Hop.\nfifi.hop();\n
\n" -line: 1329 -isConstructor: false -itemtype: property -example: - - "\n
\n\n// Declare a frog variable.\nlet fifi;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variable a new Frog object.\n fifi = new Frog(50, 50, 20);\n\n describe('A frog face drawn on a blue background.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frog.\n fifi.show();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n}\n\n
\n\n
\n\n// Declare two frog variables.\nlet frog1;\nlet frog2;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variables a new Frog object.\n frog1 = new Frog(25, 50, 10);\n frog2 = new Frog(75, 50, 20);\n\n describe('Two frog faces drawn next to each other on a blue background.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frogs.\n frog1.show();\n frog2.show();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n}\n\n
\n\n
\n\n// Declare two frog variables.\nlet frog1;\nlet frog2;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variables a new Frog object.\n frog1 = new Frog(25, 50, 10);\n frog2 = new Frog(75, 50, 20);\n\n // Slow the frame rate.\n frameRate(1);\n\n describe('Two frog faces on a blue background. The frogs hop around randomly.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frogs.\n frog1.show();\n frog2.show();\n\n // Move the frogs.\n frog1.hop();\n frog2.hop();\n\n // Wrap around if they've hopped off the edge.\n frog1.checkEdges();\n frog2.checkEdges();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n\n hop() {\n this.x += random(-10, 10);\n this.y += random(-10, 10);\n }\n\n checkEdges() {\n if (this.x > width) {\n this.x = this.x - width;\n } else if (this.x < 0) {\n this.x = width - this.x;\n }\n\n if (this.y > height) {\n this.y = this.y - height;\n } else if (this.y < 0) {\n this.y = height - this.y;\n }\n }\n}\n\n
\n\n
\n\n// Create an array that will hold frogs.\nlet frogs = [];\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Add Frog objects to the array.\n for (let i = 0; i < 5; i += 1) {\n // Calculate random coordinates and size.\n let x = random(0, 100);\n let y = random(0, 100);\n let s = random(2, 20);\n\n // Create a new Frog object.\n let frog = new Frog(x, y, s);\n\n // Add the Frog to the array.\n frogs.push(frog);\n }\n\n // Slow the frame rate.\n frameRate(1);\n\n describe(\n 'Five frog faces on a blue background. The frogs hop around randomly.'\n );\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n for (let frog of frogs) {\n // Show the frog.\n frog.show();\n\n // Move the frog.\n frog.hop();\n\n // Wrap around if they've hopped off the edge.\n frog.checkEdges();\n }\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n\n hop() {\n this.x += random(-10, 10);\n this.y += random(-10, 10);\n }\n\n checkEdges() {\n if (this.x > width) {\n this.x = this.x - width;\n } else if (this.x < 0) {\n this.x = width - this.x;\n }\n\n if (this.y > height) {\n this.y = this.y - height;\n } else if (this.y < 0) {\n this.y = height - this.y;\n }\n }\n}\n\n
" -class: p5 ---- - - -# class diff --git a/src/content/reference/en/p5 copy/clear.mdx b/src/content/reference/en/p5 copy/clear.mdx deleted file mode 100644 index a096184afc..0000000000 --- a/src/content/reference/en/p5 copy/clear.mdx +++ /dev/null @@ -1,108 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L673 -title: clear -module: Color -submodule: Setting -file: src/color/setting.js -description: > -

Clears the pixels on the canvas.

- -

clear() makes every pixel 100% transparent. Calling - clear() doesn't - - clear objects created by createX() functions such as - - createGraphics(), - - createVideo(), and - - createImg(). These objects will remain - - unchanged after calling clear() and can be redrawn.

- -

In WebGL mode, this function can clear the screen to a specific color. It - - interprets four numeric parameters as normalized RGBA color values. It also - - clears the depth buffer. If you are not using the WebGL renderer, these - - parameters will have no effect.

-line: 673 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - describe('A gray square. White circles are drawn as the user moves the mouse. The circles disappear when the user presses the mouse.'); - } - - function draw() { - circle(mouseX, mouseY, 20); - } - - function mousePressed() { - clear(); - background(200); - } - -
- -
- - let pg; - - function setup() { - createCanvas(100, 100); - background(200); - - pg = createGraphics(60, 60); - pg.background(200); - pg.noStroke(); - pg.circle(pg.width / 2, pg.height / 2, 15); - image(pg, 20, 20); - - describe('A white circle drawn on a gray square. The square gets smaller when the mouse is pressed.'); - } - - function mousePressed() { - clear(); - image(pg, 20, 20); - } - -
-class: p5 -params: - - name: r - description: | -

normalized red value.

- type: Number - optional: true - - name: g - description: | -

normalized green value.

- type: Number - optional: true - - name: b - description: | -

normalized blue value.

- type: Number - optional: true - - name: a - description: | -

normalized alpha value.

- type: Number - optional: true -chainable: true ---- - - -# clear diff --git a/src/content/reference/en/p5 copy/clearDepth.mdx b/src/content/reference/en/p5 copy/clearDepth.mdx deleted file mode 100644 index 25425d1920..0000000000 --- a/src/content/reference/en/p5 copy/clearDepth.mdx +++ /dev/null @@ -1,113 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L635 -title: clearDepth -module: Rendering -submodule: Rendering -file: src/core/rendering.js -description: > -

Clears the depth buffer in WebGL mode.

- -

clearDepth() clears information about how far objects are from - the camera - - in 3D space. This information is stored in an object called the - - depth buffer. Clearing the depth buffer ensures new objects aren't - drawn - - behind old ones. Doing so can be useful for feedback effects in which the - - previous frame serves as the background for the current frame.

- -

The parameter, depth, is optional. If a number is passed, as - in - - clearDepth(0.5), it determines the range of objects to clear from - the - - depth buffer. 0 doesn't clear any depth information, 0.5 clears depth - - information halfway between the near and far clipping planes, and 1 clears - - depth information all the way to the far clipping plane. By default, - - depth is 1.

- -

Note: clearDepth() can only be used in WebGL mode.

-line: 635 -isConstructor: false -itemtype: method -example: - - |- - -
- - let previous; - let current; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the p5.Framebuffer objects. - previous = createFramebuffer({ format: FLOAT }); - current = createFramebuffer({ format: FLOAT }); - - describe( - 'A multicolor box drifts from side to side on a white background. It leaves a trail that fades over time.' - ); - } - - function draw() { - // Swap the previous p5.Framebuffer and the - // current one so it can be used as a texture. - [previous, current] = [current, previous]; - - // Start drawing to the current p5.Framebuffer. - current.begin(); - - // Paint the background. - background(255); - - // Draw the previous p5.Framebuffer. - // Clear the depth buffer so the previous - // frame doesn't block the current one. - push(); - tint(255, 250); - image(previous, -50, -50); - clearDepth(); - pop(); - - // Draw the box on top of the previous frame. - push(); - let x = 25 * sin(frameCount * 0.01); - let y = 25 * sin(frameCount * 0.02); - translate(x, y, 0); - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - normalMaterial(); - box(12); - pop(); - - // Stop drawing to the current p5.Framebuffer. - current.end(); - - // Display the current p5.Framebuffer. - image(current, -50, -50); - } - -
-class: p5 -params: - - name: depth - description: | -

amount of the depth buffer to clear between 0 - (none) and 1 (far clipping plane). Defaults to 1.

- type: Number - optional: true -chainable: false ---- - - -# clearDepth diff --git a/src/content/reference/en/p5 copy/clearStorage.mdx b/src/content/reference/en/p5 copy/clearStorage.mdx deleted file mode 100644 index d2c89e63bf..0000000000 --- a/src/content/reference/en/p5 copy/clearStorage.mdx +++ /dev/null @@ -1,81 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/data/local_storage.js#L313 -title: clearStorage -module: Data -submodule: LocalStorage -file: src/data/local_storage.js -description: > -

Removes all items in the web browser's local storage.

- -

Web browsers can save small amounts of data using the built-in - - localStorage object. - - Data stored in localStorage can be retrieved at any point, even - after - - refreshing a page or restarting the browser. Data are stored as key-value - - pairs. Calling clearStorage() removes all data from - localStorage.

- -

Note: Sensitive data such as passwords or personal information shouldn't be - - stored in localStorage.

-line: 313 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Double-click to clear localStorage. - - function setup() { - createCanvas(100, 100); - - // Store the player's name. - storeItem('name', 'Feist'); - - // Store the player's score. - storeItem('score', 1234); - - describe( - 'The text "Feist: 1234" written in black on a gray background. The text "null: null" appears when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(14); - - // Retrieve the name. - let name = getItem('name'); - - // Retrieve the score. - let score = getItem('score'); - - // Display the score. - text(`${name}: ${score}`, 50, 50); - } - - // Clear localStorage when the user double-clicks. - function doubleClicked() { - clearStorage(); - } - -
-class: p5 -chainable: false ---- - - -# clearStorage diff --git a/src/content/reference/en/p5 copy/clip.mdx b/src/content/reference/en/p5 copy/clip.mdx deleted file mode 100644 index ae72687f03..0000000000 --- a/src/content/reference/en/p5 copy/clip.mdx +++ /dev/null @@ -1,225 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L222 -title: clip -module: Color -submodule: Setting -file: src/color/setting.js -description: > -

Defines a shape that will mask any shapes drawn afterward.

- -

The first parameter, callback, is a function that defines the - mask. - - Any shapes drawn in callback will add to the mask shape. The - mask - - will apply to anything drawn after clip() is called.

- -

The second parameter, options, is optional. If an object with - an invert - - property is passed, as in beginClip({ invert: true }), it will be - used to - - set the masking mode. { invert: true } inverts the mask, creating - holes - - in shapes that are masked. invert is false by - default.

- -

Masks can be contained between the - - push() and pop() functions. - - Doing so allows unmasked shapes to be drawn after masked shapes.

- -

Masks can also be defined with beginClip() - - and endClip().

-line: 222 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a mask. - clip(mask); - - // Draw a backing shape. - square(5, 5, 45); - - describe('A white triangle and circle on a gray background.'); - } - - // Declare a function that defines the mask. - function mask() { - triangle(15, 37, 30, 13, 43, 37); - circle(45, 45, 7); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an inverted mask. - clip(mask, { invert: true }); - - // Draw a backing shape. - square(5, 5, 45); - - describe('A white square at the top-left corner of a gray square. The white square has a triangle and a circle cut out of it.'); - } - - // Declare a function that defines the mask. - function mask() { - triangle(15, 37, 30, 13, 43, 37); - circle(45, 45, 7); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - noStroke(); - - // Draw a masked shape. - push(); - // Create a mask. - clip(mask); - - // Draw a backing shape. - square(5, 5, 45); - pop(); - - // Translate the origin to the center. - translate(50, 50); - - // Draw an inverted masked shape. - push(); - // Create an inverted mask. - clip(mask, { invert: true }); - - // Draw a backing shape. - square(5, 5, 45); - pop(); - - describe('In the top left, a white triangle and circle. In the bottom right, a white square with a triangle and circle cut out of it.'); - } - - // Declare a function that defines the mask. - function mask() { - triangle(15, 37, 30, 13, 43, 37); - circle(45, 45, 7); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A silhouette of a rotating torus colored fuchsia.'); - } - - function draw() { - background(200); - - // Create a mask. - clip(mask); - - // Draw a backing shape. - noStroke(); - fill('fuchsia'); - plane(100); - } - - // Declare a function that defines the mask. - function mask() { - push(); - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - scale(0.5); - torus(30, 15); - pop(); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A silhouette of a rotating torus colored with a gradient from cyan to purple.'); - } - - function draw() { - background(200); - - // Create a mask. - clip(mask); - - // Draw a backing shape. - noStroke(); - beginShape(QUAD_STRIP); - fill(0, 255, 255); - vertex(-width / 2, -height / 2); - vertex(width / 2, -height / 2); - fill(100, 0, 100); - vertex(-width / 2, height / 2); - vertex(width / 2, height / 2); - endShape(); - } - - // Declare a function that defines the mask. - function mask() { - push(); - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - scale(0.5); - torus(30, 15); - pop(); - } - -
-class: p5 -params: - - name: callback - description: | -

a function that draws the mask shape.

- type: Function - - name: options - description: | -

an object containing clip settings.

- type: Object - optional: true -chainable: false ---- - - -# clip diff --git a/src/content/reference/en/p5 copy/color.mdx b/src/content/reference/en/p5 copy/color.mdx deleted file mode 100644 index ad2bdbd8da..0000000000 --- a/src/content/reference/en/p5 copy/color.mdx +++ /dev/null @@ -1,349 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L398 -title: color -module: Color -submodule: Creating & Reading -file: src/color/creating_reading.js -description: > -

Creates a p5.Color object.

- -

By default, the parameters are interpreted as RGB values. Calling - - color(255, 204, 0) will return a bright yellow color. The way - these - - parameters are interpreted may be changed with the - - colorMode() function.

- -

The version of color() with one parameter interprets the value - one of two - - ways. If the parameter is a number, it's interpreted as a grayscale value. - - If the parameter is a string, it's interpreted as a CSS color string.

- -

The version of color() with two parameters interprets the - first one as a - - grayscale value. The second parameter sets the alpha (transparency) value.

- -

The version of color() with three parameters interprets them - as RGB, HSB, - - or HSL colors, depending on the current colorMode().

- -

The version of color() with four parameters interprets them as - RGBA, HSBA, - - or HSLA colors, depending on the current colorMode(). The last - parameter - - sets the alpha (transparency) value.

-line: 398 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object using RGB values. - let c = color(255, 204, 0); - - // Draw the square. - fill(c); - noStroke(); - square(30, 20, 55); - - describe('A yellow square on a gray canvas.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object using RGB values. - let c1 = color(255, 204, 0); - - // Draw the left circle. - fill(c1); - noStroke(); - circle(25, 25, 80); - - // Create a p5.Color object using a grayscale value. - let c2 = color(65); - - // Draw the right circle. - fill(c2); - circle(75, 75, 80); - - describe( - 'Two circles on a gray canvas. The circle in the top-left corner is yellow and the one at the bottom-right is gray.' - ); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object using a named color. - let c = color('magenta'); - - // Draw the square. - fill(c); - noStroke(); - square(20, 20, 60); - - describe('A magenta square on a gray canvas.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object using a hex color code. - let c1 = color('#0f0'); - - // Draw the left rectangle. - fill(c1); - noStroke(); - rect(0, 10, 45, 80); - - // Create a p5.Color object using a hex color code. - let c2 = color('#00ff00'); - - // Draw the right rectangle. - fill(c2); - rect(55, 10, 45, 80); - - describe('Two bright green rectangles on a gray canvas.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object using a RGB color string. - let c1 = color('rgb(0, 0, 255)'); - - // Draw the top-left square. - fill(c1); - square(10, 10, 35); - - // Create a p5.Color object using a RGB color string. - let c2 = color('rgb(0%, 0%, 100%)'); - - // Draw the top-right square. - fill(c2); - square(55, 10, 35); - - // Create a p5.Color object using a RGBA color string. - let c3 = color('rgba(0, 0, 255, 1)'); - - // Draw the bottom-left square. - fill(c3); - square(10, 55, 35); - - // Create a p5.Color object using a RGBA color string. - let c4 = color('rgba(0%, 0%, 100%, 1)'); - - // Draw the bottom-right square. - fill(c4); - square(55, 55, 35); - - describe('Four blue squares in the corners of a gray canvas.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object using a HSL color string. - let c1 = color('hsl(160, 100%, 50%)'); - - // Draw the left rectangle. - noStroke(); - fill(c1); - rect(0, 10, 45, 80); - - // Create a p5.Color object using a HSLA color string. - let c2 = color('hsla(160, 100%, 50%, 0.5)'); - - // Draw the right rectangle. - fill(c2); - rect(55, 10, 45, 80); - - describe('Two sea green rectangles. A darker rectangle on the left and a brighter one on the right.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object using a HSB color string. - let c1 = color('hsb(160, 100%, 50%)'); - - // Draw the left rectangle. - noStroke(); - fill(c1); - rect(0, 10, 45, 80); - - // Create a p5.Color object using a HSBA color string. - let c2 = color('hsba(160, 100%, 50%, 0.5)'); - - // Draw the right rectangle. - fill(c2); - rect(55, 10, 45, 80); - - describe('Two green rectangles. A darker rectangle on the left and a brighter one on the right.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object using RGB values. - let c1 = color(50, 55, 100); - - // Draw the left rectangle. - fill(c1); - rect(0, 10, 45, 80); - - // Switch the color mode to HSB. - colorMode(HSB, 100); - - // Create a p5.Color object using HSB values. - let c2 = color(50, 55, 100); - - // Draw the right rectangle. - fill(c2); - rect(55, 10, 45, 80); - - describe('Two blue rectangles. A darker rectangle on the left and a brighter one on the right.'); - } - -
-class: p5 -return: - description: resulting color. - type: p5.Color -overloads: - - line: 398 - params: - - name: gray - description: | -

number specifying value between white and black.

- type: Number - - name: alpha - description: | -

alpha value relative to current color range - (default is 0-255).

- type: Number - optional: true - return: - description: resulting color. - type: p5.Color - - line: 652 - params: - - name: v1 - description: | -

red or hue value relative to - the current color range.

- type: Number - - name: v2 - description: | -

green or saturation value - relative to the current color range.

- type: Number - - name: v3 - description: | -

blue or brightness value - relative to the current color range.

- type: Number - - name: alpha - description: '' - type: Number - optional: true - return: - description: '' - type: p5.Color - - line: 664 - params: - - name: value - description: | -

a color string.

- type: String - return: - description: '' - type: p5.Color - - line: 670 - params: - - name: values - description: | -

an array containing the red, green, blue, - and alpha components of the color.

- type: 'Number[]' - return: - description: '' - type: p5.Color - - line: 677 - params: - - name: color - description: '' - type: p5.Color - return: - description: '' - type: p5.Color -chainable: false ---- - - -# color diff --git a/src/content/reference/en/p5 copy/colorMode.mdx b/src/content/reference/en/p5 copy/colorMode.mdx deleted file mode 100644 index b4aca3c9ce..0000000000 --- a/src/content/reference/en/p5 copy/colorMode.mdx +++ /dev/null @@ -1,271 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L751 -title: colorMode -module: Color -submodule: Setting -file: src/color/setting.js -description: > -

Changes the way color values are interpreted.

- -

By default, the Number parameters for fill(), - - stroke(), - - background(), and - - color() are defined by values between 0 and - 255 - - using the RGB color model. This is equivalent to calling - - colorMode(RGB, 255). Pure red is color(255, 0, 0) in - this model.

- -

Calling colorMode(RGB, 100) sets colors to use RGB color - values - - between 0 and 100. Pure red is color(100, 0, 0) in this - model.

- -

Calling colorMode(HSB) or colorMode(HSL) changes - to HSB or HSL system - - instead of RGB. Pure red is color(0, 100, 100) in HSB and - - color(0, 100, 50) in HSL.

- -

p5.Color objects remember the mode - that they were - - created in. Changing modes doesn't affect their appearance.

-line: 751 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Fill with pure red. - fill(255, 0, 0); - - circle(50, 50, 25); - - describe('A gray square with a red circle at its center.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use RGB color with values in the range 0-100. - colorMode(RGB, 100); - - // Fill with pure red. - fill(100, 0, 0); - - circle(50, 50, 25); - - describe('A gray square with a red circle at its center.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use HSB color. - colorMode(HSB); - - // Fill with pure red. - fill(0, 100, 100); - - circle(50, 50, 25); - - describe('A gray square with a red circle at its center.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use HSL color. - colorMode(HSL); - - // Fill with pure red. - fill(0, 100, 50); - - circle(50, 50, 25); - - describe('A gray square with a red circle at its center.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - // Use RGB color with values in the range 0-100. - colorMode(RGB, 100); - - for (let x = 0; x < 100; x += 1) { - for (let y = 0; y < 100; y += 1) { - stroke(x, y, 0); - point(x, y); - } - } - - describe( - 'A diagonal green to red gradient from bottom-left to top-right with shading transitioning to black at top-left corner.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Use HSB color with values in the range 0-100. - colorMode(HSB, 100); - - for (let x = 0; x < 100; x += 1) { - for (let y = 0; y < 100; y += 1) { - stroke(x, y, 100); - point(x, y); - } - } - - describe('A rainbow gradient from left-to-right. Brightness transitions to white at the top.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Create a p5.Color object. - let myColor = color(180, 175, 230); - background(myColor); - - // Use RGB color with values in the range 0-1. - colorMode(RGB, 1); - - // Get the red, green, and blue color components. - let redValue = red(myColor); - let greenValue = green(myColor); - let blueValue = blue(myColor); - - // Round the color components for display. - redValue = round(redValue, 2); - greenValue = round(greenValue, 2); - blueValue = round(blueValue, 2); - - // Display the color components. - text(`Red: ${redValue}`, 10, 10, 80, 80); - text(`Green: ${greenValue}`, 10, 40, 80, 80); - text(`Blue: ${blueValue}`, 10, 70, 80, 80); - - describe('A purple canvas with the red, green, and blue decimal values of the color written on it.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(255); - - // Use RGB color with alpha values in the range 0-1. - colorMode(RGB, 255, 255, 255, 1); - - noFill(); - strokeWeight(4); - stroke(255, 0, 10, 0.3); - circle(40, 40, 50); - circle(50, 60, 50); - - describe('Two overlapping translucent pink circle outlines.'); - } - -
-class: p5 -overloads: - - line: 751 - params: - - name: mode - description: | -

either RGB, HSB or HSL, corresponding to - Red/Green/Blue and Hue/Saturation/Brightness - (or Lightness).

- type: Constant - - name: max - description: | -

range for all values.

- type: Number - optional: true - chainable: 1 - - line: 956 - params: - - name: mode - description: '' - type: Constant - - name: max1 - description: | -

range for the red or hue depending on the - current color mode.

- type: Number - - name: max2 - description: | -

range for the green or saturation depending - on the current color mode.

- type: Number - - name: max3 - description: | -

range for the blue or brightness/lightness - depending on the current color mode.

- type: Number - - name: maxA - description: | -

range for the alpha.

- type: Number - optional: true - chainable: 1 -chainable: true ---- - - -# colorMode diff --git a/src/content/reference/en/p5 copy/concat.mdx b/src/content/reference/en/p5 copy/concat.mdx deleted file mode 100644 index 1e83bf84c0..0000000000 --- a/src/content/reference/en/p5 copy/concat.mdx +++ /dev/null @@ -1,54 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L112 -title: concat -module: Data -submodule: Array Functions -file: src/utilities/array_functions.js -description: | -

Concatenates two arrays, maps to Array.concat(). Does not modify the - input arrays.

-line: 112 -deprecated: >- - Use arr1.concat(arr2) - instead. -isConstructor: false -itemtype: method -example: - - |- - -
- function setup() { - let arr1 = ['A', 'B', 'C']; - let arr2 = [1, 2, 3]; - - print(arr1); // ['A','B','C'] - print(arr2); // [1,2,3] - - let arr3 = concat(arr1, arr2); - - print(arr1); // ['A','B','C'] - print(arr2); // [1, 2, 3] - print(arr3); // ['A','B','C', 1, 2, 3] - } -
-class: p5 -params: - - name: a - description: | -

first Array to concatenate

- type: Array - - name: b - description: | -

second Array to concatenate

- type: Array -return: - description: concatenated array - type: Array -chainable: false ---- - - -# concat diff --git a/src/content/reference/en/p5 copy/cone.mdx b/src/content/reference/en/p5 copy/cone.mdx deleted file mode 100644 index ff0756d0a5..0000000000 --- a/src/content/reference/en/p5 copy/cone.mdx +++ /dev/null @@ -1,265 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L1730 -title: cone -module: Shape -submodule: 3D Primitives -file: src/webgl/3d_primitives.js -description: > -

Draws a cone.

- -

A cone is a 3D shape with triangular faces that connect a flat bottom to a - - single point. Cones with few faces look like pyramids. Cones with many - - faces have smooth surfaces.

- -

The first parameter, radius, is optional. If a - Number is passed, as in - - cone(20), it sets the radius of the cone’s base. By default, - radius is - - 50.

- -

The second parameter, height, is also optional. If a - Number is passed, - - as in cone(20, 30), it sets the cone’s height. By default, - height is - - set to the cone’s radius.

- -

The third parameter, detailX, is also optional. If a - Number is passed, - - as in cone(20, 30, 5), it sets the number of edges used to form - the - - cone's base. Using more edges makes the base look more like a circle. By - - default, detailX is 24.

- -

The fourth parameter, detailY, is also optional. If a - Number is passed, - - as in cone(20, 30, 5, 7), it sets the number of triangle - subdivisions to - - use along the y-axis connecting the base to the tip. All 3D shapes are made - - by connecting triangles to form their surfaces. By default, - detailY is 1.

- -

The fifth parameter, cap, is also optional. If a - false is passed, as - - in cone(20, 30, 5, 7, false) the cone’s base won’t be drawn. By - default, - - cap is true.

- -

Note: cone() can only be used in WebGL mode.

-line: 1730 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cone on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cone. - cone(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cone on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cone. - // Set its radius and height to 30. - cone(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cone on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cone. - // Set its radius to 30 and height to 50. - cone(30, 50); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cone on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cone. - // Set its radius to 30 and height to 50. - // Set its detailX to 5. - cone(30, 50, 5); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white pyramid on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cone. - // Set its radius to 30 and height to 50. - // Set its detailX to 5. - cone(30, 50, 5); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cone on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cone. - // Set its radius to 30 and height to 50. - // Set its detailX to 24 and detailY to 2. - cone(30, 50, 24, 2); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cone on a gray background. Its base is missing.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cone. - // Set its radius to 30 and height to 50. - // Set its detailX to 24 and detailY to 1. - // Don't draw its base. - cone(30, 50, 24, 1, false); - } - -
-class: p5 -params: - - name: radius - description: | -

radius of the cone's base. Defaults to 50.

- type: Number - optional: true - - name: height - description: | -

height of the cone. Defaults to the value of radius.

- type: Number - optional: true - - name: detailX - description: | -

number of edges used to draw the base. Defaults to 24.

- type: Integer - optional: true - - name: detailY - description: | -

number of triangle subdivisions along the y-axis. Defaults to 1.

- type: Integer - optional: true - - name: cap - description: | -

whether to draw the cone's base. Defaults to true.

- type: Boolean - optional: true -chainable: true ---- - - -# cone diff --git a/src/content/reference/en/p5 copy/console.mdx b/src/content/reference/en/p5 copy/console.mdx deleted file mode 100644 index 411b08357e..0000000000 --- a/src/content/reference/en/p5 copy/console.mdx +++ /dev/null @@ -1,99 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L1988 -title: console -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: > -

Prints a message to the web browser's console.

- -

The console - - object is helpful for printing messages while debugging. For example, it's - - common to add a console.log() statement while studying how a - section of - - code works:

- -
if (isPlaying === true) {
-    // Add a console.log() statement to make sure this block of code runs.
-    console.log('Got here!');
-
-    // Game logic.
-  }
-
-  
- -

console.error() is helpful for tracking errors because it - prints - - formatted messages. For example, it's common to encounter errors when - - loading media assets:

- -
// Logs an error message with special
-  formatting.
-
-  function handleFailure(error) {
-    console.error('Oops!', error);
-  }
-
-
-  // Try to load an image and call handleError() if it fails.
-
-  loadImage('https://example.com/cat.jpg', handleImage, handleError);
-
-  
-line: 1988 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - noCanvas(); - - // Prints "Hello!" to the console. - console.log('Hello!'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Try to load an image from a fake URL. - // Call handleError() if the image fails to load. - loadImage('https://example.com/cat.jpg', handleImage, handleError); - } - - // Displays the image. - function handleImage(img) { - image(img, 0, 0); - - describe('A cat on a gray background.'); - } - - // Prints the error. - function handleError(error) { - console.error('Oops!', error); - - describe('A gray square.'); - } - -
-class: p5 ---- - - -# console diff --git a/src/content/reference/en/p5 copy/constants/ADD.mdx b/src/content/reference/en/p5 copy/constants/ADD.mdx deleted file mode 100644 index 9148f688e9..0000000000 --- a/src/content/reference/en/p5 copy/constants/ADD.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L905 -title: ADD -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 905 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# ADD diff --git a/src/content/reference/en/p5 copy/constants/ALT.mdx b/src/content/reference/en/p5 copy/constants/ALT.mdx deleted file mode 100644 index a039e3919b..0000000000 --- a/src/content/reference/en/p5 copy/constants/ALT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L820 -title: ALT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 820 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# ALT diff --git a/src/content/reference/en/p5 copy/constants/ARROW.mdx b/src/content/reference/en/p5 copy/constants/ARROW.mdx deleted file mode 100644 index d2a0e065a1..0000000000 --- a/src/content/reference/en/p5 copy/constants/ARROW.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L55 -title: ARROW -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 55 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# ARROW diff --git a/src/content/reference/en/p5 copy/constants/AUTO.mdx b/src/content/reference/en/p5 copy/constants/AUTO.mdx deleted file mode 100644 index 185fb15902..0000000000 --- a/src/content/reference/en/p5 copy/constants/AUTO.mdx +++ /dev/null @@ -1,25 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L810 -title: AUTO -module: Constants -submodule: Constants -file: src/core/constants.js -description: > -

AUTO allows us to automatically set the width or height of an element (but - not both), - - based on the current height and width of the element. Only one parameter can - - be passed to the size function as - AUTO, at a time.

-line: 810 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# AUTO diff --git a/src/content/reference/en/p5 copy/constants/AXES.mdx b/src/content/reference/en/p5 copy/constants/AXES.mdx deleted file mode 100644 index c6f60b6b89..0000000000 --- a/src/content/reference/en/p5 copy/constants/AXES.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1171 -title: AXES -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1171 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# AXES diff --git a/src/content/reference/en/p5 copy/constants/BACKSPACE.mdx b/src/content/reference/en/p5 copy/constants/BACKSPACE.mdx deleted file mode 100644 index ee299ffcff..0000000000 --- a/src/content/reference/en/p5 copy/constants/BACKSPACE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L826 -title: BACKSPACE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 826 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# BACKSPACE diff --git a/src/content/reference/en/p5 copy/constants/BASELINE.mdx b/src/content/reference/en/p5 copy/constants/BASELINE.mdx deleted file mode 100644 index 200aa201ec..0000000000 --- a/src/content/reference/en/p5 copy/constants/BASELINE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L675 -title: BASELINE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 675 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# BASELINE diff --git a/src/content/reference/en/p5 copy/constants/BEVEL.mdx b/src/content/reference/en/p5 copy/constants/BEVEL.mdx deleted file mode 100644 index a4af3693f7..0000000000 --- a/src/content/reference/en/p5 copy/constants/BEVEL.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L777 -title: BEVEL -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 777 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# BEVEL diff --git a/src/content/reference/en/p5 copy/constants/BEZIER.mdx b/src/content/reference/en/p5 copy/constants/BEZIER.mdx deleted file mode 100644 index b2993b2c33..0000000000 --- a/src/content/reference/en/p5 copy/constants/BEZIER.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1073 -title: BEZIER -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1073 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# BEZIER diff --git a/src/content/reference/en/p5 copy/constants/BLEND.mdx b/src/content/reference/en/p5 copy/constants/BLEND.mdx deleted file mode 100644 index bf367f05eb..0000000000 --- a/src/content/reference/en/p5 copy/constants/BLEND.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L893 -title: BLEND -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 893 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# BLEND diff --git a/src/content/reference/en/p5 copy/constants/BLUR.mdx b/src/content/reference/en/p5 copy/constants/BLUR.mdx deleted file mode 100644 index 5580994e74..0000000000 --- a/src/content/reference/en/p5 copy/constants/BLUR.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1019 -title: BLUR -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1019 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# BLUR diff --git a/src/content/reference/en/p5 copy/constants/BOLD.mdx b/src/content/reference/en/p5 copy/constants/BOLD.mdx deleted file mode 100644 index 6069c955e8..0000000000 --- a/src/content/reference/en/p5 copy/constants/BOLD.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1036 -title: BOLD -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1036 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# BOLD diff --git a/src/content/reference/en/p5 copy/constants/BOLDITALIC.mdx b/src/content/reference/en/p5 copy/constants/BOLDITALIC.mdx deleted file mode 100644 index 2967579a9c..0000000000 --- a/src/content/reference/en/p5 copy/constants/BOLDITALIC.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1041 -title: BOLDITALIC -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1041 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# BOLDITALIC diff --git a/src/content/reference/en/p5 copy/constants/BOTTOM.mdx b/src/content/reference/en/p5 copy/constants/BOTTOM.mdx deleted file mode 100644 index b01ded11ea..0000000000 --- a/src/content/reference/en/p5 copy/constants/BOTTOM.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L670 -title: BOTTOM -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 670 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# BOTTOM diff --git a/src/content/reference/en/p5 copy/constants/BURN.mdx b/src/content/reference/en/p5 copy/constants/BURN.mdx deleted file mode 100644 index 7ba3764dac..0000000000 --- a/src/content/reference/en/p5 copy/constants/BURN.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L976 -title: BURN -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 976 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# BURN diff --git a/src/content/reference/en/p5 copy/constants/CENTER.mdx b/src/content/reference/en/p5 copy/constants/CENTER.mdx deleted file mode 100644 index cab0205cef..0000000000 --- a/src/content/reference/en/p5 copy/constants/CENTER.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L660 -title: CENTER -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 660 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# CENTER diff --git a/src/content/reference/en/p5 copy/constants/CHAR.mdx b/src/content/reference/en/p5 copy/constants/CHAR.mdx deleted file mode 100644 index 564855787a..0000000000 --- a/src/content/reference/en/p5 copy/constants/CHAR.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1046 -title: CHAR -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1046 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# CHAR diff --git a/src/content/reference/en/p5 copy/constants/CHORD.mdx b/src/content/reference/en/p5 copy/constants/CHORD.mdx deleted file mode 100644 index 40896bb3a1..0000000000 --- a/src/content/reference/en/p5 copy/constants/CHORD.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L750 -title: CHORD -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 750 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# CHORD diff --git a/src/content/reference/en/p5 copy/constants/CLAMP.mdx b/src/content/reference/en/p5 copy/constants/CLAMP.mdx deleted file mode 100644 index 977b02599d..0000000000 --- a/src/content/reference/en/p5 copy/constants/CLAMP.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1126 -title: CLAMP -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1126 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# CLAMP diff --git a/src/content/reference/en/p5 copy/constants/CLOSE.mdx b/src/content/reference/en/p5 copy/constants/CLOSE.mdx deleted file mode 100644 index 34bc946fe5..0000000000 --- a/src/content/reference/en/p5 copy/constants/CLOSE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L740 -title: CLOSE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 740 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# CLOSE diff --git a/src/content/reference/en/p5 copy/constants/CONTAIN.mdx b/src/content/reference/en/p5 copy/constants/CONTAIN.mdx deleted file mode 100644 index 59d56be350..0000000000 --- a/src/content/reference/en/p5 copy/constants/CONTAIN.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1188 -title: CONTAIN -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1188 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# CONTAIN diff --git a/src/content/reference/en/p5 copy/constants/CONTROL.mdx b/src/content/reference/en/p5 copy/constants/CONTROL.mdx deleted file mode 100644 index d620bb502d..0000000000 --- a/src/content/reference/en/p5 copy/constants/CONTROL.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L831 -title: CONTROL -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 831 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# CONTROL diff --git a/src/content/reference/en/p5 copy/constants/CORNER.mdx b/src/content/reference/en/p5 copy/constants/CORNER.mdx deleted file mode 100644 index e8b5eced3e..0000000000 --- a/src/content/reference/en/p5 copy/constants/CORNER.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L635 -title: CORNER -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 635 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# CORNER diff --git a/src/content/reference/en/p5 copy/constants/CORNERS.mdx b/src/content/reference/en/p5 copy/constants/CORNERS.mdx deleted file mode 100644 index 85e4226b1e..0000000000 --- a/src/content/reference/en/p5 copy/constants/CORNERS.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L640 -title: CORNERS -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 640 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# CORNERS diff --git a/src/content/reference/en/p5 copy/constants/COVER.mdx b/src/content/reference/en/p5 copy/constants/COVER.mdx deleted file mode 100644 index 3714b4bec3..0000000000 --- a/src/content/reference/en/p5 copy/constants/COVER.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1194 -title: COVER -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1194 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# COVER diff --git a/src/content/reference/en/p5 copy/constants/CROSS.mdx b/src/content/reference/en/p5 copy/constants/CROSS.mdx deleted file mode 100644 index eba1238e34..0000000000 --- a/src/content/reference/en/p5 copy/constants/CROSS.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L60 -title: CROSS -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 60 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# CROSS diff --git a/src/content/reference/en/p5 copy/constants/CURVE.mdx b/src/content/reference/en/p5 copy/constants/CURVE.mdx deleted file mode 100644 index 3e46bf2151..0000000000 --- a/src/content/reference/en/p5 copy/constants/CURVE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1078 -title: CURVE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1078 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# CURVE diff --git a/src/content/reference/en/p5 copy/constants/DARKEST.mdx b/src/content/reference/en/p5 copy/constants/DARKEST.mdx deleted file mode 100644 index b86d06dec4..0000000000 --- a/src/content/reference/en/p5 copy/constants/DARKEST.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L913 -title: DARKEST -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 913 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# DARKEST diff --git a/src/content/reference/en/p5 copy/constants/DEGREES.mdx b/src/content/reference/en/p5 copy/constants/DEGREES.mdx deleted file mode 100644 index c259f456ad..0000000000 --- a/src/content/reference/en/p5 copy/constants/DEGREES.mdx +++ /dev/null @@ -1,59 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L547 -title: DEGREES -module: Constants -submodule: Constants -file: src/core/constants.js -description: > -

A String constant that's used to set the - - angleMode().

- -

By default, functions such as rotate() - and - - sin() expect angles measured in units of - radians. - - Calling angleMode(DEGREES) ensures that angles are measured in - units of - - degrees.

- -

Note: TWO_PI radians equals 360˚.

-line: 547 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw a red arc from 0 to HALF_PI radians. - fill(255, 0, 0); - arc(50, 50, 80, 80, 0, HALF_PI); - - // Use degrees. - angleMode(DEGREES); - - // Draw a blue arc from 90˚ to 180˚. - fill(0, 0, 255); - arc(50, 50, 80, 80, 90, 180); - - describe('The bottom half of a circle drawn on a gray background. The bottom-right quarter is red. The bottom-left quarter is blue.'); - } - -
-class: p5 -type: String ---- - - -# DEGREES diff --git a/src/content/reference/en/p5 copy/constants/DELETE.mdx b/src/content/reference/en/p5 copy/constants/DELETE.mdx deleted file mode 100644 index 3bef8a3983..0000000000 --- a/src/content/reference/en/p5 copy/constants/DELETE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L836 -title: DELETE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 836 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# DELETE diff --git a/src/content/reference/en/p5 copy/constants/DIFFERENCE.mdx b/src/content/reference/en/p5 copy/constants/DIFFERENCE.mdx deleted file mode 100644 index 27d7e0880c..0000000000 --- a/src/content/reference/en/p5 copy/constants/DIFFERENCE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L924 -title: DIFFERENCE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 924 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# DIFFERENCE diff --git a/src/content/reference/en/p5 copy/constants/DILATE.mdx b/src/content/reference/en/p5 copy/constants/DILATE.mdx deleted file mode 100644 index 5eca5b06dd..0000000000 --- a/src/content/reference/en/p5 copy/constants/DILATE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1009 -title: DILATE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1009 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# DILATE diff --git a/src/content/reference/en/p5 copy/constants/DODGE.mdx b/src/content/reference/en/p5 copy/constants/DODGE.mdx deleted file mode 100644 index ba1594bfe4..0000000000 --- a/src/content/reference/en/p5 copy/constants/DODGE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L970 -title: DODGE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 970 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# DODGE diff --git a/src/content/reference/en/p5 copy/constants/DOWN_ARROW.mdx b/src/content/reference/en/p5 copy/constants/DOWN_ARROW.mdx deleted file mode 100644 index c1d80ae679..0000000000 --- a/src/content/reference/en/p5 copy/constants/DOWN_ARROW.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L841 -title: DOWN_ARROW -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 841 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# DOWN\_ARROW diff --git a/src/content/reference/en/p5 copy/constants/ENTER.mdx b/src/content/reference/en/p5 copy/constants/ENTER.mdx deleted file mode 100644 index 0ded2aec7f..0000000000 --- a/src/content/reference/en/p5 copy/constants/ENTER.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L846 -title: ENTER -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 846 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# ENTER diff --git a/src/content/reference/en/p5 copy/constants/ERODE.mdx b/src/content/reference/en/p5 copy/constants/ERODE.mdx deleted file mode 100644 index 9dba021043..0000000000 --- a/src/content/reference/en/p5 copy/constants/ERODE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1014 -title: ERODE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1014 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# ERODE diff --git a/src/content/reference/en/p5 copy/constants/ESCAPE.mdx b/src/content/reference/en/p5 copy/constants/ESCAPE.mdx deleted file mode 100644 index 53256ed7ce..0000000000 --- a/src/content/reference/en/p5 copy/constants/ESCAPE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L851 -title: ESCAPE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 851 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# ESCAPE diff --git a/src/content/reference/en/p5 copy/constants/EXCLUSION.mdx b/src/content/reference/en/p5 copy/constants/EXCLUSION.mdx deleted file mode 100644 index 61c3572125..0000000000 --- a/src/content/reference/en/p5 copy/constants/EXCLUSION.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L934 -title: EXCLUSION -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 934 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# EXCLUSION diff --git a/src/content/reference/en/p5 copy/constants/FALLBACK.mdx b/src/content/reference/en/p5 copy/constants/FALLBACK.mdx deleted file mode 100644 index 6c9f4ec37c..0000000000 --- a/src/content/reference/en/p5 copy/constants/FALLBACK.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1182 -title: FALLBACK -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1182 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# FALLBACK diff --git a/src/content/reference/en/p5 copy/constants/FILL.mdx b/src/content/reference/en/p5 copy/constants/FILL.mdx deleted file mode 100644 index 9e2ca1ce96..0000000000 --- a/src/content/reference/en/p5 copy/constants/FILL.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1090 -title: FILL -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1090 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# FILL diff --git a/src/content/reference/en/p5 copy/constants/FLAT.mdx b/src/content/reference/en/p5 copy/constants/FLAT.mdx deleted file mode 100644 index 50d8b95b1e..0000000000 --- a/src/content/reference/en/p5 copy/constants/FLAT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1138 -title: FLAT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1138 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# FLAT diff --git a/src/content/reference/en/p5 copy/constants/FLOAT.mdx b/src/content/reference/en/p5 copy/constants/FLOAT.mdx deleted file mode 100644 index b063ffc631..0000000000 --- a/src/content/reference/en/p5 copy/constants/FLOAT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1212 -title: FLOAT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1212 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# FLOAT diff --git a/src/content/reference/en/p5 copy/constants/GRAY.mdx b/src/content/reference/en/p5 copy/constants/GRAY.mdx deleted file mode 100644 index ca8a56d090..0000000000 --- a/src/content/reference/en/p5 copy/constants/GRAY.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L989 -title: GRAY -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 989 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# GRAY diff --git a/src/content/reference/en/p5 copy/constants/GRID.mdx b/src/content/reference/en/p5 copy/constants/GRID.mdx deleted file mode 100644 index 683bbf43f9..0000000000 --- a/src/content/reference/en/p5 copy/constants/GRID.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1165 -title: GRID -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1165 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# GRID diff --git a/src/content/reference/en/p5 copy/constants/HALF_FLOAT.mdx b/src/content/reference/en/p5 copy/constants/HALF_FLOAT.mdx deleted file mode 100644 index a70c409626..0000000000 --- a/src/content/reference/en/p5 copy/constants/HALF_FLOAT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1218 -title: HALF_FLOAT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1218 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# HALF\_FLOAT diff --git a/src/content/reference/en/p5 copy/constants/HALF_PI.mdx b/src/content/reference/en/p5 copy/constants/HALF_PI.mdx deleted file mode 100644 index 212458ee9e..0000000000 --- a/src/content/reference/en/p5 copy/constants/HALF_PI.mdx +++ /dev/null @@ -1,109 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L88 -title: HALF_PI -module: Constants -submodule: Constants -file: src/core/constants.js -description: > -

A Number constant that's approximately 1.5708.

- -

HALF_PI is half the value of the mathematical constant π. It's - useful for - - many tasks that involve rotation and oscillation. For example, calling - - rotate(HALF_PI) rotates the coordinate system - HALF_PI radians, which is - - a quarter turn (90˚).

- -

Note: TWO_PI radians equals 360˚, PI radians - equals 180˚, HALF_PI - - radians equals 90˚, and QUARTER_PI radians equals 45˚.

-line: 88 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw an arc from 0 to HALF_PI. - arc(50, 50, 80, 80, 0, HALF_PI); - - describe('The bottom-right quarter of a circle drawn in white on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Draw a line. - line(0, 0, 40, 0); - - // Rotate a quarter turn. - rotate(HALF_PI); - - // Draw the same line, rotated. - line(0, 0, 40, 0); - - describe('Two black lines on a gray background. One line extends from the center to the right. The other line extends from the center to the bottom.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A red circle and a blue circle oscillate from left to right on a gray background. The red circle appears to chase the blue circle.' - ); - } - - function draw() { - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Calculate the x-coordinates. - let x1 = 40 * sin(frameCount * 0.05); - let x2 = 40 * sin(frameCount * 0.05 + HALF_PI); - - // Style the oscillators. - noStroke(); - - // Draw the red oscillator. - fill(255, 0, 0); - circle(x1, 0, 20); - - // Draw the blue oscillator. - fill(0, 0, 255); - circle(x2, 0, 20); - } - -
-class: p5 -type: Number ---- - - -# HALF\_PI diff --git a/src/content/reference/en/p5 copy/constants/HAND.mdx b/src/content/reference/en/p5 copy/constants/HAND.mdx deleted file mode 100644 index 0bd864fb59..0000000000 --- a/src/content/reference/en/p5 copy/constants/HAND.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L65 -title: HAND -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 65 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# HAND diff --git a/src/content/reference/en/p5 copy/constants/HARD_LIGHT.mdx b/src/content/reference/en/p5 copy/constants/HARD_LIGHT.mdx deleted file mode 100644 index 9f3f9742fc..0000000000 --- a/src/content/reference/en/p5 copy/constants/HARD_LIGHT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L960 -title: HARD_LIGHT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 960 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# HARD\_LIGHT diff --git a/src/content/reference/en/p5 copy/constants/HSB.mdx b/src/content/reference/en/p5 copy/constants/HSB.mdx deleted file mode 100644 index d921d5405e..0000000000 --- a/src/content/reference/en/p5 copy/constants/HSB.mdx +++ /dev/null @@ -1,24 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L794 -title: HSB -module: Constants -submodule: Constants -file: src/core/constants.js -description: > -

HSB (hue, saturation, brightness) is a type of color model. - - You can learn more about it at - - HSB.

-line: 794 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# HSB diff --git a/src/content/reference/en/p5 copy/constants/HSL.mdx b/src/content/reference/en/p5 copy/constants/HSL.mdx deleted file mode 100644 index aa660c2da5..0000000000 --- a/src/content/reference/en/p5 copy/constants/HSL.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L803 -title: HSL -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 803 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# HSL diff --git a/src/content/reference/en/p5 copy/constants/IMAGE.mdx b/src/content/reference/en/p5 copy/constants/IMAGE.mdx deleted file mode 100644 index 479af890bb..0000000000 --- a/src/content/reference/en/p5 copy/constants/IMAGE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1108 -title: IMAGE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1108 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# IMAGE diff --git a/src/content/reference/en/p5 copy/constants/IMMEDIATE.mdx b/src/content/reference/en/p5 copy/constants/IMMEDIATE.mdx deleted file mode 100644 index 52b38ee8b5..0000000000 --- a/src/content/reference/en/p5 copy/constants/IMMEDIATE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1100 -title: IMMEDIATE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1100 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# IMMEDIATE diff --git a/src/content/reference/en/p5 copy/constants/INVERT.mdx b/src/content/reference/en/p5 copy/constants/INVERT.mdx deleted file mode 100644 index 9c383dd4d1..0000000000 --- a/src/content/reference/en/p5 copy/constants/INVERT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L999 -title: INVERT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 999 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# INVERT diff --git a/src/content/reference/en/p5 copy/constants/ITALIC.mdx b/src/content/reference/en/p5 copy/constants/ITALIC.mdx deleted file mode 100644 index d0a9a1f2e5..0000000000 --- a/src/content/reference/en/p5 copy/constants/ITALIC.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1031 -title: ITALIC -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1031 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# ITALIC diff --git a/src/content/reference/en/p5 copy/constants/LABEL.mdx b/src/content/reference/en/p5 copy/constants/LABEL.mdx deleted file mode 100644 index 92786b3feb..0000000000 --- a/src/content/reference/en/p5 copy/constants/LABEL.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1177 -title: LABEL -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1177 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# LABEL diff --git a/src/content/reference/en/p5 copy/constants/LANDSCAPE.mdx b/src/content/reference/en/p5 copy/constants/LANDSCAPE.mdx deleted file mode 100644 index c1709051cd..0000000000 --- a/src/content/reference/en/p5 copy/constants/LANDSCAPE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1150 -title: LANDSCAPE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1150 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# LANDSCAPE diff --git a/src/content/reference/en/p5 copy/constants/LEFT.mdx b/src/content/reference/en/p5 copy/constants/LEFT.mdx deleted file mode 100644 index 6e48fe2d99..0000000000 --- a/src/content/reference/en/p5 copy/constants/LEFT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L655 -title: LEFT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 655 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# LEFT diff --git a/src/content/reference/en/p5 copy/constants/LEFT_ARROW.mdx b/src/content/reference/en/p5 copy/constants/LEFT_ARROW.mdx deleted file mode 100644 index 8628e56688..0000000000 --- a/src/content/reference/en/p5 copy/constants/LEFT_ARROW.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L856 -title: LEFT_ARROW -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 856 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# LEFT\_ARROW diff --git a/src/content/reference/en/p5 copy/constants/LIGHTEST.mdx b/src/content/reference/en/p5 copy/constants/LIGHTEST.mdx deleted file mode 100644 index bd15662468..0000000000 --- a/src/content/reference/en/p5 copy/constants/LIGHTEST.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L918 -title: LIGHTEST -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 918 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# LIGHTEST diff --git a/src/content/reference/en/p5 copy/constants/LINEAR.mdx b/src/content/reference/en/p5 copy/constants/LINEAR.mdx deleted file mode 100644 index e56c663585..0000000000 --- a/src/content/reference/en/p5 copy/constants/LINEAR.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1063 -title: LINEAR -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1063 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# LINEAR diff --git a/src/content/reference/en/p5 copy/constants/LINES.mdx b/src/content/reference/en/p5 copy/constants/LINES.mdx deleted file mode 100644 index 9d7d5d2abc..0000000000 --- a/src/content/reference/en/p5 copy/constants/LINES.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L687 -title: LINES -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 687 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# LINES diff --git a/src/content/reference/en/p5 copy/constants/LINE_LOOP.mdx b/src/content/reference/en/p5 copy/constants/LINE_LOOP.mdx deleted file mode 100644 index 2a566fa4c7..0000000000 --- a/src/content/reference/en/p5 copy/constants/LINE_LOOP.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L699 -title: LINE_LOOP -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 699 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# LINE\_LOOP diff --git a/src/content/reference/en/p5 copy/constants/LINE_STRIP.mdx b/src/content/reference/en/p5 copy/constants/LINE_STRIP.mdx deleted file mode 100644 index 816e857d01..0000000000 --- a/src/content/reference/en/p5 copy/constants/LINE_STRIP.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L693 -title: LINE_STRIP -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 693 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# LINE\_STRIP diff --git a/src/content/reference/en/p5 copy/constants/MIRROR.mdx b/src/content/reference/en/p5 copy/constants/MIRROR.mdx deleted file mode 100644 index 9b2bcd7146..0000000000 --- a/src/content/reference/en/p5 copy/constants/MIRROR.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1131 -title: MIRROR -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1131 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# MIRROR diff --git a/src/content/reference/en/p5 copy/constants/MITER.mdx b/src/content/reference/en/p5 copy/constants/MITER.mdx deleted file mode 100644 index 533039ecc8..0000000000 --- a/src/content/reference/en/p5 copy/constants/MITER.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L782 -title: MITER -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 782 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# MITER diff --git a/src/content/reference/en/p5 copy/constants/MOVE.mdx b/src/content/reference/en/p5 copy/constants/MOVE.mdx deleted file mode 100644 index aea9bf8a71..0000000000 --- a/src/content/reference/en/p5 copy/constants/MOVE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L70 -title: MOVE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 70 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# MOVE diff --git a/src/content/reference/en/p5 copy/constants/MULTIPLY.mdx b/src/content/reference/en/p5 copy/constants/MULTIPLY.mdx deleted file mode 100644 index ce343b4bf2..0000000000 --- a/src/content/reference/en/p5 copy/constants/MULTIPLY.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L939 -title: MULTIPLY -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 939 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# MULTIPLY diff --git a/src/content/reference/en/p5 copy/constants/NEAREST.mdx b/src/content/reference/en/p5 copy/constants/NEAREST.mdx deleted file mode 100644 index 9fba7e46cf..0000000000 --- a/src/content/reference/en/p5 copy/constants/NEAREST.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1116 -title: NEAREST -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1116 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# NEAREST diff --git a/src/content/reference/en/p5 copy/constants/NORMAL.mdx b/src/content/reference/en/p5 copy/constants/NORMAL.mdx deleted file mode 100644 index 2c49e02fbf..0000000000 --- a/src/content/reference/en/p5 copy/constants/NORMAL.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1026 -title: NORMAL -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1026 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# NORMAL diff --git a/src/content/reference/en/p5 copy/constants/OPAQUE.mdx b/src/content/reference/en/p5 copy/constants/OPAQUE.mdx deleted file mode 100644 index 9ddf599dd1..0000000000 --- a/src/content/reference/en/p5 copy/constants/OPAQUE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L994 -title: OPAQUE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 994 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# OPAQUE diff --git a/src/content/reference/en/p5 copy/constants/OPEN.mdx b/src/content/reference/en/p5 copy/constants/OPEN.mdx deleted file mode 100644 index 29011d1e69..0000000000 --- a/src/content/reference/en/p5 copy/constants/OPEN.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L745 -title: OPEN -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 745 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# OPEN diff --git a/src/content/reference/en/p5 copy/constants/OPTION.mdx b/src/content/reference/en/p5 copy/constants/OPTION.mdx deleted file mode 100644 index 8ea0e625db..0000000000 --- a/src/content/reference/en/p5 copy/constants/OPTION.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L861 -title: OPTION -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 861 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# OPTION diff --git a/src/content/reference/en/p5 copy/constants/OVERLAY.mdx b/src/content/reference/en/p5 copy/constants/OVERLAY.mdx deleted file mode 100644 index ccb03411bb..0000000000 --- a/src/content/reference/en/p5 copy/constants/OVERLAY.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L955 -title: OVERLAY -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 955 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# OVERLAY diff --git a/src/content/reference/en/p5 copy/constants/P2D.mdx b/src/content/reference/en/p5 copy/constants/P2D.mdx deleted file mode 100644 index 83f09b1d9c..0000000000 --- a/src/content/reference/en/p5 copy/constants/P2D.mdx +++ /dev/null @@ -1,19 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L18 -title: P2D -module: Constants -submodule: Constants -file: src/core/constants.js -description: | -

The default, two-dimensional renderer.

-line: 18 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# P2D diff --git a/src/content/reference/en/p5 copy/constants/PI.mdx b/src/content/reference/en/p5 copy/constants/PI.mdx deleted file mode 100644 index bddf509592..0000000000 --- a/src/content/reference/en/p5 copy/constants/PI.mdx +++ /dev/null @@ -1,108 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L178 -title: PI -module: Constants -submodule: Constants -file: src/core/constants.js -description: > -

A Number constant that's approximately 3.1416.

- -

PI is the mathematical constant π. It's useful for many tasks - that - - involve rotation and oscillation. For example, calling rotate(PI) - rotates - - the coordinate system PI radians, which is a half turn - (180˚).

- -

Note: TWO_PI radians equals 360˚, PI radians - equals 180˚, HALF_PI - - radians equals 90˚, and QUARTER_PI radians equals 45˚.

-line: 178 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw an arc from 0 to PI. - arc(50, 50, 80, 80, 0, PI); - - describe('The bottom half of a circle drawn in white on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Draw a line. - line(0, 0, 40, 0); - - // Rotate a half turn. - rotate(PI); - - // Draw the same line, rotated. - line(0, 0, 40, 0); - - describe('A horizontal black line on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A red circle and a blue circle oscillate from left to right on a gray background. The circles drift apart, then meet in the middle, over and over again.' - ); - } - - function draw() { - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Calculate the x-coordinates. - let x1 = 40 * sin(frameCount * 0.05); - let x2 = 40 * sin(frameCount * 0.05 + PI); - - // Style the oscillators. - noStroke(); - - // Draw the red oscillator. - fill(255, 0, 0); - circle(x1, 0, 20); - - // Draw the blue oscillator. - fill(0, 0, 255); - circle(x2, 0, 20); - } - -
-class: p5 -type: Number ---- - - -# PI diff --git a/src/content/reference/en/p5 copy/constants/PIE.mdx b/src/content/reference/en/p5 copy/constants/PIE.mdx deleted file mode 100644 index 7be0810e6e..0000000000 --- a/src/content/reference/en/p5 copy/constants/PIE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L755 -title: PIE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 755 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# PIE diff --git a/src/content/reference/en/p5 copy/constants/POINTS.mdx b/src/content/reference/en/p5 copy/constants/POINTS.mdx deleted file mode 100644 index 8dea326a14..0000000000 --- a/src/content/reference/en/p5 copy/constants/POINTS.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L681 -title: POINTS -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 681 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# POINTS diff --git a/src/content/reference/en/p5 copy/constants/PORTRAIT.mdx b/src/content/reference/en/p5 copy/constants/PORTRAIT.mdx deleted file mode 100644 index 492546578c..0000000000 --- a/src/content/reference/en/p5 copy/constants/PORTRAIT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1155 -title: PORTRAIT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1155 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# PORTRAIT diff --git a/src/content/reference/en/p5 copy/constants/POSTERIZE.mdx b/src/content/reference/en/p5 copy/constants/POSTERIZE.mdx deleted file mode 100644 index 198c365591..0000000000 --- a/src/content/reference/en/p5 copy/constants/POSTERIZE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1004 -title: POSTERIZE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1004 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# POSTERIZE diff --git a/src/content/reference/en/p5 copy/constants/PROJECT.mdx b/src/content/reference/en/p5 copy/constants/PROJECT.mdx deleted file mode 100644 index ce6f7dbaac..0000000000 --- a/src/content/reference/en/p5 copy/constants/PROJECT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L760 -title: PROJECT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 760 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# PROJECT diff --git a/src/content/reference/en/p5 copy/constants/QUADRATIC.mdx b/src/content/reference/en/p5 copy/constants/QUADRATIC.mdx deleted file mode 100644 index 49e8d2cc19..0000000000 --- a/src/content/reference/en/p5 copy/constants/QUADRATIC.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1068 -title: QUADRATIC -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1068 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# QUADRATIC diff --git a/src/content/reference/en/p5 copy/constants/QUADS.mdx b/src/content/reference/en/p5 copy/constants/QUADS.mdx deleted file mode 100644 index c67a193a4f..0000000000 --- a/src/content/reference/en/p5 copy/constants/QUADS.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L723 -title: QUADS -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 723 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# QUADS diff --git a/src/content/reference/en/p5 copy/constants/QUAD_STRIP.mdx b/src/content/reference/en/p5 copy/constants/QUAD_STRIP.mdx deleted file mode 100644 index c1ce9d4291..0000000000 --- a/src/content/reference/en/p5 copy/constants/QUAD_STRIP.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L728 -title: QUAD_STRIP -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 728 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# QUAD\_STRIP diff --git a/src/content/reference/en/p5 copy/constants/QUARTER_PI.mdx b/src/content/reference/en/p5 copy/constants/QUARTER_PI.mdx deleted file mode 100644 index 5f4cc24bc1..0000000000 --- a/src/content/reference/en/p5 copy/constants/QUARTER_PI.mdx +++ /dev/null @@ -1,109 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L267 -title: QUARTER_PI -module: Constants -submodule: Constants -file: src/core/constants.js -description: > -

A Number constant that's approximately 0.7854.

- -

QUARTER_PI is one-fourth the value of the mathematical - constant π. It's - - useful for many tasks that involve rotation and oscillation. For example, - - calling rotate(QUARTER_PI) rotates the coordinate system - QUARTER_PI - - radians, which is an eighth of a turn (45˚).

- -

Note: TWO_PI radians equals 360˚, PI radians - equals 180˚, HALF_PI - - radians equals 90˚, and QUARTER_PI radians equals 45˚.

-line: 267 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw an arc from 0 to QUARTER_PI. - arc(50, 50, 80, 80, 0, QUARTER_PI); - - describe('A one-eighth slice of a circle drawn in white on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Draw a line. - line(0, 0, 40, 0); - - // Rotate an eighth turn. - rotate(QUARTER_PI); - - // Draw the same line, rotated. - line(0, 0, 40, 0); - - describe('Two black lines that form a "V" opening towards the bottom-right corner of a gray square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A red circle and a blue circle oscillate from left to right on a gray background. The red circle appears to chase the blue circle.' - ); - } - - function draw() { - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Calculate the x-coordinates. - let x1 = 40 * sin(frameCount * 0.05); - let x2 = 40 * sin(frameCount * 0.05 + QUARTER_PI); - - // Style the oscillators. - noStroke(); - - // Draw the red oscillator. - fill(255, 0, 0); - circle(x1, 0, 20); - - // Draw the blue oscillator. - fill(0, 0, 255); - circle(x2, 0, 20); - } - -
-class: p5 -type: Number ---- - - -# QUARTER\_PI diff --git a/src/content/reference/en/p5 copy/constants/RADIANS.mdx b/src/content/reference/en/p5 copy/constants/RADIANS.mdx deleted file mode 100644 index 856db37b9f..0000000000 --- a/src/content/reference/en/p5 copy/constants/RADIANS.mdx +++ /dev/null @@ -1,66 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L587 -title: RADIANS -module: Constants -submodule: Constants -file: src/core/constants.js -description: > -

A String constant that's used to set the - - angleMode().

- -

By default, functions such as rotate() - and - - sin() expect angles measured in units of - radians. - - Calling angleMode(RADIANS) ensures that angles are measured in - units of - - radians. Doing so can be useful if the - - angleMode() has been set to - - DEGREES.

- -

Note: TWO_PI radians equals 360˚.

-line: 587 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use degrees. - angleMode(DEGREES); - - // Draw a red arc from 0˚ to 90˚. - fill(255, 0, 0); - arc(50, 50, 80, 80, 0, 90); - - // Use radians. - angleMode(RADIANS); - - // Draw a blue arc from HALF_PI to PI. - fill(0, 0, 255); - arc(50, 50, 80, 80, HALF_PI, PI); - - describe('The bottom half of a circle drawn on a gray background. The bottom-right quarter is red. The bottom-left quarter is blue.'); - } - -
-class: p5 -type: String ---- - - -# RADIANS diff --git a/src/content/reference/en/p5 copy/constants/RADIUS.mdx b/src/content/reference/en/p5 copy/constants/RADIUS.mdx deleted file mode 100644 index 95f1dcdeef..0000000000 --- a/src/content/reference/en/p5 copy/constants/RADIUS.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L645 -title: RADIUS -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 645 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# RADIUS diff --git a/src/content/reference/en/p5 copy/constants/REMOVE.mdx b/src/content/reference/en/p5 copy/constants/REMOVE.mdx deleted file mode 100644 index c2daffc564..0000000000 --- a/src/content/reference/en/p5 copy/constants/REMOVE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L899 -title: REMOVE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 899 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# REMOVE diff --git a/src/content/reference/en/p5 copy/constants/REPEAT.mdx b/src/content/reference/en/p5 copy/constants/REPEAT.mdx deleted file mode 100644 index c9e75c8bec..0000000000 --- a/src/content/reference/en/p5 copy/constants/REPEAT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1121 -title: REPEAT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1121 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# REPEAT diff --git a/src/content/reference/en/p5 copy/constants/REPLACE.mdx b/src/content/reference/en/p5 copy/constants/REPLACE.mdx deleted file mode 100644 index 8a04f06130..0000000000 --- a/src/content/reference/en/p5 copy/constants/REPLACE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L949 -title: REPLACE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 949 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# REPLACE diff --git a/src/content/reference/en/p5 copy/constants/RETURN.mdx b/src/content/reference/en/p5 copy/constants/RETURN.mdx deleted file mode 100644 index 3069efc256..0000000000 --- a/src/content/reference/en/p5 copy/constants/RETURN.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L866 -title: RETURN -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 866 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# RETURN diff --git a/src/content/reference/en/p5 copy/constants/RGB.mdx b/src/content/reference/en/p5 copy/constants/RGB.mdx deleted file mode 100644 index b0ae826064..0000000000 --- a/src/content/reference/en/p5 copy/constants/RGB.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L789 -title: RGB -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 789 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# RGB diff --git a/src/content/reference/en/p5 copy/constants/RGBA.mdx b/src/content/reference/en/p5 copy/constants/RGBA.mdx deleted file mode 100644 index 256949cfd1..0000000000 --- a/src/content/reference/en/p5 copy/constants/RGBA.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1224 -title: RGBA -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1224 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# RGBA diff --git a/src/content/reference/en/p5 copy/constants/RIGHT.mdx b/src/content/reference/en/p5 copy/constants/RIGHT.mdx deleted file mode 100644 index e9f69e8a80..0000000000 --- a/src/content/reference/en/p5 copy/constants/RIGHT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L650 -title: RIGHT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 650 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# RIGHT diff --git a/src/content/reference/en/p5 copy/constants/RIGHT_ARROW.mdx b/src/content/reference/en/p5 copy/constants/RIGHT_ARROW.mdx deleted file mode 100644 index 731ab29fb5..0000000000 --- a/src/content/reference/en/p5 copy/constants/RIGHT_ARROW.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L871 -title: RIGHT_ARROW -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 871 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# RIGHT\_ARROW diff --git a/src/content/reference/en/p5 copy/constants/ROUND.mdx b/src/content/reference/en/p5 copy/constants/ROUND.mdx deleted file mode 100644 index 50426d2636..0000000000 --- a/src/content/reference/en/p5 copy/constants/ROUND.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L772 -title: ROUND -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 772 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# ROUND diff --git a/src/content/reference/en/p5 copy/constants/SCREEN.mdx b/src/content/reference/en/p5 copy/constants/SCREEN.mdx deleted file mode 100644 index 65f2e6192d..0000000000 --- a/src/content/reference/en/p5 copy/constants/SCREEN.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L944 -title: SCREEN -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 944 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# SCREEN diff --git a/src/content/reference/en/p5 copy/constants/SHIFT.mdx b/src/content/reference/en/p5 copy/constants/SHIFT.mdx deleted file mode 100644 index e48b091ab3..0000000000 --- a/src/content/reference/en/p5 copy/constants/SHIFT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L876 -title: SHIFT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 876 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# SHIFT diff --git a/src/content/reference/en/p5 copy/constants/SMOOTH.mdx b/src/content/reference/en/p5 copy/constants/SMOOTH.mdx deleted file mode 100644 index 816be1029b..0000000000 --- a/src/content/reference/en/p5 copy/constants/SMOOTH.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1143 -title: SMOOTH -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1143 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# SMOOTH diff --git a/src/content/reference/en/p5 copy/constants/SOFT_LIGHT.mdx b/src/content/reference/en/p5 copy/constants/SOFT_LIGHT.mdx deleted file mode 100644 index 846e6fe72b..0000000000 --- a/src/content/reference/en/p5 copy/constants/SOFT_LIGHT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L965 -title: SOFT_LIGHT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 965 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# SOFT\_LIGHT diff --git a/src/content/reference/en/p5 copy/constants/SQUARE.mdx b/src/content/reference/en/p5 copy/constants/SQUARE.mdx deleted file mode 100644 index 7b5da139d7..0000000000 --- a/src/content/reference/en/p5 copy/constants/SQUARE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L766 -title: SQUARE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 766 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# SQUARE diff --git a/src/content/reference/en/p5 copy/constants/STROKE.mdx b/src/content/reference/en/p5 copy/constants/STROKE.mdx deleted file mode 100644 index 16cfa32e5e..0000000000 --- a/src/content/reference/en/p5 copy/constants/STROKE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1085 -title: STROKE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1085 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# STROKE diff --git a/src/content/reference/en/p5 copy/constants/SUBTRACT.mdx b/src/content/reference/en/p5 copy/constants/SUBTRACT.mdx deleted file mode 100644 index 2bd6d94fe9..0000000000 --- a/src/content/reference/en/p5 copy/constants/SUBTRACT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L929 -title: SUBTRACT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 929 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# SUBTRACT diff --git a/src/content/reference/en/p5 copy/constants/TAB.mdx b/src/content/reference/en/p5 copy/constants/TAB.mdx deleted file mode 100644 index cf89117ae4..0000000000 --- a/src/content/reference/en/p5 copy/constants/TAB.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L881 -title: TAB -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 881 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# TAB diff --git a/src/content/reference/en/p5 copy/constants/TAU.mdx b/src/content/reference/en/p5 copy/constants/TAU.mdx deleted file mode 100644 index a553339913..0000000000 --- a/src/content/reference/en/p5 copy/constants/TAU.mdx +++ /dev/null @@ -1,114 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L357 -title: TAU -module: Constants -submodule: Constants -file: src/core/constants.js -description: > -

A Number constant that's approximately 6.2382.

- -

TAU is twice the value of the mathematical constant π. It's - useful for - - many tasks that involve rotation and oscillation. For example, calling - - rotate(TAU) rotates the coordinate system TAU - radians, which is one - - full turn (360˚). TAU and TWO_PI are equal.

- -

Note: TAU radians equals 360˚, PI radians equals - 180˚, HALF_PI - - radians equals 90˚, and QUARTER_PI radians equals 45˚.

-line: 357 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw an arc from 0 to TAU. - arc(50, 50, 80, 80, 0, TAU); - - describe('A white circle drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Draw a line. - line(0, 0, 40, 0); - - // Rotate a full turn. - rotate(TAU); - - // Style the second line. - strokeWeight(5); - - // Draw the same line, shorter and rotated. - line(0, 0, 20, 0); - - describe( - 'Two horizontal black lines on a gray background. A thick line extends from the center toward the right. A thin line extends from the end of the thick line.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A red circle with a blue center oscillates from left to right on a gray background.' - ); - } - - function draw() { - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Calculate the x-coordinates. - let x1 = 40 * sin(frameCount * 0.05); - let x2 = 40 * sin(frameCount * 0.05 + TAU); - - // Style the oscillators. - noStroke(); - - // Draw the red oscillator. - fill(255, 0, 0); - circle(x1, 0, 20); - - // Draw the blue oscillator, smaller. - fill(0, 0, 255); - circle(x2, 0, 10); - } - -
-class: p5 -type: Number ---- - - -# TAU diff --git a/src/content/reference/en/p5 copy/constants/TESS.mdx b/src/content/reference/en/p5 copy/constants/TESS.mdx deleted file mode 100644 index e6f853e8ab..0000000000 --- a/src/content/reference/en/p5 copy/constants/TESS.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L734 -title: TESS -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 734 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# TESS diff --git a/src/content/reference/en/p5 copy/constants/TEXT.mdx b/src/content/reference/en/p5 copy/constants/TEXT.mdx deleted file mode 100644 index 157a90001a..0000000000 --- a/src/content/reference/en/p5 copy/constants/TEXT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L75 -title: TEXT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 75 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# TEXT diff --git a/src/content/reference/en/p5 copy/constants/TEXTURE.mdx b/src/content/reference/en/p5 copy/constants/TEXTURE.mdx deleted file mode 100644 index 8ada92f376..0000000000 --- a/src/content/reference/en/p5 copy/constants/TEXTURE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1095 -title: TEXTURE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1095 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# TEXTURE diff --git a/src/content/reference/en/p5 copy/constants/THRESHOLD.mdx b/src/content/reference/en/p5 copy/constants/THRESHOLD.mdx deleted file mode 100644 index f12e6ea336..0000000000 --- a/src/content/reference/en/p5 copy/constants/THRESHOLD.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L984 -title: THRESHOLD -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 984 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# THRESHOLD diff --git a/src/content/reference/en/p5 copy/constants/TOP.mdx b/src/content/reference/en/p5 copy/constants/TOP.mdx deleted file mode 100644 index a91b5f4824..0000000000 --- a/src/content/reference/en/p5 copy/constants/TOP.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L665 -title: TOP -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 665 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# TOP diff --git a/src/content/reference/en/p5 copy/constants/TRIANGLES.mdx b/src/content/reference/en/p5 copy/constants/TRIANGLES.mdx deleted file mode 100644 index ec281d033e..0000000000 --- a/src/content/reference/en/p5 copy/constants/TRIANGLES.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L705 -title: TRIANGLES -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 705 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# TRIANGLES diff --git a/src/content/reference/en/p5 copy/constants/TRIANGLE_FAN.mdx b/src/content/reference/en/p5 copy/constants/TRIANGLE_FAN.mdx deleted file mode 100644 index bcd5d5f5a1..0000000000 --- a/src/content/reference/en/p5 copy/constants/TRIANGLE_FAN.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L711 -title: TRIANGLE_FAN -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 711 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# TRIANGLE\_FAN diff --git a/src/content/reference/en/p5 copy/constants/TRIANGLE_STRIP.mdx b/src/content/reference/en/p5 copy/constants/TRIANGLE_STRIP.mdx deleted file mode 100644 index fefe226e17..0000000000 --- a/src/content/reference/en/p5 copy/constants/TRIANGLE_STRIP.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L717 -title: TRIANGLE_STRIP -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 717 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# TRIANGLE\_STRIP diff --git a/src/content/reference/en/p5 copy/constants/TWO_PI.mdx b/src/content/reference/en/p5 copy/constants/TWO_PI.mdx deleted file mode 100644 index ed62a10b0f..0000000000 --- a/src/content/reference/en/p5 copy/constants/TWO_PI.mdx +++ /dev/null @@ -1,114 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L452 -title: TWO_PI -module: Constants -submodule: Constants -file: src/core/constants.js -description: > -

A Number constant that's approximately 6.2382.

- -

TWO_PI is twice the value of the mathematical constant π. It's - useful for - - many tasks that involve rotation and oscillation. For example, calling - - rotate(TWO_PI) rotates the coordinate system TWO_PI - radians, which is - - one full turn (360˚). TWO_PI and TAU are equal.

- -

Note: TWO_PI radians equals 360˚, PI radians - equals 180˚, HALF_PI - - radians equals 90˚, and QUARTER_PI radians equals 45˚.

-line: 452 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw an arc from 0 to TWO_PI. - arc(50, 50, 80, 80, 0, TWO_PI); - - describe('A white circle drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Draw a line. - line(0, 0, 40, 0); - - // Rotate a full turn. - rotate(TWO_PI); - - // Style the second line. - strokeWeight(5); - - // Draw the same line, shorter and rotated. - line(0, 0, 20, 0); - - describe( - 'Two horizontal black lines on a gray background. A thick line extends from the center toward the right. A thin line extends from the end of the thick line.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A red circle with a blue center oscillates from left to right on a gray background.' - ); - } - - function draw() { - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Calculate the x-coordinates. - let x1 = 40 * sin(frameCount * 0.05); - let x2 = 40 * sin(frameCount * 0.05 + TWO_PI); - - // Style the oscillators. - noStroke(); - - // Draw the red oscillator. - fill(255, 0, 0); - circle(x1, 0, 20); - - // Draw the blue oscillator, smaller. - fill(0, 0, 255); - circle(x2, 0, 10); - } - -
-class: p5 -type: Number ---- - - -# TWO\_PI diff --git a/src/content/reference/en/p5 copy/constants/UNSIGNED_BYTE.mdx b/src/content/reference/en/p5 copy/constants/UNSIGNED_BYTE.mdx deleted file mode 100644 index 00acfe29c0..0000000000 --- a/src/content/reference/en/p5 copy/constants/UNSIGNED_BYTE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1200 -title: UNSIGNED_BYTE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1200 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# UNSIGNED\_BYTE diff --git a/src/content/reference/en/p5 copy/constants/UNSIGNED_INT.mdx b/src/content/reference/en/p5 copy/constants/UNSIGNED_INT.mdx deleted file mode 100644 index f060682a13..0000000000 --- a/src/content/reference/en/p5 copy/constants/UNSIGNED_INT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1206 -title: UNSIGNED_INT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1206 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# UNSIGNED\_INT diff --git a/src/content/reference/en/p5 copy/constants/UP_ARROW.mdx b/src/content/reference/en/p5 copy/constants/UP_ARROW.mdx deleted file mode 100644 index e0e0326aa6..0000000000 --- a/src/content/reference/en/p5 copy/constants/UP_ARROW.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L886 -title: UP_ARROW -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 886 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# UP\_ARROW diff --git a/src/content/reference/en/p5 copy/constants/VERSION.mdx b/src/content/reference/en/p5 copy/constants/VERSION.mdx deleted file mode 100644 index f9f62fca55..0000000000 --- a/src/content/reference/en/p5 copy/constants/VERSION.mdx +++ /dev/null @@ -1,19 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L9 -title: VERSION -module: Constants -submodule: Constants -file: src/core/constants.js -description: | -

Version of this p5.js.

-line: 9 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# VERSION diff --git a/src/content/reference/en/p5 copy/constants/WAIT.mdx b/src/content/reference/en/p5 copy/constants/WAIT.mdx deleted file mode 100644 index 833f77ee4f..0000000000 --- a/src/content/reference/en/p5 copy/constants/WAIT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L80 -title: WAIT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 80 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# WAIT diff --git a/src/content/reference/en/p5 copy/constants/WEBGL.mdx b/src/content/reference/en/p5 copy/constants/WEBGL.mdx deleted file mode 100644 index 2919ec489c..0000000000 --- a/src/content/reference/en/p5 copy/constants/WEBGL.mdx +++ /dev/null @@ -1,91 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L24 -title: WEBGL -module: Constants -submodule: Constants -file: src/core/constants.js -description: > -

One of the two render modes in p5.js, used for computationally intensive - tasks like 3D rendering and shaders.

- -

WEBGL differs from the default P2D renderer in the following - ways:

- - - -

To learn more about WEBGL mode, check out all the interactive WEBGL - tutorials in the "Tutorials" section of this website, or read the wiki - article "Getting - started with WebGL in p5".

-line: 24 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# WEBGL diff --git a/src/content/reference/en/p5 copy/constants/WEBGL2.mdx b/src/content/reference/en/p5 copy/constants/WEBGL2.mdx deleted file mode 100644 index 68c6ca83fa..0000000000 --- a/src/content/reference/en/p5 copy/constants/WEBGL2.mdx +++ /dev/null @@ -1,21 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L45 -title: WEBGL2 -module: Constants -submodule: Constants -file: src/core/constants.js -description: | -

One of the two possible values of a WebGL canvas (either WEBGL or WEBGL2), - which can be used to determine what capabilities the rendering environment - has.

-line: 45 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# WEBGL2 diff --git a/src/content/reference/en/p5 copy/constants/WORD.mdx b/src/content/reference/en/p5 copy/constants/WORD.mdx deleted file mode 100644 index 03f13b4874..0000000000 --- a/src/content/reference/en/p5 copy/constants/WORD.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1051 -title: WORD -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1051 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# WORD diff --git a/src/content/reference/en/p5 copy/constrain.mdx b/src/content/reference/en/p5 copy/constrain.mdx deleted file mode 100644 index d869ce2e74..0000000000 --- a/src/content/reference/en/p5 copy/constrain.mdx +++ /dev/null @@ -1,86 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L91 -title: constrain -module: Math -submodule: Calculation -file: src/math/calculation.js -description: | -

Constrains a number between a minimum and maximum value.

-line: 91 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A black dot drawn on a gray square follows the mouse from left to right. Its movement is constrained to the middle third of the square.'); - } - - function draw() { - background(200); - - let x = constrain(mouseX, 33, 67); - let y = 50; - - strokeWeight(5); - point(x, y); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('Two vertical lines. Two circles move horizontally with the mouse. One circle stops at the vertical lines.'); - } - - function draw() { - background(200); - - // Set boundaries and draw them. - let leftWall = 25; - let rightWall = 75; - line(leftWall, 0, leftWall, 100); - line(rightWall, 0, rightWall, 100); - - // Draw a circle that follows the mouse freely. - fill(255); - circle(mouseX, 33, 9); - - // Draw a circle that's constrained. - let xc = constrain(mouseX, leftWall, rightWall); - fill(0); - circle(xc, 67, 9); - } - -
-class: p5 -params: - - name: 'n' - description: | -

number to constrain.

- type: Number - - name: low - description: | -

minimum limit.

- type: Number - - name: high - description: | -

maximum limit.

- type: Number -return: - description: constrained number. - type: Number -chainable: false ---- - - -# constrain diff --git a/src/content/reference/en/p5 copy/copy.mdx b/src/content/reference/en/p5 copy/copy.mdx deleted file mode 100644 index 059df56434..0000000000 --- a/src/content/reference/en/p5 copy/copy.mdx +++ /dev/null @@ -1,144 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L288 -title: copy -module: Image -submodule: Pixels -file: src/image/pixels.js -description: > -

Copies pixels from a source image to a region of the canvas.

- -

The first parameter, srcImage, is the - - p5.Image object to blend. The source - image can be - - the canvas itself or a - - p5.Image object. copy() will - scale pixels from - - the source region if it isn't the same size as the destination region.

- -

The next four parameters, sx, sy, - sw, and sh determine the region - - to copy from the source image. (sx, sy) is the top-left corner of - the - - region. sw and sh are the region's width and - height.

- -

The next four parameters, dx, dy, - dw, and dh determine the region - - of the canvas to copy into. (dx, dy) is the top-left corner of - the - - region. dw and dh are the region's width and - height.

-line: 288 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/rockies.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Use the mountains as the background. - background(img); - - // Copy a region of pixels to another spot. - copy(img, 7, 22, 10, 10, 35, 25, 50, 50); - - // Outline the copied region. - stroke(255); - noFill(); - square(7, 22, 10); - - describe('An image of a mountain landscape. A square region is outlined in white. A larger square contains a pixelated view of the outlined region.'); - } - -
-class: p5 -overloads: - - line: 288 - params: - - name: srcImage - description: | -

source image.

- type: p5.Image|p5.Element - - name: sx - description: | -

x-coordinate of the source's upper-left corner.

- type: Integer - - name: sy - description: | -

y-coordinate of the source's upper-left corner.

- type: Integer - - name: sw - description: | -

source image width.

- type: Integer - - name: sh - description: | -

source image height.

- type: Integer - - name: dx - description: | -

x-coordinate of the destination's upper-left corner.

- type: Integer - - name: dy - description: | -

y-coordinate of the destination's upper-left corner.

- type: Integer - - name: dw - description: | -

destination image width.

- type: Integer - - name: dh - description: | -

destination image height.

- type: Integer - - line: 345 - params: - - name: sx - description: '' - type: Integer - - name: sy - description: '' - type: Integer - - name: sw - description: '' - type: Integer - - name: sh - description: '' - type: Integer - - name: dx - description: '' - type: Integer - - name: dy - description: '' - type: Integer - - name: dw - description: '' - type: Integer - - name: dh - description: '' - type: Integer -chainable: false ---- - - -# copy diff --git a/src/content/reference/en/p5 copy/cos.mdx b/src/content/reference/en/p5 copy/cos.mdx deleted file mode 100644 index cd6468fc4f..0000000000 --- a/src/content/reference/en/p5 copy/cos.mdx +++ /dev/null @@ -1,107 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L281 -title: cos -module: Math -submodule: Trigonometry -file: src/math/trigonometry.js -description: > -

Calculates the cosine of an angle.

- -

cos() is useful for many geometric tasks in creative coding. - The values - - returned oscillate between -1 and 1 as the input angle increases. - cos() - - calculates the cosine of an angle, using radians by default, or according to - - if angleMode() setting (RADIANS or - DEGREES).

-line: 281 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A white ball on a string oscillates left and right.'); - } - - function draw() { - background(200); - - // Calculate the coordinates. - let x = 30 * cos(frameCount * 0.05) + 50; - let y = 50; - - // Draw the oscillator. - line(50, y, x, y); - circle(x, y, 20); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - describe('A series of black dots form a wave pattern.'); - } - - function draw() { - // Calculate the coordinates. - let x = frameCount; - let y = 30 * cos(x * 0.1) + 50; - - // Draw the point. - point(x, y); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - describe('A series of black dots form an infinity symbol.'); - } - - function draw() { - // Calculate the coordinates. - let x = 30 * cos(frameCount * 0.1) + 50; - let y = 10 * sin(frameCount * 0.2) + 50; - - // Draw the point. - point(x, y); - } - -
-class: p5 -params: - - name: angle - description: > -

the angle, in radians by default, or according to - - if angleMode() setting (RADIANS or - DEGREES).

- type: Number -return: - description: cosine of the angle. - type: Number -chainable: false ---- - - -# cos diff --git a/src/content/reference/en/p5 copy/createA.mdx b/src/content/reference/en/p5 copy/createA.mdx deleted file mode 100644 index 669ce45a27..0000000000 --- a/src/content/reference/en/p5 copy/createA.mdx +++ /dev/null @@ -1,93 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L724 -title: createA -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates an element that links to another web page.

- -

The first parmeter, href, is a string that sets the URL of the - linked - - page.

- -

The second parameter, html, is a string that sets the inner - HTML of the - - link. It's common to use text, images, or buttons as links.

- -

The third parameter, target, is optional. It's a string that - tells the - - web browser where to open the link. By default, links open in the current - - browser tab. Passing '_blank' will cause the link to open in a - new - - browser tab. MDN describes a few - - other options.

-line: 724 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an anchor element that links to p5js.org. - let a = createA('https://p5js.org/', 'p5*js'); - a.position(25, 35); - - describe('The text "p5*js" written at the center of a gray square.'); - } - -
- -
- - function setup() { - background(200); - - // Create an anchor tag that links to p5js.org. - // Open the link in a new tab. - let a = createA('https://p5js.org/', 'p5*js', '_blank'); - a.position(25, 35); - - describe('The text "p5*js" written at the center of a gray square.'); - } - -
-class: p5 -params: - - name: href - description: | -

URL of linked page.

- type: String - - name: html - description: | -

inner HTML of link element to display.

- type: String - - name: target - description: | -

target where the new link should open, - either '_blank', '_self', '_parent', or '_top'.

- type: String - optional: true -return: - description: new p5.Element object. - type: p5.Element -chainable: false ---- - - -# createA diff --git a/src/content/reference/en/p5 copy/createAudio.mdx b/src/content/reference/en/p5 copy/createAudio.mdx deleted file mode 100644 index 24b3bce36b..0000000000 --- a/src/content/reference/en/p5 copy/createAudio.mdx +++ /dev/null @@ -1,83 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L2213 -title: createAudio -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a hidden element for simple audio - playback.

- -

createAudio() returns a new - - p5.MediaElement object.

- -

The first parameter, src, is the path the video. If a single - string is - - passed, as in '/assets/video.mp4', a single video is loaded. An - array - - of strings can be used to load the same video in different formats. For - - example, ['/assets/video.mp4', '/assets/video.ogv', - '/assets/video.webm']. - - This is useful for ensuring that the video can play across different - - browsers with different capabilities. See - - MDN - - for more information about supported formats.

- -

The second parameter, callback, is optional. It's a function - to call once - - the audio is ready to play.

-line: 2213 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - noCanvas(); - - // Load the audio. - let beat = createAudio('/assets/beat.mp3'); - - // Show the default audio controls. - beat.showControls(); - - describe('An audio beat plays when the user double-clicks the square.'); - } - -
-class: p5 -params: - - name: src - description: | -

path to an audio file, or an array of paths - for supporting different browsers.

- type: 'String|String[]' - optional: true - - name: callback - description: | -

function to call once the audio is ready to play.

- type: Function - optional: true -return: - description: new p5.MediaElement object. - type: p5.MediaElement -chainable: false ---- - - -# createAudio diff --git a/src/content/reference/en/p5 copy/createButton.mdx b/src/content/reference/en/p5 copy/createButton.mdx deleted file mode 100644 index 9ff2d66faf..0000000000 --- a/src/content/reference/en/p5 copy/createButton.mdx +++ /dev/null @@ -1,109 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L924 -title: createButton -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a element.

- -

The first parameter, label, is a string that sets the label - displayed on - - the button.

- -

The second parameter, value, is optional. It's a string that - sets the - - button's value. See - - MDN - - for more details.

-line: 924 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a button and place it beneath the canvas. - let button = createButton('click me'); - button.position(0, 100); - - // Call repaint() when the button is pressed. - button.mousePressed(repaint); - - describe('A gray square with a button that says "click me" beneath it. The square changes color when the button is clicked.'); - } - - // Change the background color. - function repaint() { - let g = random(255); - background(g); - } - -
- -
- - let button; - - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a button and set its value to 0. - // Place the button beneath the canvas. - button = createButton('click me', 'red'); - button.position(0, 100); - - // Call randomColor() when the button is pressed. - button.mousePressed(randomColor); - - describe('A red square with a button that says "click me" beneath it. The square changes color when the button is clicked.'); - } - - function draw() { - // Use the button's value to set the background color. - let c = button.value(); - background(c); - } - - // Set the button's value to a random color. - function randomColor() { - let c = random(['red', 'green', 'blue', 'yellow']); - button.value(c); - } - -
-class: p5 -params: - - name: label - description: | -

label displayed on the button.

- type: String - - name: value - description: | -

value of the button.

- type: String - optional: true -return: - description: new p5.Element object. - type: p5.Element -chainable: false ---- - - -# createButton diff --git a/src/content/reference/en/p5 copy/createCamera.mdx b/src/content/reference/en/p5 copy/createCamera.mdx deleted file mode 100644 index 8fbb13ce5d..0000000000 --- a/src/content/reference/en/p5 copy/createCamera.mdx +++ /dev/null @@ -1,99 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L638 -title: createCamera -module: 3D -submodule: Camera -file: src/webgl/p5.Camera.js -description: > -

Creates a new p5.Camera object and - sets it - - as the current (active) camera.

- -

The new camera is initialized with a default position (0, 0, - 800) and a - - default perspective projection. Its properties can be controlled with - - p5.Camera methods such as - - myCamera.lookAt(0, 0, 0).

- -

Note: Every 3D sketch starts with a default camera initialized. - - This camera can be controlled with the functions - - camera(), - - perspective(), - - ortho(), and - - frustum() if it's the only camera in the - scene.

- -

Note: createCamera() can only be used in WebGL mode.

-line: 638 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Double-click to toggle between cameras. - - let cam1; - let cam2; - let usingCam1 = true; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the first camera. - // Keep its default settings. - cam1 = createCamera(); - - // Create the second camera. - // Place it at the top-left. - // Point it at the origin. - cam2 = createCamera(); - cam2.setPosition(400, -400, 800); - cam2.lookAt(0, 0, 0); - - // Set the current camera to cam1. - setCamera(cam1); - - describe('A white cube on a gray background. The camera toggles between frontal and aerial views when the user double-clicks.'); - } - - function draw() { - background(200); - - // Draw the box. - box(); - } - - // Toggle the current camera when the user double-clicks. - function doubleClicked() { - if (usingCam1 === true) { - setCamera(cam2); - usingCam1 = false; - } else { - setCamera(cam1); - usingCam1 = true; - } - } - -
-class: p5 -return: - description: the new camera. - type: p5.Camera -chainable: false ---- - - -# createCamera diff --git a/src/content/reference/en/p5 copy/createCanvas.mdx b/src/content/reference/en/p5 copy/createCanvas.mdx deleted file mode 100644 index 600d7e3545..0000000000 --- a/src/content/reference/en/p5 copy/createCanvas.mdx +++ /dev/null @@ -1,191 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L15 -title: createCanvas -module: Rendering -submodule: Rendering -file: src/core/rendering.js -description: > -

Creates a canvas element on the web page.

- -

createCanvas() creates the main drawing canvas for a sketch. - It should - - only be called once at the beginning of setup(). - - Calling createCanvas() more than once causes unpredictable - behavior.

- -

The first two parameters, width and height, are - optional. They set the - - dimensions of the canvas and the values of the - - width and height system - - variables. For example, calling createCanvas(900, 500) creates a - canvas - - that's 900×500 pixels. By default, width and height - are both 100.

- -

The third parameter is also optional. If either of the constants - P2D or - - WEBGL is passed, as in createCanvas(900, 500, - WEBGL), then it will set - - the sketch's rendering mode. If an existing - - HTMLCanvasElement - - is passed, as in createCanvas(900, 500, myCanvas), then it will - be used - - by the sketch.

- -

The fourth parameter is also optional. If an existing - - HTMLCanvasElement - - is passed, as in createCanvas(900, 500, WEBGL, myCanvas), then it - will be - - used by the sketch.

- -

Note: In WebGL mode, the canvas will use a WebGL2 context if it's supported - - by the browser. Check the webglVersion - - system variable to check what version is being used, or call - - setAttributes({ version: 1 }) to create a WebGL1 context.

-line: 15 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Draw a diagonal line. - line(0, 0, width, height); - - describe('A diagonal line drawn from top-left to bottom-right on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 50); - - background(180); - - // Draw a diagonal line. - line(0, 0, width, height); - - describe('A diagonal line drawn from top-left to bottom-right on a gray background.'); - } - -
- -
- - // Use WebGL mode. - - function setup() { - createCanvas(100, 100, WEBGL); - - background(180); - - // Draw a diagonal line. - line(-width / 2, -height / 2, width / 2, height / 2); - - describe('A diagonal line drawn from top-left to bottom-right on a gray background.'); - } - -
- -
- - function setup() { - // Create a p5.Renderer object. - let cnv = createCanvas(50, 50); - - // Position the canvas. - cnv.position(10, 20); - - background(180); - - // Draw a diagonal line. - line(0, 0, width, height); - - describe('A diagonal line drawn from top-left to bottom-right on a gray background.'); - } - -
-class: p5 -return: - description: new `p5.Renderer` that holds the canvas. - type: p5.Renderer -overloads: - - line: 15 - params: - - name: width - description: | -

width of the canvas. Defaults to 100.

- type: Number - optional: true - - name: height - description: | -

height of the canvas. Defaults to 100.

- type: Number - optional: true - - name: renderer - description: | -

either P2D or WEBGL. Defaults to P2D.

- type: Constant - optional: true - - name: canvas - description: | -

existing canvas element that should be used for the sketch.

- type: HTMLCanvasElement - optional: true - return: - description: new `p5.Renderer` that holds the canvas. - type: p5.Renderer - - line: 119 - params: - - name: width - description: '' - type: Number - optional: true - - name: height - description: '' - type: Number - optional: true - - name: canvas - description: '' - type: HTMLCanvasElement - optional: true - return: - description: '' - type: p5.Renderer -chainable: false ---- - - -# createCanvas diff --git a/src/content/reference/en/p5 copy/createCapture.mdx b/src/content/reference/en/p5 copy/createCapture.mdx deleted file mode 100644 index 1087d14b1a..0000000000 --- a/src/content/reference/en/p5 copy/createCapture.mdx +++ /dev/null @@ -1,189 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L2295 -title: createCapture -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a element that "captures" the audio/video - stream from - - the webcam and microphone.

- -

createCapture() returns a new - - p5.MediaElement object. Videos are - shown by - - default. They can be hidden by calling capture.hide() and drawn - to the - - canvas using image().

- -

The first parameter, type, is optional. It sets the type of - capture to - - use. By default, createCapture() captures both audio and video. - If VIDEO - - is passed, as in createCapture(VIDEO), only video will be - captured. - - If AUDIO is passed, as in createCapture(AUDIO), only - audio will be - - captured. A constraints object can also be passed to customize the stream. - - See the - - W3C documentation for possible properties. Different browsers support - different - - properties.

- -

The 'flipped' property is an optional property which can be set to - {flipped:true} - - to mirror the video output.If it is true then it means that video will be - mirrored - - or flipped and if nothing is mentioned then by default it will be - false.

- -

The second parameter,callback, is optional. It's a function to - call once - - the capture is ready for use. The callback function should have one - - parameter, stream, that's a - - MediaStream object.

- -

Note: createCapture() only works when running a sketch locally - or using HTTPS. Learn more - - here - - and here.

-line: 2295 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - noCanvas(); - - // Create the video capture. - createCapture(VIDEO); - - describe('A video stream from the webcam.'); - } - -
- -
- - let capture; - - function setup() { - createCanvas(100, 100); - - // Create the video capture and hide the element. - capture = createCapture(VIDEO); - capture.hide(); - - describe('A video stream from the webcam with inverted colors.'); - } - - function draw() { - // Draw the video capture within the canvas. - image(capture, 0, 0, width, width * capture.height / capture.width); - - // Invert the colors in the stream. - filter(INVERT); - } - -
-
- - let capture; - - function setup() { - createCanvas(100, 100); - - // Create the video capture with mirrored output. - capture = createCapture(VIDEO,{ flipped:true }); - capture.size(100,100); - - describe('A video stream from the webcam with flipped or mirrored output.'); - } - - -
- -
- - function setup() { - createCanvas(480, 120); - - // Create a constraints object. - let constraints = { - video: { - mandatory: { - minWidth: 1280, - minHeight: 720 - }, - optional: [{ maxFrameRate: 10 }] - }, - audio: false - }; - - // Create the video capture. - createCapture(constraints); - - describe('A video stream from the webcam.'); - } - -
-class: p5 -params: - - name: type - description: | -

type of capture, either AUDIO or VIDEO, - or a constraints object. Both video and audio - audio streams are captured by default.

- type: String|Constant|Object - optional: true - - name: flipped - description: > -

flip the capturing video and mirror the output with - {flipped:true}. By - default it is false.

- type: Object - optional: true - - name: callback - description: | -

function to call once the stream - has loaded.

- type: Function - optional: true -return: - description: new p5.MediaElement object. - type: p5.MediaElement -chainable: false ---- - - -# createCapture diff --git a/src/content/reference/en/p5 copy/createCheckbox.mdx b/src/content/reference/en/p5 copy/createCheckbox.mdx deleted file mode 100644 index 45335be2d4..0000000000 --- a/src/content/reference/en/p5 copy/createCheckbox.mdx +++ /dev/null @@ -1,131 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1008 -title: createCheckbox -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a checkbox element.

- -

Checkboxes extend the p5.Element - class with a - - checked() method. Calling myBox.checked() returns - true if it the box - - is checked and false if not.

- -

The first parameter, label, is optional. It's a string that - sets the label - - to display next to the checkbox.

- -

The second parameter, value, is also optional. It's a boolean - that sets the - - checkbox's value.

-line: 1008 -isConstructor: false -itemtype: method -example: - - |- - -
- - let checkbox; - - function setup() { - createCanvas(100, 100); - - // Create a checkbox and place it beneath the canvas. - checkbox = createCheckbox(); - checkbox.position(0, 100); - - describe('A black square with a checkbox beneath it. The square turns white when the box is checked.'); - } - - function draw() { - // Use the checkbox to set the background color. - if (checkbox.checked()) { - background(255); - } else { - background(0); - } - } - -
- -
- - let checkbox; - - function setup() { - createCanvas(100, 100); - - // Create a checkbox and place it beneath the canvas. - // Label the checkbox "white". - checkbox = createCheckbox(' white'); - checkbox.position(0, 100); - - describe('A black square with a checkbox labeled "white" beneath it. The square turns white when the box is checked.'); - } - - function draw() { - // Use the checkbox to set the background color. - if (checkbox.checked()) { - background(255); - } else { - background(0); - } - } - -
- -
- - let checkbox; - - function setup() { - createCanvas(100, 100); - - // Create a checkbox and place it beneath the canvas. - // Label the checkbox "white" and set its value to true. - checkbox = createCheckbox(' white', true); - checkbox.position(0, 100); - - describe('A white square with a checkbox labeled "white" beneath it. The square turns black when the box is unchecked.'); - } - - function draw() { - // Use the checkbox to set the background color. - if (checkbox.checked()) { - background(255); - } else { - background(0); - } - } - -
-class: p5 -params: - - name: label - description: | -

label displayed after the checkbox.

- type: String - optional: true - - name: value - description: > -

value of the checkbox. Checked is true and unchecked is - false.

- type: Boolean - optional: true -return: - description: new p5.Element object. - type: p5.Element -chainable: false ---- - - -# createCheckbox diff --git a/src/content/reference/en/p5 copy/createColorPicker.mdx b/src/content/reference/en/p5 copy/createColorPicker.mdx deleted file mode 100644 index 0c34a0593e..0000000000 --- a/src/content/reference/en/p5 copy/createColorPicker.mdx +++ /dev/null @@ -1,101 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1759 -title: createColorPicker -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a color picker element.

- -

The parameter, value, is optional. If a color string or - - p5.Color object is passed, it will set - the default - - color.

- -

Color pickers extend the p5.Element - class with a - - couple of helpful methods for managing colors:

- -
    - -
  • myPicker.value() returns the current color as a hex string in - the format '#rrggbb'.
  • - -
  • myPicker.color() returns the current color as a p5.Color object.
  • - -
-line: 1759 -isConstructor: false -itemtype: method -example: - - |- - -
- - let myPicker; - - function setup() { - createCanvas(100, 100); - - // Create a color picker and set its position. - myPicker = createColorPicker('deeppink'); - myPicker.position(0, 100); - - describe('A pink square with a color picker beneath it. The square changes color when the user picks a new color.'); - } - - function draw() { - // Use the color picker to paint the background. - let c = myPicker.color(); - background(c); - } - -
- -
- - let myPicker; - - function setup() { - createCanvas(100, 100); - - // Create a color picker and set its position. - myPicker = createColorPicker('deeppink'); - myPicker.position(0, 100); - - describe('A number with the format "#rrggbb" is displayed on a pink canvas. The background color and number change when the user picks a new color.'); - } - - function draw() { - // Use the color picker to paint the background. - let c = myPicker.value(); - background(c); - - // Display the current color as a hex string. - text(c, 25, 55); - } - -
-class: p5 -params: - - name: value - description: > -

default color as a CSS color string.

- type: String|p5.Color - optional: true -return: - description: new p5.Element object. - type: p5.Element -chainable: false ---- - - -# createColorPicker diff --git a/src/content/reference/en/p5 copy/createConvolver.mdx b/src/content/reference/en/p5 copy/createConvolver.mdx deleted file mode 100644 index 89fba3be4e..0000000000 --- a/src/content/reference/en/p5 copy/createConvolver.mdx +++ /dev/null @@ -1,78 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L8885 -title: createConvolver -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: | -

Create a p5.Convolver. Accepts a path to a soundfile - that will be used to generate an impulse response.

-line: 8885 -isConstructor: false -itemtype: method -example: - - |- - -
- let cVerb, sound; - function preload() { - // We have both MP3 and OGG versions of all sound assets - soundFormats('ogg', 'mp3'); - - // Try replacing 'bx-spring' with other soundfiles like - // 'concrete-tunnel' 'small-plate' 'drum' 'beatbox' - cVerb = createConvolver('/assets/bx-spring.mp3'); - - // Try replacing 'Damscray_DancingTiger' with - // 'beat', 'doorbell', lucky_dragons_-_power_melody' - sound = loadSound('/assets/Damscray_DancingTiger.mp3'); - } - - function setup() { - let cnv = createCanvas(100, 100); - cnv.mousePressed(playSound); - background(220); - text('tap to play', 20, 20); - - // disconnect from main output... - sound.disconnect(); - - // ...and process with cVerb - // so that we only hear the convolution - cVerb.process(sound); - } - - function playSound() { - sound.play(); - } -
-class: p5 -params: - - name: path - description: | -

path to a sound file

- type: String - - name: callback - description: | -

function to call if loading is successful. - The object will be passed in as the argument - to the callback function.

- type: Function - optional: true - - name: errorCallback - description: | -

function to call if loading is not successful. - A custom error will be passed in as the argument - to the callback function.

- type: Function - optional: true -return: - description: '' - type: p5.Convolver -chainable: false ---- - - -# createConvolver diff --git a/src/content/reference/en/p5 copy/createDiv.mdx b/src/content/reference/en/p5 copy/createDiv.mdx deleted file mode 100644 index 610e0a4f67..0000000000 --- a/src/content/reference/en/p5 copy/createDiv.mdx +++ /dev/null @@ -1,72 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L491 -title: createDiv -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a

element.

- -

elements are commonly used as containers for - - other elements.

- -

The parameter html is optional. It accepts a string that sets - the - - inner HTML of the new

.

-line: 491 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a div element and set its position. - let div = createDiv('p5*js'); - div.position(25, 35); - - describe('A gray square with the text "p5*js" written in its center.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an h3 element within the div. - let div = createDiv('

p5*js

'); - div.position(20, 5); - - describe('A gray square with the text "p5*js" written in its center.'); - } -
-
-class: p5 -params: - - name: html - description: > -

inner HTML for the new <div></div> - element.

- type: String - optional: true -return: - description: new p5.Element object. - type: p5.Element -chainable: false ---- - - -# createDiv diff --git a/src/content/reference/en/p5 copy/createElement.mdx b/src/content/reference/en/p5 copy/createElement.mdx deleted file mode 100644 index 5969416251..0000000000 --- a/src/content/reference/en/p5 copy/createElement.mdx +++ /dev/null @@ -1,78 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L2493 -title: createElement -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a new p5.Element object.

- -

The first parameter, tag, is a string an HTML tag such as - 'h5'.

- -

The second parameter, content, is optional. It's a string that - sets the - - HTML content to insert into the new element. New elements have no content - - by default.

-line: 2493 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an h5 element with nothing in it. - createElement('h5'); - - describe('A gray square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an h5 element with the content "p5*js". - let h5 = createElement('h5', 'p5*js'); - - // Set the element's style and position. - h5.style('color', 'deeppink'); - h5.position(30, 15); - - describe('The text "p5*js" written in pink in the middle of a gray square.'); - } - -
-class: p5 -params: - - name: tag - description: | -

tag for the new element.

- type: String - - name: content - description: | -

HTML content to insert into the element.

- type: String - optional: true -return: - description: new p5.Element object. - type: p5.Element -chainable: false ---- - - -# createElement diff --git a/src/content/reference/en/p5 copy/createFileInput.mdx b/src/content/reference/en/p5 copy/createFileInput.mdx deleted file mode 100644 index 295f2a0434..0000000000 --- a/src/content/reference/en/p5 copy/createFileInput.mdx +++ /dev/null @@ -1,138 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1942 -title: createFileInput -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates an element of type - 'file'.

- -

createFileInput() allows users to select local files for use - in a sketch. - - It returns a p5.File object.

- -

The first parameter, callback, is a function that's called - when the file - - loads. The callback function should have one parameter, file, - that's a - - p5.File object.

- -

The second parameter, multiple, is optional. It's a boolean - value that - - allows loading multiple files if set to true. If - true, callback - - will be called once per file.

-line: 1942 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Use the file input to select an image to - // load and display. - let input; - let img; - - function setup() { - createCanvas(100, 100); - - // Create a file input and place it beneath - // the canvas. - input = createFileInput(handleImage); - input.position(0, 100); - - describe('A gray square with a file input beneath it. If the user selects an image file to load, it is displayed on the square.'); - } - - function draw() { - background(200); - - // Draw the image if loaded. - if (img) { - image(img, 0, 0, width, height); - } - } - - // Create an image if the file is an image. - function handleImage(file) { - if (file.type === 'image') { - img = createImg(file.data, ''); - img.hide(); - } else { - img = null; - } - } - -
- -
- - // Use the file input to select multiple images - // to load and display. - let input; - let images = []; - - function setup() { - // Create a file input and place it beneath - // the canvas. Allow it to load multiple files. - input = createFileInput(handleImage, true); - input.position(0, 100); - } - - function draw() { - background(200); - - // Draw the images if loaded. Each image - // is drawn 20 pixels lower than the - // previous image. - for (let i = 0; i < images.length; i += 1) { - // Calculate the y-coordinate. - let y = i * 20; - - // Draw the image. - image(images[i], 0, y, 100, 100); - } - - describe('A gray square with a file input beneath it. If the user selects multiple image files to load, they are displayed on the square.'); - } - - // Create an image if the file is an image, - // then add it to the images array. - function handleImage(file) { - if (file.type === 'image') { - let img = createImg(file.data, ''); - img.hide(); - images.push(img); - } - } - -
-class: p5 -params: - - name: callback - description: | -

function to call once the file loads.

- type: Function - - name: multiple - description: | -

allow multiple files to be selected.

- type: Boolean - optional: true -return: - description: new p5.File object. - type: p5.File -chainable: false ---- - - -# createFileInput diff --git a/src/content/reference/en/p5 copy/createFilterShader.mdx b/src/content/reference/en/p5 copy/createFilterShader.mdx deleted file mode 100644 index 5c6c9a4ec5..0000000000 --- a/src/content/reference/en/p5 copy/createFilterShader.mdx +++ /dev/null @@ -1,148 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L540 -title: createFilterShader -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Creates a p5.Shader object to be used - with the - - filter() function.

- -

createFilterShader() works like - - createShader() but has a default - vertex - - shader included. createFilterShader() is intended to be used - along with - - filter() for filtering the contents of a - canvas. - - A filter shader will be applied to the whole canvas instead of just - - p5.Geometry objects.

- -

The parameter, fragSrc, sets the fragment shader. It’s a - string that - - contains the fragment shader program written in - - GLSL.

- -

The p5.Shader object that's created - has some - - uniforms that can be set:

- -
    - -
  • sampler2D tex0, which contains the canvas contents as a - texture.
  • - -
  • vec2 canvasSize, which is the width and height of the canvas, - not including pixel density.
  • - -
  • vec2 texelSize, which is the size of a physical pixel - including pixel density. This is calculated as 1.0 / (width * - density) for the pixel width and 1.0 / (height * density) - for the pixel height.
  • - -
- -

The p5.Shader that's created also - provides - - varying vec2 vTexCoord, a coordinate with values between 0 and 1. - - vTexCoord describes where on the canvas the pixel will be - drawn.

- -

For more info about filters and shaders, see Adam Ferriss' repo of shader - examples - - or the Introduction to - Shaders tutorial.

-line: 540 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - let fragSrc = `precision highp float; - void main() { - gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); - }`; - - createCanvas(100, 100, WEBGL); - let s = createFilterShader(fragSrc); - filter(s); - describe('a yellow canvas'); - } - -
- -
- - let img, s; - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - function setup() { - let fragSrc = `precision highp float; - - // x,y coordinates, given from the vertex shader - varying vec2 vTexCoord; - - // the canvas contents, given from filter() - uniform sampler2D tex0; - // other useful information from the canvas - uniform vec2 texelSize; - uniform vec2 canvasSize; - // a custom variable from this sketch - uniform float darkness; - - void main() { - // get the color at current pixel - vec4 color = texture2D(tex0, vTexCoord); - // set the output color - color.b = 1.0; - color *= darkness; - gl_FragColor = vec4(color.rgb, 1.0); - }`; - - createCanvas(100, 100, WEBGL); - s = createFilterShader(fragSrc); - } - function draw() { - image(img, -50, -50); - s.setUniform('darkness', 0.5); - filter(s); - describe('a image of bricks tinted dark blue'); - } - -
-class: p5 -params: - - name: fragSrc - description: | -

source code for the fragment shader.

- type: String -return: - description: new shader object created from the fragment shader. - type: p5.Shader -chainable: false ---- - - -# createFilterShader diff --git a/src/content/reference/en/p5 copy/createFramebuffer.mdx b/src/content/reference/en/p5 copy/createFramebuffer.mdx deleted file mode 100644 index 80d8199779..0000000000 --- a/src/content/reference/en/p5 copy/createFramebuffer.mdx +++ /dev/null @@ -1,208 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L495 -title: createFramebuffer -module: Rendering -submodule: Rendering -file: src/core/rendering.js -description: > -

Creates and a new p5.Framebuffer - object.

- -

p5.Framebuffer objects are - separate drawing - - surfaces that can be used as textures in WebGL mode. They're similar to - - p5.Graphics objects and generally run - much - - faster when used as textures.

- -

The parameter, options, is optional. An object can be passed - to configure - - the p5.Framebuffer object. The - available - - properties are:

- -
    - -
  • format: data format of the texture, either - UNSIGNED_BYTE, FLOAT, or HALF_FLOAT. - Default is UNSIGNED_BYTE.
  • - -
  • channels: whether to store RGB or - RGBA color channels. Default is to match the main canvas which is - RGBA.
  • - -
  • depth: whether to include a depth buffer. Default is - true.
  • - -
  • depthFormat: data format of depth information, either - UNSIGNED_INT or FLOAT. Default is - FLOAT.
  • - -
  • stencil: whether to include a stencil buffer for masking. - depth must be true for this feature to work. - Defaults to the value of depth which is true.
  • - -
  • antialias: whether to perform anti-aliasing. If set to - true, as in { antialias: true }, 2 samples will be - used by default. The number of samples can also be set, as in { - antialias: 4 }. Default is to match setAttributes() which is - false (true in Safari).
  • - -
  • width: width of the p5.Framebuffer object. Default is to - always match the main canvas width.
  • - -
  • height: height of the p5.Framebuffer object. Default is to - always match the main canvas height.
  • - -
  • density: pixel density of the p5.Framebuffer object. Default is to - always match the main canvas pixel density.
  • - -
  • textureFiltering: how to read values from the p5.Framebuffer object. Either - LINEAR (nearby pixels will be interpolated) or - NEAREST (no interpolation). Generally, use LINEAR - when using the texture as an image and NEAREST if reading the - texture as data. Default is LINEAR.
  • - -
- -

If the width, height, or density - attributes are set, they won't automatically match the main canvas and must be - changed manually.

- -

Note: createFramebuffer() can only be used in WebGL mode.

-line: 495 -isConstructor: false -itemtype: method -example: - - |- - -
- - let myBuffer; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Framebuffer object. - myBuffer = createFramebuffer(); - - describe('A grid of white toruses rotating against a dark gray background.'); - } - - function draw() { - background(50); - - // Start drawing to the p5.Framebuffer object. - myBuffer.begin(); - - // Clear the drawing surface. - clear(); - - // Turn on the lights. - lights(); - - // Rotate the coordinate system. - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - - // Style the torus. - noStroke(); - - // Draw the torus. - torus(20); - - // Stop drawing to the p5.Framebuffer object. - myBuffer.end(); - - // Iterate from left to right. - for (let x = -50; x < 50; x += 25) { - // Iterate from top to bottom. - for (let y = -50; y < 50; y += 25) { - // Draw the p5.Framebuffer object to the canvas. - image(myBuffer, x, y, 25, 25); - } - } - } - -
- -
- - let myBuffer; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create an options object. - let options = { width: 25, height: 25 }; - - // Create a p5.Framebuffer object. - // Use options for configuration. - myBuffer = createFramebuffer(options); - - describe('A grid of white toruses rotating against a dark gray background.'); - } - - function draw() { - background(50); - - // Start drawing to the p5.Framebuffer object. - myBuffer.begin(); - - // Clear the drawing surface. - clear(); - - // Turn on the lights. - lights(); - - // Rotate the coordinate system. - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - - // Style the torus. - noStroke(); - - // Draw the torus. - torus(5, 2.5); - - // Stop drawing to the p5.Framebuffer object. - myBuffer.end(); - - // Iterate from left to right. - for (let x = -50; x < 50; x += 25) { - // Iterate from top to bottom. - for (let y = -50; y < 50; y += 25) { - // Draw the p5.Framebuffer object to the canvas. - image(myBuffer, x, y); - } - } - } - -
-class: p5 -params: - - name: options - description: | -

configuration options.

- type: Object - optional: true -return: - description: new framebuffer. - type: p5.Framebuffer -chainable: false ---- - - -# createFramebuffer diff --git a/src/content/reference/en/p5 copy/createGraphics.mdx b/src/content/reference/en/p5 copy/createGraphics.mdx deleted file mode 100644 index 6d75f158f4..0000000000 --- a/src/content/reference/en/p5 copy/createGraphics.mdx +++ /dev/null @@ -1,191 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L370 -title: createGraphics -module: Rendering -submodule: Rendering -file: src/core/rendering.js -description: > -

Creates a p5.Graphics object.

- -

createGraphics() creates an offscreen drawing canvas (graphics - buffer) - - and returns it as a p5.Graphics - object. Drawing - - to a separate graphics buffer can be helpful for performance and for - - organizing code.

- -

The first two parameters, width and height, are - optional. They set the - - dimensions of the p5.Graphics object. - For - - example, calling createGraphics(900, 500) creates a graphics - buffer - - that's 900×500 pixels.

- -

The third parameter is also optional. If either of the constants - P2D or - - WEBGL is passed, as in createGraphics(900, 500, - WEBGL), then it will set - - the p5.Graphics object's rendering - mode. If an - - existing - - HTMLCanvasElement - - is passed, as in createGraphics(900, 500, myCanvas), then it will - be used - - by the graphics buffer.

- -

The fourth parameter is also optional. If an existing - - HTMLCanvasElement - - is passed, as in createGraphics(900, 500, WEBGL, myCanvas), then - it will be - - used by the graphics buffer.

- -

Note: In WebGL mode, the p5.Graphics object - - will use a WebGL2 context if it's supported by the browser. Check the - - webglVersion system variable to - check what - - version is being used, or call setAttributes({ version: 1 }) to - create a - - WebGL1 context.

-line: 370 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Double-click to draw the contents of the graphics buffer. - - let pg; - - function setup() { - createCanvas(100, 100); - - background(180); - - // Create the p5.Graphics object. - pg = createGraphics(50, 50); - - // Draw to the graphics buffer. - pg.background(100); - pg.circle(pg.width / 2, pg.height / 2, 20); - - describe('A gray square. A smaller, darker square with a white circle at its center appears when the user double-clicks.'); - } - - // Display the graphics buffer when the user double-clicks. - function doubleClicked() { - if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { - image(pg, 25, 25); - } - } - -
- -
- - // Double-click to draw the contents of the graphics buffer. - - let pg; - - function setup() { - createCanvas(100, 100); - - background(180); - - // Create the p5.Graphics object in WebGL mode. - pg = createGraphics(50, 50, WEBGL); - - // Draw to the graphics buffer. - pg.background(100); - pg.lights(); - pg.noStroke(); - pg.rotateX(QUARTER_PI); - pg.rotateY(QUARTER_PI); - pg.torus(15, 5); - - describe('A gray square. A smaller, darker square with a white torus at its center appears when the user double-clicks.'); - } - - // Display the graphics buffer when the user double-clicks. - function doubleClicked() { - if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { - image(pg, 25, 25); - } - } - -
-class: p5 -return: - description: new graphics buffer. - type: p5.Graphics -overloads: - - line: 370 - params: - - name: width - description: | -

width of the graphics buffer.

- type: Number - - name: height - description: | -

height of the graphics buffer.

- type: Number - - name: renderer - description: | -

either P2D or WEBGL. Defaults to P2D.

- type: Constant - optional: true - - name: canvas - description: | -

existing canvas element that should be - used for the graphics buffer..

- type: HTMLCanvasElement - optional: true - return: - description: new graphics buffer. - type: p5.Graphics - - line: 475 - params: - - name: width - description: '' - type: Number - - name: height - description: '' - type: Number - - name: canvas - description: '' - type: HTMLCanvasElement - optional: true - return: - description: '' - type: p5.Graphics -chainable: false ---- - - -# createGraphics diff --git a/src/content/reference/en/p5 copy/createImage.mdx b/src/content/reference/en/p5 copy/createImage.mdx deleted file mode 100644 index 33c151c315..0000000000 --- a/src/content/reference/en/p5 copy/createImage.mdx +++ /dev/null @@ -1,172 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/image.js#L15 -title: createImage -module: Image -submodule: Image -file: src/image/image.js -description: > -

Creates a new p5.Image object.

- -

createImage() uses the width and - height parameters to set the new - - p5.Image object's dimensions in pixels. - The new - - p5.Image can be modified by updating its - - pixels array or by calling its - - get() and - - set() methods. The - - loadPixels() method must be - called - - before reading or modifying pixel values. The - - updatePixels() method must be - called - - for updates to take effect.

- -

Note: The new p5.Image object is - transparent by - - default.

-line: 15 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Image object. - let img = createImage(66, 66); - - // Load the image's pixels into memory. - img.loadPixels(); - - // Set all the image's pixels to black. - for (let x = 0; x < img.width; x += 1) { - for (let y = 0; y < img.height; y += 1) { - img.set(x, y, 0); - } - } - - // Update the image's pixel values. - img.updatePixels(); - - // Draw the image. - image(img, 17, 17); - - describe('A black square drawn in the middle of a gray square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Image object. - let img = createImage(66, 66); - - // Load the image's pixels into memory. - img.loadPixels(); - - // Create a color gradient. - for (let x = 0; x < img.width; x += 1) { - for (let y = 0; y < img.height; y += 1) { - // Calculate the transparency. - let a = map(x, 0, img.width, 0, 255); - - // Create a p5.Color object. - let c = color(0, a); - - // Set the pixel's color. - img.set(x, y, c); - } - } - - // Update the image's pixels. - img.updatePixels(); - - // Display the image. - image(img, 17, 17); - - describe('A square with a horizontal color gradient that transitions from gray to black.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Image object. - let img = createImage(66, 66); - - // Load the pixels into memory. - img.loadPixels(); - // Get the current pixel density. - let d = pixelDensity(); - - // Calculate the pixel that is halfway through the image's pixel array. - let halfImage = 4 * (d * img.width) * (d * img.height / 2); - - // Set half of the image's pixels to black. - for (let i = 0; i < halfImage; i += 4) { - // Red. - img.pixels[i] = 0; - // Green. - img.pixels[i + 1] = 0; - // Blue. - img.pixels[i + 2] = 0; - // Alpha. - img.pixels[i + 3] = 255; - } - - // Update the image's pixels. - img.updatePixels(); - - // Display the image. - image(img, 17, 17); - - describe('A black square drawn in the middle of a gray square.'); - } - -
-class: p5 -params: - - name: width - description: | -

width in pixels.

- type: Integer - - name: height - description: | -

height in pixels.

- type: Integer -return: - description: new p5.Image object. - type: p5.Image -chainable: false ---- - - -# createImage diff --git a/src/content/reference/en/p5 copy/createImg.mdx b/src/content/reference/en/p5 copy/createImg.mdx deleted file mode 100644 index 22b71d22c4..0000000000 --- a/src/content/reference/en/p5 copy/createImg.mdx +++ /dev/null @@ -1,115 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L649 -title: createImg -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates an element that can appear outside of the - canvas.

- -

The first parameter, src, is a string with the path to the - image file. - - src should be a relative path, as in - '/assets/image.png', or a URL, as - - in 'https://example.com/image.png'.

- -

The second parameter, alt, is a string with the - - alternate text - - for the image. An empty string '' can be used for images that - aren't displayed.

- -

The third parameter, crossOrigin, is optional. It's a string - that sets the - - crossOrigin property - - of the image. Use 'anonymous' or 'use-credentials' - to fetch the image - - with cross-origin access.

- -

The fourth parameter, callback, is also optional. It sets a - function to - - call after the image loads. The new image is passed to the callback - - function as a p5.Element object.

-line: 649 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - let img = createImg( - 'https://p5js.org//assets/img/asterisk-01.png', - 'The p5.js magenta asterisk.' - ); - img.position(0, -10); - - describe('A gray square with a magenta asterisk in its center.'); - } - -
-class: p5 -return: - description: new p5.Element object. - type: p5.Element -overloads: - - line: 649 - params: - - name: src - description: | -

relative path or URL for the image.

- type: String - - name: alt - description: | -

alternate text for the image.

- type: String - return: - description: new p5.Element object. - type: p5.Element - - line: 693 - params: - - name: src - description: '' - type: String - - name: alt - description: '' - type: String - - name: crossOrigin - description: | -

crossOrigin property to use when fetching the image.

- type: String - optional: true - - name: successCallback - description: | -

function to call once the image loads. The new image will be passed - to the function as a p5.Element object.

- type: Function - optional: true - return: - description: new p5.Element object. - type: p5.Element -chainable: false ---- - - -# createImg diff --git a/src/content/reference/en/p5 copy/createInput.mdx b/src/content/reference/en/p5 copy/createInput.mdx deleted file mode 100644 index 3a790ee6b2..0000000000 --- a/src/content/reference/en/p5 copy/createInput.mdx +++ /dev/null @@ -1,118 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1859 -title: createInput -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a text element.

- -

Call myInput.size() to set the length of the text box.

- -

The first parameter, value, is optional. It's a string that - sets the - - input's default value. The input is blank by default.

- -

The second parameter, type, is also optional. It's a string - that - - specifies the type of text being input. See MDN for a full - - list of options. - - The default is 'text'.

-line: 1859 -isConstructor: false -itemtype: method -example: - - |- - -
- - let myInput; - - function setup() { - createCanvas(100, 100); - - // Create an input element and place it - // beneath the canvas. - myInput = createInput(); - myInput.position(0, 100); - - describe('A gray square with a text box beneath it. The text in the square changes when the user types something new in the input bar.'); - } - - function draw() { - background(200); - - // Use the input to display a message. - let msg = myInput.value(); - text(msg, 25, 55); - } - -
- -
- - let myInput; - - function setup() { - createCanvas(100, 100); - - // Create an input element and place it - // beneath the canvas. Set its default - // text to "hello!". - myInput = createInput('hello!'); - myInput.position(0, 100); - - describe('The text "hello!" written at the center of a gray square. A text box beneath the square also says "hello!". The text in the square changes when the user types something new in the input bar.'); - } - - function draw() { - background(200); - - // Use the input to display a message. - let msg = myInput.value(); - text(msg, 25, 55); - } - -
-class: p5 -return: - description: new p5.Element object. - type: p5.Element -overloads: - - line: 1859 - params: - - name: value - description: > -

default value of the input box. Defaults to an empty string - ''.

- type: String - optional: true - - name: type - description: | -

type of input. Defaults to 'text'.

- type: String - optional: true - return: - description: new p5.Element object. - type: p5.Element - - line: 1929 - params: - - name: value - description: '' - type: String - optional: true - return: - description: '' - type: p5.Element -chainable: false ---- - - -# createInput diff --git a/src/content/reference/en/p5 copy/createModel.mdx b/src/content/reference/en/p5 copy/createModel.mdx deleted file mode 100644 index c94e95900f..0000000000 --- a/src/content/reference/en/p5 copy/createModel.mdx +++ /dev/null @@ -1,193 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/loading.js#L1132 -title: createModel -module: Shape -submodule: 3D Models -file: src/webgl/loading.js -description: > -

Load a 3d model from an OBJ or STL string.

- -

OBJ and STL files lack a built-in sense of scale, causing models exported - from different programs to vary in size. - - If your model doesn't display correctly, consider using - loadModel() with normalize set to true - to standardize its size. - - Further adjustments can be made using the scale() function.

- -

Also, the support for colored STL files is not present. STL files with - color will be - - rendered without color properties.

- -
    - -
  • Options can include:
  • - -
- -
    - -
  • modelString: Specifies the plain text string of either an stl - or obj file to be loaded.
  • - -
  • fileType: Defines the file extension of the model.
  • - -
  • normalize: Enables standardized size scaling during loading - if set to true.
  • - -
  • successCallback: Callback for post-loading actions with the - 3D model object.
  • - -
  • failureCallback: Handles errors if model loading fails, - receiving an event error.
  • - -
  • flipU: Flips the U texture coordinates of the model.
  • - -
  • flipV: Flips the V texture coordinates of the model.
  • - -
-line: 1132 -isConstructor: false -itemtype: method -example: - - |- - -
- - const octahedron_model = ` - v 0.000000E+00 0.000000E+00 40.0000 - v 22.5000 22.5000 0.000000E+00 - v 22.5000 -22.5000 0.000000E+00 - v -22.5000 -22.5000 0.000000E+00 - v -22.5000 22.5000 0.000000E+00 - v 0.000000E+00 0.000000E+00 -40.0000 - f 1 2 3 - f 1 3 4 - f 1 4 5 - f 1 5 2 - f 6 5 4 - f 6 4 3 - f 6 3 2 - f 6 2 5 - `; - //draw a spinning octahedron - let octahedron; - - function setup() { - createCanvas(100, 100, WEBGL); - octahedron = createModel(octahedron_model, '.obj'); - describe('Vertically rotating 3D octahedron.'); - } - - function draw() { - background(200); - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - model(octahedron); - } - -
-class: p5 -return: - description: the p5.Geometry object - type: p5.Geometry -overloads: - - line: 1132 - params: - - name: modelString - description: | -

String of the object to be loaded

- type: String - - name: fileType - description: | -

The file extension of the model - (.stl, .obj).

- type: String - optional: true - - name: normalize - description: | -

If true, scale the model to a - standardized size when loading

- type: Boolean - - name: successCallback - description: | -

Function to be called - once the model is loaded. Will be passed - the 3D model object.

- type: function(p5.Geometry) - optional: true - - name: failureCallback - description: | -

called with event error if - the model fails to load.

- type: Function(Event) - optional: true - return: - description: the p5.Geometry object - type: p5.Geometry - - line: 1202 - params: - - name: modelString - description: '' - type: String - - name: fileType - description: '' - type: String - optional: true - - name: successCallback - description: '' - type: function(p5.Geometry) - optional: true - - name: failureCallback - description: '' - type: Function(Event) - optional: true - return: - description: the p5.Geometry object - type: p5.Geometry - - line: 1210 - params: - - name: modelString - description: '' - type: String - - name: fileType - description: '' - type: String - optional: true - - name: options - description: '' - type: Object - optional: true - props: - - name: successCallback - description: '' - type: function(p5.Geometry) - optional: true - - name: failureCallback - description: '' - type: Function(Event) - optional: true - - name: normalize - description: '' - type: Boolean - optional: true - - name: flipU - description: '' - type: Boolean - optional: true - - name: flipV - description: '' - type: Boolean - optional: true - return: - description: the p5.Geometry object - type: p5.Geometry -chainable: false ---- - - -# createModel diff --git a/src/content/reference/en/p5 copy/createNumberDict.mdx b/src/content/reference/en/p5 copy/createNumberDict.mdx deleted file mode 100644 index 952410a222..0000000000 --- a/src/content/reference/en/p5 copy/createNumberDict.mdx +++ /dev/null @@ -1,57 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/data/p5.TypedDict.js#L48 -title: createNumberDict -module: Data -submodule: Dictionary -file: src/data/p5.TypedDict.js -description: > -

Creates a new instance of p5.NumberDict using the key-value pair - or object you provide.

-line: 48 -isConstructor: false -itemtype: method -example: - - |2- - -
- - function setup() { - let myDictionary = createNumberDict(100, 42); - print(myDictionary.hasKey(100)); // logs true to console - let anotherDictionary = createNumberDict({ 200: 84 }); - print(anotherDictionary.hasKey(200)); // logs true to console - } -
-class: p5 -return: - description: '' - type: p5.NumberDict -overloads: - - line: 48 - params: - - name: key - description: '' - type: Number - - name: value - description: '' - type: Number - return: - description: '' - type: p5.NumberDict - - line: 71 - params: - - name: object - description: | -

object

- type: Object - return: - description: '' - type: p5.NumberDict -chainable: false ---- - - -# createNumberDict diff --git a/src/content/reference/en/p5 copy/createP.mdx b/src/content/reference/en/p5 copy/createP.mdx deleted file mode 100644 index 6d3005fc37..0000000000 --- a/src/content/reference/en/p5 copy/createP.mdx +++ /dev/null @@ -1,54 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L543 -title: createP -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a paragraph element.

- -

elements are commonly used for paragraph-length - text.

- -

The parameter html is optional. It accepts a string that sets - the - - inner HTML of the new

.

-line: 543 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a paragraph element and set its position. - let p = createP('Tell me a story.'); - p.position(5, 0); - - describe('A gray square displaying the text "Tell me a story." written in black.'); - } - -
-class: p5 -params: - - name: html - description: | -

inner HTML for the new <p></p> element.

- type: String - optional: true -return: - description: new p5.Element object. - type: p5.Element -chainable: false ---- - - -# createP diff --git a/src/content/reference/en/p5 copy/createRadio.mdx b/src/content/reference/en/p5 copy/createRadio.mdx deleted file mode 100644 index f2b8a2a81c..0000000000 --- a/src/content/reference/en/p5 copy/createRadio.mdx +++ /dev/null @@ -1,223 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1440 -title: createRadio -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a radio button element.

- -

The parameter is optional. If a string is passed, as in - - let myRadio = createSelect('food'), then each radio option will - - have "food" as its name parameter: . - - If an existing

or - - element is passed, as in let myRadio = createSelect(container), - it will - - become the radio button's parent element.

- -

Radio buttons extend the p5.Element - class with a few - - helpful methods for managing options:

- -
    - -
  • myRadio.option(value, [label]) adds an option to the menu. - The first parameter, value, is a string that sets the option's - value and label. The second parameter, label, is optional. If - provided, it sets the label displayed for the value. If an option - with value already exists, its label is changed and its value is - returned.
  • - -
  • myRadio.value() returns the currently-selected option's - value.
  • - -
  • myRadio.selected() returns the currently-selected - option.
  • - -
  • myRadio.selected(value) selects the given option and returns - it as an HTMLInputElement.
  • - -
  • myRadio.disable(shouldDisable) Disables the radio button if - true is passed, and enables it if false is - passed.
  • - -
-line: 1440 -isConstructor: false -itemtype: method -example: - - |- - -
- - let style = document.createElement('style'); - style.innerHTML = ` - .p5-radio label { - display: flex; - align-items: center; - } - .p5-radio input { - margin-right: 5px; - } - `; - document.head.appendChild(style); - - let myRadio; - - function setup() { - createCanvas(100, 100); - - // Create a radio button element and place it - // in the top-left corner. - myRadio = createRadio(); - myRadio.position(0, 0); - myRadio.class('p5-radio'); - myRadio.size(60); - - // Add a few color options. - myRadio.option('red'); - myRadio.option('yellow'); - myRadio.option('blue'); - - // Choose a default option. - myRadio.selected('yellow'); - - describe('A yellow square with three color options listed, "red", "yellow", and "blue". The square changes color when the user selects a new option.'); - } - - function draw() { - // Set the background color using the radio button. - let g = myRadio.value(); - background(g); - } - -
- -
- - let myRadio; - - function setup() { - createCanvas(100, 100); - - // Create a radio button element and place it - // in the top-left corner. - myRadio = createRadio(); - myRadio.position(0, 0); - myRadio.size(50); - - // Add a few color options. - // Color values are labeled with - // emotions they evoke. - myRadio.option('red', 'love'); - myRadio.option('yellow', 'joy'); - myRadio.option('blue', 'trust'); - - // Choose a default option. - myRadio.selected('yellow'); - - describe('A yellow square with three options listed, "love", "joy", and "trust". The square changes color when the user selects a new option.'); - } - - function draw() { - // Set the background color using the radio button. - let c = myRadio.value(); - background(c); - } - -
- -
- - let myRadio; - - function setup() { - createCanvas(100, 100); - - // Create a radio button element and place it - // in the top-left corner. - myRadio = createRadio(); - myRadio.position(0, 0); - myRadio.class('p5-radio'); - myRadio.size(50); - - // Add a few color options. - myRadio.option('red'); - myRadio.option('yellow'); - myRadio.option('blue'); - - // Choose a default option. - myRadio.selected('yellow'); - - // Create a button and place it beneath the canvas. - let btn = createButton('disable'); - btn.position(0, 100); - - // Call disableRadio() when btn is pressed. - btn.mousePressed(disableRadio); - - describe('A yellow square with three options listed, "red", "yellow", and "blue". The square changes color when the user selects a new option. A "disable" button beneath the canvas disables the color options when pressed.'); - } - - function draw() { - // Set the background color using the radio button. - let c = myRadio.value(); - background(c); - } - - // Disable myRadio. - function disableRadio() { - myRadio.disable(true); - } - -
-class: p5 -return: - description: new p5.Element object. - type: p5.Element -overloads: - - line: 1440 - params: - - name: containerElement - description: > -

container HTML Element, either a - <div></div> - - or <span></span>.

- type: Object - optional: true - return: - description: new p5.Element object. - type: p5.Element - - line: 1588 - params: - - name: name - description: > -

name parameter assigned to each option's - <input></input> element.

- type: String - optional: true - return: - description: new p5.Element object. - type: p5.Element - - line: 1593 - params: [] - return: - description: new p5.Element object. - type: p5.Element -chainable: false ---- - - -# createRadio diff --git a/src/content/reference/en/p5 copy/createSelect.mdx b/src/content/reference/en/p5 copy/createSelect.mdx deleted file mode 100644 index 496f4082e6..0000000000 --- a/src/content/reference/en/p5 copy/createSelect.mdx +++ /dev/null @@ -1,235 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1159 -title: createSelect -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a dropdown menu element.

- -

The parameter is optional. If true is passed, as in - - let mySelect = createSelect(true), then the dropdown will support - - multiple selections. If an existing element - - is passed, as in let mySelect = createSelect(otherSelect), the - existing - - element will be wrapped in a new p5.Element - - object.

- -

Dropdowns extend the p5.Element - class with a few - - helpful methods for managing options:

- -
    - -
  • mySelect.option(name, [value]) adds an option to the menu. - The first paremeter, name, is a string that sets the option's - name and value. The second parameter, value, is optional. If - provided, it sets the value that corresponds to the key name. If - an option with name already exists, its value is changed to - value.
  • - -
  • mySelect.value() returns the currently-selected option's - value.
  • - -
  • mySelect.selected() returns the currently-selected - option.
  • - -
  • mySelect.selected(option) selects the given option by - default.
  • - -
  • mySelect.disable() marks the whole dropdown element as - disabled.
  • - -
  • mySelect.disable(option) marks a given option as - disabled.
  • - -
  • mySelect.enable() marks the whole dropdown element as - enabled.
  • - -
  • mySelect.enable(option) marks a given option as enabled.
  • - -
-line: 1159 -isConstructor: false -itemtype: method -example: - - |- - -
- - let mySelect; - - function setup() { - createCanvas(100, 100); - - // Create a dropdown and place it beneath the canvas. - mySelect = createSelect(); - mySelect.position(0, 100); - - // Add color options. - mySelect.option('red'); - mySelect.option('green'); - mySelect.option('blue'); - mySelect.option('yellow'); - - // Set the selected option to "red". - mySelect.selected('red'); - - describe('A red square with a dropdown menu beneath it. The square changes color when a new color is selected.'); - } - - function draw() { - // Use the selected value to paint the background. - let c = mySelect.selected(); - background(c); - } - -
- -
- - let mySelect; - - function setup() { - createCanvas(100, 100); - - // Create a dropdown and place it beneath the canvas. - mySelect = createSelect(); - mySelect.position(0, 100); - - // Add color options. - mySelect.option('red'); - mySelect.option('green'); - mySelect.option('blue'); - mySelect.option('yellow'); - - // Set the selected option to "red". - mySelect.selected('red'); - - // Disable the "yellow" option. - mySelect.disable('yellow'); - - describe('A red square with a dropdown menu beneath it. The square changes color when a new color is selected.'); - } - - function draw() { - // Use the selected value to paint the background. - let c = mySelect.selected(); - background(c); - } - -
- -
- - let mySelect; - - function setup() { - createCanvas(100, 100); - - // Create a dropdown and place it beneath the canvas. - mySelect = createSelect(); - mySelect.position(0, 100); - - // Add color options with names and values. - mySelect.option('one', 'red'); - mySelect.option('two', 'green'); - mySelect.option('three', 'blue'); - mySelect.option('four', 'yellow'); - - // Set the selected option to "one". - mySelect.selected('one'); - - describe('A red square with a dropdown menu beneath it. The square changes color when a new color is selected.'); - } - - function draw() { - // Use the selected value to paint the background. - let c = mySelect.selected(); - background(c); - } - -
- -
- - // Hold CTRL to select multiple options on Windows and Linux. - // Hold CMD to select multiple options on macOS. - let mySelect; - - function setup() { - createCanvas(100, 100); - - // Create a dropdown and allow multiple selections. - // Place it beneath the canvas. - mySelect = createSelect(true); - mySelect.position(0, 100); - - // Add color options. - mySelect.option('red'); - mySelect.option('green'); - mySelect.option('blue'); - mySelect.option('yellow'); - - describe('A gray square with a dropdown menu beneath it. Colorful circles appear when their color is selected.'); - } - - function draw() { - background(200); - - // Use the selected value(s) to draw circles. - let colors = mySelect.selected(); - for (let i = 0; i < colors.length; i += 1) { - // Calculate the x-coordinate. - let x = 10 + i * 20; - - // Access the color. - let c = colors[i]; - - // Draw the circle. - fill(c); - circle(x, 50, 20); - } - } - -
-class: p5 -return: - description: new p5.Element object. - type: p5.Element -overloads: - - line: 1159 - params: - - name: multiple - description: | -

support multiple selections.

- type: Boolean - optional: true - return: - description: new p5.Element object. - type: p5.Element - - line: 1324 - params: - - name: existing - description: > -

select element to wrap, either as a p5.Element or - a HTMLSelectElement.

- type: Object - return: - description: '' - type: p5.Element -chainable: false ---- - - -# createSelect diff --git a/src/content/reference/en/p5 copy/createShader.mdx b/src/content/reference/en/p5 copy/createShader.mdx deleted file mode 100644 index c595145529..0000000000 --- a/src/content/reference/en/p5 copy/createShader.mdx +++ /dev/null @@ -1,438 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L173 -title: createShader -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Creates a new p5.Shader object.

- -

Shaders are programs that run on the graphics processing unit (GPU). They - - can process many pixels at the same time, making them fast for many - - graphics tasks. They’re written in a language called - - GLSL - - and run along with the rest of the code in a sketch.

- -

Once the p5.Shader object is created, - it can be - - used with the shader() function, as in - - shader(myShader). A shader program consists of two parts, a - vertex shader - - and a fragment shader. The vertex shader affects where 3D geometry is drawn - - on the screen and the fragment shader affects color.

- -

The first parameter, vertSrc, sets the vertex shader. It’s a - string that - - contains the vertex shader program written in GLSL.

- -

The second parameter, fragSrc, sets the fragment shader. It’s - a string - - that contains the fragment shader program written in GLSL.

- -

A shader can optionally describe hooks, which are functions in - GLSL that - - users may choose to provide to customize the behavior of the shader using the - - modify() method of - p5.Shader. These are added by - - describing the hooks in a third parameter, options, and - referencing the hooks in - - your vertSrc or fragSrc. Hooks for the vertex or - fragment shader are described under - - the vertex and fragment keys of - options. Each one is an object. where each key is - - the type and name of a hook function, and each value is a string with the - - parameter list and default implementation of the hook. For example, to let - users - - optionally run code at the start of the vertex shader, the options object - could - - include:

- -
{
-    vertex: {
-      'void beforeVertex': '() {}'
-    }
-  }
-
-  
- -

Then, in your vertex shader source, you can run a hook by calling a - function - - with the same name prefixed by HOOK_. If you want to check if the - default - - hook has been replaced, maybe to avoid extra overhead, you can check if the - - same name prefixed by AUGMENTED_HOOK_ has been defined:

- -
void main() {
-    // In most cases, just calling the hook is fine:
-    HOOK_beforeVertex();
-
-    // Alternatively, for more efficiency:
-    #ifdef AUGMENTED_HOOK_beforeVertex
-    HOOK_beforeVertex();
-    #endif
-
-    // Add the rest of your shader code here!
-  }
-
-  
- -

Note: Only filter shaders can be used in 2D mode. All shaders can be used - - in WebGL mode.

-line: 173 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Note: A "uniform" is a global variable within a shader program. - - // Create a string with the vertex shader program. - // The vertex shader is called for each vertex. - let vertSrc = ` - precision highp float; - uniform mat4 uModelViewMatrix; - uniform mat4 uProjectionMatrix; - attribute vec3 aPosition; - attribute vec2 aTexCoord; - varying vec2 vTexCoord; - - void main() { - vTexCoord = aTexCoord; - vec4 positionVec4 = vec4(aPosition, 1.0); - gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; - } - `; - - // Create a string with the fragment shader program. - // The fragment shader is called for each pixel. - let fragSrc = ` - precision highp float; - - void main() { - // Set each pixel's RGBA value to yellow. - gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); - } - `; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Shader object. - let shaderProgram = createShader(vertSrc, fragSrc); - - // Compile and apply the p5.Shader object. - shader(shaderProgram); - - // Style the drawing surface. - noStroke(); - - // Add a plane as a drawing surface. - plane(100, 100); - - describe('A yellow square.'); - } - -
- -
- - // Note: A "uniform" is a global variable within a shader program. - - // Create a string with the vertex shader program. - // The vertex shader is called for each vertex. - let vertSrc = ` - precision highp float; - uniform mat4 uModelViewMatrix; - uniform mat4 uProjectionMatrix; - attribute vec3 aPosition; - attribute vec2 aTexCoord; - varying vec2 vTexCoord; - - void main() { - vTexCoord = aTexCoord; - vec4 positionVec4 = vec4(aPosition, 1.0); - gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; - } - `; - - // Create a string with the fragment shader program. - // The fragment shader is called for each pixel. - let fragSrc = ` - precision highp float; - uniform vec2 p; - uniform float r; - const int numIterations = 500; - varying vec2 vTexCoord; - - void main() { - vec2 c = p + gl_FragCoord.xy * r; - vec2 z = c; - float n = 0.0; - - for (int i = numIterations; i > 0; i--) { - if (z.x * z.x + z.y * z.y > 4.0) { - n = float(i) / float(numIterations); - break; - } - z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c; - } - - gl_FragColor = vec4( - 0.5 - cos(n * 17.0) / 2.0, - 0.5 - cos(n * 13.0) / 2.0, - 0.5 - cos(n * 23.0) / 2.0, - 1.0 - ); - } - `; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Shader object. - let mandelbrot = createShader(vertSrc, fragSrc); - - // Compile and apply the p5.Shader object. - shader(mandelbrot); - - // Set the shader uniform p to an array. - // p is the center point of the Mandelbrot image. - mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); - - // Set the shader uniform r to 0.005. - // r is the size of the image in Mandelbrot-space. - mandelbrot.setUniform('r', 0.005); - - // Style the drawing surface. - noStroke(); - - // Add a plane as a drawing surface. - plane(100, 100); - - describe('A black fractal image on a magenta background.'); - } - -
- -
- - // Note: A "uniform" is a global variable within a shader program. - - // Create a string with the vertex shader program. - // The vertex shader is called for each vertex. - let vertSrc = ` - precision highp float; - uniform mat4 uModelViewMatrix; - uniform mat4 uProjectionMatrix; - - attribute vec3 aPosition; - attribute vec2 aTexCoord; - varying vec2 vTexCoord; - - void main() { - vTexCoord = aTexCoord; - vec4 positionVec4 = vec4(aPosition, 1.0); - gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; - } - `; - - // Create a string with the fragment shader program. - // The fragment shader is called for each pixel. - let fragSrc = ` - precision highp float; - uniform vec2 p; - uniform float r; - const int numIterations = 500; - varying vec2 vTexCoord; - - void main() { - vec2 c = p + gl_FragCoord.xy * r; - vec2 z = c; - float n = 0.0; - - for (int i = numIterations; i > 0; i--) { - if (z.x * z.x + z.y * z.y > 4.0) { - n = float(i) / float(numIterations); - break; - } - - z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c; - } - - gl_FragColor = vec4( - 0.5 - cos(n * 17.0) / 2.0, - 0.5 - cos(n * 13.0) / 2.0, - 0.5 - cos(n * 23.0) / 2.0, - 1.0 - ); - } - `; - - let mandelbrot; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Shader object. - mandelbrot = createShader(vertSrc, fragSrc); - - // Apply the p5.Shader object. - shader(mandelbrot); - - // Set the shader uniform p to an array. - // p is the center point of the Mandelbrot image. - mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); - - describe('A fractal image zooms in and out of focus.'); - } - - function draw() { - // Set the shader uniform r to a value that oscillates - // between 0 and 0.005. - // r is the size of the image in Mandelbrot-space. - let radius = 0.005 * (sin(frameCount * 0.01) + 1); - mandelbrot.setUniform('r', radius); - - // Style the drawing surface. - noStroke(); - - // Add a plane as a drawing surface. - plane(100, 100); - } - -
- -
- - // A shader with hooks. - let myShader; - - // A shader with modified hooks. - let modifiedShader; - - // Create a string with the vertex shader program. - // The vertex shader is called for each vertex. - let vertSrc = ` - precision highp float; - uniform mat4 uModelViewMatrix; - uniform mat4 uProjectionMatrix; - - attribute vec3 aPosition; - attribute vec2 aTexCoord; - - void main() { - vec4 positionVec4 = vec4(aPosition, 1.0); - gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; - } - `; - - // Create a fragment shader that uses a hook. - let fragSrc = ` - precision highp float; - void main() { - // Let users override the color - gl_FragColor = HOOK_getColor(vec4(1., 0., 0., 1.)); - } - `; - - function setup() { - createCanvas(50, 50, WEBGL); - - // Create a shader with hooks - myShader = createShader(vertSrc, fragSrc, { - fragment: { - 'vec4 getColor': '(vec4 color) { return color; }' - } - }); - - // Make a version of the shader with a hook overridden - modifiedShader = myShader.modify({ - 'vec4 getColor': `(vec4 color) { - return vec4(0., 0., 1., 1.); - }` - }); - } - - function draw() { - noStroke(); - - push(); - shader(myShader); - translate(-width/3, 0); - sphere(10); - pop(); - - push(); - shader(modifiedShader); - translate(width/3, 0); - sphere(10); - pop(); - } - -
-class: p5 -params: - - name: vertSrc - description: | -

source code for the vertex shader.

- type: String - - name: fragSrc - description: | -

source code for the fragment shader.

- type: String - - name: options - description: > -

An optional object describing how this shader can - - be augmented with hooks. It can include:

- -
    - -
  • vertex: An object describing the available vertex shader - hooks.
  • - -
  • fragment: An object describing the available frament - shader hooks.
  • - -
- type: Object - optional: true -return: - description: |- - new shader object created from the - vertex and fragment shaders. - type: p5.Shader -chainable: false ---- - - -# createShader diff --git a/src/content/reference/en/p5 copy/createSlider.mdx b/src/content/reference/en/p5 copy/createSlider.mdx deleted file mode 100644 index 7bdf510078..0000000000 --- a/src/content/reference/en/p5 copy/createSlider.mdx +++ /dev/null @@ -1,162 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L789 -title: createSlider -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a slider element.

- -

Range sliders are useful for quickly selecting numbers from a given - range.

- -

The first two parameters, min and max, are - numbers that set the - - slider's minimum and maximum.

- -

The third parameter, value, is optional. It's a number that - sets the - - slider's default value.

- -

The fourth parameter, step, is also optional. It's a number - that sets the - - spacing between each value in the slider's range. Setting step to - 0 - - allows the slider to move smoothly from min to - max.

-line: 789 -isConstructor: false -itemtype: method -example: - - |- - -
- - let slider; - - function setup() { - createCanvas(100, 100); - - // Create a slider and place it at the top of the canvas. - slider = createSlider(0, 255); - slider.position(10, 10); - slider.size(80); - - describe('A dark gray square with a range slider at the top. The square changes color when the slider is moved.'); - } - - function draw() { - // Use the slider as a grayscale value. - let g = slider.value(); - background(g); - } - -
- -
- - let slider; - - function setup() { - createCanvas(100, 100); - - // Create a slider and place it at the top of the canvas. - // Set its default value to 0. - slider = createSlider(0, 255, 0); - slider.position(10, 10); - slider.size(80); - - describe('A black square with a range slider at the top. The square changes color when the slider is moved.'); - } - - function draw() { - // Use the slider as a grayscale value. - let g = slider.value(); - background(g); - } - -
- -
- - let slider; - - function setup() { - createCanvas(100, 100); - - // Create a slider and place it at the top of the canvas. - // Set its default value to 0. - // Set its step size to 50. - slider = createSlider(0, 255, 0, 50); - slider.position(10, 10); - slider.size(80); - - describe('A black square with a range slider at the top. The square changes color when the slider is moved.'); - } - - function draw() { - // Use the slider as a grayscale value. - let g = slider.value(); - background(g); - } - -
- -
- - let slider; - - function setup() { - createCanvas(100, 100); - - // Create a slider and place it at the top of the canvas. - // Set its default value to 0. - // Set its step size to 0 so that it moves smoothly. - slider = createSlider(0, 255, 0, 0); - slider.position(10, 10); - slider.size(80); - - describe('A black square with a range slider at the top. The square changes color when the slider is moved.'); - } - - function draw() { - // Use the slider as a grayscale value. - let g = slider.value(); - background(g); - } - -
-class: p5 -params: - - name: min - description: | -

minimum value of the slider.

- type: Number - - name: max - description: | -

maximum value of the slider.

- type: Number - - name: value - description: | -

default value of the slider.

- type: Number - optional: true - - name: step - description: | -

size for each step in the slider's range.

- type: Number - optional: true -return: - description: new p5.Element object. - type: p5.Element -chainable: false ---- - - -# createSlider diff --git a/src/content/reference/en/p5 copy/createSpan.mdx b/src/content/reference/en/p5 copy/createSpan.mdx deleted file mode 100644 index ed346b35dc..0000000000 --- a/src/content/reference/en/p5 copy/createSpan.mdx +++ /dev/null @@ -1,93 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L578 -title: createSpan -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a element.

- -

elements are commonly used as containers - - for inline elements. For example, a - - can hold part of a sentence that's a - - different style.

- -

The parameter html is optional. It accepts a string that sets - the - - inner HTML of the new .

-line: 578 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a span element and set its position. - let span = createSpan('p5*js'); - span.position(25, 35); - - describe('A gray square with the text "p5*js" written in its center.'); - } - -
- -
- - function setup() { - background(200); - - // Create a div element as a container. - let div = createDiv(); - - // Place the div at the center. - div.position(25, 35); - - // Create a span element. - let s1 = createSpan('p5'); - - // Create a second span element. - let s2 = createSpan('*'); - - // Set the second span's font color. - s2.style('color', 'deeppink'); - - // Create a third span element. - let s3 = createSpan('js'); - - // Add all the spans to the container div. - s1.parent(div); - s2.parent(div); - s3.parent(div); - - describe('A gray square with the text "p5*js" written in black at its center. The asterisk is pink.'); - } - -
-class: p5 -params: - - name: html - description: > -

inner HTML for the new <span></span> - element.

- type: String - optional: true -return: - description: new p5.Element object. - type: p5.Element -chainable: false ---- - - -# createSpan diff --git a/src/content/reference/en/p5 copy/createStringDict.mdx b/src/content/reference/en/p5 copy/createStringDict.mdx deleted file mode 100644 index bc080c1276..0000000000 --- a/src/content/reference/en/p5 copy/createStringDict.mdx +++ /dev/null @@ -1,56 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/data/p5.TypedDict.js#L14 -title: createStringDict -module: Data -submodule: Dictionary -file: src/data/p5.TypedDict.js -description: | -

Creates a new instance of p5.StringDict using the key-value pair - or the object you provide.

-line: 14 -isConstructor: false -itemtype: method -example: - - |2- - -
- - function setup() { - let myDictionary = createStringDict('p5', 'js'); - print(myDictionary.hasKey('p5')); // logs true to console - let anotherDictionary = createStringDict({ happy: 'coding' }); - print(anotherDictionary.hasKey('happy')); // logs true to console - } -
-class: p5 -return: - description: '' - type: p5.StringDict -overloads: - - line: 14 - params: - - name: key - description: '' - type: String - - name: value - description: '' - type: String - return: - description: '' - type: p5.StringDict - - line: 37 - params: - - name: object - description: | -

object

- type: Object - return: - description: '' - type: p5.StringDict -chainable: false ---- - - -# createStringDict diff --git a/src/content/reference/en/p5 copy/createVector.mdx b/src/content/reference/en/p5 copy/createVector.mdx deleted file mode 100644 index 07ca75ec36..0000000000 --- a/src/content/reference/en/p5 copy/createVector.mdx +++ /dev/null @@ -1,133 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/math.js#L10 -title: createVector -module: Math -submodule: Vector -file: src/math/math.js -description: > -

Creates a new p5.Vector object.

- -

A vector can be thought of in different ways. In one view, a vector is like - - an arrow pointing in space. Vectors have both magnitude (length) and - - direction. This view is helpful for programming motion.

- -

A vector's components determine its magnitude and direction. For example, - - calling createVector(3, 4) creates a new - - p5.Vector object with an x-component of - 3 and a - - y-component of 4. From the origin, this vector's tip is 3 units to the - - right and 4 units down.

- -

p5.Vector objects are often used to - program - - motion because they simplify the math. For example, a moving ball has a - - position and a velocity. Position describes where the ball is in space. The - - ball's position vector extends from the origin to the ball's center. - - Velocity describes the ball's speed and the direction it's moving. If the - - ball is moving straight up, its velocity vector points straight up. Adding - - the ball's velocity vector to its position vector moves it, as in - - pos.add(vel). Vector math relies on methods inside the - - p5.Vector class.

-line: 10 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create p5.Vector objects. - let p1 = createVector(25, 25); - let p2 = createVector(50, 50); - let p3 = createVector(75, 75); - - // Draw the dots. - strokeWeight(5); - point(p1); - point(p2); - point(p3); - - describe('Three black dots form a diagonal line from top left to bottom right.'); - } - -
- -
- - let pos; - let vel; - - function setup() { - createCanvas(100, 100); - - // Create p5.Vector objects. - pos = createVector(50, 100); - vel = createVector(0, -1); - - describe('A black dot moves from bottom to top on a gray square. The dot reappears at the bottom when it reaches the top.'); - } - - function draw() { - background(200); - - // Add velocity to position. - pos.add(vel); - - // If the dot reaches the top of the canvas, - // restart from the bottom. - if (pos.y < 0) { - pos.y = 100; - } - - // Draw the dot. - strokeWeight(5); - point(pos); - } - -
-class: p5 -params: - - name: x - description: | -

x component of the vector.

- type: Number - optional: true - - name: 'y' - description: | -

y component of the vector.

- type: Number - optional: true - - name: z - description: | -

z component of the vector.

- type: Number - optional: true -return: - description: new p5.Vector object. - type: p5.Vector -chainable: false ---- - - -# createVector diff --git a/src/content/reference/en/p5 copy/createVideo.mdx b/src/content/reference/en/p5 copy/createVideo.mdx deleted file mode 100644 index a7053f80a0..0000000000 --- a/src/content/reference/en/p5 copy/createVideo.mdx +++ /dev/null @@ -1,135 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L2115 -title: createVideo -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a element for simple audio/video playback.

- -

createVideo() returns a new - - p5.MediaElement object. Videos are - shown by - - default. They can be hidden by calling video.hide() and drawn to - the - - canvas using image().

- -

The first parameter, src, is the path the video. If a single - string is - - passed, as in '/assets/topsecret.mp4', a single video is loaded. - An array - - of strings can be used to load the same video in different formats. For - - example, ['/assets/topsecret.mp4', '/assets/topsecret.ogv', - '/assets/topsecret.webm']. - - This is useful for ensuring that the video can play across different browsers - with - - different capabilities. See - - MDN - - for more information about supported formats.

- -

The second parameter, callback, is optional. It's a function - to call once - - the video is ready to play.

-line: 2115 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - noCanvas(); - - // Load a video and add it to the page. - // Note: this may not work in some browsers. - let video = createVideo('/assets/small.mp4'); - - // Show the default video controls. - video.showControls(); - - describe('A video of a toy robot with playback controls beneath it.'); - } - -
- -
- - function setup() { - noCanvas(); - - // Load a video and add it to the page. - // Provide an array options for different file formats. - let video = createVideo( - ['/assets/small.mp4', '/assets/small.ogv', '/assets/small.webm'] - ); - - // Show the default video controls. - video.showControls(); - - describe('A video of a toy robot with playback controls beneath it.'); - } - -
- -
- - let video; - - function setup() { - noCanvas(); - - // Load a video and add it to the page. - // Provide an array options for different file formats. - // Call mute() once the video loads. - video = createVideo( - ['/assets/small.mp4', '/assets/small.ogv', '/assets/small.webm'], - muteVideo - ); - - // Show the default video controls. - video.showControls(); - - describe('A video of a toy robot with playback controls beneath it.'); - } - - // Mute the video once it loads. - function muteVideo() { - video.volume(0); - } - -
-class: p5 -params: - - name: src - description: | -

path to a video file, or an array of paths for - supporting different browsers.

- type: 'String|String[]' - - name: callback - description: | -

function to call once the video is ready to play.

- type: Function - optional: true -return: - description: new p5.MediaElement object. - type: p5.MediaElement -chainable: false ---- - - -# createVideo diff --git a/src/content/reference/en/p5 copy/createWriter.mdx b/src/content/reference/en/p5 copy/createWriter.mdx deleted file mode 100644 index 18928ff461..0000000000 --- a/src/content/reference/en/p5 copy/createWriter.mdx +++ /dev/null @@ -1,146 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1444 -title: createWriter -module: IO -submodule: Output -file: src/io/files.js -description: > -

Creates a new p5.PrintWriter - object.

- -

p5.PrintWriter objects provide a - way to - - save a sequence of text data, called the print stream, to the user's - - computer. They're low-level objects that enable precise control of text - - output. Functions such as - - saveStrings() and - - saveJSON() are easier to use for simple - file - - saving.

- -

The first parameter, filename, is the name of the file to be - written. If - - a string is passed, as in createWriter('words.txt'), a new - - p5.PrintWriter object will be - created that - - writes to a file named words.txt.

- -

The second parameter, extension, is optional. If a string is - passed, as - - in createWriter('words', 'csv'), the first parameter will be - interpreted - - as the file name and the second parameter as the extension.

-line: 1444 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(12); - - // Display instructions. - text('Double-click to save', 5, 50, 90); - - describe('The text "Double-click to save" written in black on a gray background.'); - } - - // Save the file when the user double-clicks. - function doubleClicked() { - if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { - // Create a p5.PrintWriter object. - let myWriter = createWriter('xo.txt'); - - // Add some lines to the print stream. - myWriter.print('XOO'); - myWriter.print('OXO'); - myWriter.print('OOX'); - - // Save the file and close the print stream. - myWriter.close(); - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(12); - - // Display instructions. - text('Double-click to save', 5, 50, 90); - - describe('The text "Double-click to save" written in black on a gray background.'); - } - - // Save the file when the user double-clicks. - function doubleClicked() { - if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { - // Create a p5.PrintWriter object. - // Use the file format .csv. - let myWriter = createWriter('mauna_loa_co2', 'csv'); - - // Add some lines to the print stream. - myWriter.print('date,ppm_co2'); - myWriter.print('1960-01-01,316.43'); - myWriter.print('1970-01-01,325.06'); - myWriter.print('1980-01-01,337.9'); - myWriter.print('1990-01-01,353.86'); - myWriter.print('2000-01-01,369.45'); - myWriter.print('2020-01-01,413.61'); - - // Save the file and close the print stream. - myWriter.close(); - } - } - -
-class: p5 -params: - - name: name - description: | -

name of the file to create.

- type: String - - name: extension - description: | -

format to use for the file.

- type: String - optional: true -return: - description: stream for writing data. - type: p5.PrintWriter -chainable: false ---- - - -# createWriter diff --git a/src/content/reference/en/p5 copy/cursor.mdx b/src/content/reference/en/p5 copy/cursor.mdx deleted file mode 100644 index 8ada3a4379..0000000000 --- a/src/content/reference/en/p5 copy/cursor.mdx +++ /dev/null @@ -1,139 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L209 -title: cursor -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

Changes the cursor's appearance.

- -

The first parameter, type, sets the type of cursor to display. - The - - built-in options are ARROW, CROSS, - HAND, MOVE, TEXT, and - WAIT. - - cursor() also recognizes standard CSS cursor properties passed as - - strings: 'help', 'wait', 'crosshair', - 'not-allowed', 'zoom-in', - - and 'grab'. If the path to an image is passed, as in - - cursor('/assets/target.png'), then the image will be used as the - cursor. - - Images must be in .cur, .gif, .jpg, .jpeg, or .png format and should be at - most 32 by 32 pixels large.

- -

The parameters x and y are optional. If an image - is used for the - - cursor, x and y set the location pointed to within - the image. They are - - both 0 by default, so the cursor points to the image's top-left corner. - x - - and y must be less than the image's width and height, - respectively.

-line: 209 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A gray square. The cursor appears as crosshairs.'); - } - - function draw() { - background(200); - - // Set the cursor to crosshairs: + - cursor(CROSS); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A gray square divided into quadrants. The cursor image changes when the mouse moves to each quadrant.'); - } - - function draw() { - background(200); - - // Divide the canvas into quadrants. - line(50, 0, 50, 100); - line(0, 50, 100, 50); - - // Change cursor based on mouse position. - if (mouseX < 50 && mouseY < 50) { - cursor(CROSS); - } else if (mouseX > 50 && mouseY < 50) { - cursor('progress'); - } else if (mouseX > 50 && mouseY > 50) { - cursor('https://avatars0.githubusercontent.com/u/1617169?s=16'); - } else { - cursor('grab'); - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('An image of three purple curves follows the mouse. The image shifts when the mouse is pressed.'); - } - - function draw() { - background(200); - - // Change the cursor's active spot - // when the mouse is pressed. - if (mouseIsPressed === true) { - cursor('https://avatars0.githubusercontent.com/u/1617169?s=16', 8, 8); - } else { - cursor('https://avatars0.githubusercontent.com/u/1617169?s=16'); - } - } - -
-class: p5 -params: - - name: type - description: | -

Built-in: either ARROW, CROSS, HAND, MOVE, TEXT, or WAIT. - Native CSS properties: 'grab', 'progress', and so on. - Path to cursor image.

- type: String|Constant - - name: x - description: | -

horizontal active spot of the cursor.

- type: Number - optional: true - - name: 'y' - description: | -

vertical active spot of the cursor.

- type: Number - optional: true -chainable: false ---- - - -# cursor diff --git a/src/content/reference/en/p5 copy/curve.mdx b/src/content/reference/en/p5 copy/curve.mdx deleted file mode 100644 index 9631e551e8..0000000000 --- a/src/content/reference/en/p5 copy/curve.mdx +++ /dev/null @@ -1,272 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L570 -title: curve -module: Shape -submodule: Curves -file: src/core/shape/curves.js -description: > -

Draws a curve using a Catmull-Rom spline.

- -

Spline curves can form shapes and curves that slope gently. They’re like - - cables that are attached to a set of points. Splines are defined by two - - anchor points and two control points.

- -

The first two parameters, x1 and y1, set the - first control point. This - - point isn’t drawn and can be thought of as the curve’s starting point.

- -

The next four parameters, x2, y2, - x3, and y3, set the two anchor - - points. The anchor points are the start and end points of the curve’s - - visible segment.

- -

The seventh and eighth parameters, x4 and y4, set - the last control - - point. This point isn’t drawn and can be thought of as the curve’s ending - - point.

- -

Spline curves can also be drawn in 3D using WebGL mode. The 3D version of - - curve() has twelve arguments because each point has x-, y-, and - - z-coordinates.

-line: 570 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw a black spline curve. - noFill(); - strokeWeight(1); - stroke(0); - curve(5, 26, 73, 24, 73, 61, 15, 65); - - // Draw red spline curves from the anchor points to the control points. - stroke(255, 0, 0); - curve(5, 26, 5, 26, 73, 24, 73, 61); - curve(73, 24, 73, 61, 15, 65, 15, 65); - - // Draw the anchor points in black. - strokeWeight(5); - stroke(0); - point(73, 24); - point(73, 61); - - // Draw the control points in red. - stroke(255, 0, 0); - point(5, 26); - point(15, 65); - - describe( - 'A gray square with a curve drawn in three segments. The curve is a sideways U shape with red segments on top and bottom, and a black segment on the right. The endpoints of all the segments are marked with dots.' - ); - } - -
- -
- - let x1 = 5; - let y1 = 26; - let isChanging = false; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a curve drawn in three segments. The curve is a sideways U shape with red segments on top and bottom, and a black segment on the right. The endpoints of all the segments are marked with dots.' - ); - } - - function draw() { - background(200); - - // Draw a black spline curve. - noFill(); - strokeWeight(1); - stroke(0); - curve(x1, y1, 73, 24, 73, 61, 15, 65); - - // Draw red spline curves from the anchor points to the control points. - stroke(255, 0, 0); - curve(x1, y1, x1, y1, 73, 24, 73, 61); - curve(73, 24, 73, 61, 15, 65, 15, 65); - - // Draw the anchor points in black. - strokeWeight(5); - stroke(0); - point(73, 24); - point(73, 61); - - // Draw the control points in red. - stroke(255, 0, 0); - point(x1, y1); - point(15, 65); - } - - // Start changing the first control point if the user clicks near it. - function mousePressed() { - if (dist(mouseX, mouseY, x1, y1) < 20) { - isChanging = true; - } - } - - // Stop changing the first control point when the user releases the mouse. - function mouseReleased() { - isChanging = false; - } - - // Update the first control point while the user drags the mouse. - function mouseDragged() { - if (isChanging === true) { - x1 = mouseX; - y1 = mouseY; - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background('skyblue'); - - // Draw the red balloon. - fill('red'); - curve(-150, 275, 50, 60, 50, 60, 250, 275); - - // Draw the balloon string. - line(50, 60, 50, 80); - - describe('A red balloon in a blue sky.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A red balloon in a blue sky.'); - } - - function draw() { - background('skyblue'); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Draw the red balloon. - fill('red'); - curve(-200, 225, 0, 0, 10, 0, 0, 10, 0, 200, 225, 0); - - // Draw the balloon string. - line(0, 10, 0, 0, 30, 0); - } - -
-class: p5 -overloads: - - line: 570 - params: - - name: x1 - description: | -

x-coordinate of the first control point.

- type: Number - - name: y1 - description: | -

y-coordinate of the first control point.

- type: Number - - name: x2 - description: | -

x-coordinate of the first anchor point.

- type: Number - - name: y2 - description: | -

y-coordinate of the first anchor point.

- type: Number - - name: x3 - description: | -

x-coordinate of the second anchor point.

- type: Number - - name: y3 - description: | -

y-coordinate of the second anchor point.

- type: Number - - name: x4 - description: | -

x-coordinate of the second control point.

- type: Number - - name: y4 - description: | -

y-coordinate of the second control point.

- type: Number - chainable: 1 - - line: 746 - params: - - name: x1 - description: '' - type: Number - - name: y1 - description: '' - type: Number - - name: z1 - description: | -

z-coordinate of the first control point.

- type: Number - - name: x2 - description: '' - type: Number - - name: y2 - description: '' - type: Number - - name: z2 - description: | -

z-coordinate of the first anchor point.

- type: Number - - name: x3 - description: '' - type: Number - - name: y3 - description: '' - type: Number - - name: z3 - description: | -

z-coordinate of the second anchor point.

- type: Number - - name: x4 - description: '' - type: Number - - name: y4 - description: '' - type: Number - - name: z4 - description: | -

z-coordinate of the second control point.

- type: Number - chainable: 1 -chainable: true ---- - - -# curve diff --git a/src/content/reference/en/p5 copy/curveDetail.mdx b/src/content/reference/en/p5 copy/curveDetail.mdx deleted file mode 100644 index 796ca5a026..0000000000 --- a/src/content/reference/en/p5 copy/curveDetail.mdx +++ /dev/null @@ -1,117 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L772 -title: curveDetail -module: Shape -submodule: Curves -file: src/core/shape/curves.js -description: > -

Sets the number of segments used to draw spline curves in WebGL mode.

- -

In WebGL mode, smooth shapes are drawn using many flat segments. Adding - - more flat segments makes shapes appear smoother.

- -

The parameter, detail, is the number of segments to use while - drawing a - - spline curve. For example, calling curveDetail(5) will use 5 - segments to - - draw curves with the curve() function. By - - default,detail is 20.

- -

Note: curveDetail() has no effect in 2D mode.

-line: 772 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw a black spline curve. - noFill(); - strokeWeight(1); - stroke(0); - curve(5, 26, 73, 24, 73, 61, 15, 65); - - // Draw red spline curves from the anchor points to the control points. - stroke(255, 0, 0); - curve(5, 26, 5, 26, 73, 24, 73, 61); - curve(73, 24, 73, 61, 15, 65, 15, 65); - - // Draw the anchor points in black. - strokeWeight(5); - stroke(0); - point(73, 24); - point(73, 61); - - // Draw the control points in red. - stroke(255, 0, 0); - point(5, 26); - point(15, 65); - - describe( - 'A gray square with a curve drawn in three segments. The curve is a sideways U shape with red segments on top and bottom, and a black segment on the right. The endpoints of all the segments are marked with dots.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - // Set the curveDetail() to 3. - curveDetail(3); - - // Draw a black spline curve. - noFill(); - strokeWeight(1); - stroke(0); - curve(-45, -24, 0, 23, -26, 0, 23, 11, 0, -35, 15, 0); - - // Draw red spline curves from the anchor points to the control points. - stroke(255, 0, 0); - curve(-45, -24, 0, -45, -24, 0, 23, -26, 0, 23, 11, 0); - curve(23, -26, 0, 23, 11, 0, -35, 15, 0, -35, 15, 0); - - // Draw the anchor points in black. - strokeWeight(5); - stroke(0); - point(23, -26); - point(23, 11); - - // Draw the control points in red. - stroke(255, 0, 0); - point(-45, -24); - point(-35, 15); - - describe( - 'A gray square with a jagged curve drawn in three segments. The curve is a sideways U shape with red segments on top and bottom, and a black segment on the right. The endpoints of all the segments are marked with dots.' - ); - } - -
-class: p5 -params: - - name: resolution - description: | -

number of segments to use. Defaults to 20.

- type: Number -chainable: true ---- - - -# curveDetail diff --git a/src/content/reference/en/p5 copy/curvePoint.mdx b/src/content/reference/en/p5 copy/curvePoint.mdx deleted file mode 100644 index 761b468ca6..0000000000 --- a/src/content/reference/en/p5 copy/curvePoint.mdx +++ /dev/null @@ -1,160 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L930 -title: curvePoint -module: Shape -submodule: Curves -file: src/core/shape/curves.js -description: > -

Calculates coordinates along a spline curve using interpolation.

- -

curvePoint() calculates coordinates along a spline curve using - the - - anchor and control points. It expects points in the same order as the - - curve() function. curvePoint() - works one axis - - at a time. Passing the anchor and control points' x-coordinates will - - calculate the x-coordinate of a point on the curve. Passing the anchor and - - control points' y-coordinates will calculate the y-coordinate of a point on - - the curve.

- -

The first parameter, a, is the coordinate of the first control - point.

- -

The second and third parameters, b and c, are the - coordinates of the - - anchor points.

- -

The fourth parameter, d, is the coordinate of the last control - point.

- -

The fifth parameter, t, is the amount to interpolate along the - curve. 0 - - is the first anchor point, 1 is the second anchor point, and 0.5 is halfway - - between them.

-line: 930 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Set the coordinates for the curve's anchor and control points. - let x1 = 5; - let y1 = 26; - let x2 = 73; - let y2 = 24; - let x3 = 73; - let y3 = 61; - let x4 = 15; - let y4 = 65; - - // Draw the curve. - noFill(); - curve(x1, y1, x2, y2, x3, y3, x4, y4); - - // Draw circles along the curve's path. - fill(255); - - // Top. - let x = curvePoint(x1, x2, x3, x4, 0); - let y = curvePoint(y1, y2, y3, y4, 0); - circle(x, y, 5); - - // Center. - x = curvePoint(x1, x2, x3, x4, 0.5); - y = curvePoint(y1, y2, y3, y4, 0.5); - circle(x, y, 5); - - // Bottom. - x = curvePoint(x1, x2, x3, x4, 1); - y = curvePoint(y1, y2, y3, y4, 1); - circle(x, y, 5); - - describe('A black curve on a gray square. The endpoints and center of the curve are marked with white circles.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A black curve on a gray square. A white circle moves back and forth along the curve.'); - } - - function draw() { - background(200); - - // Set the coordinates for the curve's anchor and control points. - let x1 = 5; - let y1 = 26; - let x2 = 73; - let y2 = 24; - let x3 = 73; - let y3 = 61; - let x4 = 15; - let y4 = 65; - - // Draw the curve. - noFill(); - curve(x1, y1, x2, y2, x3, y3, x4, y4); - - // Calculate the circle's coordinates. - let t = 0.5 * sin(frameCount * 0.01) + 0.5; - let x = curvePoint(x1, x2, x3, x4, t); - let y = curvePoint(y1, y2, y3, y4, t); - - // Draw the circle. - fill(255); - circle(x, y, 5); - } - -
-class: p5 -params: - - name: a - description: | -

coordinate of first control point.

- type: Number - - name: b - description: | -

coordinate of first anchor point.

- type: Number - - name: c - description: | -

coordinate of second anchor point.

- type: Number - - name: d - description: | -

coordinate of second control point.

- type: Number - - name: t - description: | -

amount to interpolate between 0 and 1.

- type: Number -return: - description: coordinate of a point on the curve. - type: Number -chainable: false ---- - - -# curvePoint diff --git a/src/content/reference/en/p5 copy/curveTangent.mdx b/src/content/reference/en/p5 copy/curveTangent.mdx deleted file mode 100644 index 005ade9aab..0000000000 --- a/src/content/reference/en/p5 copy/curveTangent.mdx +++ /dev/null @@ -1,153 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L1054 -title: curveTangent -module: Shape -submodule: Curves -file: src/core/shape/curves.js -description: > -

Calculates coordinates along a line that's tangent to a spline curve.

- -

Tangent lines skim the surface of a curve. A tangent line's slope equals - - the curve's slope at the point where it intersects.

- -

curveTangent() calculates coordinates along a tangent line - using the - - spline curve's anchor and control points. It expects points in the same - - order as the curve() function. - curveTangent() - - works one axis at a time. Passing the anchor and control points' - - x-coordinates will calculate the x-coordinate of a point on the tangent - - line. Passing the anchor and control points' y-coordinates will calculate - - the y-coordinate of a point on the tangent line.

- -

The first parameter, a, is the coordinate of the first control - point.

- -

The second and third parameters, b and c, are the - coordinates of the - - anchor points.

- -

The fourth parameter, d, is the coordinate of the last control - point.

- -

The fifth parameter, t, is the amount to interpolate along the - curve. 0 - - is the first anchor point, 1 is the second anchor point, and 0.5 is halfway - - between them.

-line: 1054 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Set the coordinates for the curve's anchor and control points. - let x1 = 5; - let y1 = 26; - let x2 = 73; - let y2 = 24; - let x3 = 73; - let y3 = 61; - let x4 = 15; - let y4 = 65; - - // Draw the curve. - noFill(); - curve(x1, y1, x2, y2, x3, y3, x4, y4); - - // Draw tangents along the curve's path. - fill(255); - - // Top circle. - stroke(0); - let x = curvePoint(x1, x2, x3, x4, 0); - let y = curvePoint(y1, y2, y3, y4, 0); - circle(x, y, 5); - - // Top tangent line. - // Scale the tangent point to draw a shorter line. - stroke(255, 0, 0); - let tx = 0.2 * curveTangent(x1, x2, x3, x4, 0); - let ty = 0.2 * curveTangent(y1, y2, y3, y4, 0); - line(x + tx, y + ty, x - tx, y - ty); - - // Center circle. - stroke(0); - x = curvePoint(x1, x2, x3, x4, 0.5); - y = curvePoint(y1, y2, y3, y4, 0.5); - circle(x, y, 5); - - // Center tangent line. - // Scale the tangent point to draw a shorter line. - stroke(255, 0, 0); - tx = 0.2 * curveTangent(x1, x2, x3, x4, 0.5); - ty = 0.2 * curveTangent(y1, y2, y3, y4, 0.5); - line(x + tx, y + ty, x - tx, y - ty); - - // Bottom circle. - stroke(0); - x = curvePoint(x1, x2, x3, x4, 1); - y = curvePoint(y1, y2, y3, y4, 1); - circle(x, y, 5); - - // Bottom tangent line. - // Scale the tangent point to draw a shorter line. - stroke(255, 0, 0); - tx = 0.2 * curveTangent(x1, x2, x3, x4, 1); - ty = 0.2 * curveTangent(y1, y2, y3, y4, 1); - line(x + tx, y + ty, x - tx, y - ty); - - describe( - 'A black curve on a gray square. A white circle moves back and forth along the curve.' - ); - } - -
-class: p5 -params: - - name: a - description: | -

coordinate of first control point.

- type: Number - - name: b - description: | -

coordinate of first anchor point.

- type: Number - - name: c - description: | -

coordinate of second anchor point.

- type: Number - - name: d - description: | -

coordinate of second control point.

- type: Number - - name: t - description: | -

amount to interpolate between 0 and 1.

- type: Number -return: - description: coordinate of a point on the tangent line. - type: Number -chainable: false ---- - - -# curveTangent diff --git a/src/content/reference/en/p5 copy/curveTightness.mdx b/src/content/reference/en/p5 copy/curveTightness.mdx deleted file mode 100644 index 506066be18..0000000000 --- a/src/content/reference/en/p5 copy/curveTightness.mdx +++ /dev/null @@ -1,77 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L875 -title: curveTightness -module: Shape -submodule: Curves -file: src/core/shape/curves.js -description: > -

Adjusts the way curve() and - - curveVertex() draw.

- -

Spline curves are like cables that are attached to a set of points. - - curveTightness() adjusts how tightly the cable is attached to the - points.

- -

The parameter, tightness, determines how the curve fits to the - vertex - - points. By default, tightness is set to 0. Setting tightness to - 1, - - as in curveTightness(1), connects the curve's points using - straight - - lines. Values in the range from –5 to 5 deform curves while leaving them - - recognizable.

-line: 875 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Move the mouse left and right to see the curve change. - - function setup() { - createCanvas(100, 100); - - describe('A black curve forms a sideways U shape. The curve deforms as the user moves the mouse from left to right'); - } - - function draw() { - background(200); - - // Set the curve's tightness using the mouse. - let t = map(mouseX, 0, 100, -5, 5, true); - curveTightness(t); - - // Draw the curve. - noFill(); - beginShape(); - curveVertex(10, 26); - curveVertex(10, 26); - curveVertex(83, 24); - curveVertex(83, 61); - curveVertex(25, 65); - curveVertex(25, 65); - endShape(); - } - -
-class: p5 -params: - - name: amount - description: | -

amount of tightness.

- type: Number -chainable: true ---- - - -# curveTightness diff --git a/src/content/reference/en/p5 copy/curveVertex.mdx b/src/content/reference/en/p5 copy/curveVertex.mdx deleted file mode 100644 index 3d928fc0ce..0000000000 --- a/src/content/reference/en/p5 copy/curveVertex.mdx +++ /dev/null @@ -1,407 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L832 -title: curveVertex -module: Shape -submodule: Vertex -file: src/core/shape/vertex.js -description: > -

Adds a spline curve segment to a custom shape.

- -

curveVertex() adds a curved segment to custom shapes. The - spline curves - - it creates are defined like those made by the - - curve() function. - curveVertex() must be called - - between the beginShape() and - - endShape() functions.

- -

Spline curves can form shapes and curves that slope gently. They’re like - - cables that are attached to a set of points. Splines are defined by two - - anchor points and two control points. curveVertex() must be - called at - - least four times between - - beginShape() and - - endShape() in order to draw a curve:

- -
beginShape();
-
-
-  // Add the first control point.
-
-  curveVertex(84, 91);
-
-
-  // Add the anchor points to draw between.
-
-  curveVertex(68, 19);
-
-  curveVertex(21, 17);
-
-
-  // Add the second control point.
-
-  curveVertex(32, 91);
-
-
-  endShape();
-
-  
- -

The code snippet above would only draw the curve between the anchor points, - - similar to the curve() function. The - segments - - between the control and anchor points can be drawn by calling - - curveVertex() with the coordinates of the control points:

- -
beginShape();
-
-
-  // Add the first control point and draw a segment to it.
-
-  curveVertex(84, 91);
-
-  curveVertex(84, 91);
-
-
-  // Add the anchor points to draw between.
-
-  curveVertex(68, 19);
-
-  curveVertex(21, 17);
-
-
-  // Add the second control point.
-
-  curveVertex(32, 91);
-
-
-  // Uncomment the next line to draw the segment to the second control point.
-
-  // curveVertex(32, 91);
-
-
-  endShape();
-
-  
- -

The first two parameters, x and y, set the - vertex’s location. For - - example, calling curveVertex(10, 10) adds a point to the curve at - - (10, 10).

- -

Spline curves can also be drawn in 3D using WebGL mode. The 3D version of - - curveVertex() has three arguments because each point has x-, y-, - and - - z-coordinates. By default, the vertex’s z-coordinate is set to 0.

- -

Note: curveVertex() won’t work when an argument is passed to - - beginShape().

-line: 832 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the shape. - noFill(); - strokeWeight(1); - - // Start drawing the shape. - beginShape(); - - // Add the first control point. - curveVertex(32, 91); - - // Add the anchor points. - curveVertex(21, 17); - curveVertex(68, 19); - - // Add the second control point. - curveVertex(84, 91); - - // Stop drawing the shape. - endShape(); - - // Style the anchor and control points. - strokeWeight(5); - - // Draw the anchor points in black. - stroke(0); - point(21, 17); - point(68, 19); - - // Draw the control points in red. - stroke(255, 0, 0); - point(32, 91); - point(84, 91); - - describe( - 'A black curve drawn on a gray background. The curve has black dots at its ends. Two red dots appear near the bottom of the canvas.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the shape. - noFill(); - strokeWeight(1); - - // Start drawing the shape. - beginShape(); - - // Add the first control point and draw a segment to it. - curveVertex(32, 91); - curveVertex(32, 91); - - // Add the anchor points. - curveVertex(21, 17); - curveVertex(68, 19); - - // Add the second control point. - curveVertex(84, 91); - - // Stop drawing the shape. - endShape(); - - // Style the anchor and control points. - strokeWeight(5); - - // Draw the anchor points in black. - stroke(0); - point(21, 17); - point(68, 19); - - // Draw the control points in red. - stroke(255, 0, 0); - point(32, 91); - point(84, 91); - - describe( - 'A black curve drawn on a gray background. The curve passes through one red dot and two black dots. Another red dot appears near the bottom of the canvas.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the shape. - noFill(); - strokeWeight(1); - - // Start drawing the shape. - beginShape(); - - // Add the first control point and draw a segment to it. - curveVertex(32, 91); - curveVertex(32, 91); - - // Add the anchor points. - curveVertex(21, 17); - curveVertex(68, 19); - - // Add the second control point and draw a segment to it. - curveVertex(84, 91); - curveVertex(84, 91); - - // Stop drawing the shape. - endShape(); - - // Style the anchor and control points. - strokeWeight(5); - - // Draw the anchor points in black. - stroke(0); - point(21, 17); - point(68, 19); - - // Draw the control points in red. - stroke(255, 0, 0); - point(32, 91); - point(84, 91); - - describe( - 'A black U curve drawn upside down on a gray background. The curve passes from one red dot through two black dots and ends at another red dot.' - ); - } - -
- -
- - // Click the mouse near the red dot in the bottom-left corner - // and drag to change the curve's shape. - - let x1 = 32; - let y1 = 91; - let isChanging = false; - - function setup() { - createCanvas(100, 100); - - describe( - 'A black U curve drawn upside down on a gray background. The curve passes from one red dot through two black dots and ends at another red dot.' - ); - } - - function draw() { - background(200); - - // Style the shape. - noFill(); - stroke(0); - strokeWeight(1); - - // Start drawing the shape. - beginShape(); - - // Add the first control point and draw a segment to it. - curveVertex(x1, y1); - curveVertex(x1, y1); - - // Add the anchor points. - curveVertex(21, 17); - curveVertex(68, 19); - - // Add the second control point and draw a segment to it. - curveVertex(84, 91); - curveVertex(84, 91); - - // Stop drawing the shape. - endShape(); - - // Style the anchor and control points. - strokeWeight(5); - - // Draw the anchor points in black. - stroke(0); - point(21, 17); - point(68, 19); - - // Draw the control points in red. - stroke(255, 0, 0); - point(x1, y1); - point(84, 91); - } - - // Start changing the first control point if the user clicks near it. - function mousePressed() { - if (dist(mouseX, mouseY, x1, y1) < 20) { - isChanging = true; - } - } - - // Stop changing the first control point when the user releases the mouse. - function mouseReleased() { - isChanging = false; - } - - // Update the first control point while the user drags the mouse. - function mouseDragged() { - if (isChanging === true) { - x1 = mouseX; - y1 = mouseY; - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - beginShape(); - - // Add the first control point and draw a segment to it. - curveVertex(32, 91); - curveVertex(32, 91); - - // Add the anchor points. - curveVertex(21, 17); - curveVertex(68, 19); - - // Add the second control point. - curveVertex(84, 91); - curveVertex(84, 91); - - // Stop drawing the shape. - endShape(); - - describe('A ghost shape drawn in white on a gray background.'); - } - -
-class: p5 -overloads: - - line: 832 - params: - - name: x - description: | -

x-coordinate of the vertex

- type: Number - - name: 'y' - description: | -

y-coordinate of the vertex

- type: Number - chainable: 1 - - line: 1160 - params: - - name: x - description: '' - type: Number - - name: 'y' - description: '' - type: Number - - name: z - description: | -

z-coordinate of the vertex.

- type: Number - optional: true - chainable: 1 -chainable: true ---- - - -# curveVertex diff --git a/src/content/reference/en/p5 copy/cylinder.mdx b/src/content/reference/en/p5 copy/cylinder.mdx deleted file mode 100644 index dd81cd687f..0000000000 --- a/src/content/reference/en/p5 copy/cylinder.mdx +++ /dev/null @@ -1,282 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L1477 -title: cylinder -module: Shape -submodule: 3D Primitives -file: src/webgl/3d_primitives.js -description: > -

Draws a cylinder.

- -

A cylinder is a 3D shape with triangular faces that connect a flat bottom - - to a flat top. Cylinders with few faces look like boxes. Cylinders with - - many faces have smooth surfaces.

- -

The first parameter, radius, is optional. If a - Number is passed, as in - - cylinder(20), it sets the radius of the cylinder’s base. By - default, - - radius is 50.

- -

The second parameter, height, is also optional. If a - Number is passed, - - as in cylinder(20, 30), it sets the cylinder’s height. By - default, - - height is set to the cylinder’s radius.

- -

The third parameter, detailX, is also optional. If a - Number is passed, - - as in cylinder(20, 30, 5), it sets the number of edges used to - form the - - cylinder's top and bottom. Using more edges makes the top and bottom look - - more like circles. By default, detailX is 24.

- -

The fourth parameter, detailY, is also optional. If a - Number is passed, - - as in cylinder(20, 30, 5, 2), it sets the number of triangle - subdivisions - - to use along the y-axis, between cylinder's the top and bottom. All 3D - - shapes are made by connecting triangles to form their surfaces. By default, - - detailY is 1.

- -

The fifth parameter, bottomCap, is also optional. If a - false is passed, - - as in cylinder(20, 30, 5, 2, false) the cylinder’s bottom won’t - be drawn. - - By default, bottomCap is true.

- -

The sixth parameter, topCap, is also optional. If a - false is passed, as - - in cylinder(20, 30, 5, 2, false, false) the cylinder’s top won’t - be - - drawn. By default, topCap is true.

- -

Note: cylinder() can only be used in WebGL mode.

-line: 1477 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cylinder on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cylinder. - cylinder(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cylinder on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cylinder. - // Set its radius and height to 30. - cylinder(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cylinder on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cylinder. - // Set its radius to 30 and height to 50. - cylinder(30, 50); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white box on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cylinder. - // Set its radius to 30 and height to 50. - // Set its detailX to 5. - cylinder(30, 50, 5); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cylinder on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cylinder. - // Set its radius to 30 and height to 50. - // Set its detailX to 24 and detailY to 2. - cylinder(30, 50, 24, 2); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cylinder on a gray background. Its top is missing.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cylinder. - // Set its radius to 30 and height to 50. - // Set its detailX to 24 and detailY to 1. - // Don't draw its bottom. - cylinder(30, 50, 24, 1, false); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cylinder on a gray background. Its top and bottom are missing.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cylinder. - // Set its radius to 30 and height to 50. - // Set its detailX to 24 and detailY to 1. - // Don't draw its bottom or top. - cylinder(30, 50, 24, 1, false, false); - } - -
-class: p5 -params: - - name: radius - description: | -

radius of the cylinder. Defaults to 50.

- type: Number - optional: true - - name: height - description: > -

height of the cylinder. Defaults to the value of - radius.

- type: Number - optional: true - - name: detailX - description: | -

number of edges along the top and bottom. Defaults to 24.

- type: Integer - optional: true - - name: detailY - description: | -

number of triangle subdivisions along the y-axis. Defaults to 1.

- type: Integer - optional: true - - name: bottomCap - description: > -

whether to draw the cylinder's bottom. Defaults to - true.

- type: Boolean - optional: true - - name: topCap - description: | -

whether to draw the cylinder's top. Defaults to true.

- type: Boolean - optional: true -chainable: true ---- - - -# cylinder diff --git a/src/content/reference/en/p5 copy/day.mdx b/src/content/reference/en/p5 copy/day.mdx deleted file mode 100644 index f029fcb983..0000000000 --- a/src/content/reference/en/p5 copy/day.mdx +++ /dev/null @@ -1,47 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L10 -title: day -module: IO -submodule: Time & Date -file: src/utilities/time_date.js -description: | -

Returns the current day as a number from 1–31.

-line: 10 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Get the current day. - let d = day(); - - // Style the text. - textAlign(LEFT, CENTER); - textSize(12); - textFont('Courier New'); - - // Display the day. - text(`Current day: ${d}`, 20, 50, 60); - - describe(`The text 'Current day: ${d}' written in black on a gray background.`); - } - -
-class: p5 -return: - description: current day between 1 and 31. - type: Integer -chainable: false ---- - - -# day diff --git a/src/content/reference/en/p5 copy/debugMode.mdx b/src/content/reference/en/p5 copy/debugMode.mdx deleted file mode 100644 index 19ccdfb63f..0000000000 --- a/src/content/reference/en/p5 copy/debugMode.mdx +++ /dev/null @@ -1,362 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/interaction.js#L471 -title: debugMode -module: 3D -submodule: Interaction -file: src/webgl/interaction.js -description: > -

Adds a grid and an axes icon to clarify orientation in 3D sketches.

- -

debugMode() adds a grid that shows where the “ground” is in a - sketch. By - - default, the grid will run through the origin (0, 0, 0) of the - sketch - - along the XZ plane. debugMode() also adds an axes icon that - points along - - the positive x-, y-, and z-axes. Calling debugMode() displays the - grid - - and axes icon with their default size and position.

- -

There are four ways to call debugMode() with optional - parameters to - - customize the debugging environment.

- -

The first way to call debugMode() has one parameter, - mode. If the - - system constant GRID is passed, as in - debugMode(GRID), then the grid - - will be displayed and the axes icon will be hidden. If the constant - AXES - - is passed, as in debugMode(AXES), then the axes icon will be - displayed - - and the grid will be hidden.

- -

The second way to call debugMode() has six parameters. The - first - - parameter, mode, selects either GRID or - AXES to be displayed. The - - next five parameters, gridSize, gridDivisions, - xOff, yOff, and - - zOff are optional. They’re numbers that set the appearance of the - grid - - (gridSize and gridDivisions) and the placement of - the axes icon - - (xOff, yOff, and zOff). For example, - calling - - debugMode(20, 5, 10, 10, 10) sets the gridSize to 20 - pixels, the number - - of gridDivisions to 5, and offsets the axes icon by 10 pixels - along the - - x-, y-, and z-axes.

- -

The third way to call debugMode() has five parameters. The - first - - parameter, mode, selects either GRID or - AXES to be displayed. The - - next four parameters, axesSize, xOff, - yOff, and zOff are optional. - - They’re numbers that set the appearance of the size of the axes icon - - (axesSize) and its placement (xOff, - yOff, and zOff).

- -

The fourth way to call debugMode() has nine optional - parameters. The - - first five parameters, gridSize, gridDivisions, - gridXOff, gridYOff, - - and gridZOff are numbers that set the appearance of the grid. For - - example, calling debugMode(100, 5, 0, 0, 0) sets the - gridSize to 100, - - the number of gridDivisions to 5, and sets all the offsets to 0 - so that - - the grid is centered at the origin. The next four parameters, - axesSize, - - xOff, yOff, and zOff are numbers that - set the appearance of the size - - of the axes icon (axesSize) and its placement - (axesXOff, axesYOff, - - and axesZOff). For example, calling - - debugMode(100, 5, 0, 0, 0, 50, 10, 10, 10) sets the - gridSize to 100, - - the number of gridDivisions to 5, and sets all the offsets to 0 - so that - - the grid is centered at the origin. It then sets the axesSize to - 50 and - - offsets the icon 10 pixels along each axis.

-line: 471 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - // Enable debug mode. - debugMode(); - - describe('A multicolor box on a gray background. A grid and axes icon are displayed near the box.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the box. - normalMaterial(); - - // Draw the box. - box(20, 40); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - // Enable debug mode. - // Only display the axes icon. - debugMode(AXES); - - describe('A multicolor box on a gray background. A grid and axes icon are displayed near the box.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the box. - normalMaterial(); - - // Draw the box. - box(20, 40); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - // Enable debug mode. - // Only display the grid and customize it: - // - size: 50 - // - divisions: 10 - // - offsets: 0, 20, 0 - debugMode(GRID, 50, 10, 0, 20, 0); - - describe('A multicolor box on a gray background. A grid is displayed below the box.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the box. - normalMaterial(); - - // Draw the box. - box(20, 40); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - // Enable debug mode. - // Display the grid and axes icon and customize them: - // Grid - // ---- - // - size: 50 - // - divisions: 10 - // - offsets: 0, 20, 0 - // Axes - // ---- - // - size: 50 - // - offsets: 0, 0, 0 - debugMode(50, 10, 0, 20, 0, 50, 0, 0, 0); - - describe('A multicolor box on a gray background. A grid is displayed below the box. An axes icon is displayed at the center of the box.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the box. - normalMaterial(); - - // Draw the box. - box(20, 40); - } - -
-class: p5 -overloads: - - line: 471 - params: [] - - line: 650 - params: - - name: mode - description: | -

either GRID or AXES

- type: Constant - - line: 655 - params: - - name: mode - description: '' - type: Constant - - name: gridSize - description: | -

side length of the grid.

- type: Number - optional: true - - name: gridDivisions - description: | -

number of divisions in the grid.

- type: Number - optional: true - - name: xOff - description: | -

offset from origin along the x-axis.

- type: Number - optional: true - - name: yOff - description: | -

offset from origin along the y-axis.

- type: Number - optional: true - - name: zOff - description: | -

offset from origin along the z-axis.

- type: Number - optional: true - - line: 665 - params: - - name: mode - description: '' - type: Constant - - name: axesSize - description: | -

length of axes icon markers.

- type: Number - optional: true - - name: xOff - description: '' - type: Number - optional: true - - name: yOff - description: '' - type: Number - optional: true - - name: zOff - description: '' - type: Number - optional: true - - line: 674 - params: - - name: gridSize - description: '' - type: Number - optional: true - - name: gridDivisions - description: '' - type: Number - optional: true - - name: gridXOff - description: | -

grid offset from the origin along the x-axis.

- type: Number - optional: true - - name: gridYOff - description: | -

grid offset from the origin along the y-axis.

- type: Number - optional: true - - name: gridZOff - description: | -

grid offset from the origin along the z-axis.

- type: Number - optional: true - - name: axesSize - description: '' - type: Number - optional: true - - name: axesXOff - description: | -

axes icon offset from the origin along the x-axis.

- type: Number - optional: true - - name: axesYOff - description: | -

axes icon offset from the origin along the y-axis.

- type: Number - optional: true - - name: axesZOff - description: | -

axes icon offset from the origin along the z-axis.

- type: Number - optional: true -chainable: false ---- - - -# debugMode diff --git a/src/content/reference/en/p5 copy/degrees.mdx b/src/content/reference/en/p5 copy/degrees.mdx deleted file mode 100644 index 730b361384..0000000000 --- a/src/content/reference/en/p5 copy/degrees.mdx +++ /dev/null @@ -1,53 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L485 -title: degrees -module: Math -submodule: Trigonometry -file: src/math/trigonometry.js -description: | -

Converts an angle measured in radians to its value in degrees.

-

Degrees and radians are both units for measuring angles. There are 360˚ in - one full rotation. A full rotation is 2 × π (about 6.28) radians.

-

The same angle can be expressed in with either unit. For example, 90° is a - quarter of a full rotation. The same angle is 2 × π ÷ 4 - (about 1.57) radians.

-line: 485 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Calculate the angle conversion. - let rad = QUARTER_PI; - let deg = degrees(rad); - - // Display the conversion. - text(`${round(rad, 2)} rad = ${deg}˚`, 10, 50); - - describe('The text "0.79 rad = 45˚".'); - } - -
-class: p5 -params: - - name: radians - description: | -

radians value to convert to degrees.

- type: Number -return: - description: converted angle. - type: Number -chainable: false ---- - - -# degrees diff --git a/src/content/reference/en/p5 copy/deltaTime.mdx b/src/content/reference/en/p5 copy/deltaTime.mdx deleted file mode 100644 index 0915a014c2..0000000000 --- a/src/content/reference/en/p5 copy/deltaTime.mdx +++ /dev/null @@ -1,68 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L124 -title: deltaTime -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

A Number variable that tracks the number of milliseconds it - took to draw - - the last frame.

- -

deltaTime contains the amount of time it took - - draw() to execute during the previous frame. - It's - - useful for simulating physics.

-line: 124 -isConstructor: false -itemtype: property -example: - - |- - -
- - let x = 0; - let speed = 0.05; - - function setup() { - createCanvas(100, 100); - - // Set the frameRate to 30. - frameRate(30); - - describe('A white circle moves from left to right on a gray background. It reappears on the left side when it reaches the right side.'); - } - - function draw() { - background(200); - - // Use deltaTime to calculate - // a change in position. - let deltaX = speed * deltaTime; - - // Update the x variable. - x += deltaX; - - // Reset x to 0 if it's - // greater than 100. - if (x > 100) { - x = 0; - } - - // Use x to set the circle's - // position. - circle(x, 50, 20); - } - -
-class: p5 -type: Integer ---- - - -# deltaTime diff --git a/src/content/reference/en/p5 copy/describe.mdx b/src/content/reference/en/p5 copy/describe.mdx deleted file mode 100644 index dee815b9f1..0000000000 --- a/src/content/reference/en/p5 copy/describe.mdx +++ /dev/null @@ -1,137 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/accessibility/describe.js#L18 -title: describe -module: Environment -submodule: Environment -file: src/accessibility/describe.js -description: > -

Creates a screen reader-accessible description of the canvas.

- -

The first parameter, text, is the description of the - canvas.

- -

The second parameter, display, is optional. It determines how - the - - description is displayed. If LABEL is passed, as in - - describe('A description.', LABEL), the description will be - visible in - - a div element next to the canvas. If FALLBACK is passed, as in - - describe('A description.', FALLBACK), the description will only - be - - visible to screen readers. This is the default mode.

- -

Read - - Writing - accessible canvas descriptions - - to learn more about making sketches accessible.

-line: 18 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - background('pink'); - - // Draw a heart. - fill('red'); - noStroke(); - circle(67, 67, 20); - circle(83, 67, 20); - triangle(91, 73, 75, 95, 59, 73); - - // Add a general description of the canvas. - describe('A pink square with a red heart in the bottom-right corner.'); - } - -
- -
- - function setup() { - background('pink'); - - // Draw a heart. - fill('red'); - noStroke(); - circle(67, 67, 20); - circle(83, 67, 20); - triangle(91, 73, 75, 95, 59, 73); - - // Add a general description of the canvas - // and display it for debugging. - describe('A pink square with a red heart in the bottom-right corner.', LABEL); - } - -
- -
- - function draw() { - background(200); - - // The expression - // frameCount % 100 - // causes x to increase from 0 - // to 99, then restart from 0. - let x = frameCount % 100; - - // Draw the circle. - fill(0, 255, 0); - circle(x, 50, 40); - - // Add a general description of the canvas. - describe(`A green circle at (${x}, 50) moves from left to right on a gray square.`); - } - -
- -
- - function draw() { - background(200); - - // The expression - // frameCount % 100 - // causes x to increase from 0 - // to 99, then restart from 0. - let x = frameCount % 100; - - // Draw the circle. - fill(0, 255, 0); - circle(x, 50, 40); - - // Add a general description of the canvas - // and display it for debugging. - describe(`A green circle at (${x}, 50) moves from left to right on a gray square.`, LABEL); - } - -
-class: p5 -params: - - name: text - description: | -

description of the canvas.

- type: String - - name: display - description: | -

either LABEL or FALLBACK.

- type: Constant - optional: true -chainable: false ---- - - -# describe diff --git a/src/content/reference/en/p5 copy/describeElement.mdx b/src/content/reference/en/p5 copy/describeElement.mdx deleted file mode 100644 index 0b7bc8b330..0000000000 --- a/src/content/reference/en/p5 copy/describeElement.mdx +++ /dev/null @@ -1,127 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/accessibility/describe.js#L162 -title: describeElement -module: Environment -submodule: Environment -file: src/accessibility/describe.js -description: > -

Creates a screen reader-accessible description of elements in the - canvas.

- -

Elements are shapes or groups of shapes that create meaning together. For - - example, a few overlapping circles could make an "eye" element.

- -

The first parameter, name, is the name of the element.

- -

The second parameter, text, is the description of the - element.

- -

The third parameter, display, is optional. It determines how - the - - description is displayed. If LABEL is passed, as in - - describe('A description.', LABEL), the description will be - visible in - - a div element next to the canvas. Using LABEL creates unhelpful - - duplicates for screen readers. Only use LABEL during development. - If - - FALLBACK is passed, as in describe('A description.', - FALLBACK), the - - description will only be visible to screen readers. This is the default - - mode.

- -

Read - - Writing - accessible canvas descriptions - - to learn more about making sketches accessible.

-line: 162 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - background('pink'); - - // Describe the first element - // and draw it. - describeElement('Circle', 'A yellow circle in the top-left corner.'); - noStroke(); - fill('yellow'); - circle(25, 25, 40); - - // Describe the second element - // and draw it. - describeElement('Heart', 'A red heart in the bottom-right corner.'); - fill('red'); - circle(66.6, 66.6, 20); - circle(83.2, 66.6, 20); - triangle(91.2, 72.6, 75, 95, 58.6, 72.6); - - // Add a general description of the canvas. - describe('A red heart and yellow circle over a pink background.'); - } - -
- -
- - function setup() { - background('pink'); - - // Describe the first element - // and draw it. Display the - // description for debugging. - describeElement('Circle', 'A yellow circle in the top-left corner.', LABEL); - noStroke(); - fill('yellow'); - circle(25, 25, 40); - - // Describe the second element - // and draw it. Display the - // description for debugging. - describeElement('Heart', 'A red heart in the bottom-right corner.', LABEL); - fill('red'); - circle(66.6, 66.6, 20); - circle(83.2, 66.6, 20); - triangle(91.2, 72.6, 75, 95, 58.6, 72.6); - - // Add a general description of the canvas. - describe('A red heart and yellow circle over a pink background.'); - } - -
-class: p5 -params: - - name: name - description: | -

name of the element.

- type: String - - name: text - description: | -

description of the element.

- type: String - - name: display - description: | -

either LABEL or FALLBACK.

- type: Constant - optional: true -chainable: false ---- - - -# describeElement diff --git a/src/content/reference/en/p5 copy/deviceMoved.mdx b/src/content/reference/en/p5 copy/deviceMoved.mdx deleted file mode 100644 index 90e9ce91fb..0000000000 --- a/src/content/reference/en/p5 copy/deviceMoved.mdx +++ /dev/null @@ -1,49 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L501 -title: deviceMoved -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

The deviceMoved() function is - called when the device is moved by more than - - the threshold value along X, Y or Z axis. The default threshold is set to 0.5. - - The threshold value can be changed using setMoveThreshold().

-line: 501 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Run this example on a mobile device - // Move the device around - // to change the value. - - let value = 0; - 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; - if (value > 255) { - value = 0; - } - } - -
-class: p5 -chainable: false ---- - - -# deviceMoved diff --git a/src/content/reference/en/p5 copy/deviceOrientation.mdx b/src/content/reference/en/p5 copy/deviceOrientation.mdx deleted file mode 100644 index a18763fc87..0000000000 --- a/src/content/reference/en/p5 copy/deviceOrientation.mdx +++ /dev/null @@ -1,22 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L11 -title: deviceOrientation -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: | -

The system variable deviceOrientation always contains the orientation of - the device. The value of this variable will either be set 'landscape' - or 'portrait'. If no data is available it will be set to 'undefined'. - either LANDSCAPE or PORTRAIT.

-line: 11 -isConstructor: false -itemtype: property -class: p5 -type: Constant ---- - - -# deviceOrientation diff --git a/src/content/reference/en/p5 copy/deviceShaken.mdx b/src/content/reference/en/p5 copy/deviceShaken.mdx deleted file mode 100644 index 0c1cce17f8..0000000000 --- a/src/content/reference/en/p5 copy/deviceShaken.mdx +++ /dev/null @@ -1,50 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L589 -title: deviceShaken -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

The deviceShaken() function is - called when the device total acceleration - - changes of accelerationX and accelerationY values is more than - - the threshold value. The default threshold is set to 30. - - The threshold value can be changed using setShakeThreshold().

-line: 589 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Run this example on a mobile device - // Shake the device to change the value. - - let value = 0; - 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; - if (value > 255) { - value = 0; - } - } - -
-class: p5 -chainable: false ---- - - -# deviceShaken diff --git a/src/content/reference/en/p5 copy/deviceTurned.mdx b/src/content/reference/en/p5 copy/deviceTurned.mdx deleted file mode 100644 index 28f760eb6f..0000000000 --- a/src/content/reference/en/p5 copy/deviceTurned.mdx +++ /dev/null @@ -1,80 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L531 -title: deviceTurned -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

The deviceTurned() function is - called when the device rotates by - - more than 90 degrees continuously.

- -

The axis that triggers the deviceTurned() method is stored in the - turnAxis - - variable. The deviceTurned() method - can be locked to trigger on any axis: - - X, Y or Z by comparing the turnAxis variable to 'X', 'Y' or 'Z'.

-line: 531 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Run this example on a mobile device - // Rotate the device by 90 degrees - // to change the value. - - let value = 0; - 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) { - value = 255; - } else if (value === 255) { - value = 0; - } - } - -
-
- - // Run this example on a mobile device - // Rotate the device by 90 degrees in the - // X-axis to change the value. - - let value = 0; - 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') { - if (value === 0) { - value = 255; - } else if (value === 255) { - value = 0; - } - } - } - -
-class: p5 -chainable: false ---- - - -# deviceTurned diff --git a/src/content/reference/en/p5 copy/directionalLight.mdx b/src/content/reference/en/p5 copy/directionalLight.mdx deleted file mode 100644 index b2b3e011a3..0000000000 --- a/src/content/reference/en/p5 copy/directionalLight.mdx +++ /dev/null @@ -1,277 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L461 -title: directionalLight -module: 3D -submodule: Lights -file: src/webgl/light.js -description: > -

Creates a light that shines in one direction.

- -

Directional lights don’t shine from a specific point. They’re like a sun - - that shines from somewhere offscreen. The light’s direction is set using - - three (x, y, z) values between -1 and 1. For example, setting a - light’s - - direction as (1, 0, 0) will light p5.Geometry - - objects from the left since the light faces directly to the right. A - - maximum of 5 directional lights can be active at once.

- -

There are four ways to call directionalLight() with parameters - to set the - - light’s color and direction.

- -

The first way to call directionalLight() has six parameters. - The first - - three parameters, v1, v2, and v3, set - the light’s color using the - - current colorMode(). The last three - - parameters, x, y, and z, set the - light’s direction. For example, - - directionalLight(255, 0, 0, 1, 0, 0) creates a red (255, 0, - 0) light - - that shines to the right (1, 0, 0).

- -

The second way to call directionalLight() has four parameters. - The first - - three parameters, v1, v2, and v3, set - the light’s color using the - - current colorMode(). The last - parameter, - - direction sets the light’s direction using a - p5.Vector object. For example, - directionalLight(255, 0, 0, lightDir) creates a red (255, - 0, 0) light - - that shines in the direction the lightDir vector points.

- -

The third way to call directionalLight() has four parameters. - The first - - parameter, color, sets the light’s color using a - - p5.Color object or an array of color - values. The - - last three parameters, x, y, and z, set - the light’s direction. For - - example, directionalLight(myColor, 1, 0, 0) creates a light that - shines - - to the right (1, 0, 0) with the color value of - myColor.

- -

The fourth way to call directionalLight() has two parameters. - The first - - parameter, color, sets the light’s color using a - - p5.Color object or an array of color - values. The - - second parameter, direction, sets the light’s direction using a - - p5.Color object. For example, - - directionalLight(myColor, lightDir) creates a light that shines - in the - - direction the lightDir vector points with the color value of - myColor.

-line: 461 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click to turn on the directional light. - - let isLit = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A sphere drawn on a gray background. A red light starts shining from above when the user double-clicks.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Control the light. - if (isLit === true) { - // Add a red directional light from above. - // Use RGB values and XYZ directions. - directionalLight(255, 0, 0, 0, 1, 0); - } - - // Style the sphere. - noStroke(); - - // Draw the sphere. - sphere(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Add a red directional light from above. - // Use a p5.Color object and XYZ directions. - let c = color(255, 0, 0); - directionalLight(c, 0, 1, 0); - - // Style the sphere. - noStroke(); - - // Draw the sphere. - sphere(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Add a red directional light from above. - // Use a p5.Color object and a p5.Vector object. - let c = color(255, 0, 0); - let lightDir = createVector(0, 1, 0); - directionalLight(c, lightDir); - - // Style the sphere. - noStroke(); - - // Draw the sphere. - sphere(30); - } - -
-class: p5 -overloads: - - line: 461 - params: - - name: v1 - description: | -

red or hue value in the current - colorMode().

- type: Number - - name: v2 - description: | -

green or saturation value in the current - colorMode().

- type: Number - - name: v3 - description: | -

blue, brightness, or lightness value in the current - colorMode().

- type: Number - - name: x - description: | -

x-component of the light's direction between -1 and 1.

- type: Number - - name: 'y' - description: | -

y-component of the light's direction between -1 and 1.

- type: Number - - name: z - description: | -

z-component of the light's direction between -1 and 1.

- type: Number - chainable: 1 - - line: 614 - params: - - name: v1 - description: '' - type: Number - - name: v2 - description: '' - type: Number - - name: v3 - description: '' - type: Number - - name: direction - description: | -

direction of the light as a - p5.Vector object.

- type: p5.Vector - chainable: 1 - - line: 624 - params: - - name: color - description: | -

color as a p5.Color object, - an array of color values, or as a CSS string.

- type: 'p5.Color|Number[]|String' - - name: x - description: '' - type: Number - - name: 'y' - description: '' - type: Number - - name: z - description: '' - type: Number - chainable: 1 - - line: 634 - params: - - name: color - description: '' - type: 'p5.Color|Number[]|String' - - name: direction - description: '' - type: p5.Vector - chainable: 1 -chainable: true ---- - - -# directionalLight diff --git a/src/content/reference/en/p5 copy/disableFriendlyErrors.mdx b/src/content/reference/en/p5 copy/disableFriendlyErrors.mdx deleted file mode 100644 index a72ec28678..0000000000 --- a/src/content/reference/en/p5 copy/disableFriendlyErrors.mdx +++ /dev/null @@ -1,55 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L872 -title: disableFriendlyErrors -module: Structure -submodule: Structure -file: src/core/main.js -description: > -

Turns off the parts of the Friendly Error System (FES) that impact - performance.

- -

The FES - - can cause sketches to draw slowly because it does extra work behind the - - scenes. For example, the FES checks the arguments passed to functions, - - which takes time to process. Disabling the FES can significantly improve - - performance by turning off these checks.

-line: 872 -isConstructor: false -itemtype: property -example: - - |- - -
- - // Disable the FES. - p5.disableFriendlyErrors = true; - - function setup() { - createCanvas(100, 100); - - background(200); - - // The circle() function requires three arguments. The - // next line would normally display a friendly error that - // points this out. Instead, nothing happens and it fails - // silently. - circle(50, 50); - - describe('A gray square.'); - } - -
-class: p5 -type: Boolean ---- - - -# disableFriendlyErrors diff --git a/src/content/reference/en/p5 copy/displayDensity.mdx b/src/content/reference/en/p5 copy/displayDensity.mdx deleted file mode 100644 index e52be83ec2..0000000000 --- a/src/content/reference/en/p5 copy/displayDensity.mdx +++ /dev/null @@ -1,55 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L1078 -title: displayDensity -module: Environment -submodule: Environment -file: src/core/environment.js -description: | -

Returns the display's current pixel density.

-line: 1078 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - // Set the pixel density to 1. - pixelDensity(1); - - // Create a canvas and draw - // a circle. - createCanvas(100, 100); - background(200); - circle(50, 50, 70); - - describe('A fuzzy white circle drawn on a gray background. The circle becomes sharper when the mouse is pressed.'); - } - - function mousePressed() { - // Get the current display density. - let d = displayDensity(); - - // Use the display density to set - // the sketch's pixel density. - pixelDensity(d); - - // Paint the background and - // draw a circle. - background(200); - circle(50, 50, 70); - } - -
-class: p5 -return: - description: current pixel density of the display. - type: Number -chainable: false ---- - - -# displayDensity diff --git a/src/content/reference/en/p5 copy/displayHeight.mdx b/src/content/reference/en/p5 copy/displayHeight.mdx deleted file mode 100644 index d392419e70..0000000000 --- a/src/content/reference/en/p5 copy/displayHeight.mdx +++ /dev/null @@ -1,47 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L621 -title: displayHeight -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

A Number variable that stores the height of the screen - display.

- -

displayHeight is useful for running full-screen programs. Its - value - - depends on the current pixelDensity().

- -

Note: The actual screen height can be computed as - - displayHeight * pixelDensity().

-line: 621 -isConstructor: false -itemtype: property -alt: This example does not render anything. -example: - - |- - -
- - function setup() { - // Set the canvas' width and height - // using the display's dimensions. - createCanvas(displayWidth, displayHeight); - - background(200); - - describe('A gray canvas that is the same size as the display.'); - } - -
-class: p5 -type: Number ---- - - -# displayHeight diff --git a/src/content/reference/en/p5 copy/displayWidth.mdx b/src/content/reference/en/p5 copy/displayWidth.mdx deleted file mode 100644 index 9ab79a09db..0000000000 --- a/src/content/reference/en/p5 copy/displayWidth.mdx +++ /dev/null @@ -1,47 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L590 -title: displayWidth -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

A Number variable that stores the width of the screen - display.

- -

displayWidth is useful for running full-screen programs. Its - value - - depends on the current pixelDensity().

- -

Note: The actual screen width can be computed as - - displayWidth * pixelDensity().

-line: 590 -isConstructor: false -itemtype: property -alt: This example does not render anything. -example: - - |- - -
- - function setup() { - // Set the canvas' width and height - // using the display's dimensions. - createCanvas(displayWidth, displayHeight); - - background(200); - - describe('A gray canvas that is the same size as the display.'); - } - -
-class: p5 -type: Number ---- - - -# displayWidth diff --git a/src/content/reference/en/p5 copy/dist.mdx b/src/content/reference/en/p5 copy/dist.mdx deleted file mode 100644 index 60b7155b9b..0000000000 --- a/src/content/reference/en/p5 copy/dist.mdx +++ /dev/null @@ -1,121 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L155 -title: dist -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Calculates the distance between two points.

- -

The version of dist() with four parameters calculates distance - in two - - dimensions.

- -

The version of dist() with six parameters calculates distance - in three - - dimensions.

- -

Use p5.Vector.dist() to calculate - the - - distance between two p5.Vector - objects.

-line: 155 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Set the coordinates. - let x1 = 10; - let y1 = 50; - let x2 = 90; - let y2 = 50; - - // Draw the points and a line connecting them. - line(x1, y1, x2, y2); - strokeWeight(5); - point(x1, y1); - point(x2, y2); - - // Calculate the distance. - let d = dist(x1, y1, x2, y2); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the distance. - text(d, 43, 40); - - describe('Two dots connected by a horizontal line. The number 80 is written above the center of the line.'); - } - -
-class: p5 -return: - description: distance between the two points. - type: Number -overloads: - - line: 155 - params: - - name: x1 - description: | -

x-coordinate of the first point.

- type: Number - - name: y1 - description: | -

y-coordinate of the first point.

- type: Number - - name: x2 - description: | -

x-coordinate of the second point.

- type: Number - - name: y2 - description: | -

y-coordinate of the second point.

- type: Number - return: - description: distance between the two points. - type: Number - - line: 209 - params: - - name: x1 - description: '' - type: Number - - name: y1 - description: '' - type: Number - - name: z1 - description: | -

z-coordinate of the first point.

- type: Number - - name: x2 - description: '' - type: Number - - name: y2 - description: '' - type: Number - - name: z2 - description: | -

z-coordinate of the second point.

- type: Number - return: - description: distance between the two points. - type: Number -chainable: false ---- - - -# dist diff --git a/src/content/reference/en/p5 copy/doubleClicked.mdx b/src/content/reference/en/p5 copy/doubleClicked.mdx deleted file mode 100644 index 3e148c677f..0000000000 --- a/src/content/reference/en/p5 copy/doubleClicked.mdx +++ /dev/null @@ -1,157 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1599 -title: doubleClicked -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A function that's called once when a mouse button is clicked twice - quickly.

- -

Declaring the function doubleClicked() sets a code block to - run - - automatically when the user presses and releases the mouse button twice - - quickly:

- -
function doubleClicked() {
-    // Code to run.
-  }
-
-  
- -

The mouse system variables, such as mouseX and - - mouseY, will be updated with their most - recent - - value when doubleClicked() is called by p5.js:

- -
function doubleClicked() {
-    if (mouseX < 50) {
-      // Code to run if the mouse is on the left.
-    }
-
-    if (mouseY > 50) {
-      // Code to run if the mouse is near the bottom.
-    }
-  }
-
-  
- -

The parameter, event, is optional. - doubleClicked() is always passed a - - MouseEvent - - object with properties that describe the double-click event:

- -
function doubleClicked(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

On touchscreen devices, code placed in doubleClicked() will - run after two - - touches that occur within a short time.

- -

Browsers may have default behaviors attached to various mouse events. For - - example, some browsers highlight text when the user moves the mouse while - - pressing a mouse button. To prevent any default behavior for this event, - - add return false; to the end of the function.

-line: 1599 -isConstructor: false -itemtype: method -example: - - |- - -
- - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square changes color when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Toggle the square's color when the user double-clicks. - function doubleClicked() { - if (value === 0) { - value = 255; - } else { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
- -
- - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black circle at its center. When the user double-clicks on the circle, it changes color to white.' - ); - } - - function draw() { - background(200); - - // Style the circle. - fill(value); - - // Draw the circle. - circle(50, 50, 80); - } - - // Reassign value to 255 when the user double-clicks on the circle. - function doubleClicked() { - if (dist(50, 50, mouseX, mouseY) < 40) { - value = 255; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
-class: p5 -params: - - name: event - description: | -

optional MouseEvent argument.

- type: MouseEvent - optional: true -chainable: false ---- - - -# doubleClicked diff --git a/src/content/reference/en/p5 copy/draw.mdx b/src/content/reference/en/p5 copy/draw.mdx deleted file mode 100644 index dba2e2b44a..0000000000 --- a/src/content/reference/en/p5 copy/draw.mdx +++ /dev/null @@ -1,129 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L176 -title: draw -module: Structure -submodule: Structure -file: src/core/main.js -description: > -

A function that's called repeatedly while the sketch runs.

- -

Declaring the function draw() sets a code block to run - repeatedly - - once the sketch starts. It’s used to create animations and respond to - - user inputs:

- -
function draw() {
-    // Code to run repeatedly.
-  }
-
-  
- -

This is often called the "draw loop" because p5.js calls the code in - - draw() in a loop behind the scenes. By default, - draw() tries to run - - 60 times per second. The actual rate depends on many factors. The - - drawing rate, called the "frame rate", can be controlled by calling - - frameRate(). The number of times - draw() - - has run is stored in the system variable - - frameCount().

- -

Code placed within draw() begins looping after - - setup() runs. draw() will run - until the user - - closes the sketch. draw() can be stopped by calling the - - noLoop() function. draw() can - be resumed by - - calling the loop() function.

-line: 176 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Paint the background once. - background(200); - - describe( - 'A white circle on a gray background. The circle follows the mouse as the user moves, leaving a trail.' - ); - } - - function draw() { - // Draw circles repeatedly. - circle(mouseX, mouseY, 40); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A white circle on a gray background. The circle follows the mouse as the user moves.' - ); - } - - function draw() { - // Paint the background repeatedly. - background(200); - - // Draw circles repeatedly. - circle(mouseX, mouseY, 40); - } - -
- -
- - // Double-click the canvas to change the circle's color. - - function setup() { - createCanvas(100, 100); - - describe( - 'A white circle on a gray background. The circle follows the mouse as the user moves. The circle changes color to pink when the user double-clicks.' - ); - } - - function draw() { - // Paint the background repeatedly. - background(200); - - // Draw circles repeatedly. - circle(mouseX, mouseY, 40); - } - - // Change the fill color when the user double-clicks. - function doubleClicked() { - fill('deeppink'); - } - -
-class: p5 -chainable: false ---- - - -# draw diff --git a/src/content/reference/en/p5 copy/drawingContext.mdx b/src/content/reference/en/p5 copy/drawingContext.mdx deleted file mode 100644 index 3cf1335733..0000000000 --- a/src/content/reference/en/p5 copy/drawingContext.mdx +++ /dev/null @@ -1,78 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L1198 -title: drawingContext -module: Rendering -submodule: Rendering -file: src/core/rendering.js -description: > -

A system variable that provides direct access to the sketch's - - element.

- -

The element provides many specialized features that - aren't - - included in the p5.js library. The drawingContext system variable - - provides access to these features by exposing the sketch's - - CanvasRenderingContext2D - - object.

-line: 1198 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Style the circle using shadows. - drawingContext.shadowOffsetX = 5; - drawingContext.shadowOffsetY = -5; - drawingContext.shadowBlur = 10; - drawingContext.shadowColor = 'black'; - - // Draw the circle. - circle(50, 50, 40); - - describe("A white circle on a gray background. The circle's edges are shadowy."); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background('skyblue'); - - // Style the circle using a color gradient. - let myGradient = drawingContext.createRadialGradient(50, 50, 3, 50, 50, 40); - myGradient.addColorStop(0, 'yellow'); - myGradient.addColorStop(0.6, 'orangered'); - myGradient.addColorStop(1, 'yellow'); - drawingContext.fillStyle = myGradient; - drawingContext.strokeStyle = 'rgba(0, 0, 0, 0)'; - - // Draw the circle. - circle(50, 50, 40); - - describe('A fiery sun drawn on a light blue background.'); - } - -
-class: p5 ---- - - -# drawingContext diff --git a/src/content/reference/en/p5 copy/ellipse.mdx b/src/content/reference/en/p5 copy/ellipse.mdx deleted file mode 100644 index 6c07765230..0000000000 --- a/src/content/reference/en/p5 copy/ellipse.mdx +++ /dev/null @@ -1,164 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L371 -title: ellipse -module: Shape -submodule: 2D Primitives -file: src/core/shape/2d_primitives.js -description: > -

Draws an ellipse (oval).

- -

An ellipse is a round shape defined by the x, y, - w, and - - h parameters. x and y set the location - of its center. w and - - h set its width and height. See - - ellipseMode() for other ways to set - - its position.

- -

If no height is set, the value of width is used for both the width and - - height. If a negative height or width is specified, the absolute value is - - taken.

- -

The fifth parameter, detail, is also optional. It determines - how many - - vertices are used to draw the ellipse in WebGL mode. The default value is - - 25.

-line: 371 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - ellipse(50, 50, 80, 80); - - describe('A white circle on a gray canvas.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - ellipse(50, 50, 80); - - describe('A white circle on a gray canvas.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - ellipse(50, 50, 80, 40); - - describe('A white ellipse on a gray canvas.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - ellipse(0, 0, 80, 40); - - describe('A white ellipse on a gray canvas.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - // Use 6 vertices. - ellipse(0, 0, 80, 40, 6); - - describe('A white hexagon on a gray canvas.'); - } - -
-class: p5 -overloads: - - line: 371 - params: - - name: x - description: | -

x-coordinate of the center of the ellipse.

- type: Number - - name: 'y' - description: | -

y-coordinate of the center of the ellipse.

- type: Number - - name: w - description: | -

width of the ellipse.

- type: Number - - name: h - description: | -

height of the ellipse.

- type: Number - optional: true - chainable: 1 - - line: 472 - params: - - name: x - description: '' - type: Number - - name: 'y' - description: '' - type: Number - - name: w - description: '' - type: Number - - name: h - description: '' - type: Number - - name: detail - description: | -

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.

- type: Integer - optional: true -chainable: true ---- - - -# ellipse diff --git a/src/content/reference/en/p5 copy/ellipseMode.mdx b/src/content/reference/en/p5 copy/ellipseMode.mdx deleted file mode 100644 index 0826de63f4..0000000000 --- a/src/content/reference/en/p5 copy/ellipseMode.mdx +++ /dev/null @@ -1,113 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L12 -title: ellipseMode -module: Shape -submodule: Attributes -file: src/core/shape/attributes.js -description: > -

Changes where ellipses, circles, and arcs are drawn.

- -

By default, the first two parameters of - - ellipse(), circle(), - - and arc() - - are the x- and y-coordinates of the shape's center. The next parameters set - - the shape's width and height. This is the same as calling - - ellipseMode(CENTER).

- -

ellipseMode(RADIUS) also uses the first two parameters to set - the x- and - - y-coordinates of the shape's center. The next parameters are half of the - - shapes's width and height. Calling ellipse(0, 0, 10, 15) draws a - shape - - with a width of 20 and height of 30.

- -

ellipseMode(CORNER) uses the first two parameters as the - upper-left - - corner of the shape. The next parameters are its width and height.

- -

ellipseMode(CORNERS) uses the first two parameters as the - location of one - - corner of the ellipse's bounding box. The next parameters are the location - - of the opposite corner.

- -

The argument passed to ellipseMode() must be written in ALL - CAPS because - - the constants CENTER, RADIUS, CORNER, - and CORNERS are defined this - - way. JavaScript is a case-sensitive language.

-line: 12 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // White ellipse. - ellipseMode(RADIUS); - fill(255); - ellipse(50, 50, 30, 30); - - // Gray ellipse. - ellipseMode(CENTER); - fill(100); - ellipse(50, 50, 30, 30); - - describe('A white circle with a gray circle at its center. Both circles have black outlines.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // White ellipse. - ellipseMode(CORNER); - fill(255); - ellipse(25, 25, 50, 50); - - // Gray ellipse. - ellipseMode(CORNERS); - fill(100); - ellipse(25, 25, 50, 50); - - describe('A white circle with a gray circle at its top-left corner. Both circles have black outlines.'); - } - -
-class: p5 -params: - - name: mode - description: | -

either CENTER, RADIUS, CORNER, or CORNERS

- type: Constant -chainable: true ---- - - -# ellipseMode diff --git a/src/content/reference/en/p5 copy/ellipsoid.mdx b/src/content/reference/en/p5 copy/ellipsoid.mdx deleted file mode 100644 index 56d86709b7..0000000000 --- a/src/content/reference/en/p5 copy/ellipsoid.mdx +++ /dev/null @@ -1,233 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L1965 -title: ellipsoid -module: Shape -submodule: 3D Primitives -file: src/webgl/3d_primitives.js -description: > -

Draws an ellipsoid.

- -

An ellipsoid is a 3D shape with triangular faces that connect to form a - - round surface. Ellipsoids with few faces look like crystals. Ellipsoids - - with many faces have smooth surfaces and look like eggs. - ellipsoid() - - defines a shape by its radii. This is different from - - ellipse() which uses diameters - - (width and height).

- -

The first parameter, radiusX, is optional. If a - Number is passed, as in - - ellipsoid(20), it sets the radius of the ellipsoid along the - x-axis. By - - default, radiusX is 50.

- -

The second parameter, radiusY, is also optional. If a - Number is passed, - - as in ellipsoid(20, 30), it sets the ellipsoid’s radius along the - y-axis. - - By default, radiusY is set to the ellipsoid’s - radiusX.

- -

The third parameter, radiusZ, is also optional. If a - Number is passed, - - as in ellipsoid(20, 30, 40), it sets the ellipsoid’s radius along - the - - z-axis. By default, radiusZ is set to the ellipsoid’s - radiusY.

- -

The fourth parameter, detailX, is also optional. If a - Number is passed, - - as in ellipsoid(20, 30, 40, 5), it sets the number of triangle - - subdivisions to use along the x-axis. All 3D shapes are made by connecting - - triangles to form their surfaces. By default, detailX is 24.

- -

The fifth parameter, detailY, is also optional. If a - Number is passed, - - as in ellipsoid(20, 30, 40, 5, 7), it sets the number of triangle - - subdivisions to use along the y-axis. All 3D shapes are made by connecting - - triangles to form their surfaces. By default, detailY is 16.

- -

Note: ellipsoid() can only be used in WebGL mode.

-line: 1965 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white sphere on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the ellipsoid. - // Set its radiusX to 30. - ellipsoid(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white ellipsoid on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the ellipsoid. - // Set its radiusX to 30. - // Set its radiusY to 40. - ellipsoid(30, 40); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white ellipsoid on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the ellipsoid. - // Set its radiusX to 30. - // Set its radiusY to 40. - // Set its radiusZ to 50. - ellipsoid(30, 40, 50); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white ellipsoid on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the ellipsoid. - // Set its radiusX to 30. - // Set its radiusY to 40. - // Set its radiusZ to 50. - // Set its detailX to 4. - ellipsoid(30, 40, 50, 4); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white ellipsoid on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the ellipsoid. - // Set its radiusX to 30. - // Set its radiusY to 40. - // Set its radiusZ to 50. - // Set its detailX to 4. - // Set its detailY to 3. - ellipsoid(30, 40, 50, 4, 3); - } - -
-class: p5 -params: - - name: radiusX - description: | -

radius of the ellipsoid along the x-axis. Defaults to 50.

- type: Number - optional: true - - name: radiusY - description: > -

radius of the ellipsoid along the y-axis. Defaults to - radiusX.

- type: Number - optional: true - - name: radiusZ - description: > -

radius of the ellipsoid along the z-axis. Defaults to - radiusY.

- type: Number - optional: true - - name: detailX - description: | -

number of triangle subdivisions along the x-axis. Defaults to 24.

- type: Integer - optional: true - - name: detailY - description: | -

number of triangle subdivisions along the y-axis. Defaults to 16.

- type: Integer - optional: true -chainable: true ---- - - -# ellipsoid diff --git a/src/content/reference/en/p5 copy/emissiveMaterial.mdx b/src/content/reference/en/p5 copy/emissiveMaterial.mdx deleted file mode 100644 index 10037c3c86..0000000000 --- a/src/content/reference/en/p5 copy/emissiveMaterial.mdx +++ /dev/null @@ -1,140 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2647 -title: emissiveMaterial -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Sets the emissive color of shapes’ surface material.

- -

The emissiveMaterial() color sets a color shapes display at - full - - strength, regardless of lighting. This can give the appearance that a shape - - is glowing. However, emissive materials don’t actually emit light that - - can affect surrounding objects.

- -

emissiveMaterial() can be called three ways with different - parameters to - - set the material’s color.

- -

The first way to call emissiveMaterial() has one parameter, - gray. - - Grayscale values between 0 and 255, as in emissiveMaterial(50), - can be - - passed to set the material’s color. Higher grayscale values make shapes - - appear brighter.

- -

The second way to call emissiveMaterial() has one parameter, - color. A - - p5.Color object, an array of color - values, or a - - CSS color string, as in emissiveMaterial('magenta'), can be - passed to set - - the material’s color.

- -

The third way to call emissiveMaterial() has four parameters, - v1, v2, - - v3, and alpha. alpha is optional. RGBA, - HSBA, or HSLA values can be - - passed to set the material’s colors, as in emissiveMaterial(255, 0, - 0) or - - emissiveMaterial(255, 0, 0, 30). Color values will be interpreted - using - - the current colorMode().

- -

Note: emissiveMaterial() can only be used in WebGL mode.

-line: 2647 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A red cube drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on a white ambient light. - ambientLight(255, 255, 255); - - // Add a red emissive material using RGB values. - emissiveMaterial(255, 0, 0); - - // Draw the box. - box(); - } - -
-class: p5 -overloads: - - line: 2647 - params: - - name: v1 - description: | -

red or hue value in the current - colorMode().

- type: Number - - name: v2 - description: | -

green or saturation value in the - current colorMode().

- type: Number - - name: v3 - description: | -

blue, brightness, or lightness value in the - current colorMode().

- type: Number - - name: alpha - description: | -

alpha value in the current - colorMode().

- type: Number - optional: true - chainable: 1 - - line: 2717 - params: - - name: gray - description: | -

grayscale value between 0 (black) and 255 (white).

- type: Number - chainable: 1 - - line: 2723 - params: - - name: color - description: | -

color as a p5.Color object, - an array of color values, or a CSS string.

- type: 'p5.Color|Number[]|String' - chainable: 1 -chainable: true ---- - - -# emissiveMaterial diff --git a/src/content/reference/en/p5 copy/endClip.mdx b/src/content/reference/en/p5 copy/endClip.mdx deleted file mode 100644 index 69bf243858..0000000000 --- a/src/content/reference/en/p5 copy/endClip.mdx +++ /dev/null @@ -1,43 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L190 -title: endClip -module: Color -submodule: Setting -file: src/color/setting.js -description: | -

Ends defining a mask that was started with - beginClip().

-line: 190 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a mask. - beginClip(); - triangle(15, 37, 30, 13, 43, 37); - circle(45, 45, 7); - endClip(); - - // Draw a backing shape. - square(5, 5, 45); - - describe('A white triangle and circle on a gray background.'); - } - -
-class: p5 -chainable: false ---- - - -# endClip diff --git a/src/content/reference/en/p5 copy/endContour.mdx b/src/content/reference/en/p5 copy/endContour.mdx deleted file mode 100644 index 5965b72db8..0000000000 --- a/src/content/reference/en/p5 copy/endContour.mdx +++ /dev/null @@ -1,133 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L1224 -title: endContour -module: Shape -submodule: Vertex -file: src/core/shape/vertex.js -description: > -

Stops creating a hole within a flat shape.

- -

The beginContour() and - endContour() - - functions allow for creating negative space within custom shapes that are - - flat. beginContour() begins adding - vertices - - to a negative space and endContour() stops adding them. - - beginContour() and - endContour() must be - - called between beginShape() and - - endShape().

- -

Transformations such as translate(), - - rotate(), and scale() - - don't work between beginContour() - and - - endContour(). It's also not possible to use other shapes, such as - - ellipse() or rect(), - - between beginContour() and - endContour().

- -

Note: The vertices that define a negative space must "wind" in the opposite - - direction from the outer shape. First, draw vertices for the outer shape - - clockwise order. Then, draw vertices for the negative space in - - counter-clockwise order.

-line: 1224 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - beginShape(); - - // Exterior vertices, clockwise winding. - vertex(10, 10); - vertex(90, 10); - vertex(90, 90); - vertex(10, 90); - - // Interior vertices, counter-clockwise winding. - beginContour(); - vertex(30, 30); - vertex(30, 70); - vertex(70, 70); - vertex(70, 30); - endContour(); - - // Stop drawing the shape. - endShape(CLOSE); - - describe('A white square with a square hole in its center drawn on a gray background.'); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white square with a square hole in its center drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Start drawing the shape. - beginShape(); - - // Exterior vertices, clockwise winding. - vertex(-40, -40); - vertex(40, -40); - vertex(40, 40); - vertex(-40, 40); - - // Interior vertices, counter-clockwise winding. - beginContour(); - vertex(-20, -20); - vertex(-20, 20); - vertex(20, 20); - vertex(20, -20); - endContour(); - - // Stop drawing the shape. - endShape(CLOSE); - } - -
-class: p5 -chainable: true ---- - - -# endContour diff --git a/src/content/reference/en/p5 copy/endGeometry.mdx b/src/content/reference/en/p5 copy/endGeometry.mdx deleted file mode 100644 index bfbeb81c7b..0000000000 --- a/src/content/reference/en/p5 copy/endGeometry.mdx +++ /dev/null @@ -1,285 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L266 -title: endGeometry -module: Shape -submodule: 3D Primitives -file: src/webgl/3d_primitives.js -description: > -

Stops adding shapes to a new - - p5.Geometry object and returns the - object.

- -

The beginGeometry() and endGeometry() - - functions help with creating complex 3D shapes from simpler ones such as - - sphere(). beginGeometry() - begins adding shapes - - to a custom p5.Geometry object and - - endGeometry() stops adding them.

- -

beginGeometry() and endGeometry() can help - - to make sketches more performant. For example, if a complex 3D shape - - doesn’t change while a sketch runs, then it can be created with - - beginGeometry() and endGeometry(). - - Creating a p5.Geometry object once and - then - - drawing it will run faster than repeatedly drawing the individual pieces.

- -

See buildGeometry() for another - way to - - build 3D shapes.

- -

Note: endGeometry() can only be used in WebGL mode.

-line: 266 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Start building the p5.Geometry object. - beginGeometry(); - - // Add a cone. - cone(); - - // Stop building the p5.Geometry object. - shape = endGeometry(); - - describe('A white cone drawn on a gray background.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the p5.Geometry object. - noStroke(); - - // Draw the p5.Geometry object. - model(shape); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the p5.Geometry object. - createArrow(); - - describe('A white arrow drawn on a gray background.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the p5.Geometry object. - noStroke(); - - // Draw the p5.Geometry object. - model(shape); - } - - function createArrow() { - // Start building the p5.Geometry object. - beginGeometry(); - - // Add shapes. - push(); - rotateX(PI); - cone(10); - translate(0, -10, 0); - cylinder(3, 20); - pop(); - - // Stop building the p5.Geometry object. - shape = endGeometry(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let blueArrow; - let redArrow; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the arrows. - redArrow = createArrow('red'); - blueArrow = createArrow('blue'); - - describe('A red arrow and a blue arrow drawn on a gray background. The blue arrow rotates slowly.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the arrows. - noStroke(); - - // Draw the red arrow. - model(redArrow); - - // Translate and rotate the coordinate system. - translate(30, 0, 0); - rotateZ(frameCount * 0.01); - - // Draw the blue arrow. - model(blueArrow); - } - - function createArrow(fillColor) { - // Start building the p5.Geometry object. - beginGeometry(); - - fill(fillColor); - - // Add shapes to the p5.Geometry object. - push(); - rotateX(PI); - cone(10); - translate(0, -10, 0); - cylinder(3, 20); - pop(); - - // Stop building the p5.Geometry object. - let shape = endGeometry(); - - return shape; - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let button; - let particles; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a button to reset the particle system. - button = createButton('Reset'); - - // Call resetModel() when the user presses the button. - button.mousePressed(resetModel); - - // Add the original set of particles. - resetModel(); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the particles. - noStroke(); - - // Draw the particles. - model(particles); - } - - function resetModel() { - // If the p5.Geometry object has already been created, - // free those resources. - if (particles) { - freeGeometry(particles); - } - - // Create a new p5.Geometry object with random spheres. - particles = createParticles(); - } - - function createParticles() { - // Start building the p5.Geometry object. - beginGeometry(); - - // Add shapes. - for (let i = 0; i < 60; i += 1) { - // Calculate random coordinates. - let x = randomGaussian(0, 20); - let y = randomGaussian(0, 20); - let z = randomGaussian(0, 20); - - push(); - // Translate to the particle's coordinates. - translate(x, y, z); - // Draw the particle. - sphere(5); - pop(); - } - - // Stop building the p5.Geometry object. - let shape = endGeometry(); - - return shape; - } - -
-class: p5 -return: - description: new 3D shape. - type: p5.Geometry -chainable: false ---- - - -# endGeometry diff --git a/src/content/reference/en/p5 copy/endShape.mdx b/src/content/reference/en/p5 copy/endShape.mdx deleted file mode 100644 index 198b6d7497..0000000000 --- a/src/content/reference/en/p5 copy/endShape.mdx +++ /dev/null @@ -1,256 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L1344 -title: endShape -module: Shape -submodule: Vertex -file: src/core/shape/vertex.js -description: > -

Stops adding vertices to a custom shape.

- -

The beginShape() and - endShape() functions - - allow for creating custom shapes in 2D or 3D. - - beginShape() begins adding vertices to - a - - custom shape and endShape() stops adding them.

- -

The first parameter, mode, is optional. By default, the first - and last - - vertices of a shape aren't connected. If the constant CLOSE is - passed, as - - in endShape(CLOSE), then the first and last vertices will be - connected.

- -

The second parameter, count, is also optional. In WebGL mode, - it’s more - - efficient to draw many copies of the same shape using a technique called - - instancing. - - The count parameter tells WebGL mode how many copies to draw. For - - example, calling endShape(CLOSE, 400) after drawing a custom - shape will - - make it efficient to draw 400 copies. This feature requires - - writing - a custom shader.

- -

After calling beginShape(), shapes - can be - - built by calling vertex(), - - bezierVertex(), - - quadraticVertex(), and/or - - curveVertex(). Calling - - endShape() will stop adding vertices to the - - shape. Each shape will be outlined with the current stroke color and filled - - with the current fill color.

- -

Transformations such as translate(), - - rotate(), and - - scale() don't work between - - beginShape() and - endShape(). It's also not - - possible to use other shapes, such as ellipse() or - - rect(), between - - beginShape() and - endShape().

-line: 1344 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the shapes. - noFill(); - - // Left triangle. - beginShape(); - vertex(20, 20); - vertex(45, 20); - vertex(45, 80); - endShape(CLOSE); - - // Right triangle. - beginShape(); - vertex(50, 20); - vertex(75, 20); - vertex(75, 80); - endShape(); - - describe( - 'Two sets of black lines drawn on a gray background. The three lines on the left form a right triangle. The two lines on the right form a right angle.' - ); - } - -
- -
- - function setup() { - createCanvas(200, 100); - - background(240); - - noFill(); - stroke(0); - - // Open shape (left) - beginShape(); - vertex(20, 20); - vertex(80, 20); - vertex(80, 80); - endShape(); // Not closed - - // Closed shape (right) - beginShape(); - vertex(120, 20); - vertex(180, 20); - vertex(180, 80); - endShape(CLOSE); // Closed - - describe( - 'Two right-angled shapes on a light gray background. The left shape is open with three lines. The right shape is closed, forming a triangle.' - ); - } - -
- -
- - // Note: A "uniform" is a global variable within a shader program. - - // Create a string with the vertex shader program. - // The vertex shader is called for each vertex. - let vertSrc = `#version 300 es - - precision mediump float; - - in vec3 aPosition; - flat out int instanceID; - - uniform mat4 uModelViewMatrix; - uniform mat4 uProjectionMatrix; - - void main() { - - // Copy the instance ID to the fragment shader. - instanceID = gl_InstanceID; - vec4 positionVec4 = vec4(aPosition, 1.0); - - // gl_InstanceID represents a numeric value for each instance. - // Using gl_InstanceID allows us to move each instance separately. - // Here we move each instance horizontally by ID * 23. - float xOffset = float(gl_InstanceID) * 23.0; - - // Apply the offset to the final position. - gl_Position = uProjectionMatrix * uModelViewMatrix * (positionVec4 - - vec4(xOffset, 0.0, 0.0, 0.0)); - } - `; - - // Create a string with the fragment shader program. - // The fragment shader is called for each pixel. - let fragSrc = `#version 300 es - - precision mediump float; - - out vec4 outColor; - flat in int instanceID; - uniform float numInstances; - - void main() { - vec4 red = vec4(1.0, 0.0, 0.0, 1.0); - vec4 blue = vec4(0.0, 0.0, 1.0, 1.0); - - // Normalize the instance ID. - float normId = float(instanceID) / numInstances; - - // Mix between two colors using the normalized instance ID. - outColor = mix(red, blue, normId); - } - `; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Shader object. - let myShader = createShader(vertSrc, fragSrc); - - background(220); - - // Compile and apply the p5.Shader. - shader(myShader); - - // Set the numInstances uniform. - myShader.setUniform('numInstances', 4); - - // Translate the origin to help align the drawing. - translate(25, -10); - - // Style the shapes. - noStroke(); - - // Draw the shapes. - beginShape(); - vertex(0, 0); - vertex(0, 20); - vertex(20, 20); - vertex(20, 0); - vertex(0, 0); - endShape(CLOSE, 4); - - describe('A row of four squares. Their colors transition from purple on the left to red on the right'); - } - -
-class: p5 -params: - - name: mode - description: | -

use CLOSE to close the shape

- type: Constant - optional: true - - name: count - description: > -

number of times you want to draw/instance the shape (for WebGL - mode).

- type: Integer - optional: true -chainable: true ---- - - -# endShape diff --git a/src/content/reference/en/p5 copy/erase.mdx b/src/content/reference/en/p5 copy/erase.mdx deleted file mode 100644 index 24f1397e8e..0000000000 --- a/src/content/reference/en/p5 copy/erase.mdx +++ /dev/null @@ -1,123 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1629 -title: erase -module: Color -submodule: Setting -file: src/color/setting.js -description: > -

Starts using shapes to erase parts of the canvas.

- -

All drawing that follows erase() will subtract from the - canvas, revealing - - the web page underneath. The erased areas will become transparent, allowing - - the content behind the canvas to show through. The - - fill(), stroke(), and - - blendMode() have no effect once - erase() is - - called.

- -

The erase() function has two optional parameters. The first - parameter - - sets the strength of erasing by the shape's interior. A value of 0 means - - that no erasing will occur. A value of 255 means that the shape's interior - - will fully erase the content underneath. The default value is 255 - - (full strength).

- -

The second parameter sets the strength of erasing by the shape's edge. A - - value of 0 means that no erasing will occur. A value of 255 means that the - - shape's edge will fully erase the content underneath. The default value is - - 255 (full strength).

- -

To cancel the erasing effect, use the noErase() - - function.

- -

erase() has no effect on drawing done with the - - image() and - - background() functions.

-line: 1629 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(100, 100, 250); - - // Draw a pink square. - fill(250, 100, 100); - square(20, 20, 60); - - // Erase a circular area. - erase(); - circle(25, 30, 30); - noErase(); - - describe('A purple canvas with a pink square in the middle. A circle is erased from the top-left, leaving a hole.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(100, 100, 250); - - // Draw a pink square. - fill(250, 100, 100); - square(20, 20, 60); - - // Erase a circular area. - strokeWeight(5); - erase(150, 255); - circle(25, 30, 30); - noErase(); - - describe('A purple canvas with a pink square in the middle. A circle at the top-left partially erases its interior and a fully erases its outline.'); - } - -
-class: p5 -params: - - name: strengthFill - description: | -

a number (0-255) for the strength of erasing under a shape's interior. - Defaults to 255, which is full strength.

- type: Number - optional: true - - name: strengthStroke - description: | -

a number (0-255) for the strength of erasing under a shape's edge. - Defaults to 255, which is full strength.

- type: Number - optional: true -chainable: true ---- - - -# erase diff --git a/src/content/reference/en/p5 copy/exitPointerLock.mdx b/src/content/reference/en/p5 copy/exitPointerLock.mdx deleted file mode 100644 index db8a989422..0000000000 --- a/src/content/reference/en/p5 copy/exitPointerLock.mdx +++ /dev/null @@ -1,82 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1946 -title: exitPointerLock -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

Exits a pointer lock started with - - requestPointerLock.

- -

Calling requestPointerLock() locks the values of - - mouseX, mouseY, - - pmouseX, and pmouseY. - - Calling exitPointerLock() resumes updating the mouse system - variables.

- -

Note: Most browsers require an input, such as a click, before calling - - requestPointerLock(). It’s recommended to call - requestPointerLock() in - - an event function such as doubleClicked().

-line: 1946 -isConstructor: false -itemtype: method -example: - - |- - -
- - let isLocked = false; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a word at its center. The word changes between "Unlocked" and "Locked" when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Tell the user whether the pointer is locked. - if (isLocked === true) { - text('Locked', 50, 50); - } else { - text('Unlocked', 50, 50); - } - } - - // Toggle the pointer lock when the user double-clicks. - function doubleClicked() { - if (isLocked === true) { - exitPointerLock(); - isLocked = false; - } else { - requestPointerLock(); - isLocked = true; - } - } - -
-class: p5 -chainable: false ---- - - -# exitPointerLock diff --git a/src/content/reference/en/p5 copy/exp.mdx b/src/content/reference/en/p5 copy/exp.mdx deleted file mode 100644 index e75a420dab..0000000000 --- a/src/content/reference/en/p5 copy/exp.mdx +++ /dev/null @@ -1,83 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L230 -title: exp -module: Math -submodule: Calculation -file: src/math/calculation.js -description: | -

Calculates the value of Euler's number e (2.71828...) raised to the power - of a number.

-line: 230 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Top-left. - let d = exp(1); - circle(10, 10, d); - - // Left-center. - d = exp(2); - circle(20, 20, d); - - // Right-center. - d = exp(3); - circle(40, 40, d); - - // Bottom-right. - d = exp(4); - circle(80, 80, d); - - describe('A series of circles that grow exponentially from top left to bottom right.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - describe('A series of black dots that grow exponentially from left to right.'); - } - - function draw() { - // Invert the y-axis. - scale(1, -1); - translate(0, -100); - - // Calculate the coordinates. - let x = frameCount; - let y = 0.005 * exp(x * 0.1); - - // Draw a point. - point(x, y); - } - -
-class: p5 -params: - - name: 'n' - description: | -

exponent to raise.

- type: Number -return: - description: e^n - type: Number -chainable: false ---- - - -# exp diff --git a/src/content/reference/en/p5 copy/fill.mdx b/src/content/reference/en/p5 copy/fill.mdx deleted file mode 100644 index 84f074abd4..0000000000 --- a/src/content/reference/en/p5 copy/fill.mdx +++ /dev/null @@ -1,312 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1000 -title: fill -module: Color -submodule: Setting -file: src/color/setting.js -description: > -

Sets the color used to fill shapes.

- -

Calling fill(255, 165, 0) or fill('orange') means - all shapes drawn - - after the fill command will be filled with the color orange.

- -

The version of fill() with one parameter interprets the value - one of - - three ways. If the parameter is a Number, it's interpreted as a - grayscale - - value. If the parameter is a String, it's interpreted as a CSS - color - - string. A p5.Color object can also be - provided to - - set the fill color.

- -

The version of fill() with three parameters interprets them as - RGB, HSB, - - or HSL colors, depending on the current - - colorMode(). The default color space is - RGB, - - with each value in the range from 0 to 255.

- -

The version of fill() with four parameters interprets them as - RGBA, HSBA, - - or HSLA colors, depending on the current colorMode(). The last parameter - - sets the alpha (transparency) value.

-line: 1000 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // A grayscale value. - fill(51); - square(20, 20, 60); - - describe('A dark charcoal gray square with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // R, G & B values. - fill(255, 204, 0); - square(20, 20, 60); - - describe('A yellow square with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // R, G, B, and Alpha values. - fill(255, 0, 0, 128); - square(20, 20, 60); - - describe('A semi-transparent red square with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(100); - - // Use HSB color. - colorMode(HSB); - - // H, S & B values. - fill(255, 204, 100); - square(20, 20, 60); - - describe('A royal blue square with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // A CSS named color. - fill('red'); - square(20, 20, 60); - - describe('A red square with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Three-digit hex RGB notation. - fill('#fae'); - square(20, 20, 60); - - describe('A pink square with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Six-digit hex RGB notation. - fill('#A251FA'); - square(20, 20, 60); - - describe('A purple square with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Integer RGB notation. - fill('rgb(0, 255, 0)'); - square(20, 20, 60); - - describe('A bright green square with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Integer RGBA notation. - fill('rgba(0, 255, 0, 0.25)'); - square(20, 20, 60); - - describe('A soft green rectange with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Percentage RGB notation. - fill('rgb(100%, 0%, 10%)'); - square(20, 20, 60); - - describe('A red square with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Percentage RGBA notation. - fill('rgba(100%, 0%, 100%, 0.5)'); - square(20, 20, 60); - - describe('A dark fuchsia square with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // A p5.Color object. - let c = color(0, 0, 255); - fill(c); - square(20, 20, 60); - - describe('A blue square with a black outline.'); - } - -
-class: p5 -overloads: - - line: 1000 - params: - - name: v1 - description: > -

red value if color mode is RGB or hue value if color mode is - HSB.

- type: Number - - name: v2 - description: > -

green value if color mode is RGB or saturation value if color mode - is HSB.

- type: Number - - name: v3 - description: > -

blue value if color mode is RGB or brightness value if color mode - is HSB.

- type: Number - - name: alpha - description: > -

alpha value, controls transparency (0 - transparent, 255 - - opaque).

- type: Number - optional: true - chainable: 1 - - line: 1225 - params: - - name: value - description: | -

a color string.

- type: String - chainable: 1 - - line: 1231 - params: - - name: gray - description: | -

a grayscale value.

- type: Number - - name: alpha - description: '' - type: Number - optional: true - chainable: 1 - - line: 1238 - params: - - name: values - description: | -

an array containing the red, green, blue & - and alpha components of the color.

- type: 'Number[]' - chainable: 1 - - line: 1245 - params: - - name: color - description: | -

the fill color.

- type: p5.Color - chainable: 1 -chainable: true ---- - - -# fill diff --git a/src/content/reference/en/p5 copy/filter.mdx b/src/content/reference/en/p5 copy/filter.mdx deleted file mode 100644 index 5496568d48..0000000000 --- a/src/content/reference/en/p5 copy/filter.mdx +++ /dev/null @@ -1,330 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L442 -title: filter -module: Image -submodule: Pixels -file: src/image/pixels.js -description: > -

Applies an image filter to the canvas.

- -

The preset options are:

- -

INVERT - - Inverts the colors in the image. No parameter is used.

- -

GRAY - - Converts the image to grayscale. No parameter is used.

- -

THRESHOLD - - Converts the image to black and white. Pixels with a grayscale value - - above a given threshold are converted to white. The rest are converted to - - black. The threshold must be between 0.0 (black) and 1.0 (white). If no - - value is specified, 0.5 is used.

- -

OPAQUE - - Sets the alpha channel to entirely opaque. No parameter is used.

- -

POSTERIZE - - Limits the number of colors in the image. Each color channel is limited to - - the number of colors specified. Values between 2 and 255 are valid, but - - results are most noticeable with lower values. The default value is 4.

- -

BLUR - - Blurs the image. The level of blurring is specified by a blur radius. Larger - - values increase the blur. The default value is 4. A gaussian blur is used - - in P2D mode. A box blur is used in WEBGL mode.

- -

ERODE - - Reduces the light areas. No parameter is used.

- -

DILATE - - Increases the light areas. No parameter is used.

- -

filter() uses WebGL in the background by default because it's - faster. - - This can be disabled in P2D mode by adding a false - argument, as in - - filter(BLUR, false). This may be useful to keep computation off - the GPU - - or to work around a lack of WebGL support.

- -

In WebgL mode, filter() can also use custom shaders. See - - createFilterShader() for more - - information.

-line: 442 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Apply the INVERT filter. - filter(INVERT); - - describe('A blue brick wall.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Apply the GRAY filter. - filter(GRAY); - - describe('A brick wall drawn in grayscale.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Apply the THRESHOLD filter. - filter(THRESHOLD); - - describe('A brick wall drawn in black and white.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Apply the OPAQUE filter. - filter(OPAQUE); - - describe('A red brick wall.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Apply the POSTERIZE filter. - filter(POSTERIZE, 3); - - describe('An image of a red brick wall drawn with limited color palette.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Apply the BLUR filter. - filter(BLUR, 3); - - describe('A blurry image of a red brick wall.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Apply the DILATE filter. - filter(DILATE); - - describe('A red brick wall with bright lines between each brick.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Apply the ERODE filter. - filter(ERODE); - - describe('A red brick wall with faint lines between each brick.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Apply the BLUR filter. - // Don't use WebGL. - filter(BLUR, 3, false); - - describe('A blurry image of a red brick wall.'); - } - -
-class: p5 -overloads: - - line: 442 - params: - - name: filterType - description: | -

either THRESHOLD, GRAY, OPAQUE, INVERT, - POSTERIZE, BLUR, ERODE, DILATE or BLUR.

- type: Constant - - name: filterParam - description: | -

parameter unique to each filter.

- type: Number - optional: true - - name: useWebGL - description: | -

flag to control whether to use fast - WebGL filters (GPU) or original image - filters (CPU); defaults to true.

- type: Boolean - optional: true - - line: 715 - params: - - name: filterType - description: '' - type: Constant - - name: useWebGL - description: '' - type: Boolean - optional: true - - line: 720 - params: - - name: shaderFilter - description: | -

shader that's been loaded, with the - frag shader using a tex0 uniform.

- type: p5.Shader -chainable: false ---- - - -# filter diff --git a/src/content/reference/en/p5 copy/float.mdx b/src/content/reference/en/p5 copy/float.mdx deleted file mode 100644 index fffd6bfc1b..0000000000 --- a/src/content/reference/en/p5 copy/float.mdx +++ /dev/null @@ -1,116 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L10 -title: float -module: Data -submodule: Conversion -file: src/utilities/conversion.js -description: > -

Converts a String to a floating point (decimal) - Number.

- -

float() converts strings that resemble numbers, such as - '12.34', into - - numbers.

- -

The parameter, str, is the string value to convert. For - example, calling - - float('12.34') returns the number 12.34. If an - array of strings is - - passed, as in float(['12.34', '56.78']), then an array of numbers - will be - - returned.

- -

Note: If a string can't be converted to a number, as in - float('giraffe'), - - then the value NaN (not a number) will be returned.

-line: 10 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let original = '12.3'; - - // Convert the string to a number. - let converted = float(original); - - // Double the converted value. - let twice = converted * 2; - - // Style the text. - textAlign(CENTER, CENTER); - textSize(12); - - // Display the original and converted values. - text(`${original} × 2 = ${twice}`, 50, 50); - - describe('The text "12.3 × 2 = 24.6" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of strings. - let original = ['60', '30', '15']; - - // Convert the strings to numbers. - let diameters = float(original); - - for (let d of diameters) { - // Draw a circle. - circle(50, 50, d); - } - - describe('Three white, concentric circles on a gray background.'); - } - -
-class: p5 -return: - description: converted number. - type: Number -overloads: - - line: 10 - params: - - name: str - description: | -

string to convert.

- type: String - return: - description: converted number. - type: Number - - line: 80 - params: - - name: ns - description: | -

array of strings to convert.

- type: 'String[]' - return: - description: converted numbers. - type: 'Number[]' -chainable: false ---- - - -# float diff --git a/src/content/reference/en/p5 copy/floor.mdx b/src/content/reference/en/p5 copy/floor.mdx deleted file mode 100644 index a9e97965a3..0000000000 --- a/src/content/reference/en/p5 copy/floor.mdx +++ /dev/null @@ -1,57 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L294 -title: floor -module: Math -submodule: Calculation -file: src/math/calculation.js -description: | -

Calculates the closest integer value that is less than or equal to the - value of a number.

-line: 294 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Use RGB color with values from 0 to 1. - colorMode(RGB, 1); - - noStroke(); - - // Draw the left rectangle. - let r = 0.8; - fill(r, 0, 0); - rect(0, 0, 50, 100); - - // Round r down to 0. - r = floor(r); - - // Draw the right rectangle. - fill(r, 0, 0); - rect(50, 0, 50, 100); - - describe('Two rectangles. The one on the left is bright red and the one on the right is black.'); - } - -
-class: p5 -params: - - name: 'n' - description: | -

number to round down.

- type: Number -return: - description: rounded down number. - type: Integer -chainable: false ---- - - -# floor diff --git a/src/content/reference/en/p5 copy/focused.mdx b/src/content/reference/en/p5 copy/focused.mdx deleted file mode 100644 index 1e95f25927..0000000000 --- a/src/content/reference/en/p5 copy/focused.mdx +++ /dev/null @@ -1,50 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L174 -title: focused -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

A Boolean variable that's true if the browser is - focused and false if - - not.

- -

Note: The browser window can only receive input if it's focused.

-line: 174 -isConstructor: false -itemtype: property -example: - - |- - -
- - // Open this example in two separate browser - // windows placed side-by-side to demonstrate. - - function setup() { - createCanvas(100, 100); - - describe('A square changes color from green to red when the browser window is out of focus.'); - } - - function draw() { - // Change the background color - // when the browser window - // goes in/out of focus. - if (focused === true) { - background(0, 255, 0); - } else { - background(255, 0, 0); - } - } - -
-class: p5 -type: Boolean ---- - - -# focused diff --git a/src/content/reference/en/p5 copy/for.mdx b/src/content/reference/en/p5 copy/for.mdx deleted file mode 100644 index dc71d1c2ca..0000000000 --- a/src/content/reference/en/p5 copy/for.mdx +++ /dev/null @@ -1,290 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L1648 -title: for -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: > -

A way to repeat a block of code when the number of iterations is known.

- -

for loops are helpful for repeating statements a certain - number of times. - - For example, a for loop makes it easy to express the idea - - "draw five lines" like so:

- -
for (let x = 10; x < 100; x += 20) {
-    line(x, 25, x, 75);
-  }
-
-  
- -

The loop's header begins with the keyword for. Loops generally - count up - - or count down as they repeat, or iterate. The statements in parentheses - - let x = 10; x < 100; x += 20 tell the loop how it should - repeat:

- -
    - -
  • let x = 10 tells the loop to start counting at - 10 and keep track of iterations using the variable - x.
  • - -
  • x < 100 tells the loop to count up to, but not including, - 100.
  • - -
  • x += 20 tells the loop to count up by 20 at the - end of each iteration.
  • - -
- -

The code between the curly braces {} is the loop's body. - Statements in the - - loop body are repeated during each iteration of the loop.

- -

It's common to create infinite loops accidentally. When this happens, - - sketches may become unresponsive and the web browser may display a warning. - - For example, the following loop never stops iterating because it doesn't - - count up:

- -
for (let x = 10; x < 100; x = 20) {
-    line(x, 25, x, 75);
-  }
-
-  
- -

The statement x = 20 keeps the variable x stuck - at 20, which is - - always less than 100.

- -

for loops can also count down:

- -
for (let d = 100; d > 0; d -= 10) {
-    circle(50, 50, d);
-  }
-
-  
- -

for loops can also contain other loops. The following nested - loop draws a - - grid of points:

- -
// Loop from left to right.
-
-  for (let x = 10; x < 100; x += 10) {
-
-    // Loop from top to bottom.
-    for (let y = 10; y < 100; y += 10) {
-      point(x, y);
-    }
-
-  }
-
-  
- -

for loops are also helpful for iterating through the elements - of an - - array. For example, it's common to iterate through an array that contains - - information about where or what to draw:

- -
// Create an array of x-coordinates.
-
-  let xCoordinates = [20, 40, 60];
-
-
-  for (let i = 0; i < xCoordinates.length; i += 1) {
-    // Update the element.
-    xCoordinates[i] += random(-1, 1);
-
-    // Draw a circle.
-    circle(xCoordinates[i], 50, 20);
-  }
-
-  
- -

If the array's values aren't modified, the for...of statement - can - - simplify the code. They're similar to for loops in Python and - for-each - - loops in C++ and Java. The following loops have the same effect:

- -
// Draw circles with a for loop.
-
-  let xCoordinates = [20, 40, 60];
-
-
-  for (let i = 0; i < xCoordinates.length; i += 1) {
-    circle(xCoordinates[i], 50, 20);
-  }
-
-  
- -
// Draw circles with a for...of statement.
-
-  let xCoordinates = [20, 40, 60];
-
-
-  for (let x of xCoordinates) {
-    circle(x, 50, 20);
-  }
-
-  
- -

In the code snippets above, the variables i and x - have different roles.

- -

In the first snippet, i counts from 0 up to - 2, which is one less than - - xCoordinates.length. i is used to access the element - in xCoordinates - - at index i.

- -

In the second code snippet, x isn't keeping track of the - loop's progress - - or an index. During each iteration, x contains the next element - of - - xCoordinates. x starts from the beginning of - xCoordinates (20) and - - updates its value to 40 and then 60 during the next - iterations.

-line: 1648 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('Five black vertical lines on a gray background.'); - } - - function draw() { - background(200); - - // Draw vertical lines using a loop. - for (let x = 10; x < 100; x += 20) { - line(x, 25, x, 75); - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('Five white concentric circles drawn on a gray background.'); - } - - function draw() { - background(200); - - // Draw concentric circles using a loop. - for (let d = 100; d > 0; d -= 20) { - circle(50, 50, d); - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A grid of black dots on a gray background.'); - } - - function draw() { - background(200); - - // Set the spacing for points on the grid. - let space = 10; - - // Increase the stroke weight. - strokeWeight(3); - - // Loop from the left to the right. - for (let x = space; x < 100; x += space) { - // Loop from the top to the bottom. - for (let y = space; y < 100; y += space) { - point(x, y); - } - } - } - -
- -
- - // Declare the variable xCoordinates and assign it an array of numbers. - let xCoordinates = [20, 40, 60, 80]; - - function setup() { - createCanvas(100, 100); - - describe('Four white circles drawn in a horizontal line on a gray background.'); - } - - function draw() { - background(200); - - // Access the element at index i and use it to draw a circle. - for (let i = 0; i < xCoordinates.length; i += 1) { - circle(xCoordinates[i], 50, 20); - } - } - -
- -
- - // Declare the variable xCoordinates and assign it an array of numbers. - let xCoordinates = [20, 40, 60, 80]; - - function setup() { - createCanvas(100, 100); - - describe('Four white circles drawn in a horizontal line on a gray background.'); - } - - function draw() { - background(200); - - // Access each element of the array and use it to draw a circle. - for (let x of xCoordinates) { - circle(x, 50, 20); - } - } - -
-class: p5 ---- - - -# for diff --git a/src/content/reference/en/p5 copy/fract.mdx b/src/content/reference/en/p5 copy/fract.mdx deleted file mode 100644 index 399f144c09..0000000000 --- a/src/content/reference/en/p5 copy/fract.mdx +++ /dev/null @@ -1,55 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L1048 -title: fract -module: Math -submodule: Calculation -file: src/math/calculation.js -description: | -

Calculates the fractional part of a number.

-

A number's fractional part includes its decimal values. For example, - fract(12.34) returns 0.34.

-line: 1048 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Original number. - let n = 56.78; - text(n, 50, 33); - - // Fractional part. - let f = fract(n); - text(f, 50, 67); - - describe('The number 56.78 written above the number 0.78.'); - } - -
-class: p5 -params: - - name: 'n' - description: | -

number whose fractional part will be found.

- type: Number -return: - description: fractional part of n. - type: Number -chainable: false ---- - - -# fract diff --git a/src/content/reference/en/p5 copy/frameCount.mdx b/src/content/reference/en/p5 copy/frameCount.mdx deleted file mode 100644 index f2d02603a0..0000000000 --- a/src/content/reference/en/p5 copy/frameCount.mdx +++ /dev/null @@ -1,73 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L69 -title: frameCount -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

A Number variable that tracks the number of frames drawn since - the sketch - - started.

- -

frameCount's value is 0 inside setup(). It - - increments by 1 each time the code in draw() - - finishes executing.

-line: 69 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Display the value of - // frameCount. - textSize(30); - textAlign(CENTER, CENTER); - text(frameCount, 50, 50); - - describe('The number 0 written in black in the middle of a gray square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Set the frameRate to 30. - frameRate(30); - - textSize(30); - textAlign(CENTER, CENTER); - - describe('A number written in black in the middle of a gray square. Its value increases rapidly.'); - } - - function draw() { - background(200); - - // Display the value of - // frameCount. - text(frameCount, 50, 50); - } - -
-class: p5 -type: Integer ---- - - -# frameCount diff --git a/src/content/reference/en/p5 copy/frameRate.mdx b/src/content/reference/en/p5 copy/frameRate.mdx deleted file mode 100644 index 38ccddd0d6..0000000000 --- a/src/content/reference/en/p5 copy/frameRate.mdx +++ /dev/null @@ -1,107 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L330 -title: frameRate -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

Sets the number of frames to draw per second.

- -

Calling frameRate() with one numeric argument, as in - frameRate(30), - - attempts to draw 30 frames per second (FPS). The target frame rate may not - - be achieved depending on the sketch's processing needs. Most computers - - default to a frame rate of 60 FPS. Frame rates of 24 FPS and above are - - fast enough for smooth animations.

- -

Calling frameRate() without an argument returns the current - frame rate. - - The value returned is an approximation.

-line: 330 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A white circle on a gray background. The circle moves from left to right in a loop. It slows down when the mouse is pressed.'); - } - - function draw() { - background(200); - - // Set the x variable based - // on the current frameCount. - let x = frameCount % 100; - - // If the mouse is pressed, - // decrease the frame rate. - if (mouseIsPressed === true) { - frameRate(10); - } else { - frameRate(60); - } - - // Use x to set the circle's - // position. - circle(x, 50, 20); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A number written in black on a gray background. The number decreases when the mouse is pressed.'); - } - - function draw() { - background(200); - - // If the mouse is pressed, do lots - // of math to slow down drawing. - if (mouseIsPressed === true) { - for (let i = 0; i < 1000000; i += 1) { - random(); - } - } - - // Get the current frame rate - // and display it. - let fps = frameRate(); - text(fps, 50, 50); - } - -
-class: p5 -overloads: - - line: 330 - params: - - name: fps - description: | -

number of frames to draw per second.

- type: Number - chainable: 1 - - line: 404 - params: [] - return: - description: current frame rate. - type: Number -chainable: true ---- - - -# frameRate diff --git a/src/content/reference/en/p5 copy/freeGeometry.mdx b/src/content/reference/en/p5 copy/freeGeometry.mdx deleted file mode 100644 index 7af36d8620..0000000000 --- a/src/content/reference/en/p5 copy/freeGeometry.mdx +++ /dev/null @@ -1,152 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L748 -title: freeGeometry -module: Shape -submodule: 3D Primitives -file: src/webgl/3d_primitives.js -description: > -

Clears a p5.Geometry object from - the graphics - - processing unit (GPU) memory.

- -

p5.Geometry objects can contain - lots of data - - about their vertices, surface normals, colors, and so on. Complex 3D shapes - - can use lots of memory which is a limited resource in many GPUs. Calling - - freeGeometry() can improve performance by freeing a - - p5.Geometry object’s resources from - GPU memory. - - freeGeometry() works with p5.Geometry objects - - created with beginGeometry() and - - endGeometry(), - - buildGeometry(), and - - loadModel().

- -

The parameter, geometry, is the p5.Geometry - - object to be freed.

- -

Note: A p5.Geometry object can - still be drawn - - after its resources are cleared from GPU memory. It may take longer to draw - - the first time it’s redrawn.

- -

Note: freeGeometry() can only be used in WebGL mode.

-line: 748 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - // Create a p5.Geometry object. - beginGeometry(); - cone(); - let shape = endGeometry(); - - // Draw the shape. - model(shape); - - // Free the shape's resources. - freeGeometry(shape); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let button; - let particles; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a button to reset the particle system. - button = createButton('Reset'); - - // Call resetModel() when the user presses the button. - button.mousePressed(resetModel); - - // Add the original set of particles. - resetModel(); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the particles. - noStroke(); - - // Draw the particles. - model(particles); - } - - function resetModel() { - // If the p5.Geometry object has already been created, - // free those resources. - if (particles) { - freeGeometry(particles); - } - - // Create a new p5.Geometry object with random spheres. - particles = buildGeometry(createParticles); - } - - function createParticles() { - for (let i = 0; i < 60; i += 1) { - // Calculate random coordinates. - let x = randomGaussian(0, 20); - let y = randomGaussian(0, 20); - let z = randomGaussian(0, 20); - - push(); - // Translate to the particle's coordinates. - translate(x, y, z); - // Draw the particle. - sphere(5); - pop(); - } - } - -
-class: p5 -params: - - name: geometry - description: | -

3D shape whose resources should be freed.

- type: p5.Geometry -chainable: false ---- - - -# freeGeometry diff --git a/src/content/reference/en/p5 copy/freqToMidi.mdx b/src/content/reference/en/p5 copy/freqToMidi.mdx deleted file mode 100644 index 12c6e1eff9..0000000000 --- a/src/content/reference/en/p5 copy/freqToMidi.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L825 -title: freqToMidi -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: | -

Returns the closest MIDI note value for - a given frequency.

-line: 825 -isConstructor: false -itemtype: method -class: p5 -params: - - name: frequency - description: | -

A freqeuncy, for example, the "A" - above Middle C is 440Hz

- type: Number -return: - description: MIDI note value - type: Number -chainable: false ---- - - -# freqToMidi diff --git a/src/content/reference/en/p5 copy/frustum.mdx b/src/content/reference/en/p5 copy/frustum.mdx deleted file mode 100644 index 01ffd87883..0000000000 --- a/src/content/reference/en/p5 copy/frustum.mdx +++ /dev/null @@ -1,175 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L522 -title: frustum -module: 3D -submodule: Camera -file: src/webgl/p5.Camera.js -description: > -

Sets the frustum of the current camera in a 3D sketch.

- -

In a frustum projection, shapes that are further from the camera appear - - smaller than shapes that are near the camera. This technique, called - - foreshortening, creates realistic 3D scenes.

- -

frustum() changes the default camera’s perspective by changing - its - - viewing frustum. The frustum is the volume of space that’s visible to the - - camera. The frustum’s shape is a pyramid with its top cut off. The camera - - is placed where the top of the pyramid should be and points towards the - - base of the pyramid. It views everything within the frustum.

- -

The first four parameters, left, right, - bottom, and top, set the - - coordinates of the frustum’s sides, bottom, and top. For example, calling - - frustum(-100, 100, 200, -200) creates a frustum that’s 200 pixels - wide - - and 400 pixels tall. By default, these coordinates are set based on the - - sketch’s width and height, as in - - ortho(-width / 20, width / 20, height / 20, -height / 20).

- -

The last two parameters, near and far, set the - distance of the - - frustum’s near and far plane from the camera. For example, calling - - ortho(-100, 100, 200, -200, 50, 1000) creates a frustum that’s - 200 pixels - - wide, 400 pixels tall, starts 50 pixels from the camera, and ends 1,000 - - pixels from the camera. By default, near is set to 0.1 * 800, - which is - - 1/10th the default distance between the camera and the origin. - far is set - - to 10 * 800, which is 10 times the default distance between the - camera - - and the origin.

- -

Note: frustum() can only be used in WebGL mode.

-line: 522 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A row of white cubes on a gray background.'); - } - - function draw() { - background(200); - - // Apply the default frustum projection. - frustum(); - - // Translate the origin toward the camera. - translate(-10, 10, 600); - - // Rotate the coordinate system. - rotateY(-0.1); - rotateX(-0.1); - - // Draw the row of boxes. - for (let i = 0; i < 6; i += 1) { - translate(0, 0, -40); - box(10); - } - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Adjust the frustum. - // Center it. - // Set its width and height to 20 pixels. - // Place its near plane 300 pixels from the camera. - // Place its far plane 350 pixels from the camera. - frustum(-10, 10, -10, 10, 300, 350); - - // Translate the origin toward the camera. - translate(-10, 10, 600); - - // Rotate the coordinate system. - rotateY(-0.1); - rotateX(-0.1); - - // Draw the row of boxes. - for (let i = 0; i < 6; i += 1) { - translate(0, 0, -40); - box(10); - } - } - -
-class: p5 -params: - - name: left - description: > -

x-coordinate of the frustum’s left plane. Defaults to -width / - 20.

- type: Number - optional: true - - name: right - description: > -

x-coordinate of the frustum’s right plane. Defaults to width / - 20.

- type: Number - optional: true - - name: bottom - description: > -

y-coordinate of the frustum’s bottom plane. Defaults to height / - 20.

- type: Number - optional: true - - name: top - description: > -

y-coordinate of the frustum’s top plane. Defaults to -height / - 20.

- type: Number - optional: true - - name: near - description: > -

z-coordinate of the frustum’s near plane. Defaults to 0.1 * - 800.

- type: Number - optional: true - - name: far - description: > -

z-coordinate of the frustum’s far plane. Defaults to 10 * - 800.

- type: Number - optional: true -chainable: true ---- - - -# frustum diff --git a/src/content/reference/en/p5 copy/fullscreen.mdx b/src/content/reference/en/p5 copy/fullscreen.mdx deleted file mode 100644 index 1c6b2eb7fe..0000000000 --- a/src/content/reference/en/p5 copy/fullscreen.mdx +++ /dev/null @@ -1,63 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L950 -title: fullscreen -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

Toggles full-screen mode or returns the current mode.

- -

Calling fullscreen(true) makes the sketch full-screen. Calling - - fullscreen(false) makes the sketch its original size.

- -

Calling fullscreen() without an argument returns - true if the sketch - - is in full-screen mode and false if not.

- -

Note: Due to browser restrictions, fullscreen() can only be - called with - - user input such as a mouse press.

-line: 950 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - background(200); - - describe('A gray canvas that switches between default and full-screen display when clicked.'); - } - - // If the mouse is pressed, - // toggle full-screen mode. - function mousePressed() { - if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) { - let fs = fullscreen(); - fullscreen(!fs); - } - } - -
-class: p5 -params: - - name: val - description: | -

whether the sketch should be in fullscreen mode.

- type: Boolean - optional: true -return: - description: current fullscreen state. - type: Boolean -chainable: false ---- - - -# fullscreen diff --git a/src/content/reference/en/p5 copy/function.mdx b/src/content/reference/en/p5 copy/function.mdx deleted file mode 100644 index e213633c86..0000000000 --- a/src/content/reference/en/p5 copy/function.mdx +++ /dev/null @@ -1,19 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L317 -title: function -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: "

A named group of statements.

\n

Functions\nhelp with organizing and reusing code. For example, functions make it easy\nto express the idea \"Draw a flower.\":

\n
function drawFlower() {\n  // Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(20);\n\n  // Draw a flower emoji.\n  text('\U0001F338', 50, 50);\n}\n
\n

The function header begins with the keyword function. The function's\nname, drawFlower, is followed by parentheses () and curly braces {}.\nThe code between the curly braces is called the function's body. The\nfunction's body runs when the function is called like so:

\n
drawFlower();\n
\n

Functions can accept inputs by adding parameters to their headers.\nParameters are placeholders for values that will be provided when the\nfunction is called. For example, the drawFlower() function could include\na parameter for the flower's size:

\n
function drawFlower(size) {\n  // Style the text.\n  textAlign(CENTER, CENTER);\n\n  // Use the size parameter.\n  textSize(size);\n\n  // Draw a flower emoji.\n  text('\U0001F338', 50, 50);\n}\n
\n

Parameters are part of the function's declaration. Arguments are provided\nby the code that calls a function. When a function is called, arguments are\nassigned to parameters:

\n
// The argument 20 is assigned to the parameter size.\ndrawFlower(20);\n
\n

Functions can have multiple parameters separated by commas. Parameters\ncan have any type. For example, the drawFlower() function could accept\nNumber parameters for the flower's x- and y-coordinates along with its\nsize:

\n
function drawFlower(x, y, size) {\n  // Style the text.\n  textAlign(CENTER, CENTER);\n\n  // Use the size parameter.\n  textSize(size);\n\n  // Draw a flower emoji.\n  // Use the x and y parameters.\n  text('\U0001F338', x, y);\n}\n
\n

Functions can also produce outputs by adding a return statement:

\n
function double(x) {\n  let answer = 2 * x;\n  return answer;\n}\n
\n

The expression following return can produce an output that's used\nelsewhere. For example, the output of the double() function can be\nassigned to a variable:

\n
let six = double(3);\ntext(`3 x 2 = ${six}`, 50, 50);\n
\n" -line: 317 -isConstructor: false -itemtype: property -example: - - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n describe('A pink flower on a gray background.');\n}\n\nfunction draw() {\n background(200);\n\n // Call the drawFlower() function.\n drawFlower();\n}\n\n// Declare a function that draws a flower at the\n// center of the canvas.\nfunction drawFlower() {\n // Style the text.\n textAlign(CENTER, CENTER);\n textSize(20);\n\n // Draw a flower emoji.\n text('\U0001F338', 50, 50);\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n describe('A pink flower on a gray background.');\n}\n\nfunction draw() {\n background(200);\n\n // Call the drawFlower() function and pass values for\n // its position and size.\n drawFlower(50, 50, 20);\n}\n\n// Declare a function that draws a flower at the\n// center of the canvas.\nfunction drawFlower(x, y, size) {\n // Style the text.\n textAlign(CENTER, CENTER);\n\n // Use the size parameter.\n textSize(size);\n\n // Draw a flower emoji.\n // Use the x and y parameters.\n text('\U0001F338', x, y);\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n describe('The message \"Hello, \U0001F30D!\" written on a gray background.');\n}\n\nfunction draw() {\n background(200);\n\n // Create a greeting.\n let greeting = createGreeting('\U0001F30D');\n\n // Style the text.\n textAlign(CENTER, CENTER);\n textSize(16);\n\n // Display the greeting.\n text(greeting, 50, 50);\n}\n\n// Return a string with a personalized greeting.\nfunction createGreeting(name) {\n let message = `Hello, ${name}!`;\n return message;\n}\n\n
" -class: p5 ---- - - -# function diff --git a/src/content/reference/en/p5 copy/get.mdx b/src/content/reference/en/p5 copy/get.mdx deleted file mode 100644 index 42cbb8e7f8..0000000000 --- a/src/content/reference/en/p5 copy/get.mdx +++ /dev/null @@ -1,178 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L820 -title: get -module: Image -submodule: Pixels -file: src/image/pixels.js -description: > -

Gets a pixel or a region of pixels from the canvas.

- -

get() is easy to use but it's not as fast as - - pixels. Use pixels - - to read many pixel values.

- -

The version of get() with no parameters returns the entire - canvas.

- -

The version of get() with two parameters interprets them as - - coordinates. It returns an array with the [R, G, B, A] values of - the - - pixel at the given point.

- -

The version of get() with four parameters interprets them as - coordinates - - and dimensions. It returns a subsection of the canvas as a - - p5.Image object. The first two parameters - are the - - coordinates for the upper-left corner of the subsection. The last two - - parameters are the width and height of the subsection.

- -

Use p5.Image.get() to work directly - with - - p5.Image objects.

-line: 820 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/rockies.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Get the entire canvas. - let c = get(); - - // Display half the canvas. - image(c, 50, 0); - - describe('Two identical mountain landscapes shown side-by-side.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/rockies.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Get the color of a pixel. - let c = get(50, 90); - - // Style the square with the pixel's color. - fill(c); - noStroke(); - - // Display the square. - square(25, 25, 50); - - describe('A mountain landscape with an olive green square in its center.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/rockies.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Get a region of the image. - let c = get(0, 0, 50, 50); - - // Display the region. - image(c, 50, 50); - - describe('A mountain landscape drawn on top of another mountain landscape.'); - } - -
-class: p5 -return: - description: subsection as a p5.Image object. - type: p5.Image -overloads: - - line: 820 - params: - - name: x - description: | -

x-coordinate of the pixel.

- type: Number - - name: 'y' - description: | -

y-coordinate of the pixel.

- type: Number - - name: w - description: | -

width of the subsection to be returned.

- type: Number - - name: h - description: | -

height of the subsection to be returned.

- type: Number - return: - description: subsection as a p5.Image object. - type: p5.Image - - line: 931 - params: [] - return: - description: whole canvas as a p5.Image. - type: p5.Image - - line: 935 - params: - - name: x - description: '' - type: Number - - name: 'y' - description: '' - type: Number - return: - description: 'color of the pixel at (x, y) in array format `[R, G, B, A]`.' - type: 'Number[]' -chainable: false ---- - - -# get diff --git a/src/content/reference/en/p5 copy/getAudioContext.mdx b/src/content/reference/en/p5 copy/getAudioContext.mdx deleted file mode 100644 index c7291c5cdf..0000000000 --- a/src/content/reference/en/p5 copy/getAudioContext.mdx +++ /dev/null @@ -1,56 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L159 -title: getAudioContext -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: >- -

Returns the Audio Context for this sketch. Useful for users - - who would like to dig deeper into the Web Audio API - - .

- - -

Some browsers require users to startAudioContext - - with a user gesture, such as touchStarted in the example below.

-line: 159 -isConstructor: false -itemtype: method -example: - - |- - -
- function draw() { - background(255); - textAlign(CENTER); - - if (getAudioContext().state !== 'running') { - text('click to start audio', width/2, height/2); - } else { - text('audio is enabled', width/2, height/2); - } - } - - function touchStarted() { - if (getAudioContext().state !== 'running') { - getAudioContext().resume(); - } - var synth = new p5.MonoSynth(); - synth.play('A4', 0.5, 0, 0.2); - } - -
-class: p5 -return: - description: AudioContext for this sketch - type: Object -chainable: false ---- - - -# getAudioContext diff --git a/src/content/reference/en/p5 copy/getItem.mdx b/src/content/reference/en/p5 copy/getItem.mdx deleted file mode 100644 index 5747f67366..0000000000 --- a/src/content/reference/en/p5 copy/getItem.mdx +++ /dev/null @@ -1,151 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/data/local_storage.js#L164 -title: getItem -module: Data -submodule: LocalStorage -file: src/data/local_storage.js -description: > -

Returns a value in the web browser's local storage.

- -

Web browsers can save small amounts of data using the built-in - - localStorage object. - - Data stored in localStorage can be retrieved at any point, even - after - - refreshing a page or restarting the browser. Data are stored as key-value - - pairs.

- -

storeItem() makes it easy to store - values in - - localStorage and getItem() makes it easy to retrieve - them.

- -

The first parameter, key, is the name of the value to be - stored as a - - string.

- -

The second parameter, value, is the value to be retrieved a - string. For - - example, calling getItem('size') retrieves the value with the key - size.

- -

Note: Sensitive data such as passwords or personal information shouldn't be - - stored in localStorage.

-line: 164 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Store the player's name. - storeItem('name', 'Feist'); - - // Store the player's score. - storeItem('score', 1234); - - describe('The text "Feist: 1234" written in black on a gray background.'); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(14); - - // Retrieve the name. - let name = getItem('name'); - - // Retrieve the score. - let score = getItem('score'); - - // Display the score. - text(`${name}: ${score}`, 50, 50); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Create an object. - let p = { x: 50, y: 50 }; - - // Store the object. - storeItem('position', p); - - describe('A white circle on a gray background.'); - } - - function draw() { - background(200); - - // Retrieve the object. - let p = getItem('position'); - - // Draw the circle. - circle(p.x, p.y, 30); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Create a p5.Color object. - let c = color('deeppink'); - - // Store the object. - storeItem('color', c); - - describe('A pink circle on a gray background.'); - } - - function draw() { - background(200); - - // Retrieve the object. - let c = getItem('color'); - - // Style the circle. - fill(c); - - // Draw the circle. - circle(50, 50, 30); - } - -
-class: p5 -params: - - name: key - description: | -

name of the value.

- type: String -return: - description: stored item. - type: String|Number|Boolean|Object|Array -chainable: false ---- - - -# getItem diff --git a/src/content/reference/en/p5 copy/getOutputVolume.mdx b/src/content/reference/en/p5 copy/getOutputVolume.mdx deleted file mode 100644 index 6542c5edb6..0000000000 --- a/src/content/reference/en/p5 copy/getOutputVolume.mdx +++ /dev/null @@ -1,25 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L726 -title: getOutputVolume -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: | -

Returns a number representing the output volume for sound - in this sketch.

-line: 726 -isConstructor: false -itemtype: method -class: p5 -return: - description: |- - Output volume for sound in this sketch. - Should be between 0.0 (silence) and 1.0. - type: Number -chainable: false ---- - - -# getOutputVolume diff --git a/src/content/reference/en/p5 copy/getTargetFrameRate.mdx b/src/content/reference/en/p5 copy/getTargetFrameRate.mdx deleted file mode 100644 index 10e3c74a4b..0000000000 --- a/src/content/reference/en/p5 copy/getTargetFrameRate.mdx +++ /dev/null @@ -1,48 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L447 -title: getTargetFrameRate -module: Environment -submodule: Environment -file: src/core/environment.js -description: | -

Returns the target frame rate.

-

The value is either the system frame rate or the last value passed to - frameRate().

-line: 447 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('The number 20 written in black on a gray background.'); - } - - function draw() { - background(200); - - // Set the frame rate to 20. - frameRate(20); - - // Get the target frame rate and - // display it. - let fps = getTargetFrameRate(); - text(fps, 43, 54); - } - -
-class: p5 -return: - description: _targetFrameRate - type: Number -chainable: false ---- - - -# getTargetFrameRate diff --git a/src/content/reference/en/p5 copy/getURL.mdx b/src/content/reference/en/p5 copy/getURL.mdx deleted file mode 100644 index 01ccdc8e11..0000000000 --- a/src/content/reference/en/p5 copy/getURL.mdx +++ /dev/null @@ -1,46 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L1149 -title: getURL -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

Returns the sketch's current - - URL - - as a String.

-line: 1149 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - background(200); - - // Get the sketch's URL - // and display it. - let url = getURL(); - textWrap(CHAR); - text(url, 0, 40, 100); - - describe('The URL "https://p5js.org/reference/p5/getURL" written in black on a gray background.'); - } - -
-class: p5 -return: - description: url - type: String -chainable: false ---- - - -# getURL diff --git a/src/content/reference/en/p5 copy/getURLParams.mdx b/src/content/reference/en/p5 copy/getURLParams.mdx deleted file mode 100644 index c08c77f23f..0000000000 --- a/src/content/reference/en/p5 copy/getURLParams.mdx +++ /dev/null @@ -1,59 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L1208 -title: getURLParams -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

Returns the current - - URL parameters - - in an Object.

- -

For example, calling getURLParams() in a sketch hosted at the - URL - - https://p5js.org?year=2014&month=May&day=15 returns - - { year: 2014, month: 'May', day: 15 }.

-line: 1208 -isConstructor: false -itemtype: method -alt: This example does not render anything. -example: - - |- - -
- - // Imagine this sketch is hosted at the following URL: - // https://p5js.org?year=2014&month=May&day=15 - - function setup() { - background(200); - - // Get the sketch's URL - // parameters and display - // them. - let params = getURLParams(); - text(params.day, 10, 20); - text(params.month, 10, 40); - text(params.year, 10, 60); - - describe('The text "15", "May", and "2014" written in black on separate lines.'); - } - -
-class: p5 -return: - description: URL params - type: Object -chainable: false ---- - - -# getURLParams diff --git a/src/content/reference/en/p5 copy/getURLPath.mdx b/src/content/reference/en/p5 copy/getURLPath.mdx deleted file mode 100644 index e71b7746ad..0000000000 --- a/src/content/reference/en/p5 copy/getURLPath.mdx +++ /dev/null @@ -1,58 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L1175 -title: getURLPath -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

Returns the current - - URL - - path as an Array of Strings.

- -

For example, consider a sketch hosted at the URL - - https://example.com/sketchbook. Calling getURLPath() - returns - - ['sketchbook']. For a sketch hosted at the URL - - https://example.com/sketchbook/monday, getURLPath() - returns - - ['sketchbook', 'monday'].

-line: 1175 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - background(200); - - // Get the sketch's URL path - // and display the first - // part. - let path = getURLPath(); - text(path[0], 25, 54); - - describe('The word "reference" written in black on a gray background.'); - } - -
-class: p5 -return: - description: path components. - type: 'String[]' -chainable: false ---- - - -# getURLPath diff --git a/src/content/reference/en/p5 copy/green.mdx b/src/content/reference/en/p5 copy/green.mdx deleted file mode 100644 index 72634492fb..0000000000 --- a/src/content/reference/en/p5 copy/green.mdx +++ /dev/null @@ -1,159 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L692 -title: green -module: Color -submodule: Creating & Reading -file: src/color/creating_reading.js -description: > -

Gets the green value of a color.

- -

green() extracts the green value from a - - p5.Color object, an array of color - components, or - - a CSS color string.

- -

By default, green() returns a color's green value in the range - 0 - - to 255. If the colorMode() is set to - RGB, it - - returns the green value in the given range.

-line: 692 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object. - let c = color(175, 100, 220); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'greenValue' to 100. - let greenValue = green(c); - - // Draw the right rectangle. - fill(0, greenValue, 0); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is dark green.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a color array. - let c = [175, 100, 220]; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'greenValue' to 100. - let greenValue = green(c); - - // Draw the right rectangle. - fill(0, greenValue, 0); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is dark green.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a CSS color string. - let c = 'rgb(175, 100, 220)'; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'greenValue' to 100. - let greenValue = green(c); - - // Draw the right rectangle. - fill(0, greenValue, 0); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is dark green.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use RGB color with values in the range 0-100. - colorMode(RGB, 100); - - // Create a p5.Color object using RGB values. - let c = color(69, 39, 86); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'greenValue' to 39. - let greenValue = green(c); - - // Draw the right rectangle. - fill(0, greenValue, 0); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is dark green.'); - } - -
-class: p5 -params: - - name: color - description: | -

p5.Color object, array of - color components, or CSS color string.

- type: 'p5.Color|Number[]|String' -return: - description: the green value. - type: Number -chainable: false ---- - - -# green diff --git a/src/content/reference/en/p5 copy/gridOutput.mdx b/src/content/reference/en/p5 copy/gridOutput.mdx deleted file mode 100644 index c80c3efaf2..0000000000 --- a/src/content/reference/en/p5 copy/gridOutput.mdx +++ /dev/null @@ -1,189 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/accessibility/outputs.js#L161 -title: gridOutput -module: Environment -submodule: Environment -file: src/accessibility/outputs.js -description: > -

Creates a screen reader-accessible description of shapes on the canvas.

- -

gridOutput() adds a general description, table of shapes, and - list of - - shapes to the web page. The general description includes the canvas size, - - canvas color, and number of shapes. For example, - - gray canvas, 100 by 100 pixels, contains 2 shapes: 1 circle 1 - square.

- -

gridOutput() uses its table of shapes as a grid. Each shape in - the grid - - is placed in a cell whose row and column correspond to the shape's location - - on the canvas. The grid cells describe the color and type of shape at that - - location. For example, red circle. These descriptions can be - selected - - individually to get more details. This is different from - - textOutput(), which uses its table as - a list.

- -

A list of shapes follows the table. The list describes the color, type, - - location, and area of each shape. For example, - - red circle, location = middle, area = 3 %.

- -

The display parameter is optional. It determines how the - description is - - displayed. If LABEL is passed, as in - gridOutput(LABEL), the description - - will be visible in a div element next to the canvas. Using LABEL - creates - - unhelpful duplicates for screen readers. Only use LABEL during - - development. If FALLBACK is passed, as in - gridOutput(FALLBACK), the - - description will only be visible to screen readers. This is the default - - mode.

- -

Read - - Writing - accessible canvas descriptions - - to learn more about making sketches accessible.

- -

gridOutput() generates descriptions in English only. Text - drawn with - - text() is not described. Shapes created with - - beginShape() are not described. WEBGL - mode - - and 3D shapes are not supported.

- -

Use describe() and - - describeElement() for more - control - - over canvas descriptions.

-line: 161 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - // Add the grid description. - gridOutput(); - - // Draw a couple of shapes. - background(200); - fill(255, 0, 0); - circle(20, 20, 20); - fill(0, 0, 255); - square(50, 50, 50); - - // Add a general description of the canvas. - describe('A red circle and a blue square on a gray background.'); - } - -
- -
- - function setup() { - // Add the grid description and - // display it for debugging. - gridOutput(LABEL); - - // Draw a couple of shapes. - background(200); - fill(255, 0, 0); - circle(20, 20, 20); - fill(0, 0, 255); - square(50, 50, 50); - - // Add a general description of the canvas. - describe('A red circle and a blue square on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - } - - function draw() { - // Add the grid description. - gridOutput(); - - // Draw a moving circle. - background(200); - let x = frameCount * 0.1; - fill(255, 0, 0); - circle(x, 20, 20); - fill(0, 0, 255); - square(50, 50, 50); - - // Add a general description of the canvas. - describe('A red circle moves from left to right above a blue square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - } - - function draw() { - // Add the grid description and - // display it for debugging. - gridOutput(LABEL); - - // Draw a moving circle. - background(200); - let x = frameCount * 0.1; - fill(255, 0, 0); - circle(x, 20, 20); - fill(0, 0, 255); - square(50, 50, 50); - - // Add a general description of the canvas. - describe('A red circle moves from left to right above a blue square.'); - } - -
-class: p5 -params: - - name: display - description: | -

either FALLBACK or LABEL.

- type: Constant - optional: true -chainable: false ---- - - -# gridOutput diff --git a/src/content/reference/en/p5 copy/height.mdx b/src/content/reference/en/p5 copy/height.mdx deleted file mode 100644 index f6321218df..0000000000 --- a/src/content/reference/en/p5 copy/height.mdx +++ /dev/null @@ -1,87 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L881 -title: height -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

A Number variable that stores the height of the canvas in - pixels.

- -

height's default value is 100. Calling - - createCanvas() or - - resizeCanvas() changes the value of - - height. Calling noCanvas() - sets its value to - - 0.

-line: 881 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - background(200); - - // Display the canvas' height. - text(height, 42, 54); - - describe('The number 100 written in black on a gray square.'); - } - -
- -
- - function setup() { - createCanvas(100, 50); - - background(200); - - // Display the canvas' height. - text(height, 42, 27); - - describe('The number 50 written in black on a gray rectangle.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Display the canvas' height. - text(height, 42, 54); - - describe('The number 100 written in black on a gray square. When the mouse is pressed, the square becomes a rectangle and the number becomes 50.'); - } - - // If the mouse is pressed, reisze - // the canvas and display its new - // height. - function mousePressed() { - if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) { - resizeCanvas(100, 50); - background(200); - text(height, 42, 27); - } - } - -
-class: p5 -type: Number ---- - - -# height diff --git a/src/content/reference/en/p5 copy/hex.mdx b/src/content/reference/en/p5 copy/hex.mdx deleted file mode 100644 index 5475af324a..0000000000 --- a/src/content/reference/en/p5 copy/hex.mdx +++ /dev/null @@ -1,166 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L818 -title: hex -module: Data -submodule: Conversion -file: src/utilities/conversion.js -description: > -

Converts a Number to a String with its - hexadecimal value.

- -

hex() converts a number to a string with its hexadecimal - number value. - - Hexadecimal (hex) numbers are base-16, which means there are 16 unique - - digits. Hex extends the numbers 0–9 with the letters A–F. For example, the - - number 11 (eleven) in base-10 is written as the letter - B in hex.

- -

The first parameter, n, is the number to convert. For example, - hex(20), - - returns the string '00000014'. If an array is passed, as in - - hex([1, 10, 100]), an array of hexadecimal strings is - returned.

- -

The second parameter, digits, is optional. If a number is - passed, as in - - hex(20, 2), it sets the number of hexadecimal digits to display. - For - - example, calling hex(20, 2) returns the string - '14'.

-line: 818 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a number variable. - let original = 20; - - // Convert the number to a hex string. - let converted = hex(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(14); - - // Display the original and converted values. - text(`${original} = ${converted}`, 50, 50); - - describe('The text "20 = 00000014" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a number variable. - let original = 20; - - // Convert the number to a hex string. - // Only display two hex digits. - let converted = hex(original, 2); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the original and converted values. - text(`${original} = ${converted}`, 50, 50); - - describe('The text "20 = 14" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of numbers. - let original = [1, 10, 100]; - - // Convert the numbers to hex strings. - // Only use two hex digits. - let converted = hex(original, 2); - - // Style the text. - textAlign(RIGHT, CENTER); - textSize(16); - - // Iterate over the converted values. - for (let i = 0; i < converted.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 25; - - // Display the original and converted values. - text(`${ original[i]} = ${converted[i]}`, 75, y); - } - - describe( - 'The text "1 = 01", "10 = 0A", and "100 = 64" written on three separate lines. The text is in black on a gray background.' - ); - } - -
-class: p5 -return: - description: converted hexadecimal value. - type: String -overloads: - - line: 818 - params: - - name: 'n' - description: | -

value to convert.

- type: Number - - name: digits - description: | -

number of digits to include.

- type: Number - optional: true - return: - description: converted hexadecimal value. - type: String - - line: 926 - params: - - name: ns - description: | -

values to convert.

- type: 'Number[]' - - name: digits - description: '' - type: Number - optional: true - return: - description: converted hexadecimal values. - type: 'String[]' -chainable: false ---- - - -# hex diff --git a/src/content/reference/en/p5 copy/hour.mdx b/src/content/reference/en/p5 copy/hour.mdx deleted file mode 100644 index 802a809d72..0000000000 --- a/src/content/reference/en/p5 copy/hour.mdx +++ /dev/null @@ -1,47 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L44 -title: hour -module: IO -submodule: Time & Date -file: src/utilities/time_date.js -description: | -

Returns the current hour as a number from 0–23.

-line: 44 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Get the current hour. - let h = hour(); - - // Style the text. - textAlign(LEFT, CENTER); - textSize(12); - textFont('Courier New'); - - // Display the hour. - text(`Current hour: ${h}`, 20, 50, 60); - - describe(`The text 'Current hour: ${h}' written in black on a gray background.`); - } - -
-class: p5 -return: - description: current hour between 0 and 23. - type: Integer -chainable: false ---- - - -# hour diff --git a/src/content/reference/en/p5 copy/httpDo.mdx b/src/content/reference/en/p5 copy/httpDo.mdx deleted file mode 100644 index 52d6553248..0000000000 --- a/src/content/reference/en/p5 copy/httpDo.mdx +++ /dev/null @@ -1,150 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1208 -title: httpDo -module: IO -submodule: Input -file: src/io/files.js -description: > -

Method for executing an HTTP request. If data type is not specified, - - p5 will try to guess based on the URL, defaulting to text.

- - For more advanced use, you may also pass in the path as the first argument - - and a object as the second argument, the signature follows the one specified - - in the Fetch API specification. - - This method is suitable for fetching files up to size of 64MB when "GET" is - used.

-line: 1208 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Examples use USGS Earthquake API: - // https://earthquake.usgs.gov/fdsnws/event/1/#methods - - // displays an animation of all USGS earthquakes - let earthquakes; - let eqFeatureIndex = 0; - - function preload() { - let url = 'https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson'; - httpDo( - url, - { - method: 'GET', - // Other Request options, like special headers for apis - headers: { authorization: 'Bearer secretKey' } - }, - function(res) { - earthquakes = res; - } - ); - } - - function draw() { - // wait until the data is loaded - if (!earthquakes || !earthquakes.features[eqFeatureIndex]) { - return; - } - clear(); - - let feature = earthquakes.features[eqFeatureIndex]; - let mag = feature.properties.mag; - let rad = mag / 11 * ((width + height) / 2); - fill(255, 0, 0, 100); - ellipse(width / 2 + random(-2, 2), height / 2 + random(-2, 2), rad, rad); - - if (eqFeatureIndex >= earthquakes.features.length) { - eqFeatureIndex = 0; - } else { - eqFeatureIndex += 1; - } - } - -
-class: p5 -return: - description: |- - A promise that resolves with the data when the operation - completes successfully or rejects with the error after - one occurs. - type: Promise -overloads: - - line: 1208 - params: - - name: path - description: | -

name of the file or url to load

- type: String - - name: method - description: | -

either "GET", "POST", or "PUT", - defaults to "GET"

- type: String - optional: true - - name: datatype - description: | -

"json", "jsonp", "xml", or "text"

- type: String - optional: true - - name: data - description: | -

param data passed sent with request

- type: Object - optional: true - - name: callback - description: | -

function to be executed after - httpGet() completes, data is passed in - as first argument

- type: Function - optional: true - - name: errorCallback - description: | -

function to be executed if - there is an error, response is passed - in as first argument

- type: Function - optional: true - return: - description: |- - A promise that resolves with the data when the operation - completes successfully or rejects with the error after - one occurs. - type: Promise - - line: 1279 - params: - - name: path - description: '' - type: String - - name: options - description: > -

Request object options as documented in the - "fetch" API - reference

- type: Object - - name: callback - description: '' - type: Function - optional: true - - name: errorCallback - description: '' - type: Function - optional: true - return: - description: '' - type: Promise -chainable: false ---- - - -# httpDo diff --git a/src/content/reference/en/p5 copy/httpGet.mdx b/src/content/reference/en/p5 copy/httpGet.mdx deleted file mode 100644 index 9e8591e059..0000000000 --- a/src/content/reference/en/p5 copy/httpGet.mdx +++ /dev/null @@ -1,140 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1043 -title: httpGet -module: IO -submodule: Input -file: src/io/files.js -description: > -

Method for executing an HTTP GET request. If data type is not specified, - - p5 will try to guess based on the URL, defaulting to text. This is equivalent - to - - calling httpDo(path, 'GET'). The 'binary' datatype will return - - a Blob object, and the 'arrayBuffer' datatype will return an ArrayBuffer - - which can be used to initialize typed arrays (such as Uint8Array).

-line: 1043 -isConstructor: false -itemtype: method -example: - - |- - -
- // Examples use USGS Earthquake API: - // https://earthquake.usgs.gov/fdsnws/event/1/#methods - let earthquakes; - function preload() { - // Get the most recent earthquake in the database - let url = - 'https://earthquake.usgs.gov/fdsnws/event/1/query?' + - 'format=geojson&limit=1&orderby=time'; - httpGet(url, 'jsonp', false, function(response) { - // when the HTTP request completes, populate the variable that holds the - // earthquake data used in the visualization. - earthquakes = response; - }); - } - - function draw() { - if (!earthquakes) { - // Wait until the earthquake data has loaded before drawing. - return; - } - background(200); - // Get the magnitude and name of the earthquake out of the loaded JSON - let earthquakeMag = earthquakes.features[0].properties.mag; - let earthquakeName = earthquakes.features[0].properties.place; - ellipse(width / 2, height / 2, earthquakeMag * 10, earthquakeMag * 10); - textAlign(CENTER); - text(earthquakeName, 0, height - 30, width, 30); - noLoop(); - } -
-class: p5 -return: - description: |- - A promise that resolves with the data when the operation - completes successfully or rejects with the error after - one occurs. - type: Promise -overloads: - - line: 1043 - params: - - name: path - description: | -

name of the file or url to load

- type: String - - name: datatype - description: | -

"json", "jsonp", "binary", "arrayBuffer", - "xml", or "text"

- type: String - optional: true - - name: data - description: | -

param data passed sent with request

- type: Object|Boolean - optional: true - - name: callback - description: | -

function to be executed after - httpGet() completes, data is passed in - as first argument

- type: Function - optional: true - - name: errorCallback - description: | -

function to be executed if - there is an error, response is passed - in as first argument

- type: Function - optional: true - return: - description: |- - A promise that resolves with the data when the operation - completes successfully or rejects with the error after - one occurs. - type: Promise - - line: 1097 - params: - - name: path - description: '' - type: String - - name: data - description: '' - type: Object|Boolean - - name: callback - description: '' - type: Function - optional: true - - name: errorCallback - description: '' - type: Function - optional: true - return: - description: '' - type: Promise - - line: 1105 - params: - - name: path - description: '' - type: String - - name: callback - description: '' - type: Function - - name: errorCallback - description: '' - type: Function - optional: true - return: - description: '' - type: Promise -chainable: false ---- - - -# httpGet diff --git a/src/content/reference/en/p5 copy/httpPost.mdx b/src/content/reference/en/p5 copy/httpPost.mdx deleted file mode 100644 index 39f4fc75a0..0000000000 --- a/src/content/reference/en/p5 copy/httpPost.mdx +++ /dev/null @@ -1,165 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1119 -title: httpPost -module: IO -submodule: Input -file: src/io/files.js -description: > -

Method for executing an HTTP POST request. If data type is not specified, - - p5 will try to guess based on the URL, defaulting to text. This is equivalent - to - - calling httpDo(path, 'POST').

-line: 1119 -isConstructor: false -itemtype: method -example: - - >- - -
- - - - // Examples use jsonplaceholder.typicode.com for a Mock Data API - - - let url = 'https://jsonplaceholder.typicode.com/posts'; - - let postData = { userId: 1, title: 'p5 Clicked!', body: 'p5.js is very - cool.' }; - - - function setup() { - createCanvas(100, 100); - background(200); - } - - - function mousePressed() { - httpPost(url, 'json', postData, function(result) { - strokeWeight(2); - text(result.body, mouseX, mouseY); - }); - } - - - -
- - -
- - let url = 'ttps://invalidURL'; // A bad URL that will cause errors - - let postData = { title: 'p5 Clicked!', body: 'p5.js is very cool.' }; - - - function setup() { - createCanvas(100, 100); - background(200); - } - - - function mousePressed() { - httpPost( - url, - 'json', - postData, - function(result) { - // ... won't be called - }, - function(error) { - strokeWeight(2); - text(error.toString(), mouseX, mouseY); - } - ); - } - -
-class: p5 -return: - description: |- - A promise that resolves with the data when the operation - completes successfully or rejects with the error after - one occurs. - type: Promise -overloads: - - line: 1119 - params: - - name: path - description: | -

name of the file or url to load

- type: String - - name: datatype - description: | -

"json", "jsonp", "xml", or "text". - If omitted, httpPost() will guess.

- type: String - optional: true - - name: data - description: | -

param data passed sent with request

- type: Object|Boolean - optional: true - - name: callback - description: | -

function to be executed after - httpPost() completes, data is passed in - as first argument

- type: Function - optional: true - - name: errorCallback - description: | -

function to be executed if - there is an error, response is passed - in as first argument

- type: Function - optional: true - return: - description: |- - A promise that resolves with the data when the operation - completes successfully or rejects with the error after - one occurs. - type: Promise - - line: 1186 - params: - - name: path - description: '' - type: String - - name: data - description: '' - type: Object|Boolean - - name: callback - description: '' - type: Function - optional: true - - name: errorCallback - description: '' - type: Function - optional: true - return: - description: '' - type: Promise - - line: 1194 - params: - - name: path - description: '' - type: String - - name: callback - description: '' - type: Function - - name: errorCallback - description: '' - type: Function - optional: true - return: - description: '' - type: Promise -chainable: false ---- - - -# httpPost diff --git a/src/content/reference/en/p5 copy/hue.mdx b/src/content/reference/en/p5 copy/hue.mdx deleted file mode 100644 index 6baca2b9ce..0000000000 --- a/src/content/reference/en/p5 copy/hue.mdx +++ /dev/null @@ -1,145 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L828 -title: hue -module: Color -submodule: Creating & Reading -file: src/color/creating_reading.js -description: > -

Gets the hue value of a color.

- -

hue() extracts the hue value from a - - p5.Color object, an array of color - components, or - - a CSS color string.

- -

Hue describes a color's position on the color wheel. By default, - hue() - - returns a color's HSL hue in the range 0 to 360. If the - - colorMode() is set to HSB or HSL, it - returns the hue - - value in the given mode.

-line: 828 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use HSL color. - colorMode(HSL); - - // Create a p5.Color object. - let c = color(0, 50, 100); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 20, 35, 60); - - // Set 'hueValue' to 0. - let hueValue = hue(c); - - // Draw the right rectangle. - fill(hueValue); - rect(50, 20, 35, 60); - - describe( - 'Two rectangles. The rectangle on the left is salmon pink and the one on the right is black.' - ); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use HSL color. - colorMode(HSL); - - // Create a color array. - let c = [0, 50, 100]; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 20, 35, 60); - - // Set 'hueValue' to 0. - let hueValue = hue(c); - - // Draw the right rectangle. - fill(hueValue); - rect(50, 20, 35, 60); - - describe( - 'Two rectangles. The rectangle on the left is salmon pink and the one on the right is black.' - ); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use HSL color. - colorMode(HSL); - - // Create a CSS color string. - let c = 'rgb(255, 128, 128)'; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 20, 35, 60); - - // Set 'hueValue' to 0. - let hueValue = hue(c); - - // Draw the right rectangle. - fill(hueValue); - rect(50, 20, 35, 60); - - describe( - 'Two rectangles. The rectangle on the left is salmon pink and the one on the right is black.' - ); - } - -
-class: p5 -params: - - name: color - description: | -

p5.Color object, array of - color components, or CSS color string.

- type: 'p5.Color|Number[]|String' -return: - description: the hue value. - type: Number -chainable: false ---- - - -# hue diff --git a/src/content/reference/en/p5 copy/if.mdx b/src/content/reference/en/p5 copy/if.mdx deleted file mode 100644 index 88228b3ed0..0000000000 --- a/src/content/reference/en/p5 copy/if.mdx +++ /dev/null @@ -1,268 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L110 -title: if -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: > -

A way to choose whether to run a block of code.

- -

if statements are helpful for running a block of code based on - a - - condition. For example, an if statement makes it easy to express - the - - idea "Draw a circle if the mouse is pressed.":

- -
if (mouseIsPressed === true) {
-    circle(mouseX, mouseY, 20);
-  }
-
-  
- -

The statement header begins with the keyword if. The - expression in - - parentheses mouseIsPressed === true is a Boolean - expression that's - - either true or false. The code between the curly - braces {} is the if - - statement's body. The body only runs if the Boolean expression is - true.

- -

The mouseIsPressed system - variable is - - always true or false, so the code snippet above - could also be written - - as follows:

- -
if (mouseIsPressed) {
-    circle(mouseX, mouseY, 20);
-  }
-
-  
- -

An if-else statement adds a block of code that - runs if the Boolean - - expression is false. For example, here's an - if-else statement that - - expresses the idea "Draw a circle if the mouse is pressed. Otherwise, - - display a message.":

- -
if (mouseIsPressed === true) {
-    // When true.
-    circle(mouseX, mouseY, 20);
-  } else {
-    // When false.
-    text('Click me!', 50, 50);
-  }
-
-  
- -

There are two possible paths, or branches, in this code snippet. The - - program must follow one branch or the other.

- -

An else-if statement makes it possible to add - more branches. - - else-if statements run different blocks of code - under different - - conditions. For example, an else-if statement makes - it easy to express - - the idea "If the mouse is on the left, paint the canvas white. If the mouse - - is in the middle, paint the canvas gray. Otherwise, paint the canvas - - black.":

- -
if (mouseX < 33) {
-    background(255);
-  } else if (mouseX < 67) {
-    background(200);
-  } else {
-    background(0);
-  }
-
-  
- -

if statements can add as many - else-if statements as needed. However, - - there can only be one else statement and it must be last.

- -

if statements can also check for multiple conditions at once. - For - - example, the Boolean operator && (AND) checks - whether two expressions - - are both true:

- -
if (keyIsPressed === true && key === 'p') {
-    text('You pressed the "p" key!', 50, 50);
-  }
-
-  
- -

If the user is pressing a key AND that key is 'p', then a - message will - - display.

- -

The Boolean operator || (OR) checks whether at - least one of two - - expressions is true:

- -
if (keyIsPressed === true || mouseIsPressed ===
-  true) {
-    text('You did something!', 50, 50);
-  }
-
-  
- -

If the user presses a key, or presses a mouse button, or both, then a - - message will display.

- -

The body of an if statement can contain another - if statement. This is - - called a "nested if statement." For example, nested - if statements make - - it easy to express the idea "If a key is pressed, then check if the key is - - 'r'. If it is, then set the fill to red.":

- -
if (keyIsPressed === true) {
-    if (key === 'r') {
-      fill('red');
-    }
-  }
-
-  
- -

See Boolean and Number - - to learn more about these data types and the operations they support.

-line: 110 -isConstructor: false -itemtype: property -example: - - |- - -
- - // Click the mouse to show the circle. - - function setup() { - createCanvas(100, 100); - - describe( - 'A white circle on a gray background. The circle follows the mouse user clicks on the canvas.' - ); - } - - function draw() { - background(200); - - if (mouseIsPressed === true) { - circle(mouseX, mouseY, 20); - } - } - -
- -
- - // Click the mouse to show different shapes. - - function setup() { - createCanvas(100, 100); - - describe( - 'A white ellipse on a gray background. The ellipse becomes a circle when the user presses the mouse.' - ); - } - - function draw() { - background(200); - - if (mouseIsPressed === true) { - circle(50, 50, 20); - } else { - ellipse(50, 50, 20, 50); - } - } - -
- -
- - // Move the mouse to change the background color. - - function setup() { - createCanvas(100, 100); - - describe( - 'A square changes color from white to black as the user moves the mouse from left to right.' - ); - } - - function draw() { - if (mouseX < 33) { - background(255); - } else if (mouseX < 67) { - background(200); - } else { - background(0); - } - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - function setup() { - createCanvas(100, 100); - - describe( - 'A white circle drawn on a gray background. The circle changes color to red when the user presses the "r" key.' - ); - } - - function draw() { - background(200); - - if (keyIsPressed === true) { - if (key === 'r') { - fill('red'); - } - } - - circle(50, 50, 40); - } - -
-class: p5 ---- - - -# if diff --git a/src/content/reference/en/p5 copy/image.mdx b/src/content/reference/en/p5 copy/image.mdx deleted file mode 100644 index 9dbd36fd22..0000000000 --- a/src/content/reference/en/p5 copy/image.mdx +++ /dev/null @@ -1,327 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L888 -title: image -module: Image -submodule: Loading & Displaying -file: src/image/loading_displaying.js -description: > -

Draws an image to the canvas.

- -

The first parameter, img, is the source image to be drawn. - img can be - - any of the following objects:

- - - -

The second and third parameters, dx and dy, set - the coordinates of the - - destination image's top left corner. See - - imageMode() for other ways to position - images.

- -

Here's a diagram that explains how optional parameters work in - image():

- -

- -

The fourth and fifth parameters, dw and dh, are - optional. They set the - - the width and height to draw the destination image. By default, - image() - - draws the full source image at its original size.

- -

The sixth and seventh parameters, sx and sy, are - also optional. - - These coordinates define the top left corner of a subsection to draw from - - the source image.

- -

The eighth and ninth parameters, sw and sh, are - also optional. - - They define the width and height of a subsection to draw from the source - - image. By default, image() draws the full subsection that begins - at - - (sx, sy) and extends to the edges of the source image.

- -

The ninth parameter, fit, is also optional. It enables a - subsection of - - the source image to be drawn without affecting its aspect ratio. If - - CONTAIN is passed, the full subsection will appear within the - destination - - rectangle. If COVER is passed, the subsection will completely - cover the - - destination rectangle. This may have the effect of zooming into the - - subsection.

- -

The tenth and eleventh parameters, xAlign and - yAlign, are also - - optional. They determine how to align the fitted subsection. - xAlign can - - be set to either LEFT, RIGHT, or - CENTER. yAlign can be set to - - either TOP, BOTTOM, or CENTER. By - default, both xAlign and yAlign - - are set to CENTER.

-line: 888 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100); - - background(50); - - // Draw the image. - image(img, 0, 0); - - describe('An image of the underside of a white umbrella with a gridded ceiling above.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100); - - background(50); - - // Draw the image. - image(img, 10, 10); - - describe('An image of the underside of a white umbrella with a gridded ceiling above. The image has dark gray borders on its left and top.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100); - - background(50); - - // Draw the image 50x50. - image(img, 0, 0, 50, 50); - - describe('An image of the underside of a white umbrella with a gridded ceiling above. The image is drawn in the top left corner of a dark gray square.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100); - - background(50); - - // Draw the center of the image. - image(img, 25, 25, 50, 50, 25, 25, 50, 50); - - describe('An image of a gridded ceiling drawn in the center of a dark gray square.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/moonwalk.jpg'); - } - - function setup() { - createCanvas(100, 100); - - background(50); - - // Draw the image and scale it to fit within the canvas. - image(img, 0, 0, width, height, 0, 0, img.width, img.height, CONTAIN); - - describe('An image of an astronaut on the moon. The top and bottom borders of the image are dark gray.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - // Image is 50 x 50 pixels. - img = loadImage('/assets/laDefense50.png'); - } - - function setup() { - createCanvas(100, 100); - - background(50); - - // Draw the image and scale it to cover the canvas. - image(img, 0, 0, width, height, 0, 0, img.width, img.height, COVER); - - describe('A pixelated image of the underside of a white umbrella with a gridded ceiling above.'); - } - -
-class: p5 -overloads: - - line: 888 - params: - - name: img - description: | -

image to display.

- type: p5.Image|p5.Element|p5.Texture|p5.Framebuffer|p5.FramebufferTexture - - name: x - description: | -

x-coordinate of the top-left corner of the image.

- type: Number - - name: 'y' - description: | -

y-coordinate of the top-left corner of the image.

- type: Number - - name: width - description: | -

width to draw the image.

- type: Number - optional: true - - name: height - description: | -

height to draw the image.

- type: Number - optional: true - - line: 1074 - params: - - name: img - description: '' - type: p5.Image|p5.Element|p5.Texture|p5.Framebuffer|p5.FramebufferTexture - - name: dx - description: | -

the x-coordinate of the destination - rectangle in which to draw the source image

- type: Number - - name: dy - description: | -

the y-coordinate of the destination - rectangle in which to draw the source image

- type: Number - - name: dWidth - description: | -

the width of the destination rectangle

- type: Number - - name: dHeight - description: | -

the height of the destination rectangle

- type: Number - - name: sx - description: | -

the x-coordinate of the subsection of the source - image to draw into the destination rectangle

- type: Number - - name: sy - description: | -

the y-coordinate of the subsection of the source - image to draw into the destination rectangle

- type: Number - - name: sWidth - description: | -

the width of the subsection of the - source image to draw into the destination - rectangle

- type: Number - optional: true - - name: sHeight - description: | -

the height of the subsection of the - source image to draw into the destination rectangle

- type: Number - optional: true - - name: fit - description: | -

either CONTAIN or COVER

- type: Constant - optional: true - - name: xAlign - description: | -

either LEFT, RIGHT or CENTER default is CENTER

- type: Constant - optional: true - - name: yAlign - description: | -

either TOP, BOTTOM or CENTER default is CENTER

- type: Constant - optional: true -chainable: false ---- - - -# image diff --git a/src/content/reference/en/p5 copy/imageLight.mdx b/src/content/reference/en/p5 copy/imageLight.mdx deleted file mode 100644 index 70b001f3e5..0000000000 --- a/src/content/reference/en/p5 copy/imageLight.mdx +++ /dev/null @@ -1,86 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L956 -title: imageLight -module: 3D -submodule: Lights -file: src/webgl/light.js -description: > -

Creates an ambient light from an image.

- -

imageLight() simulates a light shining from all directions. - The effect is - - like placing the sketch at the center of a giant sphere that uses the image - - as its texture. The image's diffuse light will be affected by - - fill() and the specular reflections will be - - affected by specularMaterial() - and - - shininess().

- -

The parameter, img, is the p5.Image object to - - use as the light source.

-line: 956 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - let img; - - // Load an image and create a p5.Image object. - function preload() { - img = loadImage('/assets/outdoor_spheremap.jpg'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A sphere floating above a landscape. The surface of the sphere reflects the landscape.'); - } - - function draw() { - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the image as a panorama (360˚ background). - panorama(img); - - // Add a soft ambient light. - ambientLight(50); - - // Add light from the image. - imageLight(img); - - // Style the sphere. - specularMaterial(20); - shininess(100); - noStroke(); - - // Draw the sphere. - sphere(30); - } - -
-class: p5 -params: - - name: img - description: | -

image to use as the light source.

- type: p5.image -chainable: false ---- - - -# imageLight diff --git a/src/content/reference/en/p5 copy/imageMode.mdx b/src/content/reference/en/p5 copy/imageMode.mdx deleted file mode 100644 index f7d41c6d54..0000000000 --- a/src/content/reference/en/p5 copy/imageMode.mdx +++ /dev/null @@ -1,129 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L1395 -title: imageMode -module: Image -submodule: Loading & Displaying -file: src/image/loading_displaying.js -description: > -

Changes the location from which images are drawn when - - image() is called.

- -

By default, the first - - two parameters of image() are the x- and - - y-coordinates of the image's upper-left corner. The next parameters are - - its width and height. This is the same as calling - imageMode(CORNER).

- -

imageMode(CORNERS) also uses the first two parameters of - - image() as the x- and y-coordinates of the - image's - - top-left corner. The third and fourth parameters are the coordinates of its - - bottom-right corner.

- -

imageMode(CENTER) uses the first two parameters of - - image() as the x- and y-coordinates of the - image's - - center. The next parameters are its width and height.

-line: 1395 -isConstructor: false -itemtype: method -example: - - |- - - -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Use CORNER mode. - imageMode(CORNER); - - // Display the image. - image(img, 10, 10, 50, 50); - - describe('A square image of a brick wall is drawn at the top left of a gray square.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Use CORNERS mode. - imageMode(CORNERS); - - // Display the image. - image(img, 10, 10, 90, 40); - - describe('An image of a brick wall is drawn on a gray square. The image is squeezed into a small rectangular area.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Use CENTER mode. - imageMode(CENTER); - - // Display the image. - image(img, 50, 50, 80, 80); - - describe('A square image of a brick wall is drawn on a gray square.'); - } - -
-class: p5 -params: - - name: mode - description: | -

either CORNER, CORNERS, or CENTER.

- type: Constant -chainable: false ---- - - -# imageMode diff --git a/src/content/reference/en/p5 copy/input.mdx b/src/content/reference/en/p5 copy/input.mdx deleted file mode 100644 index 83f71feabc..0000000000 --- a/src/content/reference/en/p5 copy/input.mdx +++ /dev/null @@ -1,88 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L405 -title: input -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Calls a function when the element receives input.

- -

myElement.input() is often used to with text inputs and - sliders. Calling - - myElement.input(false) disables the function.

-line: 405 -isConstructor: false -itemtype: method -example: - - |- - -
- - let slider; - - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a slider and place it beneath the canvas. - slider = createSlider(0, 255, 200); - slider.position(0, 100); - - // Call repaint() when the slider changes. - slider.input(repaint); - - describe('A gray square with a range slider underneath it. The background changes shades of gray when the slider is moved.'); - } - - // Paint the background using slider's value. - function repaint() { - let g = slider.value(); - background(g); - } - -
- -
- - let input; - - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an input and place it beneath the canvas. - input = createInput(''); - input.position(0, 100); - - // Call repaint() when input is detected. - input.input(repaint); - - describe('A gray square with a text input bar beneath it. Any text written in the input appears in the middle of the square.'); - } - - // Paint the background gray and display the input's value. - function repaint() { - background(200); - let msg = input.value(); - text(msg, 5, 50); - } - -
-class: p5 -params: - - name: fxn - description: | -

function to call when input is detected within - the element. - false disables the function.

- type: Function|Boolean -chainable: true ---- - - -# input diff --git a/src/content/reference/en/p5 copy/int.mdx b/src/content/reference/en/p5 copy/int.mdx deleted file mode 100644 index 5d5fe8826a..0000000000 --- a/src/content/reference/en/p5 copy/int.mdx +++ /dev/null @@ -1,169 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L92 -title: int -module: Data -submodule: Conversion -file: src/utilities/conversion.js -description: > -

Converts a Boolean, String, or decimal - Number to an integer.

- -

int() converts values to integers. Integers are positive or - negative - - numbers without decimals. If the original value has decimals, as in -34.56, - - they're removed to produce an integer such as -34.

- -

The parameter, n, is the value to convert. If n - is a Boolean, as in - - int(false) or int(true), then the number 0 - (false) or 1 (true) will - - be returned. If n is a string or number, as in - int('45') or - - int(67.89), then an integer will be returned. If an array is - passed, as - - in int([12.34, 56.78]), then an array of integers will be - returned.

- -

Note: If a value can't be converted to a number, as in - int('giraffe'), - - then the value NaN (not a number) will be returned.

-line: 92 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a Boolean variable. - let original = false; - - // Convert the Boolean to an integer. - let converted = int(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the original and converted values. - text(`${original} : ${converted}`, 50, 50); - - describe('The text "false : 0" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let original = '12.34'; - - // Convert the string to an integer. - let converted = int(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(14); - - // Display the original and converted values. - text(`${original} ≈ ${converted}`, 50, 50); - - describe('The text "12.34 ≈ 12" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a decimal number variable. - let original = 12.34; - - // Convert the decimal number to an integer. - let converted = int(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(14); - - // Display the original and converted values. - text(`${original} ≈ ${converted}`, 50, 50); - - describe('The text "12.34 ≈ 12" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of strings. - let original = ['60', '30', '15']; - - // Convert the strings to integers. - let diameters = int(original); - - for (let d of diameters) { - // Draw a circle. - circle(50, 50, d); - } - - describe('Three white, concentric circles on a gray background.'); - } - -
-class: p5 -return: - description: converted number. - type: Number -overloads: - - line: 92 - params: - - name: 'n' - description: | -

value to convert.

- type: String|Boolean|Number - return: - description: converted number. - type: Number - - line: 211 - params: - - name: ns - description: | -

values to convert.

- type: Array - return: - description: converted numbers. - type: 'Number[]' -chainable: false ---- - - -# int diff --git a/src/content/reference/en/p5 copy/isLooping.mdx b/src/content/reference/en/p5 copy/isLooping.mdx deleted file mode 100644 index 622fd77d9b..0000000000 --- a/src/content/reference/en/p5 copy/isLooping.mdx +++ /dev/null @@ -1,65 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L224 -title: isLooping -module: Structure -submodule: Structure -file: src/core/structure.js -description: > -

Returns true if the draw loop is running and - false if not.

- -

By default, draw() tries to run 60 times - per - - second. Calling noLoop() stops - - draw() from repeating. The draw loop can be - - restarted by calling loop().

- -

The isLooping() function can be used to check whether a sketch - is - - looping, as in isLooping() === true.

-line: 224 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A white circle drawn against a gray background. When the user double-clicks, the circle stops or resumes following the mouse.'); - } - - function draw() { - background(200); - - // Draw the circle at the mouse's position. - circle(mouseX, mouseY, 20); - } - - // Toggle the draw loop when the user double-clicks. - function doubleClicked() { - if (isLooping() === true) { - noLoop(); - } else { - loop(); - } - } - -
-class: p5 -return: - description: '' - type: Boolean -chainable: false ---- - - -# isLooping diff --git a/src/content/reference/en/p5 copy/join.mdx b/src/content/reference/en/p5 copy/join.mdx deleted file mode 100644 index 23222a6db4..0000000000 --- a/src/content/reference/en/p5 copy/join.mdx +++ /dev/null @@ -1,70 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L15 -title: join -module: Data -submodule: String Functions -file: src/utilities/string_functions.js -description: > -

Combines an array of strings into one string.

- -

The first parameter, list, is the array of strings to - join.

- -

The second parameter, separator, is the character(s) that - should be used - - to separate the combined strings. For example, calling - - join(myWords, ' : ') would return a string of words each - separated by a - - colon and spaces.

-line: 15 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of strings. - let myWords = ['one', 'two', 'three']; - - // Create a combined string - let combined = join(myWords, ' : '); - - // Style the text. - textAlign(CENTER, CENTER); - - // Display the combined string. - text(combined, 50, 50); - - describe('The text "one : two : three" written in black on a gray canvas.'); - } - -
-class: p5 -params: - - name: list - description: | -

array of strings to combine.

- type: Array - - name: separator - description: | -

character(s) to place between strings when they're combined.

- type: String -return: - description: combined string. - type: String -chainable: false ---- - - -# join diff --git a/src/content/reference/en/p5 copy/key.mdx b/src/content/reference/en/p5 copy/key.mdx deleted file mode 100644 index 63fc144fa3..0000000000 --- a/src/content/reference/en/p5 copy/key.mdx +++ /dev/null @@ -1,106 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L102 -title: key -module: Events -submodule: Keyboard -file: src/events/keyboard.js -description: > -

A String system variable that contains the value of the last - key typed.

- -

The key variable is helpful for checking whether an - - ASCII - - key has been typed. For example, the expression key === "a" - evaluates to - - true if the a key was typed and false - if not. key doesn’t update - - for special keys such as LEFT_ARROW and ENTER. Use - keyCode instead for - - special keys. The keyIsDown() function - should - - be used to check for multiple different key presses at the same time.

-line: 102 -isConstructor: false -itemtype: property -example: - - |- - -
- - // Click on the canvas to begin detecting key presses. - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square. The last key pressed is displayed at the center.' - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the last key pressed. - text(key, 50, 50); - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - let x = 50; - let y = 50; - - function setup() { - createCanvas(100, 100); - - background(200); - - describe( - 'A gray square with a black circle at its center. The circle moves when the user presses the keys "w", "a", "s", or "d". It leaves a trail as it moves.' - ); - } - - function draw() { - // Update x and y if a key is pressed. - if (keyIsPressed === true) { - if (key === 'w') { - y -= 1; - } else if (key === 's') { - y += 1; - } else if (key === 'a') { - x -= 1; - } else if (key === 'd') { - x += 1; - } - } - - // Style the circle. - fill(0); - - // Draw the circle at (x, y). - circle(x, y, 5); - } - -
-class: p5 -type: String ---- - - -# key diff --git a/src/content/reference/en/p5 copy/keyCode.mdx b/src/content/reference/en/p5 copy/keyCode.mdx deleted file mode 100644 index 808526b788..0000000000 --- a/src/content/reference/en/p5 copy/keyCode.mdx +++ /dev/null @@ -1,128 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L184 -title: keyCode -module: Events -submodule: Keyboard -file: src/events/keyboard.js -description: > -

A Number system variable that contains the code of the last - key typed.

- -

All keys have a keyCode. For example, the a key - has the keyCode 65. - - The keyCode variable is helpful for checking whether a special - key has - - been typed. For example, the following conditional checks whether the enter - - key has been typed:

- -
if (keyCode === 13) {
-    // Code to run if the enter key was pressed.
-  }
-
-  
- -

The same code can be written more clearly using the system variable - ENTER - - which has a value of 13:

- -
if (keyCode === ENTER) {
-    // Code to run if the enter key was pressed.
-  }
-
-  
- -

The system variables BACKSPACE, DELETE, - ENTER, RETURN, TAB, - - ESCAPE, SHIFT, CONTROL, - OPTION, ALT, UP_ARROW, - DOWN_ARROW, - - LEFT_ARROW, and RIGHT_ARROW are all helpful - shorthands the key codes of - - special keys. Key codes can be found on websites such as - - keycode.info.

-line: 184 -isConstructor: false -itemtype: property -example: - - |- - -
- - // Click on the canvas to begin detecting key presses. - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square. The last key pressed and its code are displayed at the center.' - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the last key pressed and its code. - text(`${key} : ${keyCode}`, 50, 50); - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - let x = 50; - let y = 50; - - function setup() { - createCanvas(100, 100); - - background(200); - - describe( - 'A gray square with a black circle at its center. The circle moves when the user presses an arrow key. It leaves a trail as it moves.' - ); - } - - function draw() { - // Update x and y if an arrow key is pressed. - if (keyIsPressed === true) { - if (keyCode === UP_ARROW) { - y -= 1; - } else if (keyCode === DOWN_ARROW) { - y += 1; - } else if (keyCode === LEFT_ARROW) { - x -= 1; - } else if (keyCode === RIGHT_ARROW) { - x += 1; - } - } - - // Style the circle. - fill(0); - - // Draw the circle at (x, y). - circle(x, y, 5); - } - -
-class: p5 -type: Integer ---- - - -# keyCode diff --git a/src/content/reference/en/p5 copy/keyIsDown.mdx b/src/content/reference/en/p5 copy/keyIsDown.mdx deleted file mode 100644 index 8afe4b0bdf..0000000000 --- a/src/content/reference/en/p5 copy/keyIsDown.mdx +++ /dev/null @@ -1,142 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L811 -title: keyIsDown -module: Events -submodule: Keyboard -file: src/events/keyboard.js -description: > -

Returns true if the key it’s checking is pressed and - false if not.

- -

keyIsDown() is helpful when checking for multiple different - key presses. - - For example, keyIsDown() can be used to check if both - LEFT_ARROW and - - UP_ARROW are pressed:

- -
if (keyIsDown(LEFT_ARROW) &&
-  keyIsDown(UP_ARROW)) {
-    // Move diagonally.
-  }
-
-  
- -

keyIsDown() can check for key presses using - - keyCode values, as in - keyIsDown(37) or - - keyIsDown(LEFT_ARROW). Key codes can be found on websites such as - - keycode.info.

-line: 811 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click on the canvas to begin detecting key presses. - - let x = 50; - let y = 50; - - function setup() { - createCanvas(100, 100); - - background(200); - - describe( - 'A gray square with a black circle at its center. The circle moves when the user presses an arrow key. It leaves a trail as it moves.' - ); - } - - function draw() { - // Update x and y if an arrow key is pressed. - if (keyIsDown(LEFT_ARROW) === true) { - x -= 1; - } - - if (keyIsDown(RIGHT_ARROW) === true) { - x += 1; - } - - if (keyIsDown(UP_ARROW) === true) { - y -= 1; - } - - if (keyIsDown(DOWN_ARROW) === true) { - y += 1; - } - - // Style the circle. - fill(0); - - // Draw the circle. - circle(x, y, 5); - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - let x = 50; - let y = 50; - - function setup() { - createCanvas(100, 100); - - background(200); - - describe( - 'A gray square with a black circle at its center. The circle moves when the user presses an arrow key. It leaves a trail as it moves.' - ); - } - - function draw() { - // Update x and y if an arrow key is pressed. - if (keyIsDown(37) === true) { - x -= 1; - } - - if (keyIsDown(39) === true) { - x += 1; - } - - if (keyIsDown(38) === true) { - y -= 1; - } - - if (keyIsDown(40) === true) { - y += 1; - } - - // Style the circle. - fill(0); - - // Draw the circle. - circle(x, y, 5); - } - -
-class: p5 -params: - - name: code - description: | -

key to check.

- type: Number -return: - description: whether the key is down or not. - type: Boolean -chainable: false ---- - - -# keyIsDown diff --git a/src/content/reference/en/p5 copy/keyIsPressed.mdx b/src/content/reference/en/p5 copy/keyIsPressed.mdx deleted file mode 100644 index 0b129c49e8..0000000000 --- a/src/content/reference/en/p5 copy/keyIsPressed.mdx +++ /dev/null @@ -1,105 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L10 -title: keyIsPressed -module: Events -submodule: Keyboard -file: src/events/keyboard.js -description: > -

A Boolean system variable that's true if any key - is currently pressed - - and false if not.

-line: 10 -isConstructor: false -itemtype: property -example: - - |- - -
- - // Click on the canvas to begin detecting key presses. - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a white square at its center. The white square turns black when the user presses a key.' - ); - } - - function draw() { - background(200); - - // Style the square. - if (keyIsPressed === true) { - fill(0); - } else { - fill(255); - } - - // Draw the square. - square(25, 25, 50); - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a white square at its center. The white square turns black when the user presses a key.' - ); - } - - function draw() { - background(200); - - // Style the square. - if (keyIsPressed) { - fill(0); - } else { - fill(255); - } - - // Draw the square. - square(25, 25, 50); - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with the word "false" at its center. The word switches to "true" when the user presses a key.' - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the value of keyIsPressed. - text(keyIsPressed, 50, 50); - } - -
-class: p5 -type: Boolean ---- - - -# keyIsPressed diff --git a/src/content/reference/en/p5 copy/keyPressed.mdx b/src/content/reference/en/p5 copy/keyPressed.mdx deleted file mode 100644 index 4a4007f09a..0000000000 --- a/src/content/reference/en/p5 copy/keyPressed.mdx +++ /dev/null @@ -1,192 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L284 -title: keyPressed -module: Events -submodule: Keyboard -file: src/events/keyboard.js -description: > -

A function that's called once when any key is pressed.

- -

Declaring the function keyPressed() sets a code block to run - once - - automatically when the user presses any key:

- -
function keyPressed() {
-    // Code to run.
-  }
-
-  
- -

The key and keyCode - - variables will be updated with the most recently typed value when - - keyPressed() is called by p5.js:

- -
function keyPressed() {
-    if (key === 'c') {
-      // Code to run.
-    }
-
-    if (keyCode === ENTER) {
-      // Code to run.
-    }
-  }
-
-  
- -

The parameter, event, is optional. keyPressed() - is always passed a - - KeyboardEvent - - object with properties that describe the key press event:

- -
function keyPressed(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

Browsers may have default behaviors attached to various key events. For - - example, some browsers may jump to the bottom of a web page when the - - SPACE key is pressed. To prevent any default behavior for this - event, add - - return false; to the end of the function.

-line: 284 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click on the canvas to begin detecting key presses. - - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square changes color when the user presses a key.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Toggle the background color when the user presses a key. - function keyPressed() { - if (value === 0) { - value = 255; - } else { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a white square at its center. The inner square turns black when the user presses the "b" key. It turns white when the user presses the "a" key.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Reassign value when the user presses the 'a' or 'b' key. - function keyPressed() { - if (key === 'a') { - value = 255; - } else if (key === 'b') { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square turns white when the user presses the left arrow key. It turns black when the user presses the right arrow key.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Toggle the background color when the user presses an arrow key. - function keyPressed() { - if (keyCode === LEFT_ARROW) { - value = 255; - } else if (keyCode === RIGHT_ARROW) { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
-class: p5 -params: - - name: event - description: | -

optional KeyboardEvent callback argument.

- type: KeyboardEvent - optional: true -chainable: false ---- - - -# keyPressed diff --git a/src/content/reference/en/p5 copy/keyReleased.mdx b/src/content/reference/en/p5 copy/keyReleased.mdx deleted file mode 100644 index e19da953f1..0000000000 --- a/src/content/reference/en/p5 copy/keyReleased.mdx +++ /dev/null @@ -1,188 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L474 -title: keyReleased -module: Events -submodule: Keyboard -file: src/events/keyboard.js -description: > -

A function that's called once when any key is released.

- -

Declaring the function keyReleased() sets a code block to run - once - - automatically when the user releases any key:

- -
function keyReleased() {
-    // Code to run.
-  }
-
-  
- -

The key and keyCode - - variables will be updated with the most recently released value when - - keyReleased() is called by p5.js:

- -
function keyReleased() {
-    if (key === 'c') {
-      // Code to run.
-    }
-
-    if (keyCode === ENTER) {
-      // Code to run.
-    }
-  }
-
-  
- -

The parameter, event, is optional. keyReleased() - is always passed a - - KeyboardEvent - - object with properties that describe the key press event:

- -
function keyReleased(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

Browsers may have default behaviors attached to various key events. To - - prevent any default behavior for this event, add return false; to - the end - - of the function.

-line: 474 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click on the canvas to begin detecting key presses. - - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square changes color when the user releases a key.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Toggle value when the user releases a key. - function keyReleased() { - if (value === 0) { - value = 255; - } else { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square becomes white when the user releases the "w" key.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Set value to 255 the user releases the 'w' key. - function keyReleased() { - if (key === 'w') { - value = 255; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square turns white when the user presses and releases the left arrow key. It turns black when the user presses and releases the right arrow key.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Toggle the background color when the user releases an arrow key. - function keyReleased() { - if (keyCode === LEFT_ARROW) { - value = 255; - } else if (keyCode === RIGHT_ARROW) { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
-class: p5 -params: - - name: event - description: | -

optional KeyboardEvent callback argument.

- type: KeyboardEvent - optional: true -chainable: false ---- - - -# keyReleased diff --git a/src/content/reference/en/p5 copy/keyTyped.mdx b/src/content/reference/en/p5 copy/keyTyped.mdx deleted file mode 100644 index a591db9e60..0000000000 --- a/src/content/reference/en/p5 copy/keyTyped.mdx +++ /dev/null @@ -1,170 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L655 -title: keyTyped -module: Events -submodule: Keyboard -file: src/events/keyboard.js -description: > -

A function that's called once when keys with printable characters are - pressed.

- -

Declaring the function keyTyped() sets a code block to run - once - - automatically when the user presses any key with a printable character such - - as a or 1. Modifier keys such as SHIFT, - CONTROL, and the arrow keys - - will be ignored:

- -
function keyTyped() {
-    // Code to run.
-  }
-
-  
- -

The key and keyCode - - variables will be updated with the most recently released value when - - keyTyped() is called by p5.js:

- -
function keyTyped() {
-    // Check for the "c" character using key.
-    if (key === 'c') {
-      // Code to run.
-    }
-
-    // Check for "c" using keyCode.
-    if (keyCode === 67) {
-      // Code to run.
-    }
-  }
-
-  
- -

The parameter, event, is optional. keyTyped() is - always passed a - - KeyboardEvent - - object with properties that describe the key press event:

- -
function keyReleased(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

Note: Use the keyPressed() function - and - - keyCode system variable to respond to - modifier - - keys such as ALT.

- -

Browsers may have default behaviors attached to various key events. To - - prevent any default behavior for this event, add return false; to - the end - - of the function.

-line: 655 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click on the canvas to begin detecting key presses. - // Note: Pressing special keys such as SPACE have no effect. - - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a white square at its center. The inner square changes color when the user presses a key.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Toggle the square's color when the user types a printable key. - function keyTyped() { - if (value === 0) { - value = 255; - } else { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a white square at its center. The inner square turns black when the user types the "b" key. It turns white when the user types the "a" key.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Reassign value when the user types the 'a' or 'b' key. - function keyTyped() { - if (key === 'a') { - value = 255; - } else if (key === 'b') { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
-class: p5 -params: - - name: event - description: | -

optional KeyboardEvent callback argument.

- type: KeyboardEvent - optional: true -chainable: false ---- - - -# keyTyped diff --git a/src/content/reference/en/p5 copy/lerp.mdx b/src/content/reference/en/p5 copy/lerp.mdx deleted file mode 100644 index 84c4b5bc7a..0000000000 --- a/src/content/reference/en/p5 copy/lerp.mdx +++ /dev/null @@ -1,122 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L332 -title: lerp -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Calculates a number between two numbers at a specific increment.

- -

The amt parameter is the amount to interpolate between the two - numbers. - - 0.0 is equal to the first number, 0.1 is very near the first number, 0.5 is - - half-way in between, and 1.0 is equal to the second number. The - lerp() - - function is convenient for creating motion along a straight path and for - - drawing dotted lines.

- -

If the value of amt is less than 0 or more than 1, - lerp() will return a - - number outside of the original interval. For example, calling - - lerp(0, 10, 1.5) will return 15.

-line: 332 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Declare variables for coordinates. - let a = 20; - let b = 80; - let c = lerp(a, b, 0.2); - let d = lerp(a, b, 0.5); - let e = lerp(a, b, 0.8); - - strokeWeight(5); - - // Draw the original points in black. - stroke(0); - point(a, 50); - point(b, 50); - - // Draw the lerped points in gray. - stroke(100); - point(c, 50); - point(d, 50); - point(e, 50); - - describe('Five points in a horizontal line. The outer points are black and the inner points are gray.'); - } - -
- -
- - let x = 50; - let y = 50; - let targetX = 50; - let targetY = 50; - - function setup() { - createCanvas(100, 100); - - background(200); - - describe('A white circle at the center of a gray canvas. The circle moves to where the user clicks, then moves smoothly back to the center.'); - } - - function draw() { - background(220); - - // Move x and y toward the target. - x = lerp(x, targetX, 0.05); - y = lerp(y, targetY, 0.05); - - // Draw the circle. - circle(x, y, 20); - } - - // Set x and y when the user clicks the mouse. - function mouseClicked() { - x = mouseX; - y = mouseY; - } - -
-class: p5 -params: - - name: start - description: | -

first value.

- type: Number - - name: stop - description: | -

second value.

- type: Number - - name: amt - description: | -

number.

- type: Number -return: - description: lerped value. - type: Number -chainable: false ---- - - -# lerp diff --git a/src/content/reference/en/p5 copy/lerpColor.mdx b/src/content/reference/en/p5 copy/lerpColor.mdx deleted file mode 100644 index d815ba9ddb..0000000000 --- a/src/content/reference/en/p5 copy/lerpColor.mdx +++ /dev/null @@ -1,96 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L949 -title: lerpColor -module: Color -submodule: Creating & Reading -file: src/color/creating_reading.js -description: > -

Blends two colors to find a third color between them.

- -

The amt parameter specifies the amount to interpolate between - the two - - values. 0 is equal to the first color, 0.1 is very near the first color, - - 0.5 is halfway between the two colors, and so on. Negative numbers are set - - to 0. Numbers greater than 1 are set to 1. This differs from the behavior of - - lerp. It's necessary because numbers outside - of the - - interval [0, 1] will produce strange and unexpected colors.

- -

The way that colors are interpolated depends on the current - - colorMode().

-line: 949 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create p5.Color objects to interpolate between. - let from = color(218, 165, 32); - let to = color(72, 61, 139); - - // Create intermediate colors. - let interA = lerpColor(from, to, 0.33); - let interB = lerpColor(from, to, 0.66); - - // Draw the left rectangle. - noStroke(); - fill(from); - rect(10, 20, 20, 60); - - // Draw the left-center rectangle. - fill(interA); - rect(30, 20, 20, 60); - - // Draw the right-center rectangle. - fill(interB); - rect(50, 20, 20, 60); - - // Draw the right rectangle. - fill(to); - rect(70, 20, 20, 60); - - describe( - 'Four rectangles. From left to right, the rectangles are tan, brown, brownish purple, and purple.' - ); - } - -
-class: p5 -params: - - name: c1 - description: > -

interpolate from this color (any value created by the color() - function).

- type: p5.Color - - name: c2 - description: > -

interpolate to this color (any value created by the color() - function).

- type: p5.Color - - name: amt - description: | -

number between 0 and 1.

- type: Number -return: - description: interpolated color. - type: p5.Color -chainable: false ---- - - -# lerpColor diff --git a/src/content/reference/en/p5 copy/let.mdx b/src/content/reference/en/p5 copy/let.mdx deleted file mode 100644 index f04902a9b0..0000000000 --- a/src/content/reference/en/p5 copy/let.mdx +++ /dev/null @@ -1,91 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L7 -title: let -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: > -

Declares a new variable.

- -

A variable is a container for a value. For example, a variable might - - contain a creature's x-coordinate as a Number or its name as a - - String. Variables can change value by reassigning them as - follows:

- -
// Declare the variable x and assign it the
-  value 10.
-
-  let x = 10;
-
-
-  // Reassign x to 50.
-
-  x = 50;
-
-  
- -

Variables have block scope. When a variable is declared between curly - - braces {}, it only exists within the block defined by those - braces. For - - example, the following code would throw a ReferenceError because - x is - - declared within the setup() function's block:

- -
function setup() {
-    createCanvas(100, 100);
-
-    let x = 50;
-  }
-
-
-  function draw() {
-    background(200);
-
-    // x was declared in setup(), so it can't be referenced here.
-    circle(x, 50, 20);
-  }
-
-  
- -

Variables declared outside of all curly braces {} are in the - global - - scope. A variable that's in the global scope can be used and changed - - anywhere in a sketch:

- -
let x = 50;
-
-
-  function setup() {
-    createCanvas(100, 100);
-  }
-
-
-  function draw() {
-    background(200);
-
-    // Change the value of x.
-    x += 10;
-
-    circle(x, 50, 20);
-  }
-
-  
-line: 7 -isConstructor: false -itemtype: property -example: - - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(220);\n\n // Style the text.\n textAlign(CENTER);\n textSize(16);\n\n // Create the message variable.\n let message = 'Hello, \U0001F30D!';\n\n // Display the message.\n text(message, 50, 50);\n\n describe('The text \"Hello, \U0001F30D!\" written on a gray background.');\n}\n\n
\n\n
\n\nlet x = 0;\n\nfunction setup() {\n createCanvas(100, 100);\n\n describe('A white circle moves from left to right against a gray background.');\n}\n\nfunction draw() {\n background(220);\n\n // Change the value of x.\n x += 1;\n\n circle(x, 50, 20);\n}\n\n
" -class: p5 ---- - - -# let diff --git a/src/content/reference/en/p5 copy/lightFalloff.mdx b/src/content/reference/en/p5 copy/lightFalloff.mdx deleted file mode 100644 index e8b8245064..0000000000 --- a/src/content/reference/en/p5 copy/lightFalloff.mdx +++ /dev/null @@ -1,100 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L1161 -title: lightFalloff -module: 3D -submodule: Lights -file: src/webgl/light.js -description: > -

Sets the falloff rate for pointLight() - - and spotLight().

- -

A light’s falloff describes the intensity of its beam at a distance. For - - example, a lantern has a slow falloff, a flashlight has a medium falloff, - - and a laser pointer has a sharp falloff.

- -

lightFalloff() has three parameters, constant, - linear, and - - quadratic. They’re numbers used to calculate falloff at a - distance, d, - - as follows:

- -

falloff = 1 / (constant + d * linear + (d * d) * - quadratic)

- -

Note: constant, linear, and - quadratic should always be set to values - - greater than 0.

-line: 1161 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click to change the falloff rate. - - let useFalloff = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A sphere drawn against a gray background. The intensity of the light changes when the user double-clicks.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Set the light falloff. - if (useFalloff === true) { - lightFalloff(2, 0, 0); - } - - // Add a white point light from the front. - pointLight(255, 255, 255, 0, 0, 100); - - // Style the sphere. - noStroke(); - - // Draw the sphere. - sphere(30); - } - - // Change the falloff value when the user double-clicks. - function doubleClicked() { - useFalloff = true; - } - -
-class: p5 -params: - - name: constant - description: | -

constant value for calculating falloff.

- type: Number - - name: linear - description: | -

linear value for calculating falloff.

- type: Number - - name: quadratic - description: | -

quadratic value for calculating falloff.

- type: Number -chainable: true ---- - - -# lightFalloff diff --git a/src/content/reference/en/p5 copy/lightness.mdx b/src/content/reference/en/p5 copy/lightness.mdx deleted file mode 100644 index 284523dcc8..0000000000 --- a/src/content/reference/en/p5 copy/lightness.mdx +++ /dev/null @@ -1,168 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L1134 -title: lightness -module: Color -submodule: Creating & Reading -file: src/color/creating_reading.js -description: > -

Gets the lightness value of a color.

- -

lightness() extracts the HSL lightness value from a - - p5.Color object, an array of color - components, or - - a CSS color string.

- -

By default, lightness() returns a color's HSL lightness in the - range 0 - - to 100. If the colorMode() is set to - HSL, it - - returns the lightness value in the given range.

-line: 1134 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(50); - - // Use HSL color. - colorMode(HSL); - - // Create a p5.Color object using HSL values. - let c = color(0, 100, 75); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'lightValue' to 75. - let lightValue = lightness(c); - - // Draw the right rectangle. - fill(lightValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is gray.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(50); - - // Use HSL color. - colorMode(HSL); - - // Create a color array. - let c = [0, 100, 75]; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'lightValue' to 75. - let lightValue = lightness(c); - - // Draw the right rectangle. - fill(lightValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is gray.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(50); - - // Use HSL color. - colorMode(HSL); - - // Create a CSS color string. - let c = 'rgb(255, 128, 128)'; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'lightValue' to 75. - let lightValue = lightness(c); - - // Draw the right rectangle. - fill(lightValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is gray.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(50); - - // Use HSL color with values in the range 0-255. - colorMode(HSL, 255); - - // Create a p5.Color object using HSL values. - let c = color(0, 255, 191.5); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'lightValue' to 191.5. - let lightValue = lightness(c); - - // Draw the right rectangle. - fill(lightValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is gray.'); - } - -
-class: p5 -params: - - name: color - description: | -

p5.Color object, array of - color components, or CSS color string.

- type: 'p5.Color|Number[]|String' -return: - description: the lightness value. - type: Number -chainable: false ---- - - -# lightness diff --git a/src/content/reference/en/p5 copy/lights.mdx b/src/content/reference/en/p5 copy/lights.mdx deleted file mode 100644 index a7cf3ba7ae..0000000000 --- a/src/content/reference/en/p5 copy/lights.mdx +++ /dev/null @@ -1,88 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L1077 -title: lights -module: 3D -submodule: Lights -file: src/webgl/light.js -description: | -

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.

-line: 1077 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click to turn on the lights. - - let isLit = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white box drawn against a gray background. The quality of the light changes when the user double-clicks.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Control the lights. - if (isLit === true) { - lights(); - } - - // Draw the box. - box(); - } - - // Turn on the lights when the user double-clicks. - function doubleClicked() { - isLit = true; - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white box drawn against a gray background.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - ambientLight(128, 128, 128); - directionalLight(128, 128, 128, 0, 0, -1); - - // Draw the box. - box(); - } - -
-class: p5 -chainable: true ---- - - -# lights diff --git a/src/content/reference/en/p5 copy/line.mdx b/src/content/reference/en/p5 copy/line.mdx deleted file mode 100644 index b225222235..0000000000 --- a/src/content/reference/en/p5 copy/line.mdx +++ /dev/null @@ -1,194 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L564 -title: line -module: Shape -submodule: 2D Primitives -file: src/core/shape/2d_primitives.js -description: > -

Draws a straight line between two points.

- -

A line's default width is one pixel. The version of line() - with four - - parameters draws the line in 2D. To color a line, use the - - stroke() function. To change its width, - use the - - strokeWeight() function. A line - - can't be filled, so the fill() function - won't - - affect the line's color.

- -

The version of line() with six parameters allows the line to - be drawn in - - 3D space. Doing so requires adding the WEBGL argument to - - createCanvas().

-line: 564 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - line(30, 20, 85, 75); - - describe( - 'A black line on a gray canvas running from top-center to bottom-right.' - ); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the line. - stroke('magenta'); - strokeWeight(5); - - line(30, 20, 85, 75); - - describe( - 'A thick, magenta line on a gray canvas running from top-center to bottom-right.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Top. - line(30, 20, 85, 20); - - // Right. - stroke(126); - line(85, 20, 85, 75); - - // Bottom. - stroke(255); - line(85, 75, 30, 75); - - describe( - 'Three lines drawn in grayscale on a gray canvas. They form the top, right, and bottom sides of a square.' - ); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - line(-20, -30, 35, 25); - - describe( - 'A black line on a gray canvas running from top-center to bottom-right.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A black line connecting two spheres. The scene spins slowly.'); - } - - function draw() { - background(200); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Draw a line. - line(0, 0, 0, 30, 20, -10); - - // Draw the center sphere. - sphere(10); - - // Translate to the second point. - translate(30, 20, -10); - - // Draw the bottom-right sphere. - sphere(10); - } - -
-class: p5 -overloads: - - line: 564 - params: - - name: x1 - description: | -

the x-coordinate of the first point.

- type: Number - - name: y1 - description: | -

the y-coordinate of the first point.

- type: Number - - name: x2 - description: | -

the x-coordinate of the second point.

- type: Number - - name: y2 - description: | -

the y-coordinate of the second point.

- type: Number - chainable: 1 - - line: 696 - params: - - name: x1 - description: '' - type: Number - - name: y1 - description: '' - type: Number - - name: z1 - description: | -

the z-coordinate of the first point.

- type: Number - - name: x2 - description: '' - type: Number - - name: y2 - description: '' - type: Number - - name: z2 - description: | -

the z-coordinate of the second point.

- type: Number - chainable: 1 -chainable: true ---- - - -# line diff --git a/src/content/reference/en/p5 copy/linePerspective.mdx b/src/content/reference/en/p5 copy/linePerspective.mdx deleted file mode 100644 index 80bf539c73..0000000000 --- a/src/content/reference/en/p5 copy/linePerspective.mdx +++ /dev/null @@ -1,164 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L280 -title: linePerspective -module: 3D -submodule: Camera -file: src/webgl/p5.Camera.js -description: > -

Enables or disables perspective for lines in 3D sketches.

- -

In WebGL mode, lines can be drawn with a thinner stroke when they’re - - further from the camera. Doing so gives them a more realistic appearance.

- -

By default, lines are drawn differently based on the type of perspective - - being used:

- -
    - -
  • perspective() and frustum() simulate a realistic - perspective. In - - these modes, stroke weight is affected by the line’s distance from the - - camera. Doing so results in a more natural appearance. - perspective() is - - the default mode for 3D sketches.
  • - -
  • ortho() doesn’t simulate a realistic perspective. In this - mode, stroke - - weights are consistent regardless of the line’s distance from the camera. - - Doing so results in a more predictable and consistent appearance.
  • - -
- -

linePerspective() can override the default line drawing - mode.

- -

The parameter, enable, is optional. It’s a - Boolean value that sets the - - way lines are drawn. If true is passed, as in - linePerspective(true), - - then lines will appear thinner when they are further from the camera. If - - false is passed, as in linePerspective(false), then - lines will have - - consistent stroke weights regardless of their distance from the camera. By - - default, linePerspective() is enabled.

- -

Calling linePerspective() without passing an argument returns - true if - - it's enabled and false if not.

- -

Note: linePerspective() can only be used in WebGL mode.

-line: 280 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Double-click the canvas to toggle the line perspective. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'A white cube with black edges on a gray background. Its edges toggle between thick and thin when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Translate the origin toward the camera. - translate(-10, 10, 600); - - // Rotate the coordinate system. - rotateY(-0.1); - rotateX(-0.1); - - // Draw the row of boxes. - for (let i = 0; i < 6; i += 1) { - translate(0, 0, -40); - box(10); - } - } - - // Toggle the line perspective when the user double-clicks. - function doubleClicked() { - let isEnabled = linePerspective(); - linePerspective(!isEnabled); - } - -
- -
- - // Double-click the canvas to toggle the line perspective. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'A row of cubes with black edges on a gray background. Their edges toggle between thick and thin when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Use an orthographic projection. - ortho(); - - // Translate the origin toward the camera. - translate(-10, 10, 600); - - // Rotate the coordinate system. - rotateY(-0.1); - rotateX(-0.1); - - // Draw the row of boxes. - for (let i = 0; i < 6; i += 1) { - translate(0, 0, -40); - box(10); - } - } - - // Toggle the line perspective when the user double-clicks. - function doubleClicked() { - let isEnabled = linePerspective(); - linePerspective(!isEnabled); - } - -
-class: p5 -overloads: - - line: 280 - params: - - name: enable - description: | -

whether to enable line perspective.

- type: Boolean - - line: 392 - params: [] - return: - description: whether line perspective is enabled. - type: Boolean -chainable: false ---- - - -# linePerspective diff --git a/src/content/reference/en/p5 copy/loadBytes.mdx b/src/content/reference/en/p5 copy/loadBytes.mdx deleted file mode 100644 index 8b02c0683e..0000000000 --- a/src/content/reference/en/p5 copy/loadBytes.mdx +++ /dev/null @@ -1,56 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L986 -title: loadBytes -module: IO -submodule: Input -file: src/io/files.js -description: | -

This method is suitable for fetching files up to size of 64MB.

-line: 986 -isConstructor: false -itemtype: method -example: - - |- - -
- let data; - - function preload() { - data = loadBytes('/assets/mammals.xml'); - } - - function setup() { - for (let i = 0; i < 5; i++) { - console.log(data.bytes[i].toString(16)); - } - describe('no image displayed'); - } -
-class: p5 -params: - - name: file - description: | -

name of the file or URL to load

- type: String - - name: callback - description: | -

function to be executed after loadBytes() - completes

- type: Function - optional: true - - name: errorCallback - description: | -

function to be executed if there - is an error

- type: Function - optional: true -return: - description: an object whose 'bytes' property will be the loaded buffer - type: Object -chainable: false ---- - - -# loadBytes diff --git a/src/content/reference/en/p5 copy/loadFont.mdx b/src/content/reference/en/p5 copy/loadFont.mdx deleted file mode 100644 index 86af4b7123..0000000000 --- a/src/content/reference/en/p5 copy/loadFont.mdx +++ /dev/null @@ -1,171 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/loading_displaying.js#L16 -title: loadFont -module: Typography -submodule: Loading & Displaying -file: src/typography/loading_displaying.js -description: > -

Loads a font and creates a p5.Font - object. - - loadFont() can load fonts in either .otf or .ttf format. Loaded - fonts can - - be used to style text on the canvas and in HTML elements.

- -

The first parameter, path, is the path to a font file. - - Paths to local files should be relative. For example, - - '/assets/inconsolata.otf'. The Inconsolata font used in the - following - - examples can be downloaded for free - - here. - - Paths to remote files should be URLs. For example, - - 'https://example.com/inconsolata.otf'. URLs may be blocked due to - browser - - security.

- -

The second parameter, successCallback, is optional. If a - function is - - passed, it will be called once the font has loaded. The callback function - - may use the new p5.Font object if - needed.

- -

The third parameter, failureCallback, is also optional. If a - function is - - passed, it will be called if the font fails to load. The callback function - - may use the error - - Event - - object if needed.

- -

Fonts can take time to load. Calling loadFont() in - - preload() ensures fonts load before - they're - - used in setup() or - - draw().

-line: 16 -isConstructor: false -itemtype: method -example: - - |- - - -
- - let font; - - function preload() { - font = loadFont('/assets/inconsolata.otf'); - } - - function setup() { - fill('deeppink'); - textFont(font); - textSize(36); - text('p5*js', 10, 50); - - describe('The text "p5*js" written in pink on a white background.'); - } - -
- -
- - function setup() { - loadFont('/assets/inconsolata.otf', font => { - fill('deeppink'); - textFont(font); - textSize(36); - text('p5*js', 10, 50); - - describe('The text "p5*js" written in pink on a white background.'); - }); - } - -
- -
- - function setup() { - loadFont('/assets/inconsolata.otf', success, failure); - } - - function success(font) { - fill('deeppink'); - textFont(font); - textSize(36); - text('p5*js', 10, 50); - - describe('The text "p5*js" written in pink on a white background.'); - } - - function failure(event) { - console.error('Oops!', event); - } - -
- -
- - function preload() { - loadFont('/assets/inconsolata.otf'); - } - - function setup() { - let p = createP('p5*js'); - p.style('color', 'deeppink'); - p.style('font-family', 'Inconsolata'); - p.style('font-size', '36px'); - p.position(10, 50); - - describe('The text "p5*js" written in pink on a white background.'); - } - -
-class: p5 -params: - - name: path - description: | -

path of the font to be loaded.

- type: String - - name: successCallback - description: | -

function called with the - p5.Font object after it - loads.

- type: Function - optional: true - - name: failureCallback - description: | -

function called with the error - Event - object if the font fails to load.

- type: Function - optional: true -return: - description: p5.Font object. - type: p5.Font -chainable: false ---- - - -# loadFont diff --git a/src/content/reference/en/p5 copy/loadImage.mdx b/src/content/reference/en/p5 copy/loadImage.mdx deleted file mode 100644 index 7e5b8bf0b7..0000000000 --- a/src/content/reference/en/p5 copy/loadImage.mdx +++ /dev/null @@ -1,137 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L18 -title: loadImage -module: Image -submodule: Loading & Displaying -file: src/image/loading_displaying.js -description: > -

Loads an image to create a p5.Image - object.

- -

loadImage() interprets the first parameter one of three ways. - If the path - - to an image file is provided, loadImage() will load it. Paths to - local - - files should be relative, such as '/assets/thundercat.jpg'. URLs - such as - - 'https://example.com/thundercat.jpg' may be blocked due to - browser - - security. Raw image data can also be passed as a base64 encoded image in - - the form 'data:image/png;base64,arandomsequenceofcharacters'.

- -

The second parameter is optional. If a function is passed, it will be - - called once the image has loaded. The callback function can optionally use - - the new p5.Image object.

- -

The third parameter is also optional. If a function is passed, it will be - - called if the image fails to load. The callback function can optionally use - - the event error.

- -

Images can take time to load. Calling loadImage() in - - preload() ensures images load before - they're - - used in setup() or draw().

-line: 18 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load the image and create a p5.Image object. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Draw the image. - image(img, 0, 0); - - describe('Image of the underside of a white umbrella and a gridded ceiling.'); - } - -
- -
- - function setup() { - // Call handleImage() once the image loads. - loadImage('/assets/laDefense.jpg', handleImage); - - describe('Image of the underside of a white umbrella and a gridded ceiling.'); - } - - // Display the image. - function handleImage(img) { - image(img, 0, 0); - } - -
- -
- - function setup() { - // Call handleImage() once the image loads or - // call handleError() if an error occurs. - loadImage('/assets/laDefense.jpg', handleImage, handleError); - } - - // Display the image. - function handleImage(img) { - image(img, 0, 0); - - describe('Image of the underside of a white umbrella and a gridded ceiling.'); - } - - // Log the error. - function handleError(event) { - console.error('Oops!', event); - } - -
-class: p5 -params: - - name: path - description: | -

path of the image to be loaded or base64 encoded image.

- type: String - - name: successCallback - description: | -

function called with - p5.Image once it - loads.

- type: function(p5.Image) - optional: true - - name: failureCallback - description: | -

function called with event - error if the image fails to load.

- type: Function(Event) - optional: true -return: - description: the p5.Image object. - type: p5.Image -chainable: false ---- - - -# loadImage diff --git a/src/content/reference/en/p5 copy/loadJSON.mdx b/src/content/reference/en/p5 copy/loadJSON.mdx deleted file mode 100644 index 95fd0552b5..0000000000 --- a/src/content/reference/en/p5 copy/loadJSON.mdx +++ /dev/null @@ -1,288 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L17 -title: loadJSON -module: IO -submodule: Input -file: src/io/files.js -description: > -

Loads a JSON file to create an Object.

- -

JavaScript Object Notation - - (JSON) - - is a standard format for sending data between applications. The format is - - based on JavaScript objects which have keys and values. JSON files store - - data in an object with strings as keys. Values can be strings, numbers, - - Booleans, arrays, null, or other objects.

- -

The first parameter, path, is always a string with the path to - the file. - - Paths to local files should be relative, as in - - loadJSON('/assets/data.json'). URLs such as - - 'https://example.com/data.json' may be blocked due to browser - security.

- -

The second parameter, successCallback, is optional. If a - function is - - passed, as in loadJSON('/assets/data.json', handleData), then the - - handleData() function will be called once the data loads. The - object - - created from the JSON data will be passed to handleData() as its - only argument.

- -

The third parameter, failureCallback, is also optional. If a - function is - - passed, as in loadJSON('/assets/data.json', handleData, - handleFailure), - - then the handleFailure() function will be called if an error - occurs while - - loading. The Error object will be passed to - handleFailure() as its only - - argument.

- -

Note: Data can take time to load. Calling loadJSON() within - - preload() ensures data loads before it's - used in - - setup() or draw().

-line: 17 -isConstructor: false -itemtype: method -example: - - |- - - -
- - let myData; - - // Load the JSON and create an object. - function preload() { - myData = loadJSON('/assets/data.json'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the circle. - fill(myData.color); - noStroke(); - - // Draw the circle. - circle(myData.x, myData.y, myData.d); - - describe('A pink circle on a gray background.'); - } - -
- -
- - let myData; - - // Load the JSON and create an object. - function preload() { - myData = loadJSON('/assets/data.json'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object and make it transparent. - let c = color(myData.color); - c.setAlpha(80); - - // Style the circles. - fill(c); - noStroke(); - - // Iterate over the myData.bubbles array. - for (let b of myData.bubbles) { - // Draw a circle for each bubble. - circle(b.x, b.y, b.d); - } - - describe('Several pink bubbles floating in a blue sky.'); - } - -
- -
- - let myData; - - // Load the GeoJSON and create an object. - function preload() { - myData = loadJSON('https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Get data about the most recent earthquake. - let quake = myData.features[0].properties; - - // Draw a circle based on the earthquake's magnitude. - circle(50, 50, quake.mag * 10); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(11); - - // Display the earthquake's location. - text(quake.place, 5, 80, 100); - - describe(`A white circle on a gray background. The text "${quake.place}" is written beneath the circle.`); - } - -
- -
- - let bigQuake; - - // Load the GeoJSON and preprocess it. - function preload() { - loadJSON( - 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson', - handleData - ); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw a circle based on the earthquake's magnitude. - circle(50, 50, bigQuake.mag * 10); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(11); - - // Display the earthquake's location. - text(bigQuake.place, 5, 80, 100); - - describe(`A white circle on a gray background. The text "${bigQuake.place}" is written beneath the circle.`); - } - - // Find the biggest recent earthquake. - function handleData(data) { - let maxMag = 0; - // Iterate over the earthquakes array. - for (let quake of data.features) { - // Reassign bigQuake if a larger - // magnitude quake is found. - if (quake.properties.mag > maxMag) { - bigQuake = quake.properties; - } - } - } - -
- -
- - let bigQuake; - - // Load the GeoJSON and preprocess it. - function preload() { - loadJSON( - 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson', - handleData, - handleError - ); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw a circle based on the earthquake's magnitude. - circle(50, 50, bigQuake.mag * 10); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(11); - - // Display the earthquake's location. - text(bigQuake.place, 5, 80, 100); - - describe(`A white circle on a gray background. The text "${bigQuake.place}" is written beneath the circle.`); - } - - // Find the biggest recent earthquake. - function handleData(data) { - let maxMag = 0; - // Iterate over the earthquakes array. - for (let quake of data.features) { - // Reassign bigQuake if a larger - // magnitude quake is found. - if (quake.properties.mag > maxMag) { - bigQuake = quake.properties; - } - } - } - - // Log any errors to the console. - function handleError(error) { - console.log('Oops!', error); - } - -
-class: p5 -params: - - name: path - description: | -

path of the JSON file to be loaded.

- type: String - - name: successCallback - description: > -

function to call once the data is loaded. Will be passed the - object.

- type: Function - optional: true - - name: errorCallback - description: > -

function to call if the data fails to load. Will be passed an - Error event object.

- type: Function - optional: true -return: - description: object containing the loaded data. - type: Object -chainable: false ---- - - -# loadJSON diff --git a/src/content/reference/en/p5 copy/loadModel.mdx b/src/content/reference/en/p5 copy/loadModel.mdx deleted file mode 100644 index 56b2230e1e..0000000000 --- a/src/content/reference/en/p5 copy/loadModel.mdx +++ /dev/null @@ -1,469 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/loading.js#L13 -title: loadModel -module: Shape -submodule: 3D Models -file: src/webgl/loading.js -description: > -

Loads a 3D model to create a - - p5.Geometry object.

- -

loadModel() can load 3D models from OBJ and STL files. Once - the model is - - loaded, it can be displayed with the - - model() function, as in - model(shape).

- -

There are three ways to call loadModel() with optional - parameters to help - - process the model.

- -

The first parameter, path, is always a String - with the path to the - - file. Paths to local files should be relative, as in - - loadModel('/assets/model.obj'). URLs such as - - 'https://example.com/model.obj' may be blocked due to browser - security.

- -

Note: When loading a .obj file that references materials - stored in - - .mtl files, p5.js will attempt to load and apply those materials. - - To ensure that the .obj file reads the .mtl file - correctly include the - - .mtl file alongside it.

- -

The first way to call loadModel() has three optional - parameters after the - - file path. The first optional parameter, successCallback, is a - function - - to call once the model loads. For example, - - loadModel('/assets/model.obj', handleModel) will call the - handleModel() - - function once the model loads. The second optional parameter, - - failureCallback, is a function to call if the model fails to - load. For - - example, loadModel('/assets/model.obj', handleModel, - handleFailure) will - - call the handleFailure() function if an error occurs while - loading. The - - third optional parameter, fileType, is the model’s file extension - as a - - string. For example, - - loadModel('/assets/model', handleModel, handleFailure, '.obj') - will try to - - load the file model as a .obj file.

- -

The second way to call loadModel() has four optional - parameters after the - - file path. The first optional parameter is a Boolean value. If - true is - - passed, as in loadModel('/assets/model.obj', true), then the - model will be - - resized to ensure it fits the canvas. The next three parameters are - - successCallback, failureCallback, and - fileType as described above.

- -

The third way to call loadModel() has one optional parameter - after the - - file path. The optional parameter, options, is an - Object with options, - - as in loadModel('/assets/model.obj', options). The - options object can - - have the following properties:

- -
let options = {
-    // Enables standardized size scaling during loading if set to true.
-    normalize: true,
-
-    // Function to call once the model loads.
-    successCallback: handleModel,
-
-    // Function to call if an error occurs while loading.
-    failureCallback: handleError,
-
-    // Model's file extension.
-    fileType: '.stl',
-
-    // Flips the U texture coordinates of the model.
-    flipU: false,
-
-    // Flips the V texture coordinates of the model.
-    flipV: false
-  };
-
-
-  // Pass the options object to loadModel().
-
-  loadModel('/assets/model.obj', options);
-
-  
- -

Models can take time to load. Calling loadModel() in - - preload() ensures models load before - they're - - used in setup() or draw().

- -

Note: There’s no support for colored STL files. STL files with color will - - be rendered without color.

-line: 13 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - // Load the file and create a p5.Geometry object. - function preload() { - shape = loadModel('/assets/teapot.obj'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white teapot drawn against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the shape. - model(shape); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - // Load the file and create a p5.Geometry object. - // Normalize the geometry's size to fit the canvas. - function preload() { - shape = loadModel('/assets/teapot.obj', true); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white teapot drawn against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the shape. - model(shape); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - // Load the file and create a p5.Geometry object. - function preload() { - loadModel('/assets/teapot.obj', true, handleModel); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white teapot drawn against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the shape. - model(shape); - } - - // Set the shape variable and log the geometry's - // ID to the console. - function handleModel(data) { - shape = data; - console.log(shape.gid); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - // Load the file and create a p5.Geometry object. - function preload() { - loadModel('/assets/wrong.obj', true, handleModel, handleError); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white teapot drawn against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the shape. - model(shape); - } - - // Set the shape variable and print the geometry's - // ID to the console. - function handleModel(data) { - shape = data; - console.log(shape.gid); - } - - // Print an error message if the file doesn't load. - function handleError(error) { - console.error('Oops!', error); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - // Load the file and create a p5.Geometry object. - function preload() { - loadModel('/assets/teapot.obj', true, handleModel, handleError, '.obj'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white teapot drawn against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the shape. - model(shape); - } - - // Set the shape variable and print the geometry's - // ID to the console. - function handleModel(data) { - shape = data; - console.log(shape.gid); - } - - // Print an error message if the file doesn't load. - function handleError(error) { - console.error('Oops!', error); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - let options = { - normalize: true, - successCallback: handleModel, - failureCallback: handleError, - fileType: '.obj' - }; - - // Load the file and create a p5.Geometry object. - function preload() { - loadModel('/assets/teapot.obj', options); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white teapot drawn against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the shape. - model(shape); - } - - // Set the shape variable and print the geometry's - // ID to the console. - function handleModel(data) { - shape = data; - console.log(shape.gid); - } - - // Print an error message if the file doesn't load. - function handleError(error) { - console.error('Oops!', error); - } - -
-class: p5 -return: - description: the p5.Geometry object - type: p5.Geometry -overloads: - - line: 13 - params: - - name: path - description: | -

path of the model to be loaded.

- type: String - - name: normalize - description: | -

if true, scale the model to fit the canvas.

- type: Boolean - - name: successCallback - description: | -

function to call once the model is loaded. Will be passed - the p5.Geometry object.

- type: function(p5.Geometry) - optional: true - - name: failureCallback - description: > -

function to call if the model fails to load. Will be passed an - Error event object.

- type: Function(Event) - optional: true - - name: fileType - description: > -

model’s file extension. Either '.obj' or - '.stl'.

- type: String - optional: true - return: - description: the p5.Geometry object - type: p5.Geometry - - line: 324 - params: - - name: path - description: '' - type: String - - name: successCallback - description: '' - type: function(p5.Geometry) - optional: true - - name: failureCallback - description: '' - type: Function(Event) - optional: true - - name: fileType - description: '' - type: String - optional: true - return: - description: new p5.Geometry object. - type: p5.Geometry - - line: 332 - params: - - name: path - description: '' - type: String - - name: options - description: | -

loading options.

- type: Object - optional: true - props: - - name: successCallback - description: '' - type: function(p5.Geometry) - optional: true - - name: failureCallback - description: '' - type: Function(Event) - optional: true - - name: fileType - description: '' - type: String - optional: true - - name: normalize - description: '' - type: Boolean - optional: true - - name: flipU - description: '' - type: Boolean - optional: true - - name: flipV - description: '' - type: Boolean - optional: true - return: - description: new p5.Geometry object. - type: p5.Geometry -chainable: false ---- - - -# loadModel diff --git a/src/content/reference/en/p5 copy/loadPixels.mdx b/src/content/reference/en/p5 copy/loadPixels.mdx deleted file mode 100644 index 424a87765f..0000000000 --- a/src/content/reference/en/p5 copy/loadPixels.mdx +++ /dev/null @@ -1,61 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L946 -title: loadPixels -module: Image -submodule: Pixels -file: src/image/pixels.js -description: | -

Loads the current value of each pixel on the canvas into the - pixels array.

-

loadPixels() must be called before reading from or writing to - pixels.

-line: 946 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/rockies.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0, 100, 100); - - // Get the pixel density. - let d = pixelDensity(); - - // Calculate the halfway index in the pixels array. - let halfImage = 4 * (d * width) * (d * height / 2); - - // Load the pixels array. - loadPixels(); - - // Copy the top half of the canvas to the bottom. - for (let i = 0; i < halfImage; i += 1) { - pixels[i + halfImage] = pixels[i]; - } - - // Update the canvas. - updatePixels(); - - describe('Two identical images of mountain landscapes, one on top of the other.'); - } - -
-class: p5 -chainable: false ---- - - -# loadPixels diff --git a/src/content/reference/en/p5 copy/loadShader.mdx b/src/content/reference/en/p5 copy/loadShader.mdx deleted file mode 100644 index 1180e6c487..0000000000 --- a/src/content/reference/en/p5 copy/loadShader.mdx +++ /dev/null @@ -1,172 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L12 -title: loadShader -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Loads vertex and fragment shaders to create a - - p5.Shader object.

- -

Shaders are programs that run on the graphics processing unit (GPU). They - - can process many pixels at the same time, making them fast for many - - graphics tasks. They’re written in a language called - - GLSL - - and run along with the rest of the code in a sketch.

- -

Once the p5.Shader object is created, - it can be - - used with the shader() function, as in - - shader(myShader). A shader program consists of two files, a - vertex shader - - and a fragment shader. The vertex shader affects where 3D geometry is drawn - - on the screen and the fragment shader affects color.

- -

loadShader() loads the vertex and fragment shaders from their - .vert and - - .frag files. For example, calling - - loadShader('/assets/shader.vert', '/assets/shader.frag') loads - both - - required shaders and returns a p5.Shader - object.

- -

The third parameter, successCallback, is optional. If a - function is - - passed, it will be called once the shader has loaded. The callback function - - can use the new p5.Shader object as its - - parameter.

- -

The fourth parameter, failureCallback, is also optional. If a - function is - - passed, it will be called if the shader fails to load. The callback - - function can use the event error as its parameter.

- -

Shaders can take time to load. Calling loadShader() in - - preload() ensures shaders load before - they're - - used in setup() or draw().

- -

Note: Shaders can only be used in WebGL mode.

-line: 12 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Note: A "uniform" is a global variable within a shader program. - - let mandelbrot; - - // Load the shader and create a p5.Shader object. - function preload() { - mandelbrot = loadShader('/assets/shader.vert', '/assets/shader.frag'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - // Compile and apply the p5.Shader object. - shader(mandelbrot); - - // Set the shader uniform p to an array. - mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); - - // Set the shader uniform r to the value 1.5. - mandelbrot.setUniform('r', 1.5); - - // Add a quad as a display surface for the shader. - quad(-1, -1, 1, -1, 1, 1, -1, 1); - - describe('A black fractal image on a magenta background.'); - } - -
- -
- - // Note: A "uniform" is a global variable within a shader program. - - let mandelbrot; - - // Load the shader and create a p5.Shader object. - function preload() { - mandelbrot = loadShader('/assets/shader.vert', '/assets/shader.frag'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - // Use the p5.Shader object. - shader(mandelbrot); - - // Set the shader uniform p to an array. - mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); - - describe('A fractal image zooms in and out of focus.'); - } - - function draw() { - // Set the shader uniform r to a value that oscillates between 0 and 2. - mandelbrot.setUniform('r', sin(frameCount * 0.01) + 1); - - // Add a quad as a display surface for the shader. - quad(-1, -1, 1, -1, 1, 1, -1, 1); - } - -
-class: p5 -params: - - name: vertFilename - description: | -

path of the vertex shader to be loaded.

- type: String - - name: fragFilename - description: | -

path of the fragment shader to be loaded.

- type: String - - name: successCallback - description: | -

function to call once the shader is loaded. Can be passed the - p5.Shader object.

- type: Function - optional: true - - name: failureCallback - description: | -

function to call if the shader fails to load. Can be passed an - Error event object.

- type: Function - optional: true -return: - description: new shader created from the vertex and fragment shader files. - type: p5.Shader -chainable: false ---- - - -# loadShader diff --git a/src/content/reference/en/p5 copy/loadSound.mdx b/src/content/reference/en/p5 copy/loadSound.mdx deleted file mode 100644 index be9dd1ac29..0000000000 --- a/src/content/reference/en/p5 copy/loadSound.mdx +++ /dev/null @@ -1,78 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L2946 -title: loadSound -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: | -

loadSound() returns a new p5.SoundFile from a specified - path. If called during preload(), the p5.SoundFile will be ready - to play in time for setup() and draw(). If called outside of - preload, the p5.SoundFile will not be ready immediately, so - loadSound accepts a callback as the second parameter. Using a - - local server is recommended when loading external files.

-line: 2946 -isConstructor: false -itemtype: method -example: - - |- - -
- let mySound; - function preload() { - soundFormats('mp3', 'ogg'); - mySound = loadSound('/assets/doorbell'); - } - - function setup() { - let cnv = createCanvas(100, 100); - cnv.mousePressed(canvasPressed); - background(220); - text('tap here to play', 10, 20); - } - - function canvasPressed() { - // playing a sound file on a user gesture - // is equivalent to `userStartAudio()` - mySound.play(); - } -
-class: p5 -params: - - name: path - description: | -

Path to the sound file, or an array with - paths to soundfiles in multiple formats - i.e. ['sound.ogg', 'sound.mp3']. - Alternately, accepts an object: either - from the HTML5 File API, or a p5.File.

- type: String|Array - - name: successCallback - description: | -

Name of a function to call once file loads

- type: Function - optional: true - - name: errorCallback - description: | -

Name of a function to call if there is - an error loading the file.

- type: Function - optional: true - - name: whileLoading - description: | -

Name of a function to call while file is loading. - This function will receive the percentage loaded - so far, from 0.0 to 1.0.

- type: Function - optional: true -return: - description: Returns a p5.SoundFile - type: SoundFile -chainable: false ---- - - -# loadSound diff --git a/src/content/reference/en/p5 copy/loadStrings.mdx b/src/content/reference/en/p5 copy/loadStrings.mdx deleted file mode 100644 index ce011835bc..0000000000 --- a/src/content/reference/en/p5 copy/loadStrings.mdx +++ /dev/null @@ -1,188 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L309 -title: loadStrings -module: IO -submodule: Input -file: src/io/files.js -description: > -

Loads a text file to create an Array.

- -

The first parameter, path, is always a string with the path to - the file. - - Paths to local files should be relative, as in - - loadStrings('/assets/data.txt'). URLs such as - - 'https://example.com/data.txt' may be blocked due to browser - security.

- -

The second parameter, successCallback, is optional. If a - function is - - passed, as in loadStrings('/assets/data.txt', handleData), then - the - - handleData() function will be called once the data loads. The - array - - created from the text data will be passed to handleData() as its - only - - argument.

- -

The third parameter, failureCallback, is also optional. If a - function is - - passed, as in loadStrings('/assets/data.txt', handleData, - handleFailure), - - then the handleFailure() function will be called if an error - occurs while - - loading. The Error object will be passed to - handleFailure() as its only - - argument.

- -

Note: Data can take time to load. Calling loadStrings() within - - preload() ensures data loads before it's - used in - - setup() or draw().

-line: 309 -isConstructor: false -itemtype: method -example: - - |- - - -
- - let myData; - - // Load the text and create an array. - function preload() { - myData = loadStrings('/assets/test.txt'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Select a random line from the text. - let phrase = random(myData); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(12); - - // Display the text. - text(phrase, 10, 50, 90); - - describe(`The text "${phrase}" written in black on a gray background.`); - } - -
- -
- - let lastLine; - - // Load the text and preprocess it. - function preload() { - loadStrings('/assets/test.txt', handleData); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(12); - - // Display the text. - text(lastLine, 10, 50, 90); - - describe('The text "I talk like an orange" written in black on a gray background.'); - } - - // Select the last line from the text. - function handleData(data) { - lastLine = data[data.length - 1]; - } - -
- -
- - let lastLine; - - // Load the text and preprocess it. - function preload() { - loadStrings('/assets/test.txt', handleData, handleError); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(12); - - // Display the text. - text(lastLine, 10, 50, 90); - - describe('The text "I talk like an orange" written in black on a gray background.'); - } - - // Select the last line from the text. - function handleData(data) { - lastLine = data[data.length - 1]; - } - - // Log any errors to the console. - function handleError(error) { - console.error('Oops!', error); - } - -
-class: p5 -params: - - name: path - description: | -

path of the text file to be loaded.

- type: String - - name: successCallback - description: | -

function to call once the data is - loaded. Will be passed the array.

- type: Function - optional: true - - name: errorCallback - description: | -

function to call if the data fails to - load. Will be passed an Error event - object.

- type: Function - optional: true -return: - description: new array containing the loaded text. - type: 'String[]' -chainable: false ---- - - -# loadStrings diff --git a/src/content/reference/en/p5 copy/loadTable.mdx b/src/content/reference/en/p5 copy/loadTable.mdx deleted file mode 100644 index d93e40a3da..0000000000 --- a/src/content/reference/en/p5 copy/loadTable.mdx +++ /dev/null @@ -1,124 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L505 -title: loadTable -module: IO -submodule: Input -file: src/io/files.js -description: > -

Reads the contents of a file or URL and creates a p5.Table object with - - its values. If a file is specified, it must be located in the sketch's - - "data" folder. The filename parameter can also be a URL to a file found - - online. By default, the file is assumed to be comma-separated (in CSV - - format). Table only looks for a header row if the 'header' option is - - included.

- -

This method is asynchronous, meaning it may not finish before the next - - line in your sketch is executed. Calling loadTable() inside preload() - - guarantees to complete the operation before setup() and draw() are called. - - Outside of preload(), you may supply a - callback function to handle the - - object:

- -

All files loaded and saved use UTF-8 encoding. This method is suitable for - fetching files up to size of 64MB.

-line: 505 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Given the following CSV file called "mammals.csv" - // located in the project's "assets" folder: - // - // id,species,name - // 0,Capra hircus,Goat - // 1,Panthera pardus,Leopard - // 2,Equus zebra,Zebra - - let table; - - function preload() { - //my table is comma separated value "csv" - //and has a header specifying the columns labels - table = loadTable('/assets/mammals.csv', 'csv', 'header'); - //the file can be remote - //table = loadTable("https://p5js.org/reference//assets/mammals.csv", - // "csv", "header"); - } - - function setup() { - //count the columns - print(table.getRowCount() + ' total rows in table'); - print(table.getColumnCount() + ' total columns in table'); - - print(table.getColumn('name')); - //["Goat", "Leopard", "Zebra"] - - //cycle through the table - for (let r = 0; r < table.getRowCount(); r++) - 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"`); - } - -
-class: p5 -params: - - name: filename - description: | -

name of the file or URL to load

- type: String - - name: extension - description: | -

parse the table by comma-separated values "csv", semicolon-separated - values "ssv", or tab-separated values "tsv"

- type: String - optional: true - - name: header - description: | -

"header" to indicate table has header row

- type: String - optional: true - - name: callback - description: | -

function to be executed after - loadTable() completes. On success, the - Table object is passed in as the - first argument.

- type: Function - optional: true - - name: errorCallback - description: | -

function to be executed if - there is an error, response is passed - in as first argument

- type: Function - optional: true -return: - description: Table object containing data - type: Object -chainable: false ---- - - -# loadTable diff --git a/src/content/reference/en/p5 copy/loadXML.mdx b/src/content/reference/en/p5 copy/loadXML.mdx deleted file mode 100644 index 859a3c895d..0000000000 --- a/src/content/reference/en/p5 copy/loadXML.mdx +++ /dev/null @@ -1,220 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L780 -title: loadXML -module: IO -submodule: Input -file: src/io/files.js -description: > -

Loads an XML file to create a p5.XML - object.

- -

Extensible Markup Language - - (XML) - - is a standard format for sending data between applications. Like HTML, the - - XML format is based on tags and attributes, as in - - .

- -

The first parameter, path, is always a string with the path to - the file. - - Paths to local files should be relative, as in - - loadXML('/assets/data.xml'). URLs such as - 'https://example.com/data.xml' - - may be blocked due to browser security.

- -

The second parameter, successCallback, is optional. If a - function is - - passed, as in loadXML('/assets/data.xml', handleData), then the - - handleData() function will be called once the data loads. The - - p5.XML object created from the data will be - passed - - to handleData() as its only argument.

- -

The third parameter, failureCallback, is also optional. If a - function is - - passed, as in loadXML('/assets/data.xml', handleData, - handleFailure), then - - the handleFailure() function will be called if an error occurs - while - - loading. The Error object will be passed to - handleFailure() as its only - - argument.

- -

Note: Data can take time to load. Calling loadXML() within - - preload() ensures data loads before it's - used in - - setup() or draw().

-line: 780 -isConstructor: false -itemtype: method -example: - - |- - -
- - let myXML; - - // Load the XML and create a p5.XML object. - function preload() { - myXML = loadXML('/assets/animals.xml'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Get an array with all mammal tags. - let mammals = myXML.getChildren('mammal'); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(14); - - // Iterate over the mammals array. - for (let i = 0; i < mammals.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 25; - - // Get the mammal's common name. - let name = mammals[i].getContent(); - - // Display the mammal's name. - text(name, 20, y); - } - - describe( - 'The words "Goat", "Leopard", and "Zebra" written on three separate lines. The text is black on a gray background.' - ); - } - -
- -
- - let lastMammal; - - // Load the XML and create a p5.XML object. - function preload() { - loadXML('/assets/animals.xml', handleData); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(CENTER, CENTER); - textFont('Courier New'); - textSize(16); - - // Display the content of the last mammal element. - text(lastMammal, 50, 50); - - describe('The word "Zebra" written in black on a gray background.'); - } - - // Get the content of the last mammal element. - function handleData(data) { - // Get an array with all mammal elements. - let mammals = data.getChildren('mammal'); - - // Get the content of the last mammal. - lastMammal = mammals[mammals.length - 1].getContent(); - } - -
- -
- - let lastMammal; - - // Load the XML and preprocess it. - function preload() { - loadXML('/assets/animals.xml', handleData, handleError); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(CENTER, CENTER); - textFont('Courier New'); - textSize(16); - - // Display the content of the last mammal element. - text(lastMammal, 50, 50); - - describe('The word "Zebra" written in black on a gray background.'); - } - - // Get the content of the last mammal element. - function handleData(data) { - // Get an array with all mammal elements. - let mammals = data.getChildren('mammal'); - - // Get the content of the last mammal. - lastMammal = mammals[mammals.length - 1].getContent(); - } - - // Log any errors to the console. - function handleError(error) { - console.error('Oops!', error); - } - -
-class: p5 -params: - - name: path - description: | -

path of the XML file to be loaded.

- type: String - - name: successCallback - description: | -

function to call once the data is - loaded. Will be passed the - p5.XML object.

- type: Function - optional: true - - name: errorCallback - description: | -

function to call if the data fails to - load. Will be passed an Error event - object.

- type: Function - optional: true -return: - description: |- - XML data loaded into a p5.XML - object. - type: p5.XML -chainable: false ---- - - -# loadXML diff --git a/src/content/reference/en/p5 copy/log.mdx b/src/content/reference/en/p5 copy/log.mdx deleted file mode 100644 index c84c6d5a4b..0000000000 --- a/src/content/reference/en/p5 copy/log.mdx +++ /dev/null @@ -1,79 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L423 -title: log -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Calculates the natural logarithm (the base-e logarithm) of a number.

- -

log() expects the n parameter to be a value - greater than 0 because - - the natural logarithm is defined that way.

-line: 423 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Top-left. - let d = log(50); - circle(33, 33, d); - - // Bottom-right. - d = log(500000000); - circle(67, 67, d); - - describe('Two white circles. The circle at the top-left is small. The circle at the bottom-right is about five times larger.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - describe('A series of black dots that get higher slowly from left to right.'); - } - - function draw() { - // Invert the y-axis. - scale(1, -1); - translate(0, -100); - - // Calculate coordinates. - let x = frameCount; - let y = 15 * log(x); - - // Draw a point. - point(x, y); - } - -
-class: p5 -params: - - name: 'n' - description: | -

number greater than 0.

- type: Number -return: - description: natural logarithm of n. - type: Number -chainable: false ---- - - -# log diff --git a/src/content/reference/en/p5 copy/loop.mdx b/src/content/reference/en/p5 copy/loop.mdx deleted file mode 100644 index a73432d2c1..0000000000 --- a/src/content/reference/en/p5 copy/loop.mdx +++ /dev/null @@ -1,111 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L127 -title: loop -module: Structure -submodule: Structure -file: src/core/structure.js -description: > -

Resumes the draw loop after noLoop() - has been - - called.

- -

By default, draw() tries to run 60 times - per - - second. Calling noLoop() stops - - draw() from repeating. The draw loop can be - - restarted by calling loop().

- -

The isLooping() function can be used - to check - - whether a sketch is looping, as in isLooping() === true.

-line: 127 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Turn off the draw loop. - noLoop(); - - describe( - 'A white half-circle on the left edge of a gray square. The circle starts moving to the right when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Calculate the circle's x-coordinate. - let x = frameCount; - - // Draw the circle. - circle(x, 50, 20); - } - - // Resume the draw loop when the user double-clicks. - function doubleClicked() { - loop(); - } - -
- -
- - let startButton; - let stopButton; - - function setup() { - createCanvas(100, 100); - - // Create the button elements and place them - // beneath the canvas. - startButton = createButton('▶'); - startButton.position(0, 100); - startButton.size(50, 20); - stopButton = createButton('◾'); - stopButton.position(50, 100); - stopButton.size(50, 20); - - // Set functions to call when the buttons are pressed. - startButton.mousePressed(loop); - stopButton.mousePressed(noLoop); - - // Slow the frame rate. - frameRate(5); - - describe( - 'A white circle moves randomly on a gray background. Play and stop buttons are shown beneath the canvas. The circle stops or starts moving when the user presses a button.' - ); - } - - function draw() { - background(200); - - // Calculate the circle's coordinates. - let x = random(0, 100); - let y = random(0, 100); - - // Draw the circle. - // Normally, the circle would move from left to right. - circle(x, y, 20); - } - -
-class: p5 -chainable: false ---- - - -# loop diff --git a/src/content/reference/en/p5 copy/mag.mdx b/src/content/reference/en/p5 copy/mag.mdx deleted file mode 100644 index 4d46565b07..0000000000 --- a/src/content/reference/en/p5 copy/mag.mdx +++ /dev/null @@ -1,84 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L481 -title: mag -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Calculates the magnitude, or length, of a vector.

- -

A vector can be thought of in different ways. In one view, a vector is a - - point in space. The vector's components, x and y, - are the point's - - coordinates (x, y). A vector's magnitude is the distance from the - origin - - (0, 0) to (x, y). mag(x, y) is a - shortcut for calling - - dist(0, 0, x, y).

- -

A vector can also be thought of as an arrow pointing in space. This view is - - helpful for programming motion. See p5.Vector for - - more details.

- -

Use p5.Vector.mag() to calculate - the - - magnitude of a p5.Vector object.

-line: 481 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Set the vector's components. - let x = 30; - let y = 40; - - // Calculate the magnitude. - let m = mag(x, y); - - // Style the text. - textSize(16); - - // Display the vector and its magnitude. - line(0, 0, x, y); - text(m, x, y); - - describe('A diagonal line is drawn from the top left of the canvas. The number 50 is written at the end of the line.'); - } - -
-class: p5 -params: - - name: x - description: | -

first component.

- type: Number - - name: 'y' - description: | -

second component.

- type: Number -return: - description: magnitude of vector. - type: Number -chainable: false ---- - - -# mag diff --git a/src/content/reference/en/p5 copy/map.mdx b/src/content/reference/en/p5 copy/map.mdx deleted file mode 100644 index a94e6e4dd7..0000000000 --- a/src/content/reference/en/p5 copy/map.mdx +++ /dev/null @@ -1,119 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L534 -title: map -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Re-maps a number from one range to another.

- -

For example, calling map(2, 0, 10, 0, 100) returns 20. The - first three - - arguments set the original value to 2 and the original range from 0 to 10. - - The last two arguments set the target range from 0 to 100. 20's position - - in the target range [0, 100] is proportional to 2's position in the - - original range [0, 10].

- -

The sixth parameter, withinBounds, is optional. By default, - map() can - - return values outside of the target range. For example, - - map(11, 0, 10, 0, 100) returns 110. Passing true as - the sixth parameter - - constrains the remapped value to the target range. For example, - - map(11, 0, 10, 0, 100, true) returns 100.

-line: 534 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('Two horizontal lines. The top line grows horizontally as the mouse moves to the right. The bottom line also grows horizontally but is scaled to stay on the left half of the canvas.'); - } - - function draw() { - background(200); - - // Draw the top line. - line(0, 25, mouseX, 25); - - // Remap mouseX from [0, 100] to [0, 50]. - let x = map(mouseX, 0, 100, 0, 50); - - // Draw the bottom line. - line(0, 75, x, 75); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A circle changes color from black to white as the mouse moves from left to right.'); - } - - function draw() { - background(200); - - // Remap mouseX from [0, 100] to [0, 255] - let c = map(mouseX, 0, 100, 0, 255); - - // Style the circle. - fill(c); - - // Draw the circle. - circle(50, 50, 20); - } - -
-class: p5 -params: - - name: value - description: | -

the value to be remapped.

- type: Number - - name: start1 - description: | -

lower bound of the value's current range.

- type: Number - - name: stop1 - description: | -

upper bound of the value's current range.

- type: Number - - name: start2 - description: | -

lower bound of the value's target range.

- type: Number - - name: stop2 - description: | -

upper bound of the value's target range.

- type: Number - - name: withinBounds - description: | -

constrain the value to the newly mapped range.

- type: Boolean - optional: true -return: - description: remapped number. - type: Number -chainable: false ---- - - -# map diff --git a/src/content/reference/en/p5 copy/match.mdx b/src/content/reference/en/p5 copy/match.mdx deleted file mode 100644 index c93425e96d..0000000000 --- a/src/content/reference/en/p5 copy/match.mdx +++ /dev/null @@ -1,91 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L60 -title: match -module: Data -submodule: String Functions -file: src/utilities/string_functions.js -description: > -

Applies a regular expression to a string and returns an array with the - - first match.

- -

match() uses regular expressions (regex) to match patterns in - text. For - - example, the regex abc can be used to search a string for the - exact - - sequence of characters abc. See - - MDN. - - for more information about regexes.

- -

The first parameter, str, is the string to search.

- -

The second parameter, regex, is a string with the regular - expression to - - apply. For example, calling match('Hello, p5*js!', '[a-z][0-9]') - would - - return the array ['p5'].

- -

Note: If no matches are found, null is returned.

-line: 60 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let string = 'Hello, p5*js!'; - - // Match the characters that are lowercase - // letters followed by digits. - let matches = match(string, '[a-z][0-9]'); - - // Print the matches array to the console: - // ['p5'] - print(matches); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the matches. - text(matches, 50, 50); - - describe('The text "p5" written in black on a gray canvas.'); - } - -
-class: p5 -params: - - name: str - description: | -

string to search.

- type: String - - name: regexp - description: | -

regular expression to match.

- type: String -return: - description: match if found. - type: 'String[]' -chainable: false ---- - - -# match diff --git a/src/content/reference/en/p5 copy/matchAll.mdx b/src/content/reference/en/p5 copy/matchAll.mdx deleted file mode 100644 index 371d596b61..0000000000 --- a/src/content/reference/en/p5 copy/matchAll.mdx +++ /dev/null @@ -1,107 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L119 -title: matchAll -module: Data -submodule: String Functions -file: src/utilities/string_functions.js -description: > -

Applies a regular expression to a string and returns an array of - matches.

- -

match() uses regular expressions (regex) to match patterns in - text. For - - example, the regex abc can be used to search a string for the - exact - - sequence of characters abc. See - - MDN. - - for more information about regexes. matchAll() is different from - - match() because it returns every match, not - just - - the first.

- -

The first parameter, str, is the string to search.

- -

The second parameter, regex, is a string with the regular - expression to - - apply. For example, calling - - matchAll('p5*js is easier than abc123', '[a-z][0-9]') would - return the - - 2D array [['p5'], ['c1']].

- -

Note: If no matches are found, an empty array [] is - returned.

-line: 119 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let string = 'p5*js is easier than abc123'; - - // Match the character sequences that are - // lowercase letters followed by digits. - let matches = matchAll(string, '[a-z][0-9]'); - - // Print the matches array to the console: - // [['p5'], ['c1']] - print(matches); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Iterate over the matches array. - for (let i = 0; i < matches.length; i += 1) { - - // Calculate the y-coordainate. - let y = (i + 1) * 33; - - // Display the match. - text(matches[i], 50, y); - } - - describe( - 'The text "p5" and "c1" written on separate lines. The text is black on a gray background.' - ); - } - -
-class: p5 -params: - - name: str - description: | -

string to search.

- type: String - - name: regexp - description: | -

regular expression to match.

- type: String -return: - description: matches found. - type: 'String[]' -chainable: false ---- - - -# matchAll diff --git a/src/content/reference/en/p5 copy/max.mdx b/src/content/reference/en/p5 copy/max.mdx deleted file mode 100644 index 0dd0ee142c..0000000000 --- a/src/content/reference/en/p5 copy/max.mdx +++ /dev/null @@ -1,104 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L618 -title: max -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Returns the largest value in a sequence of numbers.

- -

The version of max() with one parameter interprets it as an - array of - - numbers and returns the largest number.

- -

The version of max() with two or more parameters interprets - them as - - individual numbers and returns the largest number.

-line: 618 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Calculate the maximum of 10, 5, and 20. - let m = max(10, 5, 20); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the max. - text(m, 50, 50); - - describe('The number 20 written in the middle of a gray square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of numbers. - let numbers = [10, 5, 20]; - - // Calculate the maximum of the array. - let m = max(numbers); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the max. - text(m, 50, 50); - - describe('The number 20 written in the middle of a gray square.'); - } - -
-class: p5 -return: - description: maximum number. - type: Number -overloads: - - line: 618 - params: - - name: n0 - description: | -

first number to compare.

- type: Number - - name: n1 - description: | -

second number to compare.

- type: Number - return: - description: maximum number. - type: Number - - line: 680 - params: - - name: nums - description: | -

numbers to compare.

- type: 'Number[]' - return: - description: '' - type: Number -chainable: false ---- - - -# max diff --git a/src/content/reference/en/p5 copy/metalness.mdx b/src/content/reference/en/p5 copy/metalness.mdx deleted file mode 100644 index ef378bc2a9..0000000000 --- a/src/content/reference/en/p5 copy/metalness.mdx +++ /dev/null @@ -1,142 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L3069 -title: metalness -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Sets the amount of "metalness" of a - - specularMaterial().

- -

metalness() can make materials appear more metallic. It - affects the way - - materials reflect light sources including - - affects the way materials reflect light sources including - - directionalLight(), - - pointLight(), - - spotLight(), and - - imageLight().

- -

The parameter, metallic, is a number that sets the amount of - metalness. - - metallic must be greater than 1, which is its default value. - Higher - - values, such as metalness(100), make specular materials appear - more - - metallic.

-line: 3069 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'Two blue spheres drawn on a gray background. White light reflects from their surfaces as the mouse moves. The right sphere is more metallic than the left sphere.' - ); - } - - function draw() { - background(200); - - // Turn on an ambient light. - ambientLight(200); - - // Get the mouse's coordinates. - let mx = mouseX - 50; - let my = mouseY - 50; - - // Turn on a white point light that follows the mouse. - pointLight(255, 255, 255, mx, my, 50); - - // Style the spheres. - noStroke(); - fill(30, 30, 255); - specularMaterial(255); - shininess(20); - - // Draw the left sphere with low metalness. - translate(-25, 0, 0); - metalness(1); - sphere(20); - - // Draw the right sphere with high metalness. - translate(50, 0, 0); - metalness(50); - sphere(20); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let img; - - function preload() { - img = loadImage('/assets/outdoor_spheremap.jpg'); - } - - function setup() { - createCanvas(100 ,100 ,WEBGL); - - describe( - 'Two spheres floating above a landscape. The surface of the spheres reflect the landscape. The right sphere is more reflective than the left sphere.' - ); - } - - function draw() { - // Add the panorama. - panorama(img); - - // Enable orbiting with the mouse. - orbitControl(); - - // Use the image as a light source. - imageLight(img); - - // Style the spheres. - noStroke(); - specularMaterial(50); - shininess(200); - - // Draw the left sphere with low metalness. - translate(-25, 0, 0); - metalness(1); - sphere(20); - - // Draw the right sphere with high metalness. - translate(50, 0, 0); - metalness(50); - sphere(20); - } - -
-class: p5 -params: - - name: metallic - description: | -

amount of metalness.

- type: Number -chainable: false ---- - - -# metalness diff --git a/src/content/reference/en/p5 copy/midiToFreq.mdx b/src/content/reference/en/p5 copy/midiToFreq.mdx deleted file mode 100644 index ada29d80ea..0000000000 --- a/src/content/reference/en/p5 copy/midiToFreq.mdx +++ /dev/null @@ -1,66 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L841 -title: midiToFreq -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: | -

Returns the frequency value of a MIDI note value. - General MIDI treats notes as integers where middle C - is 60, C# is 61, D is 62 etc. Useful for generating - musical frequencies with oscillators.

-line: 841 -isConstructor: false -itemtype: method -example: - - |- - -
- let midiNotes = [60, 64, 67, 72]; - let noteIndex = 0; - let midiVal, freq; - - function setup() { - let cnv = createCanvas(100, 100); - cnv.mousePressed(startSound); - osc = new p5.TriOsc(); - env = new p5.Envelope(); - } - - function draw() { - background(220); - text('tap to play', 10, 20); - if (midiVal) { - text('MIDI: ' + midiVal, 10, 40); - text('Freq: ' + freq, 10, 60); - } - } - - function startSound() { - // see also: userStartAudio(); - osc.start(); - - midiVal = midiNotes[noteIndex % midiNotes.length]; - freq = midiToFreq(midiVal); - osc.freq(freq); - env.ramp(osc, 0, 1.0, 0); - - noteIndex++; - } -
-class: p5 -params: - - name: midiNote - description: | -

The number of a MIDI note

- type: Number -return: - description: Frequency value of the given MIDI note - type: Number -chainable: false ---- - - -# midiToFreq diff --git a/src/content/reference/en/p5 copy/millis.mdx b/src/content/reference/en/p5 copy/millis.mdx deleted file mode 100644 index 18f1ac06d0..0000000000 --- a/src/content/reference/en/p5 copy/millis.mdx +++ /dev/null @@ -1,147 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L112 -title: millis -module: IO -submodule: Time & Date -file: src/utilities/time_date.js -description: > -

Returns the number of milliseconds since a sketch started running.

- -

millis() keeps track of how long a sketch has been running in - - milliseconds (thousandths of a second). This information is often - - helpful for timing events and animations.

- -

If a sketch has a - - setup() function, then - millis() begins tracking - - time before the code in setup() runs. If a - - sketch includes a preload() function, - then - - millis() begins tracking time as soon as the code in - - preload() starts running.

-line: 112 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Get the number of milliseconds the sketch has run. - let ms = millis(); - - // Style the text. - textAlign(LEFT, CENTER); - textSize(10); - textFont('Courier New'); - - // Display how long it took setup() to be called. - text(`Startup time: ${round(ms, 2)} ms`, 5, 50, 90); - - describe( - `The text 'Startup time: ${round(ms, 2)} ms' written in black on a gray background.` - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('The text "Running time: S sec" written in black on a gray background. The number S increases as the sketch runs.'); - } - - function draw() { - background(200); - - // Get the number of seconds the sketch has run. - let s = millis() / 1000; - - // Style the text. - textAlign(LEFT, CENTER); - textSize(10); - textFont('Courier New'); - - // Display how long the sketch has run. - text(`Running time: ${nf(s, 1, 1)} sec`, 5, 50, 90); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A white circle oscillates left and right on a gray background.'); - } - - function draw() { - background(200); - - // Get the number of seconds the sketch has run. - let s = millis() / 1000; - - // Calculate an x-coordinate. - let x = 30 * sin(s) + 50; - - // Draw the circle. - circle(x, 50, 30); - } - -
- -
- - // Load the GeoJSON. - function preload() { - loadJSON('https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Get the number of milliseconds the sketch has run. - let ms = millis(); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(11); - - // Display how long it took to load the data. - text(`It took ${round(ms, 2)} ms to load the data`, 5, 50, 100); - - describe( - `The text "It took ${round(ms, 2)} ms to load the data" written in black on a gray background.` - ); - } - -
-class: p5 -return: - description: number of milliseconds since starting the sketch. - type: Number -chainable: false ---- - - -# millis diff --git a/src/content/reference/en/p5 copy/min.mdx b/src/content/reference/en/p5 copy/min.mdx deleted file mode 100644 index 67af3b37f1..0000000000 --- a/src/content/reference/en/p5 copy/min.mdx +++ /dev/null @@ -1,104 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L695 -title: min -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Returns the smallest value in a sequence of numbers.

- -

The version of min() with one parameter interprets it as an - array of - - numbers and returns the smallest number.

- -

The version of min() with two or more parameters interprets - them as - - individual numbers and returns the smallest number.

-line: 695 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Calculate the minimum of 10, 5, and 20. - let m = min(10, 5, 20); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the min. - text(m, 50, 50); - - describe('The number 5 written in the middle of a gray square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of numbers. - let numbers = [10, 5, 20]; - - // Calculate the minimum of the array. - let m = min(numbers); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the min. - text(m, 50, 50); - - describe('The number 5 written in the middle of a gray square.'); - } - -
-class: p5 -return: - description: minimum number. - type: Number -overloads: - - line: 695 - params: - - name: n0 - description: | -

first number to compare.

- type: Number - - name: n1 - description: | -

second number to compare.

- type: Number - return: - description: minimum number. - type: Number - - line: 757 - params: - - name: nums - description: | -

numbers to compare.

- type: 'Number[]' - return: - description: '' - type: Number -chainable: false ---- - - -# min diff --git a/src/content/reference/en/p5 copy/minute.mdx b/src/content/reference/en/p5 copy/minute.mdx deleted file mode 100644 index 3ac966c800..0000000000 --- a/src/content/reference/en/p5 copy/minute.mdx +++ /dev/null @@ -1,47 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L78 -title: minute -module: IO -submodule: Time & Date -file: src/utilities/time_date.js -description: | -

Returns the current minute as a number from 0–59.

-line: 78 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Get the current minute. - let m = minute(); - - // Style the text. - textAlign(LEFT, CENTER); - textSize(12); - textFont('Courier New'); - - // Display the minute. - text(`Current minute: ${m}`, 10, 50, 80); - - describe(`The text 'Current minute: ${m}' written in black on a gray background.`); - } - -
-class: p5 -return: - description: current minute between 0 and 59. - type: Integer -chainable: false ---- - - -# minute diff --git a/src/content/reference/en/p5 copy/model.mdx b/src/content/reference/en/p5 copy/model.mdx deleted file mode 100644 index e925350407..0000000000 --- a/src/content/reference/en/p5 copy/model.mdx +++ /dev/null @@ -1,155 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/loading.js#L991 -title: model -module: Shape -submodule: 3D Models -file: src/webgl/loading.js -description: > -

Draws a p5.Geometry object to the - canvas.

- -

The parameter, model, is the - - p5.Geometry object to draw. - - p5.Geometry objects can be built with - - buildGeometry(), or - - beginGeometry() and - - endGeometry(). They can also be - loaded from - - a file with loadGeometry().

- -

Note: model() can only be used in WebGL mode.

-line: 991 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the p5.Geometry object. - shape = buildGeometry(createShape); - - describe('A white cone drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the p5.Geometry object. - model(shape); - } - - // Create p5.Geometry object from a single cone. - function createShape() { - cone(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the p5.Geometry object. - shape = buildGeometry(createArrow); - - describe('Two white arrows drawn on a gray background. The arrow on the right rotates slowly.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the arrows. - noStroke(); - - // Draw the p5.Geometry object. - model(shape); - - // Translate and rotate the coordinate system. - translate(30, 0, 0); - rotateZ(frameCount * 0.01); - - // Draw the p5.Geometry object again. - model(shape); - } - - function createArrow() { - // Add shapes to the p5.Geometry object. - push(); - rotateX(PI); - cone(10); - translate(0, -10, 0); - cylinder(3, 20); - pop(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - // Load the file and create a p5.Geometry object. - function preload() { - shape = loadModel('/assets/octahedron.obj'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white octahedron drawn against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the shape. - model(shape); - } - -
-class: p5 -params: - - name: model - description: | -

3D shape to be drawn.

- type: p5.Geometry -chainable: false ---- - - -# model diff --git a/src/content/reference/en/p5 copy/month.mdx b/src/content/reference/en/p5 copy/month.mdx deleted file mode 100644 index d2e248235c..0000000000 --- a/src/content/reference/en/p5 copy/month.mdx +++ /dev/null @@ -1,47 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L242 -title: month -module: IO -submodule: Time & Date -file: src/utilities/time_date.js -description: | -

Returns the current month as a number from 1–12.

-line: 242 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Get the current month. - let m = month(); - - // Style the text. - textAlign(LEFT, CENTER); - textSize(12); - textFont('Courier New'); - - // Display the month. - text(`Current month: ${m}`, 10, 50, 80); - - describe(`The text 'Current month: ${m}' written in black on a gray background.`); - } - -
-class: p5 -return: - description: current month between 1 and 12. - type: Integer -chainable: false ---- - - -# month diff --git a/src/content/reference/en/p5 copy/mouseButton.mdx b/src/content/reference/en/p5 copy/mouseButton.mdx deleted file mode 100644 index 82128f97a3..0000000000 --- a/src/content/reference/en/p5 copy/mouseButton.mdx +++ /dev/null @@ -1,87 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L687 -title: mouseButton -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A String system variable that contains the value of the last mouse button - - pressed.

- -

The mouseButton variable is either LEFT, - RIGHT, or CENTER, - - depending on which button was pressed last.

- -

Note: Different browsers may track mouseButton differently. - See - - MDN - - for more information.

-line: 687 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with black text at its center. The text changes from 0 to either "left" or "right" when the user clicks a mouse button.' - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the mouse button. - text(mouseButton, 50, 50); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - "A gray square. Different shapes appear at its center depending on the mouse button that's clicked." - ); - } - - function draw() { - background(200); - - if (mouseIsPressed === true) { - if (mouseButton === LEFT) { - circle(50, 50, 50); - } - if (mouseButton === RIGHT) { - square(25, 25, 50); - } - if (mouseButton === CENTER) { - triangle(23, 75, 50, 20, 78, 75); - } - } - } - -
-class: p5 -type: Constant ---- - - -# mouseButton diff --git a/src/content/reference/en/p5 copy/mouseClicked.mdx b/src/content/reference/en/p5 copy/mouseClicked.mdx deleted file mode 100644 index 80bd80b0a2..0000000000 --- a/src/content/reference/en/p5 copy/mouseClicked.mdx +++ /dev/null @@ -1,196 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1443 -title: mouseClicked -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A function that's called once after a mouse button is pressed and - released.

- -

Declaring the function mouseClicked() sets a code block to run - - automatically when the user releases a mouse button after having pressed - - it:

- -
function mouseClicked() {
-    // Code to run.
-  }
-
-  
- -

The mouse system variables, such as mouseX and - - mouseY, will be updated with their most - recent - - value when mouseClicked() is called by p5.js:

- -
function mouseClicked() {
-    if (mouseX < 50) {
-      // Code to run if the mouse is on the left.
-    }
-
-    if (mouseY > 50) {
-      // Code to run if the mouse is near the bottom.
-    }
-  }
-
-  
- -

The parameter, event, is optional. mouseClicked() - is always passed a - - MouseEvent - - object with properties that describe the mouse click event:

- -
function mouseClicked(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

On touchscreen devices, mouseClicked() will run when a user’s - touch - - ends if touchEnded() isn’t declared. - If - - touchEnded() is declared, then - - touchEnded() will run when a user’s - touch - - ends and mouseClicked() won’t.

- -

Browsers may have default behaviors attached to various mouse events. For - - example, some browsers highlight text when the user moves the mouse while - - pressing a mouse button. To prevent any default behavior for this event, - - add return false; to the end of the function.

- -

Note: mousePressed(), - - mouseReleased(), - - and mouseClicked() are all related. - - mousePressed() runs as soon as the - user - - clicks the mouse. mouseReleased() - runs as - - soon as the user releases the mouse click. mouseClicked() runs - - immediately after mouseReleased().

-line: 1443 -isConstructor: false -itemtype: method -example: - - |- - -
- - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square changes color when the user presses and releases a mouse button.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Toggle the square's color when the user clicks. - function mouseClicked() { - if (value === 0) { - value = 255; - } else { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Style the circle. - fill('orange'); - stroke('royalblue'); - strokeWeight(10); - - describe( - 'An orange circle with a thick, blue border drawn on a gray background. When the user presses and holds the mouse, the border becomes thin and pink. When the user releases the mouse, the border becomes thicker and changes color to blue.' - ); - } - - function draw() { - background(220); - - // Draw the circle. - circle(50, 50, 20); - } - - // Set the stroke color and weight as soon as the user clicks. - function mousePressed() { - stroke('deeppink'); - strokeWeight(3); - } - - // Set the stroke and fill colors as soon as the user releases - // the mouse. - function mouseReleased() { - stroke('royalblue'); - - // This is never visible because fill() is called - // in mouseClicked() which runs immediately after - // mouseReleased(); - fill('limegreen'); - } - - // Set the fill color and stroke weight after - // mousePressed() and mouseReleased() are called. - function mouseClicked() { - fill('orange'); - strokeWeight(10); - } - -
-class: p5 -params: - - name: event - description: | -

optional MouseEvent argument.

- type: MouseEvent - optional: true -chainable: false ---- - - -# mouseClicked diff --git a/src/content/reference/en/p5 copy/mouseDragged.mdx b/src/content/reference/en/p5 copy/mouseDragged.mdx deleted file mode 100644 index 26fea21fe9..0000000000 --- a/src/content/reference/en/p5 copy/mouseDragged.mdx +++ /dev/null @@ -1,130 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L982 -title: mouseDragged -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A function that's called when the mouse moves while a button is - pressed.

- -

Declaring the function mouseDragged() sets a code block to run - - automatically when the user clicks and drags the mouse:

- -
function mouseDragged() {
-    // Code to run.
-  }
-
-  
- -

The mouse system variables, such as mouseX and - - mouseY, will be updated with their most - recent - - value when mouseDragged() is called by p5.js:

- -
function mouseDragged() {
-    if (mouseX < 50) {
-      // Code to run if the mouse is on the left.
-    }
-
-    if (mouseY > 50) {
-      // Code to run if the mouse is near the bottom.
-    }
-  }
-
-  
- -

The parameter, event, is optional. mouseDragged() - is always passed a - - MouseEvent - - object with properties that describe the mouse drag event:

- -
function mouseDragged(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

On touchscreen devices, mouseDragged() will run when a user - moves a touch - - point if touchMoved() isn’t declared. - If - - touchMoved() is declared, then - - touchMoved() will run when a user - moves a - - touch point and mouseDragged() won’t.

- -

Browsers may have default behaviors attached to various mouse events. For - - example, some browsers highlight text when the user moves the mouse while - - pressing a mouse button. To prevent any default behavior for this event, - - add return false; to the end of the function.

-line: 982 -isConstructor: false -itemtype: method -example: - - |- - -
- - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square becomes lighter as the user drags the mouse.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - function mouseDragged() { - // Update the grayscale value. - value += 5; - - // Reset the grayscale value. - if (value > 255) { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
-class: p5 -params: - - name: event - description: | -

optional MouseEvent argument.

- type: MouseEvent - optional: true -chainable: false ---- - - -# mouseDragged diff --git a/src/content/reference/en/p5 copy/mouseIsPressed.mdx b/src/content/reference/en/p5 copy/mouseIsPressed.mdx deleted file mode 100644 index 37109eb364..0000000000 --- a/src/content/reference/en/p5 copy/mouseIsPressed.mdx +++ /dev/null @@ -1,73 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L755 -title: mouseIsPressed -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A Boolean system variable that's true if the - mouse is pressed and - - false if not.

-line: 755 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with the word "false" at its center. The word changes to "true" when the user presses a mouse button.' - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the mouseIsPressed variable. - text(mouseIsPressed, 25, 50); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a white square at its center. The inner square turns black when the user presses the mouse.' - ); - } - - function draw() { - background(200); - - // Style the square. - if (mouseIsPressed === true) { - fill(0); - } else { - fill(255); - } - - // Draw the square. - square(25, 25, 50); - } - -
-class: p5 -type: Boolean ---- - - -# mouseIsPressed diff --git a/src/content/reference/en/p5 copy/mouseMoved.mdx b/src/content/reference/en/p5 copy/mouseMoved.mdx deleted file mode 100644 index 14928fdc5e..0000000000 --- a/src/content/reference/en/p5 copy/mouseMoved.mdx +++ /dev/null @@ -1,118 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L896 -title: mouseMoved -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A function that's called when the mouse moves.

- -

Declaring the function mouseMoved() sets a code block to run - - automatically when the user moves the mouse without clicking any mouse - - buttons:

- -
function mouseMoved() {
-    // Code to run.
-  }
-
-  
- -

The mouse system variables, such as mouseX and - - mouseY, will be updated with their most - recent - - value when mouseMoved() is called by p5.js:

- -
function mouseMoved() {
-    if (mouseX < 50) {
-      // Code to run if the mouse is on the left.
-    }
-
-    if (mouseY > 50) {
-      // Code to run if the mouse is near the bottom.
-    }
-  }
-
-  
- -

The parameter, event, is optional. mouseMoved() - is always passed a - - MouseEvent - - object with properties that describe the mouse move event:

- -
function mouseMoved(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

Browsers may have default behaviors attached to various mouse events. For - - example, some browsers highlight text when the user moves the mouse while - - pressing a mouse button. To prevent any default behavior for this event, - - add return false; to the end of the function.

-line: 896 -isConstructor: false -itemtype: method -example: - - |- - -
- - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square becomes lighter as the mouse moves.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - function mouseMoved() { - // Update the grayscale value. - value += 5; - - // Reset the grayscale value. - if (value > 255) { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
-class: p5 -params: - - name: event - description: | -

optional MouseEvent argument.

- type: MouseEvent - optional: true -chainable: false ---- - - -# mouseMoved diff --git a/src/content/reference/en/p5 copy/mousePressed.mdx b/src/content/reference/en/p5 copy/mousePressed.mdx deleted file mode 100644 index 81181859c1..0000000000 --- a/src/content/reference/en/p5 copy/mousePressed.mdx +++ /dev/null @@ -1,193 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1098 -title: mousePressed -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A function that's called once when a mouse button is pressed.

- -

Declaring the function mousePressed() sets a code block to run - - automatically when the user presses a mouse button:

- -
function mousePressed() {
-    // Code to run.
-  }
-
-  
- -

The mouse system variables, such as mouseX and - - mouseY, will be updated with their most - recent - - value when mousePressed() is called by p5.js:

- -
function mousePressed() {
-    if (mouseX < 50) {
-      // Code to run if the mouse is on the left.
-    }
-
-    if (mouseY > 50) {
-      // Code to run if the mouse is near the bottom.
-    }
-  }
-
-  
- -

The parameter, event, is optional. mousePressed() - is always passed a - - MouseEvent - - object with properties that describe the mouse press event:

- -
function mousePressed(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

On touchscreen devices, mousePressed() will run when a user’s - touch - - begins if touchStarted() isn’t - declared. If - - touchStarted() is declared, then - - touchStarted() will run when a - user’s touch - - begins and mousePressed() won’t.

- -

Browsers may have default behaviors attached to various mouse events. For - - example, some browsers highlight text when the user moves the mouse while - - pressing a mouse button. To prevent any default behavior for this event, - - add return false; to the end of the function.

- -

Note: mousePressed(), mouseReleased(), - - and mouseClicked() are all related. - - mousePressed() runs as soon as the user clicks the mouse. - - mouseReleased() runs as soon as the - user - - releases the mouse click. mouseClicked() - - runs immediately after mouseReleased().

-line: 1098 -isConstructor: false -itemtype: method -example: - - |- - -
- - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square becomes lighter when the user presses a mouse button.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - function mousePressed() { - // Update the grayscale value. - value += 5; - - // Reset the grayscale value. - if (value > 255) { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Style the circle. - fill('orange'); - stroke('royalblue'); - strokeWeight(10); - - describe( - 'An orange circle with a thick, blue border drawn on a gray background. When the user presses and holds the mouse, the border becomes thin and pink. When the user releases the mouse, the border becomes thicker and changes color to blue.' - ); - } - - function draw() { - background(220); - - // Draw the circle. - circle(50, 50, 20); - } - - // Set the stroke color and weight as soon as the user clicks. - function mousePressed() { - stroke('deeppink'); - strokeWeight(3); - } - - // Set the stroke and fill colors as soon as the user releases - // the mouse. - function mouseReleased() { - stroke('royalblue'); - - // This is never visible because fill() is called - // in mouseClicked() which runs immediately after - // mouseReleased(); - fill('limegreen'); - } - - // Set the fill color and stroke weight after - // mousePressed() and mouseReleased() are called. - function mouseClicked() { - fill('orange'); - strokeWeight(10); - } - -
-class: p5 -params: - - name: event - description: | -

optional MouseEvent argument.

- type: MouseEvent - optional: true -chainable: false ---- - - -# mousePressed diff --git a/src/content/reference/en/p5 copy/mouseReleased.mdx b/src/content/reference/en/p5 copy/mouseReleased.mdx deleted file mode 100644 index 6f52911162..0000000000 --- a/src/content/reference/en/p5 copy/mouseReleased.mdx +++ /dev/null @@ -1,195 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1270 -title: mouseReleased -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A function that's called once when a mouse button is released.

- -

Declaring the function mouseReleased() sets a code block to - run - - automatically when the user releases a mouse button after having pressed - - it:

- -
function mouseReleased() {
-    // Code to run.
-  }
-
-  
- -

The mouse system variables, such as mouseX and - - mouseY, will be updated with their most - recent - - value when mouseReleased() is called by p5.js:

- -
function mouseReleased() {
-    if (mouseX < 50) {
-      // Code to run if the mouse is on the left.
-    }
-
-    if (mouseY > 50) {
-      // Code to run if the mouse is near the bottom.
-    }
-  }
-
-  
- -

The parameter, event, is optional. - mouseReleased() is always passed a - - MouseEvent - - object with properties that describe the mouse release event:

- -
function mouseReleased(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

On touchscreen devices, mouseReleased() will run when a user’s - touch - - ends if touchEnded() isn’t declared. - If - - touchEnded() is declared, then - - touchEnded() will run when a user’s - touch - - ends and mouseReleased() won’t.

- -

Browsers may have default behaviors attached to various mouse events. For - - example, some browsers highlight text when the user moves the mouse while - - pressing a mouse button. To prevent any default behavior for this event, - - add return false; to the end of the function.

- -

Note: mousePressed(), - mouseReleased(), - - and mouseClicked() are all related. - - mousePressed() runs as soon as the - user - - clicks the mouse. mouseReleased() runs as soon as the user - releases the - - mouse click. mouseClicked() runs - - immediately after mouseReleased().

-line: 1270 -isConstructor: false -itemtype: method -example: - - |- - -
- - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square becomes lighter when the user presses and releases a mouse button.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - function mouseReleased() { - // Update the grayscale value. - value += 5; - - // Reset the grayscale value. - if (value > 255) { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Style the circle. - fill('orange'); - stroke('royalblue'); - strokeWeight(10); - - describe( - 'An orange circle with a thick, blue border drawn on a gray background. When the user presses and holds the mouse, the border becomes thin and pink. When the user releases the mouse, the border becomes thicker and changes color to blue.' - ); - } - - function draw() { - background(220); - - // Draw the circle. - circle(50, 50, 20); - } - - // Set the stroke color and weight as soon as the user clicks. - function mousePressed() { - stroke('deeppink'); - strokeWeight(3); - } - - // Set the stroke and fill colors as soon as the user releases - // the mouse. - function mouseReleased() { - stroke('royalblue'); - - // This is never visible because fill() is called - // in mouseClicked() which runs immediately after - // mouseReleased(); - fill('limegreen'); - } - - // Set the fill color and stroke weight after - // mousePressed() and mouseReleased() are called. - function mouseClicked() { - fill('orange'); - strokeWeight(10); - } - -
-class: p5 -params: - - name: event - description: | -

optional MouseEvent argument.

- type: MouseEvent - optional: true -chainable: false ---- - - -# mouseReleased diff --git a/src/content/reference/en/p5 copy/mouseWheel.mdx b/src/content/reference/en/p5 copy/mouseWheel.mdx deleted file mode 100644 index a659ea3cec..0000000000 --- a/src/content/reference/en/p5 copy/mouseWheel.mdx +++ /dev/null @@ -1,162 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1746 -title: mouseWheel -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A function that's called once when the mouse wheel moves.

- -

Declaring the function mouseWheel() sets a code block to run - - automatically when the user scrolls with the mouse wheel:

- -
function mouseWheel() {
-    // Code to run.
-  }
-
-  
- -

The mouse system variables, such as mouseX and - - mouseY, will be updated with their most - recent - - value when mouseWheel() is called by p5.js:

- -
function mouseWheel() {
-    if (mouseX < 50) {
-      // Code to run if the mouse is on the left.
-    }
-
-    if (mouseY > 50) {
-      // Code to run if the mouse is near the bottom.
-    }
-  }
-
-  
- -

The parameter, event, is optional. mouseWheel() - is always passed a - - MouseEvent - - object with properties that describe the mouse scroll event:

- -
function mouseWheel(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

The event object has many properties including - delta, a Number - - containing the distance that the user scrolled. For example, - event.delta - - might have the value 5 when the user scrolls up. event.delta is - positive - - if the user scrolls up and negative if they scroll down. The signs are - - opposite on macOS with "natural" scrolling enabled.

- -

Browsers may have default behaviors attached to various mouse events. For - - example, some browsers highlight text when the user moves the mouse while - - pressing a mouse button. To prevent any default behavior for this event, - - add return false; to the end of the function.

- -

Note: On Safari, mouseWheel() may only work as expected if - - return false; is added at the end of the function.

-line: 1746 -isConstructor: false -itemtype: method -example: - - |- - -
- - let circleSize = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square. A white circle at its center grows up when the user scrolls the mouse wheel.' - ); - } - - function draw() { - background(200); - - // Draw the circle - circle(50, 50, circleSize); - } - - // Increment circleSize when the user scrolls the mouse wheel. - function mouseWheel() { - circleSize += 1; - // Uncomment to prevent any default behavior. - // return false; - } - -
- -
- - let direction = ''; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square. An arrow at its center points up when the user scrolls up. The arrow points down when the user scrolls down.' - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Draw an arrow that points where - // the mouse last scrolled. - text(direction, 50, 50); - } - - // Change direction when the user scrolls the mouse wheel. - function mouseWheel(event) { - if (event.delta > 0) { - direction = '▲'; - } else { - direction = '▼'; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
-class: p5 -params: - - name: event - description: | -

optional WheelEvent argument.

- type: WheelEvent - optional: true -chainable: false ---- - - -# mouseWheel diff --git a/src/content/reference/en/p5 copy/mouseX.mdx b/src/content/reference/en/p5 copy/mouseX.mdx deleted file mode 100644 index 7c0ba7f4a3..0000000000 --- a/src/content/reference/en/p5 copy/mouseX.mdx +++ /dev/null @@ -1,124 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L119 -title: mouseX -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A Number system variable that tracks the mouse's horizontal - position.

- -

mouseX keeps track of the mouse's position relative to the - - top-left corner of the canvas. For example, if the mouse is 50 pixels from - - the left edge of the canvas, then mouseX will be 50.

- -

If touch is used instead of the mouse, then mouseX will hold - the - - x-coordinate of the most recent touch point.

-line: 119 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe("A vertical black line moves left and right following the mouse's x-position."); - } - - function draw() { - background(200); - - // Draw a vertical line that follows the mouse's x-coordinate. - line(mouseX, 0, mouseX, 100); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe("A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse."); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the mouse's coordinates. - text(`x: ${mouseX} y: ${mouseY}`, 50, 50); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe("A vertical black line moves left and right following the mouse's x-position."); - } - - function draw() { - background(200); - - // Adjust coordinates for WebGL mode. - // The origin (0, 0) is at the center of the canvas. - let mx = mouseX - 50; - - // Draw the line. - line(mx, -50, mx, 50); - } - -
- -
- - let font; - - // Load a font for WebGL mode. - function preload() { - font = loadFont('/assets/inconsolata.otf'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - "A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse." - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - textFont(font); - fill(0); - - // Display the mouse's coordinates. - text(`x: ${mouseX} y: ${mouseY}`, 0, 0); - } - -
-class: p5 -type: Number ---- - - -# mouseX diff --git a/src/content/reference/en/p5 copy/mouseY.mdx b/src/content/reference/en/p5 copy/mouseY.mdx deleted file mode 100644 index dc268025a4..0000000000 --- a/src/content/reference/en/p5 copy/mouseY.mdx +++ /dev/null @@ -1,124 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L226 -title: mouseY -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A Number system variable that tracks the mouse's vertical - position.

- -

mouseY keeps track of the mouse's position relative to the - - top-left corner of the canvas. For example, if the mouse is 50 pixels from - - the top edge of the canvas, then mouseY will be 50.

- -

If touch is used instead of the mouse, then mouseY will hold - the - - y-coordinate of the most recent touch point.

-line: 226 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe("A horizontal black line moves up and down following the mouse's y-position."); - } - - function draw() { - background(200); - - // Draw a horizontal line that follows the mouse's y-coordinate. - line(0, mouseY, 100, mouseY); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe("A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse."); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the mouse's coordinates. - text(`x: ${mouseX} y: ${mouseY}`, 50, 50); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe("A horizontal black line moves up and down following the mouse's y-position."); - } - - function draw() { - background(200); - - // Adjust coordinates for WebGL mode. - // The origin (0, 0) is at the center of the canvas. - let my = mouseY - 50; - - // Draw the line. - line(-50, my, 50, my); - } - -
- -
- - let font; - - // Load a font for WebGL mode. - function preload() { - font = loadFont('/assets/inconsolata.otf'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - "A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse." - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - textFont(font); - fill(0); - - // Display the mouse's coordinates. - text(`x: ${mouseX} y: ${mouseY}`, 0, 0); - } - -
-class: p5 -type: Number ---- - - -# mouseY diff --git a/src/content/reference/en/p5 copy/movedX.mdx b/src/content/reference/en/p5 copy/movedX.mdx deleted file mode 100644 index 454b577166..0000000000 --- a/src/content/reference/en/p5 copy/movedX.mdx +++ /dev/null @@ -1,78 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L12 -title: movedX -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A Number system variable that tracks the mouse's horizontal - movement.

- -

movedX tracks how many pixels the mouse moves left or right - between - - frames. movedX will have a negative value if the mouse moves left - between - - frames and a positive value if it moves right. movedX can be - calculated - - as mouseX - pmouseX.

- -

Note: movedX continues updating even when - - requestPointerLock() is - active. - - But keep in mind that during an active pointer lock, mouseX and pmouseX - - are locked, so movedX is based on - - the - MouseEvent's movementX value - - (which may behave differently in different browsers when the user - - is zoomed in or out).

-line: 12 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square. The text ">>" appears when the user moves the mouse to the right. The text "<<" appears when the user moves the mouse to the left.' - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display >> when movedX is positive and - // << when it's negative. - if (movedX > 0) { - text('>>', 50, 50); - } else if (movedX < 0) { - text('<<', 50, 50); - } - } - -
-class: p5 -type: Number ---- - - -# movedX diff --git a/src/content/reference/en/p5 copy/movedY.mdx b/src/content/reference/en/p5 copy/movedY.mdx deleted file mode 100644 index 00f4a28d5b..0000000000 --- a/src/content/reference/en/p5 copy/movedY.mdx +++ /dev/null @@ -1,78 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L62 -title: movedY -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A Number system variable that tracks the mouse's vertical - movement.

- -

movedY tracks how many pixels the mouse moves up or down - between - - frames. movedY will have a negative value if the mouse moves up - between - - frames and a positive value if it moves down. movedY can be - calculated - - as mouseY - pmouseY.

- -

Note: movedY continues updating even when - - requestPointerLock() is - active. - - But keep in mind that during an active pointer lock, mouseX and pmouseX - - are locked, so movedX is based on - - the - MouseEvent's movementX value - - (which may behave differently in different browsers when the user - - is zoomed in or out).

-line: 62 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square. The text "▲" appears when the user moves the mouse upward. The text "▼" appears when the user moves the mouse downward.' - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display ▼ when movedY is positive and - // ▲ when it's negative. - if (movedY > 0) { - text('▼', 50, 50); - } else if (movedY < 0) { - text('▲', 50, 50); - } - } - -
-class: p5 -type: Number ---- - - -# movedY diff --git a/src/content/reference/en/p5 copy/nf.mdx b/src/content/reference/en/p5 copy/nf.mdx deleted file mode 100644 index ab64244d9f..0000000000 --- a/src/content/reference/en/p5 copy/nf.mdx +++ /dev/null @@ -1,159 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L199 -title: nf -module: Data -submodule: String Functions -file: src/utilities/string_functions.js -description: > -

Converts a Number into a String with a given - number of digits.

- -

nf() converts numbers such as 123.45 into strings - formatted with a set - - number of digits, as in '123.4500'.

- -

The first parameter, num, is the number to convert to a - string. For - - example, calling nf(123.45) returns the string - '123.45'. If an array of - - numbers is passed, as in nf([123.45, 67.89]), an array of - formatted - - strings will be returned.

- -

The second parameter, left, is optional. If a number is - passed, as in - - nf(123.45, 4), it sets the minimum number of digits to include to - the - - left of the decimal place. If left is larger than the number of - digits in - - num, then unused digits will be set to 0. For example, calling - - nf(123.45, 4) returns the string '0123.45'.

- -

The third parameter, right, is also optional. If a number is - passed, as - - in nf(123.45, 4, 1), it sets the minimum number of digits to - include to - - the right of the decimal place. If right is smaller than the - number of - - decimal places in num, then num will be rounded to - the given number of - - decimal places. For example, calling nf(123.45, 4, 1) returns the - string - - '0123.5'. If right is larger than the number of decimal places in - num, - - then unused decimal places will be set to 0. For example, calling - - nf(123.45, 4, 3) returns the string '0123.450'.

- -

When the number is negative, for example, calling nf(-123.45, 5, - 2) - - returns the string '-00123.45'.

-line: 199 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textSize(16); - - // Create a number variable. - let number = 123.45; - - // Display the number as a string. - let formatted = nf(number); - text(formatted, 20, 20); - - let negative = nf(-number, 4, 2); - text(negative, 20, 40); - - // Display the number with four digits - // to the left of the decimal. - let left = nf(number, 4); - text(left, 20, 60); - - // Display the number with four digits - // to the left of the decimal and one - // to the right. - let right = nf(number, 4, 1); - text(right, 20, 80); - - describe( - 'The numbers "123.45", "-0123.45", "0123.45", and "0123.5" written on four separate lines. The text is in black on a gray background.' - ); - } - -
-class: p5 -return: - description: formatted string. - type: String -overloads: - - line: 199 - params: - - name: num - description: | -

number to format.

- type: Number|String - - name: left - description: | -

number of digits to include to the left of - the decimal point.

- type: Integer|String - optional: true - - name: right - description: | -

number of digits to include to the right - of the decimal point.

- type: Integer|String - optional: true - return: - description: formatted string. - type: String - - line: 276 - params: - - name: nums - description: | -

numbers to format.

- type: 'Number[]' - - name: left - description: '' - type: Integer|String - optional: true - - name: right - description: '' - type: Integer|String - optional: true - return: - description: formatted strings. - type: 'String[]' -chainable: false ---- - - -# nf diff --git a/src/content/reference/en/p5 copy/nfc.mdx b/src/content/reference/en/p5 copy/nfc.mdx deleted file mode 100644 index ba49f689fa..0000000000 --- a/src/content/reference/en/p5 copy/nfc.mdx +++ /dev/null @@ -1,153 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L322 -title: nfc -module: Data -submodule: String Functions -file: src/utilities/string_functions.js -description: > -

Converts a Number into a String with commas to - mark units of 1,000.

- -

nfc() converts numbers such as 12345 into strings formatted - with commas - - to mark the thousands place, as in '12,345'.

- -

The first parameter, num, is the number to convert to a - string. For - - example, calling nfc(12345) returns the string - '12,345'.

- -

The second parameter, right, is optional. If a number is - passed, as in - - nfc(12345, 1), it sets the minimum number of digits to include to - the - - right of the decimal place. If right is smaller than the number - of - - decimal places in num, then num will be rounded to - the given number of - - decimal places. For example, calling nfc(12345.67, 1) returns the - string - - '12,345.7'. If right is larger than the number of - decimal places in - - num, then unused decimal places will be set to 0. For example, - calling - - nfc(12345.67, 3) returns the string - '12,345.670'.

-line: 322 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textSize(16); - - // Create a number variable. - let number = 12345; - - // Display the number as a string. - let commas = nfc(number); - text(commas, 15, 33); - - // Display the number with four digits - // to the left of the decimal. - let decimals = nfc(number, 2); - text(decimals, 15, 67); - - describe( - 'The numbers "12,345" and "12,345.00" written on separate lines. The text is in black on a gray background.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of numbers. - let numbers = [12345, 6789]; - - // Convert the numbers to formatted strings. - let formatted = nfc(numbers); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(14); - - // Iterate over the array. - for (let i = 0; i < formatted.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 33; - - // Display the original and formatted numbers. - text(`${numbers[i]} : ${formatted[i]}`, 50, y); - } - - describe( - 'The text "12345 : 12,345" and "6789 : 6,789" written on two separate lines. The text is in black on a gray background.' - ); - } - -
-class: p5 -return: - description: formatted string. - type: String -overloads: - - line: 322 - params: - - name: num - description: | -

number to format.

- type: Number|String - - name: right - description: | -

number of digits to include to the right - of the decimal point.

- type: Integer|String - optional: true - return: - description: formatted string. - type: String - - line: 411 - params: - - name: nums - description: | -

numbers to format.

- type: 'Number[]' - - name: right - description: '' - type: Integer|String - optional: true - return: - description: formatted strings. - type: 'String[]' -chainable: false ---- - - -# nfc diff --git a/src/content/reference/en/p5 copy/nfp.mdx b/src/content/reference/en/p5 copy/nfp.mdx deleted file mode 100644 index dbd80ca5d7..0000000000 --- a/src/content/reference/en/p5 copy/nfp.mdx +++ /dev/null @@ -1,188 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L447 -title: nfp -module: Data -submodule: String Functions -file: src/utilities/string_functions.js -description: > -

Converts a Number into a String with a plus or - minus sign.

- -

nfp() converts numbers such as 123 into strings formatted with - a + or - - - symbol to mark whether they're positive or negative, as in - '+123'.

- -

The first parameter, num, is the number to convert to a - string. For - - example, calling nfp(123.45) returns the string - '+123.45'. If an array - - of numbers is passed, as in nfp([123.45, -6.78]), an array of - formatted - - strings will be returned.

- -

The second parameter, left, is optional. If a number is - passed, as in - - nfp(123.45, 4), it sets the minimum number of digits to include - to the - - left of the decimal place. If left is larger than the number of - digits in - - num, then unused digits will be set to 0. For example, calling - - nfp(123.45, 4) returns the string '+0123.45'.

- -

The third parameter, right, is also optional. If a number is - passed, as - - in nfp(123.45, 4, 1), it sets the minimum number of digits to - include to - - the right of the decimal place. If right is smaller than the - number of - - decimal places in num, then num will be rounded to - the given number of - - decimal places. For example, calling nfp(123.45, 4, 1) returns - the - - string '+0123.5'. If right is larger than the number - of decimal places - - in num, then unused decimal places will be set to 0. For - example, - - calling nfp(123.45, 4, 3) returns the string - '+0123.450'.

-line: 447 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create number variables. - let positive = 123; - let negative = -123; - - // Convert the positive number to a formatted string. - let p = nfp(positive); - - // Convert the negative number to a formatted string - // with four digits to the left of the decimal - // and two digits to the right of the decimal. - let n = nfp(negative, 4, 2); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(14); - - // Display the original and formatted numbers. - text(`${positive} : ${p}`, 50, 33); - text(`${negative} : ${n}`, 50, 67); - - describe( - 'The text "123 : +123" and "-123 : -123.00" written on separate lines. The text is in black on a gray background.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create number variables. - let numbers = [123, -4.56]; - - // Convert the numbers to formatted strings - // with four digits to the left of the decimal - // and one digit to the right of the decimal. - let formatted = nfp(numbers, 4, 1); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(14); - - // Iterate over the array. - for (let i = 0; i < formatted.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 33; - - // Display the original and formatted numbers. - text(`${numbers[i]} : ${formatted[i]}`, 50, y); - } - - describe( - 'The text "123 : +0123.0" and "-4.56 : 00-4.6" written on separate lines. The text is in black on a gray background.' - ); - } - -
-class: p5 -return: - description: formatted string. - type: String -overloads: - - line: 447 - params: - - name: num - description: | -

number to format.

- type: Number - - name: left - description: | -

number of digits to include to the left of the - decimal point.

- type: Integer - optional: true - - name: right - description: | -

number of digits to include to the right of the - decimal point.

- type: Integer - optional: true - return: - description: formatted string. - type: String - - line: 552 - params: - - name: nums - description: | -

numbers to format.

- type: 'Number[]' - - name: left - description: '' - type: Integer - optional: true - - name: right - description: '' - type: Integer - optional: true - return: - description: formatted strings. - type: 'String[]' -chainable: false ---- - - -# nfp diff --git a/src/content/reference/en/p5 copy/nfs.mdx b/src/content/reference/en/p5 copy/nfs.mdx deleted file mode 100644 index 80c144e391..0000000000 --- a/src/content/reference/en/p5 copy/nfs.mdx +++ /dev/null @@ -1,176 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L573 -title: nfs -module: Data -submodule: String Functions -file: src/utilities/string_functions.js -description: > -

Converts a positive Number into a String with an - extra space in front.

- -

nfs() converts positive numbers such as 123.45 into strings - formatted - - with an extra space in front, as in ' 123.45'. Doing so can be helpful for - - aligning positive and negative numbers.

- -

The first parameter, num, is the number to convert to a - string. For - - example, calling nfs(123.45) returns the string ' - 123.45'.

- -

The second parameter, left, is optional. If a number is - passed, as in - - nfs(123.45, 4), it sets the minimum number of digits to include - to the - - left of the decimal place. If left is larger than the number of - digits in - - num, then unused digits will be set to 0. For example, calling - - nfs(123.45, 4) returns the string ' 0123.45'.

- -

The third parameter, right, is also optional. If a number is - passed, as - - in nfs(123.45, 4, 1), it sets the minimum number of digits to - include to - - the right of the decimal place. If right is smaller than the - number of - - decimal places in num, then num will be rounded to - the given number of - - decimal places. For example, calling nfs(123.45, 4, 1) returns - the - - string ' 0123.5'. If right is larger than the number - of decimal places - - in num, then unused decimal places will be set to 0. For - example, - - calling nfs(123.45, 4, 3) returns the string ' - 0123.450'.

-line: 573 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create number variables. - let positive = 123; - let negative = -123; - - // Convert the positive number to a formatted string. - let formatted = nfs(positive); - - // Style the text. - textAlign(CENTER, CENTER); - textFont('Courier New'); - textSize(16); - - // Display the negative number and the formatted positive number. - text(negative, 50, 33); - text(formatted, 50, 67); - - describe( - 'The numbers -123 and 123 written on separate lines. The numbers align vertically. The text is in black on a gray background.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a number variable. - let number = 123.45; - - // Convert the positive number to a formatted string. - // Use four digits to the left of the decimal and - // one digit to the right. - let formatted = nfs(number, 4, 1); - - // Style the text. - textAlign(CENTER, CENTER); - textFont('Courier New'); - textSize(16); - - // Display a negative version of the number and - // the formatted positive version. - text('-0123.5', 50, 33); - text(formatted, 50, 67); - - describe( - 'The numbers "-0123.5" and "0123.5" written on separate lines. The numbers align vertically. The text is in black on a gray background.' - ); - } - -
-class: p5 -return: - description: formatted string. - type: String -overloads: - - line: 573 - params: - - name: num - description: | -

number to format.

- type: Number - - name: left - description: | -

number of digits to include to the left of the - decimal point.

- type: Integer - optional: true - - name: right - description: | -

number of digits to include to the right of the - decimal point.

- type: Integer - optional: true - return: - description: formatted string. - type: String - - line: 669 - params: - - name: nums - description: | -

numbers to format.

- type: Array - - name: left - description: '' - type: Integer - optional: true - - name: right - description: '' - type: Integer - optional: true - return: - description: formatted strings. - type: 'String[]' -chainable: false ---- - - -# nfs diff --git a/src/content/reference/en/p5 copy/noCanvas.mdx b/src/content/reference/en/p5 copy/noCanvas.mdx deleted file mode 100644 index 08fcdda5e5..0000000000 --- a/src/content/reference/en/p5 copy/noCanvas.mdx +++ /dev/null @@ -1,36 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L346 -title: noCanvas -module: Rendering -submodule: Rendering -file: src/core/rendering.js -description: > -

Removes the default canvas.

- -

By default, a 100×100 pixels canvas is created without needing to call - - createCanvas(). - noCanvas() removes the - - default canvas for sketches that don't need it.

-line: 346 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - noCanvas(); - } - -
-class: p5 -chainable: false ---- - - -# noCanvas diff --git a/src/content/reference/en/p5 copy/noCursor.mdx b/src/content/reference/en/p5 copy/noCursor.mdx deleted file mode 100644 index 37ac72c0cf..0000000000 --- a/src/content/reference/en/p5 copy/noCursor.mdx +++ /dev/null @@ -1,38 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L482 -title: noCursor -module: Environment -submodule: Environment -file: src/core/environment.js -description: | -

Hides the cursor from view.

-line: 482 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - // Hide the cursor. - noCursor(); - } - - function draw() { - background(200); - - circle(mouseX, mouseY, 10); - - describe('A white circle on a gray background. The circle follows the mouse as it moves. The cursor is hidden.'); - } - -
-class: p5 -chainable: false ---- - - -# noCursor diff --git a/src/content/reference/en/p5 copy/noDebugMode.mdx b/src/content/reference/en/p5 copy/noDebugMode.mdx deleted file mode 100644 index 19d36eba2b..0000000000 --- a/src/content/reference/en/p5 copy/noDebugMode.mdx +++ /dev/null @@ -1,54 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/interaction.js#L725 -title: noDebugMode -module: 3D -submodule: Interaction -file: src/webgl/interaction.js -description: > -

Turns off debugMode() in a 3D - sketch.

-line: 725 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - // Enable debug mode. - debugMode(); - - describe('A multicolor box on a gray background. A grid and axes icon are displayed near the box. They disappear when the user double-clicks.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the box. - normalMaterial(); - - // Draw the box. box(20, 40); - } - - // Disable debug mode when the user double-clicks. - function doubleClicked() { - noDebugMode(); - } - -
-class: p5 -chainable: false ---- - - -# noDebugMode diff --git a/src/content/reference/en/p5 copy/noErase.mdx b/src/content/reference/en/p5 copy/noErase.mdx deleted file mode 100644 index e959433b77..0000000000 --- a/src/content/reference/en/p5 copy/noErase.mdx +++ /dev/null @@ -1,55 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1716 -title: noErase -module: Color -submodule: Setting -file: src/color/setting.js -description: > -

Ends erasing that was started with erase().

- -

The fill(), stroke(), and - - blendMode() settings will return to - what they - - were prior to calling erase().

-line: 1716 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(235, 145, 15); - - // Draw the left rectangle. - noStroke(); - fill(30, 45, 220); - rect(30, 10, 10, 80); - - // Erase a circle. - erase(); - circle(50, 50, 60); - noErase(); - - // Draw the right rectangle. - rect(70, 10, 10, 80); - - describe('An orange canvas with two tall blue rectangles. A circular hole in the center erases the rectangle on the left but not the one on the right.'); - } - -
-class: p5 -chainable: true ---- - - -# noErase diff --git a/src/content/reference/en/p5 copy/noFill.mdx b/src/content/reference/en/p5 copy/noFill.mdx deleted file mode 100644 index 67a3979778..0000000000 --- a/src/content/reference/en/p5 copy/noFill.mdx +++ /dev/null @@ -1,73 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1257 -title: noFill -module: Color -submodule: Setting -file: src/color/setting.js -description: > -

Disables setting the fill color for shapes.

- -

Calling noFill() is the same as making the fill completely - transparent, - - as in fill(0, 0). If both noStroke() and - - noFill() are called, nothing will be drawn to the screen.

-line: 1257 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw the top square. - square(32, 10, 35); - - // Draw the bottom square. - noFill(); - square(32, 55, 35); - - describe('A white square on above an empty square. Both squares have black outlines.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A purple cube wireframe spinning on a black canvas.'); - } - - function draw() { - background(0); - - // Style the box. - noFill(); - stroke(100, 100, 240); - - // Rotate the coordinates. - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - - // Draw the box. - box(45); - } - -
-class: p5 -chainable: true ---- - - -# noFill diff --git a/src/content/reference/en/p5 copy/noLights.mdx b/src/content/reference/en/p5 copy/noLights.mdx deleted file mode 100644 index 1f85888bf6..0000000000 --- a/src/content/reference/en/p5 copy/noLights.mdx +++ /dev/null @@ -1,79 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L1687 -title: noLights -module: 3D -submodule: Lights -file: src/webgl/light.js -description: > -

Removes all lights from the sketch.

- -

Calling noLights() removes any lights created with - - lights(), - - ambientLight(), - - directionalLight(), - - pointLight(), or - - spotLight(). These functions may be - called - - after noLights() to create a new lighting scheme.

-line: 1687 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('Two spheres drawn against a gray background. The top sphere is white and the bottom sphere is red.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the spheres. - noStroke(); - - // Draw the top sphere. - push(); - translate(0, -25, 0); - sphere(20); - pop(); - - // Turn off the lights. - noLights(); - - // Add a red directional light that points into the screen. - directionalLight(255, 0, 0, 0, 0, -1); - - // Draw the bottom sphere. - push(); - translate(0, 25, 0); - sphere(20); - pop(); - } - -
-class: p5 -chainable: true ---- - - -# noLights diff --git a/src/content/reference/en/p5 copy/noLoop.mdx b/src/content/reference/en/p5 copy/noLoop.mdx deleted file mode 100644 index fe1897a8cb..0000000000 --- a/src/content/reference/en/p5 copy/noLoop.mdx +++ /dev/null @@ -1,139 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L9 -title: noLoop -module: Structure -submodule: Structure -file: src/core/structure.js -description: > -

Stops the code in draw() from running - repeatedly.

- -

By default, draw() tries to run 60 times - per - - second. Calling noLoop() stops draw() from - - repeating. The draw loop can be restarted by calling - - loop(). draw() can be run - - once by calling redraw().

- -

The isLooping() function can be used - to check - - whether a sketch is looping, as in isLooping() === true.

-line: 9 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Turn off the draw loop. - noLoop(); - - describe('A white half-circle on the left edge of a gray square.'); - } - - function draw() { - background(200); - - // Calculate the circle's x-coordinate. - let x = frameCount; - - // Draw the circle. - // Normally, the circle would move from left to right. - circle(x, 50, 20); - } - -
- -
- - // Double-click to stop the draw loop. - - function setup() { - createCanvas(100, 100); - - // Slow the frame rate. - frameRate(5); - - describe('A white circle moves randomly on a gray background. It stops moving when the user double-clicks.'); - } - - function draw() { - background(200); - - // Calculate the circle's coordinates. - let x = random(0, 100); - let y = random(0, 100); - - // Draw the circle. - // Normally, the circle would move from left to right. - circle(x, y, 20); - } - - // Stop the draw loop when the user double-clicks. - function doubleClicked() { - noLoop(); - } - -
- -
- - let startButton; - let stopButton; - - function setup() { - createCanvas(100, 100); - - // Create the button elements and place them - // beneath the canvas. - startButton = createButton('▶'); - startButton.position(0, 100); - startButton.size(50, 20); - stopButton = createButton('◾'); - stopButton.position(50, 100); - stopButton.size(50, 20); - - // Set functions to call when the buttons are pressed. - startButton.mousePressed(loop); - stopButton.mousePressed(noLoop); - - // Slow the frame rate. - frameRate(5); - - describe( - 'A white circle moves randomly on a gray background. Play and stop buttons are shown beneath the canvas. The circle stops or starts moving when the user presses a button.' - ); - } - - function draw() { - background(200); - - // Calculate the circle's coordinates. - let x = random(0, 100); - let y = random(0, 100); - - // Draw the circle. - // Normally, the circle would move from left to right. - circle(x, y, 20); - } - -
-class: p5 -chainable: false ---- - - -# noLoop diff --git a/src/content/reference/en/p5 copy/noSmooth.mdx b/src/content/reference/en/p5 copy/noSmooth.mdx deleted file mode 100644 index a1af76d10d..0000000000 --- a/src/content/reference/en/p5 copy/noSmooth.mdx +++ /dev/null @@ -1,92 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L100 -title: noSmooth -module: Shape -submodule: Attributes -file: src/core/shape/attributes.js -description: > -

Draws certain features with jagged (aliased) edges.

- -

smooth() is active by default. In 2D - mode, - - noSmooth() is helpful for scaling up images without blurring. The - - functions don't affect shapes or fonts.

- -

In WebGL mode, noSmooth() causes all shapes to be drawn with - jagged - - (aliased) edges. The functions don't affect images or fonts.

-line: 100 -isConstructor: false -itemtype: method -example: - - |- - -
- - let heart; - - // Load a pixelated heart image from an image data string. - function preload() { - heart = loadImage('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAAXNSR0IArs4c6QAAAEZJREFUGFd9jcsNACAIQ9tB2MeR3YdBMBBq8CIXPi2vBICIiOwkOedatllqWO6Y8yOWoyuNf1GZwgmf+RRG2YXr+xVFmA8HZ9Mx/KGPMtcAAAAASUVORK5CYII='); - } - - function setup() { - createCanvas(100, 100); - - background(50); - - // Antialiased hearts. - image(heart, 10, 10); - image(heart, 20, 10, 16, 16); - image(heart, 40, 10, 32, 32); - - // Aliased hearts. - noSmooth(); - image(heart, 10, 60); - image(heart, 20, 60, 16, 16); - image(heart, 40, 60, 32, 32); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - circle(0, 0, 80); - - describe('A white circle on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - // Disable smoothing. - noSmooth(); - - background(200); - - circle(0, 0, 80); - - describe('A pixelated white circle on a gray background.'); - } - -
-class: p5 -chainable: true ---- - - -# noSmooth diff --git a/src/content/reference/en/p5 copy/noStroke.mdx b/src/content/reference/en/p5 copy/noStroke.mdx deleted file mode 100644 index 7c4fe80960..0000000000 --- a/src/content/reference/en/p5 copy/noStroke.mdx +++ /dev/null @@ -1,71 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1317 -title: noStroke -module: Color -submodule: Setting -file: src/color/setting.js -description: > -

Disables drawing points, lines, and the outlines of shapes.

- -

Calling noStroke() is the same as making the stroke completely - transparent, - - as in stroke(0, 0). If both noStroke() and - - noFill() are called, nothing will be drawn - to the - - screen.

-line: 1317 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - noStroke(); - square(20, 20, 60); - - describe('A white square with no outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A pink cube with no edge outlines spinning on a black canvas.'); - } - - function draw() { - background(0); - - // Style the box. - noStroke(); - fill(240, 150, 150); - - // Rotate the coordinates. - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - - // Draw the box. - box(45); - } - -
-class: p5 -chainable: true ---- - - -# noStroke diff --git a/src/content/reference/en/p5 copy/noTint.mdx b/src/content/reference/en/p5 copy/noTint.mdx deleted file mode 100644 index e3b0aeea19..0000000000 --- a/src/content/reference/en/p5 copy/noTint.mdx +++ /dev/null @@ -1,51 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L1345 -title: noTint -module: Image -submodule: Loading & Displaying -file: src/image/loading_displaying.js -description: > -

Removes the current tint set by tint().

- -

noTint() restores images to their original colors.

-line: 1345 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Left. - // Tint with a CSS color string. - tint('red'); - image(img, 0, 0); - - // Right. - // Remove the tint. - noTint(); - image(img, 50, 0); - - describe('Two images of an umbrella and a ceiling side-by-side. The image on the left has a red tint.'); - } - -
-class: p5 -chainable: false ---- - - -# noTint diff --git a/src/content/reference/en/p5 copy/noise.mdx b/src/content/reference/en/p5 copy/noise.mdx deleted file mode 100644 index 1b67f49cb9..0000000000 --- a/src/content/reference/en/p5 copy/noise.mdx +++ /dev/null @@ -1,282 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/noise.js#L36 -title: noise -module: Math -submodule: Noise -file: src/math/noise.js -description: > -

Returns random numbers that can be tuned to feel organic.

- -

Values returned by random() and - - randomGaussian() can change by - large - - amounts between function calls. By contrast, values returned by - noise() - - can be made "smooth". Calls to noise() with similar inputs will - produce - - similar outputs. noise() is used to create textures, motion, - shapes, - - terrains, and so on. Ken Perlin invented noise() while animating - the - - original Tron film in the 1980s.

- -

noise() always returns values between 0 and 1. It returns the - same value - - for a given input while a sketch is running. noise() produces - different - - results each time a sketch runs. The - - noiseSeed() function can be used to - generate - - the same sequence of Perlin noise values each time a sketch runs.

- -

The character of the noise can be adjusted in two ways. The first way is to - - scale the inputs. noise() interprets inputs as coordinates. The - sequence - - of noise values will be smoother when the input coordinates are closer. The - - second way is to use the noiseDetail() - - function.

- -

The version of noise() with one parameter computes noise - values in one - - dimension. This dimension can be thought of as space, as in - noise(x), or - - time, as in noise(t).

- -

The version of noise() with two parameters computes noise - values in two - - dimensions. These dimensions can be thought of as space, as in - - noise(x, y), or space and time, as in noise(x, - t).

- -

The version of noise() with three parameters computes noise - values in - - three dimensions. These dimensions can be thought of as space, as in - - noise(x, y, z), or space and time, as in noise(x, y, - t).

-line: 36 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A black dot moves randomly on a gray square.'); - } - - function draw() { - background(200); - - // Calculate the coordinates. - let x = 100 * noise(0.005 * frameCount); - let y = 100 * noise(0.005 * frameCount + 10000); - - // Draw the point. - strokeWeight(5); - point(x, y); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A black dot moves randomly on a gray square.'); - } - - function draw() { - background(200); - - // Set the noise level and scale. - let noiseLevel = 100; - let noiseScale = 0.005; - - // Scale the input coordinate. - let nt = noiseScale * frameCount; - - // Compute the noise values. - let x = noiseLevel * noise(nt); - let y = noiseLevel * noise(nt + 10000); - - // Draw the point. - strokeWeight(5); - point(x, y); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A hilly terrain drawn in gray against a black sky.'); - } - - function draw() { - // Set the noise level and scale. - let noiseLevel = 100; - let noiseScale = 0.02; - - // Scale the input coordinate. - let x = frameCount; - let nx = noiseScale * x; - - // Compute the noise value. - let y = noiseLevel * noise(nx); - - // Draw the line. - line(x, 0, x, y); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A calm sea drawn in gray against a black sky.'); - } - - function draw() { - background(200); - - // Set the noise level and scale. - let noiseLevel = 100; - let noiseScale = 0.002; - - // Iterate from left to right. - for (let x = 0; x < width; x += 1) { - // Scale the input coordinates. - let nx = noiseScale * x; - let nt = noiseScale * frameCount; - - // Compute the noise value. - let y = noiseLevel * noise(nx, nt); - - // Draw the line. - line(x, 0, x, y); - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Set the noise level and scale. - let noiseLevel = 255; - let noiseScale = 0.01; - - // Iterate from top to bottom. - for (let y = 0; y < height; y += 1) { - // Iterate from left to right. - for (let x = 0; x < width; x += 1) { - // Scale the input coordinates. - let nx = noiseScale * x; - let ny = noiseScale * y; - - // Compute the noise value. - let c = noiseLevel * noise(nx, ny); - - // Draw the point. - stroke(c); - point(x, y); - } - } - - describe('A gray cloudy pattern.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A gray cloudy pattern that changes.'); - } - - function draw() { - // Set the noise level and scale. - let noiseLevel = 255; - let noiseScale = 0.009; - - // Iterate from top to bottom. - for (let y = 0; y < height; y += 1) { - // Iterate from left to right. - for (let x = 0; x < width; x += 1) { - // Scale the input coordinates. - let nx = noiseScale * x; - let ny = noiseScale * y; - let nt = noiseScale * frameCount; - - // Compute the noise value. - let c = noiseLevel * noise(nx, ny, nt); - - // Draw the point. - stroke(c); - point(x, y); - } - } - } - -
-class: p5 -params: - - name: x - description: | -

x-coordinate in noise space.

- type: Number - - name: 'y' - description: | -

y-coordinate in noise space.

- type: Number - optional: true - - name: z - description: | -

z-coordinate in noise space.

- type: Number - optional: true -return: - description: Perlin noise value at specified coordinates. - type: Number -chainable: false ---- - - -# noise diff --git a/src/content/reference/en/p5 copy/noiseDetail.mdx b/src/content/reference/en/p5 copy/noiseDetail.mdx deleted file mode 100644 index 973ac515ab..0000000000 --- a/src/content/reference/en/p5 copy/noiseDetail.mdx +++ /dev/null @@ -1,100 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/noise.js#L331 -title: noiseDetail -module: Math -submodule: Noise -file: src/math/noise.js -description: > -

Adjusts the character of the noise produced by the - - noise() function.

- -

Perlin noise values are created by adding layers of noise together. The - - noise layers, called octaves, are similar to harmonics in music. Lower - - octaves contribute more to the output signal. They define the overall - - intensity of the noise. Higher octaves create finer-grained details.

- -

By default, noise values are created by combining four octaves. Each higher - - octave contributes half as much (50% less) compared to its predecessor. - - noiseDetail() changes the number of octaves and the falloff - amount. For - - example, calling noiseDetail(6, 0.25) ensures that - - noise() will use six octaves. Each higher - octave - - will contribute 25% as much (75% less) compared to its predecessor. Falloff - - values between 0 and 1 are valid. However, falloff values greater than 0.5 - - might result in noise values greater than 1.

-line: 331 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Set the noise level and scale. - let noiseLevel = 255; - let noiseScale = 0.02; - - // Iterate from top to bottom. - for (let y = 0; y < height; y += 1) { - // Iterate from left to right. - for (let x = 0; x < width / 2; x += 1) { - // Scale the input coordinates. - let nx = noiseScale * x; - let ny = noiseScale * y; - - // Compute the noise value with six octaves - // and a low falloff factor. - noiseDetail(6, 0.25); - let c = noiseLevel * noise(nx, ny); - - // Draw the left side. - stroke(c); - point(x, y); - - // Compute the noise value with four octaves - // and a high falloff factor. - noiseDetail(4, 0.5); - c = noiseLevel * noise(nx, ny); - - // Draw the right side. - stroke(c); - point(x + 50, y); - } - } - - describe('Two gray cloudy patterns. The pattern on the right is cloudier than the pattern on the left.'); - } - -
-class: p5 -params: - - name: lod - description: | -

number of octaves to be used by the noise.

- type: Number - - name: falloff - description: | -

falloff factor for each octave.

- type: Number -chainable: false ---- - - -# noiseDetail diff --git a/src/content/reference/en/p5 copy/noiseSeed.mdx b/src/content/reference/en/p5 copy/noiseSeed.mdx deleted file mode 100644 index a1f2ce6fbd..0000000000 --- a/src/content/reference/en/p5 copy/noiseSeed.mdx +++ /dev/null @@ -1,68 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/noise.js#L405 -title: noiseSeed -module: Math -submodule: Noise -file: src/math/noise.js -description: > -

Sets the seed value for the noise() - function.

- -

By default, noise() produces different - results - - each time a sketch is run. Calling noiseSeed() with a constant - argument, - - such as noiseSeed(99), makes noise() produce the - - same results each time a sketch is run.

-line: 405 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Set the noise seed for consistent results. - noiseSeed(99); - - describe('A black rectangle that grows randomly, first to the right and then to the left.'); - } - - function draw() { - // Set the noise level and scale. - let noiseLevel = 100; - let noiseScale = 0.005; - - // Scale the input coordinate. - let nt = noiseScale * frameCount; - - // Compute the noise value. - let x = noiseLevel * noise(nt); - - // Draw the line. - line(x, 0, x, height); - } - -
-class: p5 -params: - - name: seed - description: | -

seed value.

- type: Number -chainable: false ---- - - -# noiseSeed diff --git a/src/content/reference/en/p5 copy/norm.mdx b/src/content/reference/en/p5 copy/norm.mdx deleted file mode 100644 index d52a73e4c5..0000000000 --- a/src/content/reference/en/p5 copy/norm.mdx +++ /dev/null @@ -1,69 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L772 -title: norm -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Maps a number from one range to a value between 0 and 1.

- -

For example, norm(2, 0, 10) returns 0.2. 2's position in the - original - - range [0, 10] is proportional to 0.2's position in the range [0, 1]. This - - is the same as calling map(2, 0, 10, 0, 1).

- -

Numbers outside of the original range are not constrained between 0 and 1. - - Out-of-range values are often intentional and useful.

-line: 772 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Use RGB color with values from 0 to 1. - colorMode(RGB, 1); - - describe('A square changes color from black to red as the mouse moves from left to right.'); - } - - function draw() { - // Calculate the redValue. - let redValue = norm(mouseX, 0, 100); - - // Paint the background. - background(redValue, 0, 0); - } - -
-class: p5 -params: - - name: value - description: | -

incoming value to be normalized.

- type: Number - - name: start - description: | -

lower bound of the value's current range.

- type: Number - - name: stop - description: | -

upper bound of the value's current range.

- type: Number -return: - description: normalized number. - type: Number -chainable: false ---- - - -# norm diff --git a/src/content/reference/en/p5 copy/normal.mdx b/src/content/reference/en/p5 copy/normal.mdx deleted file mode 100644 index a109745b80..0000000000 --- a/src/content/reference/en/p5 copy/normal.mdx +++ /dev/null @@ -1,250 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L2097 -title: normal -module: Shape -submodule: Vertex -file: src/core/shape/vertex.js -description: > -

Sets the normal vector for vertices in a custom 3D shape.

- -

3D shapes created with beginShape() - and - - endShape() are made by connecting sets - of - - points called vertices. Each vertex added with - - vertex() has a normal vector that points - away - - from it. The normal vector controls how light reflects off the shape.

- -

normal() can be called two ways with different parameters to - define the - - normal vector's components.

- -

The first way to call normal() has three parameters, - x, y, and z. - - If Numbers are passed, as in normal(1, 2, 3), they - set the x-, y-, and - - z-components of the normal vector.

- -

The second way to call normal() has one parameter, - vector. If a - - p5.Vector object is passed, as in - - normal(myVector), its components will be used to set the normal - vector.

- -

normal() changes the normal vector of vertices added to a - custom shape - - with vertex(). normal() must - be called between - - the beginShape() and - - endShape() functions, just like - - vertex(). The normal vector set by calling - - normal() will affect all following vertices until - normal() is called - - again:

- -
beginShape();
-
-
-  // Set the vertex normal.
-
-  normal(-0.4, -0.4, 0.8);
-
-
-  // Add a vertex.
-
-  vertex(-30, -30, 0);
-
-
-  // Set the vertex normal.
-
-  normal(0, 0, 1);
-
-
-  // Add vertices.
-
-  vertex(30, -30, 0);
-
-  vertex(30, 30, 0);
-
-
-  // Set the vertex normal.
-
-  normal(0.4, -0.4, 0.8);
-
-
-  // Add a vertex.
-
-  vertex(-30, 30, 0);
-
-
-  endShape();
-
-  
-line: 2097 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click the and drag the mouse to view the scene from a different angle. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'A colorful square on a black background. The square changes color and rotates when the user drags the mouse. Parts of its surface reflect light in different directions.' - ); - } - - function draw() { - background(0); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the shape. - normalMaterial(); - noStroke(); - - // Draw the shape. - beginShape(); - vertex(-30, -30, 0); - vertex(30, -30, 0); - vertex(30, 30, 0); - vertex(-30, 30, 0); - endShape(); - } - -
- -
- - // Click the and drag the mouse to view the scene from a different angle. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'A colorful square on a black background. The square changes color and rotates when the user drags the mouse. Parts of its surface reflect light in different directions.' - ); - } - - function draw() { - background(0); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the shape. - normalMaterial(); - noStroke(); - - // Draw the shape. - // Use normal() to set vertex normals. - beginShape(); - normal(-0.4, -0.4, 0.8); - vertex(-30, -30, 0); - - normal(0, 0, 1); - vertex(30, -30, 0); - vertex(30, 30, 0); - - normal(0.4, -0.4, 0.8); - vertex(-30, 30, 0); - endShape(); - } - -
- -
- - // Click the and drag the mouse to view the scene from a different angle. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'A colorful square on a black background. The square changes color and rotates when the user drags the mouse. Parts of its surface reflect light in different directions.' - ); - } - - function draw() { - background(0); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the shape. - normalMaterial(); - noStroke(); - - // Create p5.Vector objects. - let n1 = createVector(-0.4, -0.4, 0.8); - let n2 = createVector(0, 0, 1); - let n3 = createVector(0.4, -0.4, 0.8); - - // Draw the shape. - // Use normal() to set vertex normals. - beginShape(); - normal(n1); - vertex(-30, -30, 0); - - normal(n2); - vertex(30, -30, 0); - vertex(30, 30, 0); - - normal(n3); - vertex(-30, 30, 0); - endShape(); - } - -
-class: p5 -overloads: - - line: 2097 - params: - - name: vector - description: | -

vertex normal as a p5.Vector object.

- type: p5.Vector - chainable: 1 - - line: 2272 - params: - - name: x - description: | -

x-component of the vertex normal.

- type: Number - - name: 'y' - description: | -

y-component of the vertex normal.

- type: Number - - name: z - description: | -

z-component of the vertex normal.

- type: Number - chainable: 1 -chainable: true ---- - - -# normal diff --git a/src/content/reference/en/p5 copy/normalMaterial.mdx b/src/content/reference/en/p5 copy/normalMaterial.mdx deleted file mode 100644 index 0652b349d4..0000000000 --- a/src/content/reference/en/p5 copy/normalMaterial.mdx +++ /dev/null @@ -1,55 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2365 -title: normalMaterial -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Sets the current material as a normal material.

- -

A normal material sets surfaces facing the x-axis to red, those facing the - - y-axis to green, and those facing the z-axis to blue. Normal material isn't - - affected by light. It’s often used as a placeholder material when - debugging.

- -

Note: normalMaterial() can only be used in WebGL mode.

-line: 2365 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A multicolor torus drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the torus. - normalMaterial(); - - // Draw the torus. - torus(30); - } - -
-class: p5 -chainable: true ---- - - -# normalMaterial diff --git a/src/content/reference/en/p5 copy/orbitControl.mdx b/src/content/reference/en/p5 copy/orbitControl.mdx deleted file mode 100644 index be2fd25452..0000000000 --- a/src/content/reference/en/p5 copy/orbitControl.mdx +++ /dev/null @@ -1,203 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/interaction.js#L11 -title: orbitControl -module: 3D -submodule: Interaction -file: src/webgl/interaction.js -description: > -

Allows the user to orbit around a 3D sketch using a mouse, trackpad, or - - touchscreen.

- -

3D sketches are viewed through an imaginary camera. Calling - - orbitControl() within the draw() function allows - - the user to change the camera’s position:

- -
function draw() {
-    background(200);
-
-    // Enable orbiting with the mouse.
-    orbitControl();
-
-    // Rest of sketch.
-  }
-
-  
- -

Left-clicking and dragging or swipe motion will rotate the camera position - - about the center of the sketch. Right-clicking and dragging or multi-swipe - - will pan the camera position without rotation. Using the mouse wheel - - (scrolling) or pinch in/out will move the camera further or closer from the - - center of the sketch.

- -

The first three parameters, sensitivityX, - sensitivityY, and - - sensitivityZ, are optional. They’re numbers that set the sketch’s - - sensitivity to movement along each axis. For example, calling - - orbitControl(1, 2, -1) keeps movement along the x-axis at its - default - - value, makes the sketch twice as sensitive to movement along the y-axis, - - and reverses motion along the z-axis. By default, all sensitivity values - - are 1.

- -

The fourth parameter, options, is also optional. It’s an - object that - - changes the behavior of orbiting. For example, calling - - orbitControl(1, 1, 1, options) keeps the default sensitivity - values while - - changing the behaviors set with options. The object can have the - - following properties:

- -
let options = {
-    // Setting this to false makes mobile interactions smoother by
-    // preventing accidental interactions with the page while orbiting.
-    // By default, it's true.
-    disableTouchActions: true,
-
-    // Setting this to true makes the camera always rotate in the
-    // direction the mouse/touch is moving.
-    // By default, it's false.
-    freeRotation: false
-  };
-
-
-  orbitControl(1, 1, 1, options);
-
-  
-line: 11 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A multicolor box on a gray background. The camera angle changes when the user interacts using a mouse, trackpad, or touchscreen.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the box. - normalMaterial(); - - // Draw the box. - box(30, 50); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A multicolor box on a gray background. The camera angle changes when the user interacts using a mouse, trackpad, or touchscreen.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - // Make the interactions 3X sensitive. - orbitControl(3, 3, 3); - - // Style the box. - normalMaterial(); - - // Draw the box. - box(30, 50); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A multicolor box on a gray background. The camera angle changes when the user interacts using a mouse, trackpad, or touchscreen.'); - } - - function draw() { - background(200); - - // Create an options object. - let options = { - disableTouchActions: false, - freeRotation: true - }; - - // Enable orbiting with the mouse. - // Prevent accidental touch actions on touchscreen devices - // and enable free rotation. - orbitControl(1, 1, 1, options); - - // Style the box. - normalMaterial(); - - // Draw the box. - box(30, 50); - } - -
-class: p5 -params: - - name: sensitivityX - description: | -

sensitivity to movement along the x-axis. Defaults to 1.

- type: Number - optional: true - - name: sensitivityY - description: | -

sensitivity to movement along the y-axis. Defaults to 1.

- type: Number - optional: true - - name: sensitivityZ - description: | -

sensitivity to movement along the z-axis. Defaults to 1.

- type: Number - optional: true - - name: options - description: | -

object with two optional properties, disableTouchActions - and freeRotation. Both are Booleans. disableTouchActions - defaults to true and freeRotation defaults to false.

- type: Object - optional: true -chainable: true ---- - - -# orbitControl diff --git a/src/content/reference/en/p5 copy/ortho.mdx b/src/content/reference/en/p5 copy/ortho.mdx deleted file mode 100644 index 5fb384ba48..0000000000 --- a/src/content/reference/en/p5 copy/ortho.mdx +++ /dev/null @@ -1,168 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L412 -title: ortho -module: 3D -submodule: Camera -file: src/webgl/p5.Camera.js -description: > -

Sets an orthographic projection for the current camera in a 3D sketch.

- -

In an orthographic projection, shapes with the same size always appear the - - same size, regardless of whether they are near or far from the camera.

- -

ortho() changes the camera’s perspective by changing its - viewing frustum - - from a truncated pyramid to a rectangular prism. The camera is placed in - - front of the frustum and views everything between the frustum’s near plane - - and its far plane. ortho() has six optional parameters to define - the - - frustum.

- -

The first four parameters, left, right, - bottom, and top, set the - - coordinates of the frustum’s sides, bottom, and top. For example, calling - - ortho(-100, 100, 200, -200) creates a frustum that’s 200 pixels - wide and - - 400 pixels tall. By default, these coordinates are set based on the - - sketch’s width and height, as in - - ortho(-width / 2, width / 2, -height / 2, height / 2).

- -

The last two parameters, near and far, set the - distance of the - - frustum’s near and far plane from the camera. For example, calling - - ortho(-100, 100, 200, 200, 50, 1000) creates a frustum that’s 200 - pixels - - wide, 400 pixels tall, starts 50 pixels from the camera, and ends 1,000 - - pixels from the camera. By default, near and far are - set to 0 and - - max(width, height) + 800, respectively.

- -

Note: ortho() can only be used in WebGL mode.

-line: 412 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A row of tiny, white cubes on a gray background. All the cubes appear the same size.'); - } - - function draw() { - background(200); - - // Apply an orthographic projection. - ortho(); - - // Translate the origin toward the camera. - translate(-10, 10, 600); - - // Rotate the coordinate system. - rotateY(-0.1); - rotateX(-0.1); - - // Draw the row of boxes. - for (let i = 0; i < 6; i += 1) { - translate(0, 0, -40); - box(10); - } - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Apply an orthographic projection. - // Center the frustum. - // Set its width and height to 20. - // Place its near plane 300 pixels from the camera. - // Place its far plane 350 pixels from the camera. - ortho(-10, 10, -10, 10, 300, 350); - - // Translate the origin toward the camera. - translate(-10, 10, 600); - - // Rotate the coordinate system. - rotateY(-0.1); - rotateX(-0.1); - - // Draw the row of boxes. - for (let i = 0; i < 6; i += 1) { - translate(0, 0, -40); - box(10); - } - } - -
-class: p5 -params: - - name: left - description: > -

x-coordinate of the frustum’s left plane. Defaults to -width / - 2.

- type: Number - optional: true - - name: right - description: > -

x-coordinate of the frustum’s right plane. Defaults to width / - 2.

- type: Number - optional: true - - name: bottom - description: > -

y-coordinate of the frustum’s bottom plane. Defaults to height / - 2.

- type: Number - optional: true - - name: top - description: > -

y-coordinate of the frustum’s top plane. Defaults to -height / - 2.

- type: Number - optional: true - - name: near - description: | -

z-coordinate of the frustum’s near plane. Defaults to 0.

- type: Number - optional: true - - name: far - description: > -

z-coordinate of the frustum’s far plane. Defaults to max(width, - height) + 800.

- type: Number - optional: true -chainable: true ---- - - -# ortho diff --git a/src/content/reference/en/p5 copy/outputVolume.mdx b/src/content/reference/en/p5 copy/outputVolume.mdx deleted file mode 100644 index fe618922fb..0000000000 --- a/src/content/reference/en/p5 copy/outputVolume.mdx +++ /dev/null @@ -1,51 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L738 -title: outputVolume -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: |- -

Scale the output of all sound in this sketch

- Scaled between 0.0 (silence) and 1.0 (full volume). - 1.0 is the maximum amplitude of a digital sound, so multiplying - by greater than 1.0 may cause digital distortion. To - fade, provide a rampTime parameter. For more - complex fades, see the Envelope class. - -

Alternately, you can pass in a signal source such as an - oscillator to modulate the amplitude with an audio signal.

-

How This Works: When you load the p5.sound module, it - creates a single instance of p5sound. All sound objects in this - module output to p5sound before reaching your computer's output. - So if you change the amplitude of p5sound, it impacts all of the - sound in this module.

- -

If no value is provided, returns a Web Audio API Gain Node

-line: 738 -isConstructor: false -itemtype: method -class: p5 -params: - - name: volume - description: | -

Volume (amplitude) between 0.0 - and 1.0 or modulating signal/oscillator

- type: Number|Object - - name: rampTime - description: | -

Fade for t seconds

- type: Number - optional: true - - name: timeFromNow - description: | -

Schedule this event to happen at - t seconds in the future

- type: Number - optional: true -chainable: false ---- - - -# outputVolume diff --git a/src/content/reference/en/p5 copy/p5.Camera.mdx b/src/content/reference/en/p5 copy/p5.Camera.mdx deleted file mode 100644 index cc2090e329..0000000000 --- a/src/content/reference/en/p5 copy/p5.Camera.mdx +++ /dev/null @@ -1,659 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L723 -title: p5.Camera -module: 3D -submodule: Camera -file: src/webgl/p5.Camera.js -description: > -

A class to describe a camera for viewing a 3D sketch.

- -

Each p5.Camera object represents a camera that views a section - of 3D - - space. It stores information about the camera’s position, orientation, and - - projection.

- -

In WebGL mode, the default camera is a p5.Camera object that - can be - - controlled with the camera(), - - perspective(), - - ortho(), and - - frustum() functions. Additional cameras - can be - - created with createCamera() and - activated - - with setCamera().

- -

Note: p5.Camera’s methods operate in two coordinate - systems:

- -
    - -
  • The “world” coordinate system describes positions in terms of their - - relationship to the origin along the x-, y-, and z-axes. For example, - - calling myCamera.setPosition() places the camera in 3D space - using - - "world" coordinates.
  • - -
  • The "local" coordinate system describes positions from the camera's point - - of view: left-right, up-down, and forward-backward. For example, calling - - myCamera.move() moves the camera along its own axes.
  • - -
-line: 723 -isConstructor: true -params: - - name: rendererGL - description: | -

instance of WebGL renderer

- type: RendererGL -example: - - |- - -
- - let cam; - let delta = 0.001; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Camera object. - cam = createCamera(); - - // Place the camera at the top-center. - cam.setPosition(0, -400, 800); - - // Point the camera at the origin. - cam.lookAt(0, 0, 0); - - describe( - 'A white cube on a gray background. The cube goes in and out of view as the camera pans left and right.' - ); - } - - function draw() { - background(200); - - // Turn the camera left and right, called "panning". - cam.pan(delta); - - // Switch directions every 120 frames. - if (frameCount % 120 === 0) { - delta *= -1; - } - - // Draw the box. - box(); - } - -
- -
- - // Double-click to toggle between cameras. - - let cam1; - let cam2; - let isDefaultCamera = true; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the first camera. - // Keep its default settings. - cam1 = createCamera(); - - // Create the second camera. - // Place it at the top-left. - // Point it at the origin. - cam2 = createCamera(); - cam2.setPosition(400, -400, 800); - cam2.lookAt(0, 0, 0); - - // Set the current camera to cam1. - setCamera(cam1); - - describe( - 'A white cube on a gray background. The camera toggles between frontal and aerial views when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Draw the box. - box(); - } - - // Toggle the current camera when the user double-clicks. - function doubleClicked() { - if (isDefaultCamera === true) { - setCamera(cam2); - isDefaultCamera = false; - } else { - setCamera(cam1); - isDefaultCamera = true; - } - } - -
-methods: - perspective: - description: > -

Sets a perspective projection for the camera.

- -

In a perspective projection, shapes that are further from the camera - appear - - smaller than shapes that are near the camera. This technique, called - - foreshortening, creates realistic 3D scenes. It’s applied by default in - new - - p5.Camera objects.

- -

myCamera.perspective() changes the camera’s perspective by - changing its - - viewing frustum. The frustum is the volume of space that’s visible to the - - camera. The frustum’s shape is a pyramid with its top cut off. The camera - - is placed where the top of the pyramid should be and points towards the - - base of the pyramid. It views everything within the frustum.

- -

The first parameter, fovy, is the camera’s vertical field - of view. It’s - - an angle that describes how tall or narrow a view the camera has. For - - example, calling myCamera.perspective(0.5) sets the camera’s - vertical - - field of view to 0.5 radians. By default, fovy is calculated - based on the - - sketch’s height and the camera’s default z-coordinate, which is 800. The - - formula for the default fovy is 2 * atan(height / 2 / - 800).

- -

The second parameter, aspect, is the camera’s aspect - ratio. It’s a number - - that describes the ratio of the top plane’s width to its height. For - - example, calling myCamera.perspective(0.5, 1.5) sets the - camera’s field - - of view to 0.5 radians and aspect ratio to 1.5, which would make shapes - - appear thinner on a square canvas. By default, aspect is set - to - - width / height.

- -

The third parameter, near, is the distance from the camera - to the near - - plane. For example, calling myCamera.perspective(0.5, 1.5, - 100) sets the - - camera’s field of view to 0.5 radians, its aspect ratio to 1.5, and places - - the near plane 100 pixels from the camera. Any shapes drawn less than 100 - - pixels from the camera won’t be visible. By default, near is - set to - - 0.1 * 800, which is 1/10th the default distance between the - camera and - - the origin.

- -

The fourth parameter, far, is the distance from the camera - to the far - - plane. For example, calling myCamera.perspective(0.5, 1.5, 100, - 10000) - - sets the camera’s field of view to 0.5 radians, its aspect ratio to 1.5, - - places the near plane 100 pixels from the camera, and places the far plane - - 10,000 pixels from the camera. Any shapes drawn more than 10,000 pixels - - from the camera won’t be visible. By default, far is set to - 10 * 800, - - which is 10 times the default distance between the camera and the - origin.

- path: p5.Camera/perspective - ortho: - description: > -

Sets an orthographic projection for the camera.

- -

In an orthographic projection, shapes with the same size always appear - the - - same size, regardless of whether they are near or far from the camera.

- -

myCamera.ortho() changes the camera’s perspective by - changing its viewing - - frustum from a truncated pyramid to a rectangular prism. The frustum is - the - - volume of space that’s visible to the camera. The camera is placed in - front - - of the frustum and views everything within the frustum. - myCamera.ortho() - - has six optional parameters to define the viewing frustum.

- -

The first four parameters, left, right, - bottom, and top, set the - - coordinates of the frustum’s sides, bottom, and top. For example, calling - - myCamera.ortho(-100, 100, 200, -200) creates a frustum that’s - 200 pixels - - wide and 400 pixels tall. By default, these dimensions are set based on - - the sketch’s width and height, as in - - myCamera.ortho(-width / 2, width / 2, -height / 2, height / - 2).

- -

The last two parameters, near and far, set - the distance of the - - frustum’s near and far plane from the camera. For example, calling - - myCamera.ortho(-100, 100, 200, -200, 50, 1000) creates a - frustum that’s - - 200 pixels wide, 400 pixels tall, starts 50 pixels from the camera, and - - ends 1,000 pixels from the camera. By default, near and - far are set to - - 0 and max(width, height) + 800, respectively.

- path: p5.Camera/ortho - frustum: - description: > -

Sets the camera's frustum.

- -

In a frustum projection, shapes that are further from the camera appear - - smaller than shapes that are near the camera. This technique, called - - foreshortening, creates realistic 3D scenes.

- -

myCamera.frustum() changes the camera’s perspective by - changing its - - viewing frustum. The frustum is the volume of space that’s visible to the - - camera. The frustum’s shape is a pyramid with its top cut off. The camera - - is placed where the top of the pyramid should be and points towards the - - base of the pyramid. It views everything within the frustum.

- -

The first four parameters, left, right, - bottom, and top, set the - - coordinates of the frustum’s sides, bottom, and top. For example, calling - - myCamera.frustum(-100, 100, 200, -200) creates a frustum - that’s 200 - - pixels wide and 400 pixels tall. By default, these coordinates are set - - based on the sketch’s width and height, as in - - myCamera.frustum(-width / 20, width / 20, height / 20, -height / - 20).

- -

The last two parameters, near and far, set - the distance of the - - frustum’s near and far plane from the camera. For example, calling - - myCamera.frustum(-100, 100, 200, -200, 50, 1000) creates a - frustum that’s - - 200 pixels wide, 400 pixels tall, starts 50 pixels from the camera, and - ends - - 1,000 pixels from the camera. By default, near is set to 0.1 * - 800, which - - is 1/10th the default distance between the camera and the origin. - far is - - set to 10 * 800, which is 10 times the default distance - between the - - camera and the origin.

- path: p5.Camera/frustum - roll: - description: > -

Rotates the camera in a clockwise/counter-clockwise direction.

- -

Rolling rotates the camera without changing its orientation. The - rotation - - happens in the camera’s "local" space.

- -

The parameter, angle, is the angle the camera should - rotate. Passing a - - positive angle, as in myCamera.roll(0.001), rotates the - camera in counter-clockwise direction. - - Passing a negative angle, as in myCamera.roll(-0.001), - rotates the - - camera in clockwise direction.

- -

Note: Angles are interpreted based on the current - - angleMode().

- path: p5.Camera/roll - pan: - description: > -

Rotates the camera left and right.

- -

Panning rotates the camera without changing its position. The rotation - - happens in the camera’s "local" space.

- -

The parameter, angle, is the angle the camera should - rotate. Passing a - - positive angle, as in myCamera.pan(0.001), rotates the camera - to the - - right. Passing a negative angle, as in myCamera.pan(-0.001), - rotates the - - camera to the left.

- -

Note: Angles are interpreted based on the current - - angleMode().

- path: p5.Camera/pan - tilt: - description: > -

Rotates the camera up and down.

- -

Tilting rotates the camera without changing its position. The rotation - - happens in the camera’s "local" space.

- -

The parameter, angle, is the angle the camera should - rotate. Passing a - - positive angle, as in myCamera.tilt(0.001), rotates the - camera down. - - Passing a negative angle, as in myCamera.tilt(-0.001), - rotates the camera - - up.

- -

Note: Angles are interpreted based on the current - - angleMode().

- path: p5.Camera/tilt - lookAt: - description: > -

Points the camera at a location.

- -

myCamera.lookAt() changes the camera’s orientation without - changing its - - position.

- -

The parameters, x, y, and z, are - the coordinates in "world" space - - where the camera should point. For example, calling - - myCamera.lookAt(10, 20, 30) points the camera at the - coordinates - - (10, 20, 30).

- path: p5.Camera/lookAt - camera: - description: > -

Sets the position and orientation of the camera.

- -

myCamera.camera() allows objects to be viewed from - different angles. It - - has nine parameters that are all optional.

- -

The first three parameters, x, y, and - z, are the coordinates of the - - camera’s position in "world" space. For example, calling - - myCamera.camera(0, 0, 0) places the camera at the origin - (0, 0, 0). By - - default, the camera is placed at (0, 0, 800).

- -

The next three parameters, centerX, centerY, - and centerZ are the - - coordinates of the point where the camera faces in "world" space. For - - example, calling myCamera.camera(0, 0, 0, 10, 20, 30) places - the camera - - at the origin (0, 0, 0) and points it at (10, 20, - 30). By default, the - - camera points at the origin (0, 0, 0).

- -

The last three parameters, upX, upY, and - upZ are the components of - - the "up" vector in "local" space. The "up" vector orients the camera’s - - y-axis. For example, calling - - myCamera.camera(0, 0, 0, 10, 20, 30, 0, -1, 0) places the - camera at the - - origin (0, 0, 0), points it at (10, 20, 30), and - sets the "up" vector - - to (0, -1, 0) which is like holding it upside-down. By - default, the "up" - - vector is (0, 1, 0).

- path: p5.Camera/camera - move: - description: > -

Moves the camera along its "local" axes without changing its - orientation.

- -

The parameters, x, y, and z, are - the distances the camera should - - move. For example, calling myCamera.move(10, 20, 30) moves - the camera 10 - - pixels to the right, 20 pixels down, and 30 pixels backward in its "local" - - space.

- path: p5.Camera/move - setPosition: - description: > -

Sets the camera’s position in "world" space without changing its - - orientation.

- -

The parameters, x, y, and z, are - the coordinates where the camera - - should be placed. For example, calling myCamera.setPosition(10, 20, - 30) - - places the camera at coordinates (10, 20, 30) in "world" - space.

- path: p5.Camera/setPosition - set: - description: > -

Sets the camera’s position, orientation, and projection by copying - another - - camera.

- -

The parameter, cam, is the p5.Camera object - to copy. For example, calling - - cam2.set(cam1) will set cam2 using - cam1’s configuration.

- path: p5.Camera/set - slerp: - description: > -

Sets the camera’s position and orientation to values that are - in-between - - those of two other cameras.

- -

myCamera.slerp() uses spherical linear interpolation to - calculate a - - position and orientation that’s in-between two other cameras. Doing so is - - helpful for transitioning smoothly between two perspectives.

- -

The first two parameters, cam0 and cam1, are - the p5.Camera objects - - that should be used to set the current camera.

- -

The third parameter, amt, is the amount to interpolate - between cam0 and - - cam1. 0.0 keeps the camera’s position and orientation equal - to cam0’s, - - 0.5 sets them halfway between cam0’s and cam1’s - , and 1.0 sets the - - position and orientation equal to cam1’s.

- -

For example, calling myCamera.slerp(cam0, cam1, 0.1) sets - cam’s position - - and orientation very close to cam0’s. Calling - - myCamera.slerp(cam0, cam1, 0.9) sets cam’s position and - orientation very - - close to cam1’s.

- -

Note: All of the cameras must use the same projection.

- path: p5.Camera/slerp -properties: - eyeX: - description: | -

The camera’s x-coordinate.

-

By default, the camera’s x-coordinate is set to 0 in "world" space.

- path: p5.Camera/eyeX - eyeY: - description: | -

The camera’s y-coordinate.

-

By default, the camera’s y-coordinate is set to 0 in "world" space.

- path: p5.Camera/eyeY - eyeZ: - description: > -

The camera’s z-coordinate.

- -

By default, the camera’s z-coordinate is set to 800 in "world" - space.

- path: p5.Camera/eyeZ - centerX: - description: > -

The x-coordinate of the place where the camera looks.

- -

By default, the camera looks at the origin (0, 0, 0) in - "world" space, so - - myCamera.centerX is 0.

- path: p5.Camera/centerX - centerY: - description: > -

The y-coordinate of the place where the camera looks.

- -

By default, the camera looks at the origin (0, 0, 0) in - "world" space, so - - myCamera.centerY is 0.

- path: p5.Camera/centerY - centerZ: - description: > -

The y-coordinate of the place where the camera looks.

- -

By default, the camera looks at the origin (0, 0, 0) in - "world" space, so - - myCamera.centerZ is 0.

- path: p5.Camera/centerZ - upX: - description: > -

The x-component of the camera's "up" vector.

- -

The camera's "up" vector orients its y-axis. By default, the "up" - vector is - - (0, 1, 0), so its x-component is 0 in "local" space.

- path: p5.Camera/upX - upY: - description: > -

The y-component of the camera's "up" vector.

- -

The camera's "up" vector orients its y-axis. By default, the "up" - vector is - - (0, 1, 0), so its y-component is 1 in "local" space.

- path: p5.Camera/upY - upZ: - description: > -

The z-component of the camera's "up" vector.

- -

The camera's "up" vector orients its y-axis. By default, the "up" - vector is - - (0, 1, 0), so its z-component is 0 in "local" space.

- path: p5.Camera/upZ -chainable: false ---- - - -# p5.Camera diff --git a/src/content/reference/en/p5 copy/p5.Color.mdx b/src/content/reference/en/p5 copy/p5.Color.mdx deleted file mode 100644 index b804e5ee95..0000000000 --- a/src/content/reference/en/p5 copy/p5.Color.mdx +++ /dev/null @@ -1,116 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/p5.Color.js#L318 -title: p5.Color -module: Color -submodule: Creating & Reading -file: src/color/p5.Color.js -description: > -

A class to describe a color.

- -

Each p5.Color object stores the color mode - - and level maxes that were active during its construction. These values are - - used to interpret the arguments passed to the object's constructor. They - - also determine output formatting such as when - - saturation() is called.

- -

Color is stored internally as an array of ideal RGBA values in floating - - point form, normalized from 0 to 1. These values are used to calculate the - - closest screen colors, which are RGBA levels from 0 to 255. Screen colors - - are sent to the renderer.

- -

When different color representations are calculated, the results are cached - - for performance. These values are normalized, floating-point numbers.

- -

Note: color() is the recommended way to - create an - - instance of this class.

-line: 318 -isConstructor: true -params: - - name: pInst - description: | -

pointer to p5 instance.

- type: P5 - optional: true - - name: vals - description: | -

an array containing the color values - for red, green, blue and alpha channel - or CSS color.

- type: 'Number[]|String' -methods: - toString: - description: > -

Returns the color formatted as a String.

- -

Calling myColor.toString() can be useful for debugging, as - in - - print(myColor.toString()). It's also helpful for using p5.js - with other - - libraries.

- -

The parameter, format, is optional. If a format string is - passed, as in - - myColor.toString('#rrggbb'), it will determine how the color - string is - - formatted. By default, color strings are formatted as 'rgba(r, g, b, - a)'.

- path: p5.Color/toString - setRed: - description: > -

Sets the red component of a color.

- -

The range depends on the colorMode(). In the - - default RGB mode it's between 0 and 255.

- path: p5.Color/setRed - setGreen: - description: > -

Sets the green component of a color.

- -

The range depends on the colorMode(). In the - - default RGB mode it's between 0 and 255.

- path: p5.Color/setGreen - setBlue: - description: > -

Sets the blue component of a color.

- -

The range depends on the colorMode(). In the - - default RGB mode it's between 0 and 255.

- path: p5.Color/setBlue - setAlpha: - description: > -

Sets the alpha (transparency) value of a color.

- -

The range depends on the - - colorMode(). In the default RGB - mode it's - - between 0 and 255.

- path: p5.Color/setAlpha -chainable: false ---- - - -# p5.Color diff --git a/src/content/reference/en/p5 copy/p5.Element.mdx b/src/content/reference/en/p5 copy/p5.Element.mdx deleted file mode 100644 index c07b10ae79..0000000000 --- a/src/content/reference/en/p5 copy/p5.Element.mdx +++ /dev/null @@ -1,545 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/p5.Element.js#L9 -title: p5.Element -module: DOM -submodule: DOM -file: src/core/p5.Element.js -description: > -

A class to describe an - - HTML element.

- -

Sketches can use many elements. Common elements include the drawing canvas, - - buttons, sliders, webcam feeds, and so on.

- -

All elements share the methods of the p5.Element class. - They're created - - with functions such as createCanvas() and - - createButton().

-line: 9 -isConstructor: true -params: - - name: elt - description: | -

wrapped DOM element.

- type: HTMLElement - - name: pInst - description: | -

pointer to p5 instance.

- type: P5 - optional: true -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a button element and - // place it beneath the canvas. - let btn = createButton('change'); - btn.position(0, 100); - - // Call randomColor() when - // the button is pressed. - btn.mousePressed(randomColor); - - describe('A gray square with a button that says "change" beneath it. The square changes color when the user presses the button.'); - } - - // Paint the background either - // red, yellow, blue, or green. - function randomColor() { - let c = random(['red', 'yellow', 'blue', 'green']); - background(c); - } - -
-methods: - parent: - description: > -

Attaches the element to a parent element.

- -

For example, a

element may be used as a box to - - hold two pieces of text, a header and a paragraph. The - -
is the parent element of both the header and - - paragraph.

- -

The parameter parent can have one of three types. - parent can be a - - string with the parent element's ID, as in - - myElement.parent('container'). It can also be another - - p5.Element object, as in - - myElement.parent(myDiv). Finally, parent can be - an HTMLElement - - object, as in myElement.parent(anotherElement).

- -

Calling myElement.parent() without an argument returns the - element's - - parent.

- path: p5.Element/parent - id: - description: > -

Sets the element's ID using a given string.

- -

Calling myElement.id() without an argument returns its ID - as a string.

- path: p5.Element/id - class: - description: > -

Adds a - - class attribute - - to the element using a given string.

- -

Calling myElement.class() without an argument returns a - string with its current classes.

- path: p5.Element/class - mousePressed: - description: > -

Calls a function when the mouse is pressed over the element.

- -

Calling myElement.mousePressed(false) disables the - function.

- -

Note: Some mobile browsers may also trigger this event when the element - - receives a quick tap.

- path: p5.Element/mousePressed - doubleClicked: - description: > -

Calls a function when the mouse is pressed twice over the element.

- -

Calling myElement.doubleClicked(false) disables the - function.

- path: p5.Element/doubleClicked - mouseWheel: - description: > -

Calls a function when the mouse wheel scrolls over the element.

- -

The callback function, fxn, is passed an - event object. event has - - two numeric properties, deltaY and deltaX. - event.deltaY is - - negative if the mouse wheel rotates away from the user. It's positive if - - the mouse wheel rotates toward the user. event.deltaX is - positive if - - the mouse wheel moves to the right. It's negative if the mouse wheel moves - - to the left.

- -

Calling myElement.mouseWheel(false) disables the - function.

- path: p5.Element/mouseWheel - mouseReleased: - description: > -

Calls a function when the mouse is released over the element.

- -

Calling myElement.mouseReleased(false) disables the - function.

- -

Note: Some mobile browsers may also trigger this event when the element - - receives a quick tap.

- path: p5.Element/mouseReleased - mouseClicked: - description: > -

Calls a function when the mouse is pressed and released over the - element.

- -

Calling myElement.mouseReleased(false) disables the - function.

- -

Note: Some mobile browsers may also trigger this event when the element - - receives a quick tap.

- path: p5.Element/mouseClicked - mouseMoved: - description: > -

Calls a function when the mouse moves over the element.

- -

Calling myElement.mouseMoved(false) disables the - function.

- path: p5.Element/mouseMoved - mouseOver: - description: > -

Calls a function when the mouse moves onto the element.

- -

Calling myElement.mouseOver(false) disables the - function.

- path: p5.Element/mouseOver - mouseOut: - description: > -

Calls a function when the mouse moves off the element.

- -

Calling myElement.mouseOut(false) disables the - function.

- path: p5.Element/mouseOut - touchStarted: - description: > -

Calls a function when the element is touched.

- -

Calling myElement.touchStarted(false) disables the - function.

- -

Note: Touch functions only work on mobile devices.

- path: p5.Element/touchStarted - touchMoved: - description: > -

Calls a function when the user touches the element and moves.

- -

Calling myElement.touchMoved(false) disables the - function.

- -

Note: Touch functions only work on mobile devices.

- path: p5.Element/touchMoved - touchEnded: - description: > -

Calls a function when the user stops touching the element.

- -

Calling myElement.touchMoved(false) disables the - function.

- -

Note: Touch functions only work on mobile devices.

- path: p5.Element/touchEnded - dragOver: - description: > -

Calls a function when a file is dragged over the element.

- -

Calling myElement.dragOver(false) disables the - function.

- path: p5.Element/dragOver - dragLeave: - description: > -

Calls a function when a file is dragged off the element.

- -

Calling myElement.dragLeave(false) disables the - function.

- path: p5.Element/dragLeave - addClass: - description: | -

Adds a class to the element.

- path: p5.Element/addClass - removeClass: - description: | -

Removes a class from the element.

- path: p5.Element/removeClass - hasClass: - description: | -

Checks if a class is already applied to element.

- path: p5.Element/hasClass - toggleClass: - description: | -

Toggles whether a class is applied to the element.

- path: p5.Element/toggleClass - child: - description: > -

Attaches the element as a child of another element.

- -

myElement.child() accepts either a string ID, DOM node, or - - p5.Element. For example, - - myElement.child(otherElement). If no argument is provided, an - array of - - children DOM nodes is returned.

- path: p5.Element/child - center: - description: > -

Centers the element either vertically, horizontally, or both.

- -

center() will center the element relative to its parent or - according to - - the page's body if the element has no parent.

- -

If no argument is passed, as in myElement.center() the - element is aligned - - both vertically and horizontally.

- path: p5.Element/center - html: - description: > -

Sets the inner HTML of the element, replacing any existing HTML.

- -

The second parameter, append, is optional. If - true is passed, as in - - myElement.html('hi', true), the HTML is appended instead of - replacing - - existing HTML.

- -

If no arguments are passed, as in myElement.html(), the - element's inner - - HTML is returned.

- path: p5.Element/html - position: - description: > -

Sets the element's position.

- -

The first two parameters, x and y, set the - element's position relative - - to the top-left corner of the web page.

- -

The third parameter, positionType, is optional. It sets - the element's - - positioning - scheme. - - positionType is a string that can be either - 'static', 'fixed', - - 'relative', 'sticky', 'initial', or - 'inherit'.

- -

If no arguments passed, as in myElement.position(), the - method returns - - the element's position in an object, as in { x: 0, y: 0 - }.

- path: p5.Element/position - style: - description: > -

Applies a style to the element by adding a - - CSS declaration.

- -

The first parameter, property, is a string. If the name of - a style - - property is passed, as in myElement.style('color'), the - method returns - - the current value as a string or null if it hasn't been set. - If a - - property:style string is passed, as in - - myElement.style('color:deeppink'), the method sets the style - property - - to value.

- -

The second parameter, value, is optional. It sets the - property's value. - - value can be a string, as in - - myElement.style('color', 'deeppink'), or a - - p5.Color object, as in - - myElement.style('color', myColor).

- path: p5.Element/style - attribute: - description: > -

Adds an - - attribute - - to the element.

- -

This method is useful for advanced tasks. Most commonly-used - attributes, - - such as id, can be set with their dedicated methods. For - example, - - nextButton.id('next') sets an element's id - attribute. Calling - - nextButton.attribute('id', 'next') has the same effect.

- -

The first parameter, attr, is the attribute's name as a - string. Calling - - myElement.attribute('align') returns the attribute's current - value as a - - string or null if it hasn't been set.

- -

The second parameter, value, is optional. It's a string - used to set the - - attribute's value. For example, calling - - myElement.attribute('align', 'center') sets the element's - horizontal - - alignment to center.

- path: p5.Element/attribute - removeAttribute: - description: > -

Removes an attribute from the element.

- -

The parameter attr is the attribute's name as a string. - For example, - - calling myElement.removeAttribute('align') removes its - align - - attribute if it's been set.

- path: p5.Element/removeAttribute - value: - description: > -

Returns or sets the element's value.

- -

Calling myElement.value() returns the element's current - value.

- -

The parameter, value, is an optional number or string. If - provided, - - as in myElement.value(123), it's used to set the element's - value.

- path: p5.Element/value - show: - description: | -

Shows the current element.

- path: p5.Element/show - hide: - description: | -

Hides the current element.

- path: p5.Element/hide - size: - description: > -

Sets the element's width and height.

- -

Calling myElement.size() without an argument returns the - element's size - - as an object with the properties width and - height. For example, - { width: 20, height: 10 }.

-

The first parameter, width, is optional. It's a number - used to set the - - element's width. Calling myElement.size(10)

- -

The second parameter, 'height, is also optional. It's a number - used to set the element's height. For example, calling - myElement.size(20, 10)` sets the element's width to 20 pixels and - height - - to 10 pixels.

- -

The constant AUTO can be used to adjust one dimension at a - time while - - maintaining the aspect ratio, which is width / height. For - example, - - consider an element that's 200 pixels wide and 100 pixels tall. Calling - - myElement.size(20, AUTO) sets the width to 20 pixels and - height to 10 - - pixels.

- -

Note: In the case of elements that need to load data, such as images, - wait - - to call myElement.size() until after the data loads.

- path: p5.Element/size - remove: - description: | -

Removes the element, stops all audio/video streams, and removes all - callback functions.

- path: p5.Element/remove - drop: - description: > -

Calls a function when the user drops a file on the element.

- -

The first parameter, callback, is a function to call once - the file loads. - - The callback function should have one parameter, file, that's - a - - p5.File object. If the user drops - multiple files on - - the element, callback, is called once for each file.

- -

The second parameter, fxn, is a function to call when the - browser detects - - one or more dropped files. The callback function should have one - - parameter, event, that's a - - DragEvent.

- path: p5.Element/drop - draggable: - description: > -

Makes the element draggable.

- -

The parameter, elmnt, is optional. If another - - p5.Element object is passed, as in - - myElement.draggable(otherElement), the other element will - become draggable.

- path: p5.Element/draggable -properties: - elt: - description: > -

The element's underlying HTMLElement object.

- -

The - - HTMLElement - - object's properties and methods can be used directly.

- path: p5.Element/elt - width: - description: | -

A Number property that stores the element's width.

- path: p5.Element/width - height: - description: | -

A Number property that stores the element's height.

- path: p5.Element/height -chainable: false ---- - - -# p5.Element diff --git a/src/content/reference/en/p5 copy/p5.File.mdx b/src/content/reference/en/p5 copy/p5.File.mdx deleted file mode 100644 index 78675c7a98..0000000000 --- a/src/content/reference/en/p5 copy/p5.File.mdx +++ /dev/null @@ -1,153 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L5482 -title: p5.File -module: DOM -submodule: DOM -file: src/dom/dom.js -description: | -

A class to describe a file.

-

p5.File objects are used by - myElement.drop() and - created by - createFileInput.

-line: 5482 -isConstructor: true -params: - - name: file - description: | -

wrapped file.

- type: File -example: - - |- - -
- - // Use the file input to load a - // file and display its info. - - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a file input and place it beneath the canvas. - // Call displayInfo() when the file loads. - let input = createFileInput(displayInfo); - input.position(0, 100); - - describe('A gray square with a file input beneath it. If the user loads a file, its info is written in black.'); - } - - // Display the p5.File's info once it loads. - function displayInfo(file) { - background(200); - - // Display the p5.File's name. - text(file.name, 10, 10, 80, 40); - - // Display the p5.File's type and subtype. - text(`${file.type}/${file.subtype}`, 10, 70); - - // Display the p5.File's size in bytes. - text(file.size, 10, 90); - } - -
- -
- - // Use the file input to select an image to - // load and display. - let img; - - function setup() { - createCanvas(100, 100); - - // Create a file input and place it beneath the canvas. - // Call handleImage() when the file image loads. - let input = createFileInput(handleImage); - input.position(0, 100); - - describe('A gray square with a file input beneath it. If the user selects an image file to load, it is displayed on the square.'); - } - - function draw() { - background(200); - - // Draw the image if it's ready. - if (img) { - image(img, 0, 0, width, height); - } - } - - // Use the p5.File's data once it loads. - function handleImage(file) { - // Check the p5.File's type. - if (file.type === 'image') { - // Create an image using using the p5.File's data. - img = createImg(file.data, ''); - - // Hide the image element so it doesn't appear twice. - img.hide(); - } else { - img = null; - } - } - -
-properties: - file: - description: > -

Underlying - - File - - object. All File properties and methods are accessible.

- path: p5.File/file - type: - description: > -

The file - - MIME type - - as a string.

- -

For example, 'image' and 'text' are both MIME - types.

- path: p5.File/type - subtype: - description: > -

The file subtype as a string.

- -

For example, a file with an 'image' - - MIME type - - may have a subtype such as png or jpeg.

- path: p5.File/subtype - name: - description: | -

The file name as a string.

- path: p5.File/name - size: - description: | -

The number of bytes in the file.

- path: p5.File/size - data: - description: | -

A string containing the file's data.

-

Data can be either image data, text contents, or a parsed object in the - case of JSON and p5.XML objects.

- path: p5.File/data -chainable: false ---- - - -# p5.File diff --git a/src/content/reference/en/p5 copy/p5.Font.mdx b/src/content/reference/en/p5 copy/p5.Font.mdx deleted file mode 100644 index 615d0406ee..0000000000 --- a/src/content/reference/en/p5 copy/p5.Font.mdx +++ /dev/null @@ -1,146 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/p5.Font.js#L13 -title: p5.Font -module: Typography -submodule: Loading & Displaying -file: src/typography/p5.Font.js -description: | -

A class to describe fonts.

-line: 13 -isConstructor: true -params: - - name: pInst - description: | -

pointer to p5 instance.

- type: P5 - optional: true -example: - - |- - -
- - let font; - - function preload() { - // Creates a p5.Font object. - font = loadFont('/assets/inconsolata.otf'); - } - - function setup() { - createCanvas(100, 100); - - // Style the text. - fill('deeppink'); - textFont(font); - textSize(36); - - // Display the text. - text('p5*js', 10, 50); - - describe('The text "p5*js" written in pink on a gray background.'); - } - -
-methods: - textBounds: - description: > -

Returns the bounding box for a string of text written using the - font.

- -

The bounding box is the smallest rectangle that can contain a string of - - text. font.textBounds() returns an object with the bounding - box's - - location and size. For example, calling font.textBounds('p5*js', 5, - 20) - - returns an object in the format - - { x: 5.7, y: 12.1 , w: 9.9, h: 28.6 }. The x and - y properties are - - always the coordinates of the bounding box's top-left corner.

- -

The first parameter, str, is a string of text. The second - and third - - parameters, x and y, are the text's position. By - default, they set the - - coordinates of the bounding box's bottom-left corner. See - - textAlign() for more ways to align - text.

- -

The fourth parameter, fontSize, is optional. It sets the - font size used to - - determine the bounding box. By default, font.textBounds() - will use the - - current textSize().

- path: p5.Font/textBounds - textToPoints: - description: > -

Returns an array of points outlining a string of text written using the - - font.

- -

Each point object in the array has three properties that describe the - - point's location and orientation, called its path angle. For example, - - { x: 10, y: 20, alpha: 450 }.

- -

The first parameter, str, is a string of text. The second - and third - - parameters, x and y, are the text's position. By - default, they set the - - coordinates of the bounding box's bottom-left corner. See - - textAlign() for more ways to align - text.

- -

The fourth parameter, fontSize, is optional. It sets the - text's font - - size. By default, font.textToPoints() will use the current - - textSize().

- -

The fifth parameter, options, is also optional. - font.textToPoints() - - expects an object with the following properties:

- -

sampleFactor is the ratio of the text's path length to the - number of - - samples. It defaults to 0.1. Higher values produce more points along the - - path and are more precise.

- -

simplifyThreshold removes collinear points if it's set to - a number other - - than 0. The value represents the threshold angle to use when determining - - whether two edges are collinear.

- path: p5.Font/textToPoints -properties: - font: - description: | -

The font's underlying - opentype.js - font object.

- path: p5.Font/font -chainable: false ---- - - -# p5.Font diff --git a/src/content/reference/en/p5 copy/p5.Framebuffer.mdx b/src/content/reference/en/p5 copy/p5.Framebuffer.mdx deleted file mode 100644 index 8100f48199..0000000000 --- a/src/content/reference/en/p5 copy/p5.Framebuffer.mdx +++ /dev/null @@ -1,443 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Framebuffer.js#L76 -title: p5.Framebuffer -module: Rendering -file: src/webgl/p5.Framebuffer.js -description: > -

A class to describe a high-performance drawing surface for textures.

- -

Each p5.Framebuffer object provides a dedicated drawing - surface called - - a framebuffer. They're similar to - - p5.Graphics objects but can run much - faster. - - Performance is improved because the framebuffer shares the same WebGL - - context as the canvas used to create it.

- -

p5.Framebuffer objects have all the drawing features of the - main - - canvas. Drawing instructions meant for the framebuffer must be placed - - between calls to - - myBuffer.begin() and - - myBuffer.end(). The resulting - image - - can be applied as a texture by passing the p5.Framebuffer object - to the - - texture() function, as in - texture(myBuffer). - - It can also be displayed on the main canvas by passing it to the - - image() function, as in - image(myBuffer, 0, 0).

- -

Note: createFramebuffer() is - the - - recommended way to create an instance of this class.

-line: 76 -isConstructor: true -params: - - name: target - description: | -

sketch instance or - p5.Graphics - object.

- type: p5.Graphics|p5 - - name: settings - description: | -

configuration options.

- type: Object - optional: true -methods: - resize: - description: > -

Resizes the framebuffer to a given width and height.

- -

The parameters, width and height, set the - dimensions of the - - framebuffer. For example, calling myBuffer.resize(300, 500) - resizes - - the framebuffer to 300×500 pixels, then sets myBuffer.width - to 300 - - and myBuffer.height 500.

- path: p5.Framebuffer/resize - pixelDensity: - description: > -

Sets the framebuffer's pixel density or returns its current - density.

- -

Computer displays are grids of little lights called pixels. A display's - - pixel density describes how many pixels it packs into an area. Displays - - with smaller pixels have a higher pixel density and create sharper - - images.

- -

The parameter, density, is optional. If a number is - passed, as in - - myBuffer.pixelDensity(1), it sets the framebuffer's pixel - density. By - - default, the framebuffer's pixel density will match that of the canvas - - where it was created. All canvases default to match the display's pixel - - density.

- -

Calling myBuffer.pixelDensity() without an argument - returns its current - - pixel density.

- path: p5.Framebuffer/pixelDensity - autoSized: - description: > -

Toggles the framebuffer's autosizing mode or returns the current - mode.

- -

By default, the framebuffer automatically resizes to match the canvas - - that created it. Calling myBuffer.autoSized(false) disables - this - - behavior and calling myBuffer.autoSized(true) re-enables - it.

- -

Calling myBuffer.autoSized() without an argument returns - true if - - the framebuffer automatically resizes and false if not.

- path: p5.Framebuffer/autoSized - createCamera: - description: > -

Creates a new - - p5.Camera object to use with the - framebuffer.

- -

The new camera is initialized with a default position (0, 0, - 800) and a - - default perspective projection. Its properties can be controlled with - - p5.Camera methods such as - myCamera.lookAt(0, 0, 0).

- -

Framebuffer cameras should be created between calls to - - myBuffer.begin() and - - myBuffer.end() like so:

- -
let myCamera;
-
-
-      myBuffer.begin();
-
-
-      // Create the camera for the framebuffer.
-
-      myCamera = myBuffer.createCamera();
-
-
-      myBuffer.end();
-
-      
- -

Calling setCamera() updates the - - framebuffer's projection using the camera. - - resetMatrix() must also be called - for the - - view to change properly:

- -
myBuffer.begin();
-
-
-      // Set the camera for the framebuffer.
-
-      setCamera(myCamera);
-
-
-      // Reset all transformations.
-
-      resetMatrix();
-
-
-      // Draw stuff...
-
-
-      myBuffer.end();
-
-      
- path: p5.Framebuffer/createCamera - remove: - description: > -

Deletes the framebuffer from GPU memory.

- -

Calling myBuffer.remove() frees the GPU memory used by the - framebuffer. - - The framebuffer also uses a bit of memory on the CPU which can be freed - - like so:

- -
// Delete the framebuffer from GPU memory.
-
-      myBuffer.remove();
-
-
-      // Delete the framebuffer from CPU memory.
-
-      myBuffer = undefined;
-
-      
- -

Note: All variables that reference the framebuffer must be assigned - - the value undefined to delete the framebuffer from CPU - memory. If any - - variable still refers to the framebuffer, then it won't be garbage - - collected.

- path: p5.Framebuffer/remove - begin: - description: > -

Begins drawing shapes to the framebuffer.

- -

myBuffer.begin() and myBuffer.end() - - allow shapes to be drawn to the framebuffer. myBuffer.begin() - begins - - drawing to the framebuffer and - - myBuffer.end() stops drawing - to the - - framebuffer. Changes won't be visible until the framebuffer is displayed - - as an image or texture.

- path: p5.Framebuffer/begin - end: - description: > -

Stops drawing shapes to the framebuffer.

- -

myBuffer.begin() and - myBuffer.end() - - allow shapes to be drawn to the framebuffer. - - myBuffer.begin() begins - drawing to - - the framebuffer and myBuffer.end() stops drawing to the - framebuffer. - - Changes won't be visible until the framebuffer is displayed as an image - - or texture.

- path: p5.Framebuffer/end - draw: - description: > -

Draws to the framebuffer by calling a function that contains drawing - - instructions.

- -

The parameter, callback, is a function with the drawing - instructions - - for the framebuffer. For example, calling - myBuffer.draw(myFunction) - - will call a function named myFunction() to draw to the - framebuffer. - - Doing so has the same effect as the following:

- -
myBuffer.begin();
-
-      myFunction();
-
-      myBuffer.end();
-
-      
- path: p5.Framebuffer/draw - loadPixels: - description: > -

Loads the current value of each pixel in the framebuffer into its - - pixels array.

- -

myBuffer.loadPixels() must be called before reading from - or writing to - - myBuffer.pixels.

- path: p5.Framebuffer/loadPixels - get: - description: > -

Gets a pixel or a region of pixels from the framebuffer.

- -

myBuffer.get() is easy to use but it's not as fast as - - myBuffer.pixels. Use - - myBuffer.pixels to read - many pixel - - values.

- -

The version of myBuffer.get() with no parameters returns - the entire - - framebuffer as a a p5.Image - object.

- -

The version of myBuffer.get() with two parameters - interprets them as - - coordinates. It returns an array with the [R, G, B, A] values - of the - - pixel at the given point.

- -

The version of myBuffer.get() with four parameters - interprets them as - - coordinates and dimensions. It returns a subsection of the framebuffer as - - a p5.Image object. The first two - parameters are - - the coordinates for the upper-left corner of the subsection. The last two - - parameters are the width and height of the subsection.

- path: p5.Framebuffer/get - updatePixels: - description: > -

Updates the framebuffer with the RGBA values in the - - pixels array.

- -

myBuffer.updatePixels() only needs to be called after - changing values - - in the myBuffer.pixels - array. Such - - changes can be made directly after calling - - myBuffer.loadPixels().

- path: p5.Framebuffer/updatePixels -properties: - pixels: - description: > -

An array containing the color of each pixel in the framebuffer.

- -

myBuffer.loadPixels() - must be - - called before accessing the myBuffer.pixels array. - - myBuffer.updatePixels() - - must be called after any changes are made.

- -

Note: Updating pixels via this property is slower than drawing to the - - framebuffer directly. Consider using a - - p5.Shader object instead of looping - over - - myBuffer.pixels.

- path: p5.Framebuffer/pixels - color: - description: > -

An object that stores the framebuffer's color data.

- -

Each framebuffer uses a - - WebGLTexture - - object internally to store its color data. The myBuffer.color - property - - makes it possible to pass this data directly to other functions. For - - example, calling texture(myBuffer.color) or - - myShader.setUniform('colorTexture', myBuffer.color) may be - helpful for - - advanced use cases.

- -

Note: By default, a framebuffer's y-coordinates are flipped compared to - - images and videos. It's easy to flip a framebuffer's y-coordinates as - - needed when applying it as a texture. For example, calling - - plane(myBuffer.width, -myBuffer.height) will flip the - framebuffer.

- path: p5.Framebuffer/color - depth: - description: > -

An object that stores the framebuffer's depth data.

- -

Each framebuffer uses a - - WebGLTexture - - object internally to store its depth data. The myBuffer.depth - property - - makes it possible to pass this data directly to other functions. For - - example, calling texture(myBuffer.depth) or - - myShader.setUniform('depthTexture', myBuffer.depth) may be - helpful for - - advanced use cases.

- -

Note: By default, a framebuffer's y-coordinates are flipped compared to - - images and videos. It's easy to flip a framebuffer's y-coordinates as - - needed when applying it as a texture. For example, calling - - plane(myBuffer.width, -myBuffer.height) will flip the - framebuffer.

- path: p5.Framebuffer/depth -chainable: false ---- - - -# p5.Framebuffer diff --git a/src/content/reference/en/p5 copy/p5.Geometry.mdx b/src/content/reference/en/p5 copy/p5.Geometry.mdx deleted file mode 100644 index 0faa7daf7a..0000000000 --- a/src/content/reference/en/p5 copy/p5.Geometry.mdx +++ /dev/null @@ -1,793 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Geometry.js#L13 -title: p5.Geometry -module: Shape -submodule: 3D Primitives -file: src/webgl/p5.Geometry.js -description: > -

A class to describe a 3D shape.

- -

Each p5.Geometry object represents a 3D shape as a set of - connected - - points called vertices. All 3D shapes are made by connecting vertices - to - - form triangles that are stitched together. Each triangular patch on the - - geometry's surface is called a face. The geometry stores information - - about its vertices and faces for use with effects such as lighting and - - texture mapping.

- -

The first parameter, detailX, is optional. If a number is - passed, as in - - new p5.Geometry(24), it sets the number of triangle subdivisions - to use - - along the geometry's x-axis. By default, detailX is 1.

- -

The second parameter, detailY, is also optional. If a number - is passed, - - as in new p5.Geometry(24, 16), it sets the number of triangle - - subdivisions to use along the geometry's y-axis. By default, - detailX is - - 1.

- -

The third parameter, callback, is also optional. If a function - is passed, - - as in new p5.Geometry(24, 16, createShape), it will be called - once to add - - vertices to the new 3D shape.

-line: 13 -isConstructor: true -params: - - name: detailX - description: | -

number of vertices along the x-axis.

- type: Integer - optional: true - - name: detailY - description: | -

number of vertices along the y-axis.

- type: Integer - optional: true - - name: callback - description: | -

function to call once the geometry is created.

- type: Function - optional: true -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - let myGeometry; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Geometry object. - myGeometry = new p5.Geometry(); - - // Create p5.Vector objects to position the vertices. - let v0 = createVector(-40, 0, 0); - let v1 = createVector(0, -40, 0); - let v2 = createVector(40, 0, 0); - - // Add the vertices to the p5.Geometry object's vertices array. - myGeometry.vertices.push(v0, v1, v2); - - describe('A white triangle drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the p5.Geometry object. - model(myGeometry); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let myGeometry; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Geometry object using a callback function. - myGeometry = new p5.Geometry(1, 1, createShape); - - describe('A white triangle drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the p5.Geometry object. - model(myGeometry); - } - - function createShape() { - // Create p5.Vector objects to position the vertices. - let v0 = createVector(-40, 0, 0); - let v1 = createVector(0, -40, 0); - let v2 = createVector(40, 0, 0); - - // "this" refers to the p5.Geometry object being created. - - // Add the vertices to the p5.Geometry object's vertices array. - this.vertices.push(v0, v1, v2); - - // Add an array to list which vertices belong to the face. - // Vertices are listed in clockwise "winding" order from - // left to top to right. - this.faces.push([0, 1, 2]); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let myGeometry; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Geometry object using a callback function. - myGeometry = new p5.Geometry(1, 1, createShape); - - describe('A white triangle drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the p5.Geometry object. - model(myGeometry); - } - - function createShape() { - // Create p5.Vector objects to position the vertices. - let v0 = createVector(-40, 0, 0); - let v1 = createVector(0, -40, 0); - let v2 = createVector(40, 0, 0); - - // "this" refers to the p5.Geometry object being created. - - // Add the vertices to the p5.Geometry object's vertices array. - this.vertices.push(v0, v1, v2); - - // Add an array to list which vertices belong to the face. - // Vertices are listed in clockwise "winding" order from - // left to top to right. - this.faces.push([0, 1, 2]); - - // Compute the surface normals to help with lighting. - this.computeNormals(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - // Adapted from Paul Wheeler's wonderful p5.Geometry tutorial. - // https://www.paulwheeler.us/articles/custom-3d-geometry-in-p5js/ - // CC-BY-SA 4.0 - - let myGeometry; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the p5.Geometry object. - // Set detailX to 48 and detailY to 2. - // >>> try changing them. - myGeometry = new p5.Geometry(48, 2, createShape); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the p5.Geometry object. - strokeWeight(0.2); - - // Draw the p5.Geometry object. - model(myGeometry); - } - - function createShape() { - // "this" refers to the p5.Geometry object being created. - - // Define the Möbius strip with a few parameters. - let spread = 0.1; - let radius = 30; - let stripWidth = 15; - let xInterval = 4 * PI / this.detailX; - let yOffset = -stripWidth / 2; - let yInterval = stripWidth / this.detailY; - - for (let j = 0; j <= this.detailY; j += 1) { - // Calculate the "vertical" point along the strip. - let v = yOffset + yInterval * j; - - for (let i = 0; i <= this.detailX; i += 1) { - // Calculate the angle of rotation around the strip. - let u = i * xInterval; - - // Calculate the coordinates of the vertex. - let x = (radius + v * cos(u / 2)) * cos(u) - sin(u / 2) * 2 * spread; - let y = (radius + v * cos(u / 2)) * sin(u); - if (u < TWO_PI) { - y += sin(u) * spread; - } else { - y -= sin(u) * spread; - } - let z = v * sin(u / 2) + sin(u / 4) * 4 * spread; - - // Create a p5.Vector object to position the vertex. - let vert = createVector(x, y, z); - - // Add the vertex to the p5.Geometry object's vertices array. - this.vertices.push(vert); - } - } - - // Compute the faces array. - this.computeFaces(); - - // Compute the surface normals to help with lighting. - this.computeNormals(); - } - -
-methods: - calculateBoundingBox: - description: > -

Calculates the position and size of the smallest box that contains the - geometry.

- -

A bounding box is the smallest rectangular prism that contains the - entire - - geometry. It's defined by the box's minimum and maximum coordinates along - - each axis, as well as the size (length) and offset (center).

- -

Calling myGeometry.calculateBoundingBox() returns an - object with four - - properties that describe the bounding box:

- -
// Get myGeometry's bounding box.
-
-      let bbox = myGeometry.calculateBoundingBox();
-
-
-      // Print the bounding box to the console.
-
-      console.log(bbox);
-
-
-      // {
-
-      //  // The minimum coordinate along each axis.
-
-      //  min: { x: -1, y: -2, z: -3 },
-
-      //
-
-      //  // The maximum coordinate along each axis.
-
-      //  max: { x: 1, y: 2, z: 3},
-
-      //
-
-      //  // The size (length) along each axis.
-
-      //  size: { x: 2, y: 4, z: 6},
-
-      //
-
-      //  // The offset (center) along each axis.
-
-      //  offset: { x: 0, y: 0, z: 0}
-
-      // }
-
-      
- path: p5.Geometry/calculateBoundingBox - clearColors: - description: > -

Removes the geometry’s internal colors.

- -

p5.Geometry objects can be created with "internal colors" - assigned to - - vertices or the entire shape. When a geometry has internal colors, - - fill() has no effect. Calling - - myGeometry.clearColors() allows the - - fill() function to apply color to the - geometry.

- path: p5.Geometry/clearColors - saveObj: - description: > -

The saveObj() function exports p5.Geometry - objects as - - 3D models in the Wavefront .obj file format. - - This way, you can use the 3D shapes you create in p5.js in other software - - for rendering, animation, 3D printing, or more.

- -

The exported .obj file will include the faces and vertices of the - p5.Geometry, - - as well as its texture coordinates and normals, if it has them.

- path: p5.Geometry/saveObj - saveStl: - description: > -

The saveStl() function exports p5.Geometry - objects as - - 3D models in the STL stereolithography file format. - - This way, you can use the 3D shapes you create in p5.js in other software - - for rendering, animation, 3D printing, or more.

- -

The exported .stl file will include the faces, vertices, and normals of - the p5.Geometry.

- -

By default, this method saves a text-based .stl file. Alternatively, - you can save a more compact - - but less human-readable binary .stl file by passing { binary: true - } as a second parameter.

- path: p5.Geometry/saveStl - flipU: - description: > -

Flips the geometry’s texture u-coordinates.

- -

In order for texture() to work, - the geometry - - needs a way to map the points on its surface to the pixels in a - rectangular - - image that's used as a texture. The geometry's vertex at coordinates - - (x, y, z) maps to the texture image's pixel at coordinates - (u, v).

- -

The myGeometry.uvs array - stores the - - (u, v) coordinates for each vertex in the order it was added - to the - - geometry. Calling myGeometry.flipU() flips a geometry's - u-coordinates - - so that the texture appears mirrored horizontally.

- -

For example, a plane's four vertices are added clockwise starting from - the - - top-left corner. Here's how calling myGeometry.flipU() would - change a - - plane's texture coordinates:

- -
// Print the original texture coordinates.
-
-      // Output: [0, 0, 1, 0, 0, 1, 1, 1]
-
-      console.log(myGeometry.uvs);
-
-
-      // Flip the u-coordinates.
-
-      myGeometry.flipU();
-
-
-      // Print the flipped texture coordinates.
-
-      // Output: [1, 0, 0, 0, 1, 1, 0, 1]
-
-      console.log(myGeometry.uvs);
-
-
-      // Notice the swaps:
-
-      // Top vertices: [0, 0, 1, 0] --> [1, 0, 0, 0]
-
-      // Bottom vertices: [0, 1, 1, 1] --> [1, 1, 0, 1]
-
-      
- path: p5.Geometry/flipU - flipV: - description: > -

Flips the geometry’s texture v-coordinates.

- -

In order for texture() to work, - the geometry - - needs a way to map the points on its surface to the pixels in a - rectangular - - image that's used as a texture. The geometry's vertex at coordinates - - (x, y, z) maps to the texture image's pixel at coordinates - (u, v).

- -

The myGeometry.uvs array - stores the - - (u, v) coordinates for each vertex in the order it was added - to the - - geometry. Calling myGeometry.flipV() flips a geometry's - v-coordinates - - so that the texture appears mirrored vertically.

- -

For example, a plane's four vertices are added clockwise starting from - the - - top-left corner. Here's how calling myGeometry.flipV() would - change a - - plane's texture coordinates:

- -
// Print the original texture coordinates.
-
-      // Output: [0, 0, 1, 0, 0, 1, 1, 1]
-
-      console.log(myGeometry.uvs);
-
-
-      // Flip the v-coordinates.
-
-      myGeometry.flipV();
-
-
-      // Print the flipped texture coordinates.
-
-      // Output: [0, 1, 1, 1, 0, 0, 1, 0]
-
-      console.log(myGeometry.uvs);
-
-
-      // Notice the swaps:
-
-      // Left vertices: [0, 0] <--> [1, 0]
-
-      // Right vertices: [1, 0] <--> [1, 1]
-
-      
- path: p5.Geometry/flipV - computeFaces: - description: > -

Computes the geometry's faces using its vertices.

- -

All 3D shapes are made by connecting sets of points called - vertices. A - - geometry's surface is formed by connecting vertices to form triangles that - - are stitched together. Each triangular patch on the geometry's surface is - - called a face. myGeometry.computeFaces() performs - the math needed to - - define each face based on the distances between vertices.

- -

The geometry's vertices are stored as p5.Vector - - objects in the myGeometry.vertices - - array. The geometry's first vertex is the - - p5.Vector object at - myGeometry.vertices[0], - - its second vertex is myGeometry.vertices[1], its third vertex - is - - myGeometry.vertices[2], and so on.

- -

Calling myGeometry.computeFaces() fills the - - myGeometry.faces array with - three-element - - arrays that list the vertices that form each face. For example, a geometry - - made from a rectangle has two faces because a rectangle is made by joining - - two triangles. myGeometry.faces for a - - rectangle would be the two-dimensional array - - [[0, 1, 2], [2, 1, 3]]. The first face, - myGeometry.faces[0], is the - - array [0, 1, 2] because it's formed by connecting - - myGeometry.vertices[0], - myGeometry.vertices[1],and - - myGeometry.vertices[2]. The second face, - myGeometry.faces[1], is the - - array [2, 1, 3] because it's formed by connecting - - myGeometry.vertices[2], myGeometry.vertices[1], - and - - myGeometry.vertices[3].

- -

Note: myGeometry.computeFaces() only works when geometries - have four or more vertices.

- path: p5.Geometry/computeFaces - computeNormals: - description: > -

Calculates the normal vector for each vertex on the geometry.

- -

All 3D shapes are made by connecting sets of points called - vertices. A - - geometry's surface is formed by connecting vertices to create triangles - - that are stitched together. Each triangular patch on the geometry's - - surface is called a face. - myGeometry.computeNormals() performs the - - math needed to orient each face. Orientation is important for lighting - - and other effects.

- -

A face's orientation is defined by its normal vector which - points out - - of the face and is normal (perpendicular) to the surface. Calling - - myGeometry.computeNormals() first calculates each face's - normal vector. - - Then it calculates the normal vector for each vertex by averaging the - - normal vectors of the faces surrounding the vertex. The vertex normals - - are stored as p5.Vector objects in - the - - myGeometry.vertexNormals - array.

- -

The first parameter, shadingType, is optional. Passing the - constant - - FLAT, as in myGeometry.computeNormals(FLAT), - provides neighboring - - faces with their own copies of the vertices they share. Surfaces appear - - tiled with flat shading. Passing the constant SMOOTH, as in - - myGeometry.computeNormals(SMOOTH), makes neighboring faces - reuse their - - shared vertices. Surfaces appear smoother with smooth shading. By - - default, shadingType is FLAT.

- -

The second parameter, options, is also optional. If an - object with a - - roundToPrecision property is passed, as in - - myGeometry.computeNormals(SMOOTH, { roundToPrecision: 5 }), - it sets the - - number of decimal places to use for calculations. By default, - - roundToPrecision uses 3 decimal places.

- path: p5.Geometry/computeNormals - normalize: - description: > -

Transforms the geometry's vertices to fit snugly within a 100×100×100 - box - - centered at the origin.

- -

Calling myGeometry.normalize() translates the geometry's - vertices so that - - they're centered at the origin (0, 0, 0). Then it scales the - vertices so - - that they fill a 100×100×100 box. As a result, small geometries will grow - - and large geometries will shrink.

- -

Note: myGeometry.normalize() only works when called in the - - setup() function.

- path: p5.Geometry/normalize -properties: - vertices: - description: > -

An array with the geometry's vertices.

- -

The geometry's vertices are stored as - - p5.Vector objects in the - myGeometry.vertices - - array. The geometry's first vertex is the - - p5.Vector object at - myGeometry.vertices[0], - - its second vertex is myGeometry.vertices[1], its third vertex - is - - myGeometry.vertices[2], and so on.

- path: p5.Geometry/vertices - vertexNormals: - description: > -

An array with the vectors that are normal to the geometry's - vertices.

- -

A face's orientation is defined by its normal vector which - points out - - of the face and is normal (perpendicular) to the surface. Calling - - myGeometry.computeNormals() first calculates each face's - normal - - vector. Then it calculates the normal vector for each vertex by - - averaging the normal vectors of the faces surrounding the vertex. The - - vertex normals are stored as p5.Vector - - objects in the myGeometry.vertexNormals array.

- path: p5.Geometry/vertexNormals - faces: - description: > -

An array that lists which of the geometry's vertices form each of its - - faces.

- -

All 3D shapes are made by connecting sets of points called - vertices. A - - geometry's surface is formed by connecting vertices to form triangles - - that are stitched together. Each triangular patch on the geometry's - - surface is called a face.

- -

The geometry's vertices are stored as - - p5.Vector objects in the - - myGeometry.vertices array. - The - - geometry's first vertex is the p5.Vector - - object at myGeometry.vertices[0], its second vertex is - - myGeometry.vertices[1], its third vertex is - myGeometry.vertices[2], - - and so on.

- -

For example, a geometry made from a rectangle has two faces because a - - rectangle is made by joining two triangles. myGeometry.faces - for a - - rectangle would be the two-dimensional array [[0, 1, 2], [2, 1, - 3]]. - - The first face, myGeometry.faces[0], is the array [0, - 1, 2] because - - it's formed by connecting myGeometry.vertices[0], - - myGeometry.vertices[1],and - myGeometry.vertices[2]. The second face, - - myGeometry.faces[1], is the array [2, 1, 3] - because it's formed by - - connecting myGeometry.vertices[2], - myGeometry.vertices[1],and - - myGeometry.vertices[3].

- path: p5.Geometry/faces - uvs: - description: > -

An array that lists the texture coordinates for each of the geometry's - - vertices.

- -

In order for texture() to work, - the geometry - - needs a way to map the points on its surface to the pixels in a - - rectangular image that's used as a texture. The geometry's vertex at - - coordinates (x, y, z) maps to the texture image's pixel at - coordinates - - (u, v).

- -

The myGeometry.uvs array stores the (u, v) - coordinates for each - - vertex in the order it was added to the geometry. For example, the - - first vertex, myGeometry.vertices[0], has its (u, - v) coordinates - - stored at myGeometry.uvs[0] and - myGeometry.uvs[1].

- path: p5.Geometry/uvs -chainable: false ---- - - -# p5.Geometry diff --git a/src/content/reference/en/p5 copy/p5.Graphics.mdx b/src/content/reference/en/p5 copy/p5.Graphics.mdx deleted file mode 100644 index d0b7c3aff8..0000000000 --- a/src/content/reference/en/p5 copy/p5.Graphics.mdx +++ /dev/null @@ -1,261 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/p5.Graphics.js#L10 -title: p5.Graphics -module: Rendering -submodule: Rendering -file: src/core/p5.Graphics.js -description: > -

A class to describe a drawing surface that's separate from the main - canvas.

- -

Each p5.Graphics object provides a dedicated drawing surface - called a - - graphics buffer. Graphics buffers are helpful when drawing should - happen - - offscreen. For example, separate scenes can be drawn offscreen and - - displayed only when needed.

- -

p5.Graphics objects have nearly all the drawing features of - the main - - canvas. For example, calling the method myGraphics.circle(50, 50, - 20) - - draws to the graphics buffer. The resulting image can be displayed on the - - main canvas by passing the p5.Graphics object to the - - image() function, as in - image(myGraphics, 0, 0).

- -

Note: createGraphics() is the - recommended - - way to create an instance of this class.

-line: 10 -isConstructor: true -params: - - name: width - description: | -

width of the graphics buffer in pixels.

- type: Number - - name: height - description: | -

height of the graphics buffer in pixels.

- type: Number - - name: renderer - description: | -

renderer to use, either P2D or WEBGL.

- type: Constant - - name: pInst - description: | -

sketch instance.

- type: P5 - optional: true - - name: canvas - description: | -

existing <canvas> element to use.

- type: HTMLCanvasElement - optional: true -example: - - |- - -
- - let pg; - - function setup() { - createCanvas(100, 100); - - // Create a p5.Graphics object. - pg = createGraphics(50, 50); - - // Draw to the p5.Graphics object. - pg.background(100); - pg.circle(25, 25, 20); - - describe('A dark gray square with a white circle at its center drawn on a gray background.'); - } - - function draw() { - background(200); - - // Display the p5.Graphics object. - image(pg, 25, 25); - } - -
- -
- - // Click the canvas to display the graphics buffer. - - let pg; - - function setup() { - createCanvas(100, 100); - - // Create a p5.Graphics object. - pg = createGraphics(50, 50); - - describe('A square appears on a gray background when the user presses the mouse. The square cycles between white and black.'); - } - - function draw() { - background(200); - - // Calculate the background color. - let bg = frameCount % 255; - - // Draw to the p5.Graphics object. - pg.background(bg); - - // Display the p5.Graphics object while - // the user presses the mouse. - if (mouseIsPressed === true) { - image(pg, 25, 25); - } - } - -
-methods: - reset: - description: > -

Resets the graphics buffer's transformations and lighting.

- -

By default, the main canvas resets certain transformation and lighting - - values each time draw() executes. - p5.Graphics - - objects must reset these values manually by calling - myGraphics.reset().

- path: p5.Graphics/reset - remove: - description: > -

Removes the graphics buffer from the web page.

- -

Calling myGraphics.remove() removes the graphics buffer's - - element from the web page. The graphics buffer also - uses - - a bit of memory on the CPU that can be freed like so:

- -
// Remove the graphics buffer from the web
-      page.
-
-      myGraphics.remove();
-
-
-      // Delete the graphics buffer from CPU memory.
-
-      myGraphics = undefined;
-
-      
- -

Note: All variables that reference the graphics buffer must be assigned - - the value undefined to delete the graphics buffer from CPU - memory. If any - - variable still refers to the graphics buffer, then it won't be garbage - - collected.

- path: p5.Graphics/remove - createFramebuffer: - description: > -

Creates a new p5.Framebuffer - object with - - the same WebGL context as the graphics buffer.

- -

p5.Framebuffer objects are - separate drawing - - surfaces that can be used as textures in WebGL mode. They're similar to - - p5.Graphics objects and generally - run much - - faster when used as textures. Creating a - - p5.Framebuffer object in the - same context - - as the graphics buffer makes this speedup possible.

- -

The parameter, options, is optional. An object can be - passed to configure - - the p5.Framebuffer object. The - available - - properties are:

- -
    - -
  • format: data format of the texture, either - UNSIGNED_BYTE, FLOAT, or - HALF_FLOAT. Default is UNSIGNED_BYTE.
  • - -
  • channels: whether to store RGB or - RGBA color channels. Default is to match the graphics buffer - which is RGBA.
  • - -
  • depth: whether to include a depth buffer. Default is - true.
  • - -
  • depthFormat: data format of depth information, either - UNSIGNED_INT or FLOAT. Default is - FLOAT.
  • - -
  • stencil: whether to include a stencil buffer for masking. - depth must be true for this feature to work. - Defaults to the value of depth which is - true.
  • - -
  • antialias: whether to perform anti-aliasing. If set to - true, as in { antialias: true }, 2 samples will - be used by default. The number of samples can also be set, as in { - antialias: 4 }. Default is to match setAttributes() which is - false (true in Safari).
  • - -
  • width: width of the p5.Framebuffer object. Default is - to always match the graphics buffer width.
  • - -
  • height: height of the p5.Framebuffer object. Default is - to always match the graphics buffer height.
  • - -
  • density: pixel density of the p5.Framebuffer object. Default is - to always match the graphics buffer pixel density.
  • - -
  • textureFiltering: how to read values from the p5.Framebuffer object. Either - LINEAR (nearby pixels will be interpolated) or - NEAREST (no interpolation). Generally, use - LINEAR when using the texture as an image and - NEAREST if reading the texture as data. Default is - LINEAR.
  • - -
- -

If the width, height, or density - attributes are set, they won't - - automatically match the graphics buffer and must be changed manually.

- path: p5.Graphics/createFramebuffer -chainable: false ---- - - -# p5.Graphics diff --git a/src/content/reference/en/p5 copy/p5.Image.mdx b/src/content/reference/en/p5 copy/p5.Image.mdx deleted file mode 100644 index 63e2a668fe..0000000000 --- a/src/content/reference/en/p5 copy/p5.Image.mdx +++ /dev/null @@ -1,519 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/p5.Image.js#L21 -title: p5.Image -module: Image -submodule: Image -file: src/image/p5.Image.js -description: > -

A class to describe an image.

- -

Images are rectangular grids of pixels that can be displayed and - modified.

- -

Existing images can be loaded by calling - - loadImage(). Blank images can be - created by - - calling createImage(). - p5.Image objects - - have methods for common tasks such as applying filters and modifying - - pixel values.

-line: 21 -isConstructor: true -params: - - name: width - description: '' - type: Number - - name: height - description: '' - type: Number -example: - - |- - -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - describe('An image of a brick wall.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Apply the GRAY filter. - img.filter(GRAY); - - // Display the image. - image(img, 0, 0); - - describe('A grayscale image of a brick wall.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Image object. - let img = createImage(66, 66); - - // Load the image's pixels. - img.loadPixels(); - - // Set the pixels to black. - for (let x = 0; x < img.width; x += 1) { - for (let y = 0; y < img.height; y += 1) { - img.set(x, y, 0); - } - } - - // Update the image. - img.updatePixels(); - - // Display the image. - image(img, 17, 17); - - describe('A black square drawn in the middle of a gray square.'); - } - -
-methods: - pixelDensity: - description: | -

Gets or sets the pixel density for high pixel density displays.

-

By default, the density will be set to 1.

-

Call this method with no arguments to get the default density, or pass - in a number to set the density. If a non-positive number is provided, - it defaults to 1.

- path: p5.Image/pixelDensity - loadPixels: - description: > -

Loads the current value of each pixel in the image into the - img.pixels - - array.

- -

img.loadPixels() must be called before reading or - modifying pixel - - values.

- path: p5.Image/loadPixels - updatePixels: - description: > -

Updates the canvas with the RGBA values in the - - img.pixels array.

- -

img.updatePixels() only needs to be called after changing - values in - - the img.pixels array. Such - changes can be - - made directly after calling - - img.loadPixels() or by - calling - - img.set().

- -

The optional parameters x, y, - width, and height define a - - subsection of the image to update. Doing so can improve performance in - - some cases.

- -

If the image was loaded from a GIF, then calling - img.updatePixels() - - will update the pixels in current frame.

- path: p5.Image/updatePixels - get: - description: > -

Gets a pixel or a region of pixels from the image.

- -

img.get() is easy to use but it's not as fast as - - img.pixels. Use - - img.pixels to read many pixel - values.

- -

The version of img.get() with no parameters returns the - entire image.

- -

The version of img.get() with two parameters, as in - img.get(10, 20), - - interprets them as coordinates. It returns an array with the - - [R, G, B, A] values of the pixel at the given point.

- -

The version of img.get() with four parameters, as in - - img,get(10, 20, 50, 90), interprets them as - - coordinates and dimensions. The first two parameters are the coordinates - - of the upper-left corner of the subsection. The last two parameters are - - the width and height of the subsection. It returns a subsection of the - - canvas in a new p5.Image object.

- -

Use img.get() instead of get() to work directly - - with images.

- path: p5.Image/get - set: - description: > -

Sets the color of one or more pixels within an image.

- -

img.set() is easy to use but it's not as fast as - - img.pixels. Use - - img.pixels to set many pixel - values.

- -

img.set() interprets the first two parameters as x- and - y-coordinates. It - - interprets the last parameter as a grayscale value, a [R, G, B, - A] pixel - - array, a p5.Color object, or another - - p5.Image object.

- -

img.updatePixels() must - be called - - after using img.set() for changes to appear.

- path: p5.Image/set - resize: - description: > -

Resizes the image to a given width and height.

- -

The image's original aspect ratio can be kept by passing 0 for either - - width or height. For example, calling - img.resize(50, 0) on an image - - that was 500 × 300 pixels will resize it to 50 × 30 pixels.

- path: p5.Image/resize - copy: - description: > -

Copies pixels from a source image to this image.

- -

The first parameter, srcImage, is an optional - - p5.Image object to copy. If a source - image isn't - - passed, then img.copy() can copy a region of this image to - another - - region.

- -

The next four parameters, sx, sy, - sw, and sh determine the region - - to copy from the source image. (sx, sy) is the top-left - corner of the - - region. sw and sh are the region's width and - height.

- -

The next four parameters, dx, dy, - dw, and dh determine the region - - of this image to copy into. (dx, dy) is the top-left corner - of the - - region. dw and dh are the region's width and - height.

- -

Calling img.copy() will scale pixels from the source - region if it isn't - - the same size as the destination region.

- path: p5.Image/copy - mask: - description: > -

Masks part of the image with another.

- -

img.mask() uses another p5.Image object's - - alpha channel as the alpha channel for this image. Masks are cumulative - - and can't be removed once applied. If the mask has a different - - pixel density from this image, the mask will be scaled.

- path: p5.Image/mask - filter: - description: > -

Applies an image filter to the image.

- -

The preset options are:

- -

INVERT - - Inverts the colors in the image. No parameter is used.

- -

GRAY - - Converts the image to grayscale. No parameter is used.

- -

THRESHOLD - - Converts the image to black and white. Pixels with a grayscale value - - above a given threshold are converted to white. The rest are converted to - - black. The threshold must be between 0.0 (black) and 1.0 (white). If no - - value is specified, 0.5 is used.

- -

OPAQUE - - Sets the alpha channel to be entirely opaque. No parameter is used.

- -

POSTERIZE - - Limits the number of colors in the image. Each color channel is limited to - - the number of colors specified. Values between 2 and 255 are valid, but - - results are most noticeable with lower values. The default value is 4.

- -

BLUR - - Blurs the image. The level of blurring is specified by a blur radius. - Larger - - values increase the blur. The default value is 4. A gaussian blur is used - - in P2D mode. A box blur is used in WEBGL - mode.

- -

ERODE - - Reduces the light areas. No parameter is used.

- -

DILATE - - Increases the light areas. No parameter is used.

- path: p5.Image/filter - blend: - description: > -

Copies a region of pixels from another image into this one.

- -

The first parameter, srcImage, is the - - p5.Image object to blend.

- -

The next four parameters, sx, sy, - sw, and sh determine the region - - to blend from the source image. (sx, sy) is the top-left - corner of the - - region. sw and sh are the regions width and - height.

- -

The next four parameters, dx, dy, - dw, and dh determine the region - - of the canvas to blend into. (dx, dy) is the top-left corner - of the - - region. dw and dh are the regions width and - height.

- -

The tenth parameter, blendMode, sets the effect used to - blend the images' - - colors. The options are BLEND, DARKEST, - LIGHTEST, DIFFERENCE, - - MULTIPLY, EXCLUSION, SCREEN, - REPLACE, OVERLAY, HARD_LIGHT, - - SOFT_LIGHT, DODGE, BURN, - ADD, or NORMAL.

- path: p5.Image/blend - save: - description: > -

Saves the image to a file.

- -

By default, img.save() saves the image as a PNG image - called - - untitled.png.

- -

The first parameter, filename, is optional. It's a string - that sets the - - file's name. If a file extension is included, as in - - img.save('drawing.png'), then the image will be saved using - that - - format.

- -

The second parameter, extension, is also optional. It sets - the files format. - - Either 'png' or 'jpg' can be used. For example, - img.save('drawing', 'jpg') - - saves the canvas to a file called drawing.jpg.

- -

Note: The browser will either save the file immediately or prompt the - user - - with a dialogue window.

- -

The image will only be downloaded as an animated GIF if it was loaded - - from a GIF file. See saveGif() to - create new - - GIFs.

- path: p5.Image/save - reset: - description: | -

Restarts an animated GIF at its first frame.

- path: p5.Image/reset - getCurrentFrame: - description: | -

Gets the index of the current frame in an animated GIF.

- path: p5.Image/getCurrentFrame - setFrame: - description: | -

Sets the current frame in an animated GIF.

- path: p5.Image/setFrame - numFrames: - description: | -

Returns the number of frames in an animated GIF.

- path: p5.Image/numFrames - play: - description: | -

Plays an animated GIF that was paused with - img.pause().

- path: p5.Image/play - pause: - description: | -

Pauses an animated GIF.

-

The GIF can be resumed by calling - img.play().

- path: p5.Image/pause - delay: - description: > -

Changes the delay between frames in an animated GIF.

- -

The first parameter, delay, is the length of the delay in - milliseconds.

- -

The second parameter, index, is optional. If provided, - only the frame - - at index will have its delay modified. All other frames will - keep - - their default delay.

- path: p5.Image/delay -properties: - width: - description: | -

The image's width in pixels.

- path: p5.Image/width - height: - description: | -

The image's height in pixels.

- path: p5.Image/height - pixels: - description: > -

An array containing the color of each pixel in the image.

- -

Colors are stored as numbers representing red, green, blue, and alpha - - (RGBA) values. img.pixels is a one-dimensional array for - performance - - reasons.

- -

Each pixel occupies four elements in the pixels array, one for each - - RGBA value. For example, the pixel at coordinates (0, 0) stores its - - RGBA values at img.pixels[0], img.pixels[1], - img.pixels[2], - - and img.pixels[3], respectively. The next pixel at - coordinates (1, 0) - - stores its RGBA values at img.pixels[4], - img.pixels[5], - - img.pixels[6], and img.pixels[7]. And so on. The - img.pixels array - - for a 100×100 p5.Image object has - - 100 × 100 × 4 = 40,000 elements.

- -

Accessing the RGBA values for a pixel in the image requires a little - - math as shown in the examples below. The - - img.loadPixels() - - method must be called before accessing the img.pixels array. - The - - img.updatePixels() method - must be - - called after any changes are made.

- path: p5.Image/pixels -chainable: false ---- - - -# p5.Image diff --git a/src/content/reference/en/p5 copy/p5.MediaElement.mdx b/src/content/reference/en/p5 copy/p5.MediaElement.mdx deleted file mode 100644 index ee05412502..0000000000 --- a/src/content/reference/en/p5 copy/p5.MediaElement.mdx +++ /dev/null @@ -1,258 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L4099 -title: p5.MediaElement -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

A class to handle audio and video.

- -

p5.MediaElement extends p5.Element with - - methods to handle audio and video. p5.MediaElement objects are - created by - - calling createVideo, - - createAudio, and - - createCapture.

-line: 4099 -isConstructor: true -params: - - name: elt - description: | -

DOM node that is wrapped

- type: String -example: - - |- - -
- - let capture; - - function setup() { - createCanvas(100, 100); - - // Create a p5.MediaElement using createCapture(). - capture = createCapture(VIDEO); - capture.hide(); - - describe('A webcam feed with inverted colors.'); - } - - function draw() { - // Display the video stream and invert the colors. - image(capture, 0, 0, width, width * capture.height / capture.width); - filter(INVERT); - } - -
-methods: - play: - description: | -

Plays audio or video from a media element.

- path: p5.MediaElement/play - stop: - description: > -

Stops a media element and sets its current time to 0.

- -

Calling media.play() will restart playing audio/video from - the beginning.

- path: p5.MediaElement/stop - pause: - description: > -

Pauses a media element.

- -

Calling media.play() will resume playing audio/video from - the moment it paused.

- path: p5.MediaElement/pause - loop: - description: | -

Plays the audio/video repeatedly in a loop.

- path: p5.MediaElement/loop - noLoop: - description: | -

Stops the audio/video from playing in a loop.

-

The media will stop when it finishes playing.

- path: p5.MediaElement/noLoop - autoplay: - description: > -

Sets the audio/video to play once it's loaded.

- -

The parameter, shouldAutoplay, is optional. Calling - - media.autoplay() without an argument causes the media to play - - automatically. If true is passed, as in - media.autoplay(true), the - - media will automatically play. If false is passed, as in - - media.autoPlay(false), it won't play automatically.

- path: p5.MediaElement/autoplay - volume: - description: > -

Sets the audio/video volume.

- -

Calling media.volume() without an argument returns the - current volume - - as a number in the range 0 (off) to 1 (maximum).

- -

The parameter, val, is optional. It's a number that sets - the volume - - from 0 (off) to 1 (maximum). For example, calling - media.volume(0.5) - - sets the volume to half of its maximum.

- path: p5.MediaElement/volume - speed: - description: > -

Sets the audio/video playback speed.

- -

The parameter, val, is optional. It's a number that sets - the playback - - speed. 1 plays the media at normal speed, 0.5 plays it at half speed, 2 - - plays it at double speed, and so on. -1 plays the media at normal speed - - in reverse.

- -

Calling media.speed() returns the current speed as a - number.

- -

Note: Not all browsers support backward playback. Even if they do, - - playback might not be smooth.

- path: p5.MediaElement/speed - time: - description: > -

Sets the media element's playback time.

- -

The parameter, time, is optional. It's a number that - specifies the - - time, in seconds, to jump to when playback begins.

- -

Calling media.time() without an argument returns the - number of seconds - - the audio/video has played.

- -

Note: Time resets to 0 when looping media restarts.

- path: p5.MediaElement/time - duration: - description: | -

Returns the audio/video's duration in seconds.

- path: p5.MediaElement/duration - onended: - description: > -

Calls a function when the audio/video reaches the end of its - playback.

- -

The element is passed as an argument to the callback function.

- -

Note: The function won't be called if the media is looping.

- path: p5.MediaElement/onended - connect: - description: > -

Sends the element's audio to an output.

- -

The parameter, audioNode, can be an AudioNode - or an object from the - - p5.sound library.

- -

If no element is provided, as in myElement.connect(), the - element - - connects to the main output. All connections are removed by the - - .disconnect() method.

- -

Note: This method is meant to be used with the p5.sound.js addon - library.

- path: p5.MediaElement/connect - disconnect: - description: > -

Disconnect all Web Audio routing, including to the main output.

- -

This is useful if you want to re-route the output through audio - effects, - - for example.

- path: p5.MediaElement/disconnect - showControls: - description: > -

Show the default - - HTMLMediaElement - - controls.

- -

Note: The controls vary between web browsers.

- path: p5.MediaElement/showControls - hideControls: - description: > -

Hide the default - - HTMLMediaElement - - controls.

- path: p5.MediaElement/hideControls - addCue: - description: > -

Schedules a function to call when the audio/video reaches a specific - time - - during its playback.

- -

The first parameter, time, is the time, in seconds, when - the function - - should run. This value is passed to callback as its first - argument.

- -

The second parameter, callback, is the function to call at - the specified - - cue time.

- -

The third parameter, value, is optional and can be any - type of value. - - value is passed to callback.

- -

Calling media.addCue() returns an ID as a string. This is - useful for - - removing the cue later.

- path: p5.MediaElement/addCue - removeCue: - description: | -

Removes a callback based on its ID.

- path: p5.MediaElement/removeCue - clearCues: - description: | -

Removes all functions scheduled with media.addCue().

- path: p5.MediaElement/clearCues -properties: - src: - description: | -

Path to the media element's source as a string.

- path: p5.MediaElement/src -chainable: false ---- - - -# p5.MediaElement diff --git a/src/content/reference/en/p5 copy/p5.NumberDict.mdx b/src/content/reference/en/p5 copy/p5.NumberDict.mdx deleted file mode 100644 index d385eb1468..0000000000 --- a/src/content/reference/en/p5 copy/p5.NumberDict.mdx +++ /dev/null @@ -1,63 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/data/p5.TypedDict.js#L415 -title: p5.NumberDict -module: Data -submodule: Dictionary -file: src/data/p5.TypedDict.js -description: | -

A simple Dictionary class for Numbers.

-line: 415 -isConstructor: true -methods: - add: - description: | -

Add the given number to the value currently stored at the given key. - The sum then replaces the value previously stored in the Dictionary.

- path: p5.NumberDict/add - sub: - description: > -

Subtract the given number from the value currently stored at the given - key. - - The difference then replaces the value previously stored in the - Dictionary.

- path: p5.NumberDict/sub - mult: - description: > -

Multiply the given number with the value currently stored at the given - key. - - The product then replaces the value previously stored in the - Dictionary.

- path: p5.NumberDict/mult - div: - description: > -

Divide the given number with the value currently stored at the given - key. - - The quotient then replaces the value previously stored in the - Dictionary.

- path: p5.NumberDict/div - minValue: - description: | -

Return the lowest number currently stored in the Dictionary.

- path: p5.NumberDict/minValue - maxValue: - description: | -

Return the highest number currently stored in the Dictionary.

- path: p5.NumberDict/maxValue - minKey: - description: | -

Return the lowest key currently used in the Dictionary.

- path: p5.NumberDict/minKey - maxKey: - description: | -

Return the highest key currently used in the Dictionary.

- path: p5.NumberDict/maxKey -chainable: false ---- - - -# p5.NumberDict diff --git a/src/content/reference/en/p5 copy/p5.PrintWriter.mdx b/src/content/reference/en/p5 copy/p5.PrintWriter.mdx deleted file mode 100644 index 7662b4f910..0000000000 --- a/src/content/reference/en/p5 copy/p5.PrintWriter.mdx +++ /dev/null @@ -1,35 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1565 -title: p5.PrintWriter -module: IO -submodule: Output -file: src/io/files.js -description: > -

A class to describe a print stream.

- -

Each p5.PrintWriter object provides a way to save a sequence - of text - - data, called the print stream, to the user's computer. It's a - low-level - - object that enables precise control of text output. Functions such as - - saveStrings() and - - saveJSON() are easier to use for simple - file - - saving.

- -

Note: createWriter() is the - recommended way - - to make an instance of this class.

-line: 1565 ---- - - -# p5.PrintWriter diff --git a/src/content/reference/en/p5 copy/p5.Renderer.mdx b/src/content/reference/en/p5 copy/p5.Renderer.mdx deleted file mode 100644 index 5fa9dd1cd1..0000000000 --- a/src/content/reference/en/p5 copy/p5.Renderer.mdx +++ /dev/null @@ -1,34 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/p5.Renderer.js#L10 -title: p5.Renderer -module: Rendering -submodule: Rendering -file: src/core/p5.Renderer.js -description: | -

Main graphics and rendering context, as well as the base API - implementation for p5.js "core". To be used as the superclass for - Renderer2D and Renderer3D classes, respectively.

-line: 10 -isConstructor: true -params: - - name: elt - description: | -

DOM node that is wrapped

- type: HTMLElement - - name: pInst - description: | -

pointer to p5 instance

- type: P5 - optional: true - - name: isMainCanvas - description: | -

whether we're using it as main canvas

- type: Boolean - optional: true -chainable: false ---- - - -# p5.Renderer diff --git a/src/content/reference/en/p5 copy/p5.Shader.mdx b/src/content/reference/en/p5 copy/p5.Shader.mdx deleted file mode 100644 index 1730091ac1..0000000000 --- a/src/content/reference/en/p5 copy/p5.Shader.mdx +++ /dev/null @@ -1,433 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Shader.js#L11 -title: p5.Shader -module: 3D -submodule: Material -file: src/webgl/p5.Shader.js -description: > -

A class to describe a shader program.

- -

Each p5.Shader object contains a shader program that runs on - the graphics - - processing unit (GPU). Shaders can process many pixels or vertices at the - - same time, making them fast for many graphics tasks. They’re written in a - - language called - - GLSL - - and run along with the rest of the code in a sketch.

- -

A shader program consists of two files, a vertex shader and a fragment - - shader. The vertex shader affects where 3D geometry is drawn on the screen - - and the fragment shader affects color. Once the p5.Shader object - is - - created, it can be used with the shader() - - function, as in shader(myShader).

- -

A shader can optionally describe hooks, which are functions in - GLSL that - - users may choose to provide to customize the behavior of the shader. For the - - vertex or the fragment shader, users can pass in an object where each key is - - the type and name of a hook function, and each value is a string with the - - parameter list and default implementation of the hook. For example, to let - users - - optionally run code at the start of the vertex shader, the options object - could - - include:

- -
{
-    vertex: {
-      'void beforeVertex': '() {}'
-    }
-  }
-
-  
- -

Then, in your vertex shader source, you can run a hook by calling a - function - - with the same name prefixed by HOOK_:

- -
void main() {
-    HOOK_beforeVertex();
-    // Add the rest of your shader code here!
-  }
-
-  
- -

Note: createShader(), - - createFilterShader(), and - - loadShader() are the recommended ways - to - - create an instance of this class.

-line: 11 -isConstructor: true -params: - - name: renderer - description: | -

WebGL context for this shader.

- type: p5.RendererGL - - name: vertSrc - description: | -

source code for the vertex shader program.

- type: String - - name: fragSrc - description: | -

source code for the fragment shader program.

- type: String - - name: options - description: > -

An optional object describing how this shader can - - be augmented with hooks. It can include:

- -
    - -
  • vertex: An object describing the available vertex shader - hooks.
  • - -
  • fragment: An object describing the available frament - shader hooks.
  • - -
- type: Object - optional: true -example: - - |- - -
- - // Note: A "uniform" is a global variable within a shader program. - - // Create a string with the vertex shader program. - // The vertex shader is called for each vertex. - let vertSrc = ` - precision highp float; - uniform mat4 uModelViewMatrix; - uniform mat4 uProjectionMatrix; - - attribute vec3 aPosition; - attribute vec2 aTexCoord; - varying vec2 vTexCoord; - - void main() { - vTexCoord = aTexCoord; - vec4 positionVec4 = vec4(aPosition, 1.0); - gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; - } - `; - - // Create a string with the fragment shader program. - // The fragment shader is called for each pixel. - let fragSrc = ` - precision highp float; - - void main() { - // Set each pixel's RGBA value to yellow. - gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); - } - `; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Shader object. - let myShader = createShader(vertSrc, fragSrc); - - // Apply the p5.Shader object. - shader(myShader); - - // Style the drawing surface. - noStroke(); - - // Add a plane as a drawing surface. - plane(100, 100); - - describe('A yellow square.'); - } - -
- -
- - // Note: A "uniform" is a global variable within a shader program. - - let mandelbrot; - - // Load the shader and create a p5.Shader object. - function preload() { - mandelbrot = loadShader('/assets/shader.vert', '/assets/shader.frag'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - // Use the p5.Shader object. - shader(mandelbrot); - - // Set the shader uniform p to an array. - mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); - - describe('A fractal image zooms in and out of focus.'); - } - - function draw() { - // Set the shader uniform r to a value that oscillates between 0 and 2. - mandelbrot.setUniform('r', sin(frameCount * 0.01) + 1); - - // Add a quad as a display surface for the shader. - quad(-1, -1, 1, -1, 1, 1, -1, 1); - } - -
-methods: - inspectHooks: - description: > -

Logs the hooks available in this shader, and their current - implementation.

- -

Each shader may let you override bits of its behavior. Each bit is - called - - a hook. A hook is either for the vertex shader, if it - affects the - - position of vertices, or in the fragment shader, if it affects - the pixel - - color. This method logs those values to the console, letting you know what - - you are able to use in a call to - - modify().

- -

For example, this shader will produce the following output:

- -
myShader = baseMaterialShader().modify({
-        declarations: 'uniform float time;',
-        'vec3 getWorldPosition': `(vec3 pos) {
-          pos.y += 20. * sin(time * 0.001 + pos.x * 0.05);
-          return pos;
-        }`
-      });
-
-      myShader.inspectHooks();
-
-      
- -
==== Vertex shader hooks: ====
-
-      void beforeVertex() {}
-
-      vec3 getLocalPosition(vec3 position) { return position; }
-
-      [MODIFIED] vec3 getWorldPosition(vec3 pos) {
-            pos.y += 20. * sin(time * 0.001 + pos.x * 0.05);
-            return pos;
-          }
-      vec3 getLocalNormal(vec3 normal) { return normal; }
-
-      vec3 getWorldNormal(vec3 normal) { return normal; }
-
-      vec2 getUV(vec2 uv) { return uv; }
-
-      vec4 getVertexColor(vec4 color) { return color; }
-
-      void afterVertex() {}
-
-
-      ==== Fragment shader hooks: ====
-
-      void beforeFragment() {}
-
-      Inputs getPixelInputs(Inputs inputs) { return inputs; }
-
-      vec4 combineColors(ColorComponents components) {
-                      vec4 color = vec4(0.);
-                      color.rgb += components.diffuse * components.baseColor;
-                      color.rgb += components.ambient * components.ambientColor;
-                      color.rgb += components.specular * components.specularColor;
-                      color.rgb += components.emissive;
-                      color.a = components.opacity;
-                      return color;
-                    }
-      vec4 getFinalColor(vec4 color) { return color; }
-
-      void afterFragment() {}
-
-      
- path: p5.Shader/inspectHooks - modify: - description: > -

Returns a new shader, based on the original, but with custom snippets - - of shader code replacing default behaviour.

- -

Each shader may let you override bits of its behavior. Each bit is - called - - a hook. A hook is either for the vertex shader, if it - affects the - - position of vertices, or in the fragment shader, if it affects - the pixel - - color. You can inspect the different hooks available by calling - - yourShader.inspectHooks(). - You can - - also read the reference for the default material, normal material, color, - line, and point shaders to - - see what hooks they have available.

- -

modify() takes one parameter, hooks, an - object with the hooks you want - - to override. Each key of the hooks object is the name - - of a hook, and the value is a string with the GLSL code for your hook.

- -

If you supply functions that aren't existing hooks, they will get added - at the start of - - the shader as helper functions so that you can use them in your hooks.

- -

To add new uniforms to - your shader, you can pass in a uniforms object containing - - the type and name of the uniform as the key, and a default value or - function returning - - a default value as its value. These will be automatically set when the - shader is set - - with shader(yourShader).

- -

You can also add a declarations key, where the value is a - GLSL string declaring - - custom uniform variables, globals, and functions shared - - between hooks. To add declarations just in a vertex or fragment shader, - add - - vertexDeclarations and fragmentDeclarations - keys.

- path: p5.Shader/modify - copyToContext: - description: > -

Copies the shader from one drawing context to another.

- -

Each p5.Shader object must be compiled by calling - - shader() before it can run. - Compilation happens - - in a drawing context which is usually the main canvas or an instance of - - p5.Graphics. A shader can only be - used in the - - context where it was compiled. The copyToContext() method - compiles the - - shader again and copies it to another drawing context where it can be - - reused.

- -

The parameter, context, is the drawing context where the - shader will be - - used. The shader can be copied to an instance of - - p5.Graphics, as in - - myShader.copyToContext(pg). The shader can also be copied - from a - - p5.Graphics object to the main - canvas using - - the window variable, as in - myShader.copyToContext(window).

- -

Note: A p5.Shader object created - with - - createShader(), - - createFilterShader(), or - - loadShader() - - can be used directly with a p5.Framebuffer - - object created with - - createFramebuffer(). Both - objects - - have the same context as the main canvas.

- path: p5.Shader/copyToContext - setUniform: - description: > -

Sets the shader’s uniform (global) variables.

- -

Shader programs run on the computer’s graphics processing unit (GPU). - - They live in part of the computer’s memory that’s completely separate - - from the sketch that runs them. Uniforms are global variables within a - - shader program. They provide a way to pass values from a sketch running - - on the CPU to a shader program running on the GPU.

- -

The first parameter, uniformName, is a string with the - uniform’s name. - - For the shader above, uniformName would be - 'r'.

- -

The second parameter, data, is the value that should be - used to set the - - uniform. For example, calling myShader.setUniform('r', 0.5) - would set - - the r uniform in the shader above to 0.5. data - should match the - - uniform’s type. Numbers, strings, booleans, arrays, and many types of - - images can all be passed to a shader with setUniform().

- path: p5.Shader/setUniform -chainable: false ---- - - -# p5.Shader diff --git a/src/content/reference/en/p5 copy/p5.StringDict.mdx b/src/content/reference/en/p5 copy/p5.StringDict.mdx deleted file mode 100644 index 5ca466e5d1..0000000000 --- a/src/content/reference/en/p5 copy/p5.StringDict.mdx +++ /dev/null @@ -1,15 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/data/p5.TypedDict.js#L397 -title: p5.StringDict -module: Data -submodule: Dictionary -file: src/data/p5.TypedDict.js -description: | -

A simple Dictionary class for Strings.

-line: 397 ---- - - -# p5.StringDict diff --git a/src/content/reference/en/p5 copy/p5.Table.mdx b/src/content/reference/en/p5 copy/p5.Table.mdx deleted file mode 100644 index 41ad72b0d1..0000000000 --- a/src/content/reference/en/p5 copy/p5.Table.mdx +++ /dev/null @@ -1,213 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/p5.Table.js#L33 -title: p5.Table -module: IO -submodule: Table -file: src/io/p5.Table.js -description: > -

Table objects store data with multiple - rows and columns, much - - like in a traditional spreadsheet. Tables can be generated from - - scratch, dynamically, or using data from an existing file.

-line: 33 -isConstructor: true -params: - - name: rows - description: | -

An array of p5.TableRow objects

- type: 'p5.TableRow[]' - optional: true -methods: - addRow: - description: > -

Use addRow() to add a new row of - data to a p5.Table object. By - default, - - an empty row is created. Typically, you would store a reference to - - the new row in a TableRow object (see newRow in the example above), - - and then set individual values using set().

- -

If a p5.TableRow object is - included as a parameter, then that row is - - duplicated and added to the table.

- path: p5.Table/addRow - removeRow: - description: | -

Removes a row from the table object.

- path: p5.Table/removeRow - getRow: - description: > -

Returns a reference to the specified p5.TableRow. The reference - - can then be used to get and set values of the selected row.

- path: p5.Table/getRow - getRows: - description: > -

Gets all rows from the table. Returns an array of p5.TableRows.

- path: p5.Table/getRows - findRow: - description: | -

Finds the first row in the Table that contains the value - provided, and returns a reference to that row. Even if - multiple rows are possible matches, only the first matching - row is returned. The column to search may be specified by - either its ID or title.

- path: p5.Table/findRow - findRows: - description: | -

Finds the rows in the Table that contain the value - provided, and returns references to those rows. Returns an - Array, so for must be used to iterate through all the rows, - as shown in the example above. The column to search may be - specified by either its ID or title.

- path: p5.Table/findRows - matchRow: - description: | -

Finds the first row in the Table that matches the regular - expression provided, and returns a reference to that row. - Even if multiple rows are possible matches, only the first - matching row is returned. The column to search may be - specified by either its ID or title.

- path: p5.Table/matchRow - matchRows: - description: | -

Finds the rows in the Table that match the regular expression provided, - and returns references to those rows. Returns an array, so for must be - used to iterate through all the rows, as shown in the example. The - column to search may be specified by either its ID or title.

- path: p5.Table/matchRows - getColumn: - description: | -

Retrieves all values in the specified column, and returns them - as an array. The column may be specified by either its ID or title.

- path: p5.Table/getColumn - clearRows: - description: | -

Removes all rows from a Table. While all rows are removed, - columns and column titles are maintained.

- path: p5.Table/clearRows - addColumn: - description: > -

Use addColumn() to add a new - column to a Table object. - - Typically, you will want to specify a title, so the column - - may be easily referenced later by name. (If no title is - - specified, the new column's title will be null.)

- path: p5.Table/addColumn - getColumnCount: - description: | -

Returns the total number of columns in a Table.

- path: p5.Table/getColumnCount - getRowCount: - description: | -

Returns the total number of rows in a Table.

- path: p5.Table/getRowCount - removeTokens: - description: | -

Removes any of the specified characters (or "tokens").

-

If no column is specified, then the values in all columns and - rows are processed. A specific column may be referenced by - either its ID or title.

- path: p5.Table/removeTokens - trim: - description: | -

Trims leading and trailing whitespace, such as spaces and tabs, - from String table values. If no column is specified, then the - values in all columns and rows are trimmed. A specific column - may be referenced by either its ID or title.

- path: p5.Table/trim - removeColumn: - description: > -

Use removeColumn() to remove - an existing column from a Table - - object. The column to be removed may be identified by either - - its title (a String) or its index value (an int). - - removeColumn(0) would remove the first column, removeColumn(1) - - would remove the second column, and so on.

- path: p5.Table/removeColumn - set: - description: | -

Stores a value in the Table's specified row and column. - The row is specified by its ID, while the column may be specified - by either its ID or title.

- path: p5.Table/set - setNum: - description: | -

Stores a Float value in the Table's specified row and column. - The row is specified by its ID, while the column may be specified - by either its ID or title.

- path: p5.Table/setNum - setString: - description: | -

Stores a String value in the Table's specified row and column. - The row is specified by its ID, while the column may be specified - by either its ID or title.

- path: p5.Table/setString - get: - description: | -

Retrieves a value from the Table's specified row and column. - The row is specified by its ID, while the column may be specified by - either its ID or title.

- path: p5.Table/get - getNum: - description: | -

Retrieves a Float value from the Table's specified row and column. - The row is specified by its ID, while the column may be specified by - either its ID or title.

- path: p5.Table/getNum - getString: - description: | -

Retrieves a String value from the Table's specified row and column. - The row is specified by its ID, while the column may be specified by - either its ID or title.

- path: p5.Table/getString - getObject: - description: | -

Retrieves all table data and returns as an object. If a column name is - passed in, each row object will be stored with that attribute as its - title.

- path: p5.Table/getObject - getArray: - description: > -

Retrieves all table data and returns it as a multidimensional - array.

- path: p5.Table/getArray -properties: - columns: - description: > -

An array containing the names of the columns in the table, if the - "header" the table is - - loaded with the "header" parameter.

- path: p5.Table/columns - rows: - description: > -

An array containing the p5.TableRow objects that make up the - - rows of the table. The same result as calling getRows()

- path: p5.Table/rows -chainable: false ---- - - -# p5.Table diff --git a/src/content/reference/en/p5 copy/p5.TableRow.mdx b/src/content/reference/en/p5 copy/p5.TableRow.mdx deleted file mode 100644 index 00081f9654..0000000000 --- a/src/content/reference/en/p5 copy/p5.TableRow.mdx +++ /dev/null @@ -1,66 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/p5.TableRow.js#L9 -title: p5.TableRow -module: IO -submodule: Table -file: src/io/p5.TableRow.js -description: | -

A TableRow object represents a single row of data values, - stored in columns, from a table.

-

A Table Row contains both an ordered array, and an unordered - JSON object.

-line: 9 -isConstructor: true -params: - - name: str - description: | -

optional: populate the row with a - string of values, separated by the - separator

- type: String - optional: true - - name: separator - description: | -

comma separated values (csv) by default

- type: String - optional: true -methods: - set: - description: | -

Stores a value in the TableRow's specified column. - The column may be specified by either its ID or title.

- path: p5.TableRow/set - setNum: - description: | -

Stores a Float value in the TableRow's specified column. - The column may be specified by either its ID or title.

- path: p5.TableRow/setNum - setString: - description: | -

Stores a String value in the TableRow's specified column. - The column may be specified by either its ID or title.

- path: p5.TableRow/setString - get: - description: | -

Retrieves a value from the TableRow's specified column. - The column may be specified by either its ID or title.

- path: p5.TableRow/get - getNum: - description: | -

Retrieves a Float value from the TableRow's specified - column. The column may be specified by either its ID or - title.

- path: p5.TableRow/getNum - getString: - description: | -

Retrieves an String value from the TableRow's specified - column. The column may be specified by either its ID or - title.

- path: p5.TableRow/getString -chainable: false ---- - - -# p5.TableRow diff --git a/src/content/reference/en/p5 copy/p5.TypedDict.mdx b/src/content/reference/en/p5 copy/p5.TypedDict.mdx deleted file mode 100644 index 2bcb7b5752..0000000000 --- a/src/content/reference/en/p5 copy/p5.TypedDict.mdx +++ /dev/null @@ -1,66 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/data/p5.TypedDict.js#L82 -title: p5.TypedDict -module: Data -submodule: Dictionary -file: src/data/p5.TypedDict.js -description: | -

Base class for all p5.Dictionary types. Specifically - typed Dictionary classes inherit from this class.

-line: 82 -isConstructor: true -methods: - size: - description: > -

Returns the number of key-value pairs currently stored in the - Dictionary.

- path: p5.TypedDict/size - hasKey: - description: | -

Returns true if the given key exists in the Dictionary, - otherwise returns false.

- path: p5.TypedDict/hasKey - get: - description: | -

Returns the value stored at the given key.

- path: p5.TypedDict/get - set: - description: > -

Updates the value associated with the given key in case it already - exists - - in the Dictionary. Otherwise a new key-value pair is added.

- path: p5.TypedDict/set - create: - description: | -

Creates a new key-value pair in the Dictionary.

- path: p5.TypedDict/create - clear: - description: | -

Removes all previously stored key-value pairs from the Dictionary.

- path: p5.TypedDict/clear - remove: - description: > -

Removes the key-value pair stored at the given key from the - Dictionary.

- path: p5.TypedDict/remove - print: - description: > -

Logs the set of items currently stored in the Dictionary to the - console.

- path: p5.TypedDict/print - saveTable: - description: | -

Converts the Dictionary into a CSV file for local download.

- path: p5.TypedDict/saveTable - saveJSON: - description: | -

Converts the Dictionary into a JSON file for local download.

- path: p5.TypedDict/saveJSON -chainable: false ---- - - -# p5.TypedDict diff --git a/src/content/reference/en/p5 copy/p5.Vector.mdx b/src/content/reference/en/p5 copy/p5.Vector.mdx deleted file mode 100644 index ff67d7562c..0000000000 --- a/src/content/reference/en/p5 copy/p5.Vector.mdx +++ /dev/null @@ -1,673 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/p5.Vector.js#L11 -title: p5.Vector -module: Math -submodule: Vector -file: src/math/p5.Vector.js -description: > -

A class to describe a two or three-dimensional vector.

- -

A vector can be thought of in different ways. In one view, a vector is like - - an arrow pointing in space. Vectors have both magnitude (length) and - - direction.

- -

p5.Vector objects are often used to program motion because - they simplify - - the math. For example, a moving ball has a position and a velocity. - - Position describes where the ball is in space. The ball's position vector - - extends from the origin to the ball's center. Velocity describes the ball's - - speed and the direction it's moving. If the ball is moving straight up, its - - velocity vector points straight up. Adding the ball's velocity vector to - - its position vector moves it, as in pos.add(vel). Vector math - relies on - - methods inside the p5.Vector class.

- -

Note: createVector() is the - recommended way - - to make an instance of this class.

-line: 11 -isConstructor: true -params: - - name: x - description: | -

x component of the vector.

- type: Number - optional: true - - name: 'y' - description: | -

y component of the vector.

- type: Number - optional: true - - name: z - description: | -

z component of the vector.

- type: Number - optional: true -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create p5.Vector objects. - let p1 = createVector(25, 25); - let p2 = createVector(75, 75); - - // Style the points. - strokeWeight(5); - - // Draw the first point using a p5.Vector. - point(p1); - - // Draw the second point using a p5.Vector's components. - point(p2.x, p2.y); - - describe('Two black dots on a gray square, one at the top left and the other at the bottom right.'); - } - -
- -
- - let pos; - let vel; - - function setup() { - createCanvas(100, 100); - - // Create p5.Vector objects. - pos = createVector(50, 100); - vel = createVector(0, -1); - - describe('A black dot moves from bottom to top on a gray square. The dot reappears at the bottom when it reaches the top.'); - } - - function draw() { - background(200); - - // Add velocity to position. - pos.add(vel); - - // If the dot reaches the top of the canvas, - // restart from the bottom. - if (pos.y < 0) { - pos.y = 100; - } - - // Draw the dot. - strokeWeight(5); - point(pos); - } - -
-methods: - toString: - description: > -

Returns a string representation of a vector.

- -

Calling toString() is useful for printing vectors to the - console while - - debugging.

- path: p5.Vector/toString - set: - description: > -

Sets the vector's x, y, and z - components.

- -

set() can use separate numbers, as in v.set(1, 2, - 3), a - - p5.Vector object, as in - v.set(v2), or an - - array of numbers, as in v.set([1, 2, 3]).

- -

If a value isn't provided for a component, it will be set to 0. For - - example, v.set(4, 5) sets v.x to 4, - v.y to 5, and v.z to 0. - - Calling set() with no arguments, as in v.set(), - sets all the vector's - - components to 0.

- path: p5.Vector/set - copy: - description: > -

Returns a copy of the p5.Vector - object.

- path: p5.Vector/copy - add: - description: > -

Adds to a vector's x, y, and z - components.

- -

add() can use separate numbers, as in v.add(1, 2, - 3), - - another p5.Vector object, as in - v.add(v2), or - - an array of numbers, as in v.add([1, 2, 3]).

- -

If a value isn't provided for a component, it won't change. For - - example, v.add(4, 5) adds 4 to v.x, 5 to - v.y, and 0 to v.z. - - Calling add() with no arguments, as in v.add(), - has no effect.

- -

The static version of add(), as in p5.Vector.add(v2, - v1), returns a new - - p5.Vector object and doesn't change - the - - originals.

- path: p5.Vector/add - rem: - description: > -

Performs modulo (remainder) division with a vector's x, - y, and z - - components.

- -

rem() can use separate numbers, as in v.rem(1, 2, - 3), - - another p5.Vector object, as in - v.rem(v2), or - - an array of numbers, as in v.rem([1, 2, 3]).

- -

If only one value is provided, as in v.rem(2), then all - the components - - will be set to their values modulo 2. If two values are provided, as in - - v.rem(2, 3), then v.z won't change. Calling - rem() with no - - arguments, as in v.rem(), has no effect.

- -

The static version of rem(), as in p5.Vector.rem(v2, - v1), returns a - - new p5.Vector object and doesn't - change the - - originals.

- path: p5.Vector/rem - sub: - description: > -

Subtracts from a vector's x, y, and - z components.

- -

sub() can use separate numbers, as in v.sub(1, 2, - 3), another - - p5.Vector object, as in - v.sub(v2), or an array - - of numbers, as in v.sub([1, 2, 3]).

- -

If a value isn't provided for a component, it won't change. For - - example, v.sub(4, 5) subtracts 4 from v.x, 5 - from v.y, and 0 from v.z. - - Calling sub() with no arguments, as in v.sub(), - has no effect.

- -

The static version of sub(), as in p5.Vector.sub(v2, - v1), returns a new - - p5.Vector object and doesn't change - the - - originals.

- path: p5.Vector/sub - mult: - description: > -

Multiplies a vector's x, y, and - z components.

- -

mult() can use separate numbers, as in v.mult(1, 2, - 3), another - - p5.Vector object, as in - v.mult(v2), or an array - - of numbers, as in v.mult([1, 2, 3]).

- -

If only one value is provided, as in v.mult(2), then all - the components - - will be multiplied by 2. If a value isn't provided for a component, it - - won't change. For example, v.mult(4, 5) multiplies - v.x by 4, v.y by 5, - - and v.z by 1. Calling mult() with no arguments, - as in v.mult(), has - - no effect.

- -

The static version of mult(), as in - p5.Vector.mult(v, 2), returns a new - - p5.Vector object and doesn't change - the - - originals.

- path: p5.Vector/mult - div: - description: > -

Divides a vector's x, y, and z - components.

- -

div() can use separate numbers, as in v.div(1, 2, - 3), another - - p5.Vector object, as in - v.div(v2), or an array - - of numbers, as in v.div([1, 2, 3]).

- -

If only one value is provided, as in v.div(2), then all - the components - - will be divided by 2. If a value isn't provided for a component, it - - won't change. For example, v.div(4, 5) divides - v.x by, v.y by 5, - - and v.z by 1. Calling div() with no arguments, - as in v.div(), has - - no effect.

- -

The static version of div(), as in p5.Vector.div(v, - 2), returns a new - - p5.Vector object and doesn't change - the - - originals.

- path: p5.Vector/div - mag: - description: > -

Calculates the magnitude (length) of the vector.

- -

Use mag() to calculate the magnitude - of a 2D vector - - using components as in mag(x, y).

- path: p5.Vector/mag - magSq: - description: | -

Calculates the magnitude (length) of the vector squared.

- path: p5.Vector/magSq - dot: - description: > -

Calculates the dot product of two vectors.

- -

The dot product is a number that describes the overlap between two - vectors. - - Visually, the dot product can be thought of as the "shadow" one vector - - casts on another. The dot product's magnitude is largest when two vectors - - point in the same or opposite directions. Its magnitude is 0 when two - - vectors form a right angle.

- -

The version of dot() with one parameter interprets it as - another - - p5.Vector object.

- -

The version of dot() with multiple parameters interprets - them as the - - x, y, and z components of another - vector.

- -

The static version of dot(), as in p5.Vector.dot(v1, - v2), is the same - - as calling v1.dot(v2).

- path: p5.Vector/dot - cross: - description: > -

Calculates the cross product of two vectors.

- -

The cross product is a vector that points straight out of the plane - created - - by two vectors. The cross product's magnitude is the area of the - parallelogram - - formed by the original two vectors.

- -

The static version of cross(), as in - p5.Vector.cross(v1, v2), is the same - - as calling v1.cross(v2).

- path: p5.Vector/cross - dist: - description: > -

Calculates the distance between two points represented by vectors.

- -

A point's coordinates can be represented by the components of a vector - - that extends from the origin to the point.

- -

The static version of dist(), as in - p5.Vector.dist(v1, v2), is the same - - as calling v1.dist(v2).

- -

Use dist() to calculate the distance - between points - - using coordinates as in dist(x1, y1, x2, y2).

- path: p5.Vector/dist - normalize: - description: > -

Scales the components of a p5.Vector object so - - that its magnitude is 1.

- -

The static version of normalize(), as in - p5.Vector.normalize(v), - - returns a new p5.Vector object and - doesn't change - - the original.

- path: p5.Vector/normalize - limit: - description: > -

Limits a vector's magnitude to a maximum value.

- -

The static version of limit(), as in - p5.Vector.limit(v, 5), returns a - - new p5.Vector object and doesn't - change the - - original.

- path: p5.Vector/limit - setMag: - description: > -

Sets a vector's magnitude to a given value.

- -

The static version of setMag(), as in - p5.Vector.setMag(v, 10), returns - - a new p5.Vector object and doesn't - change the - - original.

- path: p5.Vector/setMag - heading: - description: > -

Calculates the angle a 2D vector makes with the positive x-axis.

- -

By convention, the positive x-axis has an angle of 0. Angles increase - in - - the clockwise direction.

- -

If the vector was created with - - createVector(), - heading() returns angles - - in the units of the current angleMode().

- -

The static version of heading(), as in - p5.Vector.heading(v), works the - - same way.

- path: p5.Vector/heading - setHeading: - description: > -

Rotates a 2D vector to a specific angle without changing its - magnitude.

- -

By convention, the positive x-axis has an angle of 0. Angles increase - in - - the clockwise direction.

- -

If the vector was created with - - createVector(), - setHeading() uses - - the units of the current angleMode().

- path: p5.Vector/setHeading - rotate: - description: > -

Rotates a 2D vector by an angle without changing its magnitude.

- -

By convention, the positive x-axis has an angle of 0. Angles increase - in - - the clockwise direction.

- -

If the vector was created with - - createVector(), - rotate() uses - - the units of the current angleMode().

- -

The static version of rotate(), as in - p5.Vector.rotate(v, PI), - - returns a new p5.Vector object and - doesn't change - - the original.

- path: p5.Vector/rotate - angleBetween: - description: > -

Calculates the angle between two vectors.

- -

The angles returned are signed, which means that - - v1.angleBetween(v2) === -v2.angleBetween(v1).

- -

If the vector was created with - - createVector(), - angleBetween() returns - - angles in the units of the current - - angleMode().

- path: p5.Vector/angleBetween - lerp: - description: > -

Calculates new x, y, and z - components that are proportionally the - - same distance between two vectors.

- -

The amt parameter is the amount to interpolate between the - old vector and - - the new vector. 0.0 keeps all components equal to the old vector's, 0.5 is - - halfway between, and 1.0 sets all components equal to the new - vector's.

- -

The static version of lerp(), as in - p5.Vector.lerp(v0, v1, 0.5), - - returns a new p5.Vector object and - doesn't change - - the original.

- path: p5.Vector/lerp - slerp: - description: > -

Calculates a new heading and magnitude that are between two - vectors.

- -

The amt parameter is the amount to interpolate between the - old vector and - - the new vector. 0.0 keeps the heading and magnitude equal to the old - - vector's, 0.5 sets them halfway between, and 1.0 sets the heading and - - magnitude equal to the new vector's.

- -

slerp() differs from lerp() because - - it interpolates magnitude. Calling v0.slerp(v1, 0.5) sets - v0's - - magnitude to a value halfway between its original magnitude and - v1's. - - Calling v0.lerp(v1, 0.5) makes no such guarantee.

- -

The static version of slerp(), as in - p5.Vector.slerp(v0, v1, 0.5), - - returns a new p5.Vector object and - doesn't change - - the original.

- path: p5.Vector/slerp - reflect: - description: > -

Reflects a vector about a line in 2D or a plane in 3D.

- -

The orientation of the line or plane is described by a normal vector - that - - points away from the shape.

- -

The static version of reflect(), as in - p5.Vector.reflect(v, n), - - returns a new p5.Vector object and - doesn't change - - the original.

- path: p5.Vector/reflect - array: - description: | -

Returns the vector's components as an array of numbers.

- path: p5.Vector/array - equals: - description: > -

Checks whether all the vector's components are equal to another - vector's.

- -

equals() returns true if the vector's - components are all the same as another - - vector's and false if not.

- -

The version of equals() with one parameter interprets it - as another - - p5.Vector object.

- -

The version of equals() with multiple parameters - interprets them as the - - components of another vector. Any missing parameters are assigned the - value - - 0.

- -

The static version of equals(), as in - p5.Vector.equals(v0, v1), - - interprets both parameters as p5.Vector objects.

- path: p5.Vector/equals - fromAngle: - description: | -

Creates a new 2D vector from an angle.

- path: p5.Vector/fromAngle - fromAngles: - description: | -

Creates a new 3D vector from a pair of ISO spherical angles.

- path: p5.Vector/fromAngles - random2D: - description: | -

Creates a new 2D unit vector with a random heading.

- path: p5.Vector/random2D - random3D: - description: | -

Creates a new 3D unit vector with a random heading.

- path: p5.Vector/random3D - clampToZero: - description: > -

Replaces the components of a p5.Vector that are very close to zero - with zero.

- -

In computers, handling numbers with decimals can give slightly - imprecise answers due to the way those numbers are represented. - - This can make it hard to check if a number is zero, as it may be close but - not exactly zero. - - This method rounds very close numbers to zero to make those checks - easier

- -

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON

- path: p5.Vector/clampToZero -properties: - x: - description: | -

The x component of the vector

- path: p5.Vector/x - 'y': - description: | -

The y component of the vector

- path: p5.Vector/y - z: - description: | -

The z component of the vector

- path: p5.Vector/z -chainable: false ---- - - -# p5.Vector diff --git a/src/content/reference/en/p5 copy/p5.XML.mdx b/src/content/reference/en/p5 copy/p5.XML.mdx deleted file mode 100644 index 71904fded2..0000000000 --- a/src/content/reference/en/p5 copy/p5.XML.mdx +++ /dev/null @@ -1,321 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/p5.XML.js#L9 -title: p5.XML -module: IO -submodule: Input -file: src/io/p5.XML.js -description: > -

A class to describe an XML object.

- -

Each p5.XML object provides an easy way to interact with XML - data. - - Extensible Markup Language - - (XML) - - is a standard format for sending data between applications. Like HTML, the - - XML format is based on tags and attributes, as in - - .

- -

Note: Use loadXML() to load external - XML files.

-line: 9 -isConstructor: true -example: - - |- - -
- - let myXML; - - // Load the XML and create a p5.XML object. - function preload() { - myXML = loadXML('/assets/animals.xml'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Get an array with all mammal tags. - let mammals = myXML.getChildren('mammal'); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(14); - - // Iterate over the mammals array. - for (let i = 0; i < mammals.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 25; - - // Get the mammal's common name. - let name = mammals[i].getContent(); - - // Display the mammal's name. - text(name, 20, y); - } - - describe( - 'The words "Goat", "Leopard", and "Zebra" written on three separate lines. The text is black on a gray background.' - ); - } - -
-methods: - getParent: - description: > -

Returns the element's parent element as a new p5.XML - - object.

- path: p5.XML/getParent - getName: - description: > -

Returns the element's name as a String.

- -

An XML element's name is given by its tag. For example, the element - - JavaScript has the name - language.

- path: p5.XML/getName - setName: - description: > -

Sets the element's tag name.

- -

An XML element's name is given by its tag. For example, the element - - JavaScript has the name - language.

- -

The parameter, name, is the element's new name as a - string. For example, - - calling myXML.setName('planet') will make the element's new - tag name - - .

- path: p5.XML/setName - hasChildren: - description: > -

Returns true if the element has child elements and - false if not.

- path: p5.XML/hasChildren - listChildren: - description: | -

Returns an array with the names of the element's child elements as - Strings.

- path: p5.XML/listChildren - getChildren: - description: > -

Returns an array with the element's child elements as new - - p5.XML objects.

- -

The parameter, name, is optional. If a string is passed, - as in - - myXML.getChildren('cat'), then the method will only return - child elements - - with the tag .

- path: p5.XML/getChildren - getChild: - description: > -

Returns the first matching child element as a new - - p5.XML object.

- -

The parameter, name, is optional. If a string is passed, - as in - - myXML.getChild('cat'), then the first child element with the - tag - - will be returned. If a number is passed, as in - - myXML.getChild(1), then the child element at that index will - be returned.

- path: p5.XML/getChild - addChild: - description: > -

Adds a new child element and returns a reference to it.

- -

The parameter, child, is the p5.XML object to add - - as a child element. For example, calling - myXML.addChild(otherXML) inserts - - otherXML as a child element of myXML.

- path: p5.XML/addChild - removeChild: - description: > -

Removes the first matching child element.

- -

The parameter, name, is the child element to remove. If a - string is - - passed, as in myXML.removeChild('cat'), then the first child - element - - with the tag will be removed. If a number is passed, as - in - - myXML.removeChild(1), then the child element at that index - will be - - removed.

- path: p5.XML/removeChild - getAttributeCount: - description: | -

Returns the number of attributes the element has.

- path: p5.XML/getAttributeCount - listAttributes: - description: > -

Returns an Array with the names of the element's - attributes.

- -

Note: Use - - myXML.getString() or - - myXML.getNum() to return an - attribute's value.

- path: p5.XML/listAttributes - hasAttribute: - description: > -

Returns true if the element has a given attribute and - false if not.

- -

The parameter, name, is a string with the name of the - attribute being - - checked.

- -

Note: Use - - myXML.getString() or - - myXML.getNum() to return an - attribute's value.

- path: p5.XML/hasAttribute - getNum: - description: > -

Return an attribute's value as a Number.

- -

The first parameter, name, is a string with the name of - the attribute - - being checked. For example, calling myXML.getNum('id') - returns the - - element's id attribute as a number.

- -

The second parameter, defaultValue, is optional. If a - number is passed, - - as in myXML.getNum('id', -1), it will be returned if the - attribute - - doesn't exist or can't be converted to a number.

- -

Note: Use - - myXML.getString() or - - myXML.getNum() to return an - attribute's value.

- path: p5.XML/getNum - getString: - description: > -

Return an attribute's value as a string.

- -

The first parameter, name, is a string with the name of - the attribute - - being checked. For example, calling myXML.getString('color') - returns the - - element's id attribute as a string.

- -

The second parameter, defaultValue, is optional. If a - string is passed, - - as in myXML.getString('color', 'deeppink'), it will be - returned if the - - attribute doesn't exist.

- -

Note: Use - - myXML.getString() or - - myXML.getNum() to return an - attribute's value.

- path: p5.XML/getString - setAttribute: - description: > -

Sets an attribute to a given value.

- -

The first parameter, name, is a string with the name of - the attribute - - being set.

- -

The second parameter, value, is the attribute's new value. - For example, - - calling myXML.setAttribute('id', 123) sets the - id attribute to the - - value 123.

- path: p5.XML/setAttribute - getContent: - description: > -

Returns the element's content as a String.

- -

The parameter, defaultValue, is optional. If a string is - passed, as in - - myXML.getContent('???'), it will be returned if the element - has no - - content.

- path: p5.XML/getContent - setContent: - description: > -

Sets the element's content.

- -

An element's content is the text between its tags. For example, the - element - - JavaScript has the content - JavaScript.

- -

The parameter, content, is a string with the element's new - content.

- path: p5.XML/setContent - serialize: - description: > -

Returns the element as a String.

- -

myXML.serialize() is useful for sending the element over - the network or - - saving it to a file.

- path: p5.XML/serialize -chainable: false ---- - - -# p5.XML diff --git a/src/content/reference/en/p5 copy/p5.mdx b/src/content/reference/en/p5 copy/p5.mdx deleted file mode 100644 index c51b8f8bff..0000000000 --- a/src/content/reference/en/p5 copy/p5.mdx +++ /dev/null @@ -1,51 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L12 -title: p5 -module: IO -submodule: Output -file: src/core/main.js -description: > -

This is the p5 instance constructor.

- -

A p5 instance holds all the properties and methods related to - - a p5 sketch. It expects an incoming sketch closure and it can also - - take an optional node parameter for attaching the generated p5 canvas - - to a node. The sketch closure takes the newly created p5 instance as - - its sole argument and may optionally set preload(), - - setup(), and/or - - draw() properties on it for running a - sketch.

- -

A p5 sketch can run in "global" or "instance" mode: - - "global" - all properties and methods are attached to the window - - "instance" - all properties and methods are bound to this p5 object

-line: 12 -isConstructor: true -params: - - name: sketch - description: | -

a closure that can set optional preload(), - setup(), and/or draw() properties on the - given p5 instance

- type: Function(p5) - - name: node - description: | -

element to attach canvas to

- type: HTMLElement - optional: true -chainable: false ---- - - -# p5 diff --git a/src/content/reference/en/p5 copy/pAccelerationX.mdx b/src/content/reference/en/p5 copy/pAccelerationX.mdx deleted file mode 100644 index ab1f3e49d1..0000000000 --- a/src/content/reference/en/p5 copy/pAccelerationX.mdx +++ /dev/null @@ -1,21 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L90 -title: pAccelerationX -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: | -

The system variable pAccelerationX always contains the acceleration of the - device along the x axis in the frame previous to the current frame. Value - is represented as meters per second squared.

-line: 90 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# pAccelerationX diff --git a/src/content/reference/en/p5 copy/pAccelerationY.mdx b/src/content/reference/en/p5 copy/pAccelerationY.mdx deleted file mode 100644 index 188ae8f77c..0000000000 --- a/src/content/reference/en/p5 copy/pAccelerationY.mdx +++ /dev/null @@ -1,21 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L100 -title: pAccelerationY -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: | -

The system variable pAccelerationY always contains the acceleration of the - device along the y axis in the frame previous to the current frame. Value - is represented as meters per second squared.

-line: 100 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# pAccelerationY diff --git a/src/content/reference/en/p5 copy/pAccelerationZ.mdx b/src/content/reference/en/p5 copy/pAccelerationZ.mdx deleted file mode 100644 index f291e6b707..0000000000 --- a/src/content/reference/en/p5 copy/pAccelerationZ.mdx +++ /dev/null @@ -1,21 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L110 -title: pAccelerationZ -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: | -

The system variable pAccelerationZ always contains the acceleration of the - device along the z axis in the frame previous to the current frame. Value - is represented as meters per second squared.

-line: 110 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# pAccelerationZ diff --git a/src/content/reference/en/p5 copy/pRotationX.mdx b/src/content/reference/en/p5 copy/pRotationX.mdx deleted file mode 100644 index 03d80f8ae5..0000000000 --- a/src/content/reference/en/p5 copy/pRotationX.mdx +++ /dev/null @@ -1,63 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L234 -title: pRotationX -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

The system variable pRotationX always contains the rotation of the - - device along the x axis in the frame previous to the current frame. - - If the sketch angleMode() is set to - DEGREES, - - the value will be -180 to 180. If it is set to RADIANS, the value will - - be -PI to PI.

- -

pRotationX can also be used with rotationX to determine the rotate - - direction of the device along the X-axis.

-line: 234 -isConstructor: false -itemtype: property -example: - - |- - -
- - // A simple if statement looking at whether - // rotationX - pRotationX < 0 is true or not will be - // sufficient for determining the rotate direction - // in most cases. - - // Some extra logic is needed to account for cases where - // the angles wrap around. - let rotateDirection = 'clockwise'; - - // Simple range conversion to make things simpler. - // This is not absolutely necessary but the logic - // will be different in that case. - - let rX = rotationX + 180; - let pRX = pRotationX + 180; - - if ((rX - pRX > 0 && rX - pRX < 270) || rX - pRX < -270) { - rotateDirection = 'clockwise'; - } else if (rX - pRX < 0 || rX - pRX > 270) { - rotateDirection = 'counter-clockwise'; - } - - print(rotateDirection); - describe('no image to display.'); - -
-class: p5 -type: Number ---- - - -# pRotationX diff --git a/src/content/reference/en/p5 copy/pRotationY.mdx b/src/content/reference/en/p5 copy/pRotationY.mdx deleted file mode 100644 index 3a15f47f43..0000000000 --- a/src/content/reference/en/p5 copy/pRotationY.mdx +++ /dev/null @@ -1,62 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L278 -title: pRotationY -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

The system variable pRotationY always contains the rotation of the - - device along the y axis in the frame previous to the current frame. - - If the sketch angleMode() is set to - DEGREES, - - the value will be -90 to 90. If it is set to RADIANS, the value will - - be -PI/2 to PI/2.

- -

pRotationY can also be used with rotationY to determine the rotate - - direction of the device along the Y-axis.

-line: 278 -isConstructor: false -itemtype: property -example: - - |- - -
- - // A simple if statement looking at whether - // rotationY - pRotationY < 0 is true or not will be - // sufficient for determining the rotate direction - // in most cases. - - // Some extra logic is needed to account for cases where - // the angles wrap around. - let rotateDirection = 'clockwise'; - - // Simple range conversion to make things simpler. - // This is not absolutely necessary but the logic - // will be different in that case. - - let rY = rotationY + 180; - let pRY = pRotationY + 180; - - if ((rY - pRY > 0 && rY - pRY < 270) || rY - pRY < -270) { - rotateDirection = 'clockwise'; - } else if (rY - pRY < 0 || rY - pRY > 270) { - rotateDirection = 'counter-clockwise'; - } - print(rotateDirection); - describe('no image to display.'); - -
-class: p5 -type: Number ---- - - -# pRotationY diff --git a/src/content/reference/en/p5 copy/pRotationZ.mdx b/src/content/reference/en/p5 copy/pRotationZ.mdx deleted file mode 100644 index 4ae6d5e63f..0000000000 --- a/src/content/reference/en/p5 copy/pRotationZ.mdx +++ /dev/null @@ -1,58 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L321 -title: pRotationZ -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

The system variable pRotationZ always contains the rotation of the - - device along the z axis in the frame previous to the current frame. - - If the sketch angleMode() is set to - DEGREES, - - the value will be 0 to 360. If it is set to RADIANS, the value will - - be 0 to 2*PI.

- -

pRotationZ can also be used with rotationZ to determine the rotate - - direction of the device along the Z-axis.

-line: 321 -isConstructor: false -itemtype: property -example: - - |- - -
- - // A simple if statement looking at whether - // rotationZ - pRotationZ < 0 is true or not will be - // sufficient for determining the rotate direction - // in most cases. - - // Some extra logic is needed to account for cases where - // the angles wrap around. - let rotateDirection = 'clockwise'; - - if ( - (rotationZ - pRotationZ > 0 && rotationZ - pRotationZ < 270) || - rotationZ - pRotationZ < -270 - ) { - rotateDirection = 'clockwise'; - } else if (rotationZ - pRotationZ < 0 || rotationZ - pRotationZ > 270) { - rotateDirection = 'counter-clockwise'; - } - print(rotateDirection); - describe('no image to display.'); - -
-class: p5 -type: Number ---- - - -# pRotationZ diff --git a/src/content/reference/en/p5 copy/paletteLerp.mdx b/src/content/reference/en/p5 copy/paletteLerp.mdx deleted file mode 100644 index 54e8c9f885..0000000000 --- a/src/content/reference/en/p5 copy/paletteLerp.mdx +++ /dev/null @@ -1,66 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L1079 -title: paletteLerp -module: Color -submodule: Creating & Reading -file: src/color/creating_reading.js -description: > -

Blends multiple colors to find a color between them.

- -

The amt parameter specifies the amount to interpolate between - the color - - stops which are colors at each amt value "location" with - amt values - - that are between 2 color stops interpolating between them based on its - relative - - distance to both.

- -

The way that colors are interpolated depends on the current - - colorMode().

-line: 1079 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(400, 400); - } - - function draw() { - // The background goes from white to red to green to blue fill - background(paletteLerp([ - ['white', 0], - ['red', 0.05], - ['green', 0.25], - ['blue', 1] - ], millis() / 10000 % 1)); - } - -
-class: p5 -params: - - name: colors_stops - description: | -

color stops to interpolate from

- type: '[p5.Color, Number][]' - - name: amt - description: | -

number to use to interpolate relative to color stops

- type: Number -return: - description: interpolated color. - type: p5.Color -chainable: false ---- - - -# paletteLerp diff --git a/src/content/reference/en/p5 copy/panorama.mdx b/src/content/reference/en/p5 copy/panorama.mdx deleted file mode 100644 index 97ee1fd9ca..0000000000 --- a/src/content/reference/en/p5 copy/panorama.mdx +++ /dev/null @@ -1,76 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L1021 -title: panorama -module: 3D -submodule: Lights -file: src/webgl/light.js -description: > -

Creates an immersive 3D background.

- -

panorama() transforms images containing 360˚ content, such as - maps or - - HDRIs, into immersive 3D backgrounds that surround a sketch. Exploring the - - space requires changing the camera's perspective with functions such as - - orbitControl() or - - camera().

-line: 1021 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - let img; - - // Load an image and create a p5.Image object. - function preload() { - img = loadImage('/assets/outdoor_spheremap.jpg'); - } - - function setup() { - createCanvas(100 ,100 ,WEBGL); - - describe('A sphere floating above a landscape. The surface of the sphere reflects the landscape. The full landscape is viewable in 3D as the user drags the mouse.'); - } - - function draw() { - // Add the panorama. - panorama(img); - - // Enable orbiting with the mouse. - orbitControl(); - - // Use the image as a light source. - imageLight(img); - - // Style the sphere. - noStroke(); - specularMaterial(50); - shininess(200); - metalness(100); - - // Draw the sphere. - sphere(30); - } - -
-class: p5 -params: - - name: img - description: | -

360˚ image to use as the background.

- type: p5.Image -chainable: false ---- - - -# panorama diff --git a/src/content/reference/en/p5 copy/perspective.mdx b/src/content/reference/en/p5 copy/perspective.mdx deleted file mode 100644 index 21cca35746..0000000000 --- a/src/content/reference/en/p5 copy/perspective.mdx +++ /dev/null @@ -1,194 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L148 -title: perspective -module: 3D -submodule: Camera -file: src/webgl/p5.Camera.js -description: > -

Sets a perspective projection for the current camera in a 3D sketch.

- -

In a perspective projection, shapes that are further from the camera appear - - smaller than shapes that are near the camera. This technique, called - - foreshortening, creates realistic 3D scenes. It’s applied by default in - - WebGL mode.

- -

perspective() changes the camera’s perspective by changing its - viewing - - frustum. The frustum is the volume of space that’s visible to the camera. - - Its shape is a pyramid with its top cut off. The camera is placed where - - the top of the pyramid should be and views everything between the frustum’s - - top (near) plane and its bottom (far) plane.

- -

The first parameter, fovy, is the camera’s vertical field of - view. It’s - - an angle that describes how tall or narrow a view the camera has. For - - example, calling perspective(0.5) sets the camera’s vertical - field of - - view to 0.5 radians. By default, fovy is calculated based on the - sketch’s - - height and the camera’s default z-coordinate, which is 800. The formula for - - the default fovy is 2 * atan(height / 2 / 800).

- -

The second parameter, aspect, is the camera’s aspect ratio. - It’s a number - - that describes the ratio of the top plane’s width to its height. For - - example, calling perspective(0.5, 1.5) sets the camera’s field of - view to - - 0.5 radians and aspect ratio to 1.5, which would make shapes appear thinner - - on a square canvas. By default, aspect is set to width / - height.

- -

The third parameter, near, is the distance from the camera to - the near - - plane. For example, calling perspective(0.5, 1.5, 100) sets the - camera’s - - field of view to 0.5 radians, its aspect ratio to 1.5, and places the near - - plane 100 pixels from the camera. Any shapes drawn less than 100 pixels - - from the camera won’t be visible. By default, near is set to 0.1 * - 800, - - which is 1/10th the default distance between the camera and the origin.

- -

The fourth parameter, far, is the distance from the camera to - the far - - plane. For example, calling perspective(0.5, 1.5, 100, 10000) - sets the - - camera’s field of view to 0.5 radians, its aspect ratio to 1.5, places the - - near plane 100 pixels from the camera, and places the far plane 10,000 - - pixels from the camera. Any shapes drawn more than 10,000 pixels from the - - camera won’t be visible. By default, far is set to 10 * 800, - which is 10 - - times the default distance between the camera and the origin.

- -

Note: perspective() can only be used in WebGL mode.

-line: 148 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Double-click to squeeze the box. - - let isSqueezed = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white rectangular prism on a gray background. The box appears to become thinner when the user double-clicks.'); - } - - function draw() { - background(200); - - // Place the camera at the top-right. - camera(400, -400, 800); - - if (isSqueezed === true) { - // Set fovy to 0.2. - // Set aspect to 1.5. - perspective(0.2, 1.5); - } - - // Draw the box. - box(); - } - - // Change the camera's perspective when the user double-clicks. - function doubleClicked() { - isSqueezed = true; - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white rectangular prism on a gray background. The prism moves away from the camera until it disappears.'); - } - - function draw() { - background(200); - - // Place the camera at the top-right. - camera(400, -400, 800); - - // Set fovy to 0.2. - // Set aspect to 1.5. - // Set near to 600. - // Set far to 1200. - perspective(0.2, 1.5, 600, 1200); - - // Move the origin away from the camera. - let x = -frameCount; - let y = frameCount; - let z = -2 * frameCount; - translate(x, y, z); - - // Draw the box. - box(); - } - -
-class: p5 -params: - - name: fovy - description: | -

camera frustum vertical field of view. Defaults to - 2 * atan(height / 2 / 800).

- type: Number - optional: true - - name: aspect - description: | -

camera frustum aspect ratio. Defaults to - width / height.

- type: Number - optional: true - - name: near - description: | -

distance from the camera to the near clipping plane. - Defaults to 0.1 * 800.

- type: Number - optional: true - - name: far - description: | -

distance from the camera to the far clipping plane. - Defaults to 10 * 800.

- type: Number - optional: true -chainable: true ---- - - -# perspective diff --git a/src/content/reference/en/p5 copy/pixelDensity.mdx b/src/content/reference/en/p5 copy/pixelDensity.mdx deleted file mode 100644 index 808ebab227..0000000000 --- a/src/content/reference/en/p5 copy/pixelDensity.mdx +++ /dev/null @@ -1,90 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L1005 -title: pixelDensity -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

Sets the pixel density or returns the current density.

- -

Computer displays are grids of little lights called pixels. A - - display's pixel density describes how many pixels it packs into an - - area. Displays with smaller pixels have a higher pixel density and create - - sharper images.

- -

pixelDensity() sets the pixel scaling for high pixel density - displays. - - By default, the pixel density is set to match the display's density. - - Calling pixelDensity(1) turn this off.

- -

Calling pixelDensity() without an argument returns the current - pixel - - density.

-line: 1005 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - // Set the pixel density to 1. - pixelDensity(1); - - // Create a canvas and draw - // a circle. - createCanvas(100, 100); - background(200); - circle(50, 50, 70); - - describe('A fuzzy white circle on a gray canvas.'); - } - -
- -
- - function setup() { - // Set the pixel density to 3. - pixelDensity(3); - - // Create a canvas, paint the - // background, and draw a - // circle. - createCanvas(100, 100); - background(200); - circle(50, 50, 70); - - describe('A sharp white circle on a gray canvas.'); - } - -
-class: p5 -overloads: - - line: 1005 - params: - - name: val - description: | -

desired pixel density.

- type: Number - optional: true - chainable: 1 - - line: 1059 - params: [] - return: - description: current pixel density of the sketch. - type: Number -chainable: true ---- - - -# pixelDensity diff --git a/src/content/reference/en/p5 copy/pixels.mdx b/src/content/reference/en/p5 copy/pixels.mdx deleted file mode 100644 index 7185d708bf..0000000000 --- a/src/content/reference/en/p5 copy/pixels.mdx +++ /dev/null @@ -1,173 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L12 -title: pixels -module: Image -submodule: Pixels -file: src/image/pixels.js -description: > -

An array containing the color of each pixel on the canvas.

- -

Colors are stored as numbers representing red, green, blue, and alpha - - (RGBA) values. pixels is a one-dimensional array for performance - reasons.

- -

Each pixel occupies four elements in the pixels array, one for - each RGBA - - value. For example, the pixel at coordinates (0, 0) stores its RGBA values - - at pixels[0], pixels[1], pixels[2], and - pixels[3], respectively. - - The next pixel at coordinates (1, 0) stores its RGBA values at - pixels[4], - - pixels[5], pixels[6], and pixels[7]. - And so on. The pixels array - - for a 100×100 canvas has 100 × 100 × 4 = 40,000 elements.

- -

Some displays use several smaller pixels to set the color at a single - - point. The pixelDensity() function - returns - - the pixel density of the canvas. High density displays often have a - - pixelDensity() of 2. On such a - display, the - - pixels array for a 100×100 canvas has 200 × 200 × 4 = - - 160,000 elements.

- -

Accessing the RGBA values for a point on the canvas requires a little math - - as shown below. The loadPixels() - function - - must be called before accessing the pixels array. The - - updatePixels() function must be - called - - after any changes are made.

-line: 12 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Load the pixels array. - loadPixels(); - - // Set the dot's coordinates. - let x = 50; - let y = 50; - - // Get the pixel density. - let d = pixelDensity(); - - // Set the pixel(s) at the center of the canvas black. - for (let i = 0; i < d; i += 1) { - for (let j = 0; j < d; j += 1) { - let index = 4 * ((y * d + j) * width * d + (x * d + i)); - // Red. - pixels[index] = 0; - // Green. - pixels[index + 1] = 0; - // Blue. - pixels[index + 2] = 0; - // Alpha. - pixels[index + 3] = 255; - } - } - - // Update the canvas. - updatePixels(); - - describe('A black dot in the middle of a gray rectangle.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Load the pixels array. - loadPixels(); - - // Get the pixel density. - let d = pixelDensity(); - - // Calculate the halfway index in the pixels array. - let halfImage = 4 * (d * width) * (d * height / 2); - - // Make the top half of the canvas red. - for (let i = 0; i < halfImage; i += 4) { - // Red. - pixels[i] = 255; - // Green. - pixels[i + 1] = 0; - // Blue. - pixels[i + 2] = 0; - // Alpha. - pixels[i + 3] = 255; - } - - // Update the canvas. - updatePixels(); - - describe('A red rectangle drawn above a gray rectangle.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Create a p5.Color object. - let pink = color(255, 102, 204); - - // Load the pixels array. - loadPixels(); - - // Get the pixel density. - let d = pixelDensity(); - - // Calculate the halfway index in the pixels array. - let halfImage = 4 * (d * width) * (d * height / 2); - - // Make the top half of the canvas red. - for (let i = 0; i < halfImage; i += 4) { - pixels[i] = red(pink); - pixels[i + 1] = green(pink); - pixels[i + 2] = blue(pink); - pixels[i + 3] = alpha(pink); - } - - // Update the canvas. - updatePixels(); - - describe('A pink rectangle drawn above a gray rectangle.'); - } - -
-class: p5 -type: 'Number[]' ---- - - -# pixels diff --git a/src/content/reference/en/p5 copy/plane.mdx b/src/content/reference/en/p5 copy/plane.mdx deleted file mode 100644 index eefeb29b7a..0000000000 --- a/src/content/reference/en/p5 copy/plane.mdx +++ /dev/null @@ -1,152 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L866 -title: plane -module: Shape -submodule: 3D Primitives -file: src/webgl/3d_primitives.js -description: > -

Draws a plane.

- -

A plane is a four-sided, flat shape with every angle measuring 90˚. It’s - - similar to a rectangle and offers advanced drawing features in WebGL mode.

- -

The first parameter, width, is optional. If a - Number is passed, as in - - plane(20), it sets the plane’s width and height. By default, - width is - - 50.

- -

The second parameter, height, is also optional. If a - Number is passed, - - as in plane(20, 30), it sets the plane’s height. By default, - height is - - set to the plane’s width.

- -

The third parameter, detailX, is also optional. If a - Number is passed, - - as in plane(20, 30, 5) it sets the number of triangle - subdivisions to use - - along the x-axis. All 3D shapes are made by connecting triangles to form - - their surfaces. By default, detailX is 1.

- -

The fourth parameter, detailY, is also optional. If a - Number is passed, - - as in plane(20, 30, 5, 7) it sets the number of triangle - subdivisions to - - use along the y-axis. All 3D shapes are made by connecting triangles to - - form their surfaces. By default, detailY is 1.

- -

Note: plane() can only be used in WebGL mode.

-line: 866 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white plane on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the plane. - plane(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white plane on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the plane. - // Set its width and height to 30. - plane(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white plane on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the plane. - // Set its width to 30 and height to 50. - plane(30, 50); - } - -
-class: p5 -params: - - name: width - description: | -

width of the plane.

- type: Number - optional: true - - name: height - description: | -

height of the plane.

- type: Number - optional: true - - name: detailX - description: | -

number of triangle subdivisions along the x-axis.

- type: Integer - optional: true - - name: detailY - description: | -

number of triangle subdivisions along the y-axis.

- type: Integer - optional: true -chainable: true ---- - - -# plane diff --git a/src/content/reference/en/p5 copy/pmouseX.mdx b/src/content/reference/en/p5 copy/pmouseX.mdx deleted file mode 100644 index 5f5e8ff7f7..0000000000 --- a/src/content/reference/en/p5 copy/pmouseX.mdx +++ /dev/null @@ -1,88 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L333 -title: pmouseX -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A Number system variable that tracks the mouse's previous - horizontal - - position.

- -

pmouseX keeps track of the mouse's position relative to the - - top-left corner of the canvas. Its value is - - mouseX from the previous frame. For - example, if - - the mouse was 50 pixels from the left edge of the canvas during the last - - frame, then pmouseX will be 50.

- -

If touch is used instead of the mouse, then pmouseX will hold - the - - x-coordinate of the last touch point.

- -

Note: pmouseX is reset to the current mouseX - - value at the start of each touch event.

-line: 333 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Slow the frame rate. - frameRate(10); - - describe('A line follows the mouse as it moves. The line grows longer with faster movements.'); - } - - function draw() { - background(200); - - line(pmouseX, pmouseY, mouseX, mouseY); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A line follows the mouse as it moves. The line grows longer with faster movements.'); - } - - function draw() { - background(200); - - // Adjust coordinates for WebGL mode. - // The origin (0, 0) is at the center of the canvas. - let pmx = pmouseX - 50; - let pmy = pmouseY - 50; - let mx = mouseX - 50; - let my = mouseY - 50; - - // Draw the line. - line(pmx, pmy, mx, my); - } - -
-class: p5 -type: Number ---- - - -# pmouseX diff --git a/src/content/reference/en/p5 copy/pmouseY.mdx b/src/content/reference/en/p5 copy/pmouseY.mdx deleted file mode 100644 index 558747e43f..0000000000 --- a/src/content/reference/en/p5 copy/pmouseY.mdx +++ /dev/null @@ -1,88 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L398 -title: pmouseY -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A Number system variable that tracks the mouse's previous - vertical - - position.

- -

pmouseY keeps track of the mouse's position relative to the - - top-left corner of the canvas. Its value is - - mouseY from the previous frame. For - example, if - - the mouse was 50 pixels from the top edge of the canvas during the last - - frame, then pmouseY will be 50.

- -

If touch is used instead of the mouse, then pmouseY will hold - the - - y-coordinate of the last touch point.

- -

Note: pmouseY is reset to the current mouseY - - value at the start of each touch event.

-line: 398 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Slow the frame rate. - frameRate(10); - - describe('A line follows the mouse as it moves. The line grows longer with faster movements.'); - } - - function draw() { - background(200); - - line(pmouseX, pmouseY, mouseX, mouseY); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A line follows the mouse as it moves. The line grows longer with faster movements.'); - } - - function draw() { - background(200); - - // Adjust coordinates for WebGL mode. - // The origin (0, 0) is at the center of the canvas. - let pmx = pmouseX - 50; - let pmy = pmouseY - 50; - let mx = mouseX - 50; - let my = mouseY - 50; - - // Draw the line. - line(pmx, pmy, mx, my); - } - -
-class: p5 -type: Number ---- - - -# pmouseY diff --git a/src/content/reference/en/p5 copy/point.mdx b/src/content/reference/en/p5 copy/point.mdx deleted file mode 100644 index 7912c06cbb..0000000000 --- a/src/content/reference/en/p5 copy/point.mdx +++ /dev/null @@ -1,229 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L721 -title: point -module: Shape -submodule: 2D Primitives -file: src/core/shape/2d_primitives.js -description: > -

Draws a single point in space.

- -

A point's default width is one pixel. To color a point, use the - - stroke() function. To change its width, - use the - - strokeWeight() function. A point - - can't be filled, so the fill() function - won't - - affect the point's color.

- -

The version of point() with two parameters allows the point's - location to - - be set with its x- and y-coordinates, as in point(10, 20).

- -

The version of point() with three parameters allows the point - to be drawn - - in 3D space with x-, y-, and z-coordinates, as in point(10, 20, - 30). - - Doing so requires adding the WEBGL argument to - - createCanvas().

- -

The version of point() with one parameter allows the point's - location to - - be set with a p5.Vector object.

-line: 721 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - - // Making point to 5 pixels - strokeWeight(5); - - - // Top-left. - point(30, 20); - - // Top-right. - point(85, 20); - - // Bottom-right. - point(85, 75); - - // Bottom-left. - point(30, 75); - - describe( - 'Four small, black points drawn on a gray canvas. The points form the corners of a square.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - - // Making point to 5 pixels. - strokeWeight(5); - - - // Top-left. - point(30, 20); - - // Top-right. - point(70, 20); - - // Style the next points. - stroke('purple'); - strokeWeight(10); - - // Bottom-right. - point(70, 80); - - // Bottom-left. - point(30, 80); - - describe( - 'Four points drawn on a gray canvas. Two are black and two are purple. The points form the corners of a square.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - - // Making point to 5 pixels. - strokeWeight(5); - - - // Top-left. - let a = createVector(30, 20); - point(a); - - // Top-right. - let b = createVector(70, 20); - point(b); - - // Bottom-right. - let c = createVector(70, 80); - point(c); - - // Bottom-left. - let d = createVector(30, 80); - point(d); - - describe( - 'Four small, black points drawn on a gray canvas. The points form the corners of a square.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('Two purple points drawn on a gray canvas.'); - } - - function draw() { - background(200); - - // Style the points. - stroke('purple'); - strokeWeight(10); - - // Top-left. - point(-20, -30); - - // Bottom-right. - point(20, 30); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('Two purple points drawn on a gray canvas. The scene spins slowly.'); - } - - function draw() { - background(200); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Style the points. - stroke('purple'); - strokeWeight(10); - - // Top-left. - point(-20, -30, 0); - - // Bottom-right. - point(20, 30, -50); - } - -
-class: p5 -overloads: - - line: 721 - params: - - name: x - description: | -

the x-coordinate.

- type: Number - - name: 'y' - description: | -

the y-coordinate.

- type: Number - - name: z - description: | -

the z-coordinate (for WebGL mode).

- type: Number - optional: true - chainable: 1 - - line: 900 - params: - - name: coordinateVector - description: | -

the coordinate vector.

- type: p5.Vector - chainable: 1 -chainable: true ---- - - -# point diff --git a/src/content/reference/en/p5 copy/pointLight.mdx b/src/content/reference/en/p5 copy/pointLight.mdx deleted file mode 100644 index c6f10715b9..0000000000 --- a/src/content/reference/en/p5 copy/pointLight.mdx +++ /dev/null @@ -1,329 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L683 -title: pointLight -module: 3D -submodule: Lights -file: src/webgl/light.js -description: > -

Creates a light that shines from a point in all directions.

- -

Point lights are like light bulbs that shine in all directions. They can be - - placed at different positions to achieve different lighting effects. A - - maximum of 5 point lights can be active at once.

- -

There are four ways to call pointLight() with parameters to - set the - - light’s color and position.

- -

The first way to call pointLight() has six parameters. The - first three - - parameters, v1, v2, and v3, set the - light’s color using the current - - colorMode(). The last three parameters, - x, - - y, and z, set the light’s position. For example, - - pointLight(255, 0, 0, 50, 0, 0) creates a red (255, 0, - 0) light that - - shines from the coordinates (50, 0, 0).

- -

The second way to call pointLight() has four parameters. The - first three - - parameters, v1, v2, and v3, set the - light’s color using the current - - colorMode(). The last parameter, - position sets - - the light’s position using a p5.Vector - object. - - For example, pointLight(255, 0, 0, lightPos) creates a red - (255, 0, 0) - - light that shines from the position set by the lightPos - vector.

- -

The third way to call pointLight() has four parameters. The - first - - parameter, color, sets the light’s color using a - - p5.Color object or an array of color - values. The - - last three parameters, x, y, and z, set - the light’s position. For - - example, directionalLight(myColor, 50, 0, 0) creates a light that - shines - - from the coordinates (50, 0, 0) with the color value of - myColor.

- -

The fourth way to call pointLight() has two parameters. The - first - - parameter, color, sets the light’s color using a - - p5.Color object or an array of color - values. The - - second parameter, position, sets the light’s position using a - - p5.Vector object. For example, - - directionalLight(myColor, lightPos) creates a light that shines - from the - - position set by the lightPos vector with the color value of - myColor.

-line: 683 -isConstructor: false -itemtype: method -example: - - |- - - -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click to turn on the point light. - - let isLit = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A sphere drawn on a gray background. A red light starts shining from above when the user double-clicks.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Control the light. - if (isLit === true) { - // Add a red point light from above. - // Use RGB values and XYZ coordinates. - pointLight(255, 0, 0, 0, -150, 0); - } - - // Style the sphere. - noStroke(); - - // Draw the sphere. - sphere(30); - } - - // Turn on the point light when the user double-clicks. - function doubleClicked() { - isLit = true; - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Add a red point light from above. - // Use a p5.Color object and XYZ directions. - let c = color(255, 0, 0); - pointLight(c, 0, -150, 0); - - // Style the sphere. - noStroke(); - - // Draw the sphere. - sphere(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Add a red point light from above. - // Use a p5.Color object and a p5.Vector object. - let c = color(255, 0, 0); - let lightPos = createVector(0, -150, 0); - pointLight(c, lightPos); - - // Style the sphere. - noStroke(); - - // Draw the sphere. - sphere(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('Four spheres arranged in a square and drawn on a gray background. The spheres appear bright red toward the center of the square. The color gets darker toward the corners of the square.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Add a red point light that points to the center of the scene. - // Use a p5.Color object and a p5.Vector object. - let c = color(255, 0, 0); - let lightPos = createVector(0, 0, 65); - pointLight(c, lightPos); - - // Style the spheres. - noStroke(); - - // Draw a sphere up and to the left. - push(); - translate(-25, -25, 25); - sphere(10); - pop(); - - // Draw a box up and to the right. - push(); - translate(25, -25, 25); - sphere(10); - pop(); - - // Draw a sphere down and to the left. - push(); - translate(-25, 25, 25); - sphere(10); - pop(); - - // Draw a box down and to the right. - push(); - translate(25, 25, 25); - sphere(10); - pop(); - } - -
-class: p5 -overloads: - - line: 683 - params: - - name: v1 - description: | -

red or hue value in the current - colorMode().

- type: Number - - name: v2 - description: | -

green or saturation value in the current - colorMode().

- type: Number - - name: v3 - description: | -

blue, brightness, or lightness value in the current - colorMode().

- type: Number - - name: x - description: | -

x-coordinate of the light.

- type: Number - - name: 'y' - description: | -

y-coordinate of the light.

- type: Number - - name: z - description: | -

z-coordinate of the light.

- type: Number - chainable: 1 - - line: 890 - params: - - name: v1 - description: '' - type: Number - - name: v2 - description: '' - type: Number - - name: v3 - description: '' - type: Number - - name: position - description: | -

position of the light as a - p5.Vector object.

- type: p5.Vector - chainable: 1 - - line: 900 - params: - - name: color - description: | -

color as a p5.Color object, - an array of color values, or a CSS string.

- type: 'p5.Color|Number[]|String' - - name: x - description: '' - type: Number - - name: 'y' - description: '' - type: Number - - name: z - description: '' - type: Number - chainable: 1 - - line: 910 - params: - - name: color - description: '' - type: 'p5.Color|Number[]|String' - - name: position - description: '' - type: p5.Vector - chainable: 1 -chainable: true ---- - - -# pointLight diff --git a/src/content/reference/en/p5 copy/pop.mdx b/src/content/reference/en/p5 copy/pop.mdx deleted file mode 100644 index 72b5c1db21..0000000000 --- a/src/content/reference/en/p5 copy/pop.mdx +++ /dev/null @@ -1,20 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L553 -title: pop -module: Structure -submodule: Structure -file: src/core/structure.js -description: "

Ends a drawing group that contains its own styles and transformations.

\n

By default, styles such as fill() and\ntransformations such as rotate() are applied to\nall drawing that follows. The push() and pop()\nfunctions can limit the effect of styles and transformations to a specific\ngroup of shapes, images, and text. For example, a group of shapes could be\ntranslated to follow the mouse without affecting the rest of the sketch:

\n
// Begin the drawing group.\npush();\n\n// Translate the origin to the mouse's position.\ntranslate(mouseX, mouseY);\n\n// Style the face.\nnoStroke();\nfill('green');\n\n// Draw the face.\ncircle(0, 0, 60);\n\n// Style the eyes.\nfill('white');\n\n// Draw the left eye.\nellipse(-20, -20, 30, 20);\n\n// Draw the right eye.\nellipse(20, -20, 30, 20);\n\n// End the drawing group.\npop();\n\n// Draw a bug.\nlet x = random(0, 100);\nlet y = random(0, 100);\ntext('\U0001F99F', x, y);\n
\n

In the code snippet above, the bug's position isn't affected by\ntranslate(mouseX, mouseY) because that transformation is contained\nbetween push() and pop(). The bug moves around\nthe entire canvas as expected.

\n

Note: push() and pop() are always called as a\npair. Both functions are required to begin and end a drawing group.

\n

push() and pop() can also be nested to create\nsubgroups. For example, the code snippet above could be changed to give\nmore detail to the frog’s eyes:

\n
// Begin the drawing group.\npush();\n\n// Translate the origin to the mouse's position.\ntranslate(mouseX, mouseY);\n\n// Style the face.\nnoStroke();\nfill('green');\n\n// Draw a face.\ncircle(0, 0, 60);\n\n// Style the eyes.\nfill('white');\n\n// Draw the left eye.\npush();\ntranslate(-20, -20);\nellipse(0, 0, 30, 20);\nfill('black');\ncircle(0, 0, 8);\npop();\n\n// Draw the right eye.\npush();\ntranslate(20, -20);\nellipse(0, 0, 30, 20);\nfill('black');\ncircle(0, 0, 8);\npop();\n\n// End the drawing group.\npop();\n\n// Draw a bug.\nlet x = random(0, 100);\nlet y = random(0, 100);\ntext('\U0001F99F', x, y);\n
\n

In this version, the code to draw each eye is contained between its own\npush() and pop() functions. Doing so makes it\neasier to add details in the correct part of a drawing.

\n

push() and pop() contain the effects of the\nfollowing functions:

\n\n

In WebGL mode, push() and pop() contain the\neffects of a few additional styles:

\n\n" -line: 553 -isConstructor: false -itemtype: method -example: - - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Draw the left circle.\n circle(25, 50, 20);\n\n // Begin the drawing group.\n push();\n\n // Translate the origin to the center.\n translate(50, 50);\n\n // Style the circle.\n strokeWeight(5);\n stroke('royalblue');\n fill('orange');\n\n // Draw the circle.\n circle(0, 0, 20);\n\n // End the drawing group.\n pop();\n\n // Draw the right circle.\n circle(75, 50, 20);\n\n describe(\n 'Three circles drawn in a row on a gray background. The left and right circles are white with thin, black borders. The middle circle is orange with a thick, blue border.'\n );\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Slow the frame rate.\n frameRate(24);\n\n describe('A mosquito buzzes in front of a green frog. The frog follows the mouse as the user moves.');\n}\n\nfunction draw() {\n background(200);\n\n // Begin the drawing group.\n push();\n\n // Translate the origin to the mouse's position.\n translate(mouseX, mouseY);\n\n // Style the face.\n noStroke();\n fill('green');\n\n // Draw a face.\n circle(0, 0, 60);\n\n // Style the eyes.\n fill('white');\n\n // Draw the left eye.\n push();\n translate(-20, -20);\n ellipse(0, 0, 30, 20);\n fill('black');\n circle(0, 0, 8);\n pop();\n\n // Draw the right eye.\n push();\n translate(20, -20);\n ellipse(0, 0, 30, 20);\n fill('black');\n circle(0, 0, 8);\n pop();\n\n // End the drawing group.\n pop();\n\n // Draw a bug.\n let x = random(0, 100);\n let y = random(0, 100);\n text('\U0001F99F', x, y);\n}\n\n
\n\n
\n\n// Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n\n describe(\n 'Two spheres drawn on a gray background. The sphere on the left is red and lit from the front. The sphere on the right is a blue wireframe.'\n );\n}\n\nfunction draw() {\n background(200);\n\n // Enable orbiting with the mouse.\n orbitControl();\n\n // Draw the red sphere.\n push();\n translate(-25, 0, 0);\n noStroke();\n directionalLight(255, 0, 0, 0, 0, -1);\n sphere(20);\n pop();\n\n // Draw the blue sphere.\n push();\n translate(25, 0, 0);\n strokeWeight(0.3);\n stroke(0, 0, 255);\n noFill();\n sphere(20);\n pop();\n}\n\n
" -class: p5 -chainable: false ---- - - -# pop diff --git a/src/content/reference/en/p5 copy/pow.mdx b/src/content/reference/en/p5 copy/pow.mdx deleted file mode 100644 index 18201ec3c2..0000000000 --- a/src/content/reference/en/p5 copy/pow.mdx +++ /dev/null @@ -1,67 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L815 -title: pow -module: Math -submodule: Calculation -file: src/math/calculation.js -description: | -

Calculates exponential expressions such as 23.

-

For example, pow(2, 3) evaluates the expression - 2 × 2 × 2. pow(2, -3) evaluates 1 ÷ - (2 × 2 × 2).

-line: 815 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Set the base of the exponent. - let base = 3; - - // Top-left. - let d = pow(base, 1); - circle(10, 10, d); - - // Left-center. - d = pow(base, 2); - circle(20, 20, d); - - // Right-center. - d = pow(base, 3); - circle(40, 40, d); - - // Bottom-right. - d = pow(base, 4); - circle(80, 80, d); - - describe('A series of circles that grow exponentially from top left to bottom right.'); - } - -
-class: p5 -params: - - name: 'n' - description: | -

base of the exponential expression.

- type: Number - - name: e - description: | -

power by which to raise the base.

- type: Number -return: - description: n^e. - type: Number -chainable: false ---- - - -# pow diff --git a/src/content/reference/en/p5 copy/preload.mdx b/src/content/reference/en/p5 copy/preload.mdx deleted file mode 100644 index 66d5db4378..0000000000 --- a/src/content/reference/en/p5 copy/preload.mdx +++ /dev/null @@ -1,70 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L41 -title: preload -module: Structure -submodule: Structure -file: src/core/main.js -description: > -

A function that's called once to load assets before the sketch runs.

- -

Declaring the function preload() sets a code block to run once - - automatically before setup() or - - draw(). It's used to load assets including - - multimedia files, fonts, data, and 3D models:

- -
function preload() {
-    // Code to run before the rest of the sketch.
-  }
-
-  
- -

Functions such as loadImage(), - - loadFont(), - - loadJSON(), and - - loadModel() are guaranteed to either - - finish loading or raise an error if they're called within - preload(). - - Doing so ensures that assets are available when the sketch begins - - running.

-line: 41 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load an image and create a p5.Image object. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Draw the image. - image(img, 0, 0); - - describe('A red brick wall.'); - } - -
-class: p5 -chainable: false ---- - - -# preload diff --git a/src/content/reference/en/p5 copy/print.mdx b/src/content/reference/en/p5 copy/print.mdx deleted file mode 100644 index 50137586ae..0000000000 --- a/src/content/reference/en/p5 copy/print.mdx +++ /dev/null @@ -1,55 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L21 -title: print -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

Displays text in the web browser's console.

- -

print() is helpful for printing values while debugging. Each - call to - - print() creates a new line of text.

- -

Note: Call print('\n') to print a blank line. Calling - print() without - - an argument opens the browser's dialog for printing documents.

-line: 21 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - // Prints "hello, world" to the console. - print('hello, world'); - } - -
- -
- - function setup() { - let name = 'ada'; - // Prints "hello, ada" to the console. - print(`hello, ${name}`); - } - -
-class: p5 -params: - - name: contents - description: | -

content to print to the console.

- type: Any -chainable: false ---- - - -# print diff --git a/src/content/reference/en/p5 copy/push.mdx b/src/content/reference/en/p5 copy/push.mdx deleted file mode 100644 index ee1a386cee..0000000000 --- a/src/content/reference/en/p5 copy/push.mdx +++ /dev/null @@ -1,20 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L269 -title: push -module: Structure -submodule: Structure -file: src/core/structure.js -description: "

Begins a drawing group that contains its own styles and transformations.

\n

By default, styles such as fill() and\ntransformations such as rotate() are applied to\nall drawing that follows. The push() and pop()\nfunctions can limit the effect of styles and transformations to a specific\ngroup of shapes, images, and text. For example, a group of shapes could be\ntranslated to follow the mouse without affecting the rest of the sketch:

\n
// Begin the drawing group.\npush();\n\n// Translate the origin to the mouse's position.\ntranslate(mouseX, mouseY);\n\n// Style the face.\nnoStroke();\nfill('green');\n\n// Draw the face.\ncircle(0, 0, 60);\n\n// Style the eyes.\nfill('white');\n\n// Draw the left eye.\nellipse(-20, -20, 30, 20);\n\n// Draw the right eye.\nellipse(20, -20, 30, 20);\n\n// End the drawing group.\npop();\n\n// Draw a bug.\nlet x = random(0, 100);\nlet y = random(0, 100);\ntext('\U0001F99F', x, y);\n
\n

In the code snippet above, the bug's position isn't affected by\ntranslate(mouseX, mouseY) because that transformation is contained\nbetween push() and pop(). The bug moves around\nthe entire canvas as expected.

\n

Note: push() and pop() are always called as a\npair. Both functions are required to begin and end a drawing group.

\n

push() and pop() can also be nested to create\nsubgroups. For example, the code snippet above could be changed to give\nmore detail to the frog’s eyes:

\n
// Begin the drawing group.\npush();\n\n// Translate the origin to the mouse's position.\ntranslate(mouseX, mouseY);\n\n// Style the face.\nnoStroke();\nfill('green');\n\n// Draw a face.\ncircle(0, 0, 60);\n\n// Style the eyes.\nfill('white');\n\n// Draw the left eye.\npush();\ntranslate(-20, -20);\nellipse(0, 0, 30, 20);\nfill('black');\ncircle(0, 0, 8);\npop();\n\n// Draw the right eye.\npush();\ntranslate(20, -20);\nellipse(0, 0, 30, 20);\nfill('black');\ncircle(0, 0, 8);\npop();\n\n// End the drawing group.\npop();\n\n// Draw a bug.\nlet x = random(0, 100);\nlet y = random(0, 100);\ntext('\U0001F99F', x, y);\n
\n

In this version, the code to draw each eye is contained between its own\npush() and pop() functions. Doing so makes it\neasier to add details in the correct part of a drawing.

\n

push() and pop() contain the effects of the\nfollowing functions:

\n\n

In WebGL mode, push() and pop() contain the\neffects of a few additional styles:

\n\n" -line: 269 -isConstructor: false -itemtype: method -example: - - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Draw the left circle.\n circle(25, 50, 20);\n\n // Begin the drawing group.\n push();\n\n // Translate the origin to the center.\n translate(50, 50);\n\n // Style the circle.\n strokeWeight(5);\n stroke('royalblue');\n fill('orange');\n\n // Draw the circle.\n circle(0, 0, 20);\n\n // End the drawing group.\n pop();\n\n // Draw the right circle.\n circle(75, 50, 20);\n\n describe(\n 'Three circles drawn in a row on a gray background. The left and right circles are white with thin, black borders. The middle circle is orange with a thick, blue border.'\n );\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Slow the frame rate.\n frameRate(24);\n\n describe('A mosquito buzzes in front of a green frog. The frog follows the mouse as the user moves.');\n}\n\nfunction draw() {\n background(200);\n\n // Begin the drawing group.\n push();\n\n // Translate the origin to the mouse's position.\n translate(mouseX, mouseY);\n\n // Style the face.\n noStroke();\n fill('green');\n\n // Draw a face.\n circle(0, 0, 60);\n\n // Style the eyes.\n fill('white');\n\n // Draw the left eye.\n push();\n translate(-20, -20);\n ellipse(0, 0, 30, 20);\n fill('black');\n circle(0, 0, 8);\n pop();\n\n // Draw the right eye.\n push();\n translate(20, -20);\n ellipse(0, 0, 30, 20);\n fill('black');\n circle(0, 0, 8);\n pop();\n\n // End the drawing group.\n pop();\n\n // Draw a bug.\n let x = random(0, 100);\n let y = random(0, 100);\n text('\U0001F99F', x, y);\n}\n\n
\n\n
\n\n// Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n\n describe(\n 'Two spheres drawn on a gray background. The sphere on the left is red and lit from the front. The sphere on the right is a blue wireframe.'\n );\n}\n\nfunction draw() {\n background(200);\n\n // Enable orbiting with the mouse.\n orbitControl();\n\n // Draw the red sphere.\n push();\n translate(-25, 0, 0);\n noStroke();\n directionalLight(255, 0, 0, 0, 0, -1);\n sphere(20);\n pop();\n\n // Draw the blue sphere.\n push();\n translate(25, 0, 0);\n strokeWeight(0.3);\n stroke(0, 0, 255);\n noFill();\n sphere(20);\n pop();\n}\n\n
" -class: p5 -chainable: false ---- - - -# push diff --git a/src/content/reference/en/p5 copy/pwinMouseX.mdx b/src/content/reference/en/p5 copy/pwinMouseX.mdx deleted file mode 100644 index cb869aea71..0000000000 --- a/src/content/reference/en/p5 copy/pwinMouseX.mdx +++ /dev/null @@ -1,99 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L545 -title: pwinMouseX -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A Number variable that tracks the mouse's previous horizontal - position - - within the browser.

- -

pwinMouseX keeps track of the mouse's position relative to the - top-left - - corner of the browser window. Its value is - - winMouseX from the previous frame. For - - example, if the mouse was 50 pixels from - - the left edge of the browser during the last frame, then - pwinMouseX will - - be 50.

- -

On a touchscreen device, pwinMouseX will hold the x-coordinate - of the most - - recent touch point. pwinMouseX is reset to the current - - winMouseX value at the start of each - touch - - event.

- -

Note: Use pmouseX to track the mouse’s - previous - - x-coordinate within the canvas.

-line: 545 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Slow the frame rate. - frameRate(10); - - describe('A gray square. A white circle at its center grows larger when the mouse moves horizontally.'); - } - - function draw() { - background(200); - - // Calculate the circle's diameter. - let d = winMouseX - pwinMouseX; - - // Draw the circle. - circle(50, 50, d); - } - -
- -
- - function setup() { - // Create the canvas and set its position. - let cnv = createCanvas(100, 100); - cnv.position(20, 20); - - describe('A gray square with a number at its center. The number changes as the user moves the mouse vertically.'); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display pwinMouseX. - text(pwinMouseX, 50, 50); - } - -
-class: p5 -type: Number ---- - - -# pwinMouseX diff --git a/src/content/reference/en/p5 copy/pwinMouseY.mdx b/src/content/reference/en/p5 copy/pwinMouseY.mdx deleted file mode 100644 index 2f36580a23..0000000000 --- a/src/content/reference/en/p5 copy/pwinMouseY.mdx +++ /dev/null @@ -1,99 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L616 -title: pwinMouseY -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A Number variable that tracks the mouse's previous vertical - position - - within the browser.

- -

pwinMouseY keeps track of the mouse's position relative to the - top-left - - corner of the browser window. Its value is - - winMouseY from the previous frame. For - - example, if the mouse was 50 pixels from - - the top edge of the browser during the last frame, then - pwinMouseY will - - be 50.

- -

On a touchscreen device, pwinMouseY will hold the y-coordinate - of the most - - recent touch point. pwinMouseY is reset to the current - - winMouseY value at the start of each - touch - - event.

- -

Note: Use pmouseY to track the mouse’s - previous - - y-coordinate within the canvas.

-line: 616 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Slow the frame rate. - frameRate(10); - - describe('A gray square. A white circle at its center grows larger when the mouse moves vertically.'); - } - - function draw() { - background(200); - - // Calculate the circle's diameter. - let d = winMouseY - pwinMouseY; - - // Draw the circle. - circle(50, 50, d); - } - -
- -
- - function setup() { - // Create the canvas and set its position. - let cnv = createCanvas(100, 100); - cnv.position(20, 20); - - describe('A gray square with a number at its center. The number changes as the user moves the mouse vertically.'); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display pwinMouseY. - text(pwinMouseY, 50, 50); - } - -
-class: p5 -type: Number ---- - - -# pwinMouseY diff --git a/src/content/reference/en/p5 copy/quad.mdx b/src/content/reference/en/p5 copy/quad.mdx deleted file mode 100644 index fbc09fa0a3..0000000000 --- a/src/content/reference/en/p5 copy/quad.mdx +++ /dev/null @@ -1,233 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L928 -title: quad -module: Shape -submodule: 2D Primitives -file: src/core/shape/2d_primitives.js -description: > -

Draws a quadrilateral (four-sided shape).

- -

Quadrilaterals include rectangles, squares, rhombuses, and trapezoids. The - - first pair of parameters (x1, y1) sets the quad's first point. - The next - - three pairs of parameters set the coordinates for its next three points - - (x2, y2), (x3, y3), and (x4, y4). - Points should be added in either - - clockwise or counter-clockwise order.

- -

The version of quad() with twelve parameters allows the quad - to be drawn - - in 3D space. Doing so requires adding the WEBGL argument to - - createCanvas().

- -

The thirteenth and fourteenth parameters are optional. In WebGL mode, they - - set the number of segments used to draw the quadrilateral in the x- and - - y-directions. They're both 2 by default.

-line: 928 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - quad(20, 20, 80, 20, 80, 80, 20, 80); - - describe('A white square with a black outline drawn on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - quad(20, 30, 80, 30, 80, 70, 20, 70); - - describe('A white rectangle with a black outline drawn on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - quad(50, 62, 86, 50, 50, 38, 14, 50); - - describe('A white rhombus with a black outline drawn on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - quad(20, 50, 80, 30, 80, 70, 20, 70); - - describe('A white trapezoid with a black outline drawn on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - quad(-30, -30, 30, -30, 30, 30, -30, 30); - - describe('A white square with a black outline drawn on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A wavy white surface spins around on gray canvas.'); - } - - function draw() { - background(200); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Draw the quad. - quad(-30, -30, 0, 30, -30, 0, 30, 30, 20, -30, 30, -20); - } - -
-class: p5 -overloads: - - line: 928 - params: - - name: x1 - description: | -

the x-coordinate of the first point.

- type: Number - - name: y1 - description: | -

the y-coordinate of the first point.

- type: Number - - name: x2 - description: | -

the x-coordinate of the second point.

- type: Number - - name: y2 - description: | -

the y-coordinate of the second point.

- type: Number - - name: x3 - description: | -

the x-coordinate of the third point.

- type: Number - - name: y3 - description: | -

the y-coordinate of the third point.

- type: Number - - name: x4 - description: | -

the x-coordinate of the fourth point.

- type: Number - - name: y4 - description: | -

the y-coordinate of the fourth point.

- type: Number - - name: detailX - description: | -

number of segments in the x-direction.

- type: Integer - optional: true - - name: detailY - description: | -

number of segments in the y-direction.

- type: Integer - optional: true - chainable: 1 - - line: 1048 - params: - - name: x1 - description: '' - type: Number - - name: y1 - description: '' - type: Number - - name: z1 - description: | -

the z-coordinate of the first point.

- type: Number - - name: x2 - description: '' - type: Number - - name: y2 - description: '' - type: Number - - name: z2 - description: | -

the z-coordinate of the second point.

- type: Number - - name: x3 - description: '' - type: Number - - name: y3 - description: '' - type: Number - - name: z3 - description: | -

the z-coordinate of the third point.

- type: Number - - name: x4 - description: '' - type: Number - - name: y4 - description: '' - type: Number - - name: z4 - description: | -

the z-coordinate of the fourth point.

- type: Number - - name: detailX - description: '' - type: Integer - optional: true - - name: detailY - description: '' - type: Integer - optional: true - chainable: 1 -chainable: true ---- - - -# quad diff --git a/src/content/reference/en/p5 copy/quadraticVertex.mdx b/src/content/reference/en/p5 copy/quadraticVertex.mdx deleted file mode 100644 index e319e38769..0000000000 --- a/src/content/reference/en/p5 copy/quadraticVertex.mdx +++ /dev/null @@ -1,303 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L1600 -title: quadraticVertex -module: Shape -submodule: Vertex -file: src/core/shape/vertex.js -description: > -

Adds a quadratic Bézier curve segment to a custom shape.

- -

quadraticVertex() adds a curved segment to custom shapes. The - Bézier - - curve segments it creates are similar to those made by the - - bezierVertex() function. - - quadraticVertex() must be called between the - - beginShape() and - - endShape() functions. The curved segment - uses - - the previous vertex as the first anchor point, so there must be at least - - one call to vertex() before - quadraticVertex() can - - be used.

- -

The first two parameters, cx and cy, set the - curve’s control point. - - The control point "pulls" the curve towards its.

- -

The last two parameters, x3, and y3, set the last - anchor point. The - - last anchor point is where the curve ends.

- -

Bézier curves can also be drawn in 3D using WebGL mode. The 3D version of - - bezierVertex() has eight arguments because each point has x-, y-, - and - - z-coordinates.

- -

Note: quadraticVertex() won’t work when an argument is passed - to - - beginShape().

-line: 1600 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the curve. - noFill(); - - // Draw the curve. - beginShape(); - vertex(20, 20); - quadraticVertex(80, 20, 50, 50); - endShape(); - - describe('A black curve drawn on a gray square. The curve starts at the top-left corner and ends at the center.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw the curve. - noFill(); - beginShape(); - vertex(20, 20); - quadraticVertex(80, 20, 50, 50); - endShape(); - - // Draw red lines from the anchor points to the control point. - stroke(255, 0, 0); - line(20, 20, 80, 20); - line(50, 50, 80, 20); - - // Draw the anchor points in black. - strokeWeight(5); - stroke(0); - point(20, 20); - point(50, 50); - - // Draw the control point in red. - stroke(255, 0, 0); - point(80, 20); - - describe('A black curve that starts at the top-left corner and ends at the center. Its anchor and control points are marked with dots. Red lines connect both anchor points to the control point.'); - } - -
- -
- - // Click the mouse near the red dot in the top-right corner - // and drag to change the curve's shape. - - let x2 = 80; - let y2 = 20; - let isChanging = false; - - function setup() { - createCanvas(100, 100); - - describe('A black curve that starts at the top-left corner and ends at the center. Its anchor and control points are marked with dots. Red lines connect both anchor points to the control point.'); - } - - function draw() { - background(200); - - // Style the curve. - noFill(); - strokeWeight(1); - stroke(0); - - // Draw the curve. - beginShape(); - vertex(20, 20); - quadraticVertex(x2, y2, 50, 50); - endShape(); - - // Draw red lines from the anchor points to the control point. - stroke(255, 0, 0); - line(20, 20, x2, y2); - line(50, 50, x2, y2); - - // Draw the anchor points in black. - strokeWeight(5); - stroke(0); - point(20, 20); - point(50, 50); - - // Draw the control point in red. - stroke(255, 0, 0); - point(x2, y2); - } - - // Start changing the first control point if the user clicks near it. - function mousePressed() { - if (dist(mouseX, mouseY, x2, y2) < 20) { - isChanging = true; - } - } - - // Stop changing the first control point when the user releases the mouse. - function mouseReleased() { - isChanging = false; - } - - // Update the first control point while the user drags the mouse. - function mouseDragged() { - if (isChanging === true) { - x2 = mouseX; - y2 = mouseY; - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - beginShape(); - - // Add the curved segments. - vertex(20, 20); - quadraticVertex(80, 20, 50, 50); - quadraticVertex(20, 80, 80, 80); - - // Add the straight segments. - vertex(80, 10); - vertex(20, 10); - vertex(20, 20); - - // Stop drawing the shape. - endShape(); - - describe('A white puzzle piece drawn on a gray background.'); - } - -
- -
- - // Click the and drag the mouse to view the scene from a different angle. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white puzzle piece on a dark gray background. When the user clicks and drags the scene, the outline of a second puzzle piece is revealed.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the first puzzle piece. - noStroke(); - fill(255); - - // Draw the first puzzle piece. - beginShape(); - vertex(-30, -30, 0); - quadraticVertex(30, -30, 0, 0, 0, 0); - quadraticVertex(-30, 30, 0, 30, 30, 0); - vertex(30, -40, 0); - vertex(-30, -40, 0); - vertex(-30, -30, 0); - endShape(); - - // Style the second puzzle piece. - stroke(255); - noFill(); - - // Draw the second puzzle piece. - beginShape(); - vertex(-30, -30, -20); - quadraticVertex(30, -30, -20, 0, 0, -20); - quadraticVertex(-30, 30, -20, 30, 30, -20); - vertex(30, -40, -20); - vertex(-30, -40, -20); - vertex(-30, -30, -20); - endShape(); - } - -
-class: p5 -overloads: - - line: 1600 - params: - - name: cx - description: | -

x-coordinate of the control point.

- type: Number - - name: cy - description: | -

y-coordinate of the control point.

- type: Number - - name: x3 - description: | -

x-coordinate of the anchor point.

- type: Number - - name: y3 - description: | -

y-coordinate of the anchor point.

- type: Number - chainable: 1 - - line: 1832 - params: - - name: cx - description: '' - type: Number - - name: cy - description: '' - type: Number - - name: cz - description: | -

z-coordinate of the control point.

- type: Number - - name: x3 - description: '' - type: Number - - name: y3 - description: '' - type: Number - - name: z3 - description: | -

z-coordinate of the anchor point.

- type: Number -chainable: true ---- - - -# quadraticVertex diff --git a/src/content/reference/en/p5 copy/radians.mdx b/src/content/reference/en/p5 copy/radians.mdx deleted file mode 100644 index da0adc1ff7..0000000000 --- a/src/content/reference/en/p5 copy/radians.mdx +++ /dev/null @@ -1,53 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L521 -title: radians -module: Math -submodule: Trigonometry -file: src/math/trigonometry.js -description: | -

Converts an angle measured in degrees to its value in radians.

-

Degrees and radians are both units for measuring angles. There are 360˚ in - one full rotation. A full rotation is 2 × π (about 6.28) radians.

-

The same angle can be expressed in with either unit. For example, 90° is a - quarter of a full rotation. The same angle is 2 × π ÷ 4 - (about 1.57) radians.

-line: 521 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Calculate the angle conversion. - let deg = 45; - let rad = radians(deg); - - // Display the angle conversion. - text(`${deg}˚ = ${round(rad, 3)} rad`, 10, 50); - - describe('The text "45˚ = 0.785 rad".'); - } - -
-class: p5 -params: - - name: degrees - description: | -

degree value to convert to radians.

- type: Number -return: - description: converted angle. - type: Number -chainable: false ---- - - -# radians diff --git a/src/content/reference/en/p5 copy/random.mdx b/src/content/reference/en/p5 copy/random.mdx deleted file mode 100644 index aef8e546e8..0000000000 --- a/src/content/reference/en/p5 copy/random.mdx +++ /dev/null @@ -1,48 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/random.js#L86 -title: random -module: Math -submodule: Random -file: src/math/random.js -description: "

Returns a random number or a random element from an array.

\n

random() follows uniform distribution, which means that all outcomes are\nequally likely. When random() is used to generate numbers, all\nnumbers in the output range are equally likely to be returned. When\nrandom() is used to select elements from an array, all elements are\nequally likely to be chosen.

\n

By default, random() produces different results each time a sketch runs.\nThe randomSeed() function can be used to\ngenerate the same sequence of numbers or choices each time a sketch runs.

\n

The version of random() with no parameters returns a random number from 0\nup to but not including 1.

\n

The version of random() with one parameter works one of two ways. If the\nargument passed is a number, random() returns a random number from 0 up\nto but not including the number. For example, calling random(5) returns\nvalues between 0 and 5. If the argument passed is an array, random()\nreturns a random element from that array. For example, calling\nrandom(['\U0001F981', '\U0001F42F', '\U0001F43B']) returns either a lion, tiger, or bear emoji.

\n

The version of random() with two parameters returns a random number from\na given range. The arguments passed set the range's lower and upper bounds.\nFor example, calling random(-5, 10.2) returns values from -5 up to but\nnot including 10.2.

\n" -line: 86 -isConstructor: false -itemtype: method -example: - - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Get random coordinates between 0 and 100.\n let x = random(0, 100);\n let y = random(0, 100);\n\n // Draw a point.\n strokeWeight(5);\n point(x, y);\n\n describe('A black dot appears in a random position on a gray square.');\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Get random coordinates between 0 and 100.\n let x = random(100);\n let y = random(100);\n\n // Draw the point.\n strokeWeight(5);\n point(x, y);\n\n describe('A black dot appears in a random position on a gray square.');\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Create an array of emoji strings.\n let animals = ['\U0001F981', '\U0001F42F', '\U0001F43B'];\n\n // Choose a random element from the array.\n let choice = random(animals);\n\n // Style the text.\n textAlign(CENTER);\n textSize(20);\n\n // Display the emoji.\n text(choice, 50, 50);\n\n describe('An animal face is displayed at random. Either a lion, tiger, or bear.');\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Slow the frame rate.\n frameRate(5);\n\n describe('A black dot moves around randomly on a gray square.');\n}\n\nfunction draw() {\n background(200);\n\n // Get random coordinates between 0 and 100.\n let x = random(100);\n let y = random(100);\n\n // Draw the point.\n strokeWeight(5);\n point(x, y);\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Slow the frame rate.\n frameRate(5);\n\n describe('A black dot moves around randomly in the middle of a gray square.');\n}\n\nfunction draw() {\n background(200);\n\n // Get random coordinates between 45 and 55.\n let x = random(45, 55);\n let y = random(45, 55);\n\n // Draw the point.\n strokeWeight(5);\n point(x, y);\n}\n\n
\n\n
\n\nlet x = 50;\nlet y = 50;\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n describe('A black dot moves around randomly leaving a trail.');\n}\n\nfunction draw() {\n // Update x and y randomly.\n x += random(-1, 1);\n y += random(-1, 1);\n\n // Draw the point.\n point(x, y);\n}\n\n
" -class: p5 -return: - description: random number. - type: Number -overloads: - - line: 86 - params: - - name: min - description: | -

lower bound (inclusive).

- type: Number - optional: true - - name: max - description: | -

upper bound (exclusive).

- type: Number - optional: true - return: - description: random number. - type: Number - - line: 259 - params: - - name: choices - description: | -

array to choose from.

- type: Array - return: - description: random element from the array. - type: '*' -chainable: false ---- - - -# random diff --git a/src/content/reference/en/p5 copy/randomGaussian.mdx b/src/content/reference/en/p5 copy/randomGaussian.mdx deleted file mode 100644 index 24893f378b..0000000000 --- a/src/content/reference/en/p5 copy/randomGaussian.mdx +++ /dev/null @@ -1,104 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/random.js#L292 -title: randomGaussian -module: Math -submodule: Random -file: src/math/random.js -description: > -

Returns a random number fitting a Gaussian, or normal, distribution.

- -

Normal distributions look like bell curves when plotted. Values from a - - normal distribution cluster around a central value called the mean. The - - cluster's standard deviation describes its spread.

- -

By default, randomGaussian() produces different results each - time a - - sketch runs. The randomSeed() function - can be - - used to generate the same sequence of numbers each time a sketch runs.

- -

There's no minimum or maximum value that randomGaussian() - might return. - - Values far from the mean are very unlikely and values near the mean are - - very likely.

- -

The version of randomGaussian() with no parameters returns - values with a - - mean of 0 and standard deviation of 1.

- -

The version of randomGaussian() with one parameter interprets - the - - argument passed as the mean. The standard deviation is 1.

- -

The version of randomGaussian() with two parameters interprets - the first - - argument passed as the mean and the second as the standard deviation.

-line: 292 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - describe('Three horizontal black lines are filled in randomly. The top line spans entire canvas. The middle line is very short. The bottom line spans two-thirds of the canvas.'); - } - - function draw() { - // Style the circles. - noStroke(); - fill(0, 10); - - // Uniform distribution between 0 and 100. - let x = random(100); - let y = 25; - circle(x, y, 5); - - // Gaussian distribution with a mean of 50 and sd of 1. - x = randomGaussian(50); - y = 50; - circle(x, y, 5); - - // Gaussian distribution with a mean of 50 and sd of 10. - x = randomGaussian(50, 10); - y = 75; - circle(x, y, 5); - } - -
-class: p5 -params: - - name: mean - description: | -

mean.

- type: Number - optional: true - - name: sd - description: | -

standard deviation.

- type: Number - optional: true -return: - description: random number. - type: Number -chainable: false ---- - - -# randomGaussian diff --git a/src/content/reference/en/p5 copy/randomSeed.mdx b/src/content/reference/en/p5 copy/randomSeed.mdx deleted file mode 100644 index dbd1a6ae3d..0000000000 --- a/src/content/reference/en/p5 copy/randomSeed.mdx +++ /dev/null @@ -1,71 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/random.js#L37 -title: randomSeed -module: Math -submodule: Random -file: src/math/random.js -description: > -

Sets the seed value for the random() - and - - randomGaussian() functions.

- -

By default, random() and - - randomGaussian() produce different - - results each time a sketch is run. Calling randomSeed() with a - constant - - argument, such as randomSeed(99), makes these functions produce - the same - - results each time a sketch is run.

-line: 37 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Get random coordinates. - let x = random(0, 100); - let y = random(0, 100); - - // Draw the white circle. - circle(x, y, 10); - - // Set a random seed for consistency. - randomSeed(99); - - // Get random coordinates. - x = random(0, 100); - y = random(0, 100); - - // Draw the black circle. - fill(0); - circle(x, y, 10); - - describe('A white circle appears at a random position. A black circle appears at (27.4, 25.8).'); - } - -
-class: p5 -params: - - name: seed - description: | -

seed value.

- type: Number -chainable: false ---- - - -# randomSeed diff --git a/src/content/reference/en/p5 copy/rect.mdx b/src/content/reference/en/p5 copy/rect.mdx deleted file mode 100644 index 6876ab536d..0000000000 --- a/src/content/reference/en/p5 copy/rect.mdx +++ /dev/null @@ -1,209 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L1091 -title: rect -module: Shape -submodule: 2D Primitives -file: src/core/shape/2d_primitives.js -description: > -

Draws a rectangle.

- -

A rectangle is a four-sided shape defined by the x, - y, w, and h - - parameters. x and y set the location of its top-left - corner. w sets - - its width and h sets its height. Every angle in the rectangle - measures - - 90˚. See rectMode() for other ways to - define - - rectangles.

- -

The version of rect() with five parameters creates a rounded - rectangle. The - - fifth parameter sets the radius for all four corners.

- -

The version of rect() with eight parameters also creates a - rounded - - rectangle. Each of the last four parameters set the radius of a corner. The - - radii start with the top-left corner and move clockwise around the - - rectangle. If any of these parameters are omitted, they are set to the - - value of the last radius that was set.

-line: 1091 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - rect(30, 20, 55, 55); - - describe('A white square with a black outline on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - rect(30, 20, 55, 40); - - describe('A white rectangle with a black outline on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Give all corners a radius of 20. - rect(30, 20, 55, 50, 20); - - describe('A white rectangle with a black outline and round edges on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Give each corner a unique radius. - rect(30, 20, 55, 50, 20, 15, 10, 5); - - describe('A white rectangle with a black outline and round edges of different radii.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - rect(-20, -30, 55, 55); - - describe('A white square with a black outline on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white square spins around on gray canvas.'); - } - - function draw() { - background(200); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Draw the rectangle. - rect(-20, -30, 55, 55); - } - -
-class: p5 -overloads: - - line: 1091 - params: - - name: x - description: | -

x-coordinate of the rectangle.

- type: Number - - name: 'y' - description: | -

y-coordinate of the rectangle.

- type: Number - - name: w - description: | -

width of the rectangle.

- type: Number - - name: h - description: | -

height of the rectangle.

- type: Number - optional: true - - name: tl - description: | -

optional radius of top-left corner.

- type: Number - optional: true - - name: tr - description: | -

optional radius of top-right corner.

- type: Number - optional: true - - name: br - description: | -

optional radius of bottom-right corner.

- type: Number - optional: true - - name: bl - description: | -

optional radius of bottom-left corner.

- type: Number - optional: true - chainable: 1 - - line: 1214 - params: - - name: x - description: '' - type: Number - - name: 'y' - description: '' - type: Number - - name: w - description: '' - type: Number - - name: h - description: '' - type: Number - - name: detailX - description: | -

number of segments in the x-direction (for WebGL mode).

- type: Integer - optional: true - - name: detailY - description: | -

number of segments in the y-direction (for WebGL mode).

- type: Integer - optional: true - chainable: 1 -chainable: true ---- - - -# rect diff --git a/src/content/reference/en/p5 copy/rectMode.mdx b/src/content/reference/en/p5 copy/rectMode.mdx deleted file mode 100644 index 5d444cb16e..0000000000 --- a/src/content/reference/en/p5 copy/rectMode.mdx +++ /dev/null @@ -1,142 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L184 -title: rectMode -module: Shape -submodule: Attributes -file: src/core/shape/attributes.js -description: > -

Changes where rectangles and squares are drawn.

- -

By default, the first two parameters of - - rect() and square(), - - are the x- and y-coordinates of the shape's upper left corner. The next - parameters set - - the shape's width and height. This is the same as calling - - rectMode(CORNER).

- -

rectMode(CORNERS) also uses the first two parameters as the - location of - - one of the corners. The next parameters are the location of the opposite - - corner. This mode only works for rect().

- -

rectMode(CENTER) uses the first two parameters as the x- and - - y-coordinates of the shape's center. The next parameters are its width and - - height.

- -

rectMode(RADIUS) also uses the first two parameters as the x- - and - - y-coordinates of the shape's center. The next parameters are - - half of the shape's width and height.

- -

The argument passed to rectMode() must be written in ALL CAPS - because the - - constants CENTER, RADIUS, CORNER, and - CORNERS are defined this way. - - JavaScript is a case-sensitive language.

-line: 184 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - rectMode(CORNER); - fill(255); - rect(25, 25, 50, 50); - - rectMode(CORNERS); - fill(100); - rect(25, 25, 50, 50); - - describe('A small gray square drawn at the top-left corner of a white square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - rectMode(RADIUS); - fill(255); - rect(50, 50, 30, 30); - - rectMode(CENTER); - fill(100); - rect(50, 50, 30, 30); - - describe('A small gray square drawn at the center of a white square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - rectMode(CORNER); - fill(255); - square(25, 25, 50); - - describe('A white square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - rectMode(RADIUS); - fill(255); - square(50, 50, 30); - - rectMode(CENTER); - fill(100); - square(50, 50, 30); - - describe('A small gray square drawn at the center of a white square.'); - } - -
-class: p5 -params: - - name: mode - description: | -

either CORNER, CORNERS, CENTER, or RADIUS

- type: Constant -chainable: true ---- - - -# rectMode diff --git a/src/content/reference/en/p5 copy/red.mdx b/src/content/reference/en/p5 copy/red.mdx deleted file mode 100644 index 819478b246..0000000000 --- a/src/content/reference/en/p5 copy/red.mdx +++ /dev/null @@ -1,158 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L1279 -title: red -module: Color -submodule: Creating & Reading -file: src/color/creating_reading.js -description: > -

Gets the red value of a color.

- -

red() extracts the red value from a - - p5.Color object, an array of color - components, or - - a CSS color string.

- -

By default, red() returns a color's red value in the range 0 - - to 255. If the colorMode() is set to - RGB, it - - returns the red value in the given range.

-line: 1279 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object. - let c = color(175, 100, 220); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'redValue' to 175. - let redValue = red(c); - - // Draw the right rectangle. - fill(redValue, 0, 0); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is red.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a color array. - let c = [175, 100, 220]; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'redValue' to 175. - let redValue = red(c); - - // Draw the right rectangle. - fill(redValue, 0, 0); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is red.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a CSS color string. - let c = 'rgb(175, 100, 220)'; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'redValue' to 175. - let redValue = red(c); - - // Draw the right rectangle. - fill(redValue, 0, 0); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is red.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use RGB color with values in the range 0-100. - colorMode(RGB, 100); - - // Create a p5.Color object. - let c = color(69, 39, 86); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'redValue' to 69. - let redValue = red(c); - - // Draw the right rectangle. - fill(redValue, 0, 0); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is red.'); - } - -
-class: p5 -params: - - name: color - description: | -

p5.Color object, array of - color components, or CSS color string.

- type: 'p5.Color|Number[]|String' -return: - description: the red value. - type: Number -chainable: false ---- - - -# red diff --git a/src/content/reference/en/p5 copy/redraw.mdx b/src/content/reference/en/p5 copy/redraw.mdx deleted file mode 100644 index 6519f322f0..0000000000 --- a/src/content/reference/en/p5 copy/redraw.mdx +++ /dev/null @@ -1,117 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L838 -title: redraw -module: Structure -submodule: Structure -file: src/core/structure.js -description: > -

Runs the code in draw() once.

- -

By default, draw() tries to run 60 times - per - - second. Calling noLoop() stops - - draw() from repeating. Calling - redraw() will - - execute the code in the draw() function a - set - - number of times.

- -

The parameter, n, is optional. If a number is passed, as in - redraw(5), - - then the draw loop will run the given number of times. By default, - n is - - 1.

-line: 838 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Double-click the canvas to move the circle. - - let x = 0; - - function setup() { - createCanvas(100, 100); - - // Turn off the draw loop. - noLoop(); - - describe( - 'A white half-circle on the left edge of a gray square. The circle moves a little to the right when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Draw the circle. - circle(x, 50, 20); - - // Increment x. - x += 5; - } - - // Run the draw loop when the user double-clicks. - function doubleClicked() { - redraw(); - } - -
- -
- - // Double-click the canvas to move the circle. - - let x = 0; - - function setup() { - createCanvas(100, 100); - - // Turn off the draw loop. - noLoop(); - - describe( - 'A white half-circle on the left edge of a gray square. The circle hops to the right when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Draw the circle. - circle(x, 50, 20); - - // Increment x. - x += 5; - } - - // Run the draw loop three times when the user double-clicks. - function doubleClicked() { - redraw(3); - } - -
-class: p5 -params: - - name: 'n' - description: > -

number of times to run draw(). Defaults to - 1.

- type: Integer - optional: true -chainable: false ---- - - -# redraw diff --git a/src/content/reference/en/p5 copy/remove.mdx b/src/content/reference/en/p5 copy/remove.mdx deleted file mode 100644 index 552822f5a3..0000000000 --- a/src/content/reference/en/p5 copy/remove.mdx +++ /dev/null @@ -1,57 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L559 -title: remove -module: Structure -submodule: Structure -file: src/core/main.js -description: > -

Removes the sketch from the web page.

- -

Calling remove() stops the draw loop and removes any HTML - elements - - created by the sketch, including the canvas. A new sketch can be - - created by using the p5() constructor, as in - - new p5().

-line: 559 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Double-click to remove the canvas. - - function setup() { - createCanvas(100, 100); - - describe( - 'A white circle on a gray background. The circle follows the mouse as the user moves. The sketch disappears when the user double-clicks.' - ); - } - - function draw() { - // Paint the background repeatedly. - background(200); - - // Draw circles repeatedly. - circle(mouseX, mouseY, 40); - } - - // Remove the sketch when the user double-clicks. - function doubleClicked() { - remove(); - } - -
-class: p5 -chainable: false ---- - - -# remove diff --git a/src/content/reference/en/p5 copy/removeElements.mdx b/src/content/reference/en/p5 copy/removeElements.mdx deleted file mode 100644 index 51e712026b..0000000000 --- a/src/content/reference/en/p5 copy/removeElements.mdx +++ /dev/null @@ -1,85 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L256 -title: removeElements -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Removes all elements created by p5.js, including any event handlers.

- -

There are two exceptions: - - canvas elements created by createCanvas() - - and p5.Render objects created by - - createGraphics().

-line: 256 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a paragraph element and place - // it in the middle of the canvas. - let p = createP('p5*js'); - p.position(25, 25); - - describe('A gray square with the text "p5*js" written in its center. The text disappears when the mouse is pressed.'); - } - - // Remove all elements when the mouse is pressed. - function mousePressed() { - removeElements(); - } - -
- -
- - let slider; - - function setup() { - createCanvas(100, 100); - - // Create a paragraph element and place - // it at the top of the canvas. - let p = createP('p5*js'); - p.position(25, 25); - - // Create a slider element and place it - // beneath the canvas. - slider = createSlider(0, 255, 200); - slider.position(0, 100); - - describe('A gray square with the text "p5*js" written in its center and a range slider beneath it. The square changes color when the slider is moved. The text and slider disappear when the square is double-clicked.'); - } - - function draw() { - // Use the slider value to change the background color. - let g = slider.value(); - background(g); - } - - // Remove all elements when the mouse is double-clicked. - function doubleClicked() { - removeElements(); - } - -
-class: p5 -chainable: false ---- - - -# removeElements diff --git a/src/content/reference/en/p5 copy/removeItem.mdx b/src/content/reference/en/p5 copy/removeItem.mdx deleted file mode 100644 index ba091b00b4..0000000000 --- a/src/content/reference/en/p5 copy/removeItem.mdx +++ /dev/null @@ -1,97 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/data/local_storage.js#L380 -title: removeItem -module: Data -submodule: LocalStorage -file: src/data/local_storage.js -description: > -

Removes an item from the web browser's local storage.

- -

Web browsers can save small amounts of data using the built-in - - localStorage object. - - Data stored in localStorage can be retrieved at any point, even - after - - refreshing a page or restarting the browser. Data are stored as key-value - - pairs.

- -

storeItem() makes it easy to store - values in - - localStorage and removeItem() makes it easy to - delete them.

- -

The parameter, key, is the name of the value to remove as a - string. For - - example, calling removeItem('size') removes the item with the key - size.

- -

Note: Sensitive data such as passwords or personal information shouldn't be - - stored in localStorage.

-line: 380 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Double-click to remove an item from localStorage. - - function setup() { - createCanvas(100, 100); - - // Store the player's name. - storeItem('name', 'Feist'); - - // Store the player's score. - storeItem('score', 1234); - - describe( - 'The text "Feist: 1234" written in black on a gray background. The text "Feist: null" appears when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(14); - - // Retrieve the name. - let name = getItem('name'); - - // Retrieve the score. - let score = getItem('score'); - - // Display the score. - text(`${name}: ${score}`, 50, 50); - } - - // Remove the word from localStorage when the user double-clicks. - function doubleClicked() { - removeItem('score'); - } - -
-class: p5 -params: - - name: key - description: | -

name of the value to remove.

- type: String -chainable: false ---- - - -# removeItem diff --git a/src/content/reference/en/p5 copy/requestPointerLock.mdx b/src/content/reference/en/p5 copy/requestPointerLock.mdx deleted file mode 100644 index 621ce063ce..0000000000 --- a/src/content/reference/en/p5 copy/requestPointerLock.mdx +++ /dev/null @@ -1,85 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1880 -title: requestPointerLock -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

Locks the mouse pointer to its current position and makes it invisible.

- -

requestPointerLock() allows the mouse to move forever without - leaving the - - screen. Calling requestPointerLock() locks the values of - - mouseX, mouseY, - - pmouseX, and pmouseY. - - movedX and movedY - - continue updating and can be used to get the distance the mouse moved since - - the last frame was drawn. Calling - - exitPointerLock() resumes - updating the - - mouse system variables.

- -

Note: Most browsers require an input, such as a click, before calling - - requestPointerLock(). It’s recommended to call - requestPointerLock() in - - an event function such as doubleClicked().

-line: 1880 -isConstructor: false -itemtype: method -example: - - |- - -
- - let score = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with the text "Score: X" at its center. The score increases when the user moves the mouse upward. It decreases when the user moves the mouse downward.' - ); - } - - function draw() { - background(200); - - // Update the score. - score -= movedY; - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the score. - text(`Score: ${score}`, 50, 50); - } - - // Lock the pointer when the user double-clicks. - function doubleClicked() { - requestPointerLock(); - } - -
-class: p5 -chainable: false ---- - - -# requestPointerLock diff --git a/src/content/reference/en/p5 copy/resetMatrix.mdx b/src/content/reference/en/p5 copy/resetMatrix.mdx deleted file mode 100644 index af797b49db..0000000000 --- a/src/content/reference/en/p5 copy/resetMatrix.mdx +++ /dev/null @@ -1,52 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L246 -title: resetMatrix -module: Transform -submodule: Transform -file: src/core/transform.js -description: | -

Clears all transformations applied to the coordinate system.

-line: 246 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe( - 'Two circles drawn on a gray background. A blue circle is at the top-left and a red circle is at the bottom-right.' - ); - } - - function draw() { - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Draw a blue circle at the coordinates (25, 25). - fill('blue'); - circle(25, 25, 20); - - // Clear all transformations. - // The origin is now at the top-left corner. - resetMatrix(); - - // Draw a red circle at the coordinates (25, 25). - fill('red'); - circle(25, 25, 20); - } - -
-class: p5 -chainable: true ---- - - -# resetMatrix diff --git a/src/content/reference/en/p5 copy/resetShader.mdx b/src/content/reference/en/p5 copy/resetShader.mdx deleted file mode 100644 index 850ca0773c..0000000000 --- a/src/content/reference/en/p5 copy/resetShader.mdx +++ /dev/null @@ -1,95 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1628 -title: resetShader -module: 3D -submodule: Material -file: src/webgl/material.js -description: | -

Restores the default shaders.

-

resetShader() deactivates any shaders previously applied by - shader().

-

Note: Shaders can only be used in WebGL mode.

-line: 1628 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Create a string with the vertex shader program. - // The vertex shader is called for each vertex. - let vertSrc = ` - attribute vec3 aPosition; - attribute vec2 aTexCoord; - uniform mat4 uProjectionMatrix; - uniform mat4 uModelViewMatrix; - varying vec2 vTexCoord; - - void main() { - vTexCoord = aTexCoord; - vec4 position = vec4(aPosition, 1.0); - gl_Position = uProjectionMatrix * uModelViewMatrix * position; - } - `; - - // Create a string with the fragment shader program. - // The fragment shader is called for each pixel. - let fragSrc = ` - precision mediump float; - varying vec2 vTexCoord; - - void main() { - vec2 uv = vTexCoord; - vec3 color = vec3(uv.x, uv.y, min(uv.x + uv.y, 1.0)); - gl_FragColor = vec4(color, 1.0); - } - `; - - let myShader; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Shader object. - myShader = createShader(vertSrc, fragSrc); - - describe( - 'Two rotating cubes on a gray background. The left one has a blue-purple gradient on each face. The right one is red.' - ); - } - - function draw() { - background(200); - - // Draw a box using the p5.Shader. - // shader() sets the active shader to myShader. - shader(myShader); - push(); - translate(-25, 0, 0); - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - box(width / 4); - pop(); - - // Draw a box using the default fill shader. - // resetShader() restores the default fill shader. - resetShader(); - fill(255, 0, 0); - push(); - translate(25, 0, 0); - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - box(width / 4); - pop(); - } - -
-class: p5 -chainable: true ---- - - -# resetShader diff --git a/src/content/reference/en/p5 copy/resizeCanvas.mdx b/src/content/reference/en/p5 copy/resizeCanvas.mdx deleted file mode 100644 index fde0561563..0000000000 --- a/src/content/reference/en/p5 copy/resizeCanvas.mdx +++ /dev/null @@ -1,133 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L221 -title: resizeCanvas -module: Rendering -submodule: Rendering -file: src/core/rendering.js -description: > -

Resizes the canvas to a given width and height.

- -

resizeCanvas() immediately clears the canvas and calls - - redraw(). It's common to call - resizeCanvas() - - within the body of windowResized() - like - - so:

- -
function windowResized() {
-    resizeCanvas(windowWidth, windowHeight);
-  }
-
-  
- -

The first two parameters, width and height, set - the dimensions of the - - canvas. They also the values of the width - and - - height system variables. For example, - calling - - resizeCanvas(300, 500) resizes the canvas to 300×500 pixels, then - sets - - width to 300 and - - height 500.

- -

The third parameter, noRedraw, is optional. If - true is passed, as in - - resizeCanvas(300, 500, true), then the canvas will be canvas to - 300×500 - - pixels but the redraw() function won't be - called - - immediately. By default, redraw() is - called - - immediately when resizeCanvas() finishes executing.

-line: 221 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Double-click to resize the canvas. - - function setup() { - createCanvas(100, 100); - - describe( - 'A white circle drawn on a gray background. The canvas shrinks by half the first time the user double-clicks.' - ); - } - - function draw() { - background(180); - - // Draw a circle at the center of the canvas. - circle(width / 2, height / 2, 20); - } - - // Resize the canvas when the user double-clicks. - function doubleClicked() { - resizeCanvas(50, 50); - } - -
- -
- - // Resize the web browser to change the canvas size. - - function setup() { - createCanvas(windowWidth, windowHeight); - - describe('A white circle drawn on a gray background.'); - } - - function draw() { - background(180); - - // Draw a circle at the center of the canvas. - circle(width / 2, height / 2, 20); - } - - // Always resize the canvas to fill the browser window. - function windowResized() { - resizeCanvas(windowWidth, windowHeight); - } - -
-class: p5 -params: - - name: width - description: | -

width of the canvas.

- type: Number - - name: height - description: | -

height of the canvas.

- type: Number - - name: noRedraw - description: | -

whether to delay calling - redraw(). Defaults - to false.

- type: Boolean - optional: true -chainable: false ---- - - -# resizeCanvas diff --git a/src/content/reference/en/p5 copy/reverse.mdx b/src/content/reference/en/p5 copy/reverse.mdx deleted file mode 100644 index bf7a6571ac..0000000000 --- a/src/content/reference/en/p5 copy/reverse.mdx +++ /dev/null @@ -1,43 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L141 -title: reverse -module: Data -submodule: Array Functions -file: src/utilities/array_functions.js -description: | -

Reverses the order of an array, maps to Array.reverse()

-line: 141 -deprecated: >- - Use array.reverse() - instead. -isConstructor: false -itemtype: method -example: - - |- - -
- function setup() { - let myArray = ['A', 'B', 'C']; - print(myArray); // ['A','B','C'] - - reverse(myArray); - print(myArray); // ['C','B','A'] - } -
-class: p5 -params: - - name: list - description: | -

Array to reverse

- type: Array -return: - description: the reversed list - type: Array -chainable: false ---- - - -# reverse diff --git a/src/content/reference/en/p5 copy/rotate.mdx b/src/content/reference/en/p5 copy/rotate.mdx deleted file mode 100644 index bbb4f8e5f8..0000000000 --- a/src/content/reference/en/p5 copy/rotate.mdx +++ /dev/null @@ -1,226 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L289 -title: rotate -module: Transform -submodule: Transform -file: src/core/transform.js -description: > -

Rotates the coordinate system.

- -

By default, the positive x-axis points to the right and the positive y-axis - - points downward. The rotate() function changes this orientation - by - - rotating the coordinate system about the origin. Everything drawn after - - rotate() is called will appear to be rotated.

- -

The first parameter, angle, is the amount to rotate. For - example, calling - - rotate(1) rotates the coordinate system clockwise 1 radian which - is - - nearly 57˚. rotate() interprets angle values using the current - - angleMode().

- -

The second parameter, axis, is optional. It's used to orient - 3D rotations - - in WebGL mode. If a p5.Vector is passed, - as in - - rotate(QUARTER_PI, myVector), then the coordinate system will - rotate - - QUARTER_PI radians about myVector. If an array of - vector components is - - passed, as in rotate(QUARTER_PI, [1, 0, 0]), then the coordinate - system - - will rotate QUARTER_PI radians about a vector with the components - - [1, 0, 0].

- -

By default, transformations accumulate. For example, calling - rotate(1) - - twice has the same effect as calling rotate(2) once. The - - push() and pop() functions - - can be used to isolate transformations within distinct drawing groups.

- -

Note: Transformations are reset at the beginning of the draw loop. Calling - - rotate(1) inside the draw() - function won't cause - - shapes to spin.

-line: 289 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe( - "A white rectangle on a gray background. The rectangle's long axis runs from top-left to bottom-right." - ); - } - - function draw() { - background(200); - - // Rotate the coordinate system 1/8 turn. - rotate(QUARTER_PI); - - // Draw a rectangle at coordinates (50, 0). - rect(50, 0, 40, 20); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - "A white rectangle on a gray background. The rectangle's long axis runs from top-left to bottom-right." - ); - } - - function draw() { - background(200); - - // Rotate the coordinate system 1/16 turn. - rotate(QUARTER_PI / 2); - - // Rotate the coordinate system another 1/16 turn. - rotate(QUARTER_PI / 2); - - // Draw a rectangle at coordinates (50, 0). - rect(50, 0, 40, 20); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Use degrees. - angleMode(DEGREES); - - describe( - "A white rectangle on a gray background. The rectangle's long axis runs from top-left to bottom-right." - ); - } - - function draw() { - background(200); - - // Rotate the coordinate system 1/8 turn. - rotate(45); - - // Draw a rectangle at coordinates (50, 0). - rect(50, 0, 40, 20); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A white rectangle on a gray background. The rectangle rotates slowly about the top-left corner. It disappears and reappears periodically.' - ); - } - - function draw() { - background(200); - - // Rotate the coordinate system a little more each frame. - let angle = frameCount * 0.01; - rotate(angle); - - // Draw a rectangle at coordinates (50, 0). - rect(50, 0, 40, 20); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe("A cube on a gray background. The cube's front face points to the top-right."); - } - - function draw() { - background(200); - - // Rotate the coordinate system 1/8 turn about - // the axis [1, 1, 0]. - let axis = createVector(1, 1, 0); - rotate(QUARTER_PI, axis); - - // Draw a box. - box(); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe("A cube on a gray background. The cube's front face points to the top-right."); - } - - function draw() { - background(200); - - // Rotate the coordinate system 1/8 turn about - // the axis [1, 1, 0]. - let axis = [1, 1, 0]; - rotate(QUARTER_PI, axis); - - // Draw a box. - box(); - } - -
-class: p5 -params: - - name: angle - description: > -

angle of rotation in the current angleMode().

- type: Number - - name: axis - description: | -

axis to rotate about in 3D.

- type: 'p5.Vector|Number[]' - optional: true -chainable: true ---- - - -# rotate diff --git a/src/content/reference/en/p5 copy/rotateX.mdx b/src/content/reference/en/p5 copy/rotateX.mdx deleted file mode 100644 index c519976bce..0000000000 --- a/src/content/reference/en/p5 copy/rotateX.mdx +++ /dev/null @@ -1,161 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L470 -title: rotateX -module: Transform -submodule: Transform -file: src/core/transform.js -description: > -

Rotates the coordinate system about the x-axis in WebGL mode.

- -

The parameter, angle, is the amount to rotate. For example, - calling - - rotateX(1) rotates the coordinate system about the x-axis by 1 - radian. - - rotateX() interprets angle values using the current - - angleMode().

- -

By default, transformations accumulate. For example, calling - rotateX(1) - - twice has the same effect as calling rotateX(2) once. The - - push() and pop() functions - - can be used to isolate transformations within distinct drawing groups.

- -

Note: Transformations are reset at the beginning of the draw loop. Calling - - rotateX(1) inside the draw() - function won't cause - - shapes to spin.

-line: 470 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system 1/8 turn. - rotateX(QUARTER_PI); - - // Draw a box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system 1/16 turn. - rotateX(QUARTER_PI / 2); - - // Rotate the coordinate system 1/16 turn. - rotateX(QUARTER_PI / 2); - - // Draw a box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - // Use degrees. - angleMode(DEGREES); - - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system 1/8 turn. - rotateX(45); - - // Draw a box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube rotates slowly against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system a little more each frame. - let angle = frameCount * 0.01; - rotateX(angle); - - // Draw a box. - box(); - } - -
-class: p5 -params: - - name: angle - description: > -

angle of rotation in the current angleMode().

- type: Number -chainable: true ---- - - -# rotateX diff --git a/src/content/reference/en/p5 copy/rotateY.mdx b/src/content/reference/en/p5 copy/rotateY.mdx deleted file mode 100644 index c7976c5a44..0000000000 --- a/src/content/reference/en/p5 copy/rotateY.mdx +++ /dev/null @@ -1,161 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L606 -title: rotateY -module: Transform -submodule: Transform -file: src/core/transform.js -description: > -

Rotates the coordinate system about the y-axis in WebGL mode.

- -

The parameter, angle, is the amount to rotate. For example, - calling - - rotateY(1) rotates the coordinate system about the y-axis by 1 - radian. - - rotateY() interprets angle values using the current - - angleMode().

- -

By default, transformations accumulate. For example, calling - rotateY(1) - - twice has the same effect as calling rotateY(2) once. The - - push() and pop() functions - - can be used to isolate transformations within distinct drawing groups.

- -

Note: Transformations are reset at the beginning of the draw loop. Calling - - rotateY(1) inside the draw() - function won't cause - - shapes to spin.

-line: 606 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system 1/8 turn. - rotateY(QUARTER_PI); - - // Draw a box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system 1/16 turn. - rotateY(QUARTER_PI / 2); - - // Rotate the coordinate system 1/16 turn. - rotateY(QUARTER_PI / 2); - - // Draw a box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - // Use degrees. - angleMode(DEGREES); - - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system 1/8 turn. - rotateY(45); - - // Draw a box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube rotates slowly against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system a little more each frame. - let angle = frameCount * 0.01; - rotateY(angle); - - // Draw a box. - box(); - } - -
-class: p5 -params: - - name: angle - description: > -

angle of rotation in the current angleMode().

- type: Number -chainable: true ---- - - -# rotateY diff --git a/src/content/reference/en/p5 copy/rotateZ.mdx b/src/content/reference/en/p5 copy/rotateZ.mdx deleted file mode 100644 index 317bd7fe88..0000000000 --- a/src/content/reference/en/p5 copy/rotateZ.mdx +++ /dev/null @@ -1,161 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L742 -title: rotateZ -module: Transform -submodule: Transform -file: src/core/transform.js -description: > -

Rotates the coordinate system about the z-axis in WebGL mode.

- -

The parameter, angle, is the amount to rotate. For example, - calling - - rotateZ(1) rotates the coordinate system about the z-axis by 1 - radian. - - rotateZ() interprets angle values using the current - - angleMode().

- -

By default, transformations accumulate. For example, calling - rotateZ(1) - - twice has the same effect as calling rotateZ(2) once. The - - push() and pop() functions - - can be used to isolate transformations within distinct drawing groups.

- -

Note: Transformations are reset at the beginning of the draw loop. Calling - - rotateZ(1) inside the draw() - function won't cause - - shapes to spin.

-line: 742 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system 1/8 turn. - rotateZ(QUARTER_PI); - - // Draw a box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system 1/16 turn. - rotateZ(QUARTER_PI / 2); - - // Rotate the coordinate system 1/16 turn. - rotateZ(QUARTER_PI / 2); - - // Draw a box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - // Use degrees. - angleMode(DEGREES); - - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system 1/8 turn. - rotateZ(45); - - // Draw a box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube rotates slowly against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system a little more each frame. - let angle = frameCount * 0.01; - rotateZ(angle); - - // Draw a box. - box(); - } - -
-class: p5 -params: - - name: angle - description: > -

angle of rotation in the current angleMode().

- type: Number -chainable: true ---- - - -# rotateZ diff --git a/src/content/reference/en/p5 copy/rotationX.mdx b/src/content/reference/en/p5 copy/rotationX.mdx deleted file mode 100644 index 98dfd287dc..0000000000 --- a/src/content/reference/en/p5 copy/rotationX.mdx +++ /dev/null @@ -1,45 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L131 -title: rotationX -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: | -

The system variable rotationX always contains the rotation of the - device along the x axis. If the sketch - angleMode() is set to DEGREES, the value will be -180 to 180. If - it is set to RADIANS, the value will be -PI to PI.

-

Note: The order the rotations are called is important, ie. if used - together, it must be called in the order Z-X-Y or there might be - unexpected behaviour.

-line: 131 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - } - - function draw() { - background(200); - //rotateZ(radians(rotationZ)); - rotateX(radians(rotationX)); - //rotateY(radians(rotationY)); - box(200, 200, 200); - describe(`red horizontal line right, green vertical line bottom. - black background.`); - } - -
-class: p5 -type: Number ---- - - -# rotationX diff --git a/src/content/reference/en/p5 copy/rotationY.mdx b/src/content/reference/en/p5 copy/rotationY.mdx deleted file mode 100644 index f06a033bb7..0000000000 --- a/src/content/reference/en/p5 copy/rotationY.mdx +++ /dev/null @@ -1,45 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L164 -title: rotationY -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: | -

The system variable rotationY always contains the rotation of the - device along the y axis. If the sketch - angleMode() is set to DEGREES, the value will be -90 to 90. If - it is set to RADIANS, the value will be -PI/2 to PI/2.

-

Note: The order the rotations are called is important, ie. if used - together, it must be called in the order Z-X-Y or there might be - unexpected behaviour.

-line: 164 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - } - - function draw() { - background(200); - //rotateZ(radians(rotationZ)); - //rotateX(radians(rotationX)); - rotateY(radians(rotationY)); - box(200, 200, 200); - describe(`red horizontal line right, green vertical line bottom. - black background.`); - } - -
-class: p5 -type: Number ---- - - -# rotationY diff --git a/src/content/reference/en/p5 copy/rotationZ.mdx b/src/content/reference/en/p5 copy/rotationZ.mdx deleted file mode 100644 index 47d6d965aa..0000000000 --- a/src/content/reference/en/p5 copy/rotationZ.mdx +++ /dev/null @@ -1,47 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L197 -title: rotationZ -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: | -

The system variable rotationZ always contains the rotation of the - device along the z axis. If the sketch - angleMode() is set to DEGREES, the value will be 0 to 360. If - it is set to RADIANS, the value will be 0 to 2*PI.

-

Unlike rotationX and rotationY, this variable is available for devices - with a built-in compass only.

-

Note: The order the rotations are called is important, ie. if used - together, it must be called in the order Z-X-Y or there might be - unexpected behaviour.

-line: 197 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - } - - function draw() { - background(200); - rotateZ(radians(rotationZ)); - //rotateX(radians(rotationX)); - //rotateY(radians(rotationY)); - box(200, 200, 200); - describe(`red horizontal line right, green vertical line bottom. - black background.`); - } - -
-class: p5 -type: Number ---- - - -# rotationZ diff --git a/src/content/reference/en/p5 copy/round.mdx b/src/content/reference/en/p5 copy/round.mdx deleted file mode 100644 index 3f6efea6eb..0000000000 --- a/src/content/reference/en/p5 copy/round.mdx +++ /dev/null @@ -1,88 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L861 -title: round -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Calculates the integer closest to a number.

- -

For example, round(133.8) returns the value 134.

- -

The second parameter, decimals, is optional. It sets the - number of - - decimal places to use when rounding. For example, round(12.34, 1) - returns - - 12.3. decimals is 0 by default.

-line: 861 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Round a number. - let x = round(4.2); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the rounded number. - text(x, 50, 50); - - describe('The number 4 written in middle of the canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Round a number to 2 decimal places. - let x = round(12.782383, 2); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the rounded number. - text(x, 50, 50); - - describe('The number 12.78 written in middle of canvas.'); - } - -
-class: p5 -params: - - name: 'n' - description: | -

number to round.

- type: Number - - name: decimals - description: | -

number of decimal places to round to, default is 0.

- type: Number - optional: true -return: - description: rounded number. - type: Integer -chainable: false ---- - - -# round diff --git a/src/content/reference/en/p5 copy/sampleRate.mdx b/src/content/reference/en/p5 copy/sampleRate.mdx deleted file mode 100644 index 3608ee22be..0000000000 --- a/src/content/reference/en/p5 copy/sampleRate.mdx +++ /dev/null @@ -1,26 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L811 -title: sampleRate -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: | -

Returns a number representing the sample rate, in samples per second, - of all sound objects in this audio context. It is determined by the - sampling rate of your operating system's sound card, and it is not - currently possile to change. - It is often 44100, or twice the range of human hearing.

-line: 811 -isConstructor: false -itemtype: method -class: p5 -return: - description: samplerate samples per second - type: Number -chainable: false ---- - - -# sampleRate diff --git a/src/content/reference/en/p5 copy/saturation.mdx b/src/content/reference/en/p5 copy/saturation.mdx deleted file mode 100644 index 7552fe927d..0000000000 --- a/src/content/reference/en/p5 copy/saturation.mdx +++ /dev/null @@ -1,201 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L1415 -title: saturation -module: Color -submodule: Creating & Reading -file: src/color/creating_reading.js -description: > -

Gets the saturation value of a color.

- -

saturation() extracts the saturation value from a - - p5.Color object, an array of color - components, or - - a CSS color string.

- -

Saturation is scaled differently in HSB and HSL. By default, - saturation() - - returns a color's HSL saturation in the range 0 to 100. If the - - colorMode() is set to HSB or HSL, it - returns the - - saturation value in the given mode.

-line: 1415 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(50); - - // Use HSB color. - colorMode(HSB); - - // Create a p5.Color object. - let c = color(0, 50, 100); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'satValue' to 50. - let satValue = saturation(c); - - // Draw the right rectangle. - fill(satValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is dark gray.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(50); - - // Use HSB color. - colorMode(HSB); - - // Create a color array. - let c = [0, 50, 100]; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'satValue' to 100. - let satValue = saturation(c); - - // Draw the right rectangle. - fill(satValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is gray.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(50); - - // Use HSB color. - colorMode(HSB); - - // Create a CSS color string. - let c = 'rgb(255, 128, 128)'; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'satValue' to 100. - let satValue = saturation(c); - - // Draw the right rectangle. - fill(satValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is gray.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(50); - - // Use HSL color. - colorMode(HSL); - - // Create a p5.Color object. - let c = color(0, 100, 75); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'satValue' to 100. - let satValue = saturation(c); - - // Draw the right rectangle. - fill(satValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is white.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(50); - - // Use HSL color with values in the range 0-255. - colorMode(HSL, 255); - - // Create a p5.Color object. - let c = color(0, 255, 191.5); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'satValue' to 255. - let satValue = saturation(c); - - // Draw the right rectangle. - fill(satValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is white.'); - } - -
-class: p5 -params: - - name: color - description: | -

p5.Color object, array of - color components, or CSS color string.

- type: 'p5.Color|Number[]|String' -return: - description: the saturation value - type: Number -chainable: false ---- - - -# saturation diff --git a/src/content/reference/en/p5 copy/save.mdx b/src/content/reference/en/p5 copy/save.mdx deleted file mode 100644 index fb8b67cd74..0000000000 --- a/src/content/reference/en/p5 copy/save.mdx +++ /dev/null @@ -1,140 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1835 -title: save -module: IO -submodule: Output -file: src/io/files.js -description: > -

Saves a given element(image, text, json, csv, wav, or html) to the client's - - computer. The first parameter can be a pointer to element we want to save. - - The element can be one of p5.Element,an - Array of - - Strings, an Array of JSON, a JSON object, a p5.Table - - , a p5.Image, or a p5.SoundFile - (requires - - p5.sound). The second parameter is a filename (including extension).The - - third parameter is for options specific to this type of object. This method - - will save a file that fits the given parameters. - - If it is called without specifying an element, by default it will save the - - whole canvas as an image file. You can optionally specify a filename as - - the first parameter in such a case. - - Note that it is not recommended to - - call this method within draw, as it will open a new save dialog on every - - render.

-line: 1835 -isConstructor: false -itemtype: method -example: - - |2- - -
- // Saves the canvas as an image - cnv = createCanvas(300, 300); - save(cnv, 'myCanvas.jpg'); - - // 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.'); -
- -
- let myTable = new p5.Table(); - // Saves table as html file - save(myTable, 'myTable.html'); - - // Comma Separated Values - save(myTable, 'myTable.csv'); - - // Tab Separated Values - save(myTable, 'myTable.tsv'); - - describe(`An example showing how to save a table in formats of - HTML, CSV and TSV.`); -
- -
- let myJSON = { a: 1, b: true }; - - // Saves pretty JSON - save(myJSON, 'my.json'); - - // 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.`); -
-class: p5 -params: - - name: objectOrFilename - description: | -

If filename is provided, will - save canvas as an image with - either png or jpg extension - depending on the filename. - If object is provided, will - save depending on the object - and filename (see examples - above).

- type: Object|String - optional: true - - name: filename - description: | -

If an object is provided as the first - parameter, then the second parameter - indicates the filename, - and should include an appropriate - file extension (see examples above).

- type: String - optional: true - - name: options - description: | -

Additional options depend on - filetype. For example, when saving JSON, - true indicates that the - output will be optimized for filesize, - rather than readability.

- type: Boolean|String - optional: true -chainable: false ---- - - -# save diff --git a/src/content/reference/en/p5 copy/saveCanvas.mdx b/src/content/reference/en/p5 copy/saveCanvas.mdx deleted file mode 100644 index 159bf101ce..0000000000 --- a/src/content/reference/en/p5 copy/saveCanvas.mdx +++ /dev/null @@ -1,166 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/image.js#L153 -title: saveCanvas -module: Image -submodule: Image -file: src/image/image.js -description: > -

Saves the current canvas as an image.

- -

By default, saveCanvas() saves the canvas as a PNG image - called - - untitled.png.

- -

The first parameter, filename, is optional. It's a string that - sets the - - file's name. If a file extension is included, as in - - saveCanvas('drawing.png'), then the image will be saved using - that - - format.

- -

The second parameter, extension, is also optional. It sets the - files format. - - Either 'png', 'webp', or 'jpg' can be - used. For example, saveCanvas('drawing', 'jpg') - - saves the canvas to a file called drawing.jpg.

- -

Note: The browser will either save the file immediately or prompt the user - - with a dialogue window.

-line: 153 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - background(255); - - // Save the canvas to 'untitled.png'. - saveCanvas(); - - describe('A white square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(255); - - // Save the canvas to 'myCanvas.jpg'. - saveCanvas('myCanvas.jpg'); - - describe('A white square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(255); - - // Save the canvas to 'myCanvas.jpg'. - saveCanvas('myCanvas', 'jpg'); - - describe('A white square.'); - } - -
- -
- - function setup() { - let cnv = createCanvas(100, 100); - - background(255); - - // Save the canvas to 'untitled.png'. - saveCanvas(cnv); - - describe('A white square.'); - } - -
- -
- - function setup() { - let cnv = createCanvas(100, 100); - - background(255); - - // Save the canvas to 'myCanvas.jpg'. - saveCanvas(cnv, 'myCanvas.jpg'); - - describe('A white square.'); - } - -
- -
- - function setup() { - let cnv = createCanvas(100, 100); - - background(255); - - // Save the canvas to 'myCanvas.jpg'. - saveCanvas(cnv, 'myCanvas', 'jpg'); - - describe('A white square.'); - } - -
-class: p5 -overloads: - - line: 153 - params: - - name: selectedCanvas - description: | -

reference to a - specific HTML5 canvas element.

- type: p5.Framebuffer|p5.Element|HTMLCanvasElement - - name: filename - description: | -

file name. Defaults to 'untitled'.

- type: String - optional: true - - name: extension - description: > -

file extension, either 'png', 'webp', or 'jpg'. Defaults to - 'png'.

- type: String - optional: true - - line: 267 - params: - - name: filename - description: '' - type: String - optional: true - - name: extension - description: '' - type: String - optional: true -chainable: false ---- - - -# saveCanvas diff --git a/src/content/reference/en/p5 copy/saveFrames.mdx b/src/content/reference/en/p5 copy/saveFrames.mdx deleted file mode 100644 index 72b8d7d987..0000000000 --- a/src/content/reference/en/p5 copy/saveFrames.mdx +++ /dev/null @@ -1,175 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/image.js#L561 -title: saveFrames -module: Image -submodule: Image -file: src/image/image.js -description: > -

Captures a sequence of frames from the canvas that can be saved as - images.

- -

saveFrames() creates an array of frame objects. Each frame is - stored as - - an object with its file type, file name, and image data as a string. For - - example, the first saved frame might have the following properties:

- -

{ ext: 'png', filename: 'frame0', imageData: - 'data:image/octet-stream;base64, abc123' }.

- -

The first parameter, filename, sets the prefix for the file - names. For - - example, setting the prefix to 'frame' would generate the image - files - - frame0.png, frame1.png, and so on.

- -

The second parameter, extension, sets the file type to either - 'png' or - - 'jpg'.

- -

The third parameter, duration, sets the duration to record in - seconds. - - The maximum duration is 15 seconds.

- -

The fourth parameter, framerate, sets the number of frames to - record per - - second. The maximum frame rate value is 22. Limits are placed on - duration - - and framerate to avoid using too much memory. Recording large - canvases - - can easily crash sketches or even web browsers.

- -

The fifth parameter, callback, is optional. If a function is - passed, - - image files won't be saved by default. The callback function can be used - - to process an array containing the data for each captured frame. The array - - of image data contains a sequence of objects with three properties for each - - frame: imageData, filename, and - extension.

- -

Note: Frames are downloaded as individual image files by default.

-line: 561 -isConstructor: false -itemtype: method -example: - - >- - -
- - - - function setup() { - createCanvas(100, 100); - - describe('A square repeatedly changes color from blue to pink.'); - } - - - function draw() { - let r = frameCount % 255; - let g = 50; - let b = 100; - background(r, g, b); - } - - - // Save the frames when the user presses the 's' key. - - function keyPressed() { - if (key === 's') { - saveFrames('frame', 'png', 1, 5); - } - } - - - -
- - -
- - - - function setup() { - createCanvas(100, 100); - - describe('A square repeatedly changes color from blue to pink.'); - } - - - function draw() { - let r = frameCount % 255; - let g = 50; - let b = 100; - background(r, g, b); - } - - - // Print 5 frames when the user presses the mouse. - - function mousePressed() { - saveFrames('frame', 'png', 1, 5, printFrames); - } - - - // Prints an array of objects containing raw image data, filenames, and - extensions. - - function printFrames(frames) { - for (let frame of frames) { - print(frame); - } - } - - - -
-class: p5 -params: - - name: filename - description: | -

prefix of file name.

- type: String - - name: extension - description: | -

file extension, either 'jpg' or 'png'.

- type: String - - name: duration - description: > -

duration in seconds to record. This parameter will be constrained to be - less or equal to 15.

- type: Number - - name: framerate - description: > -

number of frames to save per second. This parameter will be constrained - to be less or equal to 22.

- type: Number - - name: callback - description: | -

callback function that will be executed - to handle the image data. This function - should accept an array as argument. The - array will contain the specified number of - frames of objects. Each object has three - properties: imageData, filename, and extension.

- type: Function(Array) - optional: true -chainable: false ---- - - -# saveFrames diff --git a/src/content/reference/en/p5 copy/saveGif.mdx b/src/content/reference/en/p5 copy/saveGif.mdx deleted file mode 100644 index 9b520993ac..0000000000 --- a/src/content/reference/en/p5 copy/saveGif.mdx +++ /dev/null @@ -1,119 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L204 -title: saveGif -module: Image -submodule: Loading & Displaying -file: src/image/loading_displaying.js -description: > -

Generates a gif from a sketch and saves it to a file.

- -

saveGif() may be called in setup() or at any - - point while a sketch is running.

- -

The first parameter, fileName, sets the gif's file name.

- -

The second parameter, duration, sets the gif's duration in - seconds.

- -

The third parameter, options, is optional. If an object is - passed, - - saveGif() will use its properties to customize the gif. - saveGif() - - recognizes the properties delay, units, - silent, - - notificationDuration, and notificationID.

-line: 204 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A circle drawn in the middle of a gray square. The circle changes color from black to white, then repeats.'); - } - - function draw() { - background(200); - - // Style the circle. - let c = frameCount % 255; - fill(c); - - // Display the circle. - circle(50, 50, 25); - } - - // Save a 5-second gif when the user presses the 's' key. - function keyPressed() { - if (key === 's') { - saveGif('mySketch', 5); - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A circle drawn in the middle of a gray square. The circle changes color from black to white, then repeats.'); - } - - function draw() { - background(200); - - // Style the circle. - let c = frameCount % 255; - fill(c); - - // Display the circle. - circle(50, 50, 25); - } - - // Save a 5-second gif when the user presses the 's' key. - // Wait 1 second after the key press before recording. - function keyPressed() { - if (key === 's') { - saveGif('mySketch', 5, { delay: 1 }); - } - } - -
-class: p5 -params: - - name: filename - description: | -

file name of gif.

- type: String - - name: duration - description: | -

duration in seconds to capture from the sketch.

- type: Number - - name: options - description: | -

an object that can contain five more properties: - delay, a Number specifying how much time to wait before recording; - units, a String that can be either 'seconds' or 'frames'. By default it's 'seconds’; - silent, a Boolean that defines presence of progress notifications. By default it’s false; - notificationDuration, a Number that defines how long in seconds the final notification - will live. By default it's 0, meaning the notification will never be removed; - notificationID, a String that specifies the id of the notification's DOM element. By default it’s 'progressBar’.

- type: Object - optional: true -chainable: false ---- - - -# saveGif diff --git a/src/content/reference/en/p5 copy/saveJSON.mdx b/src/content/reference/en/p5 copy/saveJSON.mdx deleted file mode 100644 index d5e664d0b2..0000000000 --- a/src/content/reference/en/p5 copy/saveJSON.mdx +++ /dev/null @@ -1,170 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1979 -title: saveJSON -module: IO -submodule: Output -file: src/io/files.js -description: > -

Saves an Object or Array to a JSON file.

- -

JavaScript Object Notation - - (JSON) - - is a standard format for sending data between applications. The format is - - based on JavaScript objects which have keys and values. JSON files store - - data in an object with strings as keys. Values can be strings, numbers, - - Booleans, arrays, null, or other objects.

- -

The first parameter, json, is the data to save. The data can - be an array, - - as in [1, 2, 3], or an object, as in - - { x: 50, y: 50, color: 'deeppink' }.

- -

The second parameter, filename, is a string that sets the - file's name. - - For example, calling saveJSON([1, 2, 3], 'data.json') saves the - array - - [1, 2, 3] to a file called data.json on the user's - computer.

- -

The third parameter, optimize, is optional. If - true is passed, as in - - saveJSON([1, 2, 3], 'data.json', true), then all unneeded - whitespace will - - be removed to reduce the file size.

- -

Note: The browser will either save the file immediately or prompt the user - - with a dialogue window.

-line: 1979 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(12); - - // Display instructions. - text('Double-click to save', 5, 50, 90); - - describe('The text "Double-click to save" written in black on a gray background.'); - } - - // Save the file when the user double-clicks. - function doubleClicked() { - if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { - // Create an array. - let data = [1, 2, 3]; - - // Save the JSON file. - saveJSON(data, 'numbers.json'); - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(12); - - // Display instructions. - text('Double-click to save', 5, 50, 90); - - describe('The text "Double-click to save" written in black on a gray background.'); - } - - // Save the file when the user double-clicks. - function doubleClicked() { - if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { - // Create an object. - let data = { x: mouseX, y: mouseY }; - - // Save the JSON file. - saveJSON(data, 'state.json'); - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(12); - - // Display instructions. - text('Double-click to save', 5, 50, 90); - - describe('The text "Double-click to save" written in black on a gray background.'); - } - - // Save the file when the user double-clicks. - function doubleClicked() { - if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { - // Create an object. - let data = { x: mouseX, y: mouseY }; - - // Save the JSON file and reduce its size. - saveJSON(data, 'state.json', true); - } - } - -
-class: p5 -params: - - name: json - description: | -

data to save.

- type: Array|Object - - name: filename - description: | -

name of the file to be saved.

- type: String - - name: optimize - description: | -

whether to trim unneeded whitespace. Defaults - to true.

- type: Boolean - optional: true -chainable: false ---- - - -# saveJSON diff --git a/src/content/reference/en/p5 copy/saveSound.mdx b/src/content/reference/en/p5 copy/saveSound.mdx deleted file mode 100644 index 3e8e7d0667..0000000000 --- a/src/content/reference/en/p5 copy/saveSound.mdx +++ /dev/null @@ -1,35 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L1145 -title: saveSound -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: > -

Save a p5.SoundFile as a .wav file. The browser will prompt the user - - to download the file to their device. - - For uploading audio to a server, use - - p5.SoundFile.saveBlob.

-line: 1145 -isConstructor: false -itemtype: method -class: p5 -params: - - name: soundFile - description: | -

p5.SoundFile that you wish to save

- type: p5.SoundFile - - name: fileName - description: | -

name of the resulting .wav file.

- type: String -chainable: false ---- - - -# saveSound diff --git a/src/content/reference/en/p5 copy/saveStrings.mdx b/src/content/reference/en/p5 copy/saveStrings.mdx deleted file mode 100644 index 36c6c448a2..0000000000 --- a/src/content/reference/en/p5 copy/saveStrings.mdx +++ /dev/null @@ -1,185 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L2118 -title: saveStrings -module: IO -submodule: Output -file: src/io/files.js -description: > -

Saves an Array of Strings to a file, one per - line.

- -

The first parameter, list, is an array with the strings to - save.

- -

The second parameter, filename, is a string that sets the - file's name. - - For example, calling saveStrings(['0', '01', '011'], 'data.txt') - saves - - the array ['0', '01', '011'] to a file called - data.txt on the user's - - computer.

- -

The third parameter, extension, is optional. If a string is - passed, as in - - saveStrings(['0', '01', '01'], 'data', 'txt')`, the second - parameter will - - be interpreted as the file name and the third parameter as the extension.

- -

The fourth parameter, isCRLF, is also optional, If - true is passed, as - - in saveStrings(['0', '01', '011'], 'data', 'txt', true), then two - - characters, \r\n , will be added to the end of each string to - create new - - lines in the saved file. \r is a carriage return (CR) and - \n is a line - - feed (LF). By default, only \n (line feed) is added to each - string in - - order to create new lines.

- -

Note: The browser will either save the file immediately or prompt the user - - with a dialogue window.

-line: 2118 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(12); - - // Display instructions. - text('Double-click to save', 5, 50, 90); - - describe('The text "Double-click to save" written in black on a gray background.'); - } - - // Save the file when the user double-clicks. - function doubleClicked() { - if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { - // Create an array. - let data = ['0', '01', '011']; - - // Save the text file. - saveStrings(data, 'data.txt'); - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(12); - - // Display instructions. - text('Double-click to save', 5, 50, 90); - - describe('The text "Double-click to save" written in black on a gray background.'); - } - - // Save the file when the user double-clicks. - function doubleClicked() { - if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { - // Create an array. - // ASCII art courtesy Wikipedia: - // https://en.wikipedia.org/wiki/ASCII_art - let data = [' (\\_/) ', "(='.'=)", '(")_(")']; - - // Save the text file. - saveStrings(data, 'cat', 'txt'); - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(12); - - // Display instructions. - text('Double-click to save', 5, 50, 90); - - describe('The text "Double-click to save" written in black on a gray background.'); - } - - // Save the file when the user double-clicks. - function doubleClicked() { - if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { - // Create an array. - // +--+ - // / /| - // +--+ + - // | |/ - // +--+ - let data = [' +--+', ' / /|', '+--+ +', '| |/', '+--+']; - - // Save the text file. - // Use CRLF for line endings. - saveStrings(data, 'box', 'txt', true); - } - } - -
-class: p5 -params: - - name: list - description: | -

data to save.

- type: 'String[]' - - name: filename - description: | -

name of file to be saved.

- type: String - - name: extension - description: | -

format to use for the file.

- type: String - optional: true - - name: isCRLF - description: | -

whether to add \r\n to the end of each - string. Defaults to false.

- type: Boolean - optional: true -chainable: false ---- - - -# saveStrings diff --git a/src/content/reference/en/p5 copy/saveTable.mdx b/src/content/reference/en/p5 copy/saveTable.mdx deleted file mode 100644 index dd6e64ea4d..0000000000 --- a/src/content/reference/en/p5 copy/saveTable.mdx +++ /dev/null @@ -1,70 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L2275 -title: saveTable -module: IO -submodule: Output -file: src/io/files.js -description: > -

Writes the contents of a Table object - to a file. Defaults to a - - text file with comma-separated-values ('csv') but can also - - use tab separation ('tsv'), or generate an HTML table ('html'). - - The file saving process and location of the saved file will - - vary between web browsers.

-line: 2275 -isConstructor: false -itemtype: method -example: - - |- - -
- let table; - - function setup() { - table = new p5.Table(); - - table.addColumn('id'); - table.addColumn('species'); - table.addColumn('name'); - - let newRow = table.addRow(); - newRow.setNum('id', table.getRowCount() - 1); - newRow.setString('species', 'Panthera leo'); - newRow.setString('name', 'Lion'); - - // 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 -
-class: p5 -params: - - name: Table - description: | -

the Table object to save to a file

- type: p5.Table - - name: filename - description: | -

the filename to which the Table should be saved

- type: String - - name: options - description: | -

can be one of "tsv", "csv", or "html"

- type: String - optional: true -chainable: false ---- - - -# saveTable diff --git a/src/content/reference/en/p5 copy/scale.mdx b/src/content/reference/en/p5 copy/scale.mdx deleted file mode 100644 index a459477d80..0000000000 --- a/src/content/reference/en/p5 copy/scale.mdx +++ /dev/null @@ -1,231 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L878 -title: scale -module: Transform -submodule: Transform -file: src/core/transform.js -description: > -

Scales the coordinate system.

- -

By default, shapes are drawn at their original scale. A rectangle that's 50 - - pixels wide appears to take up half the width of a 100 pixel-wide canvas. - - The scale() function can shrink or stretch the coordinate system - so that - - shapes appear at different sizes. There are two ways to call - scale() with - - parameters that set the scale factor(s).

- -

The first way to call scale() uses numbers to set the amount - of scaling. - - The first parameter, s, sets the amount to scale each axis. For - example, - - calling scale(2) stretches the x-, y-, and z-axes by a factor of - 2. The - - next two parameters, y and z, are optional. They set - the amount to - - scale the y- and z-axes. For example, calling scale(2, 0.5, 1) - stretches - - the x-axis by a factor of 2, shrinks the y-axis by a factor of 0.5, and - - leaves the z-axis unchanged.

- -

The second way to call scale() uses a p5.Vector - - object to set the scale factors. For example, calling - scale(myVector) - - uses the x-, y-, and z-components of myVector to set the amount - of - - scaling along the x-, y-, and z-axes. Doing so is the same as calling - - scale(myVector.x, myVector.y, myVector.z).

- -

By default, transformations accumulate. For example, calling - scale(1) - - twice has the same effect as calling scale(2) once. The - - push() and pop() functions - - can be used to isolate transformations within distinct drawing groups.

- -

Note: Transformations are reset at the beginning of the draw loop. Calling - - scale(2) inside the draw() - function won't cause - - shapes to grow continuously.

-line: 878 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe( - 'Two white squares on a gray background. The larger square appears at the top-center. The smaller square appears at the top-left.' - ); - } - - function draw() { - background(200); - - // Draw a square at (30, 20). - square(30, 20, 40); - - // Scale the coordinate system by a factor of 0.5. - scale(0.5); - - // Draw a square at (30, 20). - // It appears at (15, 10) after scaling. - square(30, 20, 40); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A rectangle and a square drawn in white on a gray background.'); - } - - function draw() { - background(200); - - // Draw a square at (30, 20). - square(30, 20, 40); - - // Scale the coordinate system by factors of - // 0.5 along the x-axis and - // 1.3 along the y-axis. - scale(0.5, 1.3); - - // Draw a square at (30, 20). - // It appears as a rectangle at (15, 26) after scaling. - square(30, 20, 40); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A rectangle and a square drawn in white on a gray background.'); - } - - function draw() { - background(200); - - // Draw a square at (30, 20). - square(30, 20, 40); - - // Create a p5.Vector object. - let v = createVector(0.5, 1.3); - - // Scale the coordinate system by factors of - // 0.5 along the x-axis and - // 1.3 along the y-axis. - scale(v); - - // Draw a square at (30, 20). - // It appears as a rectangle at (15, 26) after scaling. - square(30, 20, 40); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'A red box and a blue box drawn on a gray background. The red box appears embedded in the blue box.' - ); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the spheres. - noStroke(); - - // Draw the red sphere. - fill('red'); - box(); - - // Scale the coordinate system by factors of - // 0.5 along the x-axis and - // 1.3 along the y-axis and - // 2 along the z-axis. - scale(0.5, 1.3, 2); - - // Draw the blue sphere. - fill('blue'); - box(); - } - -
-class: p5 -overloads: - - line: 878 - params: - - name: s - description: | -

amount to scale along the positive x-axis.

- type: 'Number|p5.Vector|Number[]' - - name: 'y' - description: > -

amount to scale along the positive y-axis. Defaults to - s.

- type: Number - optional: true - - name: z - description: > -

amount to scale along the positive z-axis. Defaults to - y.

- type: Number - optional: true - chainable: 1 - - line: 1039 - params: - - name: scales - description: | -

vector whose components should be used to scale.

- type: 'p5.Vector|Number[]' - chainable: 1 -chainable: true ---- - - -# scale diff --git a/src/content/reference/en/p5 copy/second.mdx b/src/content/reference/en/p5 copy/second.mdx deleted file mode 100644 index e29042801c..0000000000 --- a/src/content/reference/en/p5 copy/second.mdx +++ /dev/null @@ -1,47 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L277 -title: second -module: IO -submodule: Time & Date -file: src/utilities/time_date.js -description: | -

Returns the current second as a number from 0–59.

-line: 277 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Get the current second. - let s = second(); - - // Style the text. - textAlign(LEFT, CENTER); - textSize(12); - textFont('Courier New'); - - // Display the second. - text(`Current second: ${s}`, 10, 50, 80); - - describe(`The text 'Current second: ${s}' written in black on a gray background.`); - } - -
-class: p5 -return: - description: current second between 0 and 59. - type: Integer -chainable: false ---- - - -# second diff --git a/src/content/reference/en/p5 copy/select.mdx b/src/content/reference/en/p5 copy/select.mdx deleted file mode 100644 index 0ace11ab0d..0000000000 --- a/src/content/reference/en/p5 copy/select.mdx +++ /dev/null @@ -1,113 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L21 -title: select -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Searches the page for the first element that matches the given - - CSS selector string.

- -

The selector string can be an ID, class, tag name, or a combination. - - select() returns a p5.Element object if it - - finds a match and null if not.

- -

The second parameter, container, is optional. It specifies a - container to - - search within. container can be CSS selector string, a - - p5.Element object, or an - - HTMLElement object.

-line: 21 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - background(200); - - // Select the canvas by its tag. - let cnv = select('canvas'); - cnv.style('border', '5px deeppink dashed'); - - describe('A gray square with a dashed pink border.'); - } - -
- -
- - function setup() { - let cnv = createCanvas(100, 100); - - // Add a class attribute to the canvas. - cnv.class('pinkborder'); - - background(200); - - // Select the canvas by its class. - cnv = select('.pinkborder'); - - // Style its border. - cnv.style('border', '5px deeppink dashed'); - - describe('A gray square with a dashed pink border.'); - } - -
- -
- - function setup() { - let cnv = createCanvas(100, 100); - - // Set the canvas' ID. - cnv.id('mycanvas'); - - background(200); - - // Select the canvas by its ID. - cnv = select('#mycanvas'); - - // Style its border. - cnv.style('border', '5px deeppink dashed'); - - describe('A gray square with a dashed pink border.'); - } - -
-class: p5 -params: - - name: selectors - description: | -

CSS selector string of element to search for.

- type: String - - name: container - description: | -

CSS selector string, p5.Element, or - HTMLElement to search within.

- type: String|p5.Element|HTMLElement - optional: true -return: - description: p5.Element containing the element. - type: p5.Element|null -chainable: false ---- - - -# select diff --git a/src/content/reference/en/p5 copy/selectAll.mdx b/src/content/reference/en/p5 copy/selectAll.mdx deleted file mode 100644 index ccd1f3329f..0000000000 --- a/src/content/reference/en/p5 copy/selectAll.mdx +++ /dev/null @@ -1,121 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L109 -title: selectAll -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Searches the page for all elements that matches the given - - CSS selector string.

- -

The selector string can be an ID, class, tag name, or a combination. - - selectAll() returns an array of p5.Element - - objects if it finds any matches and an empty array if none are found.

- -

The second parameter, container, is optional. It specifies a - container to - - search within. container can be CSS selector string, a - - p5.Element object, or an - - HTMLElement object.

-line: 109 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Create three buttons. - createButton('1'); - createButton('2'); - createButton('3'); - - // Select the buttons by their tag. - let buttons = selectAll('button'); - - // Position the buttons. - for (let i = 0; i < 3; i += 1) { - buttons[i].position(0, i * 30); - } - - describe('Three buttons stacked vertically. The buttons are labeled, "1", "2", and "3".'); - } - -
- -
- - function setup() { - // Create three buttons and position them. - let b1 = createButton('1'); - b1.position(0, 0); - let b2 = createButton('2'); - b2.position(0, 30); - let b3 = createButton('3'); - b3.position(0, 60); - - // Add a class attribute to each button. - b1.class('btn'); - b2.class('btn btn-pink'); - b3.class('btn'); - - // Select the buttons by their class. - let buttons = selectAll('.btn'); - let pinkButtons = selectAll('.btn-pink'); - - // Style the selected buttons. - buttons.forEach(setFont); - pinkButtons.forEach(setColor); - - describe('Three buttons stacked vertically. The buttons are labeled, "1", "2", and "3". Buttons "1" and "3" are gray. Button "2" is pink.'); - } - - // Set a button's font to Comic Sans MS. - function setFont(btn) { - btn.style('font-family', 'Comic Sans MS'); - } - - // Set a button's background and font color. - function setColor(btn) { - btn.style('background', 'deeppink'); - btn.style('color', 'white'); - } - -
-class: p5 -params: - - name: selectors - description: | -

CSS selector string of element to search for.

- type: String - - name: container - description: | -

CSS selector string, p5.Element, or - HTMLElement to search within.

- type: String|p5.Element|HTMLElement - optional: true -return: - description: >- - array of p5.Elements containing any elements - found. - type: 'p5.Element[]' -chainable: false ---- - - -# selectAll diff --git a/src/content/reference/en/p5 copy/set.mdx b/src/content/reference/en/p5 copy/set.mdx deleted file mode 100644 index caa9e75a66..0000000000 --- a/src/content/reference/en/p5 copy/set.mdx +++ /dev/null @@ -1,157 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L997 -title: set -module: Image -submodule: Pixels -file: src/image/pixels.js -description: > -

Sets the color of a pixel or draws an image to the canvas.

- -

set() is easy to use but it's not as fast as - - pixels. Use pixels - - to set many pixel values.

- -

set() interprets the first two parameters as x- and - y-coordinates. It - - interprets the last parameter as a grayscale value, a [R, G, B, - A] pixel - - array, a p5.Color object, or a - - p5.Image object. If an image is passed, - the first - - two parameters set the coordinates for the image's upper-left corner, - - regardless of the current imageMode().

- -

updatePixels() must be called - after using - - set() for changes to appear.

-line: 997 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Set four pixels to black. - set(30, 20, 0); - set(85, 20, 0); - set(85, 75, 0); - set(30, 75, 0); - - // Update the canvas. - updatePixels(); - - describe('Four black dots arranged in a square drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object. - let black = color(0); - - // Set four pixels to black. - set(30, 20, black); - set(85, 20, black); - set(85, 75, black); - set(30, 75, black); - - // Update the canvas. - updatePixels(); - - describe('Four black dots arranged in a square drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(255); - - // Draw a horizontal color gradient. - for (let x = 0; x < 100; x += 1) { - for (let y = 0; y < 100; y += 1) { - // Calculate the grayscale value. - let c = map(x, 0, 100, 0, 255); - - // Set the pixel using the grayscale value. - set(x, y, c); - } - } - - // Update the canvas. - updatePixels(); - - describe('A horizontal color gradient from black to white.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/rockies.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Use the image to set all pixels. - set(0, 0, img); - - // Update the canvas. - updatePixels(); - - describe('An image of a mountain landscape.'); - } - -
-class: p5 -params: - - name: x - description: | -

x-coordinate of the pixel.

- type: Number - - name: 'y' - description: | -

y-coordinate of the pixel.

- type: Number - - name: c - description: | -

grayscale value | pixel array | - p5.Color object | p5.Image to copy.

- type: 'Number|Number[]|Object' -chainable: false ---- - - -# set diff --git a/src/content/reference/en/p5 copy/setAttributes.mdx b/src/content/reference/en/p5 copy/setAttributes.mdx deleted file mode 100644 index 368bc49c6c..0000000000 --- a/src/content/reference/en/p5 copy/setAttributes.mdx +++ /dev/null @@ -1,163 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.RendererGL.js#L118 -title: setAttributes -module: Rendering -submodule: Rendering -file: src/webgl/p5.RendererGL.js -description: | -

Set attributes for the WebGL Drawing context. - This is a way of adjusting how the WebGL - renderer works to fine-tune the display and performance.

-

Note that this will reinitialize the drawing context - if called after the WebGL canvas is made.

-

If an object is passed as the parameter, all attributes - not declared in the object will be set to defaults.

-

The available attributes are: -
- alpha - indicates if the canvas contains an alpha buffer - default is true

-

depth - indicates whether the drawing buffer has a depth buffer - of at least 16 bits - default is true

-

stencil - indicates whether the drawing buffer has a stencil buffer - of at least 8 bits

-

antialias - indicates whether or not to perform anti-aliasing - default is false (true in Safari)

-

premultipliedAlpha - indicates that the page compositor will assume - the drawing buffer contains colors with pre-multiplied alpha - default is true

-

preserveDrawingBuffer - if true the buffers will not be cleared and - and will preserve their values until cleared or overwritten by author - (note that p5 clears automatically on draw loop) - default is true

-

perPixelLighting - if true, per-pixel lighting will be used in the - lighting shader otherwise per-vertex lighting is used. - default is true.

-

version - either 1 or 2, to specify which WebGL version to ask for. By - default, WebGL 2 will be requested. If WebGL2 is not available, it will - fall back to WebGL 1. You can check what version is used with by looking at - the global webglVersion property.

-line: 118 -isConstructor: false -itemtype: method -alt: a rotating cube with smoother edges -example: - - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - } - - function draw() { - background(255); - push(); - rotateZ(frameCount * 0.02); - rotateX(frameCount * 0.02); - rotateY(frameCount * 0.02); - fill(0, 0, 0); - box(50); - pop(); - } - -
-
- Now with the antialias attribute set to true. -
-
- - function setup() { - setAttributes('antialias', true); - createCanvas(100, 100, WEBGL); - } - - function draw() { - background(255); - push(); - rotateZ(frameCount * 0.02); - rotateX(frameCount * 0.02); - rotateY(frameCount * 0.02); - fill(0, 0, 0); - box(50); - pop(); - } - -
- -
- - // press the mouse button to disable perPixelLighting - function setup() { - createCanvas(100, 100, WEBGL); - noStroke(); - fill(255); - } - - let lights = [ - { c: '#f00', t: 1.12, p: 1.91, r: 0.2 }, - { c: '#0f0', t: 1.21, p: 1.31, r: 0.2 }, - { c: '#00f', t: 1.37, p: 1.57, r: 0.2 }, - { c: '#ff0', t: 1.12, p: 1.91, r: 0.7 }, - { c: '#0ff', t: 1.21, p: 1.31, r: 0.7 }, - { c: '#f0f', t: 1.37, p: 1.57, r: 0.7 } - ]; - - function draw() { - let t = millis() / 1000 + 1000; - background(0); - directionalLight(color('#222'), 1, 1, 1); - - for (let i = 0; i < lights.length; i++) { - let light = lights[i]; - pointLight( - color(light.c), - p5.Vector.fromAngles(t * light.t, t * light.p, width * light.r) - ); - } - - specularMaterial(255); - sphere(width * 0.1); - - rotateX(t * 0.77); - rotateY(t * 0.83); - rotateZ(t * 0.91); - torus(width * 0.3, width * 0.07, 24, 10); - } - - function mousePressed() { - setAttributes('perPixelLighting', false); - noStroke(); - fill(255); - } - function mouseReleased() { - setAttributes('perPixelLighting', true); - noStroke(); - fill(255); - } - -
-class: p5 -overloads: - - line: 118 - params: - - name: key - description: | -

Name of attribute

- type: String - - name: value - description: | -

New value of named attribute

- type: Boolean - - line: 262 - params: - - name: obj - description: | -

object with key-value pairs

- type: Object -chainable: false ---- - - -# setAttributes diff --git a/src/content/reference/en/p5 copy/setBPM.mdx b/src/content/reference/en/p5 copy/setBPM.mdx deleted file mode 100644 index d2e94a6c5d..0000000000 --- a/src/content/reference/en/p5 copy/setBPM.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L9084 -title: setBPM -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: | -

Set the global tempo, in beats per minute, for all - p5.Parts. This method will impact all active p5.Parts.

-line: 9084 -isConstructor: false -itemtype: method -class: p5 -params: - - name: BPM - description: | -

Beats Per Minute

- type: Number - - name: rampTime - description: | -

Seconds from now

- type: Number -chainable: false ---- - - -# setBPM diff --git a/src/content/reference/en/p5 copy/setCamera.mdx b/src/content/reference/en/p5 copy/setCamera.mdx deleted file mode 100644 index bd4727d474..0000000000 --- a/src/content/reference/en/p5 copy/setCamera.mdx +++ /dev/null @@ -1,81 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L3897 -title: setCamera -module: 3D -submodule: Camera -file: src/webgl/p5.Camera.js -description: > -

Sets the current (active) camera of a 3D sketch.

- -

setCamera() allows for switching between multiple cameras - created with - - createCamera().

- -

Note: setCamera() can only be used in WebGL mode.

-line: 3897 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Double-click to toggle between cameras. - - let cam1; - let cam2; - let usingCam1 = true; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the first camera. - // Keep its default settings. - cam1 = createCamera(); - - // Create the second camera. - // Place it at the top-left. - // Point it at the origin. - cam2 = createCamera(); - cam2.setPosition(400, -400, 800); - cam2.lookAt(0, 0, 0); - - // Set the current camera to cam1. - setCamera(cam1); - - describe('A white cube on a gray background. The camera toggles between frontal and aerial views when the user double-clicks.'); - } - - function draw() { - background(200); - - // Draw the box. - box(); - } - - // Toggle the current camera when the user double-clicks. - function doubleClicked() { - if (usingCam1 === true) { - setCamera(cam2); - usingCam1 = false; - } else { - setCamera(cam1); - usingCam1 = true; - } - } - -
-class: p5 -params: - - name: cam - description: | -

camera that should be made active.

- type: p5.Camera -chainable: false ---- - - -# setCamera diff --git a/src/content/reference/en/p5 copy/setMoveThreshold.mdx b/src/content/reference/en/p5 copy/setMoveThreshold.mdx deleted file mode 100644 index 3b90fb5f4d..0000000000 --- a/src/content/reference/en/p5 copy/setMoveThreshold.mdx +++ /dev/null @@ -1,59 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L417 -title: setMoveThreshold -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

The setMoveThreshold() - function is used to set the movement threshold for - - the deviceMoved() function. The - default threshold is set to 0.5.

-line: 417 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Run this example on a mobile device - // You will need to move the device incrementally further - // the closer the square's color gets to white in order to change the value. - - let value = 0; - let threshold = 0.5; - function setup() { - setMoveThreshold(threshold); - } - 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; - threshold = threshold + 0.1; - if (value > 255) { - value = 0; - threshold = 30; - } - setMoveThreshold(threshold); - } - -
-class: p5 -params: - - name: value - description: | -

The threshold value

- type: Number -chainable: false ---- - - -# setMoveThreshold diff --git a/src/content/reference/en/p5 copy/setShakeThreshold.mdx b/src/content/reference/en/p5 copy/setShakeThreshold.mdx deleted file mode 100644 index 30af9eadb0..0000000000 --- a/src/content/reference/en/p5 copy/setShakeThreshold.mdx +++ /dev/null @@ -1,59 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L459 -title: setShakeThreshold -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

The setShakeThreshold() - function is used to set the movement threshold for - - the deviceShaken() function. The - default threshold is set to 30.

-line: 459 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Run this example on a mobile device - // You will need to shake the device more firmly - // the closer the box's fill gets to white in order to change the value. - - let value = 0; - let threshold = 30; - function setup() { - setShakeThreshold(threshold); - } - 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; - threshold = threshold + 5; - if (value > 255) { - value = 0; - threshold = 30; - } - setShakeThreshold(threshold); - } - -
-class: p5 -params: - - name: value - description: | -

The threshold value

- type: Number -chainable: false ---- - - -# setShakeThreshold diff --git a/src/content/reference/en/p5 copy/setup.mdx b/src/content/reference/en/p5 copy/setup.mdx deleted file mode 100644 index 6a71ea6a0f..0000000000 --- a/src/content/reference/en/p5 copy/setup.mdx +++ /dev/null @@ -1,111 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L87 -title: setup -module: Structure -submodule: Structure -file: src/core/main.js -description: > -

A function that's called once when the sketch begins running.

- -

Declaring the function setup() sets a code block to run once - - automatically when the sketch starts running. It's used to perform - - setup tasks such as creating the canvas and initializing variables:

- -
function setup() {
-    // Code to run once at the start of the sketch.
-  }
-
-  
- -

Code placed in setup() will run once before code placed in - - draw() begins looping. If the - - preload() is declared, then - setup() will - - run immediately after preload() finishes - - loading assets.

- -

Note: setup() doesn’t have to be declared, but it’s common - practice to do so.

-line: 87 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw the circle. - circle(50, 50, 40); - - describe('A white circle on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Paint the background once. - background(200); - - describe( - 'A white circle on a gray background. The circle follows the mouse as the user moves, leaving a trail.' - ); - } - - function draw() { - // Draw circles repeatedly. - circle(mouseX, mouseY, 40); - } - -
- -
- - let img; - - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Draw the image. - image(img, 0, 0); - - describe( - 'A white circle on a brick wall. The circle follows the mouse as the user moves, leaving a trail.' - ); - } - - function draw() { - // Style the circle. - noStroke(); - - // Draw the circle. - circle(mouseX, mouseY, 10); - } - -
-class: p5 -chainable: false ---- - - -# setup diff --git a/src/content/reference/en/p5 copy/shader.mdx b/src/content/reference/en/p5 copy/shader.mdx deleted file mode 100644 index c8213d9261..0000000000 --- a/src/content/reference/en/p5 copy/shader.mdx +++ /dev/null @@ -1,244 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L682 -title: shader -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Sets the p5.Shader object to apply - while drawing.

- -

Shaders are programs that run on the graphics processing unit (GPU). They - - can process many pixels or vertices at the same time, making them fast for - - many graphics tasks. They’re written in a language called - - GLSL - - and run along with the rest of the code in a sketch. - - p5.Shader objects can be created using - the - - createShader() and - - loadShader() functions.

- -

The parameter, s, is the p5.Shader object to - - apply. For example, calling shader(myShader) applies - myShader to - - process each pixel on the canvas. The shader will be used for:

- -
    - -
  • Fills when a texture is enabled if it includes a uniform - sampler2D.
  • - -
  • Fills when lights are enabled if it includes the attribute - aNormal, or if it has any of the following uniforms: - uUseLighting, uAmbientLightCount, - uDirectionalLightCount, uPointLightCount, - uAmbientColor, uDirectionalDiffuseColors, - uDirectionalSpecularColors, uPointLightLocation, - uPointLightDiffuseColors, uPointLightSpecularColors, - uLightingDirection, or uSpecular.
  • - -
  • Fills whenever there are no lights or textures.
  • - -
  • Strokes if it includes the uniform uStrokeWeight.
  • - -
- -

The source code from a p5.Shader - object's - - fragment and vertex shaders will be compiled the first time it's passed to - - shader(). See - - MDN - - for more information about compiling shaders.

- -

Calling resetShader() restores a - sketch’s - - default shaders.

- -

Note: Shaders can only be used in WebGL mode.

-line: 682 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Note: A "uniform" is a global variable within a shader program. - - // Create a string with the vertex shader program. - // The vertex shader is called for each vertex. - let vertSrc = ` - precision highp float; - uniform mat4 uModelViewMatrix; - uniform mat4 uProjectionMatrix; - - attribute vec3 aPosition; - attribute vec2 aTexCoord; - varying vec2 vTexCoord; - - void main() { - vTexCoord = aTexCoord; - vec4 positionVec4 = vec4(aPosition, 1.0); - gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; - } - `; - - // Create a string with the fragment shader program. - // The fragment shader is called for each pixel. - let fragSrc = ` - precision highp float; - - void main() { - // Set each pixel's RGBA value to yellow. - gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); - } - `; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Shader object. - let shaderProgram = createShader(vertSrc, fragSrc); - - // Apply the p5.Shader object. - shader(shaderProgram); - - // Style the drawing surface. - noStroke(); - - // Add a plane as a drawing surface. - plane(100, 100); - - describe('A yellow square.'); - } - -
- -
- - // Note: A "uniform" is a global variable within a shader program. - - let mandelbrot; - - // Load the shader and create a p5.Shader object. - function preload() { - mandelbrot = loadShader('/assets/shader.vert', '/assets/shader.frag'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - // Use the p5.Shader object. - shader(mandelbrot); - - // Set the shader uniform p to an array. - mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); - - describe('A fractal image zooms in and out of focus.'); - } - - function draw() { - // Set the shader uniform r to a value that oscillates between 0 and 2. - mandelbrot.setUniform('r', sin(frameCount * 0.01) + 1); - - // Add a quad as a display surface for the shader. - quad(-1, -1, 1, -1, 1, 1, -1, 1); - } - -
- -
- - // Note: A "uniform" is a global variable within a shader program. - - let redGreen; - let orangeBlue; - let showRedGreen = false; - - // Load the shader and create two separate p5.Shader objects. - function preload() { - redGreen = loadShader('/assets/shader.vert', '/assets/shader-gradient.frag'); - orangeBlue = loadShader('/assets/shader.vert', '/assets/shader-gradient.frag'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - // Initialize the redGreen shader. - shader(redGreen); - - // Set the redGreen shader's center and background color. - redGreen.setUniform('colorCenter', [1.0, 0.0, 0.0]); - redGreen.setUniform('colorBackground', [0.0, 1.0, 0.0]); - - // Initialize the orangeBlue shader. - shader(orangeBlue); - - // Set the orangeBlue shader's center and background color. - orangeBlue.setUniform('colorCenter', [1.0, 0.5, 0.0]); - orangeBlue.setUniform('colorBackground', [0.226, 0.0, 0.615]); - - describe( - 'The scene toggles between two circular gradients when the user double-clicks. An orange and blue gradient vertically, and red and green gradient moves horizontally.' - ); - } - - function draw() { - // Update the offset values for each shader. - // Move orangeBlue vertically. - // Move redGreen horizontally. - orangeBlue.setUniform('offset', [0, sin(frameCount * 0.01) + 1]); - redGreen.setUniform('offset', [sin(frameCount * 0.01), 1]); - - if (showRedGreen === true) { - shader(redGreen); - } else { - shader(orangeBlue); - } - - // Style the drawing surface. - noStroke(); - - // Add a quad as a drawing surface. - quad(-1, -1, 1, -1, 1, 1, -1, 1); - } - - // Toggle between shaders when the user double-clicks. - function doubleClicked() { - showRedGreen = !showRedGreen; - } - -
-class: p5 -params: - - name: s - description: | -

p5.Shader object - to apply.

- type: p5.Shader -chainable: true ---- - - -# shader diff --git a/src/content/reference/en/p5 copy/shearX.mdx b/src/content/reference/en/p5 copy/shearX.mdx deleted file mode 100644 index 244fea83e2..0000000000 --- a/src/content/reference/en/p5 copy/shearX.mdx +++ /dev/null @@ -1,105 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L1069 -title: shearX -module: Transform -submodule: Transform -file: src/core/transform.js -description: > -

Shears the x-axis so that shapes appear skewed.

- -

By default, the x- and y-axes are perpendicular. The shearX() - function - - transforms the coordinate system so that x-coordinates are translated while - - y-coordinates are fixed.

- -

The first parameter, angle, is the amount to shear. For - example, calling - - shearX(1) transforms all x-coordinates using the formula - - x = x + y * tan(angle). shearX() interprets angle - values using the - - current angleMode().

- -

By default, transformations accumulate. For example, calling - - shearX(1) twice has the same effect as calling - shearX(2) once. The - - push() and - - pop() functions can be used to isolate - - transformations within distinct drawing groups.

- -

Note: Transformations are reset at the beginning of the draw loop. Calling - - shearX(1) inside the draw() - function won't - - cause shapes to shear continuously.

-line: 1069 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A white quadrilateral on a gray background.'); - } - - function draw() { - background(200); - - // Shear the coordinate system along the x-axis. - shearX(QUARTER_PI); - - // Draw the square. - square(0, 0, 50); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Use degrees. - angleMode(DEGREES); - - describe('A white quadrilateral on a gray background.'); - } - - function draw() { - background(200); - - // Shear the coordinate system along the x-axis. - shearX(45); - - // Draw the square. - square(0, 0, 50); - } - -
-class: p5 -params: - - name: angle - description: > -

angle to shear by in the current angleMode().

- type: Number -chainable: true ---- - - -# shearX diff --git a/src/content/reference/en/p5 copy/shearY.mdx b/src/content/reference/en/p5 copy/shearY.mdx deleted file mode 100644 index 007a8b4bfa..0000000000 --- a/src/content/reference/en/p5 copy/shearY.mdx +++ /dev/null @@ -1,105 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L1146 -title: shearY -module: Transform -submodule: Transform -file: src/core/transform.js -description: > -

Shears the y-axis so that shapes appear skewed.

- -

By default, the x- and y-axes are perpendicular. The shearY() - function - - transforms the coordinate system so that y-coordinates are translated while - - x-coordinates are fixed.

- -

The first parameter, angle, is the amount to shear. For - example, calling - - shearY(1) transforms all y-coordinates using the formula - - y = y + x * tan(angle). shearY() interprets angle - values using the - - current angleMode().

- -

By default, transformations accumulate. For example, calling - - shearY(1) twice has the same effect as calling - shearY(2) once. The - - push() and - - pop() functions can be used to isolate - - transformations within distinct drawing groups.

- -

Note: Transformations are reset at the beginning of the draw loop. Calling - - shearY(1) inside the draw() - function won't - - cause shapes to shear continuously.

-line: 1146 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A white quadrilateral on a gray background.'); - } - - function draw() { - background(200); - - // Shear the coordinate system along the y-axis. - shearY(QUARTER_PI); - - // Draw the square. - square(0, 0, 50); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Use degrees. - angleMode(DEGREES); - - describe('A white quadrilateral on a gray background.'); - } - - function draw() { - background(200); - - // Shear the coordinate system along the y-axis. - shearY(45); - - // Draw the square. - square(0, 0, 50); - } - -
-class: p5 -params: - - name: angle - description: > -

angle to shear by in the current angleMode().

- type: Number -chainable: true ---- - - -# shearY diff --git a/src/content/reference/en/p5 copy/shininess.mdx b/src/content/reference/en/p5 copy/shininess.mdx deleted file mode 100644 index a093e246c8..0000000000 --- a/src/content/reference/en/p5 copy/shininess.mdx +++ /dev/null @@ -1,86 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2998 -title: shininess -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Sets the amount of gloss ("shininess") of a - - specularMaterial().

- -

Shiny materials focus reflected light more than dull materials. - - shininess() affects the way materials reflect light sources - including - - directionalLight(), - - pointLight(), - - and spotLight().

- -

The parameter, shine, is a number that sets the amount of - shininess. - - shine must be greater than 1, which is its default value.

-line: 2998 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'Two red spheres drawn on a gray background. White light reflects from their surfaces as the mouse moves. The right sphere is shinier than the left sphere.' - ); - } - - function draw() { - background(200); - - // Turn on a red ambient light. - ambientLight(255, 0, 0); - - // Get the mouse's coordinates. - let mx = mouseX - 50; - let my = mouseY - 50; - - // Turn on a white point light that follows the mouse. - pointLight(255, 255, 255, mx, my, 50); - - // Style the sphere. - noStroke(); - - // Add a specular material with a grayscale value. - specularMaterial(255); - - // Draw the left sphere with low shininess. - translate(-25, 0, 0); - shininess(10); - sphere(20); - - // Draw the right sphere with high shininess. - translate(50, 0, 0); - shininess(100); - sphere(20); - } - -
-class: p5 -params: - - name: shine - description: | -

amount of shine.

- type: Number -chainable: true ---- - - -# shininess diff --git a/src/content/reference/en/p5 copy/shorten.mdx b/src/content/reference/en/p5 copy/shorten.mdx deleted file mode 100644 index a1018f7fb8..0000000000 --- a/src/content/reference/en/p5 copy/shorten.mdx +++ /dev/null @@ -1,44 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L161 -title: shorten -module: Data -submodule: Array Functions -file: src/utilities/array_functions.js -description: | -

Decreases an array by one element and returns the shortened array, - maps to Array.pop().

-line: 161 -deprecated: >- - Use array.pop() - instead. -isConstructor: false -itemtype: method -example: - - |- - -
- function setup() { - let myArray = ['A', 'B', 'C']; - print(myArray); // ['A', 'B', 'C'] - let newArray = shorten(myArray); - print(myArray); // ['A','B','C'] - print(newArray); // ['A','B'] - } -
-class: p5 -params: - - name: list - description: | -

Array to shorten

- type: Array -return: - description: shortened Array - type: Array -chainable: false ---- - - -# shorten diff --git a/src/content/reference/en/p5 copy/shuffle.mdx b/src/content/reference/en/p5 copy/shuffle.mdx deleted file mode 100644 index a4ead252ef..0000000000 --- a/src/content/reference/en/p5 copy/shuffle.mdx +++ /dev/null @@ -1,132 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L185 -title: shuffle -module: Data -submodule: Array Functions -file: src/utilities/array_functions.js -description: > -

Shuffles the elements of an array.

- -

The first parameter, array, is the array to be shuffled. For - example, - - calling shuffle(myArray) will shuffle the elements of - myArray. By - - default, the original array won’t be modified. Instead, a copy will be - - created, shuffled, and returned.

- -

The second parameter, modify, is optional. If - true is passed, as in - - shuffle(myArray, true), then the array will be shuffled in place - without - - making a copy.

-line: 185 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of colors. - let colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']; - - // Create a shuffled copy of the array. - let shuffledColors = shuffle(colors); - - // Draw a row of circles using the original array. - for (let i = 0; i < colors.length; i += 1) { - // Calculate the x-coordinate. - let x = (i + 1) * 12.5; - - // Style the circle. - let c = colors[i]; - fill(c); - - // Draw the circle. - circle(x, 33, 10); - } - - // Draw a row of circles using the original array. - for (let i = 0; i < shuffledColors.length; i += 1) { - // Calculate the x-coordinate. - let x = (i + 1) * 12.5; - - // Style the circle. - let c = shuffledColors[i]; - fill(c); - - // Draw the circle. - circle(x, 67, 10); - } - - describe( - 'Two rows of circles on a gray background. The top row follows the color sequence ROYGBIV. The bottom row has all the same colors but they are shuffled.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of colors. - let colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']; - - // Shuffle the array. - shuffle(colors, true); - - // Draw a row of circles using the original array. - for (let i = 0; i < colors.length; i += 1) { - // Calculate the x-coordinate. - let x = (i + 1) * 12.5; - - // Style the circle. - let c = colors[i]; - fill(c); - - // Draw the circle. - circle(x, 50, 10); - } - - describe( - 'A row of colorful circles on a gray background. Their sequence changes each time the sketch runs.' - ); - } - -
-class: p5 -params: - - name: array - description: | -

array to shuffle.

- type: Array - - name: bool - description: > -

if true, shuffle the original array in place. Defaults to - false.

- type: Boolean - optional: true -return: - description: shuffled array. - type: Array -chainable: false ---- - - -# shuffle diff --git a/src/content/reference/en/p5 copy/sin.mdx b/src/content/reference/en/p5 copy/sin.mdx deleted file mode 100644 index 7f0cba972d..0000000000 --- a/src/content/reference/en/p5 copy/sin.mdx +++ /dev/null @@ -1,107 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L363 -title: sin -module: Math -submodule: Trigonometry -file: src/math/trigonometry.js -description: > -

Calculates the sine of an angle.

- -

sin() is useful for many geometric tasks in creative coding. - The values - - returned oscillate between -1 and 1 as the input angle increases. - sin() - - calculates the sine of an angle, using radians by default, or according to - - if angleMode() setting (RADIANS or - DEGREES).

-line: 363 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A white ball on a string oscillates up and down.'); - } - - function draw() { - background(200); - - // Calculate the coordinates. - let x = 50; - let y = 30 * sin(frameCount * 0.05) + 50; - - // Draw the oscillator. - line(50, y, x, y); - circle(x, y, 20); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - describe('A series of black dots form a wave pattern.'); - } - - function draw() { - // Calculate the coordinates. - let x = frameCount; - let y = 30 * sin(x * 0.1) + 50; - - // Draw the point. - point(x, y); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - describe('A series of black dots form an infinity symbol.'); - } - - function draw() { - // Calculate the coordinates. - let x = 30 * cos(frameCount * 0.1) + 50; - let y = 10 * sin(frameCount * 0.2) + 50; - - // Draw the point. - point(x, y); - } - -
-class: p5 -params: - - name: angle - description: > -

the angle, in radians by default, or according to - - if angleMode() setting (RADIANS or - DEGREES).

- type: Number -return: - description: sine of the angle. - type: Number -chainable: false ---- - - -# sin diff --git a/src/content/reference/en/p5 copy/smooth.mdx b/src/content/reference/en/p5 copy/smooth.mdx deleted file mode 100644 index 2c42bda62c..0000000000 --- a/src/content/reference/en/p5 copy/smooth.mdx +++ /dev/null @@ -1,94 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L303 -title: smooth -module: Shape -submodule: Attributes -file: src/core/shape/attributes.js -description: > -

Draws certain features with smooth (antialiased) edges.

- -

smooth() is active by default. In 2D mode, - - noSmooth() is helpful for scaling up - images - - without blurring. The functions don't affect shapes or fonts.

- -

In WebGL mode, noSmooth() causes all - shapes to - - be drawn with jagged (aliased) edges. The functions don't affect images or - - fonts.

-line: 303 -isConstructor: false -itemtype: method -example: - - |- - -
- - let heart; - - // Load a pixelated heart image from an image data string. - function preload() { - heart = loadImage('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAAXNSR0IArs4c6QAAAEZJREFUGFd9jcsNACAIQ9tB2MeR3YdBMBBq8CIXPi2vBICIiOwkOedatllqWO6Y8yOWoyuNf1GZwgmf+RRG2YXr+xVFmA8HZ9Mx/KGPMtcAAAAASUVORK5CYII='); - } - - function setup() { - createCanvas(100, 100); - - background(50); - - // Antialiased hearts. - image(heart, 10, 10); - image(heart, 20, 10, 16, 16); - image(heart, 40, 10, 32, 32); - - // Aliased hearts. - noSmooth(); - image(heart, 10, 60); - image(heart, 20, 60, 16, 16); - image(heart, 40, 60, 32, 32); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - circle(0, 0, 80); - - describe('A white circle on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - // Disable smoothing. - noSmooth(); - - background(200); - - circle(0, 0, 80); - - describe('A pixelated white circle on a gray background.'); - } - -
-class: p5 -chainable: true ---- - - -# smooth diff --git a/src/content/reference/en/p5 copy/sort.mdx b/src/content/reference/en/p5 copy/sort.mdx deleted file mode 100644 index c2249d926a..0000000000 --- a/src/content/reference/en/p5 copy/sort.mdx +++ /dev/null @@ -1,63 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L300 -title: sort -module: Data -submodule: Array Functions -file: src/utilities/array_functions.js -description: | -

Sorts an array of numbers from smallest to largest, or puts an array of - words in alphabetical order. The original array is not modified; a - re-ordered array is returned. The count parameter states the number of - elements to sort. For example, if there are 12 elements in an array and - count is set to 5, only the first 5 elements in the array will be sorted.

-line: 300 -deprecated: >- - Use array.sort() - instead. -isConstructor: false -itemtype: method -example: - - |- - -
- function setup() { - let words = ['banana', 'apple', 'pear', 'lime']; - print(words); // ['banana', 'apple', 'pear', 'lime'] - let count = 4; // length of array - - words = sort(words, count); - print(words); // ['apple', 'banana', 'lime', 'pear'] - } -
-
- function setup() { - let numbers = [2, 6, 1, 5, 14, 9, 8, 12]; - print(numbers); // [2, 6, 1, 5, 14, 9, 8, 12] - let count = 5; // Less than the length of the array - - numbers = sort(numbers, count); - print(numbers); // [1,2,5,6,14,9,8,12] - } -
-class: p5 -params: - - name: list - description: | -

Array to sort

- type: Array - - name: count - description: | -

number of elements to sort, starting from 0

- type: Integer - optional: true -return: - description: the sorted list - type: Array -chainable: false ---- - - -# sort diff --git a/src/content/reference/en/p5 copy/soundFormats.mdx b/src/content/reference/en/p5 copy/soundFormats.mdx deleted file mode 100644 index 6bc28fe726..0000000000 --- a/src/content/reference/en/p5 copy/soundFormats.mdx +++ /dev/null @@ -1,51 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L925 -title: soundFormats -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: | -

List the SoundFile formats that you will include. LoadSound - will search your directory for these extensions, and will pick - a format that is compatable with the client's web browser. - Here is a free online file - converter.

-line: 925 -isConstructor: false -itemtype: method -example: - - |- - -
- function preload() { - // set the global sound formats - soundFormats('mp3', 'ogg'); - - // load either beatbox.mp3, or .ogg, depending on browser - mySound = loadSound('/assets/beatbox.mp3'); - } - - function setup() { - let cnv = createCanvas(100, 100); - background(220); - text('sound loaded! tap to play', 10, 20, width - 20); - cnv.mousePressed(function() { - mySound.play(); - }); - } -
-class: p5 -params: - - name: formats - description: | -

i.e. 'mp3', 'wav', 'ogg'

- type: String - optional: true - multiple: true -chainable: false ---- - - -# soundFormats diff --git a/src/content/reference/en/p5 copy/soundOut.mdx b/src/content/reference/en/p5 copy/soundOut.mdx deleted file mode 100644 index 2f418a829c..0000000000 --- a/src/content/reference/en/p5 copy/soundOut.mdx +++ /dev/null @@ -1,26 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L782 -title: soundOut -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: > -

p5.soundOut is the p5.sound final output bus. It sends output - to - - the destination of this window's web audio context. It contains - - Web Audio API nodes including a dyanmicsCompressor (.limiter), - - and Gain Nodes for .input and .output.

-line: 782 -isConstructor: false -itemtype: property -class: p5 -type: Object ---- - - -# soundOut diff --git a/src/content/reference/en/p5 copy/specularColor.mdx b/src/content/reference/en/p5 copy/specularColor.mdx deleted file mode 100644 index b23e834ca7..0000000000 --- a/src/content/reference/en/p5 copy/specularColor.mdx +++ /dev/null @@ -1,308 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L205 -title: specularColor -module: 3D -submodule: Lights -file: src/webgl/light.js -description: > -

Sets the specular color for lights.

- -

specularColor() affects lights that bounce off a surface in a - preferred - - direction. These lights include - - directionalLight(), - - pointLight(), and - - spotLight(). The function helps to - create - - highlights on p5.Geometry objects that - are - - styled with specularMaterial(). - If a - - geometry does not use - - specularMaterial(), then - - specularColor() will have no effect.

- -

Note: specularColor() doesn’t affect lights that bounce in all - - directions, including ambientLight() - and - - imageLight().

- -

There are three ways to call specularColor() with optional - parameters to - - set the specular highlight color.

- -

The first way to call specularColor() has two optional - parameters, gray - - and alpha. Grayscale and alpha values between 0 and 255, as in - - specularColor(50) or specularColor(50, 80), can be - passed to set the - - specular highlight color.

- -

The second way to call specularColor() has one optional - parameter, - - color. A p5.Color object, an - array of color - - values, or a CSS color string can be passed to set the specular highlight - - color.

- -

The third way to call specularColor() has four optional - parameters, v1, - - v2, v3, and alpha. RGBA, HSBA, or HSLA - values, as in - - specularColor(255, 0, 0, 80), can be passed to set the specular - highlight - - color. Color values will be interpreted using the current - - colorMode().

-line: 205 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white sphere drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // No specular color. - // Draw the sphere. - sphere(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click the canvas to add a point light. - - let isLit = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A sphere drawn on a gray background. A spotlight starts shining when the user double-clicks.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the sphere. - noStroke(); - specularColor(100); - specularMaterial(255, 255, 255); - - // Control the light. - if (isLit === true) { - // Add a white point light from the top-right. - pointLight(255, 255, 255, 30, -20, 40); - } - - // Draw the sphere. - sphere(30); - } - - // Turn on the point light when the user double-clicks. - function doubleClicked() { - isLit = true; - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A black sphere drawn on a gray background. An area on the surface of the sphere is highlighted in blue.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Add a specular highlight. - // Use a p5.Color object. - let c = color('dodgerblue'); - specularColor(c); - - // Add a white point light from the top-right. - pointLight(255, 255, 255, 30, -20, 40); - - // Style the sphere. - noStroke(); - - // Add a white specular material. - specularMaterial(255, 255, 255); - - // Draw the sphere. - sphere(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A black sphere drawn on a gray background. An area on the surface of the sphere is highlighted in blue.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Add a specular highlight. - // Use a CSS color string. - specularColor('#1E90FF'); - - // Add a white point light from the top-right. - pointLight(255, 255, 255, 30, -20, 40); - - // Style the sphere. - noStroke(); - - // Add a white specular material. - specularMaterial(255, 255, 255); - - // Draw the sphere. - sphere(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A black sphere drawn on a gray background. An area on the surface of the sphere is highlighted in blue.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Add a specular highlight. - // Use RGB values. - specularColor(30, 144, 255); - - // Add a white point light from the top-right. - pointLight(255, 255, 255, 30, -20, 40); - - // Style the sphere. - noStroke(); - - // Add a white specular material. - specularMaterial(255, 255, 255); - - // Draw the sphere. - sphere(30); - } - -
-class: p5 -overloads: - - line: 205 - params: - - name: v1 - description: | -

red or hue value in the current - colorMode().

- type: Number - - name: v2 - description: | -

green or saturation value in the current - colorMode().

- type: Number - - name: v3 - description: | -

blue, brightness, or lightness value in the current - colorMode().

- type: Number - chainable: 1 - - line: 423 - params: - - name: gray - description: | -

grayscale value between 0 and 255.

- type: Number - chainable: 1 - - line: 429 - params: - - name: value - description: | -

color as a CSS string.

- type: String - chainable: 1 - - line: 435 - params: - - name: values - description: | -

color as an array of RGBA, HSBA, or HSLA - values.

- type: 'Number[]' - chainable: 1 - - line: 442 - params: - - name: color - description: | -

color as a p5.Color object.

- type: p5.Color - chainable: 1 -chainable: true ---- - - -# specularColor diff --git a/src/content/reference/en/p5 copy/specularMaterial.mdx b/src/content/reference/en/p5 copy/specularMaterial.mdx deleted file mode 100644 index 57e8977cf5..0000000000 --- a/src/content/reference/en/p5 copy/specularMaterial.mdx +++ /dev/null @@ -1,311 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2743 -title: specularMaterial -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Sets the specular color of shapes’ surface material.

- -

The specularMaterial() color sets the components of light - color that - - glossy coats on shapes will reflect. For example, calling - - specularMaterial(255, 255, 0) would cause a shape to reflect red - and - - green light, but not blue light.

- -

Unlike ambientMaterial(), - - specularMaterial() will reflect the full color of light sources - including - - directionalLight(), - - pointLight(), - - and spotLight(). This is what gives it - shapes - - their "shiny" appearance. The material’s shininess can be controlled by the - - shininess() function.

- -

specularMaterial() can be called three ways with different - parameters to - - set the material’s color.

- -

The first way to call specularMaterial() has one parameter, - gray. - - Grayscale values between 0 and 255, as in specularMaterial(50), - can be - - passed to set the material’s color. Higher grayscale values make shapes - - appear brighter.

- -

The second way to call specularMaterial() has one parameter, - color. A - - p5.Color> object, an array of color values, - or a CSS - - color string, as in specularMaterial('magenta'), can be passed to - set the - - material’s color.

- -

The third way to call specularMaterial() has four parameters, - v1, v2, - - v3, and alpha. alpha is optional. RGBA, - HSBA, or HSLA values can be - - passed to set the material’s colors, as in specularMaterial(255, 0, - 0) or - - specularMaterial(255, 0, 0, 30). Color values will be interpreted - using - - the current colorMode().

-line: 2743 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click the canvas to apply a specular material. - - let isGlossy = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A red torus drawn on a gray background. It becomes glossy when the user double-clicks.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on a white point light at the top-right. - pointLight(255, 255, 255, 30, -40, 30); - - // Add a glossy coat if the user has double-clicked. - if (isGlossy === true) { - specularMaterial(255); - shininess(50); - } - - // Style the torus. - noStroke(); - fill(255, 0, 0); - - // Draw the torus. - torus(30); - } - - // Make the torus glossy when the user double-clicks. - function doubleClicked() { - isGlossy = true; - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click the canvas to apply a specular material. - - let isGlossy = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'A red torus drawn on a gray background. It becomes glossy and reflects green light when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on a white point light at the top-right. - pointLight(255, 255, 255, 30, -40, 30); - - // Add a glossy green coat if the user has double-clicked. - if (isGlossy === true) { - specularMaterial(0, 255, 0); - shininess(50); - } - - // Style the torus. - noStroke(); - fill(255, 0, 0); - - // Draw the torus. - torus(30); - } - - // Make the torus glossy when the user double-clicks. - function doubleClicked() { - isGlossy = true; - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click the canvas to apply a specular material. - - let isGlossy = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'A red torus drawn on a gray background. It becomes glossy and reflects green light when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on a white point light at the top-right. - pointLight(255, 255, 255, 30, -40, 30); - - // Add a glossy green coat if the user has double-clicked. - if (isGlossy === true) { - // Create a p5.Color object. - let c = color('green'); - specularMaterial(c); - shininess(50); - } - - // Style the torus. - noStroke(); - fill(255, 0, 0); - - // Draw the torus. - torus(30); - } - - // Make the torus glossy when the user double-clicks. - function doubleClicked() { - isGlossy = true; - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click the canvas to apply a specular material. - - let isGlossy = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'A red torus drawn on a gray background. It becomes glossy and reflects green light when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on a white point light at the top-right. - pointLight(255, 255, 255, 30, -40, 30); - - // Add a glossy green coat if the user has double-clicked. - if (isGlossy === true) { - specularMaterial('#00FF00'); - shininess(50); - } - - // Style the torus. - noStroke(); - fill(255, 0, 0); - - // Draw the torus. - torus(30); - } - - // Make the torus glossy when the user double-clicks. - function doubleClicked() { - isGlossy = true; - } - -
-class: p5 -overloads: - - line: 2743 - params: - - name: gray - description: | -

grayscale value between 0 (black) and 255 (white).

- type: Number - - name: alpha - description: | -

alpha value in the current current - colorMode().

- type: Number - optional: true - chainable: 1 - - line: 2966 - params: - - name: v1 - description: | -

red or hue value in - the current colorMode().

- type: Number - - name: v2 - description: | -

green or saturation value - in the current colorMode().

- type: Number - - name: v3 - description: | -

blue, brightness, or lightness value - in the current colorMode().

- type: Number - - name: alpha - description: '' - type: Number - optional: true - chainable: 1 - - line: 2978 - params: - - name: color - description: | -

color as a p5.Color object, - an array of color values, or a CSS string.

- type: 'p5.Color|Number[]|String' - chainable: 1 -chainable: true ---- - - -# specularMaterial diff --git a/src/content/reference/en/p5 copy/sphere.mdx b/src/content/reference/en/p5 copy/sphere.mdx deleted file mode 100644 index c2ceca44ad..0000000000 --- a/src/content/reference/en/p5 copy/sphere.mdx +++ /dev/null @@ -1,165 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L1227 -title: sphere -module: Shape -submodule: 3D Primitives -file: src/webgl/3d_primitives.js -description: > -

Draws a sphere.

- -

A sphere is a 3D shape with triangular faces that connect to form a round - - surface. Spheres with few faces look like crystals. Spheres with many faces - - have smooth surfaces and look like balls.

- -

The first parameter, radius, is optional. If a - Number is passed, as in - - sphere(20), it sets the radius of the sphere. By default, - radius is 50.

- -

The second parameter, detailX, is also optional. If a - Number is passed, - - as in sphere(20, 5), it sets the number of triangle subdivisions - to use - - along the x-axis. All 3D shapes are made by connecting triangles to form - - their surfaces. By default, detailX is 24.

- -

The third parameter, detailY, is also optional. If a - Number is passed, - - as in sphere(20, 5, 2), it sets the number of triangle - subdivisions to - - use along the y-axis. All 3D shapes are made by connecting triangles to - - form their surfaces. By default, detailY is 16.

- -

Note: sphere() can only be used in WebGL mode.

-line: 1227 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white sphere on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the sphere. - sphere(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white sphere on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the sphere. - // Set its radius to 30. - sphere(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white sphere on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the sphere. - // Set its radius to 30. - // Set its detailX to 6. - sphere(30, 6); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white sphere on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the sphere. - // Set its radius to 30. - // Set its detailX to 24. - // Set its detailY to 4. - sphere(30, 24, 4); - } - -
-class: p5 -params: - - name: radius - description: | -

radius of the sphere. Defaults to 50.

- type: Number - optional: true - - name: detailX - description: | -

number of triangle subdivisions along the x-axis. Defaults to 24.

- type: Integer - optional: true - - name: detailY - description: | -

number of triangle subdivisions along the y-axis. Defaults to 16.

- type: Integer - optional: true -chainable: true ---- - - -# sphere diff --git a/src/content/reference/en/p5 copy/splice.mdx b/src/content/reference/en/p5 copy/splice.mdx deleted file mode 100644 index 866bc4ddef..0000000000 --- a/src/content/reference/en/p5 copy/splice.mdx +++ /dev/null @@ -1,58 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L346 -title: splice -module: Data -submodule: Array Functions -file: src/utilities/array_functions.js -description: | -

Inserts a value or an array of values into an existing array. The first - parameter specifies the initial array to be modified, and the second - parameter defines the data to be inserted. The third parameter is an index - value which specifies the array position from which to insert data. - (Remember that array index numbering starts at zero, so the first position - is 0, the second position is 1, and so on.)

-line: 346 -deprecated: >- - Use array.splice() - instead. -isConstructor: false -itemtype: method -example: - - |- - -
- function setup() { - let myArray = [0, 1, 2, 3, 4]; - let insArray = ['A', 'B', 'C']; - print(myArray); // [0, 1, 2, 3, 4] - print(insArray); // ['A','B','C'] - - splice(myArray, insArray, 3); - print(myArray); // [0,1,2,'A','B','C',3,4] - } -
-class: p5 -params: - - name: list - description: | -

Array to splice into

- type: Array - - name: value - description: | -

value to be spliced in

- type: Any - - name: position - description: | -

in the array from which to insert data

- type: Integer -return: - description: the list - type: Array -chainable: false ---- - - -# splice diff --git a/src/content/reference/en/p5 copy/split.mdx b/src/content/reference/en/p5 copy/split.mdx deleted file mode 100644 index 60b7944313..0000000000 --- a/src/content/reference/en/p5 copy/split.mdx +++ /dev/null @@ -1,87 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L690 -title: split -module: Data -submodule: String Functions -file: src/utilities/string_functions.js -description: > -

Splits a String into pieces and returns an array containing - the pieces.

- -

The first parameter, value, is the string to split.

- -

The second parameter, delim, is the character(s) that should - be used to - - split the string. For example, calling - - split('rock...paper...scissors', '...') would return the array - - ['rock', 'paper', 'scissors'] because there are three periods - ... - - between each word.

-line: 690 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let string = 'rock...paper...scissors'; - - // Split the string at each ... - let words = split(string, '...'); - - // Print the array to the console: - // ["rock", "paper", "scissors"] - print(words); - - // Style the text. - textAlign(CENTER, CENTER); - textFont('Courier New'); - textSize(16); - - // Iterate over the words array. - for (let i = 0; i < words.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 25; - - // Display the word. - text(words[i], 50, y); - } - - describe( - 'The words "rock", "paper", and "scissors" written on separate lines. The text is black on a gray background.' - ); - } - -
-class: p5 -params: - - name: value - description: | -

the String to be split

- type: String - - name: delim - description: | -

the String used to separate the data

- type: String -return: - description: Array of Strings - type: 'String[]' -chainable: false ---- - - -# split diff --git a/src/content/reference/en/p5 copy/splitTokens.mdx b/src/content/reference/en/p5 copy/splitTokens.mdx deleted file mode 100644 index 95d6ef4f8e..0000000000 --- a/src/content/reference/en/p5 copy/splitTokens.mdx +++ /dev/null @@ -1,180 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L751 -title: splitTokens -module: Data -submodule: String Functions -file: src/utilities/string_functions.js -description: > -

Splits a String into pieces and returns an array containing - the pieces.

- -

splitTokens() is an enhanced version of - - split(). It can split a string when any - characters - - from a list are detected.

- -

The first parameter, value, is the string to split.

- -

The second parameter, delim, is optional. It sets the - character(s) that - - should be used to split the string. delim can be a single string, - as in - - splitTokens('rock...paper...scissors...shoot', '...'), or an - array of - - strings, as in - - splitTokens('rock;paper,scissors...shoot, [';', ',', '...']). By - default, - - if no delim characters are specified, then any whitespace - character is - - used to split. Whitespace characters include tab (\t), line feed - (\n), - - carriage return (\r), form feed (\f), and space.

-line: 751 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let string = 'rock paper scissors shoot'; - - // Split the string at each space. - let words = splitTokens(string); - - // Print the array to the console. - print(words); - - // Style the text. - textAlign(CENTER, CENTER); - textFont('Courier New'); - textSize(12); - - // Iterate over the words array. - for (let i = 0; i < words.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 20; - - // Display the word. - text(words[i], 50, y); - } - - describe( - 'The words "rock", "paper", "scissors", and "shoot" written on separate lines. The text is black on a gray background.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let string = 'rock...paper...scissors...shoot'; - - // Split the string at each ... - let words = splitTokens(string, '...'); - - // Print the array to the console. - print(words); - - // Style the text. - textAlign(CENTER, CENTER); - textFont('Courier New'); - textSize(12); - - // Iterate over the words array. - for (let i = 0; i < words.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 20; - - // Display the word. - text(words[i], 50, y); - } - - describe( - 'The words "rock", "paper", "scissors", and "shoot" written on separate lines. The text is black on a gray background.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let string = 'rock;paper,scissors...shoot'; - - // Split the string at each semicolon, comma, or ... - let words = splitTokens(string, [';', ',', '...']); - - // Print the array to the console. - print(words); - - // Style the text. - textAlign(CENTER, CENTER); - textFont('Courier New'); - textSize(12); - - // Iterate over the words array. - for (let i = 0; i < words.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 20; - - // Display the word. - text(words[i], 50, y); - } - - describe( - 'The words "rock", "paper", "scissors", and "shoot" written on separate lines. The text is black on a gray background.' - ); - } - -
-class: p5 -params: - - name: value - description: | -

string to split.

- type: String - - name: delim - description: | -

character(s) to use for splitting the string.

- type: String - optional: true -return: - description: separated strings. - type: 'String[]' -chainable: false ---- - - -# splitTokens diff --git a/src/content/reference/en/p5 copy/spotLight.mdx b/src/content/reference/en/p5 copy/spotLight.mdx deleted file mode 100644 index 3d221dc8f4..0000000000 --- a/src/content/reference/en/p5 copy/spotLight.mdx +++ /dev/null @@ -1,398 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L1272 -title: spotLight -module: 3D -submodule: Lights -file: src/webgl/light.js -description: > -

Creates a light that shines from a point in one direction.

- -

Spot lights are like flashlights that shine in one direction creating a - - cone of light. The shape of the cone can be controlled using the angle and - - concentration parameters. A maximum of 5 spot lights can be active at - once.

- -

There are eight ways to call spotLight() with parameters to - set the - - light’s color, position, direction. For example, - - spotLight(255, 0, 0, 0, 0, 0, 1, 0, 0) creates a red (255, - 0, 0) light - - at the origin (0, 0, 0) that points to the right (1, 0, - 0).

- -

The angle parameter is optional. It sets the radius of the - light cone. - - For example, spotLight(255, 0, 0, 0, 0, 0, 1, 0, 0, PI / 16) - creates a - - red (255, 0, 0) light at the origin (0, 0, 0) that - points to the right - - (1, 0, 0) with an angle of PI / 16 radians. By - default, angle is - - PI / 3 radians.

- -

The concentration parameter is also optional. It focuses the - light - - towards the center of the light cone. For example, - - spotLight(255, 0, 0, 0, 0, 0, 1, 0, 0, PI / 16, 50) creates a red - - (255, 0, 0) light at the origin (0, 0, 0) that - points to the right - - (1, 0, 0) with an angle of PI / 16 radians at - concentration of 50. By - - default, concentration is 100.

-line: 1272 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click to adjust the spotlight. - - let isLit = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white sphere drawn on a gray background. A red spotlight starts shining when the user double-clicks.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Control the spotlight. - if (isLit === true) { - // Add a red spot light that shines into the screen. - // Set its angle to PI / 32 radians. - spotLight(255, 0, 0, 0, 0, 100, 0, 0, -1, PI / 32); - } - - // Draw the sphere. - sphere(30); - } - - // Turn on the spotlight when the user double-clicks. - function doubleClicked() { - isLit = true; - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click to adjust the spotlight. - - let isLit = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white sphere drawn on a gray background. A red spotlight starts shining when the user double-clicks.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Control the spotlight. - if (isLit === true) { - // Add a red spot light that shines into the screen. - // Set its angle to PI / 3 radians (default). - // Set its concentration to 1000. - let c = color(255, 0, 0); - let position = createVector(0, 0, 100); - let direction = createVector(0, 0, -1); - spotLight(c, position, direction, PI / 3, 1000); - } - - // Draw the sphere. - sphere(30); - } - - // Turn on the spotlight when the user double-clicks. - function doubleClicked() { - isLit = true; - } - -
-class: p5 -overloads: - - line: 1272 - params: - - name: v1 - description: | -

red or hue value in the current - colorMode().

- type: Number - - name: v2 - description: | -

green or saturation value in the current - colorMode().

- type: Number - - name: v3 - description: | -

blue, brightness, or lightness value in the current - colorMode().

- type: Number - - name: x - description: | -

x-coordinate of the light.

- type: Number - - name: 'y' - description: | -

y-coordinate of the light.

- type: Number - - name: z - description: | -

z-coordinate of the light.

- type: Number - - name: rx - description: | -

x-component of light direction between -1 and 1.

- type: Number - - name: ry - description: | -

y-component of light direction between -1 and 1.

- type: Number - - name: rz - description: | -

z-component of light direction between -1 and 1.

- type: Number - - name: angle - description: | -

angle of the light cone. Defaults to PI / 3.

- type: Number - optional: true - - name: concentration - description: | -

concentration of the light. Defaults to 100.

- type: Number - optional: true - chainable: 1 - - line: 1399 - params: - - name: color - description: | -

color as a p5.Color object, - an array of color values, or a CSS string.

- type: 'p5.Color|Number[]|String' - - name: position - description: > -

position of the light as a p5.Vector - object.

- type: p5.Vector - - name: direction - description: > -

direction of light as a p5.Vector - object.

- type: p5.Vector - - name: angle - description: '' - type: Number - optional: true - - name: concentration - description: '' - type: Number - optional: true - - line: 1408 - params: - - name: v1 - description: '' - type: Number - - name: v2 - description: '' - type: Number - - name: v3 - description: '' - type: Number - - name: position - description: '' - type: p5.Vector - - name: direction - description: '' - type: p5.Vector - - name: angle - description: '' - type: Number - optional: true - - name: concentration - description: '' - type: Number - optional: true - - line: 1418 - params: - - name: color - description: '' - type: 'p5.Color|Number[]|String' - - name: x - description: '' - type: Number - - name: 'y' - description: '' - type: Number - - name: z - description: '' - type: Number - - name: direction - description: '' - type: p5.Vector - - name: angle - description: '' - type: Number - optional: true - - name: concentration - description: '' - type: Number - optional: true - - line: 1428 - params: - - name: color - description: '' - type: 'p5.Color|Number[]|String' - - name: position - description: '' - type: p5.Vector - - name: rx - description: '' - type: Number - - name: ry - description: '' - type: Number - - name: rz - description: '' - type: Number - - name: angle - description: '' - type: Number - optional: true - - name: concentration - description: '' - type: Number - optional: true - - line: 1438 - params: - - name: v1 - description: '' - type: Number - - name: v2 - description: '' - type: Number - - name: v3 - description: '' - type: Number - - name: x - description: '' - type: Number - - name: 'y' - description: '' - type: Number - - name: z - description: '' - type: Number - - name: direction - description: '' - type: p5.Vector - - name: angle - description: '' - type: Number - optional: true - - name: concentration - description: '' - type: Number - optional: true - - line: 1450 - params: - - name: v1 - description: '' - type: Number - - name: v2 - description: '' - type: Number - - name: v3 - description: '' - type: Number - - name: position - description: '' - type: p5.Vector - - name: rx - description: '' - type: Number - - name: ry - description: '' - type: Number - - name: rz - description: '' - type: Number - - name: angle - description: '' - type: Number - optional: true - - name: concentration - description: '' - type: Number - optional: true - - line: 1462 - params: - - name: color - description: '' - type: 'p5.Color|Number[]|String' - - name: x - description: '' - type: Number - - name: 'y' - description: '' - type: Number - - name: z - description: '' - type: Number - - name: rx - description: '' - type: Number - - name: ry - description: '' - type: Number - - name: rz - description: '' - type: Number - - name: angle - description: '' - type: Number - optional: true - - name: concentration - description: '' - type: Number - optional: true -chainable: true ---- - - -# spotLight diff --git a/src/content/reference/en/p5 copy/sq.mdx b/src/content/reference/en/p5 copy/sq.mdx deleted file mode 100644 index da0f2c4024..0000000000 --- a/src/content/reference/en/p5 copy/sq.mdx +++ /dev/null @@ -1,83 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L928 -title: sq -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Calculates the square of a number.

- -

Squaring a number means multiplying the number by itself. For example, - - sq(3) evaluates 3 × 3 which is 9. sq(-3) evaluates - -3 × -3 - - which is also 9. Multiplying two negative numbers produces a positive - - number. The value returned by sq() is always positive.

-line: 928 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Top-left. - let d = sq(3); - circle(33, 33, d); - - // Bottom-right. - d = sq(6); - circle(67, 67, d); - - describe('Two white circles. The circle at the top-left is small. The circle at the bottom-right is four times larger.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - describe('A series of black dots that get higher quickly from left to right.'); - } - - function draw() { - // Invert the y-axis. - scale(1, -1); - translate(0, -100); - - // Calculate the coordinates. - let x = frameCount; - let y = 0.01 * sq(x); - - // Draw the point. - point(x, y); - } - -
-class: p5 -params: - - name: 'n' - description: | -

number to square.

- type: Number -return: - description: squared number. - type: Number -chainable: false ---- - - -# sq diff --git a/src/content/reference/en/p5 copy/sqrt.mdx b/src/content/reference/en/p5 copy/sqrt.mdx deleted file mode 100644 index 5e239f6fe4..0000000000 --- a/src/content/reference/en/p5 copy/sqrt.mdx +++ /dev/null @@ -1,84 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L988 -title: sqrt -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Calculates the square root of a number.

- -

A number's square root can be multiplied by itself to produce the original - - number. For example, sqrt(9) returns 3 because 3 × 3 = 9. - sqrt() - - always returns a positive value. sqrt() doesn't work with - negative arguments - - such as sqrt(-9).

-line: 988 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Top-left. - let d = sqrt(16); - circle(33, 33, d); - - // Bottom-right. - d = sqrt(1600); - circle(67, 67, d); - - describe('Two white circles. The circle at the top-left is small. The circle at the bottom-right is ten times larger.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - describe('A series of black dots that get higher slowly from left to right.'); - } - - function draw() { - // Invert the y-axis. - scale(1, -1); - translate(0, -100); - - // Calculate the coordinates. - let x = frameCount; - let y = 5 * sqrt(x); - - // Draw the point. - point(x, y); - } - -
-class: p5 -params: - - name: 'n' - description: | -

non-negative number to square root.

- type: Number -return: - description: square root of number. - type: Number -chainable: false ---- - - -# sqrt diff --git a/src/content/reference/en/p5 copy/square.mdx b/src/content/reference/en/p5 copy/square.mdx deleted file mode 100644 index 1e94a0087d..0000000000 --- a/src/content/reference/en/p5 copy/square.mdx +++ /dev/null @@ -1,163 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L1229 -title: square -module: Shape -submodule: 2D Primitives -file: src/core/shape/2d_primitives.js -description: > -

Draws a square.

- -

A square is a four-sided shape defined by the x, - y, and s - - parameters. x and y set the location of its top-left - corner. s sets - - its width and height. Every angle in the square measures 90˚ and all its - - sides are the same length. See rectMode() for - - other ways to define squares.

- -

The version of square() with four parameters creates a rounded - square. - - The fourth parameter sets the radius for all four corners.

- -

The version of square() with seven parameters also creates a - rounded - - square. Each of the last four parameters set the radius of a corner. The - - radii start with the top-left corner and move clockwise around the - - square. If any of these parameters are omitted, they are set to the - - value of the last radius that was set.

-line: 1229 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - square(30, 20, 55); - - describe('A white square with a black outline in on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Give all corners a radius of 20. - square(30, 20, 55, 20); - - describe( - 'A white square with a black outline and round edges on a gray canvas.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Give each corner a unique radius. - square(30, 20, 55, 20, 15, 10, 5); - - describe('A white square with a black outline and round edges of different radii.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - square(-20, -30, 55); - - describe('A white square with a black outline in on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white square spins around on gray canvas.'); - } - - function draw() { - background(200); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Draw the square. - square(-20, -30, 55); - } - -
-class: p5 -params: - - name: x - description: | -

x-coordinate of the square.

- type: Number - - name: 'y' - description: | -

y-coordinate of the square.

- type: Number - - name: s - description: | -

side size of the square.

- type: Number - - name: tl - description: | -

optional radius of top-left corner.

- type: Number - optional: true - - name: tr - description: | -

optional radius of top-right corner.

- type: Number - optional: true - - name: br - description: | -

optional radius of bottom-right corner.

- type: Number - optional: true - - name: bl - description: | -

optional radius of bottom-left corner.

- type: Number - optional: true -chainable: true ---- - - -# square diff --git a/src/content/reference/en/p5 copy/storeItem.mdx b/src/content/reference/en/p5 copy/storeItem.mdx deleted file mode 100644 index 8552634c5a..0000000000 --- a/src/content/reference/en/p5 copy/storeItem.mdx +++ /dev/null @@ -1,149 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/data/local_storage.js#L10 -title: storeItem -module: Data -submodule: LocalStorage -file: src/data/local_storage.js -description: > -

Stores a value in the web browser's local storage.

- -

Web browsers can save small amounts of data using the built-in - - localStorage object. - - Data stored in localStorage can be retrieved at any point, even - after - - refreshing a page or restarting the browser. Data are stored as key-value - - pairs.

- -

storeItem() makes it easy to store values in - localStorage and - - getItem() makes it easy to retrieve - them.

- -

The first parameter, key, is the name of the value to be - stored as a - - string.

- -

The second parameter, value, is the value to be stored. Values - can have - - any type.

- -

Note: Sensitive data such as passwords or personal information shouldn't be - - stored in localStorage.

-line: 10 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Store the player's name. - storeItem('name', 'Feist'); - - // Store the player's score. - storeItem('score', 1234); - - describe('The text "Feist: 1234" written in black on a gray background.'); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(14); - - // Retrieve the name. - let name = getItem('name'); - - // Retrieve the score. - let score = getItem('score'); - - // Display the score. - text(`${name}: ${score}`, 50, 50); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Create an object. - let p = { x: 50, y: 50 }; - - // Store the object. - storeItem('position', p); - - describe('A white circle on a gray background.'); - } - - function draw() { - background(200); - - // Retrieve the object. - let p = getItem('position'); - - // Draw the circle. - circle(p.x, p.y, 30); - } - -
- - function setup() { - createCanvas(100, 100); - - // Create a p5.Color object. - let c = color('deeppink'); - - // Store the object. - storeItem('color', c); - - describe('A pink circle on a gray background.'); - } - - function draw() { - background(200); - - // Retrieve the object. - let c = getItem('color'); - - // Style the circle. - fill(c); - - // Draw the circle. - circle(50, 50, 30); - } - - -class: p5 -params: - - name: key - description: | -

name of the value.

- type: String - - name: value - description: | -

value to be stored.

- type: String|Number|Boolean|Object|Array -chainable: false ---- - - -# storeItem diff --git a/src/content/reference/en/p5 copy/str.mdx b/src/content/reference/en/p5 copy/str.mdx deleted file mode 100644 index c487979761..0000000000 --- a/src/content/reference/en/p5 copy/str.mdx +++ /dev/null @@ -1,135 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L232 -title: str -module: Data -submodule: Conversion -file: src/utilities/conversion.js -description: > -

Converts a Boolean or Number to - String.

- -

str() converts values to strings. See the - - String reference page for guidance on - using - - template literals instead.

- -

The parameter, n, is the value to convert. If n - is a Boolean, as in - - str(false) or str(true), then the value will be - returned as a string, - - as in 'false' or 'true'. If n is a - number, as in str(123), then its - - value will be returned as a string, as in '123'. If an array is - passed, - - as in str([12.34, 56.78]), then an array of strings will be - returned.

-line: 232 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a Boolean variable. - let original = false; - - // Convert the Boolean to a string. - let converted = str(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the original and converted values. - text(`${original} : ${converted}`, 50, 50); - - describe('The text "false : false" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a number variable. - let original = 123; - - // Convert the number to a string. - let converted = str(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the original and converted values. - text(`${original} = ${converted}`, 50, 50); - - describe('The text "123 = 123" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of numbers. - let original = [12, 34, 56]; - - // Convert the numbers to strings. - let strings = str(original); - - // Create an empty string variable. - let final = ''; - - // Concatenate all the strings. - for (let s of strings) { - final += s; - } - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the concatenated string. - text(final, 50, 50); - - describe('The text "123456" written in black on a gray background.'); - } - -
-class: p5 -params: - - name: 'n' - description: | -

value to convert.

- type: String|Boolean|Number -return: - description: converted string. - type: String -chainable: false ---- - - -# str diff --git a/src/content/reference/en/p5 copy/stroke.mdx b/src/content/reference/en/p5 copy/stroke.mdx deleted file mode 100644 index bf086f9b66..0000000000 --- a/src/content/reference/en/p5 copy/stroke.mdx +++ /dev/null @@ -1,311 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1373 -title: stroke -module: Color -submodule: Setting -file: src/color/setting.js -description: > -

Sets the color used to draw points, lines, and the outlines of shapes.

- -

Calling stroke(255, 165, 0) or stroke('orange') - means all shapes drawn - - after calling stroke() will be outlined with the color orange. - The way - - these parameters are interpreted may be changed with the - - colorMode() function.

- -

The version of stroke() with one parameter interprets the - value one of - - three ways. If the parameter is a Number, it's interpreted as a - grayscale - - value. If the parameter is a String, it's interpreted as a CSS - color - - string. A p5.Color object can also be - provided to - - set the stroke color.

- -

The version of stroke() with two parameters interprets the - first one as a - - grayscale value. The second parameter sets the alpha (transparency) value.

- -

The version of stroke() with three parameters interprets them - as RGB, HSB, - - or HSL colors, depending on the current colorMode().

- -

The version of stroke() with four parameters interprets them - as RGBA, HSBA, - - or HSLA colors, depending on the current colorMode(). The last - parameter - - sets the alpha (transparency) value.

-line: 1373 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // A grayscale value. - strokeWeight(4); - stroke(51); - square(20, 20, 60); - - describe('A white square with a dark charcoal gray outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // R, G & B values. - stroke(255, 204, 0); - strokeWeight(4); - square(20, 20, 60); - - describe('A white square with a yellow outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use HSB color. - colorMode(HSB); - - // H, S & B values. - strokeWeight(4); - stroke(255, 204, 100); - square(20, 20, 60); - - describe('A white square with a royal blue outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // A CSS named color. - stroke('red'); - strokeWeight(4); - square(20, 20, 60); - - describe('A white square with a red outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Three-digit hex RGB notation. - stroke('#fae'); - strokeWeight(4); - square(20, 20, 60); - - describe('A white square with a pink outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Six-digit hex RGB notation. - stroke('#222222'); - strokeWeight(4); - square(20, 20, 60); - - describe('A white square with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Integer RGB notation. - stroke('rgb(0, 255, 0)'); - strokeWeight(4); - square(20, 20, 60); - - describe('A whiite square with a bright green outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Integer RGBA notation. - stroke('rgba(0, 255, 0, 0.25)'); - strokeWeight(4); - square(20, 20, 60); - - describe('A white square with a soft green outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Percentage RGB notation. - stroke('rgb(100%, 0%, 10%)'); - strokeWeight(4); - square(20, 20, 60); - - describe('A white square with a red outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Percentage RGBA notation. - stroke('rgba(100%, 0%, 100%, 0.5)'); - strokeWeight(4); - square(20, 20, 60); - - describe('A white square with a dark fuchsia outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // A p5.Color object. - stroke(color(0, 0, 255)); - strokeWeight(4); - square(20, 20, 60); - - describe('A white square with a blue outline.'); - } - -
-class: p5 -overloads: - - line: 1373 - params: - - name: v1 - description: > -

red value if color mode is RGB or hue value if color mode is - HSB.

- type: Number - - name: v2 - description: > -

green value if color mode is RGB or saturation value if color mode - is HSB.

- type: Number - - name: v3 - description: > -

blue value if color mode is RGB or brightness value if color mode - is HSB.

- type: Number - - name: alpha - description: > -

alpha value, controls transparency (0 - transparent, 255 - - opaque).

- type: Number - optional: true - chainable: 1 - - line: 1596 - params: - - name: value - description: | -

a color string.

- type: String - chainable: 1 - - line: 1602 - params: - - name: gray - description: | -

a grayscale value.

- type: Number - - name: alpha - description: '' - type: Number - optional: true - chainable: 1 - - line: 1609 - params: - - name: values - description: | -

an array containing the red, green, blue, - and alpha components of the color.

- type: 'Number[]' - chainable: 1 - - line: 1616 - params: - - name: color - description: | -

the stroke color.

- type: p5.Color - chainable: 1 -chainable: true ---- - - -# stroke diff --git a/src/content/reference/en/p5 copy/strokeCap.mdx b/src/content/reference/en/p5 copy/strokeCap.mdx deleted file mode 100644 index 80965419ab..0000000000 --- a/src/content/reference/en/p5 copy/strokeCap.mdx +++ /dev/null @@ -1,67 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L388 -title: strokeCap -module: Shape -submodule: Attributes -file: src/core/shape/attributes.js -description: > -

Sets the style for rendering the ends of lines.

- -

The caps for line endings are either rounded (ROUND), squared - - (SQUARE), or extended (PROJECT). The default cap is - ROUND.

- -

The argument passed to strokeCap() must be written in ALL CAPS - because - - the constants ROUND, SQUARE, and - PROJECT are defined this way. - - JavaScript is a case-sensitive language.

-line: 388 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - strokeWeight(12); - - // Top. - strokeCap(ROUND); - line(20, 30, 80, 30); - - // Middle. - strokeCap(SQUARE); - line(20, 50, 80, 50); - - // Bottom. - strokeCap(PROJECT); - line(20, 70, 80, 70); - - describe( - 'Three horizontal lines. The top line has rounded ends, the middle line has squared ends, and the bottom line has longer, squared ends.' - ); - } - -
-class: p5 -params: - - name: cap - description: | -

either ROUND, SQUARE, or PROJECT

- type: Constant -chainable: true ---- - - -# strokeCap diff --git a/src/content/reference/en/p5 copy/strokeJoin.mdx b/src/content/reference/en/p5 copy/strokeJoin.mdx deleted file mode 100644 index 46a8a9206f..0000000000 --- a/src/content/reference/en/p5 copy/strokeJoin.mdx +++ /dev/null @@ -1,114 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L442 -title: strokeJoin -module: Shape -submodule: Attributes -file: src/core/shape/attributes.js -description: > -

Sets the style of the joints that connect line segments.

- -

Joints are either mitered (MITER), beveled - (BEVEL), or rounded - - (ROUND). The default joint is MITER in 2D mode and - ROUND in WebGL - - mode.

- -

The argument passed to strokeJoin() must be written in ALL - CAPS because - - the constants MITER, BEVEL, and ROUND - are defined this way. - - JavaScript is a case-sensitive language.

-line: 442 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the line. - noFill(); - strokeWeight(10); - strokeJoin(MITER); - - // Draw the line. - beginShape(); - vertex(35, 20); - vertex(65, 50); - vertex(35, 80); - endShape(); - - describe('A right-facing arrowhead shape with a pointed tip in center of canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the line. - noFill(); - strokeWeight(10); - strokeJoin(BEVEL); - - // Draw the line. - beginShape(); - vertex(35, 20); - vertex(65, 50); - vertex(35, 80); - endShape(); - - describe('A right-facing arrowhead shape with a flat tip in center of canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the line. - noFill(); - strokeWeight(10); - strokeJoin(ROUND); - - // Draw the line. - beginShape(); - vertex(35, 20); - vertex(65, 50); - vertex(35, 80); - endShape(); - - describe('A right-facing arrowhead shape with a rounded tip in center of canvas.'); - } - -
-class: p5 -params: - - name: join - description: | -

either MITER, BEVEL, or ROUND

- type: Constant -chainable: true ---- - - -# strokeJoin diff --git a/src/content/reference/en/p5 copy/strokeWeight.mdx b/src/content/reference/en/p5 copy/strokeWeight.mdx deleted file mode 100644 index 82ebfc13d5..0000000000 --- a/src/content/reference/en/p5 copy/strokeWeight.mdx +++ /dev/null @@ -1,77 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L541 -title: strokeWeight -module: Shape -submodule: Attributes -file: src/core/shape/attributes.js -description: > -

Sets the width of the stroke used for points, lines, and the outlines of - - shapes.

- -

Note: strokeWeight() is affected by transformations, - especially calls to - - scale().

-line: 541 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Top. - line(20, 20, 80, 20); - - // Middle. - strokeWeight(4); - line(20, 40, 80, 40); - - // Bottom. - strokeWeight(10); - line(20, 70, 80, 70); - - describe('Three horizontal black lines. The top line is thin, the middle is medium, and the bottom is thick.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Top. - line(20, 20, 80, 20); - - // Scale by a factor of 5. - scale(5); - - // Bottom. Coordinates are adjusted for scaling. - line(4, 8, 16, 8); - - describe('Two horizontal black lines. The top line is thin and the bottom is five times thicker than the top.'); - } - -
-class: p5 -params: - - name: weight - description: | -

the weight of the stroke (in pixels).

- type: Number -chainable: true ---- - - -# strokeWeight diff --git a/src/content/reference/en/p5 copy/subset.mdx b/src/content/reference/en/p5 copy/subset.mdx deleted file mode 100644 index 1cf7cb7f4e..0000000000 --- a/src/content/reference/en/p5 copy/subset.mdx +++ /dev/null @@ -1,59 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L381 -title: subset -module: Data -submodule: Array Functions -file: src/utilities/array_functions.js -description: | -

Extracts an array of elements from an existing array. The list parameter - defines the array from which the elements will be copied, and the start - and count parameters specify which elements to extract. If no count is - given, elements will be extracted from the start to the end of the array. - When specifying the start, remember that the first array element is 0. - This function does not change the source array.

-line: 381 -deprecated: >- - Use array.slice() - instead. -isConstructor: false -itemtype: method -example: - - |- - -
- function setup() { - let myArray = [1, 2, 3, 4, 5]; - print(myArray); // [1, 2, 3, 4, 5] - - let sub1 = subset(myArray, 0, 3); - let sub2 = subset(myArray, 2, 2); - print(sub1); // [1,2,3] - print(sub2); // [3,4] - } -
-class: p5 -params: - - name: list - description: | -

Array to extract from

- type: Array - - name: start - description: | -

position to begin

- type: Integer - - name: count - description: | -

number of values to extract

- type: Integer - optional: true -return: - description: Array of extracted elements - type: Array -chainable: false ---- - - -# subset diff --git a/src/content/reference/en/p5 copy/tan.mdx b/src/content/reference/en/p5 copy/tan.mdx deleted file mode 100644 index 376d093f33..0000000000 --- a/src/content/reference/en/p5 copy/tan.mdx +++ /dev/null @@ -1,66 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L445 -title: tan -module: Math -submodule: Trigonometry -file: src/math/trigonometry.js -description: > -

Calculates the tangent of an angle.

- -

tan() is useful for many geometric tasks in creative coding. - The values - - returned range from -Infinity to Infinity and repeat periodically as the - - input angle increases. tan() calculates the tan of an angle, - using radians - - by default, or according to - - if angleMode() setting (RADIANS or - DEGREES).

-line: 445 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - describe('A series of identical curves drawn with black dots. Each curve starts from the top of the canvas, continues down at a slight angle, flattens out at the middle of the canvas, then continues to the bottom.'); - } - - function draw() { - // Calculate the coordinates. - let x = frameCount; - let y = 5 * tan(x * 0.1) + 50; - - // Draw the point. - point(x, y); - } - -
-class: p5 -params: - - name: angle - description: > -

the angle, in radians by default, or according to - - if angleMode() setting (RADIANS or - DEGREES).

- type: Number -return: - description: tangent of the angle. - type: Number -chainable: false ---- - - -# tan diff --git a/src/content/reference/en/p5 copy/text.mdx b/src/content/reference/en/p5 copy/text.mdx deleted file mode 100644 index eea293bfd8..0000000000 --- a/src/content/reference/en/p5 copy/text.mdx +++ /dev/null @@ -1,96 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/loading_displaying.js#L182 -title: text -module: Typography -submodule: Loading & Displaying -file: src/typography/loading_displaying.js -description: > -

Draws text to the canvas.

- -

The first parameter, str, is the text to be drawn. The second - and third - - parameters, x and y, set the coordinates of the - text's bottom-left - - corner. See textAlign() for other ways - to - - align text.

- -

The fourth and fifth parameters, maxWidth and - maxHeight, are optional. - - They set the dimensions of the invisible rectangle containing the text. By - - default, they set its maximum width and height. See - - rectMode() for other ways to define the - - rectangular text box. Text will wrap to fit within the text box. Text - - outside of the box won't be drawn.

- -

Text can be styled a few ways. Call the fill() - - function to set the text's fill color. Call - - stroke() and - - strokeWeight() to set the text's - outline. - - Call textSize() and - - textFont() to set the text's size and - font, - - respectively.

- -

Note: WEBGL mode only supports fonts loaded with - - loadFont(). Calling - - stroke() has no effect in - WEBGL mode.

-line: 182 -isConstructor: false -itemtype: method -example: - - "\n
\n\nfunction setup() {\n background(200);\n text('hi', 50, 50);\n\n describe('The text \"hi\" written in black in the middle of a gray square.');\n}\n\n
\n\n
\n\nfunction setup() {\n background('skyblue');\n textSize(100);\n text('\U0001F308', 0, 100);\n\n describe('A rainbow in a blue sky.');\n}\n\n
\n\n
\n\nfunction setup() {\n textSize(32);\n fill(255);\n stroke(0);\n strokeWeight(4);\n text('hi', 50, 50);\n\n describe('The text \"hi\" written in white with a black outline.');\n}\n\n
\n\n
\n\nfunction setup() {\n background('black');\n textSize(22);\n fill('yellow');\n text('rainbows', 6, 20);\n fill('cornflowerblue');\n text('rainbows', 6, 45);\n fill('tomato');\n text('rainbows', 6, 70);\n fill('limegreen');\n text('rainbows', 6, 95);\n\n describe('The text \"rainbows\" written on several lines, each in a different color.');\n}\n\n
\n\n
\n\nfunction setup() {\n background(200);\n let s = 'The quick brown fox jumps over the lazy dog.';\n text(s, 10, 10, 70, 80);\n\n describe('The sample text \"The quick brown fox...\" written in black across several lines.');\n}\n\n
\n\n
\n\nfunction setup() {\n background(200);\n rectMode(CENTER);\n let s = 'The quick brown fox jumps over the lazy dog.';\n text(s, 50, 50, 70, 80);\n\n describe('The sample text \"The quick brown fox...\" written in black across several lines.');\n}\n\n
\n\n
\n\nlet font;\n\nfunction preload() {\n font = loadFont('/assets/inconsolata.otf');\n}\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n textFont(font);\n textSize(32);\n textAlign(CENTER, CENTER);\n}\n\nfunction draw() {\n background(0);\n rotateY(frameCount / 30);\n text('p5*js', 0, 0);\n\n describe('The text \"p5*js\" written in white and spinning in 3D.');\n}\n\n
" -class: p5 -params: - - name: str - description: | -

text to be displayed.

- type: String|Object|Array|Number|Boolean - - name: x - description: | -

x-coordinate of the text box.

- type: Number - - name: 'y' - description: | -

y-coordinate of the text box.

- type: Number - - name: maxWidth - description: | -

maximum width of the text box. See - rectMode() for - other options.

- type: Number - optional: true - - name: maxHeight - description: | -

maximum height of the text box. See - rectMode() for - other options.

- type: Number - optional: true -chainable: true ---- - - -# text diff --git a/src/content/reference/en/p5 copy/textAlign.mdx b/src/content/reference/en/p5 copy/textAlign.mdx deleted file mode 100644 index 3899f22842..0000000000 --- a/src/content/reference/en/p5 copy/textAlign.mdx +++ /dev/null @@ -1,135 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L11 -title: textAlign -module: Typography -submodule: Attributes -file: src/typography/attributes.js -description: > -

Sets the way text is aligned when text() - is called.

- -

By default, calling text('hi', 10, 20) places the bottom-left - corner of - - the text's bounding box at (10, 20).

- -

The first parameter, horizAlign, changes the way - - text() interprets x-coordinates. By default, - the - - x-coordinate sets the left edge of the bounding box. textAlign() - accepts - - the following values for horizAlign: LEFT, - CENTER, or RIGHT.

- -

The second parameter, vertAlign, is optional. It changes the - way - - text() interprets y-coordinates. By default, - the - - y-coordinate sets the bottom edge of the bounding box. - textAlign() - - accepts the following values for vertAlign: TOP, - BOTTOM, CENTER, - - or BASELINE.

-line: 11 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw a vertical line. - strokeWeight(0.5); - line(50, 0, 50, 100); - - // Top line. - textSize(16); - textAlign(RIGHT); - text('ABCD', 50, 30); - - // Middle line. - textAlign(CENTER); - text('EFGH', 50, 50); - - // Bottom line. - textAlign(LEFT); - text('IJKL', 50, 70); - - describe('The letters ABCD displayed at top-left, EFGH at center, and IJKL at bottom-right. A vertical line divides the canvas in half.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - strokeWeight(0.5); - - // First line. - line(0, 12, width, 12); - textAlign(CENTER, TOP); - text('TOP', 50, 12); - - // Second line. - line(0, 37, width, 37); - textAlign(CENTER, CENTER); - text('CENTER', 50, 37); - - // Third line. - line(0, 62, width, 62); - textAlign(CENTER, BASELINE); - text('BASELINE', 50, 62); - - // Fourth line. - line(0, 97, width, 97); - textAlign(CENTER, BOTTOM); - text('BOTTOM', 50, 97); - - describe('The words "TOP", "CENTER", "BASELINE", and "BOTTOM" each drawn relative to a horizontal line. Their positions demonstrate different vertical alignments.'); - } - -
-class: p5 -overloads: - - line: 11 - params: - - name: horizAlign - description: | -

horizontal alignment, either LEFT, - CENTER, or RIGHT.

- type: Constant - - name: vertAlign - description: | -

vertical alignment, either TOP, - BOTTOM, CENTER, or BASELINE.

- type: Constant - optional: true - chainable: 1 - - line: 98 - params: [] - return: - description: '' - type: Object -chainable: true ---- - - -# textAlign diff --git a/src/content/reference/en/p5 copy/textAscent.mdx b/src/content/reference/en/p5 copy/textAscent.mdx deleted file mode 100644 index b81a657de6..0000000000 --- a/src/content/reference/en/p5 copy/textAscent.mdx +++ /dev/null @@ -1,71 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L337 -title: textAscent -module: Typography -submodule: Attributes -file: src/typography/attributes.js -description: | -

Calculates the ascent of the current font at its current size.

-

The ascent represents the distance, in pixels, of the tallest character - above the baseline.

-line: 337 -isConstructor: false -itemtype: method -example: - - |- - -
- - let font; - - function preload() { - font = loadFont('/assets/inconsolata.otf'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textFont(font); - - // Different for each font. - let fontScale = 0.8; - - let baseY = 75; - strokeWeight(0.5); - - // Draw small text. - textSize(24); - text('dp', 0, baseY); - - // Draw baseline and ascent. - let a = textAscent() * fontScale; - line(0, baseY, 23, baseY); - line(23, baseY - a, 23, baseY); - - // Draw large text. - textSize(48); - text('dp', 45, baseY); - - // Draw baseline and ascent. - a = textAscent() * fontScale; - line(45, baseY, 91, baseY); - line(91, baseY - a, 91, baseY); - - describe('The letters "dp" written twice in different sizes. Each version has a horizontal baseline. A vertical line extends upward from each baseline to the top of the "d".'); - } - -
-class: p5 -return: - description: ascent measured in units of pixels. - type: Number -chainable: false ---- - - -# textAscent diff --git a/src/content/reference/en/p5 copy/textDescent.mdx b/src/content/reference/en/p5 copy/textDescent.mdx deleted file mode 100644 index 15837acff3..0000000000 --- a/src/content/reference/en/p5 copy/textDescent.mdx +++ /dev/null @@ -1,71 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L396 -title: textDescent -module: Typography -submodule: Attributes -file: src/typography/attributes.js -description: | -

Calculates the descent of the current font at its current size.

-

The descent represents the distance, in pixels, of the character with the - longest descender below the baseline.

-line: 396 -isConstructor: false -itemtype: method -example: - - |- - -
- - let font; - - function preload() { - font = loadFont('/assets/inconsolata.otf'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the font. - textFont(font); - - // Different for each font. - let fontScale = 0.9; - - let baseY = 75; - strokeWeight(0.5); - - // Draw small text. - textSize(24); - text('dp', 0, baseY); - - // Draw baseline and descent. - let d = textDescent() * fontScale; - line(0, baseY, 23, baseY); - line(23, baseY, 23, baseY + d); - - // Draw large text. - textSize(48); - text('dp', 45, baseY); - - // Draw baseline and descent. - d = textDescent() * fontScale; - line(45, baseY, 91, baseY); - line(91, baseY, 91, baseY + d); - - describe('The letters "dp" written twice in different sizes. Each version has a horizontal baseline. A vertical line extends downward from each baseline to the bottom of the "p".'); - } - -
-class: p5 -return: - description: descent measured in units of pixels. - type: Number -chainable: false ---- - - -# textDescent diff --git a/src/content/reference/en/p5 copy/textFont.mdx b/src/content/reference/en/p5 copy/textFont.mdx deleted file mode 100644 index e5e9fa8da1..0000000000 --- a/src/content/reference/en/p5 copy/textFont.mdx +++ /dev/null @@ -1,127 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/loading_displaying.js#L335 -title: textFont -module: Typography -submodule: Loading & Displaying -file: src/typography/loading_displaying.js -description: > -

Sets the font used by the text() - function.

- -

The first parameter, font, sets the font. - textFont() recognizes either - - a p5.Font object or a string with the name - of a - - system font. For example, 'Courier New'.

- -

The second parameter, size, is optional. It sets the font size - in pixels. - - This has the same effect as calling textSize().

- -

Note: WEBGL mode only supports fonts loaded with - - loadFont().

-line: 335 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - background(200); - textFont('Courier New'); - textSize(24); - text('hi', 35, 55); - - describe('The text "hi" written in a black, monospace font on a gray background.'); - } - -
- -
- - function setup() { - background('black'); - fill('palegreen'); - textFont('Courier New', 10); - text('You turn to the left and see a door. Do you enter?', 5, 5, 90, 90); - text('>', 5, 70); - - describe('A text prompt from a game is written in a green, monospace font on a black background.'); - } - -
- -
- - function setup() { - background(200); - textFont('Verdana'); - let currentFont = textFont(); - text(currentFont, 25, 50); - - describe('The text "Verdana" written in a black, sans-serif font on a gray background.'); - } - -
- -
- - let fontRegular; - let fontItalic; - let fontBold; - - function preload() { - fontRegular = loadFont('/assets/Regular.otf'); - fontItalic = loadFont('/assets/Italic.ttf'); - fontBold = loadFont('/assets/Bold.ttf'); - } - - function setup() { - background(200); - textFont(fontRegular); - text('I am Normal', 10, 30); - textFont(fontItalic); - text('I am Italic', 10, 50); - textFont(fontBold); - text('I am Bold', 10, 70); - - describe('The statements "I am Normal", "I am Italic", and "I am Bold" written in black on separate lines. The statements have normal, italic, and bold fonts, respectively.'); - } - -
-class: p5 -return: - description: current font or p5 Object. - type: Object -overloads: - - line: 335 - params: [] - return: - description: current font or p5 Object. - type: Object - - line: 418 - params: - - name: font - description: | -

font as a p5.Font object or a string.

- type: Object|String - - name: size - description: | -

font size in pixels.

- type: Number - optional: true - chainable: 1 -chainable: false ---- - - -# textFont diff --git a/src/content/reference/en/p5 copy/textLeading.mdx b/src/content/reference/en/p5 copy/textLeading.mdx deleted file mode 100644 index 3b5a22d9a2..0000000000 --- a/src/content/reference/en/p5 copy/textLeading.mdx +++ /dev/null @@ -1,63 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L107 -title: textLeading -module: Typography -submodule: Attributes -file: src/typography/attributes.js -description: > -

Sets the spacing between lines of text when - - text() is called.

- -

Note: Spacing is measured in pixels.

- -

Calling textLeading() without an argument returns the current - spacing.

-line: 107 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // "\n" starts a new line of text. - let lines = 'one\ntwo'; - - // Left. - text(lines, 10, 25); - - // Right. - textLeading(30); - text(lines, 70, 25); - - describe('The words "one" and "two" written on separate lines twice. The words on the left have less vertical spacing than the words on the right.'); - } - -
-class: p5 -overloads: - - line: 107 - params: - - name: leading - description: | -

spacing between lines of text in units of pixels.

- type: Number - chainable: 1 - - line: 142 - params: [] - return: - description: '' - type: Number -chainable: true ---- - - -# textLeading diff --git a/src/content/reference/en/p5 copy/textOutput.mdx b/src/content/reference/en/p5 copy/textOutput.mdx deleted file mode 100644 index 62ea4cb4b5..0000000000 --- a/src/content/reference/en/p5 copy/textOutput.mdx +++ /dev/null @@ -1,186 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/accessibility/outputs.js#L10 -title: textOutput -module: Environment -submodule: Environment -file: src/accessibility/outputs.js -description: > -

Creates a screen reader-accessible description of shapes on the canvas.

- -

textOutput() adds a general description, list of shapes, and - - table of shapes to the web page. The general description includes the - - canvas size, canvas color, and number of shapes. For example, - - Your output is a, 100 by 100 pixels, gray canvas containing the - following 2 shapes:.

- -

A list of shapes follows the general description. The list describes the - - color, location, and area of each shape. For example, - - a red circle at middle covering 3% of the canvas. Each shape can - be - - selected to get more details.

- -

textOutput() uses its table of shapes as a list. The table - describes the - - shape, color, location, coordinates and area. For example, - - red circle location = middle area = 3%. This is different from - - gridOutput(), which uses its table as - a grid.

- -

The display parameter is optional. It determines how the - description is - - displayed. If LABEL is passed, as in - textOutput(LABEL), the description - - will be visible in a div element next to the canvas. Using LABEL - creates - - unhelpful duplicates for screen readers. Only use LABEL during - - development. If FALLBACK is passed, as in - textOutput(FALLBACK), the - - description will only be visible to screen readers. This is the default - - mode.

- -

Read - - Writing - accessible canvas descriptions - - to learn more about making sketches accessible.

- -

textOutput() generates descriptions in English only. Text - drawn with - - text() is not described. Shapes created with - - beginShape() are not described. WEBGL - mode - - and 3D shapes are not supported.

- -

Use describe() and - - describeElement() for more - control - - over canvas descriptions.

-line: 10 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - // Add the text description. - textOutput(); - - // Draw a couple of shapes. - background(200); - fill(255, 0, 0); - circle(20, 20, 20); - fill(0, 0, 255); - square(50, 50, 50); - - // Add a general description of the canvas. - describe('A red circle and a blue square on a gray background.'); - } - -
- -
- - function setup() { - // Add the text description and - // display it for debugging. - textOutput(LABEL); - - // Draw a couple of shapes. - background(200); - fill(255, 0, 0); - circle(20, 20, 20); - fill(0, 0, 255); - square(50, 50, 50); - - // Add a general description of the canvas. - describe('A red circle and a blue square on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - } - - function draw() { - // Add the text description. - textOutput(); - - // Draw a moving circle. - background(200); - let x = frameCount * 0.1; - fill(255, 0, 0); - circle(x, 20, 20); - fill(0, 0, 255); - square(50, 50, 50); - - // Add a general description of the canvas. - describe('A red circle moves from left to right above a blue square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - } - - function draw() { - // Add the text description and - // display it for debugging. - textOutput(LABEL); - - // Draw a moving circle. - background(200); - let x = frameCount * 0.1; - fill(255, 0, 0); - circle(x, 20, 20); - fill(0, 0, 255); - square(50, 50, 50); - - // Add a general description of the canvas. - describe('A red circle moves from left to right above a blue square.'); - } - -
-class: p5 -params: - - name: display - description: | -

either FALLBACK or LABEL.

- type: Constant - optional: true -chainable: false ---- - - -# textOutput diff --git a/src/content/reference/en/p5 copy/textSize.mdx b/src/content/reference/en/p5 copy/textSize.mdx deleted file mode 100644 index df77510315..0000000000 --- a/src/content/reference/en/p5 copy/textSize.mdx +++ /dev/null @@ -1,65 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L151 -title: textSize -module: Typography -submodule: Attributes -file: src/typography/attributes.js -description: > -

Sets the font size when - - text() is called.

- -

Note: Font size is measured in pixels.

- -

Calling textSize() without an argument returns the current - size.

-line: 151 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Top. - textSize(12); - text('Font Size 12', 10, 30); - - // Middle. - textSize(14); - text('Font Size 14', 10, 60); - - // Bottom. - textSize(16); - text('Font Size 16', 10, 90); - - describe('The text "Font Size 12" drawn small, "Font Size 14" drawn medium, and "Font Size 16" drawn large.'); - } - -
-class: p5 -overloads: - - line: 151 - params: - - name: size - description: | -

size of the letters in units of pixels.

- type: Number - chainable: 1 - - line: 188 - params: [] - return: - description: '' - type: Number -chainable: true ---- - - -# textSize diff --git a/src/content/reference/en/p5 copy/textStyle.mdx b/src/content/reference/en/p5 copy/textStyle.mdx deleted file mode 100644 index 572ca0454c..0000000000 --- a/src/content/reference/en/p5 copy/textStyle.mdx +++ /dev/null @@ -1,79 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L197 -title: textStyle -module: Typography -submodule: Attributes -file: src/typography/attributes.js -description: > -

Sets the style for system fonts when - - text() is called.

- -

The parameter, style, can be either NORMAL, - ITALIC, BOLD, or - - BOLDITALIC.

- -

textStyle() may be overridden by CSS styling. This function - doesn't - - affect fonts loaded with loadFont().

-line: 197 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textSize(12); - textAlign(CENTER); - - // First row. - textStyle(NORMAL); - text('Normal', 50, 15); - - // Second row. - textStyle(ITALIC); - text('Italic', 50, 40); - - // Third row. - textStyle(BOLD); - text('Bold', 50, 65); - - // Fourth row. - textStyle(BOLDITALIC); - text('Bold Italic', 50, 90); - - describe('The words "Normal" displayed normally, "Italic" in italic, "Bold" in bold, and "Bold Italic" in bold italics.'); - } - -
-class: p5 -overloads: - - line: 197 - params: - - name: style - description: | -

styling for text, either NORMAL, - ITALIC, BOLD or BOLDITALIC.

- type: Constant - chainable: 1 - - line: 244 - params: [] - return: - description: '' - type: String -chainable: true ---- - - -# textStyle diff --git a/src/content/reference/en/p5 copy/textWidth.mdx b/src/content/reference/en/p5 copy/textWidth.mdx deleted file mode 100644 index 00721b0fee..0000000000 --- a/src/content/reference/en/p5 copy/textWidth.mdx +++ /dev/null @@ -1,83 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L253 -title: textWidth -module: Typography -submodule: Attributes -file: src/typography/attributes.js -description: | -

Calculates the maximum width of a string of text drawn when - text() is called.

-line: 253 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textSize(28); - strokeWeight(0.5); - - // Calculate the text width. - let s = 'yoyo'; - let w = textWidth(s); - - // Display the text. - text(s, 22, 55); - - // Underline the text. - line(22, 55, 22 + w, 55); - - describe('The word "yoyo" underlined.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textSize(28); - strokeWeight(0.5); - - // Calculate the text width. - // "\n" starts a new line. - let s = 'yo\nyo'; - let w = textWidth(s); - - // Display the text. - text(s, 22, 55); - - // Underline the text. - line(22, 55, 22 + w, 55); - - describe('The word "yo" written twice, one copy beneath the other. The words are divided by a horizontal line.'); - } - -
-class: p5 -params: - - name: str - description: | -

string of text to measure.

- type: String -return: - description: width measured in units of pixels. - type: Number -chainable: false ---- - - -# textWidth diff --git a/src/content/reference/en/p5 copy/textWrap.mdx b/src/content/reference/en/p5 copy/textWrap.mdx deleted file mode 100644 index 0ba2b556a7..0000000000 --- a/src/content/reference/en/p5 copy/textWrap.mdx +++ /dev/null @@ -1,111 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L462 -title: textWrap -module: Typography -submodule: Attributes -file: src/typography/attributes.js -description: > -

Sets the style for wrapping text when - - text() is called.

- -

The parameter, style, can be one of the following values:

- -

WORD starts new lines of text at spaces. If a string of text - doesn't - - have spaces, it may overflow the text box and the canvas. This is the - - default style.

- -

CHAR starts new lines as needed to stay within the text - box.

- -

textWrap() only works when the maximum width is set for a text - box. For - - example, calling text('Have a wonderful day', 0, 10, 100) sets - the - - maximum width to 100 pixels.

- -

Calling textWrap() without an argument returns the current - style.

-line: 462 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textSize(20); - textWrap(WORD); - - // Display the text. - text('Have a wonderful day', 0, 10, 100); - - describe('The text "Have a wonderful day" written across three lines.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textSize(20); - textWrap(CHAR); - - // Display the text. - text('Have a wonderful day', 0, 10, 100); - - describe('The text "Have a wonderful day" written across two lines.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textSize(20); - textWrap(CHAR); - - // Display the text. - text('祝你有美好的一天', 0, 10, 100); - - describe('The text "祝你有美好的一天" written across two lines.'); - } - -
-class: p5 -params: - - name: style - description: | -

text wrapping style, either WORD or CHAR.

- type: Constant -return: - description: style - type: String -chainable: false ---- - - -# textWrap diff --git a/src/content/reference/en/p5 copy/texture.mdx b/src/content/reference/en/p5 copy/texture.mdx deleted file mode 100644 index 7258f53ace..0000000000 --- a/src/content/reference/en/p5 copy/texture.mdx +++ /dev/null @@ -1,207 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1716 -title: texture -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Sets the texture that will be used on shapes.

- -

A texture is like a skin that wraps around a shape. texture() - works with - - built-in shapes, such as square() and - - sphere(), and custom shapes created with - - functions such as buildGeometry(). - To - - texture a geometry created with beginShape(), - - uv coordinates must be passed to each - - vertex() call.

- -

The parameter, tex, is the texture to apply. - texture() can use a range - - of sources including images, videos, and offscreen renderers such as - - p5.Graphics and - - p5.Framebuffer objects.

- -

To texture a geometry created with beginShape(), - - you will need to specify uv coordinates in vertex().

- -

Note: texture() can only be used in WebGL mode.

-line: 1716 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load an image and create a p5.Image object. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A spinning cube with an image of a ceiling on each face.'); - } - - function draw() { - background(0); - - // Rotate around the x-, y-, and z-axes. - rotateZ(frameCount * 0.01); - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - - // Apply the image as a texture. - texture(img); - - // Draw the box. - box(50); - } - -
- -
- - let pg; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Graphics object. - pg = createGraphics(100, 100); - - // Draw a circle to the p5.Graphics object. - pg.background(200); - pg.circle(50, 50, 30); - - describe('A spinning cube with circle at the center of each face.'); - } - - function draw() { - background(0); - - // Rotate around the x-, y-, and z-axes. - rotateZ(frameCount * 0.01); - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - - // Apply the p5.Graphics object as a texture. - texture(pg); - - // Draw the box. - box(50); - } - -
- -
- - let vid; - - // Load a video and create a p5.MediaElement object. - function preload() { - vid = createVideo('/assets/fingers.mov'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - // Hide the video. - vid.hide(); - - // Set the video to loop. - vid.loop(); - - describe('A rectangle with video as texture'); - } - - function draw() { - background(0); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Apply the video as a texture. - texture(vid); - - // Draw the rectangle. - rect(-40, -40, 80, 80); - } - -
- -
- - let vid; - - // Load a video and create a p5.MediaElement object. - function preload() { - vid = createVideo('/assets/fingers.mov'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - // Hide the video. - vid.hide(); - - // Set the video to loop. - vid.loop(); - - describe('A rectangle with video as texture'); - } - - function draw() { - background(0); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Set the texture mode. - textureMode(NORMAL); - - // Apply the video as a texture. - texture(vid); - - // Draw a custom shape using uv coordinates. - beginShape(); - vertex(-40, -40, 0, 0); - vertex(40, -40, 1, 0); - vertex(40, 40, 1, 1); - vertex(-40, 40, 0, 1); - endShape(); - } - -
-class: p5 -params: - - name: tex - description: | -

media to use as the texture.

- type: >- - p5.Image|p5.MediaElement|p5.Graphics|p5.Texture|p5.Framebuffer|p5.FramebufferTexture -chainable: true ---- - - -# texture diff --git a/src/content/reference/en/p5 copy/textureMode.mdx b/src/content/reference/en/p5 copy/textureMode.mdx deleted file mode 100644 index 397d1856b9..0000000000 --- a/src/content/reference/en/p5 copy/textureMode.mdx +++ /dev/null @@ -1,254 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1903 -title: textureMode -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Changes the coordinate system used for textures when they’re applied to - - custom shapes.

- -

In order for texture() to work, a - shape needs a - - way to map the points on its surface to the pixels in an image. Built-in - - shapes such as rect() and - - box() already have these texture mappings - based on - - their vertices. Custom shapes created with - - vertex() require texture mappings to be - passed as - - uv coordinates.

- -

Each call to vertex() must include 5 - arguments, - - as in vertex(x, y, z, u, v), to map the vertex at coordinates - (x, y, z) - - to the pixel at coordinates (u, v) within an image. For example, - the - - corners of a rectangular image are mapped to the corners of a rectangle by - default:

- -
// Apply the image as a texture.
-
-  texture(img);
-
-
-  // Draw the rectangle.
-
-  rect(0, 0, 30, 50);
-
-  
- -

If the image in the code snippet above has dimensions of 300 x 500 pixels, - - the same result could be achieved as follows:

- -
// Apply the image as a texture.
-
-  texture(img);
-
-
-  // Draw the rectangle.
-
-  beginShape();
-
-
-  // Top-left.
-
-  // u: 0, v: 0
-
-  vertex(0, 0, 0, 0, 0);
-
-
-  // Top-right.
-
-  // u: 300, v: 0
-
-  vertex(30, 0, 0, 300, 0);
-
-
-  // Bottom-right.
-
-  // u: 300, v: 500
-
-  vertex(30, 50, 0, 300, 500);
-
-
-  // Bottom-left.
-
-  // u: 0, v: 500
-
-  vertex(0, 50, 0, 0, 500);
-
-
-  endShape();
-
-  
- -

textureMode() changes the coordinate system for uv - coordinates.

- -

The parameter, mode, accepts two possible constants. If - NORMAL is - - passed, as in textureMode(NORMAL), then the texture’s uv - coordinates can - - be provided in the range 0 to 1 instead of the image’s dimensions. This can - - be helpful for using the same code for multiple images of different sizes. - - For example, the code snippet above could be rewritten as follows:

- -
// Set the texture mode to use normalized
-  coordinates.
-
-  textureMode(NORMAL);
-
-
-  // Apply the image as a texture.
-
-  texture(img);
-
-
-  // Draw the rectangle.
-
-  beginShape();
-
-
-  // Top-left.
-
-  // u: 0, v: 0
-
-  vertex(0, 0, 0, 0, 0);
-
-
-  // Top-right.
-
-  // u: 1, v: 0
-
-  vertex(30, 0, 0, 1, 0);
-
-
-  // Bottom-right.
-
-  // u: 1, v: 1
-
-  vertex(30, 50, 0, 1, 1);
-
-
-  // Bottom-left.
-
-  // u: 0, v: 1
-
-  vertex(0, 50, 0, 0, 1);
-
-
-  endShape();
-
-  
- -

By default, mode is IMAGE, which scales uv - coordinates to the - - dimensions of the image. Calling textureMode(IMAGE) applies the - default.

- -

Note: textureMode() can only be used in WebGL mode.

-line: 1903 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load an image and create a p5.Image object. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('An image of a ceiling against a black background.'); - } - - function draw() { - background(0); - - // Apply the image as a texture. - texture(img); - - // Draw the custom shape. - // Use the image's width and height as uv coordinates. - beginShape(); - vertex(-30, -30, 0, 0); - vertex(30, -30, img.width, 0); - vertex(30, 30, img.width, img.height); - vertex(-30, 30, 0, img.height); - endShape(); - } - -
- -
- - let img; - - // Load an image and create a p5.Image object. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('An image of a ceiling against a black background.'); - } - - function draw() { - background(0); - - // Set the texture mode. - textureMode(NORMAL); - - // Apply the image as a texture. - texture(img); - - // Draw the custom shape. - // Use normalized uv coordinates. - beginShape(); - vertex(-30, -30, 0, 0); - vertex(30, -30, 1, 0); - vertex(30, 30, 1, 1); - vertex(-30, 30, 0, 1); - endShape(); - } - -
-class: p5 -params: - - name: mode - description: | -

either IMAGE or NORMAL.

- type: Constant -chainable: false ---- - - -# textureMode diff --git a/src/content/reference/en/p5 copy/textureWrap.mdx b/src/content/reference/en/p5 copy/textureWrap.mdx deleted file mode 100644 index 6734a5325b..0000000000 --- a/src/content/reference/en/p5 copy/textureWrap.mdx +++ /dev/null @@ -1,370 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2082 -title: textureWrap -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Changes the way textures behave when a shape’s uv coordinates go beyond the - - texture.

- -

In order for texture() to work, a - shape needs a - - way to map the points on its surface to the pixels in an image. Built-in - - shapes such as rect() and - - box() already have these texture mappings - based on - - their vertices. Custom shapes created with - - vertex() require texture mappings to be - passed as - - uv coordinates.

- -

Each call to vertex() must include 5 - arguments, - - as in vertex(x, y, z, u, v), to map the vertex at coordinates - (x, y, z) - - to the pixel at coordinates (u, v) within an image. For example, - the - - corners of a rectangular image are mapped to the corners of a rectangle by - default:

- -
// Apply the image as a texture.
-
-  texture(img);
-
-
-  // Draw the rectangle.
-
-  rect(0, 0, 30, 50);
-
-  
- -

If the image in the code snippet above has dimensions of 300 x 500 pixels, - - the same result could be achieved as follows:

- -
// Apply the image as a texture.
-
-  texture(img);
-
-
-  // Draw the rectangle.
-
-  beginShape();
-
-
-  // Top-left.
-
-  // u: 0, v: 0
-
-  vertex(0, 0, 0, 0, 0);
-
-
-  // Top-right.
-
-  // u: 300, v: 0
-
-  vertex(30, 0, 0, 300, 0);
-
-
-  // Bottom-right.
-
-  // u: 300, v: 500
-
-  vertex(30, 50, 0, 300, 500);
-
-
-  // Bottom-left.
-
-  // u: 0, v: 500
-
-  vertex(0, 50, 0, 0, 500);
-
-
-  endShape();
-
-  
- -

textureWrap() controls how textures behave when their uv's go - beyond the - - texture. Doing so can produce interesting visual effects such as tiling. - - For example, the custom shape above could have u-coordinates are greater - - than the image’s width:

- -
// Apply the image as a texture.
-
-  texture(img);
-
-
-  // Draw the rectangle.
-
-  beginShape();
-
-  vertex(0, 0, 0, 0, 0);
-
-
-  // Top-right.
-
-  // u: 600
-
-  vertex(30, 0, 0, 600, 0);
-
-
-  // Bottom-right.
-
-  // u: 600
-
-  vertex(30, 50, 0, 600, 500);
-
-
-  vertex(0, 50, 0, 0, 500);
-
-  endShape();
-
-  
- -

The u-coordinates of 600 are greater than the texture image’s width of 300. - - This creates interesting possibilities.

- -

The first parameter, wrapX, accepts three possible constants. - If CLAMP - - is passed, as in textureWrap(CLAMP), the pixels at the edge of - the - - texture will extend to the shape’s edges. If REPEAT is passed, as - in - - textureWrap(REPEAT), the texture will tile repeatedly until - reaching the - - shape’s edges. If MIRROR is passed, as in - textureWrap(MIRROR), the - - texture will tile repeatedly until reaching the shape’s edges, flipping - - its orientation between tiles. By default, textures CLAMP.

- -

The second parameter, wrapY, is optional. It accepts the same - three - - constants, CLAMP, REPEAT, and MIRROR. - If one of these constants is - - passed, as in textureWRAP(MIRROR, REPEAT), then the texture will - MIRROR - - horizontally and REPEAT vertically. By default, - wrapY will be set to - - the same value as wrapX.

- -

Note: textureWrap() can only be used in WebGL mode.

-line: 2082 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - function preload() { - img = loadImage('/assets/rockies128.jpg'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'An image of a landscape occupies the top-left corner of a square. Its edge colors smear to cover the other thre quarters of the square.' - ); - } - - function draw() { - background(0); - - // Set the texture mode. - textureMode(NORMAL); - - // Set the texture wrapping. - // Note: CLAMP is the default mode. - textureWrap(CLAMP); - - // Apply the image as a texture. - texture(img); - - // Style the shape. - noStroke(); - - // Draw the shape. - // Use uv coordinates > 1. - beginShape(); - vertex(-30, -30, 0, 0, 0); - vertex(30, -30, 0, 2, 0); - vertex(30, 30, 0, 2, 2); - vertex(-30, 30, 0, 0, 2); - endShape(); - } - -
- -
- - let img; - - function preload() { - img = loadImage('/assets/rockies128.jpg'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('Four identical images of a landscape arranged in a grid.'); - } - - function draw() { - background(0); - - // Set the texture mode. - textureMode(NORMAL); - - // Set the texture wrapping. - textureWrap(REPEAT); - - // Apply the image as a texture. - texture(img); - - // Style the shape. - noStroke(); - - // Draw the shape. - // Use uv coordinates > 1. - beginShape(); - vertex(-30, -30, 0, 0, 0); - vertex(30, -30, 0, 2, 0); - vertex(30, 30, 0, 2, 2); - vertex(-30, 30, 0, 0, 2); - endShape(); - } - -
- -
- - let img; - - function preload() { - img = loadImage('/assets/rockies128.jpg'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'Four identical images of a landscape arranged in a grid. The images are reflected horizontally and vertically, creating a kaleidoscope effect.' - ); - } - - function draw() { - background(0); - - // Set the texture mode. - textureMode(NORMAL); - - // Set the texture wrapping. - textureWrap(MIRROR); - - // Apply the image as a texture. - texture(img); - - // Style the shape. - noStroke(); - - // Draw the shape. - // Use uv coordinates > 1. - beginShape(); - vertex(-30, -30, 0, 0, 0); - vertex(30, -30, 0, 2, 0); - vertex(30, 30, 0, 2, 2); - vertex(-30, 30, 0, 0, 2); - endShape(); - } - -
- -
- - let img; - - function preload() { - img = loadImage('/assets/rockies128.jpg'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'Four identical images of a landscape arranged in a grid. The top row and bottom row are reflections of each other.' - ); - } - - function draw() { - background(0); - - // Set the texture mode. - textureMode(NORMAL); - - // Set the texture wrapping. - textureWrap(REPEAT, MIRROR); - - // Apply the image as a texture. - texture(img); - - // Style the shape. - noStroke(); - - // Draw the shape. - // Use uv coordinates > 1. - beginShape(); - vertex(-30, -30, 0, 0, 0); - vertex(30, -30, 0, 2, 0); - vertex(30, 30, 0, 2, 2); - vertex(-30, 30, 0, 0, 2); - endShape(); - } - -
-class: p5 -params: - - name: wrapX - description: | -

either CLAMP, REPEAT, or MIRROR

- type: Constant - - name: wrapY - description: | -

either CLAMP, REPEAT, or MIRROR

- type: Constant - optional: true -chainable: false ---- - - -# textureWrap diff --git a/src/content/reference/en/p5 copy/tint.mdx b/src/content/reference/en/p5 copy/tint.mdx deleted file mode 100644 index e99dee4431..0000000000 --- a/src/content/reference/en/p5 copy/tint.mdx +++ /dev/null @@ -1,201 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L1192 -title: tint -module: Image -submodule: Loading & Displaying -file: src/image/loading_displaying.js -description: > -

Tints images using a color.

- -

The version of tint() with one parameter interprets it one of - four ways. - - If the parameter is a number, it's interpreted as a grayscale value. If the - - parameter is a string, it's interpreted as a CSS color string. An array of - - [R, G, B, A] values or a p5.Color object can - - also be used to set the tint color.

- -

The version of tint() with two parameters uses the first one - as a - - grayscale value and the second as an alpha value. For example, calling - - tint(255, 128) will make an image 50% transparent.

- -

The version of tint() with three parameters interprets them as - RGB or - - HSB values, depending on the current - - colorMode(). The optional fourth - parameter - - sets the alpha value. For example, tint(255, 0, 0, 100) will give - images - - a red tint and make them transparent.

-line: 1192 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Left image. - image(img, 0, 0); - - // Right image. - // Tint with a CSS color string. - tint('red'); - image(img, 50, 0); - - describe('Two images of an umbrella and a ceiling side-by-side. The image on the right has a red tint.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Left image. - image(img, 0, 0); - - // Right image. - // Tint with RGB values. - tint(255, 0, 0); - image(img, 50, 0); - - describe('Two images of an umbrella and a ceiling side-by-side. The image on the right has a red tint.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Left. - image(img, 0, 0); - - // Right. - // Tint with RGBA values. - tint(255, 0, 0, 100); - image(img, 50, 0); - - describe('Two images of an umbrella and a ceiling side-by-side. The image on the right has a transparent red tint.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Left. - image(img, 0, 0); - - // Right. - // Tint with grayscale and alpha values. - tint(255, 180); - image(img, 50, 0); - - describe('Two images of an umbrella and a ceiling side-by-side. The image on the right is transparent.'); - } - -
-class: p5 -overloads: - - line: 1192 - params: - - name: v1 - description: | -

red or hue value.

- type: Number - - name: v2 - description: | -

green or saturation value.

- type: Number - - name: v3 - description: | -

blue or brightness.

- type: Number - - name: alpha - description: '' - type: Number - optional: true - - line: 1318 - params: - - name: value - description: | -

CSS color string.

- type: String - - line: 1323 - params: - - name: gray - description: | -

grayscale value.

- type: Number - - name: alpha - description: '' - type: Number - optional: true - - line: 1329 - params: - - name: values - description: | -

array containing the red, green, blue & - alpha components of the color.

- type: 'Number[]' - - line: 1335 - params: - - name: color - description: | -

the tint color

- type: p5.Color -chainable: false ---- - - -# tint diff --git a/src/content/reference/en/p5 copy/torus.mdx b/src/content/reference/en/p5 copy/torus.mdx deleted file mode 100644 index f0e2740d59..0000000000 --- a/src/content/reference/en/p5 copy/torus.mdx +++ /dev/null @@ -1,200 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L2183 -title: torus -module: Shape -submodule: 3D Primitives -file: src/webgl/3d_primitives.js -description: > -

Draws a torus.

- -

A torus is a 3D shape with triangular faces that connect to form a ring. - - Toruses with few faces look flattened. Toruses with many faces have smooth - - surfaces.

- -

The first parameter, radius, is optional. If a - Number is passed, as in - - torus(30), it sets the radius of the ring. By default, - radius is 50.

- -

The second parameter, tubeRadius, is also optional. If a - Number is - - passed, as in torus(30, 15), it sets the radius of the tube. By - default, - - tubeRadius is 10.

- -

The third parameter, detailX, is also optional. If a - Number is passed, - - as in torus(30, 15, 5), it sets the number of edges used to draw - the hole - - of the torus. Using more edges makes the hole look more like a circle. By - - default, detailX is 24.

- -

The fourth parameter, detailY, is also optional. If a - Number is passed, - - as in torus(30, 15, 5, 7), it sets the number of triangle - subdivisions to - - use while filling in the torus’ height. By default, detailY is - 16.

- -

Note: torus() can only be used in WebGL mode.

-line: 2183 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white torus on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the torus. - torus(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white torus on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the torus. - // Set its radius to 30. - torus(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white torus on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the torus. - // Set its radius to 30 and tubeRadius to 15. - torus(30, 15); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white torus on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the torus. - // Set its radius to 30 and tubeRadius to 15. - // Set its detailX to 5. - torus(30, 15, 5); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white torus on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the torus. - // Set its radius to 30 and tubeRadius to 15. - // Set its detailX to 5. - // Set its detailY to 3. - torus(30, 15, 5, 3); - } - -
-class: p5 -params: - - name: radius - description: | -

radius of the torus. Defaults to 50.

- type: Number - optional: true - - name: tubeRadius - description: | -

radius of the tube. Defaults to 10.

- type: Number - optional: true - - name: detailX - description: | -

number of edges that form the hole. Defaults to 24.

- type: Integer - optional: true - - name: detailY - description: | -

number of triangle subdivisions along the y-axis. Defaults to 16.

- type: Integer - optional: true -chainable: true ---- - - -# torus diff --git a/src/content/reference/en/p5 copy/touchEnded.mdx b/src/content/reference/en/p5 copy/touchEnded.mdx deleted file mode 100644 index aebb308dc1..0000000000 --- a/src/content/reference/en/p5 copy/touchEnded.mdx +++ /dev/null @@ -1,196 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/touch.js#L468 -title: touchEnded -module: Events -submodule: Touch -file: src/events/touch.js -description: > -

A function that's called once each time a screen touch ends.

- -

Declaring the function touchEnded() sets a code block to run - - automatically when the user stops touching a touchscreen device:

- -
function touchEnded() {
-    // Code to run.
-  }
-
-  
- -

The touches array will be updated with - the most - - recent touch points when touchEnded() is called by p5.js:

- -
function touchEnded() {
-    // Paint over the background.
-    background(200);
-
-    // Mark each remaining touch point when the user stops
-    // a touch.
-    for (let touch of touches) {
-      circle(touch.x, touch.y, 40);
-    }
-  }
-
-  
- -

The parameter, event, is optional. touchEnded() will be passed - a - - TouchEvent - - object with properties that describe the touch event:

- -
function touchEnded(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

On touchscreen devices, mouseReleased() will - - run when the user’s touch ends if touchEnded() isn’t declared. If - - touchEnded() is declared, then touchEnded() will run - when a user’s - - touch ends and mouseReleased() - won’t.

- -

Note: touchStarted(), - - touchEnded(), and touchMoved() are all - - related. touchStarted() runs as soon - as the - - user touches a touchscreen device. touchEnded() runs as soon as - the user - - ends a touch. touchMoved() runs - repeatedly as - - the user moves any touch points.

-line: 468 -isConstructor: false -itemtype: method -example: - - |- - -
- - // On a touchscreen device, touch the canvas using one or more fingers - // at the same time. - - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square switches color between black and white each time the user stops touching the screen.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Toggle colors when a touch ends. - function touchEnded() { - if (value === 0) { - value = 255; - } else { - value = 0; - } - } - -
- -
- - // On a touchscreen device, touch the canvas using one or more fingers - // at the same time. - - let bgColor = 50; - let fillColor = 255; - let borderWidth = 0.5; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with the number 0 at the top-center. The number tracks the number of places the user is touching the screen. Circles appear at each touch point and change style in response to events.' - ); - } - - function draw() { - background(bgColor); - - // Style the text. - textAlign(CENTER); - textSize(16); - fill(0); - noStroke(); - - // Display the number of touch points. - text(touches.length, 50, 20); - - // Style the touch points. - fill(fillColor); - stroke(0); - strokeWeight(borderWidth); - - // Display the touch points as circles. - for (let touch of touches) { - circle(touch.x, touch.y, 40); - } - } - - // Set the background color to a random grayscale value. - function touchStarted() { - bgColor = random(80, 255); - } - - // Set the fill color to a random grayscale value. - function touchEnded() { - fillColor = random(0, 255); - } - - // Set the stroke weight. - function touchMoved() { - // Increment the border width. - borderWidth += 0.1; - - // Reset the border width once it's too thick. - if (borderWidth > 20) { - borderWidth = 0.5; - } - } - -
-class: p5 -params: - - name: event - description: | -

optional TouchEvent argument.

- type: TouchEvent - optional: true -chainable: false ---- - - -# touchEnded diff --git a/src/content/reference/en/p5 copy/touchMoved.mdx b/src/content/reference/en/p5 copy/touchMoved.mdx deleted file mode 100644 index 80c23b81f8..0000000000 --- a/src/content/reference/en/p5 copy/touchMoved.mdx +++ /dev/null @@ -1,198 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/touch.js#L295 -title: touchMoved -module: Events -submodule: Touch -file: src/events/touch.js -description: > -

A function that's called when the user touches the screen and moves.

- -

Declaring the function touchMoved() sets a code block to run - - automatically when the user touches a touchscreen device and moves:

- -
function touchMoved() {
-    // Code to run.
-  }
-
-  
- -

The touches array will be updated with - the most - - recent touch points when touchMoved() is called by p5.js:

- -
function touchMoved() {
-    // Paint over the background.
-    background(200);
-
-    // Mark each touch point while the user moves.
-    for (let touch of touches) {
-      circle(touch.x, touch.y, 40);
-    }
-  }
-
-  
- -

The parameter, event, is optional. touchMoved() will be passed - a - - TouchEvent - - object with properties that describe the touch event:

- -
function touchMoved(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

On touchscreen devices, mouseDragged() will - - run when the user’s touch points move if touchMoved() isn’t - declared. If - - touchMoved() is declared, then touchMoved() will run - when a user’s - - touch points move and mouseDragged() - won’t.

- -

Note: touchStarted(), - - touchEnded(), and - - touchMoved() are all related. - - touchStarted() runs as soon as the - user - - touches a touchscreen device. touchEnded() - - runs as soon as the user ends a touch. touchMoved() runs - repeatedly as - - the user moves any touch points.

-line: 295 -isConstructor: false -itemtype: method -example: - - |- - -
- - // On a touchscreen device, touch the canvas using one or more fingers - // at the same time. - - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square becomes lighter when the user touches the screen and moves.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - function touchMoved() { - // Update the grayscale value. - value += 5; - - // Reset the grayscale value. - if (value > 255) { - value = 0; - } - } - -
- -
- - // On a touchscreen device, touch the canvas using one or more fingers - // at the same time. - - let bgColor = 50; - let fillColor = 255; - let borderWidth = 0.5; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with the number 0 at the top-center. The number tracks the number of places the user is touching the screen. Circles appear at each touch point and change style in response to events.' - ); - } - - function draw() { - background(bgColor); - - // Style the text. - textAlign(CENTER); - textSize(16); - fill(0); - noStroke(); - - // Display the number of touch points. - text(touches.length, 50, 20); - - // Style the touch points. - fill(fillColor); - stroke(0); - strokeWeight(borderWidth); - - // Display the touch points as circles. - for (let touch of touches) { - circle(touch.x, touch.y, 40); - } - } - - // Set the background color to a random grayscale value. - function touchStarted() { - bgColor = random(80, 255); - } - - // Set the fill color to a random grayscale value. - function touchEnded() { - fillColor = random(0, 255); - } - - // Set the stroke weight. - function touchMoved() { - // Increment the border width. - borderWidth += 0.1; - - // Reset the border width once it's too thick. - if (borderWidth > 20) { - borderWidth = 0.5; - } - } - -
-class: p5 -params: - - name: event - description: | -

optional TouchEvent argument.

- type: TouchEvent - optional: true -chainable: false ---- - - -# touchMoved diff --git a/src/content/reference/en/p5 copy/touchStarted.mdx b/src/content/reference/en/p5 copy/touchStarted.mdx deleted file mode 100644 index fc33b1f1c5..0000000000 --- a/src/content/reference/en/p5 copy/touchStarted.mdx +++ /dev/null @@ -1,197 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/touch.js#L125 -title: touchStarted -module: Events -submodule: Touch -file: src/events/touch.js -description: > -

A function that's called once each time the user touches the screen.

- -

Declaring a function called touchStarted() sets a code block - to run - - automatically each time the user begins touching a touchscreen device:

- -
function touchStarted() {
-    // Code to run.
-  }
-
-  
- -

The touches array will be updated with - the most - - recent touch points when touchStarted() is called by p5.js:

- -
function touchStarted() {
-    // Paint over the background.
-    background(200);
-
-    // Mark each touch point once with a circle.
-    for (let touch of touches) {
-      circle(touch.x, touch.y, 40);
-    }
-  }
-
-  
- -

The parameter, event, is optional. touchStarted() will be - passed a - - TouchEvent - - object with properties that describe the touch event:

- -
function touchStarted(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

On touchscreen devices, mousePressed() will - - run when a user’s touch starts if touchStarted() isn’t declared. - If - - touchStarted() is declared, then touchStarted() will - run when a user’s - - touch starts and mousePressed() - won’t.

- -

Note: touchStarted(), touchEnded(), and - - touchMoved() are all related. - - touchStarted() runs as soon as the user touches a touchscreen - device. - - touchEnded() runs as soon as the user - ends a - - touch. touchMoved() runs repeatedly as - the - - user moves any touch points.

-line: 125 -isConstructor: false -itemtype: method -example: - - |- - -
- - // On a touchscreen device, touch the canvas using one or more fingers - // at the same time. - - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square switches color between black and white each time the user touches the screen.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Toggle colors with each touch. - function touchStarted() { - if (value === 0) { - value = 255; - } else { - value = 0; - } - } - -
- -
- - // On a touchscreen device, touch the canvas using one or more fingers - // at the same time. - - let bgColor = 50; - let fillColor = 255; - let borderWidth = 0.5; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with the number 0 at the top-center. The number tracks the number of places the user is touching the screen. Circles appear at each touch point and change style in response to events.' - ); - } - - function draw() { - background(bgColor); - - // Style the text. - textAlign(CENTER); - textSize(16); - fill(0); - noStroke(); - - // Display the number of touch points. - text(touches.length, 50, 20); - - // Style the touch points. - fill(fillColor); - stroke(0); - strokeWeight(borderWidth); - - // Display the touch points as circles. - for (let touch of touches) { - circle(touch.x, touch.y, 40); - } - } - - // Set the background color to a random grayscale value. - function touchStarted() { - bgColor = random(80, 255); - } - - // Set the fill color to a random grayscale value. - function touchEnded() { - fillColor = random(0, 255); - } - - // Set the stroke weight. - function touchMoved() { - // Increment the border width. - borderWidth += 0.1; - - // Reset the border width once it's too thick. - if (borderWidth > 20) { - borderWidth = 0.5; - } - } - -
-class: p5 -params: - - name: event - description: | -

optional TouchEvent argument.

- type: TouchEvent - optional: true -chainable: false ---- - - -# touchStarted diff --git a/src/content/reference/en/p5 copy/touches.mdx b/src/content/reference/en/p5 copy/touches.mdx deleted file mode 100644 index 7ad03e1610..0000000000 --- a/src/content/reference/en/p5 copy/touches.mdx +++ /dev/null @@ -1,102 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/touch.js#L10 -title: touches -module: Events -submodule: Touch -file: src/events/touch.js -description: > -

An Array of all the current touch points on a touchscreen - device.

- -

The touches array is empty by default. When the user touches - their - - screen, a new touch point is tracked and added to the array. Touch points - - are Objects with the following properties:

- -
// Iterate over the touches array.
-
-  for (let touch of touches) {
-    // x-coordinate relative to the top-left
-    // corner of the canvas.
-    console.log(touch.x);
-
-    // y-coordinate relative to the top-left
-    // corner of the canvas.
-    console.log(touch.y);
-
-    // x-coordinate relative to the top-left
-    // corner of the browser.
-    console.log(touch.winX);
-
-    // y-coordinate relative to the top-left
-    // corner of the browser.
-    console.log(touch.winY);
-
-    // ID number
-    console.log(touch.id);
-  }
-
-  
-line: 10 -isConstructor: false -itemtype: property -example: - - |- - -
- - // On a touchscreen device, touch the canvas using one or more fingers - // at the same time. - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square. White circles appear where the user touches the square.' - ); - } - - function draw() { - background(200); - - // Draw a circle at each touch point. - for (let touch of touches) { - circle(touch.x, touch.y, 40); - } - } - -
- -
- - // On a touchscreen device, touch the canvas using one or more fingers - // at the same time. - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square. Labels appear where the user touches the square, displaying the coordinates.' - ); - } - - function draw() { - background(200); - - // Draw a label above each touch point. - for (let touch of touches) { - text(`${touch.x}, ${touch.y}`, touch.x, touch.y - 40); - } - } - -
-class: p5 -type: 'Object[]' ---- - - -# touches diff --git a/src/content/reference/en/p5 copy/translate.mdx b/src/content/reference/en/p5 copy/translate.mdx deleted file mode 100644 index dd725eb199..0000000000 --- a/src/content/reference/en/p5 copy/translate.mdx +++ /dev/null @@ -1,241 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L1223 -title: translate -module: Transform -submodule: Transform -file: src/core/transform.js -description: > -

Translates the coordinate system.

- -

By default, the origin (0, 0) is at the sketch's top-left - corner in 2D - - mode and center in WebGL mode. The translate() function shifts - the origin - - to a different position. Everything drawn after translate() is - called - - will appear to be shifted. There are two ways to call translate() - with - - parameters that set the origin's position.

- -

The first way to call translate() uses numbers to set the - amount of - - translation. The first two parameters, x and y, set - the amount to - - translate along the positive x- and y-axes. For example, calling - - translate(20, 30) translates the origin 20 pixels along the - x-axis and 30 - - pixels along the y-axis. The third parameter, z, is optional. It - sets the - - amount to translate along the positive z-axis. For example, calling - - translate(20, 30, 40) translates the origin 20 pixels along the - x-axis, - - 30 pixels along the y-axis, and 40 pixels along the z-axis.

- -

The second way to call translate() uses a - - p5.Vector object to set the amount of - - translation. For example, calling translate(myVector) uses the - x-, y-, - - and z-components of myVector to set the amount to translate along - the x-, - - y-, and z-axes. Doing so is the same as calling - - translate(myVector.x, myVector.y, myVector.z).

- -

By default, transformations accumulate. For example, calling - - translate(10, 0) twice has the same effect as calling - - translate(20, 0) once. The push() and - - pop() functions can be used to isolate - - transformations within distinct drawing groups.

- -

Note: Transformations are reset at the beginning of the draw loop. Calling - - translate(10, 0) inside the draw() function won't - - cause shapes to move continuously.

-line: 1223 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A white circle on a gray background.'); - } - - function draw() { - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Draw a circle at coordinates (0, 0). - circle(0, 0, 40); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - 'Two circles drawn on a gray background. The blue circle on the right overlaps the red circle at the center.' - ); - } - - function draw() { - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Draw the red circle. - fill('red'); - circle(0, 0, 40); - - // Translate the origin to the right. - translate(25, 0); - - // Draw the blue circle. - fill('blue'); - circle(0, 0, 40); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A white circle moves slowly from left to right on a gray background.'); - } - - function draw() { - background(200); - - // Calculate the x-coordinate. - let x = frameCount * 0.2; - - // Translate the origin. - translate(x, 50); - - // Draw a circle at coordinates (0, 0). - circle(0, 0, 40); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A white circle on a gray background.'); - } - - function draw() { - background(200); - - // Create a p5.Vector object. - let v = createVector(50, 50); - - // Translate the origin by the vector. - translate(v); - - // Draw a circle at coordinates (0, 0). - circle(0, 0, 40); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'Two spheres sitting side-by-side on gray background. The sphere at the center is red. The sphere on the right is blue.' - ); - } - - function draw() { - background(200); - - // Turn on the lights. - lights(); - - // Style the spheres. - noStroke(); - - // Draw the red sphere. - fill('red'); - sphere(10); - - // Translate the origin to the right. - translate(30, 0, 0); - - // Draw the blue sphere. - fill('blue'); - sphere(10); - } - -
-class: p5 -overloads: - - line: 1223 - params: - - name: x - description: | -

amount to translate along the positive x-axis.

- type: Number - - name: 'y' - description: | -

amount to translate along the positive y-axis.

- type: Number - - name: z - description: | -

amount to translate along the positive z-axis.

- type: Number - optional: true - chainable: 1 - - line: 1394 - params: - - name: vector - description: | -

vector by which to translate.

- type: p5.Vector - chainable: 1 -chainable: true ---- - - -# translate diff --git a/src/content/reference/en/p5 copy/triangle.mdx b/src/content/reference/en/p5 copy/triangle.mdx deleted file mode 100644 index 08f1afb223..0000000000 --- a/src/content/reference/en/p5 copy/triangle.mdx +++ /dev/null @@ -1,104 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L1385 -title: triangle -module: Shape -submodule: 2D Primitives -file: src/core/shape/2d_primitives.js -description: > -

Draws a triangle.

- -

A triangle is a three-sided shape defined by three points. The - - first two parameters specify the triangle's first point (x1, y1). - The - - middle two parameters specify its second point (x2, y2). And the - last two - - parameters specify its third point (x3, y3).

-line: 1385 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - triangle(30, 75, 58, 20, 86, 75); - - describe('A white triangle with a black outline on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - triangle(-20, 25, 8, -30, 36, 25); - - describe('A white triangle with a black outline on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white triangle spins around on a gray canvas.'); - } - - function draw() { - background(200); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Draw the triangle. - triangle(-20, 25, 8, -30, 36, 25); - } - -
-class: p5 -params: - - name: x1 - description: | -

x-coordinate of the first point.

- type: Number - - name: y1 - description: | -

y-coordinate of the first point.

- type: Number - - name: x2 - description: | -

x-coordinate of the second point.

- type: Number - - name: y2 - description: | -

y-coordinate of the second point.

- type: Number - - name: x3 - description: | -

x-coordinate of the third point.

- type: Number - - name: y3 - description: | -

y-coordinate of the third point.

- type: Number -chainable: true ---- - - -# triangle diff --git a/src/content/reference/en/p5 copy/trim.mdx b/src/content/reference/en/p5 copy/trim.mdx deleted file mode 100644 index a782306725..0000000000 --- a/src/content/reference/en/p5 copy/trim.mdx +++ /dev/null @@ -1,113 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L916 -title: trim -module: Data -submodule: String Functions -file: src/utilities/string_functions.js -description: > -

Removes whitespace from the start and end of a String without - changing the middle.

- -

trim() trims - - whitespace characters - - such as spaces, carriage returns, tabs, Unicode "nbsp" character.

- -

The parameter, str, is the string to trim. If a single string - is passed, - - as in trim(' pad '), a single string is returned. If an array - of - - strings is passed, as in trim([' pad ', '\n space \n']), an - array of - - strings is returned.

-line: 916 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let string = ' p5*js '; - - // Trim the whitespace. - let trimmed = trim(string); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the text. - text(`Hello, ${trimmed}!`, 50, 50); - - describe('The text "Hello, p5*js!" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of strings. - let strings = [' wide ', '\n open ', '\n spaces ']; - - // Trim the whitespace. - let trimmed = trim(strings); - - // Style the text. - textAlign(CENTER, CENTER); - textFont('Courier New'); - textSize(10); - - // Display the text. - text(`${trimmed[0]} ${trimmed[1]} ${trimmed[2]}`, 50, 50); - - describe('The text "wide open spaces" written in black on a gray background.'); - } - -
-class: p5 -return: - description: trimmed string. - type: String -overloads: - - line: 916 - params: - - name: str - description: | -

string to trim.

- type: String - return: - description: trimmed string. - type: String - - line: 984 - params: - - name: strs - description: | -

strings to trim.

- type: 'String[]' - return: - description: trimmed strings. - type: 'String[]' -chainable: false ---- - - -# trim diff --git a/src/content/reference/en/p5 copy/turnAxis.mdx b/src/content/reference/en/p5 copy/turnAxis.mdx deleted file mode 100644 index e8dc93e115..0000000000 --- a/src/content/reference/en/p5 copy/turnAxis.mdx +++ /dev/null @@ -1,54 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L378 -title: turnAxis -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

When a device is rotated, the axis that triggers the deviceTurned() - - method is stored in the turnAxis variable. The turnAxis variable is only - defined within - - the scope of deviceTurned().

-line: 378 -isConstructor: false -itemtype: property -example: - - |- - -
- - // Run this example on a mobile device - // Rotate the device by 90 degrees in the - // X-axis to change the value. - - let value = 0; - 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') { - if (value === 0) { - value = 255; - } else if (value === 255) { - value = 0; - } - } - } - -
-class: p5 -type: String ---- - - -# turnAxis diff --git a/src/content/reference/en/p5 copy/types/Array.mdx b/src/content/reference/en/p5 copy/types/Array.mdx deleted file mode 100644 index 17fe1c2ed3..0000000000 --- a/src/content/reference/en/p5 copy/types/Array.mdx +++ /dev/null @@ -1,269 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L1140 -title: Array -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: > -

A list that keeps several pieces of data in order.

- -

Arrays are helpful for storing related data. They can contain data of any - - type. For example, an array could contain a list of someone's favorite - - colors as strings. Arrays are created as follows:

- -
let myArray = ['deeppink', 'darkorchid',
-  'magenta'];
-
-  
- -

Each piece of data in an array is called an element. Each element has an - - address, or index, within its array. The variable myArray refers - to an - - array with three String elements, - 'deeppink', - - 'darkorchid', and 'magenta'. Arrays are - zero-indexed, which means - - that 'deeppink' is at index 0, 'darkorchid' is at - index 1, and - - 'magenta' is at index 2. Array elements can be accessed using - their - - indices as follows:

- -
let zeroth = myArray[0]; // 'deeppink'
-
-  let first = myArray[1]; // 'darkorchid'
-
-  let second = myArray[2]; // 'magenta'
-
-  
- -

Elements can be added to the end of an array by calling the - - push() - - method as follows:

- -
myArray.push('lavender');
-
-
-  let third = myArray[3]; // 'lavender'
-
-  
- -

See MDN - - for more information about arrays.

-line: 1140 -isConstructor: false -itemtype: property -example: - - >- - -
- - - - // Declare the variable xCoordinates and assign it an array - - // with three numeric elements. - - let xCoordinates = [25, 50, 75]; - - - function setup() { - createCanvas(100, 100); - - describe( - 'Three white circles drawn in a horizontal line on a gray background.' - ); - } - - - function draw() { - background(200); - - // Access the element at index 0, which is 25. - circle(xCoordinates[0], 50, 20); - - // Access the element at index 1, which is 50. - circle(xCoordinates[1], 50, 20); - - // Access the element at index 2, which is 75. - circle(xCoordinates[2], 50, 20); - } - - - -
- - -
- - - - // Declare the variable xCoordinates and assign it an array with three - numeric elements. - - let xCoordinates = [20, 40, 60]; - - - // Add another element to the end of the array. - - xCoordinates.push(80); - - - function setup() { - createCanvas(100, 100); - - describe('Four white circles drawn in a horizontal line on a gray background.'); - } - - - function draw() { - background(200); - - // Access the element at index 0, which is 20. - circle(xCoordinates[0], 50, 20); - - // Access the element at index 1, which is 40. - circle(xCoordinates[1], 50, 20); - - // Access the element at index 2, which is 60. - circle(xCoordinates[2], 50, 20); - - // Access the element at index 3, which is 80. - circle(xCoordinates[3], 50, 20); - } - - - -
- - -
- - - - // Declare the variable xCoordinates and assign it an empty array. - - let xCoordinates = []; - - - function setup() { - createCanvas(100, 100); - - // Add elements to the array using a loop. - for (let x = 20; x < 100; x += 20) { - xCoordinates.push(x); - } - - describe('Four white circles drawn in a horizontal line on a gray background.'); - } - - - function draw() { - background(200); - - // Access the element at index i and use it to draw a circle. - for (let i = 0; i < xCoordinates.length; i += 1) { - circle(xCoordinates[i], 50, 20); - } - } - - - -
- - -
- - - - // Declare the variable xCoordinates and assign it an empty array. - - let xCoordinates = []; - - - function setup() { - createCanvas(100, 100); - - // Add elements to the array using a loop. - for (let x = 20; x < 100; x += 20) { - xCoordinates.push(x); - } - - describe('Four white circles drawn in a horizontal line on a gray background.'); - } - - - function draw() { - background(200); - - // Access each element of the array and use it to draw a circle. - for (let x of xCoordinates) { - circle(x, 50, 20); - } - } - - - -
- - -
- - - - // Declare the variable xCoordinates and assign it an empty array. - - let xCoordinates = []; - - - function setup() { - createCanvas(100, 100); - - // Add elements to the array using a loop. - for (let x = 20; x < 100; x += 20) { - xCoordinates.push(x); - } - - describe( - 'Four white circles in a horizontal line on a gray background. The circles move randomly.' - ); - } - - - function draw() { - background(200); - - for (let i = 0; i < xCoordinates.length; i += 1) { - // Update the element at index i. - xCoordinates[i] += random(-1, 1); - - // Use the element at index i to draw a circle. - circle(xCoordinates[i], 50, 20); - } - } - - - -
-class: p5 ---- - - -# Array diff --git a/src/content/reference/en/p5 copy/types/Boolean.mdx b/src/content/reference/en/p5 copy/types/Boolean.mdx deleted file mode 100644 index 01d02c8de2..0000000000 --- a/src/content/reference/en/p5 copy/types/Boolean.mdx +++ /dev/null @@ -1,273 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L502 -title: Boolean -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: > -

A value that's either true or false.

- -

Boolean values help to make decisions in code. They appear any - time a - - logical condition is checked. For example, the condition - - "Is a mouse button being pressed?" must be either true or - - false:

- -
// If the user presses the mouse, draw a circle
-  at
-
-  // the mouse's location.
-
-  if (mouseIsPressed === true) {
-    circle(mouseX, mouseY, 20);
-  }
-
-  
- -

The if statement checks whether - - mouseIsPressed is - true and draws a - - circle if it is. Boolean expressions such as mouseIsPressed - === true - - evaluate to one of the two possible Boolean values: - true or false.

- -

The === operator (EQUAL) checks whether two values are equal. - If they - - are, the expression evaluates to true. Otherwise, it evaluates to - - false.

- -

Note: There's also a == operator with two = - instead of three. Don't use - - it.

- -

The mouseIsPressed system - variable is - - always true or false, so the code snippet above - could also be written - - as follows:

- -
if (mouseIsPressed) {
-    circle(mouseX, mouseY, 20);
-  }
-
-  
- -

The !== operator (NOT EQUAL) checks whether two values are not - equal, as - - in the following example:

- -
if (2 + 2 !== 4) {
-    text('War is peace.', 50, 50);
-  }
-
-  
- -

Starting from the left, the arithmetic expression 2 + 2 - produces the - - value 4. The Boolean expression 4 !== 4 - evaluates to false because - - 4 is equal to itself. As a result, the if - statement's body is skipped.

- -

Note: There's also a != operator with one = - instead of two. Don't use - - it.

- -

The Boolean operator && (AND) checks whether two - expressions are both - - true:

- -
if (keyIsPressed === true && key === 'p') {
-    text('You pressed the "p" key!', 50, 50);
-  }
-
-  
- -

If the user is pressing a key AND that key is 'p', then a - message will - - display.

- -

The Boolean operator || (OR) checks whether at - least one of two - - expressions is true:

- -
if (keyIsPressed === true || mouseIsPressed ===
-  true) {
-    text('You did something!', 50, 50);
-  }
-
-  
- -

If the user presses a key, or presses a mouse button, or both, then a - - message will display.

- -

The following truth table summarizes a few common scenarios with - && and - - ||:

- -
true && true  // true
-
-  true && false // false
-
-  false && false // false
-
-  true || true  // true
-
-  true || false // true
-
-  false || false // false
-
-  
- -

The relational operators >, << code="">, - >=, and <=< code=""> also produce Boolean - - values:

- -
2 > 1 // true
-
-  2 < 1 // false
-
-  2 >= 2 // true
-
-  2 <= 2="" true="" <="" code=""/>
- -

See if for more information about - if statements and - - Number for more information about - Numbers.

-line: 502 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A gray square. When the user presses the mouse, a circle appears at that location.'); - } - - function draw() { - background(200); - - // If the user presses the mouse, draw a circle at that location. - if (mouseIsPressed) { - circle(mouseX, mouseY, 20); - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A gray square. When the user presses the mouse, a circle appears at that location.'); - } - - function draw() { - background(200); - - // If the user presses the mouse, draw a circle at that location. - if (mouseIsPressed === true) { - circle(mouseX, mouseY, 20); - } - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - function setup() { - createCanvas(100, 100); - - describe('A gray square that turns pink when the user presses the mouse or a key.'); - } - - function draw() { - background(200); - - // If the user presses the mouse, change the background color. - if (mouseIsPressed === true || keyIsPressed === true) { - background('deeppink'); - } - } - -
- -
- - // Click the canvas to begin detecting key presses. - - // Create a Boolean variable. - let isPlaying = false; - - function setup() { - createCanvas(100, 100); - - describe( - 'The message "Begin?\nY or N" written in green on a black background. The message "Good luck!" appears when they press the "y" key.' - ); - } - - function draw() { - background(0); - - // Style the text. - textAlign(CENTER, CENTER); - textFont('Courier New'); - textSize(16); - fill(0, 255, 0); - - // Display a different message when the user begins playing. - if (isPlaying === false) { - text('Begin?', 50, 40); - text('Y or N', 50, 60); - } else { - text('Good luck!', 50, 50); - } - } - - // Start playing when the user presses the 'y' key. - function keyPressed() { - if (key === 'y') { - isPlaying = true; - } - } - -
-class: p5 ---- - - -# Boolean diff --git a/src/content/reference/en/p5 copy/types/Number.mdx b/src/content/reference/en/p5 copy/types/Number.mdx deleted file mode 100644 index 3dfa850720..0000000000 --- a/src/content/reference/en/p5 copy/types/Number.mdx +++ /dev/null @@ -1,201 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L853 -title: Number -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: > -

A number that can be positive, negative, or zero.

- -

The Number data type is useful for describing values such as - position, - - size, and color. A number can be an integer such as 20 or a decimal number - - such as 12.34. For example, a circle's position and size can be described - - by three numbers:

- -
circle(50, 50, 20);
-
-  
- -
circle(50, 50, 12.34);
-
-  
- -

Numbers support basic arithmetic and follow the standard order of - - operations: Parentheses, Exponents, Multiplication, Division, Addition, - - and Subtraction (PEMDAS). For example, it's common to use arithmetic - - operators with p5.js' system variables that are numbers:

- -
// Draw a circle at the center.
-
-  circle(width / 2, height / 2, 20);
-
-  
- -
// Draw a circle that moves from left to right.
-
-  circle(frameCount * 0.01, 50, 20);
-
-  
- -

Here's a quick overview of the arithmetic operators:

- -
1 + 2 // Add
-
-  1 - 2 // Subtract
-
-  1 * 2 // Multiply
-
-  1 / 2 // Divide
-
-  1 % 2 // Remainder
-
-  1 ** 2 // Exponentiate
-
-  
- -

It's common to update a number variable using arithmetic. For example, an - - object's location can be updated like so:

- -
x = x + 1;
-
-  
- -

The statement above adds 1 to a variable x using the - + operator. The - - addition assignment operator += expresses the same idea:

- -
x += 1;
-
-  
- -

Here's a quick overview of the assignment operators:

- -
x += 2 // Addition assignment
-
-  x -= 2 // Subtraction assignment
-
-  x *= 2 // Multiplication assignment
-
-  x /= 2 // Division assignment
-
-  x %= 2 // Remainder assignment
-
-  
- -

Numbers can be compared using the - - relational operators - - >, << code="">, >=, <=< code="">, - ===, and !==. For example, a sketch's - - frameCount can be used as a - timer:

- -
if (frameCount > 1000) {
-    text('Game over!', 50, 50);
-  }
-
-  
- -

An expression such as frameCount > 1000 evaluates to a - Boolean value - - that's either true or false. The relational - operators all produce - - Boolean values:

- -
2 > 1 // true
-
-  2 < 1 // false
-
-  2 >= 2 // true
-
-  2 <= 2="" true="" !="=" false="" <="" code=""/>
- -

See Boolean for more information about - comparisons and conditions.

- -

Note: There are also == and != operators with one - fewer =. Don't use them.

- -

Expressions with numbers can also produce special values when something - - goes wrong:

- -
sqrt(-1) // NaN
-
-  1 / 0 // Infinity
-
-  
- -

The value NaN stands for - - Not-A-Number. - - NaN appears when calculations or conversions don't work. - Infinity is a - - value that's larger than any number. It appears during certain - - calculations.

-line: 853 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw a circle at the center. - circle(50, 50, 70); - - // Draw a smaller circle at the center. - circle(width / 2, height / 2, 30); - - describe('Two concentric, white circles drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A white circle travels from left to right on a gray background.'); - } - - function draw() { - background(200); - - circle(frameCount * 0.05, 50, 20); - } - -
-class: p5 ---- - - -# Number diff --git a/src/content/reference/en/p5 copy/types/Object.mdx b/src/content/reference/en/p5 copy/types/Object.mdx deleted file mode 100644 index c5c9adf8bb..0000000000 --- a/src/content/reference/en/p5 copy/types/Object.mdx +++ /dev/null @@ -1,91 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L999 -title: Object -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: "

A container for data that's stored as key-value pairs.

\n

Objects help to organize related data of any type, including other objects.\nA value stored in an object can be accessed by name, called its key. Each\nkey-value pair is called a \"property.\" Objects are similar to dictionaries\nin Python and maps in Java and Ruby.

\n

For example, an object could contain the location, size, and appearance of\na dog:

\n
// Declare the dog variable and assign it an object.\nlet dog = { x: 50, y: 50, size: 20, emoji: '\U0001F436' };\n\n// Style the text.\ntextAlign(CENTER, CENTER);\ntextSize(dog.size);\n\n// Draw the dog.\ntext(dog.emoji, dog.x, dog.y);\n
\n

The variable dog is assigned an object with four properties. Objects\nare declared with curly braces {}. Values can be accessed using the dot\noperator, as in dog.size. In the example above, the key size\ncorresponds to the value 20. Objects can also be empty to start:

\n
// Declare a cat variable and assign it an empty object.\nlet cat = {};\n\n// Add properties to the object.\ncat.x = 50;\ncat.y = 50;\ncat.size = 20;\ncat.emoji = '\U0001F431';\n\n// Style the text.\ntextAlign(CENTER, CENTER);\ntextSize(cat.size);\n\n// Draw the cat.\ntext(cat.emoji, cat.x, cat.y);\n
\n

An object's data can be updated while a sketch runs. For example, the cat\ncould run away from the dog by updating its location:

\n
// Run to the right.\ncat.x += 5;\n
\n

If needed, an object's values can be accessed using square brackets []\nand strings instead of dot notation:

\n
// Run to the right.\ncat[\"x\"] += 5;\n
\n

This syntax can be helpful when the key's name has spaces, as in\ncat['height (m)'].

\n" -line: 999 -isConstructor: false -itemtype: property -example: - - |- - -
- - // Declare the variable data and assign it an object with three properties. - let data = { x: 50, y: 50, d: 20 }; - - function setup() { - createCanvas(100, 100); - - describe('A white circle on a gray background.'); - } - - function draw() { - background(200); - - // Access the object's values using the . operator. - circle(data.x, data.y, data.d); - } - -
- -
- - // Declare the variable data and assign it an object with three properties. - let data = { x: 50, y: 50, d: 20 }; - - // Add another property for color. - data.color = 'deeppink'; - - function setup() { - createCanvas(100, 100); - - describe('A pink circle on a gray background.'); - } - - function draw() { - background(200); - - // Access the object's values using the . operator. - fill(data.color); - circle(data.x, data.y, data.d); - } - -
- -
- - // Declare the variable data and assign it an object with three properties. - let data = { x: 50, y: 50, d: 20 }; - - // Add another property for color. - data.color = 'deeppink'; - - function setup() { - createCanvas(100, 100); - - describe('A white circle on a gray background.'); - } - - function draw() { - background(200); - - // Access the object's values using the . operator. - fill(data.color); - circle(data.x, data.y, data.d); - - // Update the object's x and y properties. - data.x += random(-1, 1); - data.y += random(-1, 1); - } - -
-class: p5 ---- - - -# Object diff --git a/src/content/reference/en/p5 copy/types/String.mdx b/src/content/reference/en/p5 copy/types/String.mdx deleted file mode 100644 index e62a9a8b9c..0000000000 --- a/src/content/reference/en/p5 copy/types/String.mdx +++ /dev/null @@ -1,153 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L710 -title: String -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: > -

A sequence of text characters.

- -

The String data type is helpful for working with text. For - example, a - - string could contain a welcome message:

- -
// Use a string literal.
-
-  text('Hello!', 10, 10);
-
-  
- -
// Create a string variable.
-
-  let message = 'Hello!';
-
-
-  // Use the string variable.
-
-  text(message, 10, 10);
-
-  
- -

The most common way to create strings is to use some form of quotations as - - follows:

- -
text("hi", 50, 50);
-
-  
- -
text('hi', 50, 50);
-
-  
- -
text(`hi`, 50, 50);
-
-  
- -

"hi", 'hi', and hi are all string - literals. A "literal" means a - - value was actually written, as in text('hi', 50, 50). By - contrast, - - text(message, 50, 50) uses the variable message, so - it isn't a string - - literal.

- -

Single quotes '' and double quotes "" mean the - same thing. It's nice to - - have the option for cases when a string contains one type of quote:

- -
text("What's up?", 50, 50);
-
-  
- -
text('Air quotes make you look "cool."', 50,
-  50);
-
-  
- -

Backticks `` create template literals. Template literals have - many uses. - - For example, they can contain both single and double quotes as needed:

- -
text(`"Don't you forget about me"`,  10, 10);
-
-  
- -

Template literals are helpful when strings are created from variables like - - so:

- -
let size = random(10, 20);
-
-  circle(50, 50, size);
-
-
-  text(`The circle's diameter is ${size} pixels.`,  10, 10);
-
-  
- -

The size variable's value will replace ${size} - when the string is - - created. ${} is a placeholder for any value. That means an - expression can - - be used, as in ${round(PI, 3)}. All of the following are valid - template - - literals:

- -
text(`π is about ${round(PI, 2)} pixels.`,  10,
-  10);
-
-  text(`It's ${mouseX < width / 2} that I'm on the left half of the canvas.`, 
-  10, 30);
-
-  
- -

Template literals can include several variables:

- -
let x = random(0, 100);
-
-  let y = random(0, 100);
-
-  let size = random(10, 20);
-
-  circle(x, y, size);
-
-
-  text(`The circle at (${x}, ${y}) has a diameter of ${size} pixels.`,  10, 10);
-
-  
- -

Template literals are also helpful for creating multi-line text like - so:

- -
let poem = `My sketch doesn't run;
-
-  it waits for me patiently
-
-  while bugs point the way.`;
-
-
-  text(poem, 10, 10);
-
-  
-line: 710 -isConstructor: false -itemtype: property -example: - - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Style the text.\n textAlign(CENTER, CENTER);\n textSize(20);\n\n // Display a welcome message.\n text('Hello!', 50, 50);\n\n describe('The text \"Hello!\" written on a gray background.');\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Style the text.\n textAlign(CENTER, CENTER);\n textSize(20);\n\n // Create a string variable.\n let world = '\U0001F30D';\n\n // Display a welcome message using a template string.\n text(`Hello, ${world}!`, 50, 50);\n\n describe('The text \"Hello, \U0001F30D!\" written on a gray background.');\n}\n\n
" -class: p5 ---- - - -# String diff --git a/src/content/reference/en/p5 copy/unchar.mdx b/src/content/reference/en/p5 copy/unchar.mdx deleted file mode 100644 index 8ef044b393..0000000000 --- a/src/content/reference/en/p5 copy/unchar.mdx +++ /dev/null @@ -1,114 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L731 -title: unchar -module: Data -submodule: Conversion -file: src/utilities/conversion.js -description: > -

Converts a single-character String to a - Number.

- -

unchar() converts single-character strings to their - corresponding - - integer (whole number).

- -

The parameter, n, is the character to convert. For example, - - unchar('A'), returns the number 65. If an array is passed, as in - - unchar(['A', 'B', 'C']), an array of integers is returned.

-line: 731 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let original = 'A'; - - // Convert the string to a number. - let converted = unchar(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the original and converted values. - text(`${original} : ${converted}`, 50, 50); - - describe('The text "A : 65" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of characters. - let original = ['A', 'B', 'C']; - - // Convert the string to a number. - let converted = unchar(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Iterate over elements of the converted array. - for (let i = 0; i < converted.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 25; - - // Display the original and converted values. - text(`${original[i]} : ${converted[i]}`, 50, y); - } - - describe( - 'The text "A : 65", "B : 66", and "C :67" written on three separate lines. The text is in black on a gray background.' - ); - } - -
-class: p5 -return: - description: converted number. - type: Number -overloads: - - line: 731 - params: - - name: 'n' - description: | -

value to convert.

- type: String - return: - description: converted number. - type: Number - - line: 805 - params: - - name: ns - description: | -

values to convert.

- type: 'String[]' - return: - description: converted numbers. - type: 'Number[]' -chainable: false ---- - - -# unchar diff --git a/src/content/reference/en/p5 copy/unhex.mdx b/src/content/reference/en/p5 copy/unhex.mdx deleted file mode 100644 index 5c507abc4c..0000000000 --- a/src/content/reference/en/p5 copy/unhex.mdx +++ /dev/null @@ -1,121 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L956 -title: unhex -module: Data -submodule: Conversion -file: src/utilities/conversion.js -description: > -

Converts a String with a hexadecimal value to a - Number.

- -

unhex() converts a string with its hexadecimal number value to - a number. - - Hexadecimal (hex) numbers are base-16, which means there are 16 unique - - digits. Hex extends the numbers 0–9 with the letters A–F. For example, the - - number 11 (eleven) in base-10 is written as the letter - B in hex.

- -

The first parameter, n, is the hex string to convert. For - example, - - unhex('FF'), returns the number 255. If an array is passed, as in - - unhex(['00', '80', 'FF']), an array of numbers is returned.

-line: 956 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a a hex string variable - let original = 'FF'; - - // Convert the hex string to a number. - let converted = unhex(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the original and converted values. - text(`${original} = ${converted}`, 50, 50); - - describe('The text "FF = 255" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of numbers. - let original = ['00', '80', 'FF']; - - // Convert the numbers to hex strings. - // Only use two hex digits. - let converted = unhex(original, 2); - - // Style the text. - textAlign(RIGHT, CENTER); - textSize(16); - - // Iterate over the converted values. - for (let i = 0; i < converted.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 25; - - // Display the original and converted values. - text(`${ original[i]} = ${converted[i]}`, 80, y); - } - - describe( - 'The text "00 = 0", "80 = 128", and "FF = 255" written on three separate lines. The text is in black on a gray background.' - ); - } - -
-class: p5 -return: - description: converted number. - type: Number -overloads: - - line: 956 - params: - - name: 'n' - description: | -

value to convert.

- type: String - return: - description: converted number. - type: Number - - line: 1033 - params: - - name: ns - description: | -

values to convert.

- type: 'String[]' - return: - description: converted numbers. - type: 'Number[]' -chainable: false ---- - - -# unhex diff --git a/src/content/reference/en/p5 copy/updatePixels.mdx b/src/content/reference/en/p5 copy/updatePixels.mdx deleted file mode 100644 index 5de892374b..0000000000 --- a/src/content/reference/en/p5 copy/updatePixels.mdx +++ /dev/null @@ -1,94 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L1118 -title: updatePixels -module: Image -submodule: Pixels -file: src/image/pixels.js -description: > -

Updates the canvas with the RGBA values in the - - pixels array.

- -

updatePixels() only needs to be called after changing values - in the - - pixels array. Such changes can be made - directly - - after calling loadPixels() or by - calling - - set().

-line: 1118 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/rockies.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0, 100, 100); - - // Get the pixel density. - let d = pixelDensity(); - - // Calculate the halfway index in the pixels array. - let halfImage = 4 * (d * width) * (d * height / 2); - - // Load the pixels array. - loadPixels(); - - // Copy the top half of the canvas to the bottom. - for (let i = 0; i < halfImage; i += 1) { - pixels[i + halfImage] = pixels[i]; - } - - // Update the canvas. - updatePixels(); - - describe('Two identical images of mountain landscapes, one on top of the other.'); - } - -
-class: p5 -params: - - name: x - description: | -

x-coordinate of the upper-left corner of region - to update.

- type: Number - optional: true - - name: 'y' - description: | -

y-coordinate of the upper-left corner of region - to update.

- type: Number - optional: true - - name: w - description: | -

width of region to update.

- type: Number - optional: true - - name: h - description: | -

height of region to update.

- type: Number - optional: true -chainable: false ---- - - -# updatePixels diff --git a/src/content/reference/en/p5 copy/userStartAudio.mdx b/src/content/reference/en/p5 copy/userStartAudio.mdx deleted file mode 100644 index 076d8537c5..0000000000 --- a/src/content/reference/en/p5 copy/userStartAudio.mdx +++ /dev/null @@ -1,99 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L198 -title: userStartAudio -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: >- -

It is not only a good practice to give users control over starting - - audio. This policy is enforced by many web browsers, including iOS and - - Google Chrome, which create the Web Audio API's - - Audio Context - - in a suspended state.

- - -

In these browser-specific policies, sound will not play until a user - - interaction event (i.e. mousePressed()) explicitly resumes - - the AudioContext, or starts an audio node. This can be accomplished by - - calling start() on a p5.Oscillator, - - play() on a p5.SoundFile, or simply - - userStartAudio().

- - -

userStartAudio() starts the AudioContext on a user - - gesture. The default behavior will enable audio on any - - mouseUp or touchEnd event. It can also be placed in a specific - - interaction function, such as mousePressed() as in the - - example below. This method utilizes - - StartAudioContext - - , a library by Yotam Mann (MIT Licence, 2016).

-line: 198 -isConstructor: false -itemtype: method -example: - - |- - -
- function setup() { - // mimics the autoplay policy - getAudioContext().suspend(); - - let mySynth = new p5.MonoSynth(); - - // This won't play until the context has resumed - mySynth.play('A6'); - } - function draw() { - background(220); - textAlign(CENTER, CENTER); - text(getAudioContext().state, width/2, height/2); - } - function mousePressed() { - userStartAudio(); - } -
-class: p5 -params: - - name: elements - description: | -

This argument can be an Element, - Selector String, NodeList, p5.Element, - jQuery Element, or an Array of any of those.

- type: Element|Array - optional: true - - name: callback - description: | -

Callback to invoke when the AudioContext - has started

- type: Function - optional: true -return: - description: |- - Returns a Promise that resolves when - the AudioContext state is 'running' - type: Promise -chainable: false ---- - - -# userStartAudio diff --git a/src/content/reference/en/p5 copy/vertex.mdx b/src/content/reference/en/p5 copy/vertex.mdx deleted file mode 100644 index 92d5bb9138..0000000000 --- a/src/content/reference/en/p5 copy/vertex.mdx +++ /dev/null @@ -1,242 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L1881 -title: vertex -module: Shape -submodule: Vertex -file: src/core/shape/vertex.js -description: > -

Adds a vertex to a custom shape.

- -

vertex() sets the coordinates of vertices drawn between the - - beginShape() and - - endShape() functions.

- -

The first two parameters, x and y, set the x- and - y-coordinates of the - - vertex.

- -

The third parameter, z, is optional. It sets the z-coordinate - of the - - vertex in WebGL mode. By default, z is 0.

- -

The fourth and fifth parameters, u and v, are - also optional. They set - - the u- and v-coordinates for the vertex’s texture when used with - - endShape(). By default, u - and v are both 0.

-line: 1881 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the shape. - strokeWeight(3); - - // Start drawing the shape. - // Only draw the vertices. - beginShape(POINTS); - - // Add the vertices. - vertex(30, 20); - vertex(85, 20); - vertex(85, 75); - vertex(30, 75); - - // Stop drawing the shape. - endShape(); - - describe('Four black dots that form a square are drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - beginShape(); - - // Add vertices. - vertex(30, 20); - vertex(85, 20); - vertex(85, 75); - vertex(30, 75); - - // Stop drawing the shape. - endShape(CLOSE); - - describe('A white square on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - // Start drawing the shape. - beginShape(); - - // Add vertices. - vertex(-20, -30, 0); - vertex(35, -30, 0); - vertex(35, 25, 0); - vertex(-20, 25, 0); - - // Stop drawing the shape. - endShape(CLOSE); - - describe('A white square on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white square spins around slowly on a gray background.'); - } - - function draw() { - background(200); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Start drawing the shape. - beginShape(); - - // Add vertices. - vertex(-20, -30, 0); - vertex(35, -30, 0); - vertex(35, 25, 0); - vertex(-20, 25, 0); - - // Stop drawing the shape. - endShape(CLOSE); - } - -
- -
- - let img; - - // Load an image to apply as a texture. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A photograph of a ceiling rotates slowly against a gray background.'); - } - - function draw() { - background(200); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Style the shape. - noStroke(); - - // Apply the texture. - texture(img); - textureMode(NORMAL); - - // Start drawing the shape - beginShape(); - - // Add vertices. - vertex(-20, -30, 0, 0, 0); - vertex(35, -30, 0, 1, 0); - vertex(35, 25, 0, 1, 1); - vertex(-20, 25, 0, 0, 1); - - // Stop drawing the shape. - endShape(); - } - -
-class: p5 -overloads: - - line: 1881 - params: - - name: x - description: | -

x-coordinate of the vertex.

- type: Number - - name: 'y' - description: | -

y-coordinate of the vertex.

- type: Number - chainable: 1 - - line: 2052 - params: - - name: x - description: '' - type: Number - - name: 'y' - description: '' - type: Number - - name: z - description: | -

z-coordinate of the vertex. Defaults to 0.

- type: Number - optional: true - chainable: 1 - - line: 2059 - params: - - name: x - description: '' - type: Number - - name: 'y' - description: '' - type: Number - - name: z - description: '' - type: Number - optional: true - - name: u - description: | -

u-coordinate of the vertex's texture. Defaults to 0.

- type: Number - optional: true - - name: v - description: | -

v-coordinate of the vertex's texture. Defaults to 0.

- type: Number - optional: true - chainable: 1 -chainable: true ---- - - -# vertex diff --git a/src/content/reference/en/p5 copy/webglVersion.mdx b/src/content/reference/en/p5 copy/webglVersion.mdx deleted file mode 100644 index 1909f94a86..0000000000 --- a/src/content/reference/en/p5 copy/webglVersion.mdx +++ /dev/null @@ -1,105 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L508 -title: webglVersion -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

A String variable with the WebGL version in use.

- -

webglVersion's value equals one of the following string - constants:

- -
    - -
  • WEBGL2 whose value is 'webgl2',
  • - -
  • WEBGL whose value is 'webgl', or
  • - -
  • P2D whose value is 'p2d'. This is the default - for 2D sketches.
  • - -
- -

See setAttributes() for ways to - set the - - WebGL version.

-line: 508 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - background(200); - - // Display the current WebGL version. - text(webglVersion, 42, 54); - - describe('The text "p2d" written in black on a gray background.'); - } - -
- -
- - let font; - - function preload() { - // Load a font to use. - font = loadFont('/assets/inconsolata.otf'); - } - - function setup() { - // Create a canvas using WEBGL mode. - createCanvas(100, 50, WEBGL); - background(200); - - // Display the current WebGL version. - fill(0); - textFont(font); - text(webglVersion, -15, 5); - - describe('The text "webgl2" written in black on a gray background.'); - } - -
- -
- - let font; - - function preload() { - // Load a font to use. - font = loadFont('/assets/inconsolata.otf'); - } - - function setup() { - // Create a canvas using WEBGL mode. - createCanvas(100, 50, WEBGL); - - // Set WebGL to version 1. - setAttributes({ version: 1 }); - - background(200); - - // Display the current WebGL version. - fill(0); - textFont(font); - text(webglVersion, -14, 5); - - describe('The text "webgl" written in black on a gray background.'); - } - -
-class: p5 -type: String ---- - - -# webglVersion diff --git a/src/content/reference/en/p5 copy/while.mdx b/src/content/reference/en/p5 copy/while.mdx deleted file mode 100644 index 5fdcb2985a..0000000000 --- a/src/content/reference/en/p5 copy/while.mdx +++ /dev/null @@ -1,161 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L1872 -title: while -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: > -

A way to repeat a block of code.

- -

while loops are helpful for repeating statements while a - condition is - - true. They're like if statements that repeat. For - example, a while - - loop makes it easy to express the idea "draw several lines" like so:

- -
// Declare a variable to keep track of
-  iteration.
-
-  let x = 10;
-
-
-  // Repeat as long as x < 100
-
-  while (x < 100) {
-    line(x, 25, x, 75);
-
-    // Increment by 20.
-    x += 20;
-  }
-
-  
- -

The loop's header begins with the keyword while. Loops - generally count up - - or count down as they repeat, or iterate. The statement in parentheses - - x < 100 is a condition the loop checks each time it iterates. If - the - - condition is true, the loop runs the code between the curly - braces {}, - - The code between the curly braces is called the loop's body. If the - - condition is false, the body is skipped and the loop is - stopped.

- -

It's common to create infinite loops accidentally. For example, the - - following loop never stops iterating because it doesn't count up:

- -
// Declare a variable to keep track of
-  iteration.
-
-  let x = 10;
-
-
-  // Repeat as long as x < 100
-
-  while (x < 100) {
-    line(x, 25, x, 75);
-  }
-
-
-  // This should be in the loop's body!
-
-  x += 20;
-
-  
- -

The statement x += 20 appears after the loop's body. That - means the - - variable x is stuck at 10, which is always less - than 100.

- -

while loops are useful when the number of iterations isn't - known in - - advance. For example, concentric circles could be drawn at random - - increments:

- -
let d = 100;
-
-  let minSize = 5;
-
-
-  while (d > minSize) {
-    circle(50, 50, d);
-    d -= random(10);
-  }
-
-  
-line: 1872 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('Five black vertical lines on a gray background.'); - } - - function draw() { - background(200); - - // Declare a variable to keep track of iteration. - let x = 10; - - // Repeat as long as x < 100 - while (x < 100) { - line(x, 25, x, 75); - - // Increment by 20. - x += 20; - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Slow the frame rate. - frameRate(5); - - describe( - "A gray square with several concentric circles at the center. The circles' sizes decrease at random increments." - ); - } - - function draw() { - background(200); - - let d = 100; - let minSize = 5; - - while (d > minSize) { - circle(50, 50, d); - d -= random(5, 15); - } - } - -
-class: p5 ---- - - -# while diff --git a/src/content/reference/en/p5 copy/width.mdx b/src/content/reference/en/p5 copy/width.mdx deleted file mode 100644 index 0eb6ad07bb..0000000000 --- a/src/content/reference/en/p5 copy/width.mdx +++ /dev/null @@ -1,87 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L812 -title: width -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

A Number variable that stores the width of the canvas in - pixels.

- -

width's default value is 100. Calling - - createCanvas() or - - resizeCanvas() changes the value of - - width. Calling noCanvas() - sets its value to - - 0.

-line: 812 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - background(200); - - // Display the canvas' width. - text(width, 42, 54); - - describe('The number 100 written in black on a gray square.'); - } - -
- -
- - function setup() { - createCanvas(50, 100); - - background(200); - - // Display the canvas' width. - text(width, 21, 54); - - describe('The number 50 written in black on a gray rectangle.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Display the canvas' width. - text(width, 42, 54); - - describe('The number 100 written in black on a gray square. When the mouse is pressed, the square becomes a rectangle and the number becomes 50.'); - } - - // If the mouse is pressed, reisze - // the canvas and display its new - // width. - function mousePressed() { - if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) { - resizeCanvas(50, 100); - background(200); - text(width, 21, 54); - } - } - -
-class: p5 -type: Number ---- - - -# width diff --git a/src/content/reference/en/p5 copy/winMouseX.mdx b/src/content/reference/en/p5 copy/winMouseX.mdx deleted file mode 100644 index ae7dbc3fac..0000000000 --- a/src/content/reference/en/p5 copy/winMouseX.mdx +++ /dev/null @@ -1,61 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L463 -title: winMouseX -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A Number variable that tracks the mouse's horizontal position - within the - - browser.

- -

winMouseX keeps track of the mouse's position relative to the - top-left - - corner of the browser window. For example, if the mouse is 50 pixels from - - the left edge of the browser, then winMouseX will be 50.

- -

On a touchscreen device, winMouseX will hold the x-coordinate - of the most - - recent touch point.

- -

Note: Use mouseX to track the mouse’s - - x-coordinate within the canvas.

-line: 463 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe("A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse."); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the mouse's coordinates within the browser window. - text(`x: ${winMouseX} y: ${winMouseY}`, 50, 50); - } - -
-class: p5 -type: Number ---- - - -# winMouseX diff --git a/src/content/reference/en/p5 copy/winMouseY.mdx b/src/content/reference/en/p5 copy/winMouseY.mdx deleted file mode 100644 index 32c59cba4c..0000000000 --- a/src/content/reference/en/p5 copy/winMouseY.mdx +++ /dev/null @@ -1,61 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L504 -title: winMouseY -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A Number variable that tracks the mouse's vertical position - within the - - browser.

- -

winMouseY keeps track of the mouse's position relative to the - top-left - - corner of the browser window. For example, if the mouse is 50 pixels from - - the top edge of the browser, then winMouseY will be 50.

- -

On a touchscreen device, winMouseY will hold the y-coordinate - of the most - - recent touch point.

- -

Note: Use mouseY to track the mouse’s - - y-coordinate within the canvas.

-line: 504 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe("A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse."); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the mouse's coordinates within the browser window. - text(`x: ${winMouseX} y: ${winMouseY}`, 50, 50); - } - -
-class: p5 -type: Number ---- - - -# winMouseY diff --git a/src/content/reference/en/p5 copy/windowHeight.mdx b/src/content/reference/en/p5 copy/windowHeight.mdx deleted file mode 100644 index 829ac3d76b..0000000000 --- a/src/content/reference/en/p5 copy/windowHeight.mdx +++ /dev/null @@ -1,43 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L680 -title: windowHeight -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

A Number variable that stores the height of the browser's - viewport.

- -

The layout viewport - - is the area within the browser that's available for drawing.

-line: 680 -isConstructor: false -itemtype: property -alt: This example does not render anything. -example: - - |- - -
- - function setup() { - // Set the canvas' width and height - // using the browser's dimensions. - createCanvas(windowWidth, windowHeight); - - background(200); - - describe('A gray canvas that takes up the entire browser window.'); - } - -
-class: p5 -type: Number ---- - - -# windowHeight diff --git a/src/content/reference/en/p5 copy/windowResized.mdx b/src/content/reference/en/p5 copy/windowResized.mdx deleted file mode 100644 index aed52e6b4b..0000000000 --- a/src/content/reference/en/p5 copy/windowResized.mdx +++ /dev/null @@ -1,64 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L708 -title: windowResized -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

A function that's called when the browser window is resized.

- -

Code placed in the body of windowResized() will run when the - - browser window's size changes. It's a good place to call - - resizeCanvas() or make other - - adjustments to accommodate the new window size.

- -

The event parameter is optional. If added to the function - declaration, it - - can be used for debugging or other purposes.

-line: 708 -isConstructor: false -itemtype: method -alt: This example does not render anything. -example: - - |- - -
- - function setup() { - createCanvas(windowWidth, windowHeight); - - describe('A gray canvas with a white circle at its center. The canvas takes up the entire browser window. It changes size to match the browser window.'); - } - - function draw() { - background(200); - - // Draw a circle at the center. - circle(width / 2, height / 2, 50); - } - - // Resize the canvas when the - // browser's size changes. - function windowResized() { - resizeCanvas(windowWidth, windowHeight); - } - -
-class: p5 -params: - - name: event - description: | -

optional resize Event.

- type: Event - optional: true -chainable: false ---- - - -# windowResized diff --git a/src/content/reference/en/p5 copy/windowWidth.mdx b/src/content/reference/en/p5 copy/windowWidth.mdx deleted file mode 100644 index 26ec5fc2a9..0000000000 --- a/src/content/reference/en/p5 copy/windowWidth.mdx +++ /dev/null @@ -1,43 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L652 -title: windowWidth -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

A Number variable that stores the width of the browser's - viewport.

- -

The layout viewport - - is the area within the browser that's available for drawing.

-line: 652 -isConstructor: false -itemtype: property -alt: This example does not render anything. -example: - - |- - -
- - function setup() { - // Set the canvas' width and height - // using the browser's dimensions. - createCanvas(windowWidth, windowHeight); - - background(200); - - describe('A gray canvas that takes up the entire browser window.'); - } - -
-class: p5 -type: Number ---- - - -# windowWidth diff --git a/src/content/reference/en/p5 copy/year.mdx b/src/content/reference/en/p5 copy/year.mdx deleted file mode 100644 index 04efa83189..0000000000 --- a/src/content/reference/en/p5 copy/year.mdx +++ /dev/null @@ -1,47 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L311 -title: year -module: IO -submodule: Time & Date -file: src/utilities/time_date.js -description: | -

Returns the current year as a number such as 1999.

-line: 311 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Get the current year. - let y = year(); - - // Style the text. - textAlign(LEFT, CENTER); - textSize(12); - textFont('Courier New'); - - // Display the year. - text(`Current year: ${y}`, 10, 50, 80); - - describe(`The text 'Current year: ${y}' written in black on a gray background.`); - } - -
-class: p5 -return: - description: current year. - type: Integer -chainable: false ---- - - -# year From d5b71dd62828a677c77f56dd08625d5653a79b47 Mon Sep 17 00:00:00 2001 From: Aashish Panthi Date: Mon, 29 Jun 2026 23:42:54 +0545 Subject: [PATCH 15/16] add test files --- .github/actions/translation-tracker/README.md | 35 +- src/content/reference/en/p5 copy/abs.mdx | 61 ++ .../reference/en/p5 copy/accelerationX.mdx | 37 + .../reference/en/p5 copy/accelerationY.mdx | 37 + .../reference/en/p5 copy/accelerationZ.mdx | 37 + src/content/reference/en/p5 copy/acos.mdx | 86 ++ src/content/reference/en/p5 copy/alpha.mdx | 120 +++ .../reference/en/p5 copy/ambientLight.mdx | 241 ++++++ .../reference/en/p5 copy/ambientMaterial.mdx | 269 ++++++ .../reference/en/p5 copy/angleMode.mdx | 219 +++++ src/content/reference/en/p5 copy/append.mdx | 48 ++ .../reference/en/p5 copy/applyMatrix.mdx | 347 ++++++++ src/content/reference/en/p5 copy/arc.mdx | 274 ++++++ .../reference/en/p5 copy/arrayCopy.mdx | 95 +++ src/content/reference/en/p5 copy/asin.mdx | 86 ++ src/content/reference/en/p5 copy/atan.mdx | 86 ++ src/content/reference/en/p5 copy/atan2.mdx | 106 +++ .../reference/en/p5 copy/background.mdx | 336 ++++++++ .../reference/en/p5 copy/baseColorShader.mdx | 178 ++++ .../en/p5 copy/baseMaterialShader.mdx | 418 +++++++++ .../reference/en/p5 copy/baseNormalShader.mdx | 211 +++++ .../reference/en/p5 copy/baseStrokeShader.mdx | 356 ++++++++ .../reference/en/p5 copy/beginClip.mdx | 208 +++++ .../reference/en/p5 copy/beginContour.mdx | 134 +++ .../reference/en/p5 copy/beginGeometry.mdx | 281 +++++++ .../reference/en/p5 copy/beginShape.mdx | 449 ++++++++++ src/content/reference/en/p5 copy/bezier.mdx | 273 ++++++ .../reference/en/p5 copy/bezierDetail.mdx | 121 +++ .../reference/en/p5 copy/bezierPoint.mdx | 162 ++++ .../reference/en/p5 copy/bezierTangent.mdx | 155 ++++ .../reference/en/p5 copy/bezierVertex.mdx | 337 ++++++++ src/content/reference/en/p5 copy/blend.mdx | 214 +++++ .../reference/en/p5 copy/blendMode.mdx | 541 ++++++++++++ src/content/reference/en/p5 copy/blue.mdx | 158 ++++ src/content/reference/en/p5 copy/boolean.mdx | 157 ++++ src/content/reference/en/p5 copy/box.mdx | 186 ++++ .../reference/en/p5 copy/brightness.mdx | 168 ++++ .../reference/en/p5 copy/buildGeometry.mdx | 263 ++++++ src/content/reference/en/p5 copy/byte.mdx | 180 ++++ src/content/reference/en/p5 copy/camera.mdx | 200 +++++ src/content/reference/en/p5 copy/ceil.mdx | 65 ++ src/content/reference/en/p5 copy/changed.mdx | 87 ++ src/content/reference/en/p5 copy/char.mdx | 152 ++++ src/content/reference/en/p5 copy/circle.mdx | 77 ++ src/content/reference/en/p5 copy/class.mdx | 19 + src/content/reference/en/p5 copy/clear.mdx | 108 +++ .../reference/en/p5 copy/clearDepth.mdx | 113 +++ .../reference/en/p5 copy/clearStorage.mdx | 81 ++ src/content/reference/en/p5 copy/clip.mdx | 225 +++++ src/content/reference/en/p5 copy/color.mdx | 349 ++++++++ .../reference/en/p5 copy/colorMode.mdx | 271 ++++++ src/content/reference/en/p5 copy/concat.mdx | 54 ++ src/content/reference/en/p5 copy/cone.mdx | 265 ++++++ src/content/reference/en/p5 copy/console.mdx | 99 +++ .../reference/en/p5 copy/constants/ADD.mdx | 18 + .../reference/en/p5 copy/constants/ALT.mdx | 18 + .../reference/en/p5 copy/constants/ARROW.mdx | 18 + .../reference/en/p5 copy/constants/AUTO.mdx | 25 + .../reference/en/p5 copy/constants/AXES.mdx | 18 + .../en/p5 copy/constants/BACKSPACE.mdx | 18 + .../en/p5 copy/constants/BASELINE.mdx | 18 + .../reference/en/p5 copy/constants/BEVEL.mdx | 18 + .../reference/en/p5 copy/constants/BEZIER.mdx | 18 + .../reference/en/p5 copy/constants/BLEND.mdx | 18 + .../reference/en/p5 copy/constants/BLUR.mdx | 18 + .../reference/en/p5 copy/constants/BOLD.mdx | 18 + .../en/p5 copy/constants/BOLDITALIC.mdx | 18 + .../reference/en/p5 copy/constants/BOTTOM.mdx | 18 + .../reference/en/p5 copy/constants/BURN.mdx | 18 + .../reference/en/p5 copy/constants/CENTER.mdx | 18 + .../reference/en/p5 copy/constants/CHAR.mdx | 18 + .../reference/en/p5 copy/constants/CHORD.mdx | 18 + .../reference/en/p5 copy/constants/CLAMP.mdx | 18 + .../reference/en/p5 copy/constants/CLOSE.mdx | 18 + .../en/p5 copy/constants/CONTAIN.mdx | 18 + .../en/p5 copy/constants/CONTROL.mdx | 18 + .../reference/en/p5 copy/constants/CORNER.mdx | 18 + .../en/p5 copy/constants/CORNERS.mdx | 18 + .../reference/en/p5 copy/constants/COVER.mdx | 18 + .../reference/en/p5 copy/constants/CROSS.mdx | 18 + .../reference/en/p5 copy/constants/CURVE.mdx | 18 + .../en/p5 copy/constants/DARKEST.mdx | 18 + .../en/p5 copy/constants/DEGREES.mdx | 59 ++ .../reference/en/p5 copy/constants/DELETE.mdx | 18 + .../en/p5 copy/constants/DIFFERENCE.mdx | 18 + .../reference/en/p5 copy/constants/DILATE.mdx | 18 + .../reference/en/p5 copy/constants/DODGE.mdx | 18 + .../en/p5 copy/constants/DOWN_ARROW.mdx | 18 + .../reference/en/p5 copy/constants/ENTER.mdx | 18 + .../reference/en/p5 copy/constants/ERODE.mdx | 18 + .../reference/en/p5 copy/constants/ESCAPE.mdx | 18 + .../en/p5 copy/constants/EXCLUSION.mdx | 18 + .../en/p5 copy/constants/FALLBACK.mdx | 18 + .../reference/en/p5 copy/constants/FILL.mdx | 18 + .../reference/en/p5 copy/constants/FLAT.mdx | 18 + .../reference/en/p5 copy/constants/FLOAT.mdx | 18 + .../reference/en/p5 copy/constants/GRAY.mdx | 18 + .../reference/en/p5 copy/constants/GRID.mdx | 18 + .../en/p5 copy/constants/HALF_FLOAT.mdx | 18 + .../en/p5 copy/constants/HALF_PI.mdx | 109 +++ .../reference/en/p5 copy/constants/HAND.mdx | 18 + .../en/p5 copy/constants/HARD_LIGHT.mdx | 18 + .../reference/en/p5 copy/constants/HSB.mdx | 24 + .../reference/en/p5 copy/constants/HSL.mdx | 18 + .../reference/en/p5 copy/constants/IMAGE.mdx | 18 + .../en/p5 copy/constants/IMMEDIATE.mdx | 18 + .../reference/en/p5 copy/constants/INVERT.mdx | 18 + .../reference/en/p5 copy/constants/ITALIC.mdx | 18 + .../reference/en/p5 copy/constants/LABEL.mdx | 18 + .../en/p5 copy/constants/LANDSCAPE.mdx | 18 + .../reference/en/p5 copy/constants/LEFT.mdx | 18 + .../en/p5 copy/constants/LEFT_ARROW.mdx | 18 + .../en/p5 copy/constants/LIGHTEST.mdx | 18 + .../reference/en/p5 copy/constants/LINEAR.mdx | 18 + .../reference/en/p5 copy/constants/LINES.mdx | 18 + .../en/p5 copy/constants/LINE_LOOP.mdx | 18 + .../en/p5 copy/constants/LINE_STRIP.mdx | 18 + .../reference/en/p5 copy/constants/MIRROR.mdx | 18 + .../reference/en/p5 copy/constants/MITER.mdx | 18 + .../reference/en/p5 copy/constants/MOVE.mdx | 18 + .../en/p5 copy/constants/MULTIPLY.mdx | 18 + .../en/p5 copy/constants/NEAREST.mdx | 18 + .../reference/en/p5 copy/constants/NORMAL.mdx | 18 + .../reference/en/p5 copy/constants/OPAQUE.mdx | 18 + .../reference/en/p5 copy/constants/OPEN.mdx | 18 + .../reference/en/p5 copy/constants/OPTION.mdx | 18 + .../en/p5 copy/constants/OVERLAY.mdx | 18 + .../reference/en/p5 copy/constants/P2D.mdx | 19 + .../reference/en/p5 copy/constants/PI.mdx | 108 +++ .../reference/en/p5 copy/constants/PIE.mdx | 18 + .../reference/en/p5 copy/constants/POINTS.mdx | 18 + .../en/p5 copy/constants/PORTRAIT.mdx | 18 + .../en/p5 copy/constants/POSTERIZE.mdx | 18 + .../en/p5 copy/constants/PROJECT.mdx | 18 + .../en/p5 copy/constants/QUADRATIC.mdx | 18 + .../reference/en/p5 copy/constants/QUADS.mdx | 18 + .../en/p5 copy/constants/QUAD_STRIP.mdx | 18 + .../en/p5 copy/constants/QUARTER_PI.mdx | 109 +++ .../en/p5 copy/constants/RADIANS.mdx | 66 ++ .../reference/en/p5 copy/constants/RADIUS.mdx | 18 + .../reference/en/p5 copy/constants/REMOVE.mdx | 18 + .../reference/en/p5 copy/constants/REPEAT.mdx | 18 + .../en/p5 copy/constants/REPLACE.mdx | 18 + .../reference/en/p5 copy/constants/RETURN.mdx | 18 + .../reference/en/p5 copy/constants/RGB.mdx | 18 + .../reference/en/p5 copy/constants/RGBA.mdx | 18 + .../reference/en/p5 copy/constants/RIGHT.mdx | 18 + .../en/p5 copy/constants/RIGHT_ARROW.mdx | 18 + .../reference/en/p5 copy/constants/ROUND.mdx | 18 + .../reference/en/p5 copy/constants/SCREEN.mdx | 18 + .../reference/en/p5 copy/constants/SHIFT.mdx | 18 + .../reference/en/p5 copy/constants/SMOOTH.mdx | 18 + .../en/p5 copy/constants/SOFT_LIGHT.mdx | 18 + .../reference/en/p5 copy/constants/SQUARE.mdx | 18 + .../reference/en/p5 copy/constants/STROKE.mdx | 18 + .../en/p5 copy/constants/SUBTRACT.mdx | 18 + .../reference/en/p5 copy/constants/TAB.mdx | 18 + .../reference/en/p5 copy/constants/TAU.mdx | 114 +++ .../reference/en/p5 copy/constants/TESS.mdx | 18 + .../reference/en/p5 copy/constants/TEXT.mdx | 18 + .../en/p5 copy/constants/TEXTURE.mdx | 18 + .../en/p5 copy/constants/THRESHOLD.mdx | 18 + .../reference/en/p5 copy/constants/TOP.mdx | 18 + .../en/p5 copy/constants/TRIANGLES.mdx | 18 + .../en/p5 copy/constants/TRIANGLE_FAN.mdx | 18 + .../en/p5 copy/constants/TRIANGLE_STRIP.mdx | 18 + .../reference/en/p5 copy/constants/TWO_PI.mdx | 114 +++ .../en/p5 copy/constants/UNSIGNED_BYTE.mdx | 18 + .../en/p5 copy/constants/UNSIGNED_INT.mdx | 18 + .../en/p5 copy/constants/UP_ARROW.mdx | 18 + .../en/p5 copy/constants/VERSION.mdx | 19 + .../reference/en/p5 copy/constants/WAIT.mdx | 18 + .../reference/en/p5 copy/constants/WEBGL.mdx | 91 ++ .../reference/en/p5 copy/constants/WEBGL2.mdx | 21 + .../reference/en/p5 copy/constants/WORD.mdx | 18 + .../reference/en/p5 copy/constrain.mdx | 86 ++ src/content/reference/en/p5 copy/copy.mdx | 144 ++++ src/content/reference/en/p5 copy/cos.mdx | 107 +++ src/content/reference/en/p5 copy/createA.mdx | 93 ++ .../reference/en/p5 copy/createAudio.mdx | 83 ++ .../reference/en/p5 copy/createButton.mdx | 109 +++ .../reference/en/p5 copy/createCamera.mdx | 99 +++ .../reference/en/p5 copy/createCanvas.mdx | 191 +++++ .../reference/en/p5 copy/createCapture.mdx | 189 +++++ .../reference/en/p5 copy/createCheckbox.mdx | 131 +++ .../en/p5 copy/createColorPicker.mdx | 101 +++ .../reference/en/p5 copy/createConvolver.mdx | 78 ++ .../reference/en/p5 copy/createDiv.mdx | 72 ++ .../reference/en/p5 copy/createElement.mdx | 78 ++ .../reference/en/p5 copy/createFileInput.mdx | 138 +++ .../en/p5 copy/createFilterShader.mdx | 148 ++++ .../en/p5 copy/createFramebuffer.mdx | 208 +++++ .../reference/en/p5 copy/createGraphics.mdx | 191 +++++ .../reference/en/p5 copy/createImage.mdx | 172 ++++ .../reference/en/p5 copy/createImg.mdx | 115 +++ .../reference/en/p5 copy/createInput.mdx | 118 +++ .../reference/en/p5 copy/createModel.mdx | 193 +++++ .../reference/en/p5 copy/createNumberDict.mdx | 57 ++ src/content/reference/en/p5 copy/createP.mdx | 54 ++ .../reference/en/p5 copy/createRadio.mdx | 223 +++++ .../reference/en/p5 copy/createSelect.mdx | 235 ++++++ .../reference/en/p5 copy/createShader.mdx | 438 ++++++++++ .../reference/en/p5 copy/createSlider.mdx | 162 ++++ .../reference/en/p5 copy/createSpan.mdx | 93 ++ .../reference/en/p5 copy/createStringDict.mdx | 56 ++ .../reference/en/p5 copy/createVector.mdx | 133 +++ .../reference/en/p5 copy/createVideo.mdx | 135 +++ .../reference/en/p5 copy/createWriter.mdx | 146 ++++ src/content/reference/en/p5 copy/cursor.mdx | 139 +++ src/content/reference/en/p5 copy/curve.mdx | 272 ++++++ .../reference/en/p5 copy/curveDetail.mdx | 117 +++ .../reference/en/p5 copy/curvePoint.mdx | 160 ++++ .../reference/en/p5 copy/curveTangent.mdx | 153 ++++ .../reference/en/p5 copy/curveTightness.mdx | 77 ++ .../reference/en/p5 copy/curveVertex.mdx | 407 +++++++++ src/content/reference/en/p5 copy/cylinder.mdx | 282 +++++++ src/content/reference/en/p5 copy/day.mdx | 47 ++ .../reference/en/p5 copy/debugMode.mdx | 362 ++++++++ src/content/reference/en/p5 copy/degrees.mdx | 53 ++ .../reference/en/p5 copy/deltaTime.mdx | 68 ++ src/content/reference/en/p5 copy/describe.mdx | 137 +++ .../reference/en/p5 copy/describeElement.mdx | 127 +++ .../reference/en/p5 copy/deviceMoved.mdx | 49 ++ .../en/p5 copy/deviceOrientation.mdx | 22 + .../reference/en/p5 copy/deviceShaken.mdx | 50 ++ .../reference/en/p5 copy/deviceTurned.mdx | 80 ++ .../reference/en/p5 copy/directionalLight.mdx | 277 ++++++ .../en/p5 copy/disableFriendlyErrors.mdx | 55 ++ .../reference/en/p5 copy/displayDensity.mdx | 55 ++ .../reference/en/p5 copy/displayHeight.mdx | 47 ++ .../reference/en/p5 copy/displayWidth.mdx | 47 ++ src/content/reference/en/p5 copy/dist.mdx | 121 +++ .../reference/en/p5 copy/doubleClicked.mdx | 157 ++++ src/content/reference/en/p5 copy/draw.mdx | 129 +++ .../reference/en/p5 copy/drawingContext.mdx | 78 ++ src/content/reference/en/p5 copy/ellipse.mdx | 164 ++++ .../reference/en/p5 copy/ellipseMode.mdx | 113 +++ .../reference/en/p5 copy/ellipsoid.mdx | 233 +++++ .../reference/en/p5 copy/emissiveMaterial.mdx | 140 ++++ src/content/reference/en/p5 copy/endClip.mdx | 43 + .../reference/en/p5 copy/endContour.mdx | 133 +++ .../reference/en/p5 copy/endGeometry.mdx | 285 +++++++ src/content/reference/en/p5 copy/endShape.mdx | 256 ++++++ src/content/reference/en/p5 copy/erase.mdx | 123 +++ .../reference/en/p5 copy/exitPointerLock.mdx | 82 ++ src/content/reference/en/p5 copy/exp.mdx | 83 ++ src/content/reference/en/p5 copy/fill.mdx | 312 +++++++ src/content/reference/en/p5 copy/filter.mdx | 330 ++++++++ src/content/reference/en/p5 copy/float.mdx | 116 +++ src/content/reference/en/p5 copy/floor.mdx | 57 ++ src/content/reference/en/p5 copy/focused.mdx | 50 ++ src/content/reference/en/p5 copy/for.mdx | 290 +++++++ src/content/reference/en/p5 copy/fract.mdx | 55 ++ .../reference/en/p5 copy/frameCount.mdx | 73 ++ .../reference/en/p5 copy/frameRate.mdx | 107 +++ .../reference/en/p5 copy/freeGeometry.mdx | 152 ++++ .../reference/en/p5 copy/freqToMidi.mdx | 29 + src/content/reference/en/p5 copy/frustum.mdx | 175 ++++ .../reference/en/p5 copy/fullscreen.mdx | 63 ++ src/content/reference/en/p5 copy/function.mdx | 19 + src/content/reference/en/p5 copy/get.mdx | 178 ++++ .../reference/en/p5 copy/getAudioContext.mdx | 56 ++ src/content/reference/en/p5 copy/getItem.mdx | 151 ++++ .../reference/en/p5 copy/getOutputVolume.mdx | 25 + .../en/p5 copy/getTargetFrameRate.mdx | 48 ++ src/content/reference/en/p5 copy/getURL.mdx | 46 + .../reference/en/p5 copy/getURLParams.mdx | 59 ++ .../reference/en/p5 copy/getURLPath.mdx | 58 ++ src/content/reference/en/p5 copy/green.mdx | 159 ++++ .../reference/en/p5 copy/gridOutput.mdx | 189 +++++ src/content/reference/en/p5 copy/height.mdx | 87 ++ src/content/reference/en/p5 copy/hex.mdx | 166 ++++ src/content/reference/en/p5 copy/hour.mdx | 47 ++ src/content/reference/en/p5 copy/httpDo.mdx | 150 ++++ src/content/reference/en/p5 copy/httpGet.mdx | 140 ++++ src/content/reference/en/p5 copy/httpPost.mdx | 165 ++++ src/content/reference/en/p5 copy/hue.mdx | 145 ++++ src/content/reference/en/p5 copy/if.mdx | 268 ++++++ src/content/reference/en/p5 copy/image.mdx | 327 ++++++++ .../reference/en/p5 copy/imageLight.mdx | 86 ++ .../reference/en/p5 copy/imageMode.mdx | 129 +++ src/content/reference/en/p5 copy/input.mdx | 88 ++ src/content/reference/en/p5 copy/int.mdx | 169 ++++ .../reference/en/p5 copy/isLooping.mdx | 65 ++ src/content/reference/en/p5 copy/join.mdx | 70 ++ src/content/reference/en/p5 copy/key.mdx | 106 +++ src/content/reference/en/p5 copy/keyCode.mdx | 128 +++ .../reference/en/p5 copy/keyIsDown.mdx | 142 ++++ .../reference/en/p5 copy/keyIsPressed.mdx | 105 +++ .../reference/en/p5 copy/keyPressed.mdx | 192 +++++ .../reference/en/p5 copy/keyReleased.mdx | 188 +++++ src/content/reference/en/p5 copy/keyTyped.mdx | 170 ++++ src/content/reference/en/p5 copy/lerp.mdx | 122 +++ .../reference/en/p5 copy/lerpColor.mdx | 96 +++ src/content/reference/en/p5 copy/let.mdx | 91 ++ .../reference/en/p5 copy/lightFalloff.mdx | 100 +++ .../reference/en/p5 copy/lightness.mdx | 168 ++++ src/content/reference/en/p5 copy/lights.mdx | 88 ++ src/content/reference/en/p5 copy/line.mdx | 194 +++++ .../reference/en/p5 copy/linePerspective.mdx | 164 ++++ .../reference/en/p5 copy/loadBytes.mdx | 56 ++ src/content/reference/en/p5 copy/loadFont.mdx | 171 ++++ .../reference/en/p5 copy/loadImage.mdx | 137 +++ src/content/reference/en/p5 copy/loadJSON.mdx | 288 +++++++ .../reference/en/p5 copy/loadModel.mdx | 469 +++++++++++ .../reference/en/p5 copy/loadPixels.mdx | 61 ++ .../reference/en/p5 copy/loadShader.mdx | 172 ++++ .../reference/en/p5 copy/loadSound.mdx | 78 ++ .../reference/en/p5 copy/loadStrings.mdx | 188 +++++ .../reference/en/p5 copy/loadTable.mdx | 124 +++ src/content/reference/en/p5 copy/loadXML.mdx | 220 +++++ src/content/reference/en/p5 copy/log.mdx | 79 ++ src/content/reference/en/p5 copy/loop.mdx | 111 +++ src/content/reference/en/p5 copy/mag.mdx | 84 ++ src/content/reference/en/p5 copy/map.mdx | 119 +++ src/content/reference/en/p5 copy/match.mdx | 91 ++ src/content/reference/en/p5 copy/matchAll.mdx | 107 +++ src/content/reference/en/p5 copy/max.mdx | 104 +++ .../reference/en/p5 copy/metalness.mdx | 142 ++++ .../reference/en/p5 copy/midiToFreq.mdx | 66 ++ src/content/reference/en/p5 copy/millis.mdx | 147 ++++ src/content/reference/en/p5 copy/min.mdx | 104 +++ src/content/reference/en/p5 copy/minute.mdx | 47 ++ src/content/reference/en/p5 copy/model.mdx | 155 ++++ src/content/reference/en/p5 copy/month.mdx | 47 ++ .../reference/en/p5 copy/mouseButton.mdx | 87 ++ .../reference/en/p5 copy/mouseClicked.mdx | 196 +++++ .../reference/en/p5 copy/mouseDragged.mdx | 130 +++ .../reference/en/p5 copy/mouseIsPressed.mdx | 73 ++ .../reference/en/p5 copy/mouseMoved.mdx | 118 +++ .../reference/en/p5 copy/mousePressed.mdx | 193 +++++ .../reference/en/p5 copy/mouseReleased.mdx | 195 +++++ .../reference/en/p5 copy/mouseWheel.mdx | 162 ++++ src/content/reference/en/p5 copy/mouseX.mdx | 124 +++ src/content/reference/en/p5 copy/mouseY.mdx | 124 +++ src/content/reference/en/p5 copy/movedX.mdx | 78 ++ src/content/reference/en/p5 copy/movedY.mdx | 78 ++ src/content/reference/en/p5 copy/nf.mdx | 159 ++++ src/content/reference/en/p5 copy/nfc.mdx | 153 ++++ src/content/reference/en/p5 copy/nfp.mdx | 188 +++++ src/content/reference/en/p5 copy/nfs.mdx | 176 ++++ src/content/reference/en/p5 copy/noCanvas.mdx | 36 + src/content/reference/en/p5 copy/noCursor.mdx | 38 + .../reference/en/p5 copy/noDebugMode.mdx | 54 ++ src/content/reference/en/p5 copy/noErase.mdx | 55 ++ src/content/reference/en/p5 copy/noFill.mdx | 73 ++ src/content/reference/en/p5 copy/noLights.mdx | 79 ++ src/content/reference/en/p5 copy/noLoop.mdx | 139 +++ src/content/reference/en/p5 copy/noSmooth.mdx | 92 ++ src/content/reference/en/p5 copy/noStroke.mdx | 71 ++ src/content/reference/en/p5 copy/noTint.mdx | 51 ++ src/content/reference/en/p5 copy/noise.mdx | 282 +++++++ .../reference/en/p5 copy/noiseDetail.mdx | 100 +++ .../reference/en/p5 copy/noiseSeed.mdx | 68 ++ src/content/reference/en/p5 copy/norm.mdx | 69 ++ src/content/reference/en/p5 copy/normal.mdx | 250 ++++++ .../reference/en/p5 copy/normalMaterial.mdx | 55 ++ .../reference/en/p5 copy/orbitControl.mdx | 203 +++++ src/content/reference/en/p5 copy/ortho.mdx | 168 ++++ .../reference/en/p5 copy/outputVolume.mdx | 51 ++ .../reference/en/p5 copy/p5.Camera.mdx | 659 +++++++++++++++ src/content/reference/en/p5 copy/p5.Color.mdx | 116 +++ .../reference/en/p5 copy/p5.Element.mdx | 545 ++++++++++++ src/content/reference/en/p5 copy/p5.File.mdx | 153 ++++ src/content/reference/en/p5 copy/p5.Font.mdx | 146 ++++ .../reference/en/p5 copy/p5.Framebuffer.mdx | 443 ++++++++++ .../reference/en/p5 copy/p5.Geometry.mdx | 793 ++++++++++++++++++ .../reference/en/p5 copy/p5.Graphics.mdx | 261 ++++++ src/content/reference/en/p5 copy/p5.Image.mdx | 519 ++++++++++++ .../reference/en/p5 copy/p5.MediaElement.mdx | 258 ++++++ .../reference/en/p5 copy/p5.NumberDict.mdx | 63 ++ .../reference/en/p5 copy/p5.PrintWriter.mdx | 35 + .../reference/en/p5 copy/p5.Renderer.mdx | 34 + .../reference/en/p5 copy/p5.Shader.mdx | 433 ++++++++++ .../reference/en/p5 copy/p5.StringDict.mdx | 15 + src/content/reference/en/p5 copy/p5.Table.mdx | 213 +++++ .../reference/en/p5 copy/p5.TableRow.mdx | 66 ++ .../reference/en/p5 copy/p5.TypedDict.mdx | 66 ++ .../reference/en/p5 copy/p5.Vector.mdx | 673 +++++++++++++++ src/content/reference/en/p5 copy/p5.XML.mdx | 321 +++++++ src/content/reference/en/p5 copy/p5.mdx | 51 ++ .../reference/en/p5 copy/pAccelerationX.mdx | 21 + .../reference/en/p5 copy/pAccelerationY.mdx | 21 + .../reference/en/p5 copy/pAccelerationZ.mdx | 21 + .../reference/en/p5 copy/pRotationX.mdx | 63 ++ .../reference/en/p5 copy/pRotationY.mdx | 62 ++ .../reference/en/p5 copy/pRotationZ.mdx | 58 ++ .../reference/en/p5 copy/paletteLerp.mdx | 66 ++ src/content/reference/en/p5 copy/panorama.mdx | 76 ++ .../reference/en/p5 copy/perspective.mdx | 194 +++++ .../reference/en/p5 copy/pixelDensity.mdx | 90 ++ src/content/reference/en/p5 copy/pixels.mdx | 173 ++++ src/content/reference/en/p5 copy/plane.mdx | 152 ++++ src/content/reference/en/p5 copy/pmouseX.mdx | 88 ++ src/content/reference/en/p5 copy/pmouseY.mdx | 88 ++ src/content/reference/en/p5 copy/point.mdx | 229 +++++ .../reference/en/p5 copy/pointLight.mdx | 329 ++++++++ src/content/reference/en/p5 copy/pop.mdx | 20 + src/content/reference/en/p5 copy/pow.mdx | 67 ++ src/content/reference/en/p5 copy/preload.mdx | 70 ++ src/content/reference/en/p5 copy/print.mdx | 55 ++ src/content/reference/en/p5 copy/push.mdx | 20 + .../reference/en/p5 copy/pwinMouseX.mdx | 99 +++ .../reference/en/p5 copy/pwinMouseY.mdx | 99 +++ src/content/reference/en/p5 copy/quad.mdx | 233 +++++ .../reference/en/p5 copy/quadraticVertex.mdx | 303 +++++++ src/content/reference/en/p5 copy/radians.mdx | 53 ++ src/content/reference/en/p5 copy/random.mdx | 48 ++ .../reference/en/p5 copy/randomGaussian.mdx | 104 +++ .../reference/en/p5 copy/randomSeed.mdx | 71 ++ src/content/reference/en/p5 copy/rect.mdx | 209 +++++ src/content/reference/en/p5 copy/rectMode.mdx | 142 ++++ src/content/reference/en/p5 copy/red.mdx | 158 ++++ src/content/reference/en/p5 copy/redraw.mdx | 117 +++ src/content/reference/en/p5 copy/remove.mdx | 57 ++ .../reference/en/p5 copy/removeElements.mdx | 85 ++ .../reference/en/p5 copy/removeItem.mdx | 97 +++ .../en/p5 copy/requestPointerLock.mdx | 85 ++ .../reference/en/p5 copy/resetMatrix.mdx | 52 ++ .../reference/en/p5 copy/resetShader.mdx | 95 +++ .../reference/en/p5 copy/resizeCanvas.mdx | 133 +++ src/content/reference/en/p5 copy/reverse.mdx | 43 + src/content/reference/en/p5 copy/rotate.mdx | 226 +++++ src/content/reference/en/p5 copy/rotateX.mdx | 161 ++++ src/content/reference/en/p5 copy/rotateY.mdx | 161 ++++ src/content/reference/en/p5 copy/rotateZ.mdx | 161 ++++ .../reference/en/p5 copy/rotationX.mdx | 45 + .../reference/en/p5 copy/rotationY.mdx | 45 + .../reference/en/p5 copy/rotationZ.mdx | 47 ++ src/content/reference/en/p5 copy/round.mdx | 88 ++ .../reference/en/p5 copy/sampleRate.mdx | 26 + .../reference/en/p5 copy/saturation.mdx | 201 +++++ src/content/reference/en/p5 copy/save.mdx | 140 ++++ .../reference/en/p5 copy/saveCanvas.mdx | 166 ++++ .../reference/en/p5 copy/saveFrames.mdx | 175 ++++ src/content/reference/en/p5 copy/saveGif.mdx | 119 +++ src/content/reference/en/p5 copy/saveJSON.mdx | 170 ++++ .../reference/en/p5 copy/saveSound.mdx | 35 + .../reference/en/p5 copy/saveStrings.mdx | 185 ++++ .../reference/en/p5 copy/saveTable.mdx | 70 ++ src/content/reference/en/p5 copy/scale.mdx | 231 +++++ src/content/reference/en/p5 copy/second.mdx | 47 ++ src/content/reference/en/p5 copy/select.mdx | 113 +++ .../reference/en/p5 copy/selectAll.mdx | 121 +++ src/content/reference/en/p5 copy/set.mdx | 157 ++++ .../reference/en/p5 copy/setAttributes.mdx | 163 ++++ src/content/reference/en/p5 copy/setBPM.mdx | 29 + .../reference/en/p5 copy/setCamera.mdx | 81 ++ .../reference/en/p5 copy/setMoveThreshold.mdx | 59 ++ .../en/p5 copy/setShakeThreshold.mdx | 59 ++ src/content/reference/en/p5 copy/setup.mdx | 111 +++ src/content/reference/en/p5 copy/shader.mdx | 244 ++++++ src/content/reference/en/p5 copy/shearX.mdx | 105 +++ src/content/reference/en/p5 copy/shearY.mdx | 105 +++ .../reference/en/p5 copy/shininess.mdx | 86 ++ src/content/reference/en/p5 copy/shorten.mdx | 44 + src/content/reference/en/p5 copy/shuffle.mdx | 132 +++ src/content/reference/en/p5 copy/sin.mdx | 107 +++ src/content/reference/en/p5 copy/smooth.mdx | 94 +++ src/content/reference/en/p5 copy/sort.mdx | 63 ++ .../reference/en/p5 copy/soundFormats.mdx | 51 ++ src/content/reference/en/p5 copy/soundOut.mdx | 26 + .../reference/en/p5 copy/specularColor.mdx | 308 +++++++ .../reference/en/p5 copy/specularMaterial.mdx | 311 +++++++ src/content/reference/en/p5 copy/sphere.mdx | 165 ++++ src/content/reference/en/p5 copy/splice.mdx | 58 ++ src/content/reference/en/p5 copy/split.mdx | 87 ++ .../reference/en/p5 copy/splitTokens.mdx | 180 ++++ .../reference/en/p5 copy/spotLight.mdx | 398 +++++++++ src/content/reference/en/p5 copy/sq.mdx | 83 ++ src/content/reference/en/p5 copy/sqrt.mdx | 84 ++ src/content/reference/en/p5 copy/square.mdx | 163 ++++ .../reference/en/p5 copy/storeItem.mdx | 149 ++++ src/content/reference/en/p5 copy/str.mdx | 135 +++ src/content/reference/en/p5 copy/stroke.mdx | 311 +++++++ .../reference/en/p5 copy/strokeCap.mdx | 67 ++ .../reference/en/p5 copy/strokeJoin.mdx | 114 +++ .../reference/en/p5 copy/strokeWeight.mdx | 77 ++ src/content/reference/en/p5 copy/subset.mdx | 59 ++ src/content/reference/en/p5 copy/tan.mdx | 66 ++ src/content/reference/en/p5 copy/text.mdx | 96 +++ .../reference/en/p5 copy/textAlign.mdx | 135 +++ .../reference/en/p5 copy/textAscent.mdx | 71 ++ .../reference/en/p5 copy/textDescent.mdx | 71 ++ src/content/reference/en/p5 copy/textFont.mdx | 127 +++ .../reference/en/p5 copy/textLeading.mdx | 63 ++ .../reference/en/p5 copy/textOutput.mdx | 186 ++++ src/content/reference/en/p5 copy/textSize.mdx | 65 ++ .../reference/en/p5 copy/textStyle.mdx | 79 ++ .../reference/en/p5 copy/textWidth.mdx | 83 ++ src/content/reference/en/p5 copy/textWrap.mdx | 111 +++ src/content/reference/en/p5 copy/texture.mdx | 207 +++++ .../reference/en/p5 copy/textureMode.mdx | 254 ++++++ .../reference/en/p5 copy/textureWrap.mdx | 370 ++++++++ src/content/reference/en/p5 copy/tint.mdx | 201 +++++ src/content/reference/en/p5 copy/torus.mdx | 200 +++++ .../reference/en/p5 copy/touchEnded.mdx | 196 +++++ .../reference/en/p5 copy/touchMoved.mdx | 198 +++++ .../reference/en/p5 copy/touchStarted.mdx | 197 +++++ src/content/reference/en/p5 copy/touches.mdx | 102 +++ .../reference/en/p5 copy/translate.mdx | 241 ++++++ src/content/reference/en/p5 copy/triangle.mdx | 104 +++ src/content/reference/en/p5 copy/trim.mdx | 113 +++ src/content/reference/en/p5 copy/turnAxis.mdx | 54 ++ .../reference/en/p5 copy/types/Array.mdx | 269 ++++++ .../reference/en/p5 copy/types/Boolean.mdx | 273 ++++++ .../reference/en/p5 copy/types/Number.mdx | 201 +++++ .../reference/en/p5 copy/types/Object.mdx | 91 ++ .../reference/en/p5 copy/types/String.mdx | 153 ++++ src/content/reference/en/p5 copy/unchar.mdx | 114 +++ src/content/reference/en/p5 copy/unhex.mdx | 121 +++ .../reference/en/p5 copy/updatePixels.mdx | 94 +++ .../reference/en/p5 copy/userStartAudio.mdx | 99 +++ src/content/reference/en/p5 copy/vertex.mdx | 242 ++++++ .../reference/en/p5 copy/webglVersion.mdx | 105 +++ src/content/reference/en/p5 copy/while.mdx | 161 ++++ src/content/reference/en/p5 copy/width.mdx | 87 ++ .../reference/en/p5 copy/winMouseX.mdx | 61 ++ .../reference/en/p5 copy/winMouseY.mdx | 61 ++ .../reference/en/p5 copy/windowHeight.mdx | 43 + .../reference/en/p5 copy/windowResized.mdx | 64 ++ .../reference/en/p5 copy/windowWidth.mdx | 43 + src/content/reference/en/p5 copy/year.mdx | 47 ++ 523 files changed, 60155 insertions(+), 15 deletions(-) create mode 100644 src/content/reference/en/p5 copy/abs.mdx create mode 100644 src/content/reference/en/p5 copy/accelerationX.mdx create mode 100644 src/content/reference/en/p5 copy/accelerationY.mdx create mode 100644 src/content/reference/en/p5 copy/accelerationZ.mdx create mode 100644 src/content/reference/en/p5 copy/acos.mdx create mode 100644 src/content/reference/en/p5 copy/alpha.mdx create mode 100644 src/content/reference/en/p5 copy/ambientLight.mdx create mode 100644 src/content/reference/en/p5 copy/ambientMaterial.mdx create mode 100644 src/content/reference/en/p5 copy/angleMode.mdx create mode 100644 src/content/reference/en/p5 copy/append.mdx create mode 100644 src/content/reference/en/p5 copy/applyMatrix.mdx create mode 100644 src/content/reference/en/p5 copy/arc.mdx create mode 100644 src/content/reference/en/p5 copy/arrayCopy.mdx create mode 100644 src/content/reference/en/p5 copy/asin.mdx create mode 100644 src/content/reference/en/p5 copy/atan.mdx create mode 100644 src/content/reference/en/p5 copy/atan2.mdx create mode 100644 src/content/reference/en/p5 copy/background.mdx create mode 100644 src/content/reference/en/p5 copy/baseColorShader.mdx create mode 100644 src/content/reference/en/p5 copy/baseMaterialShader.mdx create mode 100644 src/content/reference/en/p5 copy/baseNormalShader.mdx create mode 100644 src/content/reference/en/p5 copy/baseStrokeShader.mdx create mode 100644 src/content/reference/en/p5 copy/beginClip.mdx create mode 100644 src/content/reference/en/p5 copy/beginContour.mdx create mode 100644 src/content/reference/en/p5 copy/beginGeometry.mdx create mode 100644 src/content/reference/en/p5 copy/beginShape.mdx create mode 100644 src/content/reference/en/p5 copy/bezier.mdx create mode 100644 src/content/reference/en/p5 copy/bezierDetail.mdx create mode 100644 src/content/reference/en/p5 copy/bezierPoint.mdx create mode 100644 src/content/reference/en/p5 copy/bezierTangent.mdx create mode 100644 src/content/reference/en/p5 copy/bezierVertex.mdx create mode 100644 src/content/reference/en/p5 copy/blend.mdx create mode 100644 src/content/reference/en/p5 copy/blendMode.mdx create mode 100644 src/content/reference/en/p5 copy/blue.mdx create mode 100644 src/content/reference/en/p5 copy/boolean.mdx create mode 100644 src/content/reference/en/p5 copy/box.mdx create mode 100644 src/content/reference/en/p5 copy/brightness.mdx create mode 100644 src/content/reference/en/p5 copy/buildGeometry.mdx create mode 100644 src/content/reference/en/p5 copy/byte.mdx create mode 100644 src/content/reference/en/p5 copy/camera.mdx create mode 100644 src/content/reference/en/p5 copy/ceil.mdx create mode 100644 src/content/reference/en/p5 copy/changed.mdx create mode 100644 src/content/reference/en/p5 copy/char.mdx create mode 100644 src/content/reference/en/p5 copy/circle.mdx create mode 100644 src/content/reference/en/p5 copy/class.mdx create mode 100644 src/content/reference/en/p5 copy/clear.mdx create mode 100644 src/content/reference/en/p5 copy/clearDepth.mdx create mode 100644 src/content/reference/en/p5 copy/clearStorage.mdx create mode 100644 src/content/reference/en/p5 copy/clip.mdx create mode 100644 src/content/reference/en/p5 copy/color.mdx create mode 100644 src/content/reference/en/p5 copy/colorMode.mdx create mode 100644 src/content/reference/en/p5 copy/concat.mdx create mode 100644 src/content/reference/en/p5 copy/cone.mdx create mode 100644 src/content/reference/en/p5 copy/console.mdx create mode 100644 src/content/reference/en/p5 copy/constants/ADD.mdx create mode 100644 src/content/reference/en/p5 copy/constants/ALT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/ARROW.mdx create mode 100644 src/content/reference/en/p5 copy/constants/AUTO.mdx create mode 100644 src/content/reference/en/p5 copy/constants/AXES.mdx create mode 100644 src/content/reference/en/p5 copy/constants/BACKSPACE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/BASELINE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/BEVEL.mdx create mode 100644 src/content/reference/en/p5 copy/constants/BEZIER.mdx create mode 100644 src/content/reference/en/p5 copy/constants/BLEND.mdx create mode 100644 src/content/reference/en/p5 copy/constants/BLUR.mdx create mode 100644 src/content/reference/en/p5 copy/constants/BOLD.mdx create mode 100644 src/content/reference/en/p5 copy/constants/BOLDITALIC.mdx create mode 100644 src/content/reference/en/p5 copy/constants/BOTTOM.mdx create mode 100644 src/content/reference/en/p5 copy/constants/BURN.mdx create mode 100644 src/content/reference/en/p5 copy/constants/CENTER.mdx create mode 100644 src/content/reference/en/p5 copy/constants/CHAR.mdx create mode 100644 src/content/reference/en/p5 copy/constants/CHORD.mdx create mode 100644 src/content/reference/en/p5 copy/constants/CLAMP.mdx create mode 100644 src/content/reference/en/p5 copy/constants/CLOSE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/CONTAIN.mdx create mode 100644 src/content/reference/en/p5 copy/constants/CONTROL.mdx create mode 100644 src/content/reference/en/p5 copy/constants/CORNER.mdx create mode 100644 src/content/reference/en/p5 copy/constants/CORNERS.mdx create mode 100644 src/content/reference/en/p5 copy/constants/COVER.mdx create mode 100644 src/content/reference/en/p5 copy/constants/CROSS.mdx create mode 100644 src/content/reference/en/p5 copy/constants/CURVE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/DARKEST.mdx create mode 100644 src/content/reference/en/p5 copy/constants/DEGREES.mdx create mode 100644 src/content/reference/en/p5 copy/constants/DELETE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/DIFFERENCE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/DILATE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/DODGE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/DOWN_ARROW.mdx create mode 100644 src/content/reference/en/p5 copy/constants/ENTER.mdx create mode 100644 src/content/reference/en/p5 copy/constants/ERODE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/ESCAPE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/EXCLUSION.mdx create mode 100644 src/content/reference/en/p5 copy/constants/FALLBACK.mdx create mode 100644 src/content/reference/en/p5 copy/constants/FILL.mdx create mode 100644 src/content/reference/en/p5 copy/constants/FLAT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/FLOAT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/GRAY.mdx create mode 100644 src/content/reference/en/p5 copy/constants/GRID.mdx create mode 100644 src/content/reference/en/p5 copy/constants/HALF_FLOAT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/HALF_PI.mdx create mode 100644 src/content/reference/en/p5 copy/constants/HAND.mdx create mode 100644 src/content/reference/en/p5 copy/constants/HARD_LIGHT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/HSB.mdx create mode 100644 src/content/reference/en/p5 copy/constants/HSL.mdx create mode 100644 src/content/reference/en/p5 copy/constants/IMAGE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/IMMEDIATE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/INVERT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/ITALIC.mdx create mode 100644 src/content/reference/en/p5 copy/constants/LABEL.mdx create mode 100644 src/content/reference/en/p5 copy/constants/LANDSCAPE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/LEFT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/LEFT_ARROW.mdx create mode 100644 src/content/reference/en/p5 copy/constants/LIGHTEST.mdx create mode 100644 src/content/reference/en/p5 copy/constants/LINEAR.mdx create mode 100644 src/content/reference/en/p5 copy/constants/LINES.mdx create mode 100644 src/content/reference/en/p5 copy/constants/LINE_LOOP.mdx create mode 100644 src/content/reference/en/p5 copy/constants/LINE_STRIP.mdx create mode 100644 src/content/reference/en/p5 copy/constants/MIRROR.mdx create mode 100644 src/content/reference/en/p5 copy/constants/MITER.mdx create mode 100644 src/content/reference/en/p5 copy/constants/MOVE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/MULTIPLY.mdx create mode 100644 src/content/reference/en/p5 copy/constants/NEAREST.mdx create mode 100644 src/content/reference/en/p5 copy/constants/NORMAL.mdx create mode 100644 src/content/reference/en/p5 copy/constants/OPAQUE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/OPEN.mdx create mode 100644 src/content/reference/en/p5 copy/constants/OPTION.mdx create mode 100644 src/content/reference/en/p5 copy/constants/OVERLAY.mdx create mode 100644 src/content/reference/en/p5 copy/constants/P2D.mdx create mode 100644 src/content/reference/en/p5 copy/constants/PI.mdx create mode 100644 src/content/reference/en/p5 copy/constants/PIE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/POINTS.mdx create mode 100644 src/content/reference/en/p5 copy/constants/PORTRAIT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/POSTERIZE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/PROJECT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/QUADRATIC.mdx create mode 100644 src/content/reference/en/p5 copy/constants/QUADS.mdx create mode 100644 src/content/reference/en/p5 copy/constants/QUAD_STRIP.mdx create mode 100644 src/content/reference/en/p5 copy/constants/QUARTER_PI.mdx create mode 100644 src/content/reference/en/p5 copy/constants/RADIANS.mdx create mode 100644 src/content/reference/en/p5 copy/constants/RADIUS.mdx create mode 100644 src/content/reference/en/p5 copy/constants/REMOVE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/REPEAT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/REPLACE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/RETURN.mdx create mode 100644 src/content/reference/en/p5 copy/constants/RGB.mdx create mode 100644 src/content/reference/en/p5 copy/constants/RGBA.mdx create mode 100644 src/content/reference/en/p5 copy/constants/RIGHT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/RIGHT_ARROW.mdx create mode 100644 src/content/reference/en/p5 copy/constants/ROUND.mdx create mode 100644 src/content/reference/en/p5 copy/constants/SCREEN.mdx create mode 100644 src/content/reference/en/p5 copy/constants/SHIFT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/SMOOTH.mdx create mode 100644 src/content/reference/en/p5 copy/constants/SOFT_LIGHT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/SQUARE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/STROKE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/SUBTRACT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/TAB.mdx create mode 100644 src/content/reference/en/p5 copy/constants/TAU.mdx create mode 100644 src/content/reference/en/p5 copy/constants/TESS.mdx create mode 100644 src/content/reference/en/p5 copy/constants/TEXT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/TEXTURE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/THRESHOLD.mdx create mode 100644 src/content/reference/en/p5 copy/constants/TOP.mdx create mode 100644 src/content/reference/en/p5 copy/constants/TRIANGLES.mdx create mode 100644 src/content/reference/en/p5 copy/constants/TRIANGLE_FAN.mdx create mode 100644 src/content/reference/en/p5 copy/constants/TRIANGLE_STRIP.mdx create mode 100644 src/content/reference/en/p5 copy/constants/TWO_PI.mdx create mode 100644 src/content/reference/en/p5 copy/constants/UNSIGNED_BYTE.mdx create mode 100644 src/content/reference/en/p5 copy/constants/UNSIGNED_INT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/UP_ARROW.mdx create mode 100644 src/content/reference/en/p5 copy/constants/VERSION.mdx create mode 100644 src/content/reference/en/p5 copy/constants/WAIT.mdx create mode 100644 src/content/reference/en/p5 copy/constants/WEBGL.mdx create mode 100644 src/content/reference/en/p5 copy/constants/WEBGL2.mdx create mode 100644 src/content/reference/en/p5 copy/constants/WORD.mdx create mode 100644 src/content/reference/en/p5 copy/constrain.mdx create mode 100644 src/content/reference/en/p5 copy/copy.mdx create mode 100644 src/content/reference/en/p5 copy/cos.mdx create mode 100644 src/content/reference/en/p5 copy/createA.mdx create mode 100644 src/content/reference/en/p5 copy/createAudio.mdx create mode 100644 src/content/reference/en/p5 copy/createButton.mdx create mode 100644 src/content/reference/en/p5 copy/createCamera.mdx create mode 100644 src/content/reference/en/p5 copy/createCanvas.mdx create mode 100644 src/content/reference/en/p5 copy/createCapture.mdx create mode 100644 src/content/reference/en/p5 copy/createCheckbox.mdx create mode 100644 src/content/reference/en/p5 copy/createColorPicker.mdx create mode 100644 src/content/reference/en/p5 copy/createConvolver.mdx create mode 100644 src/content/reference/en/p5 copy/createDiv.mdx create mode 100644 src/content/reference/en/p5 copy/createElement.mdx create mode 100644 src/content/reference/en/p5 copy/createFileInput.mdx create mode 100644 src/content/reference/en/p5 copy/createFilterShader.mdx create mode 100644 src/content/reference/en/p5 copy/createFramebuffer.mdx create mode 100644 src/content/reference/en/p5 copy/createGraphics.mdx create mode 100644 src/content/reference/en/p5 copy/createImage.mdx create mode 100644 src/content/reference/en/p5 copy/createImg.mdx create mode 100644 src/content/reference/en/p5 copy/createInput.mdx create mode 100644 src/content/reference/en/p5 copy/createModel.mdx create mode 100644 src/content/reference/en/p5 copy/createNumberDict.mdx create mode 100644 src/content/reference/en/p5 copy/createP.mdx create mode 100644 src/content/reference/en/p5 copy/createRadio.mdx create mode 100644 src/content/reference/en/p5 copy/createSelect.mdx create mode 100644 src/content/reference/en/p5 copy/createShader.mdx create mode 100644 src/content/reference/en/p5 copy/createSlider.mdx create mode 100644 src/content/reference/en/p5 copy/createSpan.mdx create mode 100644 src/content/reference/en/p5 copy/createStringDict.mdx create mode 100644 src/content/reference/en/p5 copy/createVector.mdx create mode 100644 src/content/reference/en/p5 copy/createVideo.mdx create mode 100644 src/content/reference/en/p5 copy/createWriter.mdx create mode 100644 src/content/reference/en/p5 copy/cursor.mdx create mode 100644 src/content/reference/en/p5 copy/curve.mdx create mode 100644 src/content/reference/en/p5 copy/curveDetail.mdx create mode 100644 src/content/reference/en/p5 copy/curvePoint.mdx create mode 100644 src/content/reference/en/p5 copy/curveTangent.mdx create mode 100644 src/content/reference/en/p5 copy/curveTightness.mdx create mode 100644 src/content/reference/en/p5 copy/curveVertex.mdx create mode 100644 src/content/reference/en/p5 copy/cylinder.mdx create mode 100644 src/content/reference/en/p5 copy/day.mdx create mode 100644 src/content/reference/en/p5 copy/debugMode.mdx create mode 100644 src/content/reference/en/p5 copy/degrees.mdx create mode 100644 src/content/reference/en/p5 copy/deltaTime.mdx create mode 100644 src/content/reference/en/p5 copy/describe.mdx create mode 100644 src/content/reference/en/p5 copy/describeElement.mdx create mode 100644 src/content/reference/en/p5 copy/deviceMoved.mdx create mode 100644 src/content/reference/en/p5 copy/deviceOrientation.mdx create mode 100644 src/content/reference/en/p5 copy/deviceShaken.mdx create mode 100644 src/content/reference/en/p5 copy/deviceTurned.mdx create mode 100644 src/content/reference/en/p5 copy/directionalLight.mdx create mode 100644 src/content/reference/en/p5 copy/disableFriendlyErrors.mdx create mode 100644 src/content/reference/en/p5 copy/displayDensity.mdx create mode 100644 src/content/reference/en/p5 copy/displayHeight.mdx create mode 100644 src/content/reference/en/p5 copy/displayWidth.mdx create mode 100644 src/content/reference/en/p5 copy/dist.mdx create mode 100644 src/content/reference/en/p5 copy/doubleClicked.mdx create mode 100644 src/content/reference/en/p5 copy/draw.mdx create mode 100644 src/content/reference/en/p5 copy/drawingContext.mdx create mode 100644 src/content/reference/en/p5 copy/ellipse.mdx create mode 100644 src/content/reference/en/p5 copy/ellipseMode.mdx create mode 100644 src/content/reference/en/p5 copy/ellipsoid.mdx create mode 100644 src/content/reference/en/p5 copy/emissiveMaterial.mdx create mode 100644 src/content/reference/en/p5 copy/endClip.mdx create mode 100644 src/content/reference/en/p5 copy/endContour.mdx create mode 100644 src/content/reference/en/p5 copy/endGeometry.mdx create mode 100644 src/content/reference/en/p5 copy/endShape.mdx create mode 100644 src/content/reference/en/p5 copy/erase.mdx create mode 100644 src/content/reference/en/p5 copy/exitPointerLock.mdx create mode 100644 src/content/reference/en/p5 copy/exp.mdx create mode 100644 src/content/reference/en/p5 copy/fill.mdx create mode 100644 src/content/reference/en/p5 copy/filter.mdx create mode 100644 src/content/reference/en/p5 copy/float.mdx create mode 100644 src/content/reference/en/p5 copy/floor.mdx create mode 100644 src/content/reference/en/p5 copy/focused.mdx create mode 100644 src/content/reference/en/p5 copy/for.mdx create mode 100644 src/content/reference/en/p5 copy/fract.mdx create mode 100644 src/content/reference/en/p5 copy/frameCount.mdx create mode 100644 src/content/reference/en/p5 copy/frameRate.mdx create mode 100644 src/content/reference/en/p5 copy/freeGeometry.mdx create mode 100644 src/content/reference/en/p5 copy/freqToMidi.mdx create mode 100644 src/content/reference/en/p5 copy/frustum.mdx create mode 100644 src/content/reference/en/p5 copy/fullscreen.mdx create mode 100644 src/content/reference/en/p5 copy/function.mdx create mode 100644 src/content/reference/en/p5 copy/get.mdx create mode 100644 src/content/reference/en/p5 copy/getAudioContext.mdx create mode 100644 src/content/reference/en/p5 copy/getItem.mdx create mode 100644 src/content/reference/en/p5 copy/getOutputVolume.mdx create mode 100644 src/content/reference/en/p5 copy/getTargetFrameRate.mdx create mode 100644 src/content/reference/en/p5 copy/getURL.mdx create mode 100644 src/content/reference/en/p5 copy/getURLParams.mdx create mode 100644 src/content/reference/en/p5 copy/getURLPath.mdx create mode 100644 src/content/reference/en/p5 copy/green.mdx create mode 100644 src/content/reference/en/p5 copy/gridOutput.mdx create mode 100644 src/content/reference/en/p5 copy/height.mdx create mode 100644 src/content/reference/en/p5 copy/hex.mdx create mode 100644 src/content/reference/en/p5 copy/hour.mdx create mode 100644 src/content/reference/en/p5 copy/httpDo.mdx create mode 100644 src/content/reference/en/p5 copy/httpGet.mdx create mode 100644 src/content/reference/en/p5 copy/httpPost.mdx create mode 100644 src/content/reference/en/p5 copy/hue.mdx create mode 100644 src/content/reference/en/p5 copy/if.mdx create mode 100644 src/content/reference/en/p5 copy/image.mdx create mode 100644 src/content/reference/en/p5 copy/imageLight.mdx create mode 100644 src/content/reference/en/p5 copy/imageMode.mdx create mode 100644 src/content/reference/en/p5 copy/input.mdx create mode 100644 src/content/reference/en/p5 copy/int.mdx create mode 100644 src/content/reference/en/p5 copy/isLooping.mdx create mode 100644 src/content/reference/en/p5 copy/join.mdx create mode 100644 src/content/reference/en/p5 copy/key.mdx create mode 100644 src/content/reference/en/p5 copy/keyCode.mdx create mode 100644 src/content/reference/en/p5 copy/keyIsDown.mdx create mode 100644 src/content/reference/en/p5 copy/keyIsPressed.mdx create mode 100644 src/content/reference/en/p5 copy/keyPressed.mdx create mode 100644 src/content/reference/en/p5 copy/keyReleased.mdx create mode 100644 src/content/reference/en/p5 copy/keyTyped.mdx create mode 100644 src/content/reference/en/p5 copy/lerp.mdx create mode 100644 src/content/reference/en/p5 copy/lerpColor.mdx create mode 100644 src/content/reference/en/p5 copy/let.mdx create mode 100644 src/content/reference/en/p5 copy/lightFalloff.mdx create mode 100644 src/content/reference/en/p5 copy/lightness.mdx create mode 100644 src/content/reference/en/p5 copy/lights.mdx create mode 100644 src/content/reference/en/p5 copy/line.mdx create mode 100644 src/content/reference/en/p5 copy/linePerspective.mdx create mode 100644 src/content/reference/en/p5 copy/loadBytes.mdx create mode 100644 src/content/reference/en/p5 copy/loadFont.mdx create mode 100644 src/content/reference/en/p5 copy/loadImage.mdx create mode 100644 src/content/reference/en/p5 copy/loadJSON.mdx create mode 100644 src/content/reference/en/p5 copy/loadModel.mdx create mode 100644 src/content/reference/en/p5 copy/loadPixels.mdx create mode 100644 src/content/reference/en/p5 copy/loadShader.mdx create mode 100644 src/content/reference/en/p5 copy/loadSound.mdx create mode 100644 src/content/reference/en/p5 copy/loadStrings.mdx create mode 100644 src/content/reference/en/p5 copy/loadTable.mdx create mode 100644 src/content/reference/en/p5 copy/loadXML.mdx create mode 100644 src/content/reference/en/p5 copy/log.mdx create mode 100644 src/content/reference/en/p5 copy/loop.mdx create mode 100644 src/content/reference/en/p5 copy/mag.mdx create mode 100644 src/content/reference/en/p5 copy/map.mdx create mode 100644 src/content/reference/en/p5 copy/match.mdx create mode 100644 src/content/reference/en/p5 copy/matchAll.mdx create mode 100644 src/content/reference/en/p5 copy/max.mdx create mode 100644 src/content/reference/en/p5 copy/metalness.mdx create mode 100644 src/content/reference/en/p5 copy/midiToFreq.mdx create mode 100644 src/content/reference/en/p5 copy/millis.mdx create mode 100644 src/content/reference/en/p5 copy/min.mdx create mode 100644 src/content/reference/en/p5 copy/minute.mdx create mode 100644 src/content/reference/en/p5 copy/model.mdx create mode 100644 src/content/reference/en/p5 copy/month.mdx create mode 100644 src/content/reference/en/p5 copy/mouseButton.mdx create mode 100644 src/content/reference/en/p5 copy/mouseClicked.mdx create mode 100644 src/content/reference/en/p5 copy/mouseDragged.mdx create mode 100644 src/content/reference/en/p5 copy/mouseIsPressed.mdx create mode 100644 src/content/reference/en/p5 copy/mouseMoved.mdx create mode 100644 src/content/reference/en/p5 copy/mousePressed.mdx create mode 100644 src/content/reference/en/p5 copy/mouseReleased.mdx create mode 100644 src/content/reference/en/p5 copy/mouseWheel.mdx create mode 100644 src/content/reference/en/p5 copy/mouseX.mdx create mode 100644 src/content/reference/en/p5 copy/mouseY.mdx create mode 100644 src/content/reference/en/p5 copy/movedX.mdx create mode 100644 src/content/reference/en/p5 copy/movedY.mdx create mode 100644 src/content/reference/en/p5 copy/nf.mdx create mode 100644 src/content/reference/en/p5 copy/nfc.mdx create mode 100644 src/content/reference/en/p5 copy/nfp.mdx create mode 100644 src/content/reference/en/p5 copy/nfs.mdx create mode 100644 src/content/reference/en/p5 copy/noCanvas.mdx create mode 100644 src/content/reference/en/p5 copy/noCursor.mdx create mode 100644 src/content/reference/en/p5 copy/noDebugMode.mdx create mode 100644 src/content/reference/en/p5 copy/noErase.mdx create mode 100644 src/content/reference/en/p5 copy/noFill.mdx create mode 100644 src/content/reference/en/p5 copy/noLights.mdx create mode 100644 src/content/reference/en/p5 copy/noLoop.mdx create mode 100644 src/content/reference/en/p5 copy/noSmooth.mdx create mode 100644 src/content/reference/en/p5 copy/noStroke.mdx create mode 100644 src/content/reference/en/p5 copy/noTint.mdx create mode 100644 src/content/reference/en/p5 copy/noise.mdx create mode 100644 src/content/reference/en/p5 copy/noiseDetail.mdx create mode 100644 src/content/reference/en/p5 copy/noiseSeed.mdx create mode 100644 src/content/reference/en/p5 copy/norm.mdx create mode 100644 src/content/reference/en/p5 copy/normal.mdx create mode 100644 src/content/reference/en/p5 copy/normalMaterial.mdx create mode 100644 src/content/reference/en/p5 copy/orbitControl.mdx create mode 100644 src/content/reference/en/p5 copy/ortho.mdx create mode 100644 src/content/reference/en/p5 copy/outputVolume.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Camera.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Color.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Element.mdx create mode 100644 src/content/reference/en/p5 copy/p5.File.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Font.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Framebuffer.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Geometry.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Graphics.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Image.mdx create mode 100644 src/content/reference/en/p5 copy/p5.MediaElement.mdx create mode 100644 src/content/reference/en/p5 copy/p5.NumberDict.mdx create mode 100644 src/content/reference/en/p5 copy/p5.PrintWriter.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Renderer.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Shader.mdx create mode 100644 src/content/reference/en/p5 copy/p5.StringDict.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Table.mdx create mode 100644 src/content/reference/en/p5 copy/p5.TableRow.mdx create mode 100644 src/content/reference/en/p5 copy/p5.TypedDict.mdx create mode 100644 src/content/reference/en/p5 copy/p5.Vector.mdx create mode 100644 src/content/reference/en/p5 copy/p5.XML.mdx create mode 100644 src/content/reference/en/p5 copy/p5.mdx create mode 100644 src/content/reference/en/p5 copy/pAccelerationX.mdx create mode 100644 src/content/reference/en/p5 copy/pAccelerationY.mdx create mode 100644 src/content/reference/en/p5 copy/pAccelerationZ.mdx create mode 100644 src/content/reference/en/p5 copy/pRotationX.mdx create mode 100644 src/content/reference/en/p5 copy/pRotationY.mdx create mode 100644 src/content/reference/en/p5 copy/pRotationZ.mdx create mode 100644 src/content/reference/en/p5 copy/paletteLerp.mdx create mode 100644 src/content/reference/en/p5 copy/panorama.mdx create mode 100644 src/content/reference/en/p5 copy/perspective.mdx create mode 100644 src/content/reference/en/p5 copy/pixelDensity.mdx create mode 100644 src/content/reference/en/p5 copy/pixels.mdx create mode 100644 src/content/reference/en/p5 copy/plane.mdx create mode 100644 src/content/reference/en/p5 copy/pmouseX.mdx create mode 100644 src/content/reference/en/p5 copy/pmouseY.mdx create mode 100644 src/content/reference/en/p5 copy/point.mdx create mode 100644 src/content/reference/en/p5 copy/pointLight.mdx create mode 100644 src/content/reference/en/p5 copy/pop.mdx create mode 100644 src/content/reference/en/p5 copy/pow.mdx create mode 100644 src/content/reference/en/p5 copy/preload.mdx create mode 100644 src/content/reference/en/p5 copy/print.mdx create mode 100644 src/content/reference/en/p5 copy/push.mdx create mode 100644 src/content/reference/en/p5 copy/pwinMouseX.mdx create mode 100644 src/content/reference/en/p5 copy/pwinMouseY.mdx create mode 100644 src/content/reference/en/p5 copy/quad.mdx create mode 100644 src/content/reference/en/p5 copy/quadraticVertex.mdx create mode 100644 src/content/reference/en/p5 copy/radians.mdx create mode 100644 src/content/reference/en/p5 copy/random.mdx create mode 100644 src/content/reference/en/p5 copy/randomGaussian.mdx create mode 100644 src/content/reference/en/p5 copy/randomSeed.mdx create mode 100644 src/content/reference/en/p5 copy/rect.mdx create mode 100644 src/content/reference/en/p5 copy/rectMode.mdx create mode 100644 src/content/reference/en/p5 copy/red.mdx create mode 100644 src/content/reference/en/p5 copy/redraw.mdx create mode 100644 src/content/reference/en/p5 copy/remove.mdx create mode 100644 src/content/reference/en/p5 copy/removeElements.mdx create mode 100644 src/content/reference/en/p5 copy/removeItem.mdx create mode 100644 src/content/reference/en/p5 copy/requestPointerLock.mdx create mode 100644 src/content/reference/en/p5 copy/resetMatrix.mdx create mode 100644 src/content/reference/en/p5 copy/resetShader.mdx create mode 100644 src/content/reference/en/p5 copy/resizeCanvas.mdx create mode 100644 src/content/reference/en/p5 copy/reverse.mdx create mode 100644 src/content/reference/en/p5 copy/rotate.mdx create mode 100644 src/content/reference/en/p5 copy/rotateX.mdx create mode 100644 src/content/reference/en/p5 copy/rotateY.mdx create mode 100644 src/content/reference/en/p5 copy/rotateZ.mdx create mode 100644 src/content/reference/en/p5 copy/rotationX.mdx create mode 100644 src/content/reference/en/p5 copy/rotationY.mdx create mode 100644 src/content/reference/en/p5 copy/rotationZ.mdx create mode 100644 src/content/reference/en/p5 copy/round.mdx create mode 100644 src/content/reference/en/p5 copy/sampleRate.mdx create mode 100644 src/content/reference/en/p5 copy/saturation.mdx create mode 100644 src/content/reference/en/p5 copy/save.mdx create mode 100644 src/content/reference/en/p5 copy/saveCanvas.mdx create mode 100644 src/content/reference/en/p5 copy/saveFrames.mdx create mode 100644 src/content/reference/en/p5 copy/saveGif.mdx create mode 100644 src/content/reference/en/p5 copy/saveJSON.mdx create mode 100644 src/content/reference/en/p5 copy/saveSound.mdx create mode 100644 src/content/reference/en/p5 copy/saveStrings.mdx create mode 100644 src/content/reference/en/p5 copy/saveTable.mdx create mode 100644 src/content/reference/en/p5 copy/scale.mdx create mode 100644 src/content/reference/en/p5 copy/second.mdx create mode 100644 src/content/reference/en/p5 copy/select.mdx create mode 100644 src/content/reference/en/p5 copy/selectAll.mdx create mode 100644 src/content/reference/en/p5 copy/set.mdx create mode 100644 src/content/reference/en/p5 copy/setAttributes.mdx create mode 100644 src/content/reference/en/p5 copy/setBPM.mdx create mode 100644 src/content/reference/en/p5 copy/setCamera.mdx create mode 100644 src/content/reference/en/p5 copy/setMoveThreshold.mdx create mode 100644 src/content/reference/en/p5 copy/setShakeThreshold.mdx create mode 100644 src/content/reference/en/p5 copy/setup.mdx create mode 100644 src/content/reference/en/p5 copy/shader.mdx create mode 100644 src/content/reference/en/p5 copy/shearX.mdx create mode 100644 src/content/reference/en/p5 copy/shearY.mdx create mode 100644 src/content/reference/en/p5 copy/shininess.mdx create mode 100644 src/content/reference/en/p5 copy/shorten.mdx create mode 100644 src/content/reference/en/p5 copy/shuffle.mdx create mode 100644 src/content/reference/en/p5 copy/sin.mdx create mode 100644 src/content/reference/en/p5 copy/smooth.mdx create mode 100644 src/content/reference/en/p5 copy/sort.mdx create mode 100644 src/content/reference/en/p5 copy/soundFormats.mdx create mode 100644 src/content/reference/en/p5 copy/soundOut.mdx create mode 100644 src/content/reference/en/p5 copy/specularColor.mdx create mode 100644 src/content/reference/en/p5 copy/specularMaterial.mdx create mode 100644 src/content/reference/en/p5 copy/sphere.mdx create mode 100644 src/content/reference/en/p5 copy/splice.mdx create mode 100644 src/content/reference/en/p5 copy/split.mdx create mode 100644 src/content/reference/en/p5 copy/splitTokens.mdx create mode 100644 src/content/reference/en/p5 copy/spotLight.mdx create mode 100644 src/content/reference/en/p5 copy/sq.mdx create mode 100644 src/content/reference/en/p5 copy/sqrt.mdx create mode 100644 src/content/reference/en/p5 copy/square.mdx create mode 100644 src/content/reference/en/p5 copy/storeItem.mdx create mode 100644 src/content/reference/en/p5 copy/str.mdx create mode 100644 src/content/reference/en/p5 copy/stroke.mdx create mode 100644 src/content/reference/en/p5 copy/strokeCap.mdx create mode 100644 src/content/reference/en/p5 copy/strokeJoin.mdx create mode 100644 src/content/reference/en/p5 copy/strokeWeight.mdx create mode 100644 src/content/reference/en/p5 copy/subset.mdx create mode 100644 src/content/reference/en/p5 copy/tan.mdx create mode 100644 src/content/reference/en/p5 copy/text.mdx create mode 100644 src/content/reference/en/p5 copy/textAlign.mdx create mode 100644 src/content/reference/en/p5 copy/textAscent.mdx create mode 100644 src/content/reference/en/p5 copy/textDescent.mdx create mode 100644 src/content/reference/en/p5 copy/textFont.mdx create mode 100644 src/content/reference/en/p5 copy/textLeading.mdx create mode 100644 src/content/reference/en/p5 copy/textOutput.mdx create mode 100644 src/content/reference/en/p5 copy/textSize.mdx create mode 100644 src/content/reference/en/p5 copy/textStyle.mdx create mode 100644 src/content/reference/en/p5 copy/textWidth.mdx create mode 100644 src/content/reference/en/p5 copy/textWrap.mdx create mode 100644 src/content/reference/en/p5 copy/texture.mdx create mode 100644 src/content/reference/en/p5 copy/textureMode.mdx create mode 100644 src/content/reference/en/p5 copy/textureWrap.mdx create mode 100644 src/content/reference/en/p5 copy/tint.mdx create mode 100644 src/content/reference/en/p5 copy/torus.mdx create mode 100644 src/content/reference/en/p5 copy/touchEnded.mdx create mode 100644 src/content/reference/en/p5 copy/touchMoved.mdx create mode 100644 src/content/reference/en/p5 copy/touchStarted.mdx create mode 100644 src/content/reference/en/p5 copy/touches.mdx create mode 100644 src/content/reference/en/p5 copy/translate.mdx create mode 100644 src/content/reference/en/p5 copy/triangle.mdx create mode 100644 src/content/reference/en/p5 copy/trim.mdx create mode 100644 src/content/reference/en/p5 copy/turnAxis.mdx create mode 100644 src/content/reference/en/p5 copy/types/Array.mdx create mode 100644 src/content/reference/en/p5 copy/types/Boolean.mdx create mode 100644 src/content/reference/en/p5 copy/types/Number.mdx create mode 100644 src/content/reference/en/p5 copy/types/Object.mdx create mode 100644 src/content/reference/en/p5 copy/types/String.mdx create mode 100644 src/content/reference/en/p5 copy/unchar.mdx create mode 100644 src/content/reference/en/p5 copy/unhex.mdx create mode 100644 src/content/reference/en/p5 copy/updatePixels.mdx create mode 100644 src/content/reference/en/p5 copy/userStartAudio.mdx create mode 100644 src/content/reference/en/p5 copy/vertex.mdx create mode 100644 src/content/reference/en/p5 copy/webglVersion.mdx create mode 100644 src/content/reference/en/p5 copy/while.mdx create mode 100644 src/content/reference/en/p5 copy/width.mdx create mode 100644 src/content/reference/en/p5 copy/winMouseX.mdx create mode 100644 src/content/reference/en/p5 copy/winMouseY.mdx create mode 100644 src/content/reference/en/p5 copy/windowHeight.mdx create mode 100644 src/content/reference/en/p5 copy/windowResized.mdx create mode 100644 src/content/reference/en/p5 copy/windowWidth.mdx create mode 100644 src/content/reference/en/p5 copy/year.mdx diff --git a/.github/actions/translation-tracker/README.md b/.github/actions/translation-tracker/README.md index 90ffdf1275..0c9a7e698e 100644 --- a/.github/actions/translation-tracker/README.md +++ b/.github/actions/translation-tracker/README.md @@ -6,7 +6,7 @@ Automatically tracks translation status, creates GitHub issues for outdated tran - Detects outdated/missing translations using Git commit comparison - Creates GitHub issues with diff snippets and action checklists -- **Week 2:** Generates translation stub files and opens **one PR per language** +- Generates translation stub files and opens **one PR per language** - Shows localized banners on outdated translation pages - Supports Spanish, Hindi, Korean, and Chinese Simplified @@ -64,26 +64,30 @@ GENERATE_STUBS=true STUB_FULL_SCAN=true STUB_MAX_FILES=10 STUB_LANGUAGES=es,hi \ ### GitHub Actions -| Workflow | Trigger | What it does | -|----------|---------|----------------| -| `translation-sync.yml` | Push to `examples/en`, `tutorials/en` | Issues + manifests | + +| Workflow | Trigger | What it does | +| ----------------------- | ------------------------------------------ | --------------------------------------- | +| `translation-sync.yml` | Push to `examples/en`, `tutorials/en` | Issues + manifests | | `translation-stubs.yml` | Push to `reference/en`, or manual dispatch | Stub PRs (default: es, hi, ko, zh-Hans) | + Manual stub run: Actions → **Translation Stub Generator** → Run workflow → optional full scan. ## Environment Variables -| Variable | Purpose | -|----------|---------| -| `GITHUB_TOKEN` | API access (issues, PRs) | -| `GITHUB_REPOSITORY` | `owner/repo` (default: `processing/p5.js-website`) | -| `GENERATE_STUBS` | `true` = stub mode instead of issue tracking | -| `STUB_LANGUAGES` | Comma-separated (default: `es`, `hi`, `ko`, `zh-Hans`) | -| `STUB_CONTENT_TYPES` | Comma-separated (default: `reference`) | -| `STUB_FULL_SCAN` | `true` = all English files, not just latest commit | -| `STUB_DRY_RUN` | `true` = write to `stub-preview/`, no PR | -| `STUB_MAX_FILES` | Max stubs per language per run (default: `50`) | -| `STUB_OUTPUT_DIR` | Custom dry-run output directory | + +| Variable | Purpose | +| -------------------- | ------------------------------------------------------ | +| `GITHUB_TOKEN` | API access (issues, PRs) | +| `GITHUB_REPOSITORY` | `owner/repo` (default: `processing/p5.js-website`) | +| `GENERATE_STUBS` | `true` = stub mode instead of issue tracking | +| `STUB_LANGUAGES` | Comma-separated (default: `es`, `hi`, `ko`, `zh-Hans`) | +| `STUB_CONTENT_TYPES` | Comma-separated (default: `reference`) | +| `STUB_FULL_SCAN` | `true` = all English files, not just latest commit | +| `STUB_DRY_RUN` | `true` = write to `stub-preview/`, no PR | +| `STUB_MAX_FILES` | Max stubs per language per run (default: `50`) | +| `STUB_OUTPUT_DIR` | Custom dry-run output directory | + ## What stubs contain @@ -98,3 +102,4 @@ For each English file with **no** translation yet: - `@octokit/rest`, `js-yaml` - Node.js built-ins: `fs`, `path`, `child_process` + diff --git a/src/content/reference/en/p5 copy/abs.mdx b/src/content/reference/en/p5 copy/abs.mdx new file mode 100644 index 0000000000..1bdb6895ff --- /dev/null +++ b/src/content/reference/en/p5 copy/abs.mdx @@ -0,0 +1,61 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L10 +title: abs +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Calculates the absolute value of a number.

+ +

A number's absolute value is its distance from zero on the number line. + + -5 and 5 are both five units away from zero, so calling abs(-5) + and + + abs(5) both return 5. The absolute value of a number is always + positive.

+line: 10 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A gray square with a vertical black line that divides it in half. A white rectangle gets taller when the user moves the mouse away from the line.'); + } + + function draw() { + background(200); + + // Divide the canvas. + line(50, 0, 50, 100); + + // Calculate the mouse's distance from the middle. + let h = abs(mouseX - 50); + + // Draw a rectangle based on the mouse's distance + // from the middle. + rect(0, 100 - h, 100, h); + } + +
+class: p5 +params: + - name: 'n' + description: | +

number to compute.

+ type: Number +return: + description: absolute value of given number. + type: Number +chainable: false +--- + + +# abs diff --git a/src/content/reference/en/p5 copy/accelerationX.mdx b/src/content/reference/en/p5 copy/accelerationX.mdx new file mode 100644 index 0000000000..6a47fc46ce --- /dev/null +++ b/src/content/reference/en/p5 copy/accelerationX.mdx @@ -0,0 +1,37 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L23 +title: accelerationX +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

The system variable accelerationX always contains the acceleration of the + + device along the x axis. Value is represented as meters per second + squared.

+line: 23 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // Move a touchscreen device to register + // acceleration changes. + function draw() { + background(220, 50); + fill('magenta'); + ellipse(width / 2, height / 2, accelerationX); + describe('Magnitude of device acceleration is displayed as ellipse size.'); + } + +
+class: p5 +type: Number +--- + + +# accelerationX diff --git a/src/content/reference/en/p5 copy/accelerationY.mdx b/src/content/reference/en/p5 copy/accelerationY.mdx new file mode 100644 index 0000000000..bf5f54e39b --- /dev/null +++ b/src/content/reference/en/p5 copy/accelerationY.mdx @@ -0,0 +1,37 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L45 +title: accelerationY +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

The system variable accelerationY always contains the acceleration of the + + device along the y axis. Value is represented as meters per second + squared.

+line: 45 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // Move a touchscreen device to register + // acceleration changes. + function draw() { + background(220, 50); + fill('magenta'); + ellipse(width / 2, height / 2, accelerationY); + describe('Magnitude of device acceleration is displayed as ellipse size'); + } + +
+class: p5 +type: Number +--- + + +# accelerationY diff --git a/src/content/reference/en/p5 copy/accelerationZ.mdx b/src/content/reference/en/p5 copy/accelerationZ.mdx new file mode 100644 index 0000000000..11e5cbb53e --- /dev/null +++ b/src/content/reference/en/p5 copy/accelerationZ.mdx @@ -0,0 +1,37 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L67 +title: accelerationZ +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

The system variable accelerationZ always contains the acceleration of the + + device along the z axis. Value is represented as meters per second + squared.

+line: 67 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // Move a touchscreen device to register + // acceleration changes. + function draw() { + background(220, 50); + fill('magenta'); + ellipse(width / 2, height / 2, accelerationZ); + describe('Magnitude of device acceleration is displayed as ellipse size'); + } + +
+class: p5 +type: Number +--- + + +# accelerationZ diff --git a/src/content/reference/en/p5 copy/acos.mdx b/src/content/reference/en/p5 copy/acos.mdx new file mode 100644 index 0000000000..c9ed943f5e --- /dev/null +++ b/src/content/reference/en/p5 copy/acos.mdx @@ -0,0 +1,86 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L18 +title: acos +module: Math +submodule: Trigonometry +file: src/math/trigonometry.js +description: > +

Calculates the arc cosine of a number.

+ +

acos() is the inverse of cos(). It expects + + arguments in the range -1 to 1. By default, acos() returns values + in the + + range 0 to π (about 3.14). If the + + angleMode() is DEGREES, + then values are + + returned in the range 0 to 180.

+line: 18 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Calculate cos() and acos() values. + let a = PI; + let c = cos(a); + let ac = acos(c); + + // Display the values. + text(`${round(a, 3)}`, 35, 25); + text(`${round(c, 3)}`, 35, 50); + text(`${round(ac, 3)}`, 35, 75); + + describe('The numbers 3.142, -1, and 3.142 written on separate rows.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Calculate cos() and acos() values. + let a = PI + QUARTER_PI; + let c = cos(a); + let ac = acos(c); + + // Display the values. + text(`${round(a, 3)}`, 35, 25); + text(`${round(c, 3)}`, 35, 50); + text(`${round(ac, 3)}`, 35, 75); + + describe('The numbers 3.927, -0.707, and 2.356 written on separate rows.'); + } + +
+class: p5 +params: + - name: value + description: | +

value whose arc cosine is to be returned.

+ type: Number +return: + description: arc cosine of the given value. + type: Number +chainable: false +--- + + +# acos diff --git a/src/content/reference/en/p5 copy/alpha.mdx b/src/content/reference/en/p5 copy/alpha.mdx new file mode 100644 index 0000000000..c1a87aa78d --- /dev/null +++ b/src/content/reference/en/p5 copy/alpha.mdx @@ -0,0 +1,120 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L16 +title: alpha +module: Color +submodule: Creating & Reading +file: src/color/creating_reading.js +description: > +

Gets the alpha (transparency) value of a color.

+ +

alpha() extracts the alpha value from a + + p5.Color object, an array of color + components, or + + a CSS color string.

+line: 16 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object. + let c = color(0, 126, 255, 102); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'alphaValue' to 102. + let alphaValue = alpha(c); + + // Draw the right rectangle. + fill(alphaValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light blue and the right one is charcoal gray.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a color array. + let c = [0, 126, 255, 102]; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'alphaValue' to 102. + let alphaValue = alpha(c); + + // Draw the left rectangle. + fill(alphaValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light blue and the right one is charcoal gray.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a CSS color string. + let c = 'rgba(0, 126, 255, 0.4)'; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'alphaValue' to 102. + let alphaValue = alpha(c); + + // Draw the right rectangle. + fill(alphaValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light blue and the right one is charcoal gray.'); + } + +
+class: p5 +params: + - name: color + description: | +

p5.Color object, array of + color components, or CSS color string.

+ type: 'p5.Color|Number[]|String' +return: + description: the alpha value. + type: Number +chainable: false +--- + + +# alpha diff --git a/src/content/reference/en/p5 copy/ambientLight.mdx b/src/content/reference/en/p5 copy/ambientLight.mdx new file mode 100644 index 0000000000..09f9159592 --- /dev/null +++ b/src/content/reference/en/p5 copy/ambientLight.mdx @@ -0,0 +1,241 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L10 +title: ambientLight +module: 3D +submodule: Lights +file: src/webgl/light.js +description: > +

Creates a light that shines from all directions.

+ +

Ambient light does not come from one direction. Instead, 3D shapes are + + lit evenly from all sides. Ambient lights are almost always used in + + combination with other types of lights.

+ +

There are three ways to call ambientLight() with optional + parameters to + + set the light’s color.

+ +

The first way to call ambientLight() has two parameters, + gray and + + alpha. alpha is optional. Grayscale and alpha values + between 0 and 255 + + can be passed to set the ambient light’s color, as in + ambientLight(50) or + + ambientLight(50, 30).

+ +

The second way to call ambientLight() has one parameter, + color. A + + p5.Color object, an array of color + values, or a + + CSS color string, as in ambientLight('magenta'), can be passed to + set the + + ambient light’s color.

+ +

The third way to call ambientLight() has four parameters, + v1, v2, + + v3, and alpha. alpha is optional. RGBA, + HSBA, or HSLA values can be + + passed to set the ambient light’s colors, as in ambientLight(255, 0, + 0) + + or ambientLight(255, 0, 0, 30). Color values will be interpreted + using + + the current colorMode().

+line: 10 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click the canvas to turn on the light. + + let isLit = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A sphere drawn against a gray background. The sphere appears to change color when the user double-clicks.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Control the light. + if (isLit === true) { + // Use a grayscale value of 80. + ambientLight(80); + } + + // Draw the sphere. + sphere(30); + } + + // Turn on the ambient light when the user double-clicks. + function doubleClicked() { + isLit = true; + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A faded magenta sphere drawn against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + // Use a p5.Color object. + let c = color('orchid'); + ambientLight(c); + + // Draw the sphere. + sphere(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A faded magenta sphere drawn against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + // Use a CSS color string. + ambientLight('#DA70D6'); + + // Draw the sphere. + sphere(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A faded magenta sphere drawn against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + // Use RGB values + ambientLight(218, 112, 214); + + // Draw the sphere. + sphere(30); + } + +
+class: p5 +overloads: + - line: 10 + params: + - name: v1 + description: | +

red or hue value in the current + colorMode().

+ type: Number + - name: v2 + description: | +

green or saturation value in the current + colorMode().

+ type: Number + - name: v3 + description: | +

blue, brightness, or lightness value in the current + colorMode().

+ type: Number + - name: alpha + description: | +

alpha (transparency) value in the current + colorMode().

+ type: Number + optional: true + chainable: 1 + - line: 164 + params: + - name: gray + description: | +

grayscale value between 0 and 255.

+ type: Number + - name: alpha + description: '' + type: Number + optional: true + chainable: 1 + - line: 171 + params: + - name: value + description: | +

color as a CSS string.

+ type: String + chainable: 1 + - line: 177 + params: + - name: values + description: | +

color as an array of RGBA, HSBA, or HSLA + values.

+ type: 'Number[]' + chainable: 1 + - line: 184 + params: + - name: color + description: | +

color as a p5.Color object.

+ type: p5.Color + chainable: 1 +chainable: true +--- + + +# ambientLight diff --git a/src/content/reference/en/p5 copy/ambientMaterial.mdx b/src/content/reference/en/p5 copy/ambientMaterial.mdx new file mode 100644 index 0000000000..8b96f24260 --- /dev/null +++ b/src/content/reference/en/p5 copy/ambientMaterial.mdx @@ -0,0 +1,269 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2416 +title: ambientMaterial +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Sets the ambient color of shapes’ surface material.

+ +

The ambientMaterial() color sets the components of the + + ambientLight() color that shapes + will + + reflect. For example, calling ambientMaterial(255, 255, 0) would + cause a + + shape to reflect red and green light, but not blue light.

+ +

ambientMaterial() can be called three ways with different + parameters to + + set the material’s color.

+ +

The first way to call ambientMaterial() has one parameter, + gray. + + Grayscale values between 0 and 255, as in ambientMaterial(50), + can be + + passed to set the material’s color. Higher grayscale values make shapes + + appear brighter.

+ +

The second way to call ambientMaterial() has one parameter, + color. A + + p5.Color object, an array of color + values, or a + + CSS color string, as in ambientMaterial('magenta'), can be passed + to set + + the material’s color.

+ +

The third way to call ambientMaterial() has three parameters, + v1, v2, + + and v3. RGB, HSB, or HSL values, as in ambientMaterial(255, + 0, 0), can + + be passed to set the material’s colors. Color values will be interpreted + + using the current colorMode().

+ +

Note: ambientMaterial() can only be used in WebGL mode.

+line: 2416 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A magenta cube drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on a magenta ambient light. + ambientLight(255, 0, 255); + + // Draw the box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A purple cube drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on a magenta ambient light. + ambientLight(255, 0, 255); + + // Add a dark gray ambient material. + ambientMaterial(150); + + // Draw the box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A red cube drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on a magenta ambient light. + ambientLight(255, 0, 255); + + // Add a yellow ambient material using RGB values. + ambientMaterial(255, 255, 0); + + // Draw the box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A red cube drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on a magenta ambient light. + ambientLight(255, 0, 255); + + // Add a yellow ambient material using a p5.Color object. + let c = color(255, 255, 0); + ambientMaterial(c); + + // Draw the box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A red cube drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on a magenta ambient light. + ambientLight(255, 0, 255); + + // Add a yellow ambient material using a color string. + ambientMaterial('yellow'); + + // Draw the box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A yellow cube drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on a white ambient light. + ambientLight(255, 255, 255); + + // Add a yellow ambient material using a color string. + ambientMaterial('yellow'); + + // Draw the box. + box(); + } + +
+class: p5 +overloads: + - line: 2416 + params: + - name: v1 + description: | +

red or hue value in the current + colorMode().

+ type: Number + - name: v2 + description: | +

green or saturation value in the + current colorMode().

+ type: Number + - name: v3 + description: | +

blue, brightness, or lightness value in the + current colorMode().

+ type: Number + chainable: 1 + - line: 2621 + params: + - name: gray + description: | +

grayscale value between 0 (black) and 255 (white).

+ type: Number + chainable: 1 + - line: 2627 + params: + - name: color + description: | +

color as a p5.Color object, + an array of color values, or a CSS string.

+ type: 'p5.Color|Number[]|String' + chainable: 1 +chainable: true +--- + + +# ambientMaterial diff --git a/src/content/reference/en/p5 copy/angleMode.mdx b/src/content/reference/en/p5 copy/angleMode.mdx new file mode 100644 index 0000000000..3401a563cd --- /dev/null +++ b/src/content/reference/en/p5 copy/angleMode.mdx @@ -0,0 +1,219 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L557 +title: angleMode +module: Math +submodule: Trigonometry +file: src/math/trigonometry.js +description: > +

Changes the unit system used to measure angles.

+ +

Degrees and radians are both units for measuring angles. There are 360˚ in + + one full rotation. A full rotation is 2 × π (about 6.28) radians.

+ +

Functions such as rotate() and + + sin() expect angles measured radians by + default. + + Calling angleMode(DEGREES) switches to degrees. Calling + + angleMode(RADIANS) switches back to radians.

+ +

Calling angleMode() with no arguments returns current angle + mode, which + + is either RADIANS or DEGREES.

+line: 557 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Rotate 1/8 turn. + rotate(QUARTER_PI); + + // Draw a line. + line(0, 0, 80, 0); + + describe('A diagonal line radiating from the top-left corner of a square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use degrees. + angleMode(DEGREES); + + // Rotate 1/8 turn. + rotate(45); + + // Draw a line. + line(0, 0, 80, 0); + + describe('A diagonal line radiating from the top-left corner of a square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(50); + + // Calculate the angle to rotate. + let angle = TWO_PI / 7; + + // Move the origin to the center. + translate(50, 50); + + // Style the flower. + noStroke(); + fill(255, 50); + + // Draw the flower. + for (let i = 0; i < 7; i += 1) { + ellipse(0, 0, 80, 20); + rotate(angle); + } + + describe('A translucent white flower on a dark background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(50); + + // Use degrees. + angleMode(DEGREES); + + // Calculate the angle to rotate. + let angle = 360 / 7; + + // Move the origin to the center. + translate(50, 50); + + // Style the flower. + noStroke(); + fill(255, 50); + + // Draw the flower. + for (let i = 0; i < 7; i += 1) { + ellipse(0, 0, 80, 20); + rotate(angle); + } + + describe('A translucent white flower on a dark background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A white ball on a string oscillates left and right.'); + } + + function draw() { + background(200); + + // Calculate the coordinates. + let x = 30 * cos(frameCount * 0.05) + 50; + let y = 50; + + // Draw the oscillator. + line(50, y, x, y); + circle(x, y, 20); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Use degrees. + angleMode(DEGREES); + + describe('A white ball on a string oscillates left and right.'); + } + + function draw() { + background(200); + + // Calculate the coordinates. + let x = 30 * cos(frameCount * 2.86) + 50; + let y = 50; + + // Draw the oscillator. + line(50, y, x, y); + circle(x, y, 20); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw the upper line. + rotate(PI / 6); + line(0, 0, 80, 0); + + // Use degrees. + angleMode(DEGREES); + + // Draw the lower line. + rotate(30); + line(0, 0, 80, 0); + + describe('Two diagonal lines radiating from the top-left corner of a square. The lines are oriented 30 degrees from the edges of the square and 30 degrees apart from each other.'); + } + +
+class: p5 +overloads: + - line: 557 + params: + - name: mode + description: | +

either RADIANS or DEGREES.

+ type: Constant + - line: 743 + params: [] + return: + description: mode either RADIANS or DEGREES + type: Constant +chainable: false +--- + + +# angleMode diff --git a/src/content/reference/en/p5 copy/append.mdx b/src/content/reference/en/p5 copy/append.mdx new file mode 100644 index 0000000000..4e0bbeb5eb --- /dev/null +++ b/src/content/reference/en/p5 copy/append.mdx @@ -0,0 +1,48 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L10 +title: append +module: Data +submodule: Array Functions +file: src/utilities/array_functions.js +description: | +

Adds a value to the end of an array. Extends the length of + the array by one. Maps to Array.push().

+line: 10 +deprecated: >- + Use array.push(value) + instead. +isConstructor: false +itemtype: method +example: + - |- + +
+ function setup() { + let myArray = ['Mango', 'Apple', 'Papaya']; + print(myArray); // ['Mango', 'Apple', 'Papaya'] + + append(myArray, 'Peach'); + print(myArray); // ['Mango', 'Apple', 'Papaya', 'Peach'] + } +
+class: p5 +params: + - name: array + description: | +

Array to append

+ type: Array + - name: value + description: | +

to be added to the Array

+ type: Any +return: + description: the array that was appended to + type: Array +chainable: false +--- + + +# append diff --git a/src/content/reference/en/p5 copy/applyMatrix.mdx b/src/content/reference/en/p5 copy/applyMatrix.mdx new file mode 100644 index 0000000000..b105ed75da --- /dev/null +++ b/src/content/reference/en/p5 copy/applyMatrix.mdx @@ -0,0 +1,347 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L11 +title: applyMatrix +module: Transform +submodule: Transform +file: src/core/transform.js +description: > +

Applies a transformation matrix to the coordinate system.

+ +

Transformations such as + + translate(), + + rotate(), and + + scale() + + use matrix-vector multiplication behind the scenes. A table of numbers, + + called a matrix, encodes each transformation. The values in the matrix + + then multiply each point on the canvas, which is represented by a vector.

+ +

applyMatrix() allows for many transformations to be applied at + once. See + + Wikipedia + + and MDN + + for more details about transformations.

+ +

There are two ways to call applyMatrix() in two and three + dimensions.

+ +

In 2D mode, the parameters a, b, c, + d, e, and f, correspond to + + elements in the following transformation matrix:

+ +
+ +

The transformation matrix used when applyMatrix is called in 2D
+  mode.

+ +
+ +

The numbers can be passed individually, as in + + applyMatrix(2, 0, 0, 0, 2, 0). They can also be passed in an + array, as in + + applyMatrix([2, 0, 0, 0, 2, 0]).

+ +

In 3D mode, the parameters a, b, c, + d, e, f, g, + h, i, + + j, k, l, m, + n, o, and p correspond to elements in + the + + following transformation matrix:

+ +

The transformation matrix used when applyMatrix is called in 3D
+  mode.

+ +

The numbers can be passed individually, as in + + applyMatrix(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1). They + can + + also be passed in an array, as in + + applyMatrix([2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, + 1]).

+ +

By default, transformations accumulate. The + + push() and pop() functions + + can be used to isolate transformations within distinct drawing groups.

+ +

Note: Transformations are reset at the beginning of the draw loop. Calling + + applyMatrix() inside the draw() + function won't + + cause shapes to transform continuously.

+line: 11 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A white circle on a gray background.'); + } + + function draw() { + background(200); + + // Translate the origin to the center. + applyMatrix(1, 0, 0, 1, 50, 50); + + // Draw the circle at coordinates (0, 0). + circle(0, 0, 40); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A white circle on a gray background.'); + } + + function draw() { + background(200); + + // Translate the origin to the center. + let m = [1, 0, 0, 1, 50, 50]; + applyMatrix(m); + + // Draw the circle at coordinates (0, 0). + circle(0, 0, 40); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe("A white rectangle on a gray background. The rectangle's long axis runs from top-left to bottom-right."); + } + + function draw() { + background(200); + + // Rotate the coordinate system 1/8 turn. + let angle = QUARTER_PI; + let ca = cos(angle); + let sa = sin(angle); + applyMatrix(ca, sa, -sa, ca, 0, 0); + + // Draw a rectangle at coordinates (50, 0). + rect(50, 0, 40, 20); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'Two white squares on a gray background. The larger square appears at the top-center. The smaller square appears at the top-left.' + ); + } + + function draw() { + background(200); + + // Draw a square at (30, 20). + square(30, 20, 40); + + // Scale the coordinate system by a factor of 0.5. + applyMatrix(0.5, 0, 0, 0.5, 0, 0); + + // Draw a square at (30, 20). + // It appears at (15, 10) after scaling. + square(30, 20, 40); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A white quadrilateral on a gray background.'); + } + + function draw() { + background(200); + + // Calculate the shear factor. + let angle = QUARTER_PI; + let shearFactor = 1 / tan(HALF_PI - angle); + + // Shear the coordinate system along the x-axis. + applyMatrix(1, 0, shearFactor, 1, 0, 0); + + // Draw the square. + square(0, 0, 50); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube rotates slowly against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system a little more each frame. + let angle = frameCount * 0.01; + let ca = cos(angle); + let sa = sin(angle); + applyMatrix(ca, 0, sa, 0, 0, 1, 0, 0, -sa, 0, ca, 0, 0, 0, 0, 1); + + // Draw a box. + box(); + } + +
+class: p5 +overloads: + - line: 11 + params: + - name: arr + description: > +

an array containing the elements of the transformation matrix. Its + length should be either 6 (2D) or 16 (3D).

+ type: Array + chainable: 1 + - line: 206 + params: + - name: a + description: | +

an element of the transformation matrix.

+ type: Number + - name: b + description: | +

an element of the transformation matrix.

+ type: Number + - name: c + description: | +

an element of the transformation matrix.

+ type: Number + - name: d + description: | +

an element of the transformation matrix.

+ type: Number + - name: e + description: | +

an element of the transformation matrix.

+ type: Number + - name: f + description: | +

an element of the transformation matrix.

+ type: Number + chainable: 1 + - line: 216 + params: + - name: a + description: '' + type: Number + - name: b + description: '' + type: Number + - name: c + description: '' + type: Number + - name: d + description: '' + type: Number + - name: e + description: '' + type: Number + - name: f + description: '' + type: Number + - name: g + description: | +

an element of the transformation matrix.

+ type: Number + - name: h + description: | +

an element of the transformation matrix.

+ type: Number + - name: i + description: | +

an element of the transformation matrix.

+ type: Number + - name: j + description: | +

an element of the transformation matrix.

+ type: Number + - name: k + description: | +

an element of the transformation matrix.

+ type: Number + - name: l + description: | +

an element of the transformation matrix.

+ type: Number + - name: m + description: | +

an element of the transformation matrix.

+ type: Number + - name: 'n' + description: | +

an element of the transformation matrix.

+ type: Number + - name: o + description: | +

an element of the transformation matrix.

+ type: Number + - name: p + description: | +

an element of the transformation matrix.

+ type: Number + chainable: 1 +chainable: true +--- + + +# applyMatrix diff --git a/src/content/reference/en/p5 copy/arc.mdx b/src/content/reference/en/p5 copy/arc.mdx new file mode 100644 index 0000000000..ee50708815 --- /dev/null +++ b/src/content/reference/en/p5 copy/arc.mdx @@ -0,0 +1,274 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L102 +title: arc +module: Shape +submodule: 2D Primitives +file: src/core/shape/2d_primitives.js +description: > +

Draws an arc.

+ +

An arc is a section of an ellipse defined by the x, + y, w, and + + h parameters. x and y set the location + of the arc's center. w and + + h set the arc's width and height. See + + ellipse() and + + ellipseMode() for more details.

+ +

The fifth and sixth parameters, start and stop, + set the angles + + between which to draw the arc. Arcs are always drawn clockwise from + + start to stop. The fifth and sixth parameters, start + and stop, set the + + angles between which to draw the arc. By default, angles are given in radians, + but if angleMode + + (DEGREES) is set, the function interprets the values in degrees.

+ +

The seventh parameter, mode, is optional. It determines the + arc's fill + + style. The fill modes are a semi-circle (OPEN), a closed + semi-circle + + (CHORD), or a closed pie segment (PIE).

+ +

The eighth parameter, detail, is also optional. It determines + how many + + vertices are used to draw the arc in WebGL mode. The default value is 25.

+line: 102 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + arc(50, 50, 80, 80, 0, PI + HALF_PI); + + describe('A white circle on a gray canvas. The top-right quarter of the circle is missing.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + arc(50, 50, 80, 40, 0, PI + HALF_PI); + + describe('A white ellipse on a gray canvas. The top-right quarter of the ellipse is missing.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Bottom-right. + arc(50, 55, 50, 50, 0, HALF_PI); + + noFill(); + + // Bottom-left. + arc(50, 55, 60, 60, HALF_PI, PI); + + // Top-left. + arc(50, 55, 70, 70, PI, PI + QUARTER_PI); + + // Top-right. + arc(50, 55, 80, 80, PI + QUARTER_PI, TWO_PI); + + describe( + 'A shattered outline of an circle with a quarter of a white circle at the bottom-right.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Default fill mode. + arc(50, 50, 80, 80, 0, PI + QUARTER_PI); + + describe('A white circle with the top-right third missing. The bottom is outlined in black.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // OPEN fill mode. + arc(50, 50, 80, 80, 0, PI + QUARTER_PI, OPEN); + + describe( + 'A white circle missing a section from the top-right. The bottom is outlined in black.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // CHORD fill mode. + arc(50, 50, 80, 80, 0, PI + QUARTER_PI, CHORD); + + describe('A white circle with a black outline missing a section from the top-right.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // PIE fill mode. + arc(50, 50, 80, 80, 0, PI + QUARTER_PI, PIE); + + describe('A white circle with a black outline. The top-right third is missing.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + // PIE fill mode. + arc(0, 0, 80, 80, 0, PI + QUARTER_PI, PIE); + + describe('A white circle with a black outline. The top-right third is missing.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + // PIE fill mode with 5 vertices. + arc(0, 0, 80, 80, 0, PI + QUARTER_PI, PIE, 5); + + describe('A white circle with a black outline. The top-right third is missing.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A yellow circle on a black background. The circle opens and closes its mouth.'); + } + + function draw() { + background(0); + + // Style the arc. + noStroke(); + fill(255, 255, 0); + + // Update start and stop angles. + let biteSize = PI / 16; + let startAngle = biteSize * sin(frameCount * 0.1) + biteSize; + let endAngle = TWO_PI - startAngle; + + // Draw the arc. + arc(50, 50, 80, 80, startAngle, endAngle, PIE); + } + +
+class: p5 +params: + - name: x + description: | +

x-coordinate of the arc's ellipse.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the arc's ellipse.

+ type: Number + - name: w + description: | +

width of the arc's ellipse by default.

+ type: Number + - name: h + description: | +

height of the arc's ellipse by default.

+ type: Number + - name: start + description: | +

angle to start the arc, specified in radians.

+ type: Number + - name: stop + description: | +

angle to stop the arc, specified in radians.

+ type: Number + - name: mode + description: | +

optional parameter to determine the way of drawing + the arc. either CHORD, PIE, or OPEN.

+ type: Constant + optional: true + - name: detail + description: | +

optional parameter for WebGL mode only. This is to + specify the number of vertices that makes up the + perimeter of the arc. Default value is 25. Won't + draw a stroke for a detail of more than 50.

+ type: Integer + optional: true +chainable: true +--- + + +# arc diff --git a/src/content/reference/en/p5 copy/arrayCopy.mdx b/src/content/reference/en/p5 copy/arrayCopy.mdx new file mode 100644 index 0000000000..2d149d1ed3 --- /dev/null +++ b/src/content/reference/en/p5 copy/arrayCopy.mdx @@ -0,0 +1,95 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L35 +title: arrayCopy +module: Data +submodule: Array Functions +file: src/utilities/array_functions.js +description: > +

Copies an array (or part of an array) to another array. The src array is + + copied to the dst array, beginning at the position specified by + + srcPosition and into the position specified by dstPosition. The number of + + elements to copy is determined by length. Note that copying values + + overwrites existing values in the destination array. To append values + + instead of overwriting them, use concat().

+ +

The simplified version with only two arguments, arrayCopy(src, dst), + + copies an entire array to another of the same size. It is equivalent to + + arrayCopy(src, 0, dst, 0, src.length).

+ +

Using this function is far more efficient for copying array data than + + iterating through a for() loop and copying each element individually.

+line: 35 +deprecated: >- + Use arr1.copyWithin(arr2) + instead. +isConstructor: false +itemtype: method +example: + - |- + +
+ let src = ['A', 'B', 'C']; + let dst = [1, 2, 3]; + let srcPosition = 1; + let dstPosition = 0; + let length = 2; + + print(src); // ['A', 'B', 'C'] + print(dst); // [ 1 , 2 , 3 ] + + arrayCopy(src, srcPosition, dst, dstPosition, length); + print(dst); // ['B', 'C', 3] +
+class: p5 +overloads: + - line: 35 + params: + - name: src + description: | +

the source Array

+ type: Array + - name: srcPosition + description: | +

starting position in the source Array

+ type: Integer + - name: dst + description: | +

the destination Array

+ type: Array + - name: dstPosition + description: | +

starting position in the destination Array

+ type: Integer + - name: length + description: | +

number of Array elements to be copied

+ type: Integer + - line: 73 + params: + - name: src + description: '' + type: Array + - name: dst + description: '' + type: Array + - name: length + description: '' + type: Integer + optional: true +chainable: false +--- + + +# arrayCopy diff --git a/src/content/reference/en/p5 copy/asin.mdx b/src/content/reference/en/p5 copy/asin.mdx new file mode 100644 index 0000000000..78518c0050 --- /dev/null +++ b/src/content/reference/en/p5 copy/asin.mdx @@ -0,0 +1,86 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L80 +title: asin +module: Math +submodule: Trigonometry +file: src/math/trigonometry.js +description: > +

Calculates the arc sine of a number.

+ +

asin() is the inverse of sin(). It expects input + + values in the range of -1 to 1. By default, asin() returns values + in the + + range -π ÷ 2 (about -1.57) to π ÷ 2 (about 1.57). If + + the angleMode() is DEGREES + then values are + + returned in the range -90 to 90.

+line: 80 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Calculate sin() and asin() values. + let a = PI / 3; + let s = sin(a); + let as = asin(s); + + // Display the values. + text(`${round(a, 3)}`, 35, 25); + text(`${round(s, 3)}`, 35, 50); + text(`${round(as, 3)}`, 35, 75); + + describe('The numbers 1.047, 0.866, and 1.047 written on separate rows.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Calculate sin() and asin() values. + let a = PI + PI / 3; + let s = sin(a); + let as = asin(s); + + // Display the values. + text(`${round(a, 3)}`, 35, 25); + text(`${round(s, 3)}`, 35, 50); + text(`${round(as, 3)}`, 35, 75); + + describe('The numbers 4.189, -0.866, and -1.047 written on separate rows.'); + } + +
+class: p5 +params: + - name: value + description: | +

value whose arc sine is to be returned.

+ type: Number +return: + description: arc sine of the given value. + type: Number +chainable: false +--- + + +# asin diff --git a/src/content/reference/en/p5 copy/atan.mdx b/src/content/reference/en/p5 copy/atan.mdx new file mode 100644 index 0000000000..86b3874bb0 --- /dev/null +++ b/src/content/reference/en/p5 copy/atan.mdx @@ -0,0 +1,86 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L142 +title: atan +module: Math +submodule: Trigonometry +file: src/math/trigonometry.js +description: > +

Calculates the arc tangent of a number.

+ +

atan() is the inverse of tan(). It expects input + + values in the range of -Infinity to Infinity. By default, atan() + returns + + values in the range -π ÷ 2 (about -1.57) to π ÷ 2 + + (about 1.57). If the angleMode() is + DEGREES + + then values are returned in the range -90 to 90.

+line: 142 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Calculate tan() and atan() values. + let a = PI / 3; + let t = tan(a); + let at = atan(t); + + // Display the values. + text(`${round(a, 3)}`, 35, 25); + text(`${round(t, 3)}`, 35, 50); + text(`${round(at, 3)}`, 35, 75); + + describe('The numbers 1.047, 1.732, and 1.047 written on separate rows.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Calculate tan() and atan() values. + let a = PI + PI / 3; + let t = tan(a); + let at = atan(t); + + // Display the values. + text(`${round(a, 3)}`, 35, 25); + text(`${round(t, 3)}`, 35, 50); + text(`${round(at, 3)}`, 35, 75); + + describe('The numbers 4.189, 1.732, and 1.047 written on separate rows.'); + } + +
+class: p5 +params: + - name: value + description: | +

value whose arc tangent is to be returned.

+ type: Number +return: + description: arc tangent of the given value. + type: Number +chainable: false +--- + + +# atan diff --git a/src/content/reference/en/p5 copy/atan2.mdx b/src/content/reference/en/p5 copy/atan2.mdx new file mode 100644 index 0000000000..200b49516b --- /dev/null +++ b/src/content/reference/en/p5 copy/atan2.mdx @@ -0,0 +1,106 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L204 +title: atan2 +module: Math +submodule: Trigonometry +file: src/math/trigonometry.js +description: > +

Calculates the angle formed by a point, the origin, and the positive + + x-axis.

+ +

atan2() is most often used for orienting geometry to the + mouse's + + position, as in atan2(mouseY, mouseX). The first parameter is the + point's + + y-coordinate and the second parameter is its x-coordinate.

+ +

By default, atan2() returns values in the range + + -π (about -3.14) to π (3.14). If the + + angleMode() is DEGREES, + then values are + + returned in the range -180 to 180.

+line: 204 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A rectangle at the top-left of the canvas rotates with mouse movements.'); + } + + function draw() { + background(200); + + // Calculate the angle between the mouse + // and the origin. + let a = atan2(mouseY, mouseX); + + // Rotate. + rotate(a); + + // Draw the shape. + rect(0, 0, 60, 10); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A rectangle at the center of the canvas rotates with mouse movements.'); + } + + function draw() { + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Get the mouse's coordinates relative to the origin. + let x = mouseX - 50; + let y = mouseY - 50; + + // Calculate the angle between the mouse and the origin. + let a = atan2(y, x); + + // Rotate. + rotate(a); + + // Draw the shape. + rect(-30, -5, 60, 10); + } + +
+class: p5 +params: + - name: 'y' + description: | +

y-coordinate of the point.

+ type: Number + - name: x + description: | +

x-coordinate of the point.

+ type: Number +return: + description: arc tangent of the given point. + type: Number +chainable: false +--- + + +# atan2 diff --git a/src/content/reference/en/p5 copy/background.mdx b/src/content/reference/en/p5 copy/background.mdx new file mode 100644 index 0000000000..6250c60339 --- /dev/null +++ b/src/content/reference/en/p5 copy/background.mdx @@ -0,0 +1,336 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L414 +title: background +module: Color +submodule: Setting +file: src/color/setting.js +description: > +

Sets the color used for the background of the canvas.

+ +

By default, the background is transparent. background() is + typically used + + within draw() to clear the display window at + the + + beginning of each frame. It can also be used inside + + setup() to set the background on the first + frame + + of animation.

+ +

The version of background() with one parameter interprets the + value one + + of four ways. If the parameter is a Number, it's interpreted as a + grayscale + + value. If the parameter is a String, it's interpreted as a CSS + color string. + + RGB, RGBA, HSL, HSLA, hex, and named color strings are supported. If the + + parameter is a p5.Color object, it will + be used as + + the background color. If the parameter is a + + p5.Image object, it will be used as the + background + + image.

+ +

The version of background() with two parameters interprets the + first one + + as a grayscale value. The second parameter sets the alpha (transparency) + + value.

+ +

The version of background() with three parameters interprets + them as RGB, + + HSB, or HSL colors, depending on the current + + colorMode(). By default, colors are + specified + + in RGB values. Calling background(255, 204, 0) sets the + background a bright + + yellow color.

+ +

The version of background() with four parameters interprets + them as RGBA, + + HSBA, or HSLA colors, depending on the current + + colorMode(). The last parameter sets + the alpha + + (transparency) value.

+line: 414 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // A grayscale value. + background(51); + + describe('A canvas with a dark charcoal gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // A grayscale value and an alpha value. + background(51, 0.4); + describe('A canvas with a transparent gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // R, G & B values. + background(255, 204, 0); + + describe('A canvas with a yellow background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // R, G, B, and Alpha values. + background(255, 0, 0, 128); + + describe('A canvas with a semi-transparent red background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Use HSB color. + colorMode(HSB); + + // H, S & B values. + background(255, 204, 100); + + describe('A canvas with a royal blue background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // A CSS named color. + background('red'); + + describe('A canvas with a red background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Three-digit hex RGB notation. + background('#fae'); + + describe('A canvas with a pink background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Six-digit hex RGB notation. + background('#222222'); + + describe('A canvas with a black background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Integer RGB notation. + background('rgb(0, 255, 0)'); + + describe('A canvas with a bright green background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Integer RGBA notation. + background('rgba(0, 255, 0, 0.25)'); + + describe('A canvas with a transparent green background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Percentage RGB notation. + background('rgb(100%, 0%, 10%)'); + + describe('A canvas with a red background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Percentage RGBA notation. + background('rgba(100%, 0%, 100%, 0.5)'); + + describe('A canvas with a transparent purple background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // A p5.Color object. + let c = color(0, 0, 255); + background(c); + + describe('A canvas with a blue background.'); + } + +
+class: p5 +overloads: + - line: 414 + params: + - name: color + description: > +

any value created by the color() + function

+ type: p5.Color + chainable: 1 + - line: 626 + params: + - name: colorstring + description: | +

color string, possible formats include: integer + rgb() or rgba(), percentage rgb() or rgba(), + 3-digit hex, 6-digit hex.

+ type: String + - name: a + description: | +

opacity of the background relative to current + color range (default is 0-255).

+ type: Number + optional: true + chainable: 1 + - line: 636 + params: + - name: gray + description: | +

specifies a value between white and black.

+ type: Number + - name: a + description: '' + type: Number + optional: true + chainable: 1 + - line: 643 + params: + - name: v1 + description: > +

red value if color mode is RGB, or hue value if color mode is + HSB.

+ type: Number + - name: v2 + description: > +

green value if color mode is RGB, or saturation value if color mode + is HSB.

+ type: Number + - name: v3 + description: > +

blue value if color mode is RGB, or brightness value if color mode + is HSB.

+ type: Number + - name: a + description: '' + type: Number + optional: true + chainable: 1 + - line: 652 + params: + - name: values + description: | +

an array containing the red, green, blue + and alpha components of the color.

+ type: 'Number[]' + chainable: 1 + - line: 659 + params: + - name: image + description: | +

image created with loadImage() + or createImage(), + to set as background. + (must be same size as the sketch window).

+ type: p5.Image + - name: a + description: '' + type: Number + optional: true + chainable: 1 +chainable: true +--- + + +# background diff --git a/src/content/reference/en/p5 copy/baseColorShader.mdx b/src/content/reference/en/p5 copy/baseColorShader.mdx new file mode 100644 index 0000000000..a608e4d5ce --- /dev/null +++ b/src/content/reference/en/p5 copy/baseColorShader.mdx @@ -0,0 +1,178 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1292 +title: baseColorShader +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Get the shader used when no lights or materials are applied.

+ +

You can call baseColorShader().modify() + + and change any of the following hooks:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
HookDescription
void beforeVertexCalled at the start of the vertex shader.
vec3 getLocalPositionUpdate the position of vertices before transforms are applied. It takes in + vec3 position and must return a modified version.
vec3 getWorldPositionUpdate the position of vertices after transforms are applied. It takes in + vec3 position and pust return a modified version.
vec3 getLocalNormalUpdate the normal before transforms are applied. It takes in vec3 + normal and must return a modified version.
vec3 getWorldNormalUpdate the normal after transforms are applied. It takes in vec3 + normal and must return a modified version.
vec2 getUVUpdate the texture coordinates. It takes in vec2 uv and must + return a modified version.
vec4 getVertexColorUpdate the color of each vertex. It takes in a vec4 color and + must return a modified version.
void afterVertexCalled at the end of the vertex shader.
void beforeFragmentCalled at the start of the fragment shader.
vec4 getFinalColorUpdate the final color after mixing. It takes in a vec4 color + and must return a modified version.
void afterFragmentCalled at the end of the fragment shader.
+ +

Most of the time, you will need to write your hooks in GLSL ES version 300. + If you + + are using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.

+ +

Call baseColorShader().inspectHooks() to see all the possible + hooks and + + their default implementations.

+line: 1292 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let myShader; + + function setup() { + createCanvas(200, 200, WEBGL); + myShader = baseColorShader().modify({ + uniforms: { + 'float time': () => millis() + }, + 'vec3 getWorldPosition': `(vec3 pos) { + pos.y += 20. * sin(time * 0.001 + pos.x * 0.05); + return pos; + }` + }); + } + + function draw() { + background(255); + shader(myShader); + noStroke(); + fill('red'); + circle(0, 0, 50); + } + +
+class: p5 +return: + description: The color shader + type: p5.Shader +chainable: false +beta: true +--- + + +# baseColorShader diff --git a/src/content/reference/en/p5 copy/baseMaterialShader.mdx b/src/content/reference/en/p5 copy/baseMaterialShader.mdx new file mode 100644 index 0000000000..d41248d1aa --- /dev/null +++ b/src/content/reference/en/p5 copy/baseMaterialShader.mdx @@ -0,0 +1,418 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L886 +title: baseMaterialShader +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Get the default shader used with lights, materials, + + and textures.

+ +

You can call baseMaterialShader().modify() + + and change any of the following hooks:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
HookDescription
+ + +

void beforeVertex

+ +
+ + +

Called at the start of the vertex shader.

+ +
+ + +

vec3 getLocalPosition

+ +
+ + +

Update the position of vertices before transforms are applied. It takes in + vec3 position and must return a modified version.

+ +
+ + +

vec3 getWorldPosition

+ +
+ + +

Update the position of vertices after transforms are applied. It takes in + vec3 position and pust return a modified version.

+ +
+ + +

vec3 getLocalNormal

+ +
+ + +

Update the normal before transforms are applied. It takes in vec3 + normal and must return a modified version.

+ +
+ + +

vec3 getWorldNormal

+ +
+ + +

Update the normal after transforms are applied. It takes in vec3 + normal and must return a modified version.

+ +
+ + +

vec2 getUV

+ +
+ + +

Update the texture coordinates. It takes in vec2 uv and must + return a modified version.

+ +
+ + +

vec4 getVertexColor

+ +
+ + +

Update the color of each vertex. It takes in a vec4 color and + must return a modified version.

+ +
+ + +

void afterVertex

+ +
+ + +

Called at the end of the vertex shader.

+ +
+ + +

void beforeFragment

+ +
+ + +

Called at the start of the fragment shader.

+ +
+ + +

Inputs getPixelInputs

+ +
+ + +

Update the per-pixel inputs of the material. It takes in an + Inputs struct, which includes:

+ +
    + +
  • vec3 normal, the direction pointing out of the surface
  • + +
  • vec2 texCoord, a vector where x and + y are between 0 and 1 describing the spot on a texture the pixel + is mapped to, as a fraction of the texture size
  • + +
  • vec3 ambientLight, the ambient light color on the vertex
  • + +
  • vec4 color, the base material color of the pixel
  • + +
  • vec3 ambientMaterial, the color of the pixel when affected by + ambient light
  • + +
  • vec3 specularMaterial, the color of the pixel when reflecting + specular highlights
  • + +
  • vec3 emissiveMaterial, the light color emitted by the + pixel
  • + +
  • float shininess, a number representing how sharp specular + reflections should be, from 1 to infinity
  • + +
  • float metalness, a number representing how mirrorlike the + material should be, between 0 and 1 + + The struct can be modified and returned.
+ + +

vec4 combineColors

+ +
+ + +

Take in a ColorComponents struct containing all the different + components of light, and combining them into + + a single final color. The struct contains:

+ +
    + +
  • vec3 baseColor, the base color of the pixel
  • + +
  • float opacity, the opacity between 0 and 1 that it should be + drawn at
  • + +
  • vec3 ambientColor, the color of the pixel when affected by + ambient light
  • + +
  • vec3 specularColor, the color of the pixel when affected by + specular reflections
  • + +
  • vec3 diffuse, the amount of diffused light hitting the + pixel
  • + +
  • vec3 ambient, the amount of ambient light hitting the + pixel
  • + +
  • vec3 specular, the amount of specular reflection hitting the + pixel
  • + +
  • vec3 emissive, the amount of light emitted by the pixel
  • + +
+ +
+ + +

vec4 getFinalColor

+ +
+ + +

Update the final color after mixing. It takes in a vec4 color + and must return a modified version.

+ +
+ + +

void afterFragment

+ +
+ + +

Called at the end of the fragment shader.

+ +
+ + +

Most of the time, you will need to write your hooks in GLSL ES version 300. + If you + + are using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.

+ +

Call baseMaterialShader().inspectHooks() to see all the + possible hooks and + + their default implementations.

+line: 886 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let myShader; + + function setup() { + createCanvas(200, 200, WEBGL); + myShader = baseMaterialShader().modify({ + uniforms: { + 'float time': () => millis() + }, + 'vec3 getWorldPosition': `(vec3 pos) { + pos.y += 20.0 * sin(time * 0.001 + pos.x * 0.05); + return pos; + }` + }); + } + + function draw() { + background(255); + shader(myShader); + lights(); + noStroke(); + fill('red'); + sphere(50); + } + +
+ - |- + +
+ + let myShader; + + function setup() { + createCanvas(200, 200, WEBGL); + myShader = baseMaterialShader().modify({ + declarations: 'vec3 myNormal;', + 'Inputs getPixelInputs': `(Inputs inputs) { + myNormal = inputs.normal; + return inputs; + }`, + 'vec4 getFinalColor': `(vec4 color) { + return mix( + vec4(1.0, 1.0, 1.0, 1.0), + color, + abs(dot(myNormal, vec3(0.0, 0.0, 1.0))) + ); + }` + }); + } + + function draw() { + background(255); + rotateY(millis() * 0.001); + shader(myShader); + lights(); + noStroke(); + fill('red'); + torus(30); + } + +
+ - |- + +
+ + let myShader; + let environment; + + function preload() { + environment = loadImage('/assets/outdoor_spheremap.jpg'); + } + + function setup() { + createCanvas(200, 200, WEBGL); + myShader = baseMaterialShader().modify({ + 'Inputs getPixelInputs': `(Inputs inputs) { + float factor = + sin( + inputs.texCoord.x * ${TWO_PI} + + inputs.texCoord.y * ${TWO_PI} + ) * 0.4 + 0.5; + inputs.shininess = mix(1., 100., factor); + inputs.metalness = factor; + return inputs; + }` + }); + } + + function draw() { + panorama(environment); + ambientLight(100); + imageLight(environment); + rotateY(millis() * 0.001); + shader(myShader); + noStroke(); + fill(255); + specularMaterial(150); + sphere(50); + } + +
+ - |- + +
+ + let myShader; + + function setup() { + createCanvas(200, 200, WEBGL); + myShader = baseMaterialShader().modify({ + 'Inputs getPixelInputs': `(Inputs inputs) { + vec3 newNormal = inputs.normal; + // Simple bump mapping: adjust the normal based on position + newNormal.x += 0.2 * sin( + sin( + inputs.texCoord.y * ${TWO_PI} * 10.0 + + inputs.texCoord.x * ${TWO_PI} * 25.0 + ) + ); + newNormal.y += 0.2 * sin( + sin( + inputs.texCoord.x * ${TWO_PI} * 10.0 + + inputs.texCoord.y * ${TWO_PI} * 25.0 + ) + ); + inputs.normal = normalize(newNormal); + return inputs; + }` + }); + } + + function draw() { + background(255); + shader(myShader); + ambientLight(150); + pointLight( + 255, 255, 255, + 100*cos(frameCount*0.04), -50, 100*sin(frameCount*0.04) + ); + noStroke(); + fill('red'); + shininess(200); + specularMaterial(255); + sphere(50); + } + +
+class: p5 +return: + description: The material shader + type: p5.Shader +chainable: false +beta: true +--- + + +# baseMaterialShader diff --git a/src/content/reference/en/p5 copy/baseNormalShader.mdx b/src/content/reference/en/p5 copy/baseNormalShader.mdx new file mode 100644 index 0000000000..4eac6e9109 --- /dev/null +++ b/src/content/reference/en/p5 copy/baseNormalShader.mdx @@ -0,0 +1,211 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1197 +title: baseNormalShader +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Get the shader used by normalMaterial().

+ +

You can call baseNormalShader().modify() + + and change any of the following hooks:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
HookDescription
void beforeVertexCalled at the start of the vertex shader.
vec3 getLocalPositionUpdate the position of vertices before transforms are applied. It takes in + vec3 position and must return a modified version.
vec3 getWorldPositionUpdate the position of vertices after transforms are applied. It takes in + vec3 position and pust return a modified version.
vec3 getLocalNormalUpdate the normal before transforms are applied. It takes in vec3 + normal and must return a modified version.
vec3 getWorldNormalUpdate the normal after transforms are applied. It takes in vec3 + normal and must return a modified version.
vec2 getUVUpdate the texture coordinates. It takes in vec2 uv and must + return a modified version.
vec4 getVertexColorUpdate the color of each vertex. It takes in a vec4 color and + must return a modified version.
void afterVertexCalled at the end of the vertex shader.
void beforeFragmentCalled at the start of the fragment shader.
vec4 getFinalColorUpdate the final color after mixing. It takes in a vec4 color + and must return a modified version.
void afterFragmentCalled at the end of the fragment shader.
+ +

Most of the time, you will need to write your hooks in GLSL ES version 300. + If you + + are using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.

+ +

Call baseNormalShader().inspectHooks() to see all the possible + hooks and + + their default implementations.

+line: 1197 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let myShader; + + function setup() { + createCanvas(200, 200, WEBGL); + myShader = baseNormalShader().modify({ + uniforms: { + 'float time': () => millis() + }, + 'vec3 getWorldPosition': `(vec3 pos) { + pos.y += 20. * sin(time * 0.001 + pos.x * 0.05); + return pos; + }` + }); + } + + function draw() { + background(255); + shader(myShader); + noStroke(); + sphere(50); + } + +
+ - |- + +
+ + let myShader; + + function setup() { + createCanvas(200, 200, WEBGL); + myShader = baseNormalShader().modify({ + 'vec3 getWorldNormal': '(vec3 normal) { return abs(normal); }', + 'vec4 getFinalColor': `(vec4 color) { + // Map the r, g, and b values of the old normal to new colors + // instead of just red, green, and blue: + vec3 newColor = + color.r * vec3(89.0, 240.0, 232.0) / 255.0 + + color.g * vec3(240.0, 237.0, 89.0) / 255.0 + + color.b * vec3(205.0, 55.0, 222.0) / 255.0; + newColor = newColor / (color.r + color.g + color.b); + return vec4(newColor, 1.0) * color.a; + }` + }); + } + + function draw() { + background(255); + shader(myShader); + noStroke(); + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.015); + box(100); + } + +
+class: p5 +return: + description: The `normalMaterial` shader + type: p5.Shader +chainable: false +beta: true +--- + + +# baseNormalShader diff --git a/src/content/reference/en/p5 copy/baseStrokeShader.mdx b/src/content/reference/en/p5 copy/baseStrokeShader.mdx new file mode 100644 index 0000000000..f2bfb42be5 --- /dev/null +++ b/src/content/reference/en/p5 copy/baseStrokeShader.mdx @@ -0,0 +1,356 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1355 +title: baseStrokeShader +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Get the shader used when drawing the strokes of shapes.

+ +

You can call baseStrokeShader().modify() + + and change any of the following hooks:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
HookDescription
+ + +

void beforeVertex

+ +
+ + +

Called at the start of the vertex shader.

+ +
+ + +

vec3 getLocalPosition

+ +
+ + +

Update the position of vertices before transforms are applied. It takes in + vec3 position and must return a modified version.

+ +
+ + +

vec3 getWorldPosition

+ +
+ + +

Update the position of vertices after transforms are applied. It takes in + vec3 position and pust return a modified version.

+ +
+ + +

float getStrokeWeight

+ +
+ + +

Update the stroke weight. It takes in float weight and pust + return a modified version.

+ +
+ + +

vec2 getLineCenter

+ +
+ + +

Update the center of the line. It takes in vec2 center and + must return a modified version.

+ +
+ + +

vec2 getLinePosition

+ +
+ + +

Update the position of each vertex on the edge of the line. It takes in + vec2 position and must return a modified version.

+ +
+ + +

vec4 getVertexColor

+ +
+ + +

Update the color of each vertex. It takes in a vec4 color and + must return a modified version.

+ +
+ + +

void afterVertex

+ +
+ + +

Called at the end of the vertex shader.

+ +
+ + +

void beforeFragment

+ +
+ + +

Called at the start of the fragment shader.

+ +
+ + +

Inputs getPixelInputs

+ +
+ + +

Update the inputs to the shader. It takes in a struct Inputs + inputs, which includes:

+ +
    + +
  • vec4 color, the color of the stroke
  • + +
  • vec2 tangent, the direction of the stroke in screen + space
  • + +
  • vec2 center, the coordinate of the center of the stroke in + screen space p5.js pixels
  • + +
  • vec2 position, the coordinate of the current pixel in screen + space p5.js pixels
  • + +
  • float strokeWeight, the thickness of the stroke in p5.js + pixels
  • + +
+ +
+ + +

bool shouldDiscard

+ +
+ + +

Caps and joins are made by discarded pixels in the fragment shader to carve + away unwanted areas. Use this to change this logic. It takes in a bool + willDiscard and must return a modified version.

+ +
+ + +

vec4 getFinalColor

+ +
+ + +

Update the final color after mixing. It takes in a vec4 color + and must return a modified version.

+ +
+ + +

void afterFragment

+ +
+ + +

Called at the end of the fragment shader.

+ +
+ + +

Most of the time, you will need to write your hooks in GLSL ES version 300. + If you + + are using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.

+ +

Call baseStrokeShader().inspectHooks() to see all the possible + hooks and + + their default implementations.

+line: 1355 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let myShader; + + function setup() { + createCanvas(200, 200, WEBGL); + myShader = baseStrokeShader().modify({ + 'Inputs getPixelInputs': `(Inputs inputs) { + float opacity = 1.0 - smoothstep( + 0.0, + 15.0, + length(inputs.position - inputs.center) + ); + inputs.color *= opacity; + return inputs; + }` + }); + } + + function draw() { + background(255); + shader(myShader); + strokeWeight(30); + line( + -width/3, + sin(millis()*0.001) * height/4, + width/3, + sin(millis()*0.001 + 1) * height/4 + ); + } + +
+ - |- + +
+ + let myShader; + + function setup() { + createCanvas(200, 200, WEBGL); + myShader = baseStrokeShader().modify({ + uniforms: { + 'float time': () => millis() + }, + declarations: 'vec3 myPosition;', + 'vec3 getWorldPosition': `(vec3 pos) { + myPosition = pos; + return pos; + }`, + 'float getStrokeWeight': `(float w) { + // Add a somewhat random offset to the weight + // that varies based on position and time + float scale = 0.8 + 0.2*sin(10.0 * sin( + floor(time/250.) + + myPosition.x*0.01 + + myPosition.y*0.01 + )); + return w * scale; + }` + }); + } + + function draw() { + background(255); + shader(myShader); + myShader.setUniform('time', millis()); + strokeWeight(10); + beginShape(); + for (let i = 0; i <= 50; i++) { + let r = map(i, 0, 50, 0, width/3); + let x = r*cos(i*0.2); + let y = r*sin(i*0.2); + vertex(x, y); + } + endShape(); + } + +
+ - |- + +
+ + let myShader; + + function setup() { + createCanvas(200, 200, WEBGL); + myShader = baseStrokeShader().modify({ + 'float random': `(vec2 p) { + vec3 p3 = fract(vec3(p.xyx) * .1031); + p3 += dot(p3, p3.yzx + 33.33); + return fract((p3.x + p3.y) * p3.z); + }`, + 'Inputs getPixelInputs': `(Inputs inputs) { + // Replace alpha in the color with dithering by + // randomly setting pixel colors to 0 based on opacity + float a = inputs.color.a; + inputs.color.a = 1.0; + inputs.color *= random(inputs.position.xy) > a ? 0.0 : 1.0; + return inputs; + }` + }); + } + + function draw() { + background(255); + shader(myShader); + strokeWeight(10); + beginShape(); + for (let i = 0; i <= 50; i++) { + stroke( + 0, + 255 + * map(i, 0, 20, 0, 1, true) + * map(i, 30, 50, 1, 0, true) + ); + vertex( + map(i, 0, 50, -1, 1) * width/3, + 50 * sin(i/10 + frameCount/100) + ); + } + endShape(); + } + +
+class: p5 +return: + description: The stroke shader + type: p5.Shader +chainable: false +beta: true +--- + + +# baseStrokeShader diff --git a/src/content/reference/en/p5 copy/beginClip.mdx b/src/content/reference/en/p5 copy/beginClip.mdx new file mode 100644 index 0000000000..ebad022a68 --- /dev/null +++ b/src/content/reference/en/p5 copy/beginClip.mdx @@ -0,0 +1,208 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L13 +title: beginClip +module: Color +submodule: Setting +file: src/color/setting.js +description: > +

Starts defining a shape that will mask any shapes drawn afterward.

+ +

Any shapes drawn between beginClip() and + + endClip() will add to the mask shape. The + mask + + will apply to anything drawn after endClip().

+ +

The parameter, options, is optional. If an object with an + invert + + property is passed, as in beginClip({ invert: true }), it will be + used to + + set the masking mode. { invert: true } inverts the mask, creating + holes + + in shapes that are masked. invert is false by + default.

+ +

Masks can be contained between the + + push() and pop() functions. + + Doing so allows unmasked shapes to be drawn after masked shapes.

+ +

Masks can also be defined in a callback function that's passed to + + clip().

+line: 13 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a mask. + beginClip(); + triangle(15, 37, 30, 13, 43, 37); + circle(45, 45, 7); + endClip(); + + // Draw a backing shape. + square(5, 5, 45); + + describe('A white triangle and circle on a gray background.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an inverted mask. + beginClip({ invert: true }); + triangle(15, 37, 30, 13, 43, 37); + circle(45, 45, 7); + endClip(); + + // Draw a backing shape. + square(5, 5, 45); + + describe('A white square at the top-left corner of a gray square. The white square has a triangle and a circle cut out of it.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + noStroke(); + + // Draw a masked shape. + push(); + // Create a mask. + beginClip(); + triangle(15, 37, 30, 13, 43, 37); + circle(45, 45, 7); + endClip(); + + // Draw a backing shape. + square(5, 5, 45); + pop(); + + // Translate the origin to the center. + translate(50, 50); + + // Draw an inverted masked shape. + push(); + // Create an inverted mask. + beginClip({ invert: true }); + triangle(15, 37, 30, 13, 43, 37); + circle(45, 45, 7); + endClip(); + + // Draw a backing shape. + square(5, 5, 45); + pop(); + + describe('In the top left, a white triangle and circle. In the bottom right, a white square with a triangle and circle cut out of it.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A silhouette of a rotating torus colored fuchsia.'); + } + + function draw() { + background(200); + + // Create a mask. + beginClip(); + push(); + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + scale(0.5); + torus(30, 15); + pop(); + endClip(); + + // Draw a backing shape. + noStroke(); + fill('fuchsia'); + plane(100); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A silhouette of a rotating torus colored with a gradient from cyan to purple.'); + } + + function draw() { + background(200); + + // Create a mask. + beginClip(); + push(); + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + scale(0.5); + torus(30, 15); + pop(); + endClip(); + + // Draw a backing shape. + noStroke(); + beginShape(QUAD_STRIP); + fill(0, 255, 255); + vertex(-width / 2, -height / 2); + vertex(width / 2, -height / 2); + fill(100, 0, 100); + vertex(-width / 2, height / 2); + vertex(width / 2, height / 2); + endShape(); + } + +
+class: p5 +params: + - name: options + description: | +

an object containing clip settings.

+ type: Object + optional: true +chainable: false +--- + + +# beginClip diff --git a/src/content/reference/en/p5 copy/beginContour.mdx b/src/content/reference/en/p5 copy/beginContour.mdx new file mode 100644 index 0000000000..5ecd6d1437 --- /dev/null +++ b/src/content/reference/en/p5 copy/beginContour.mdx @@ -0,0 +1,134 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L20 +title: beginContour +module: Shape +submodule: Vertex +file: src/core/shape/vertex.js +description: > +

Begins creating a hole within a flat shape.

+ +

The beginContour() and endContour() + + functions allow for creating negative space within custom shapes that are + + flat. beginContour() begins adding vertices to a negative space + and + + endContour() stops adding them. + + beginContour() and endContour() must be + + called between beginShape() and + + endShape().

+ +

Transformations such as translate(), + + rotate(), and scale() + + don't work between beginContour() and + + endContour(). It's also not possible + to use + + other shapes, such as ellipse() or + + rect(), between beginContour() + and + + endContour().

+ +

Note: The vertices that define a negative space must "wind" in the opposite + + direction from the outer shape. First, draw vertices for the outer shape + + clockwise order. Then, draw vertices for the negative space in + + counter-clockwise order.

+line: 20 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + beginShape(); + + // Exterior vertices, clockwise winding. + vertex(10, 10); + vertex(90, 10); + vertex(90, 90); + vertex(10, 90); + + // Interior vertices, counter-clockwise winding. + beginContour(); + vertex(30, 30); + vertex(30, 70); + vertex(70, 70); + vertex(70, 30); + endContour(); + + // Stop drawing the shape. + endShape(CLOSE); + + describe('A white square with a square hole in its center drawn on a gray background.'); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white square with a square hole in its center drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Start drawing the shape. + beginShape(); + + // Exterior vertices, clockwise winding. + vertex(-40, -40); + vertex(40, -40); + vertex(40, 40); + vertex(-40, 40); + + // Interior vertices, counter-clockwise winding. + beginContour(); + vertex(-20, -20); + vertex(-20, 20); + vertex(20, 20); + vertex(20, -20); + endContour(); + + // Stop drawing the shape. + endShape(CLOSE); + } + +
+class: p5 +chainable: true +--- + + +# beginContour diff --git a/src/content/reference/en/p5 copy/beginGeometry.mdx b/src/content/reference/en/p5 copy/beginGeometry.mdx new file mode 100644 index 0000000000..3fdf211bd3 --- /dev/null +++ b/src/content/reference/en/p5 copy/beginGeometry.mdx @@ -0,0 +1,281 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L13 +title: beginGeometry +module: Shape +submodule: 3D Primitives +file: src/webgl/3d_primitives.js +description: > +

Begins adding shapes to a new + + p5.Geometry object.

+ +

The beginGeometry() and endGeometry() + + functions help with creating complex 3D shapes from simpler ones such as + + sphere(). beginGeometry() + begins adding shapes + + to a custom p5.Geometry object and + + endGeometry() stops adding them.

+ +

beginGeometry() and endGeometry() can help + + to make sketches more performant. For example, if a complex 3D shape + + doesn’t change while a sketch runs, then it can be created with + + beginGeometry() and endGeometry(). + + Creating a p5.Geometry object once and + then + + drawing it will run faster than repeatedly drawing the individual pieces.

+ +

See buildGeometry() for another + way to + + build 3D shapes.

+ +

Note: beginGeometry() can only be used in WebGL mode.

+line: 13 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Start building the p5.Geometry object. + beginGeometry(); + + // Add a cone. + cone(); + + // Stop building the p5.Geometry object. + shape = endGeometry(); + + describe('A white cone drawn on a gray background.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the p5.Geometry object. + noStroke(); + + // Draw the p5.Geometry object. + model(shape); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the p5.Geometry object. + createArrow(); + + describe('A white arrow drawn on a gray background.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the p5.Geometry object. + noStroke(); + + // Draw the p5.Geometry object. + model(shape); + } + + function createArrow() { + // Start building the p5.Geometry object. + beginGeometry(); + + // Add shapes. + push(); + rotateX(PI); + cone(10); + translate(0, -10, 0); + cylinder(3, 20); + pop(); + + // Stop building the p5.Geometry object. + shape = endGeometry(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let blueArrow; + let redArrow; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the arrows. + redArrow = createArrow('red'); + blueArrow = createArrow('blue'); + + describe('A red arrow and a blue arrow drawn on a gray background. The blue arrow rotates slowly.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the arrows. + noStroke(); + + // Draw the red arrow. + model(redArrow); + + // Translate and rotate the coordinate system. + translate(30, 0, 0); + rotateZ(frameCount * 0.01); + + // Draw the blue arrow. + model(blueArrow); + } + + function createArrow(fillColor) { + // Start building the p5.Geometry object. + beginGeometry(); + + fill(fillColor); + + // Add shapes to the p5.Geometry object. + push(); + rotateX(PI); + cone(10); + translate(0, -10, 0); + cylinder(3, 20); + pop(); + + // Stop building the p5.Geometry object. + let shape = endGeometry(); + + return shape; + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let button; + let particles; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a button to reset the particle system. + button = createButton('Reset'); + + // Call resetModel() when the user presses the button. + button.mousePressed(resetModel); + + // Add the original set of particles. + resetModel(); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the particles. + noStroke(); + + // Draw the particles. + model(particles); + } + + function resetModel() { + // If the p5.Geometry object has already been created, + // free those resources. + if (particles) { + freeGeometry(particles); + } + + // Create a new p5.Geometry object with random spheres. + particles = createParticles(); + } + + function createParticles() { + // Start building the p5.Geometry object. + beginGeometry(); + + // Add shapes. + for (let i = 0; i < 60; i += 1) { + // Calculate random coordinates. + let x = randomGaussian(0, 20); + let y = randomGaussian(0, 20); + let z = randomGaussian(0, 20); + + push(); + // Translate to the particle's coordinates. + translate(x, y, z); + // Draw the particle. + sphere(5); + pop(); + } + + // Stop building the p5.Geometry object. + let shape = endGeometry(); + + return shape; + } + +
+class: p5 +chainable: false +--- + + +# beginGeometry diff --git a/src/content/reference/en/p5 copy/beginShape.mdx b/src/content/reference/en/p5 copy/beginShape.mdx new file mode 100644 index 0000000000..d8642333db --- /dev/null +++ b/src/content/reference/en/p5 copy/beginShape.mdx @@ -0,0 +1,449 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L129 +title: beginShape +module: Shape +submodule: Vertex +file: src/core/shape/vertex.js +description: > +

Begins adding vertices to a custom shape.

+ +

The beginShape() and endShape() functions + + allow for creating custom shapes in 2D or 3D. beginShape() begins + adding + + vertices to a custom shape and endShape() stops + + adding them.

+ +

The parameter, kind, sets the kind of shape to make. By + default, any + + irregular polygon can be drawn. The available modes for kind are:

+ +
    + +
  • POINTS to draw a series of points.
  • + +
  • LINES to draw a series of unconnected line segments.
  • + +
  • TRIANGLES to draw a series of separate triangles.
  • + +
  • TRIANGLE_FAN to draw a series of connected triangles sharing + the first vertex in a fan-like fashion.
  • + +
  • TRIANGLE_STRIP to draw a series of connected triangles in + strip fashion.
  • + +
  • QUADS to draw a series of separate quadrilaterals + (quads).
  • + +
  • QUAD_STRIP to draw quad strip using adjacent edges to form + the next quad.
  • + +
  • TESS to create a filling curve by explicit tessellation + (WebGL only).
  • + +
+ +

After calling beginShape(), shapes can be built by calling + + vertex(), + + bezierVertex(), + + quadraticVertex(), and/or + + curveVertex(). Calling + + endShape() will stop adding vertices to + the + + shape. Each shape will be outlined with the current stroke color and filled + + with the current fill color.

+ +

Transformations such as translate(), + + rotate(), and + + scale() don't work between + beginShape() and + + endShape(). It's also not possible to + use + + other shapes, such as ellipse() or + + rect(), between beginShape() + and + + endShape().

+line: 129 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + beginShape(); + + // Add vertices. + vertex(30, 20); + vertex(85, 20); + vertex(85, 75); + vertex(30, 75); + + // Stop drawing the shape. + endShape(CLOSE); + + describe('A white square on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + // Only draw the vertices (points). + beginShape(POINTS); + + // Add vertices. + vertex(30, 20); + vertex(85, 20); + vertex(85, 75); + vertex(30, 75); + + // Stop drawing the shape. + endShape(); + + describe('Four black dots that form a square are drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + // Only draw lines between alternating pairs of vertices. + beginShape(LINES); + + // Add vertices. + vertex(30, 20); + vertex(85, 20); + vertex(85, 75); + vertex(30, 75); + + // Stop drawing the shape. + endShape(); + + describe('Two horizontal black lines on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the shape. + noFill(); + + // Start drawing the shape. + beginShape(); + + // Add vertices. + vertex(30, 20); + vertex(85, 20); + vertex(85, 75); + vertex(30, 75); + + // Stop drawing the shape. + endShape(); + + describe('Three black lines form a sideways U shape on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the shape. + noFill(); + + // Start drawing the shape. + beginShape(); + + // Add vertices. + vertex(30, 20); + vertex(85, 20); + vertex(85, 75); + vertex(30, 75); + + // Stop drawing the shape. + // Connect the first and last vertices. + endShape(CLOSE); + + describe('A black outline of a square drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + // Draw a series of triangles. + beginShape(TRIANGLES); + + // Left triangle. + vertex(30, 75); + vertex(40, 20); + vertex(50, 75); + + // Right triangle. + vertex(60, 20); + vertex(70, 75); + vertex(80, 20); + + // Stop drawing the shape. + endShape(); + + describe('Two white triangles drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + // Draw a series of triangles. + beginShape(TRIANGLE_STRIP); + + // Add vertices. + vertex(30, 75); + vertex(40, 20); + vertex(50, 75); + vertex(60, 20); + vertex(70, 75); + vertex(80, 20); + vertex(90, 75); + + // Stop drawing the shape. + endShape(); + + describe('Five white triangles that are interleaved drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + // Draw a series of triangles that share their first vertex. + beginShape(TRIANGLE_FAN); + + // Add vertices. + vertex(57.5, 50); + vertex(57.5, 15); + vertex(92, 50); + vertex(57.5, 85); + vertex(22, 50); + vertex(57.5, 15); + + // Stop drawing the shape. + endShape(); + + describe('Four white triangles form a square are drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + // Draw a series of quadrilaterals. + beginShape(QUADS); + + // Left rectangle. + vertex(30, 20); + vertex(30, 75); + vertex(50, 75); + vertex(50, 20); + + // Right rectangle. + vertex(65, 20); + vertex(65, 75); + vertex(85, 75); + vertex(85, 20); + + // Stop drawing the shape. + endShape(); + + describe('Two white rectangles drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + // Draw a series of quadrilaterals. + beginShape(QUAD_STRIP); + + // Add vertices. + vertex(30, 20); + vertex(30, 75); + vertex(50, 20); + vertex(50, 75); + vertex(65, 20); + vertex(65, 75); + vertex(85, 20); + vertex(85, 75); + + // Stop drawing the shape. + endShape(); + + describe('Three white rectangles that share edges are drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + // Start drawing the shape. + // Draw a series of quadrilaterals. + beginShape(TESS); + + // Add the vertices. + vertex(-30, -30, 0); + vertex(30, -30, 0); + vertex(30, -10, 0); + vertex(-10, -10, 0); + vertex(-10, 10, 0); + vertex(30, 10, 0); + vertex(30, 30, 0); + vertex(-30, 30, 0); + + // Stop drawing the shape. + // Connect the first and last vertices. + endShape(CLOSE); + + describe('A blocky C shape drawn in white on a gray background.'); + } + +
+ +
+ + // Click and drag with the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A blocky C shape drawn in red, blue, and green on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Start drawing the shape. + // Draw a series of quadrilaterals. + beginShape(TESS); + + // Add the vertices. + fill('red'); + stroke('red'); + vertex(-30, -30, 0); + vertex(30, -30, 0); + vertex(30, -10, 0); + fill('green'); + stroke('green'); + vertex(-10, -10, 0); + vertex(-10, 10, 0); + vertex(30, 10, 0); + fill('blue'); + stroke('blue'); + vertex(30, 30, 0); + vertex(-30, 30, 0); + + // Stop drawing the shape. + // Connect the first and last vertices. + endShape(CLOSE); + } + +
+class: p5 +params: + - name: kind + description: | +

either POINTS, LINES, TRIANGLES, TRIANGLE_FAN + TRIANGLE_STRIP, QUADS, QUAD_STRIP or TESS.

+ type: Constant + optional: true +chainable: true +--- + + +# beginShape diff --git a/src/content/reference/en/p5 copy/bezier.mdx b/src/content/reference/en/p5 copy/bezier.mdx new file mode 100644 index 0000000000..50c15330b7 --- /dev/null +++ b/src/content/reference/en/p5 copy/bezier.mdx @@ -0,0 +1,273 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L13 +title: bezier +module: Shape +submodule: Curves +file: src/core/shape/curves.js +description: > +

Draws a Bézier curve.

+ +

Bézier curves can form shapes and curves that slope gently. They're defined + + by two anchor points and two control points. Bézier curves provide more + + control than the spline curves created with the + + curve() function.

+ +

The first two parameters, x1 and y1, set the + first anchor point. The + + first anchor point is where the curve starts.

+ +

The next four parameters, x2, y2, + x3, and y3, set the two control + + points. The control points "pull" the curve towards them.

+ +

The seventh and eighth parameters, x4 and y4, set + the last anchor + + point. The last anchor point is where the curve ends.

+ +

Bézier curves can also be drawn in 3D using WebGL mode. The 3D version of + + bezier() has twelve arguments because each point has x-, y-, + + and z-coordinates.

+line: 13 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw the anchor points in black. + stroke(0); + strokeWeight(5); + point(85, 20); + point(15, 80); + + // Draw the control points in red. + stroke(255, 0, 0); + point(10, 10); + point(90, 90); + + // Draw a black bezier curve. + noFill(); + stroke(0); + strokeWeight(1); + bezier(85, 20, 10, 10, 90, 90, 15, 80); + + // Draw red lines from the anchor points to the control points. + stroke(255, 0, 0); + line(85, 20, 10, 10); + line(15, 80, 90, 90); + + describe( + 'A gray square with three curves. A black s-curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' + ); + } + +
+ +
+ + // Click the mouse near the red dot in the top-left corner + // and drag to change the curve's shape. + + let x2 = 10; + let y2 = 10; + let isChanging = false; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with three curves. A black s-curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' + ); + } + + function draw() { + background(200); + + // Draw the anchor points in black. + stroke(0); + strokeWeight(5); + point(85, 20); + point(15, 80); + + // Draw the control points in red. + stroke(255, 0, 0); + point(x2, y2); + point(90, 90); + + // Draw a black bezier curve. + noFill(); + stroke(0); + strokeWeight(1); + bezier(85, 20, x2, y2, 90, 90, 15, 80); + + // Draw red lines from the anchor points to the control points. + stroke(255, 0, 0); + line(85, 20, x2, y2); + line(15, 80, 90, 90); + } + + // Start changing the first control point if the user clicks near it. + function mousePressed() { + if (dist(mouseX, mouseY, x2, y2) < 20) { + isChanging = true; + } + } + + // Stop changing the first control point when the user releases the mouse. + function mouseReleased() { + isChanging = false; + } + + // Update the first control point while the user drags the mouse. + function mouseDragged() { + if (isChanging === true) { + x2 = mouseX; + y2 = mouseY; + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background('skyblue'); + + // Draw the red balloon. + fill('red'); + bezier(50, 60, 5, 15, 95, 15, 50, 60); + + // Draw the balloon string. + line(50, 60, 50, 80); + + describe('A red balloon in a blue sky.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A red balloon in a blue sky. The balloon rotates slowly, revealing that it is flat.'); + } + + function draw() { + background('skyblue'); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Draw the red balloon. + fill('red'); + bezier(0, 0, 0, -45, -45, 0, 45, -45, 0, 0, 0, 0); + + // Draw the balloon string. + line(0, 0, 0, 0, 20, 0); + } + +
+class: p5 +overloads: + - line: 13 + params: + - name: x1 + description: | +

x-coordinate of the first anchor point.

+ type: Number + - name: y1 + description: | +

y-coordinate of the first anchor point.

+ type: Number + - name: x2 + description: | +

x-coordinate of the first control point.

+ type: Number + - name: y2 + description: | +

y-coordinate of the first control point.

+ type: Number + - name: x3 + description: | +

x-coordinate of the second control point.

+ type: Number + - name: y3 + description: | +

y-coordinate of the second control point.

+ type: Number + - name: x4 + description: | +

x-coordinate of the second anchor point.

+ type: Number + - name: y4 + description: | +

y-coordinate of the second anchor point.

+ type: Number + chainable: 1 + - line: 191 + params: + - name: x1 + description: '' + type: Number + - name: y1 + description: '' + type: Number + - name: z1 + description: | +

z-coordinate of the first anchor point.

+ type: Number + - name: x2 + description: '' + type: Number + - name: y2 + description: '' + type: Number + - name: z2 + description: | +

z-coordinate of the first control point.

+ type: Number + - name: x3 + description: '' + type: Number + - name: y3 + description: '' + type: Number + - name: z3 + description: | +

z-coordinate of the second control point.

+ type: Number + - name: x4 + description: '' + type: Number + - name: y4 + description: '' + type: Number + - name: z4 + description: | +

z-coordinate of the second anchor point.

+ type: Number + chainable: 1 +chainable: true +--- + + +# bezier diff --git a/src/content/reference/en/p5 copy/bezierDetail.mdx b/src/content/reference/en/p5 copy/bezierDetail.mdx new file mode 100644 index 0000000000..b4f895a3fc --- /dev/null +++ b/src/content/reference/en/p5 copy/bezierDetail.mdx @@ -0,0 +1,121 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L221 +title: bezierDetail +module: Shape +submodule: Curves +file: src/core/shape/curves.js +description: > +

Sets the number of segments used to draw Bézier curves in WebGL mode.

+ +

In WebGL mode, smooth shapes are drawn using many flat segments. Adding + + more flat segments makes shapes appear smoother.

+ +

The parameter, detail, is the number of segments to use while + drawing a + + Bézier curve. For example, calling bezierDetail(5) will use 5 + segments to + + draw curves with the bezier() function. By + + default,detail is 20.

+ +

Note: bezierDetail() has no effect in 2D mode.

+line: 221 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Draw the original curve. + + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw the anchor points in black. + stroke(0); + strokeWeight(5); + point(85, 20); + point(15, 80); + + // Draw the control points in red. + stroke(255, 0, 0); + point(10, 10); + point(90, 90); + + // Draw a black bezier curve. + noFill(); + stroke(0); + strokeWeight(1); + bezier(85, 20, 10, 10, 90, 90, 15, 80); + + // Draw red lines from the anchor points to the control points. + stroke(255, 0, 0); + line(85, 20, 10, 10); + line(15, 80, 90, 90); + + describe( + 'A gray square with three curves. A black s-curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' + ); + } + +
+ +
+ + // Draw the curve with less detail. + + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + // Set the curveDetail() to 5. + bezierDetail(5); + + // Draw the anchor points in black. + stroke(0); + strokeWeight(5); + point(35, -30, 0); + point(-35, 30, 0); + + // Draw the control points in red. + stroke(255, 0, 0); + point(-40, -40, 0); + point(40, 40, 0); + + // Draw a black bezier curve. + noFill(); + stroke(0); + strokeWeight(1); + bezier(35, -30, 0, -40, -40, 0, 40, 40, 0, -35, 30, 0); + + // Draw red lines from the anchor points to the control points. + stroke(255, 0, 0); + line(35, -30, -40, -40); + line(-35, 30, 40, 40); + + describe( + 'A gray square with three curves. A black s-curve is drawn with jagged segments. Two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' + ); + } + +
+class: p5 +params: + - name: detail + description: | +

number of segments to use. Defaults to 20.

+ type: Number +chainable: true +--- + + +# bezierDetail diff --git a/src/content/reference/en/p5 copy/bezierPoint.mdx b/src/content/reference/en/p5 copy/bezierPoint.mdx new file mode 100644 index 0000000000..a42c171121 --- /dev/null +++ b/src/content/reference/en/p5 copy/bezierPoint.mdx @@ -0,0 +1,162 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L324 +title: bezierPoint +module: Shape +submodule: Curves +file: src/core/shape/curves.js +description: > +

Calculates coordinates along a Bézier curve using interpolation.

+ +

bezierPoint() calculates coordinates along a Bézier curve + using the + + anchor and control points. It expects points in the same order as the + + bezier() function. + bezierPoint() works one axis + + at a time. Passing the anchor and control points' x-coordinates will + + calculate the x-coordinate of a point on the curve. Passing the anchor and + + control points' y-coordinates will calculate the y-coordinate of a point on + + the curve.

+ +

The first parameter, a, is the coordinate of the first anchor + point.

+ +

The second and third parameters, b and c, are the + coordinates of the + + control points.

+ +

The fourth parameter, d, is the coordinate of the last anchor + point.

+ +

The fifth parameter, t, is the amount to interpolate along the + curve. 0 + + is the first anchor point, 1 is the second anchor point, and 0.5 is halfway + + between them.

+line: 324 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Set the coordinates for the curve's anchor and control points. + let x1 = 85; + let x2 = 10; + let x3 = 90; + let x4 = 15; + let y1 = 20; + let y2 = 10; + let y3 = 90; + let y4 = 80; + + // Style the curve. + noFill(); + + // Draw the curve. + bezier(x1, y1, x2, y2, x3, y3, x4, y4); + + // Draw circles along the curve's path. + fill(255); + + // Top-right. + let x = bezierPoint(x1, x2, x3, x4, 0); + let y = bezierPoint(y1, y2, y3, y4, 0); + circle(x, y, 5); + + // Center. + x = bezierPoint(x1, x2, x3, x4, 0.5); + y = bezierPoint(y1, y2, y3, y4, 0.5); + circle(x, y, 5); + + // Bottom-left. + x = bezierPoint(x1, x2, x3, x4, 1); + y = bezierPoint(y1, y2, y3, y4, 1); + circle(x, y, 5); + + describe('A black s-curve on a gray square. The endpoints and center of the curve are marked with white circles.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A black s-curve on a gray square. A white circle moves back and forth along the curve.'); + } + + function draw() { + background(200); + + // Set the coordinates for the curve's anchor and control points. + let x1 = 85; + let x2 = 10; + let x3 = 90; + let x4 = 15; + let y1 = 20; + let y2 = 10; + let y3 = 90; + let y4 = 80; + + // Draw the curve. + noFill(); + bezier(x1, y1, x2, y2, x3, y3, x4, y4); + + // Calculate the circle's coordinates. + let t = 0.5 * sin(frameCount * 0.01) + 0.5; + let x = bezierPoint(x1, x2, x3, x4, t); + let y = bezierPoint(y1, y2, y3, y4, t); + + // Draw the circle. + fill(255); + circle(x, y, 5); + } + +
+class: p5 +params: + - name: a + description: | +

coordinate of first anchor point.

+ type: Number + - name: b + description: | +

coordinate of first control point.

+ type: Number + - name: c + description: | +

coordinate of second control point.

+ type: Number + - name: d + description: | +

coordinate of second anchor point.

+ type: Number + - name: t + description: | +

amount to interpolate between 0 and 1.

+ type: Number +return: + description: coordinate of the point on the curve. + type: Number +chainable: false +--- + + +# bezierPoint diff --git a/src/content/reference/en/p5 copy/bezierTangent.mdx b/src/content/reference/en/p5 copy/bezierTangent.mdx new file mode 100644 index 0000000000..8fb0edfaa8 --- /dev/null +++ b/src/content/reference/en/p5 copy/bezierTangent.mdx @@ -0,0 +1,155 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L450 +title: bezierTangent +module: Shape +submodule: Curves +file: src/core/shape/curves.js +description: > +

Calculates coordinates along a line that's tangent to a Bézier curve.

+ +

Tangent lines skim the surface of a curve. A tangent line's slope equals + + the curve's slope at the point where it intersects.

+ +

bezierTangent() calculates coordinates along a tangent line + using the + + Bézier curve's anchor and control points. It expects points in the same + + order as the bezier() function. + bezierTangent() + + works one axis at a time. Passing the anchor and control points' + + x-coordinates will calculate the x-coordinate of a point on the tangent + + line. Passing the anchor and control points' y-coordinates will calculate + + the y-coordinate of a point on the tangent line.

+ +

The first parameter, a, is the coordinate of the first anchor + point.

+ +

The second and third parameters, b and c, are the + coordinates of the + + control points.

+ +

The fourth parameter, d, is the coordinate of the last anchor + point.

+ +

The fifth parameter, t, is the amount to interpolate along the + curve. 0 + + is the first anchor point, 1 is the second anchor point, and 0.5 is halfway + + between them.

+line: 450 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Set the coordinates for the curve's anchor and control points. + let x1 = 85; + let x2 = 10; + let x3 = 90; + let x4 = 15; + let y1 = 20; + let y2 = 10; + let y3 = 90; + let y4 = 80; + + // Style the curve. + noFill(); + + // Draw the curve. + bezier(x1, y1, x2, y2, x3, y3, x4, y4); + + // Draw tangents along the curve's path. + fill(255); + + // Top-right circle. + stroke(0); + let x = bezierPoint(x1, x2, x3, x4, 0); + let y = bezierPoint(y1, y2, y3, y4, 0); + circle(x, y, 5); + + // Top-right tangent line. + // Scale the tangent point to draw a shorter line. + stroke(255, 0, 0); + let tx = 0.1 * bezierTangent(x1, x2, x3, x4, 0); + let ty = 0.1 * bezierTangent(y1, y2, y3, y4, 0); + line(x + tx, y + ty, x - tx, y - ty); + + // Center circle. + stroke(0); + x = bezierPoint(x1, x2, x3, x4, 0.5); + y = bezierPoint(y1, y2, y3, y4, 0.5); + circle(x, y, 5); + + // Center tangent line. + // Scale the tangent point to draw a shorter line. + stroke(255, 0, 0); + tx = 0.1 * bezierTangent(x1, x2, x3, x4, 0.5); + ty = 0.1 * bezierTangent(y1, y2, y3, y4, 0.5); + line(x + tx, y + ty, x - tx, y - ty); + + // Bottom-left circle. + stroke(0); + x = bezierPoint(x1, x2, x3, x4, 1); + y = bezierPoint(y1, y2, y3, y4, 1); + circle(x, y, 5); + + // Bottom-left tangent. + // Scale the tangent point to draw a shorter line. + stroke(255, 0, 0); + tx = 0.1 * bezierTangent(x1, x2, x3, x4, 1); + ty = 0.1 * bezierTangent(y1, y2, y3, y4, 1); + line(x + tx, y + ty, x - tx, y - ty); + + describe( + 'A black s-curve on a gray square. The endpoints and center of the curve are marked with white circles. Red tangent lines extend from the white circles.' + ); + } + +
+class: p5 +params: + - name: a + description: | +

coordinate of first anchor point.

+ type: Number + - name: b + description: | +

coordinate of first control point.

+ type: Number + - name: c + description: | +

coordinate of second control point.

+ type: Number + - name: d + description: | +

coordinate of second anchor point.

+ type: Number + - name: t + description: | +

amount to interpolate between 0 and 1.

+ type: Number +return: + description: coordinate of a point on the tangent line. + type: Number +chainable: false +--- + + +# bezierTangent diff --git a/src/content/reference/en/p5 copy/bezierVertex.mdx b/src/content/reference/en/p5 copy/bezierVertex.mdx new file mode 100644 index 0000000000..f4b5fb57cb --- /dev/null +++ b/src/content/reference/en/p5 copy/bezierVertex.mdx @@ -0,0 +1,337 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L543 +title: bezierVertex +module: Shape +submodule: Vertex +file: src/core/shape/vertex.js +description: > +

Adds a Bézier curve segment to a custom shape.

+ +

bezierVertex() adds a curved segment to custom shapes. The + Bézier curves + + it creates are defined like those made by the + + bezier() function. + bezierVertex() must be + + called between the + + beginShape() and + + endShape() functions. The curved segment + uses + + the previous vertex as the first anchor point, so there must be at least + + one call to vertex() before + bezierVertex() can + + be used.

+ +

The first four parameters, x2, y2, + x3, and y3, set the curve’s two + + control points. The control points "pull" the curve towards them.

+ +

The fifth and sixth parameters, x4, and y4, set + the last anchor point. + + The last anchor point is where the curve ends.

+ +

Bézier curves can also be drawn in 3D using WebGL mode. The 3D version of + + bezierVertex() has eight arguments because each point has x-, y-, + and + + z-coordinates.

+ +

Note: bezierVertex() won’t work when an argument is passed to + + beginShape().

+line: 543 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the shape. + noFill(); + + // Start drawing the shape. + beginShape(); + + // Add the first anchor point. + vertex(30, 20); + + // Add the Bézier vertex. + bezierVertex(80, 0, 80, 75, 30, 75); + + // Stop drawing the shape. + endShape(); + + describe('A black C curve on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw the anchor points in black. + stroke(0); + strokeWeight(5); + point(30, 20); + point(30, 75); + + // Draw the control points in red. + stroke(255, 0, 0); + point(80, 0); + point(80, 75); + + // Style the shape. + noFill(); + stroke(0); + strokeWeight(1); + + // Start drawing the shape. + beginShape(); + + // Add the first anchor point. + vertex(30, 20); + + // Add the Bézier vertex. + bezierVertex(80, 0, 80, 75, 30, 75); + + // Stop drawing the shape. + endShape(); + + // Draw red lines from the anchor points to the control points. + stroke(255, 0, 0); + line(30, 20, 80, 0); + line(30, 75, 80, 75); + + describe( + 'A gray square with three curves. A black curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' + ); + } + +
+ +
+ + // Click the mouse near the red dot in the top-right corner + // and drag to change the curve's shape. + + let x2 = 80; + let y2 = 0; + let isChanging = false; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with three curves. A black curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' + ); + } + + function draw() { + background(200); + + // Draw the anchor points in black. + stroke(0); + strokeWeight(5); + point(30, 20); + point(30, 75); + + // Draw the control points in red. + stroke(255, 0, 0); + point(x2, y2); + point(80, 75); + + // Style the shape. + noFill(); + stroke(0); + strokeWeight(1); + + // Start drawing the shape. + beginShape(); + + // Add the first anchor point. + vertex(30, 20); + + // Add the Bézier vertex. + bezierVertex(x2, y2, 80, 75, 30, 75); + + // Stop drawing the shape. + endShape(); + + // Draw red lines from the anchor points to the control points. + stroke(255, 0, 0); + line(30, 20, x2, y2); + line(30, 75, 80, 75); + } + + // Start changing the first control point if the user clicks near it. + function mousePressed() { + if (dist(mouseX, mouseY, x2, y2) < 20) { + isChanging = true; + } + } + + // Stop changing the first control point when the user releases the mouse. + function mouseReleased() { + isChanging = false; + } + + // Update the first control point while the user drags the mouse. + function mouseDragged() { + if (isChanging === true) { + x2 = mouseX; + y2 = mouseY; + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + beginShape(); + + // Add the first anchor point. + vertex(30, 20); + + // Add the Bézier vertices. + bezierVertex(80, 0, 80, 75, 30, 75); + bezierVertex(50, 80, 60, 25, 30, 20); + + // Stop drawing the shape. + endShape(); + + describe('A crescent moon shape drawn in white on a gray background.'); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A crescent moon shape drawn in white on a blue background. When the user drags the mouse, the scene rotates and a second moon is revealed.'); + } + + function draw() { + background('midnightblue'); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the moons. + noStroke(); + fill('lemonchiffon'); + + // Draw the first moon. + beginShape(); + vertex(-20, -30, 0); + bezierVertex(30, -50, 0, 30, 25, 0, -20, 25, 0); + bezierVertex(0, 30, 0, 10, -25, 0, -20, -30, 0); + endShape(); + + // Draw the second moon. + beginShape(); + vertex(-20, -30, -20); + bezierVertex(30, -50, -20, 30, 25, -20, -20, 25, -20); + bezierVertex(0, 30, -20, 10, -25, -20, -20, -30, -20); + endShape(); + } + +
+class: p5 +overloads: + - line: 543 + params: + - name: x2 + description: | +

x-coordinate of the first control point.

+ type: Number + - name: y2 + description: | +

y-coordinate of the first control point.

+ type: Number + - name: x3 + description: | +

x-coordinate of the second control point.

+ type: Number + - name: y3 + description: | +

y-coordinate of the second control point.

+ type: Number + - name: x4 + description: | +

x-coordinate of the anchor point.

+ type: Number + - name: y4 + description: | +

y-coordinate of the anchor point.

+ type: Number + chainable: 1 + - line: 792 + params: + - name: x2 + description: '' + type: Number + - name: y2 + description: '' + type: Number + - name: z2 + description: | +

z-coordinate of the first control point.

+ type: Number + - name: x3 + description: '' + type: Number + - name: y3 + description: '' + type: Number + - name: z3 + description: | +

z-coordinate of the second control point.

+ type: Number + - name: x4 + description: '' + type: Number + - name: y4 + description: '' + type: Number + - name: z4 + description: | +

z-coordinate of the anchor point.

+ type: Number + chainable: 1 +chainable: true +--- + + +# bezierVertex diff --git a/src/content/reference/en/p5 copy/blend.mdx b/src/content/reference/en/p5 copy/blend.mdx new file mode 100644 index 0000000000..53e9a94dc9 --- /dev/null +++ b/src/content/reference/en/p5 copy/blend.mdx @@ -0,0 +1,214 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L148 +title: blend +module: Image +submodule: Pixels +file: src/image/pixels.js +description: > +

Copies a region of pixels from one image to another.

+ +

The first parameter, srcImage, is the + + p5.Image object to blend.

+ +

The next four parameters, sx, sy, + sw, and sh determine the region + + to blend from the source image. (sx, sy) is the top-left corner + of the + + region. sw and sh are the regions width and + height.

+ +

The next four parameters, dx, dy, + dw, and dh determine the region + + of the canvas to blend into. (dx, dy) is the top-left corner of + the + + region. dw and dh are the regions width and + height.

+ +

The tenth parameter, blendMode, sets the effect used to blend + the images' + + colors. The options are BLEND, DARKEST, + LIGHTEST, DIFFERENCE, + + MULTIPLY, EXCLUSION, SCREEN, + REPLACE, OVERLAY, HARD_LIGHT, + + SOFT_LIGHT, DODGE, BURN, + ADD, or NORMAL

+line: 148 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img0; + let img1; + + // Load the images. + function preload() { + img0 = loadImage('/assets/rockies.jpg'); + img1 = loadImage('/assets/bricks_third.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Use the mountains as the background. + background(img0); + + // Display the bricks. + image(img1, 0, 0); + + // Display the bricks faded into the landscape. + blend(img1, 0, 0, 33, 100, 67, 0, 33, 100, LIGHTEST); + + describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears faded on the right of the image.'); + } + +
+ +
+ + let img0; + let img1; + + // Load the images. + function preload() { + img0 = loadImage('/assets/rockies.jpg'); + img1 = loadImage('/assets/bricks_third.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Use the mountains as the background. + background(img0); + + // Display the bricks. + image(img1, 0, 0); + + // Display the bricks partially transparent. + blend(img1, 0, 0, 33, 100, 67, 0, 33, 100, DARKEST); + + describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears transparent on the right of the image.'); + } + +
+ +
+ + let img0; + let img1; + + // Load the images. + function preload() { + img0 = loadImage('/assets/rockies.jpg'); + img1 = loadImage('/assets/bricks_third.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Use the mountains as the background. + background(img0); + + // Display the bricks. + image(img1, 0, 0); + + // Display the bricks washed out into the landscape. + blend(img1, 0, 0, 33, 100, 67, 0, 33, 100, ADD); + + describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears washed out on the right of the image.'); + } + +
+class: p5 +overloads: + - line: 148 + params: + - name: srcImage + description: | +

source image.

+ type: p5.Image + - name: sx + description: | +

x-coordinate of the source's upper-left corner.

+ type: Integer + - name: sy + description: | +

y-coordinate of the source's upper-left corner.

+ type: Integer + - name: sw + description: | +

source image width.

+ type: Integer + - name: sh + description: | +

source image height.

+ type: Integer + - name: dx + description: | +

x-coordinate of the destination's upper-left corner.

+ type: Integer + - name: dy + description: | +

y-coordinate of the destination's upper-left corner.

+ type: Integer + - name: dw + description: | +

destination image width.

+ type: Integer + - name: dh + description: | +

destination image height.

+ type: Integer + - name: blendMode + description: | +

the blend mode. either + BLEND, DARKEST, LIGHTEST, DIFFERENCE, + MULTIPLY, EXCLUSION, SCREEN, REPLACE, OVERLAY, HARD_LIGHT, + SOFT_LIGHT, DODGE, BURN, ADD or NORMAL.

+ type: Constant + - line: 267 + params: + - name: sx + description: '' + type: Integer + - name: sy + description: '' + type: Integer + - name: sw + description: '' + type: Integer + - name: sh + description: '' + type: Integer + - name: dx + description: '' + type: Integer + - name: dy + description: '' + type: Integer + - name: dw + description: '' + type: Integer + - name: dh + description: '' + type: Integer + - name: blendMode + description: '' + type: Constant +chainable: false +--- + + +# blend diff --git a/src/content/reference/en/p5 copy/blendMode.mdx b/src/content/reference/en/p5 copy/blendMode.mdx new file mode 100644 index 0000000000..8f6365b78d --- /dev/null +++ b/src/content/reference/en/p5 copy/blendMode.mdx @@ -0,0 +1,541 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L720 +title: blendMode +module: Rendering +submodule: Rendering +file: src/core/rendering.js +description: > +

Sets the way colors blend when added to the canvas.

+ +

By default, drawing with a solid color paints over the current pixel values + + on the canvas. blendMode() offers many options for blending + colors.

+ +

Shapes, images, and text can be used as sources for drawing to the canvas. + + A source pixel changes the color of the canvas pixel where it's drawn. The + + final color results from blending the source pixel's color with the canvas + + pixel's color. RGB color values from the source and canvas pixels are + + compared, added, subtracted, multiplied, and divided to create different + + effects. Red values with red values, greens with greens, and blues with + + blues.

+ +

The parameter, mode, sets the blend mode. For example, calling + + blendMode(ADD) sets the blend mode to ADD. The + following blend modes + + are available in both 2D and WebGL mode:

+ +
    + +
  • BLEND: color values from the source overwrite the canvas. + This is the default mode.
  • + +
  • ADD: color values from the source are added to values from + the canvas.
  • + +
  • DARKEST: keeps the darkest color value.
  • + +
  • LIGHTEST: keeps the lightest color value.
  • + +
  • EXCLUSION: similar to DIFFERENCE but with less + contrast.
  • + +
  • MULTIPLY: color values from the source are multiplied with + values from the canvas. The result is always darker.
  • + +
  • SCREEN: all color values are inverted, then multiplied, then + inverted again. The result is always lighter. (Opposite of + MULTIPLY)
  • + +
  • REPLACE: the last source drawn completely replaces the rest + of the canvas.
  • + +
  • REMOVE: overlapping pixels are removed by making them + completely transparent.
  • + +
+ +

The following blend modes are only available in 2D mode:

+ +
    + +
  • DIFFERENCE: color values from the source are subtracted from + the values from the canvas. If the difference is a negative number, it's made + positive.
  • + +
  • OVERLAY: combines MULTIPLY and + SCREEN. Dark values in the canvas get darker and light values get + lighter.
  • + +
  • HARD_LIGHT: combines MULTIPLY and + SCREEN. Dark values in the source get darker and light values get + lighter.
  • + +
  • SOFT_LIGHT: a softer version of HARD_LIGHT.
  • + +
  • DODGE: lightens light tones and increases contrast. Divides + the canvas color values by the inverted color values from the source.
  • + +
  • BURN: darkens dark tones and increases contrast. Divides the + source color values by the inverted color values from the canvas, then inverts + the result.
  • + +
+ +

The following blend modes are only available in WebGL mode:

+ +
    + +
  • SUBTRACT: RGB values from the source are subtracted from the + values from the canvas. If the difference is a negative number, it's made + positive. Alpha (transparency) values from the source and canvas are + added.
  • + +
+line: 720 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Use the default blend mode. + blendMode(BLEND); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('A Sky Blue line and a Deep Rose line form an X on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(HARD_LIGHT); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('An ocean blue line and a hot pink line form an X on a gray background. The area where they overlap is Magenta purple.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(ADD); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('An icy blue line and a light lavender line form an X on a gray background. The area where they overlap is white.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(DARKEST); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('A steel blue line and a cranberry line form an X on a gray background. The area where they overlap is deep purple.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(BURN); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('A cobalt blue line and a burgundy line form an X on a gray background. The area where they overlap is black.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(LIGHTEST); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('A pale lavender line and a soft beige line form an X on a gray background. The area where they overlap is pale lilac.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(EXCLUSION); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('An earthy brown line and a muted sage line form an X on a gray background. The area where they overlap is sage green.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(MULTIPLY); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('A slate blue line and a plum line form an X on a gray background. The area where they overlap is dark Indigo.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(SCREEN); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('A baby blue line and a peach pink line form an X on a gray background. The area where they overlap is misty lilac.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(REPLACE); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('A diagonal deep rose line.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(REMOVE); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('The silhouette of an X is missing from a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(DIFFERENCE); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('A light burgundy line and a forest green line form an X on a gray background. The area where they overlap is dark cocoa.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(OVERLAY); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('A cornflower blue line and a light rose line form an X on a gray background. The area where they overlap is violet.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(SOFT_LIGHT); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('A pale sky line and a rose blush line form an X on a gray background. The area where they overlap is lavender.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Set the blend mode. + blendMode(DODGE); + + // Style the lines. + strokeWeight(30); + + // Draw the first line. + stroke('#1a85ff'); + line(25, 25, 75, 75); + + // Draw the second line. + stroke('#d41159'); + line(75, 25, 25, 75); + + describe('An aqua blue line and a light pink line form an X on a gray background. The area where they overlap is white.'); + } + +
+ +
+ + function setup() { + // Create a canvas with WEBGL mode. + createCanvas(100, 100, WEBGL); + + // Set the background color. + background(180); + + // Set the blend mode to SUBTRACT. + blendMode(SUBTRACT); + + // Style the lines. + strokeWeight(30); + + // Draw the blue line. + stroke('#1a85ff'); + line(-25, -25, 25, 25); + + // Draw the red line. + stroke('#d41159'); + line(25, -25, -25, 25); + + describe('A burnt orange and a sea green line form an X on a gray background. The area where they overlap is forest green.'); + } + +
+class: p5 +params: + - name: mode + description: | +

blend mode to set. + either BLEND, DARKEST, LIGHTEST, DIFFERENCE, MULTIPLY, + EXCLUSION, SCREEN, REPLACE, OVERLAY, HARD_LIGHT, + SOFT_LIGHT, DODGE, BURN, ADD, REMOVE or SUBTRACT

+ type: Constant +chainable: false +--- + + +# blendMode diff --git a/src/content/reference/en/p5 copy/blue.mdx b/src/content/reference/en/p5 copy/blue.mdx new file mode 100644 index 0000000000..d3e05aae37 --- /dev/null +++ b/src/content/reference/en/p5 copy/blue.mdx @@ -0,0 +1,158 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L117 +title: blue +module: Color +submodule: Creating & Reading +file: src/color/creating_reading.js +description: > +

Gets the blue value of a color.

+ +

blue() extracts the blue value from a + + p5.Color object, an array of color + components, or + + a CSS color string.

+ +

By default, blue() returns a color's blue value in the range 0 + + to 255. If the colorMode() is set to + RGB, it + + returns the blue value in the given range.

+line: 117 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object using RGB values. + let c = color(175, 100, 220); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'blueValue' to 220. + let blueValue = blue(c); + + // Draw the right rectangle. + fill(0, 0, blueValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is royal blue.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a color array. + let c = [175, 100, 220]; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'blueValue' to 220. + let blueValue = blue(c); + + // Draw the right rectangle. + fill(0, 0, blueValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is royal blue.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a CSS color string. + let c = 'rgb(175, 100, 220)'; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'blueValue' to 220. + let blueValue = blue(c); + + // Draw the right rectangle. + fill(0, 0, blueValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is royal blue.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use RGB color with values in the range 0-100. + colorMode(RGB, 100); + + // Create a p5.Color object using RGB values. + let c = color(69, 39, 86); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'blueValue' to 86. + let blueValue = blue(c); + + // Draw the right rectangle. + fill(0, 0, blueValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is royal blue.'); + } + +
+class: p5 +params: + - name: color + description: | +

p5.Color object, array of + color components, or CSS color string.

+ type: 'p5.Color|Number[]|String' +return: + description: the blue value. + type: Number +chainable: false +--- + + +# blue diff --git a/src/content/reference/en/p5 copy/boolean.mdx b/src/content/reference/en/p5 copy/boolean.mdx new file mode 100644 index 0000000000..8eab48af5f --- /dev/null +++ b/src/content/reference/en/p5 copy/boolean.mdx @@ -0,0 +1,157 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L341 +title: boolean +module: Data +submodule: Conversion +file: src/utilities/conversion.js +description: > +

Converts a String or Number to a + Boolean.

+ +

boolean() converts values to true or + false.

+ +

The parameter, n, is the value to convert. If n + is a string, then + + boolean('true') will return true and every other + string value will + + return false. If n is a number, then + boolean(0) will return false + + and every other numeric value will return true. If an array is + passed, as + + in boolean([0, 1, 'true', 'blue']), then an array of Boolean + values will + + be returned.

+line: 341 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a number variable. + let original = 0; + + // Convert the number to a Boolean value. + let converted = boolean(original); + + // Style the circle based on the converted value. + if (converted === true) { + fill('blue'); + } else { + fill('red'); + } + + // Draw the circle. + circle(50, 50, 40); + + describe('A red circle on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let original = 'true'; + + // Convert the string to a Boolean value. + let converted = boolean(original); + + // Style the circle based on the converted value. + if (converted === true) { + fill('blue'); + } else { + fill('red'); + } + + // Draw the circle. + circle(50, 50, 40); + + describe('A blue circle on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of values. + let original = [0, 'hi', 123, 'true']; + + // Convert the array to a Boolean values. + let converted = boolean(original); + + // Iterate over the array of converted Boolean values. + for (let i = 0; i < converted.length; i += 1) { + + // Style the circle based on the converted value. + if (converted[i] === true) { + fill('blue'); + } else { + fill('red'); + } + + // Calculate the x-coordinate. + let x = (i + 1) * 20; + + // Draw the circle. + circle(x, 50, 15); + } + + describe( + 'A row of circles on a gray background. The two circles on the left are red and the two on the right are blue.' + ); + } + +
+class: p5 +return: + description: converted Boolean value. + type: Boolean +overloads: + - line: 341 + params: + - name: 'n' + description: | +

value to convert.

+ type: String|Boolean|Number + return: + description: converted Boolean value. + type: Boolean + - line: 451 + params: + - name: ns + description: | +

values to convert.

+ type: Array + return: + description: converted Boolean values. + type: 'Boolean[]' +chainable: false +--- + + +# boolean diff --git a/src/content/reference/en/p5 copy/box.mdx b/src/content/reference/en/p5 copy/box.mdx new file mode 100644 index 0000000000..a4f5282947 --- /dev/null +++ b/src/content/reference/en/p5 copy/box.mdx @@ -0,0 +1,186 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L1009 +title: box +module: Shape +submodule: 3D Primitives +file: src/webgl/3d_primitives.js +description: > +

Draws a box (rectangular prism).

+ +

A box is a 3D shape with six faces. Each face makes a 90˚ with four + + neighboring faces.

+ +

The first parameter, width, is optional. If a + Number is passed, as in + + box(20), it sets the box’s width and height. By default, + width is 50.

+ +

The second parameter, height, is also optional. If a + Number is passed, + + as in box(20, 30), it sets the box’s height. By default, + height is set + + to the box’s width.

+ +

The third parameter, depth, is also optional. If a + Number is passed, as + + in box(20, 30, 40), it sets the box’s depth. By default, + depth is set + + to the box’s height.

+ +

The fourth parameter, detailX, is also optional. If a + Number is passed, + + as in box(20, 30, 40, 5), it sets the number of triangle + subdivisions to + + use along the x-axis. All 3D shapes are made by connecting triangles to + + form their surfaces. By default, detailX is 1.

+ +

The fifth parameter, detailY, is also optional. If a number is + passed, as + + in box(20, 30, 40, 5, 7), it sets the number of triangle + subdivisions to + + use along the y-axis. All 3D shapes are made by connecting triangles to + + form their surfaces. By default, detailY is 1.

+ +

Note: box() can only be used in WebGL mode.

+line: 1009 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white box on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white box on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the box. + // Set its width and height to 30. + box(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white box on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the box. + // Set its width to 30 and height to 50. + box(30, 50); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white box on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the box. + // Set its width to 30, height to 50, and depth to 10. + box(30, 50, 10); + } + +
+class: p5 +params: + - name: width + description: | +

width of the box.

+ type: Number + optional: true + - name: height + description: | +

height of the box.

+ type: Number + optional: true + - name: depth + description: | +

depth of the box.

+ type: Number + optional: true + - name: detailX + description: | +

number of triangle subdivisions along the x-axis.

+ type: Integer + optional: true + - name: detailY + description: | +

number of triangle subdivisions along the y-axis.

+ type: Integer + optional: true +chainable: true +--- + + +# box diff --git a/src/content/reference/en/p5 copy/brightness.mdx b/src/content/reference/en/p5 copy/brightness.mdx new file mode 100644 index 0000000000..2860cbf226 --- /dev/null +++ b/src/content/reference/en/p5 copy/brightness.mdx @@ -0,0 +1,168 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L253 +title: brightness +module: Color +submodule: Creating & Reading +file: src/color/creating_reading.js +description: > +

Gets the brightness value of a color.

+ +

brightness() extracts the HSB brightness value from a + + p5.Color object, an array of color + components, or + + a CSS color string.

+ +

By default, brightness() returns a color's HSB brightness in + the range 0 + + to 100. If the colorMode() is set to + HSB, it + + returns the brightness value in the given range.

+line: 253 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use HSB color. + colorMode(HSB); + + // Create a p5.Color object. + let c = color(0, 50, 100); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'brightValue' to 100. + let brightValue = brightness(c); + + // Draw the right rectangle. + fill(brightValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is white.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use HSB color. + colorMode(HSB); + + // Create a color array. + let c = [0, 50, 100]; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'brightValue' to 100. + let brightValue = brightness(c); + + // Draw the right rectangle. + fill(brightValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is white.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use HSB color. + colorMode(HSB); + + // Create a CSS color string. + let c = 'rgb(255, 128, 128)'; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'brightValue' to 100. + let brightValue = brightness(c); + + // Draw the right rectangle. + fill(brightValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is white.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use HSB color with values in the range 0-255. + colorMode(HSB, 255); + + // Create a p5.Color object. + let c = color(0, 127, 255); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'brightValue' to 255. + let brightValue = brightness(c); + + // Draw the right rectangle. + fill(brightValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is white.'); + } + +
+class: p5 +params: + - name: color + description: | +

p5.Color object, array of + color components, or CSS color string.

+ type: 'p5.Color|Number[]|String' +return: + description: the brightness value. + type: Number +chainable: false +--- + + +# brightness diff --git a/src/content/reference/en/p5 copy/buildGeometry.mdx b/src/content/reference/en/p5 copy/buildGeometry.mdx new file mode 100644 index 0000000000..ef58d7b650 --- /dev/null +++ b/src/content/reference/en/p5 copy/buildGeometry.mdx @@ -0,0 +1,263 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L520 +title: buildGeometry +module: Shape +submodule: 3D Primitives +file: src/webgl/3d_primitives.js +description: > +

Creates a custom p5.Geometry object + from + + simpler 3D shapes.

+ +

buildGeometry() helps with creating complex 3D shapes from + simpler ones + + such as sphere(). It can help to make + sketches + + more performant. For example, if a complex 3D shape doesn’t change while a + + sketch runs, then it can be created with buildGeometry(). + Creating a + + p5.Geometry object once and then + drawing it + + will run faster than repeatedly drawing the individual pieces.

+ +

The parameter, callback, is a function with the drawing + instructions for + + the new p5.Geometry object. It will be + called + + once to create the new 3D shape.

+ +

See beginGeometry() and + + endGeometry() for another way to + build 3D + + shapes.

+ +

Note: buildGeometry() can only be used in WebGL mode.

+line: 520 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the p5.Geometry object. + shape = buildGeometry(createShape); + + describe('A white cone drawn on a gray background.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the p5.Geometry object. + noStroke(); + + // Draw the p5.Geometry object. + model(shape); + } + + // Create p5.Geometry object from a single cone. + function createShape() { + cone(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the arrow. + shape = buildGeometry(createArrow); + + describe('A white arrow drawn on a gray background.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the arrow. + noStroke(); + + // Draw the arrow. + model(shape); + } + + function createArrow() { + // Add shapes to the p5.Geometry object. + push(); + rotateX(PI); + cone(10); + translate(0, -10, 0); + cylinder(3, 20); + pop(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the p5.Geometry object. + shape = buildGeometry(createArrow); + + describe('Two white arrows drawn on a gray background. The arrow on the right rotates slowly.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the arrows. + noStroke(); + + // Draw the p5.Geometry object. + model(shape); + + // Translate and rotate the coordinate system. + translate(30, 0, 0); + rotateZ(frameCount * 0.01); + + // Draw the p5.Geometry object again. + model(shape); + } + + function createArrow() { + // Add shapes to the p5.Geometry object. + push(); + rotateX(PI); + cone(10); + translate(0, -10, 0); + cylinder(3, 20); + pop(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let button; + let particles; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a button to reset the particle system. + button = createButton('Reset'); + + // Call resetModel() when the user presses the button. + button.mousePressed(resetModel); + + // Add the original set of particles. + resetModel(); + + describe('A set of white spheres on a gray background. The spheres are positioned randomly. Their positions reset when the user presses the Reset button.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the particles. + noStroke(); + + // Draw the particles. + model(particles); + } + + function resetModel() { + // If the p5.Geometry object has already been created, + // free those resources. + if (particles) { + freeGeometry(particles); + } + + // Create a new p5.Geometry object with random spheres. + particles = buildGeometry(createParticles); + } + + function createParticles() { + for (let i = 0; i < 60; i += 1) { + // Calculate random coordinates. + let x = randomGaussian(0, 20); + let y = randomGaussian(0, 20); + let z = randomGaussian(0, 20); + + push(); + // Translate to the particle's coordinates. + translate(x, y, z); + // Draw the particle. + sphere(5); + pop(); + } + } + +
+class: p5 +params: + - name: callback + description: | +

function that draws the shape.

+ type: Function +return: + description: new 3D shape. + type: p5.Geometry +chainable: false +--- + + +# buildGeometry diff --git a/src/content/reference/en/p5 copy/byte.mdx b/src/content/reference/en/p5 copy/byte.mdx new file mode 100644 index 0000000000..0a6f3234a4 --- /dev/null +++ b/src/content/reference/en/p5 copy/byte.mdx @@ -0,0 +1,180 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L468 +title: byte +module: Data +submodule: Conversion +file: src/utilities/conversion.js +description: > +

Converts a Boolean, String, or + Number to its byte value.

+ +

byte() converts a value to an integer (whole number) between + -128 and + + 127. Values greater than 127 wrap around while negative values are + + unchanged. For example, 128 becomes -128 and -129 remains the same.

+ +

The parameter, n, is the value to convert. If n + is a Boolean, as in + + byte(false) or byte(true), the number 0 + (false) or 1 (true) will be + + returned. If n is a string or number, as in + byte('256') or byte(256), + + then the byte value will be returned. Decimal values are ignored. If an + + array is passed, as in byte([true, 123, '456']), then an array of + byte + + values will be returned.

+ +

Note: If a value can't be converted to a number, as in + byte('giraffe'), + + then the value NaN (not a number) will be returned.

+line: 468 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a Boolean variable. + let original = true; + + // Convert the Boolean to its byte value. + let converted = byte(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the original and converted values. + text(`${original} : ${converted}`, 50, 50); + + describe('The text "true : 1" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let original = '256'; + + // Convert the string to its byte value. + let converted = byte(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the original and converted values. + text(`${original} : ${converted}`, 50, 50); + + describe('The text "256 : 0" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a number variable. + let original = 256; + + // Convert the number to its byte value. + let converted = byte(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the original and converted values. + text(`${original} : ${converted}`, 50, 50); + + describe('The text "256 : 0" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of values. + let original = [false, '64', 383]; + + // Convert the array elements to their byte values. + let converted = byte(original); + + // Iterate over the converted array elements. + for (let i = 0; i < converted.length; i += 1) { + + // Style the circle. + fill(converted[i]); + + // Calculate the x-coordinate. + let x = (i + 1) * 25; + + // Draw the circle. + circle(x, 50, 20); + } + + describe( + 'Three gray circles on a gray background. The circles get lighter from left to right.' + ); + } + +
+class: p5 +return: + description: converted byte value. + type: Number +overloads: + - line: 468 + params: + - name: 'n' + description: | +

value to convert.

+ type: String|Boolean|Number + return: + description: converted byte value. + type: Number + - line: 598 + params: + - name: ns + description: | +

values to convert.

+ type: Array + return: + description: converted byte values. + type: 'Number[]' +chainable: false +--- + + +# byte diff --git a/src/content/reference/en/p5 copy/camera.mdx b/src/content/reference/en/p5 copy/camera.mdx new file mode 100644 index 0000000000..55f983385e --- /dev/null +++ b/src/content/reference/en/p5 copy/camera.mdx @@ -0,0 +1,200 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L13 +title: camera +module: 3D +submodule: Camera +file: src/webgl/p5.Camera.js +description: > +

Sets the position and orientation of the current camera in a 3D sketch.

+ +

camera() allows objects to be viewed from different angles. It + has nine + + parameters that are all optional.

+ +

The first three parameters, x, y, and + z, are the coordinates of the + + camera’s position. For example, calling camera(0, 0, 0) places + the camera + + at the origin (0, 0, 0). By default, the camera is placed at + + (0, 0, 800).

+ +

The next three parameters, centerX, centerY, and + centerZ are the + + coordinates of the point where the camera faces. For example, calling + + camera(0, 0, 0, 10, 20, 30) places the camera at the origin + (0, 0, 0) + + and points it at (10, 20, 30). By default, the camera points at + the + + origin (0, 0, 0).

+ +

The last three parameters, upX, upY, and + upZ are the components of + + the "up" vector. The "up" vector orients the camera’s y-axis. For example, + + calling camera(0, 0, 0, 10, 20, 30, 0, -1, 0) places the camera + at the + + origin (0, 0, 0), points it at (10, 20, 30), and + sets the "up" vector + + to (0, -1, 0) which is like holding it upside-down. By default, + the "up" + + vector is (0, 1, 0).

+ +

Note: camera() can only be used in WebGL mode.

+line: 13 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Move the camera to the top-right. + camera(200, -400, 800); + + // Draw the box. + box(); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube apperas to sway left and right on a gray background.'); + } + + function draw() { + background(200); + + // Calculate the camera's x-coordinate. + let x = 400 * cos(frameCount * 0.01); + + // Orbit the camera around the box. + camera(x, -400, 800); + + // Draw the box. + box(); + } + +
+ +
+ + // Adjust the range sliders to change the camera's position. + + let xSlider; + let ySlider; + let zSlider; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create slider objects to set the camera's coordinates. + xSlider = createSlider(-400, 400, 400); + xSlider.position(0, 100); + xSlider.size(100); + ySlider = createSlider(-400, 400, -200); + ySlider.position(0, 120); + ySlider.size(100); + zSlider = createSlider(0, 1600, 800); + zSlider.position(0, 140); + zSlider.size(100); + + describe( + 'A white cube drawn against a gray background. Three range sliders appear beneath the image. The camera position changes when the user moves the sliders.' + ); + } + + function draw() { + background(200); + + // Get the camera's coordinates from the sliders. + let x = xSlider.value(); + let y = ySlider.value(); + let z = zSlider.value(); + + // Move the camera. + camera(x, y, z); + + // Draw the box. + box(); + } + +
+class: p5 +params: + - name: x + description: | +

x-coordinate of the camera. Defaults to 0.

+ type: Number + optional: true + - name: 'y' + description: | +

y-coordinate of the camera. Defaults to 0.

+ type: Number + optional: true + - name: z + description: | +

z-coordinate of the camera. Defaults to 800.

+ type: Number + optional: true + - name: centerX + description: | +

x-coordinate of the point the camera faces. Defaults to 0.

+ type: Number + optional: true + - name: centerY + description: | +

y-coordinate of the point the camera faces. Defaults to 0.

+ type: Number + optional: true + - name: centerZ + description: | +

z-coordinate of the point the camera faces. Defaults to 0.

+ type: Number + optional: true + - name: upX + description: | +

x-component of the camera’s "up" vector. Defaults to 0.

+ type: Number + optional: true + - name: upY + description: | +

y-component of the camera’s "up" vector. Defaults to 1.

+ type: Number + optional: true + - name: upZ + description: | +

z-component of the camera’s "up" vector. Defaults to 0.

+ type: Number + optional: true +chainable: true +--- + + +# camera diff --git a/src/content/reference/en/p5 copy/ceil.mdx b/src/content/reference/en/p5 copy/ceil.mdx new file mode 100644 index 0000000000..45c17468bf --- /dev/null +++ b/src/content/reference/en/p5 copy/ceil.mdx @@ -0,0 +1,65 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L48 +title: ceil +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Calculates the closest integer value that is greater than or equal to a + + number.

+ +

For example, calling ceil(9.03) and ceil(9.97) + both return the value + + 10.

+line: 48 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use RGB color with values from 0 to 1. + colorMode(RGB, 1); + + noStroke(); + + // Draw the left rectangle. + let r = 0.3; + fill(r, 0, 0); + rect(0, 0, 50, 100); + + // Round r up to 1. + r = ceil(r); + + // Draw the right rectangle. + fill(r, 0, 0); + rect(50, 0, 50, 100); + + describe('Two rectangles. The one on the left is dark red and the one on the right is bright red.'); + } + +
+class: p5 +params: + - name: 'n' + description: | +

number to round up.

+ type: Number +return: + description: rounded up number. + type: Integer +chainable: false +--- + + +# ceil diff --git a/src/content/reference/en/p5 copy/changed.mdx b/src/content/reference/en/p5 copy/changed.mdx new file mode 100644 index 0000000000..45289630e9 --- /dev/null +++ b/src/content/reference/en/p5 copy/changed.mdx @@ -0,0 +1,87 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L330 +title: changed +module: DOM +submodule: DOM +file: src/dom/dom.js +description: | +

Calls a function when the element changes.

+

Calling myElement.changed(false) disables the function.

+line: 330 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let dropdown; + + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a dropdown menu and add a few color options. + dropdown = createSelect(); + dropdown.position(0, 0); + dropdown.option('red'); + dropdown.option('green'); + dropdown.option('blue'); + + // Call paintBackground() when the color option changes. + dropdown.changed(paintBackground); + + describe('A gray square with a dropdown menu at the top. The square changes color when an option is selected.'); + } + + // Paint the background with the selected color. + function paintBackground() { + let c = dropdown.value(); + background(c); + } + +
+ +
+ + let checkbox; + + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a checkbox and place it beneath the canvas. + checkbox = createCheckbox(' circle'); + checkbox.position(0, 100); + + // Call repaint() when the checkbox changes. + checkbox.changed(repaint); + + describe('A gray square with a checkbox underneath it that says "circle". A white circle appears when the box is checked and disappears otherwise.'); + } + + // Paint the background gray and determine whether to draw a circle. + function repaint() { + background(200); + if (checkbox.checked() === true) { + circle(50, 50, 30); + } + } + +
+class: p5 +params: + - name: fxn + description: | +

function to call when the element changes. + false disables the function.

+ type: Function|Boolean +chainable: true +--- + + +# changed diff --git a/src/content/reference/en/p5 copy/char.mdx b/src/content/reference/en/p5 copy/char.mdx new file mode 100644 index 0000000000..e01e22a9f7 --- /dev/null +++ b/src/content/reference/en/p5 copy/char.mdx @@ -0,0 +1,152 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L612 +title: char +module: Data +submodule: Conversion +file: src/utilities/conversion.js +description: > +

Converts a Number or String to a single-character + String.

+ +

char() converts numbers to their single-character string + representations.

+ +

The parameter, n, is the value to convert. If a number is + passed, as in + + char(65), the corresponding single-character string is returned. + If a + + string is passed, as in char('65'), the string is converted to an + integer + + (whole number) and the corresponding single-character string is returned. + + If an array is passed, as in char([65, 66, 67]), an array of + + single-character strings is returned.

+ +

See MDN + + for more information about conversions.

+line: 612 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a number variable. + let original = 65; + + // Convert the number to a char. + let converted = char(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the original and converted values. + text(`${original} : ${converted}`, 50, 50); + + describe('The text "65 : A" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let original = '65'; + + // Convert the string to a char. + let converted = char(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the original and converted values. + text(`${original} : ${converted}`, 50, 50); + + describe('The text "65 : A" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of numbers. + let original = ['65', 66, '67']; + + // Convert the string to a char. + let converted = char(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Iterate over elements of the converted array. + for (let i = 0; i < converted.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 25; + + // Display the original and converted values. + text(`${original[i]} : ${converted[i]}`, 50, y); + } + + describe( + 'The text "65 : A", "66 : B", and "67 : C" written on three separate lines. The text is in black on a gray background.' + ); + } + +
+class: p5 +return: + description: converted single-character string. + type: String +overloads: + - line: 612 + params: + - name: 'n' + description: | +

value to convert.

+ type: String|Number + return: + description: converted single-character string. + type: String + - line: 716 + params: + - name: ns + description: | +

values to convert.

+ type: Array + return: + description: converted single-character strings. + type: 'String[]' +chainable: false +--- + + +# char diff --git a/src/content/reference/en/p5 copy/circle.mdx b/src/content/reference/en/p5 copy/circle.mdx new file mode 100644 index 0000000000..46069bea74 --- /dev/null +++ b/src/content/reference/en/p5 copy/circle.mdx @@ -0,0 +1,77 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L488 +title: circle +module: Shape +submodule: 2D Primitives +file: src/core/shape/2d_primitives.js +description: > +

Draws a circle.

+ +

A circle is a round shape defined by the x, y, + and d parameters. + + x and y set the location of its center. + d sets its width and height (diameter). + + Every point on the circle's edge is the same distance, 0.5 * d, + from its center. + + 0.5 * d (half the diameter) is the circle's radius. + + See ellipseMode() for other ways to + set its position.

+line: 488 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + circle(50, 50, 25); + + describe('A white circle with black outline in the middle of a gray canvas.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + circle(0, 0, 25); + + describe('A white circle with black outline in the middle of a gray canvas.'); + } + +
+class: p5 +params: + - name: x + description: | +

x-coordinate of the center of the circle.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the center of the circle.

+ type: Number + - name: d + description: | +

diameter of the circle.

+ type: Number +chainable: true +--- + + +# circle diff --git a/src/content/reference/en/p5 copy/class.mdx b/src/content/reference/en/p5 copy/class.mdx new file mode 100644 index 0000000000..94b64b75c2 --- /dev/null +++ b/src/content/reference/en/p5 copy/class.mdx @@ -0,0 +1,19 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L1329 +title: class +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: "

A template for creating objects of a particular type.

\n

Classes can make it easier to program with objects. For example, a Frog\nclass could create objects that behave like frogs. Each object created\nusing a class is called an instance of that class. All instances of a class\nare the same type. Here's an example of creating an instance of a Frog\nclass:

\n
let fifi = new Frog(50, 50, 20);\n
\n

The variable fifi refers to an instance of the Frog class. The keyword\nnew is used to call the Frog class' constructor in the statement\nnew Frog(). Altogether, a new Frog object was created and assigned to\nthe variable fifi. Classes are templates, so they can be used to create\nmore than one instance:

\n
// First Frog instance.\nlet frog1 = new Frog(25, 50, 10);\n\n// Second Frog instance.\nlet frog2 = new Frog(75, 50, 10);\n
\n

A simple Frog class could be declared as follows:

\n
class Frog {\n  constructor(x, y, size) {\n    // This code runs once when an instance is created.\n    this.x = x;\n    this.y = y;\n    this.size = size;\n  }\n\n  show() {\n    // This code runs once when myFrog.show() is called.\n    textAlign(CENTER, CENTER);\n    textSize(this.size);\n    text('\U0001F438', this.x, this.y);\n  }\n\n  hop() {\n    // This code runs once when myFrog.hop() is called.\n    this.x += random(-10, 10);\n    this.y += random(-10, 10);\n  }\n}\n
\n

Class declarations begin with the keyword class followed by the class\nname, such as Frog, and curly braces {}. Class names should use\nPascalCase and can't have spaces in their names. For example, naming a\nclass Kermit The Frog with spaces between each word would throw a\nSyntaxError. The code between the curly braces {} defines the class.

\n

Functions that belong to a class are called methods. constructor(),\nshow(), and hop() are methods in the Frog class. Methods define an\nobject's behavior. Methods can accept parameters and return values, just\nlike functions. Note that methods don't use the function keyword.

\n

constructor() is a special method that's called once when an instance of\nthe class is created. The statement new Frog() calls the Frog class'\nconstructor() method.

\n

A class definition is a template for instances. The keyword this refers\nto an instance's data and methods. For example, each Frog instance has\nunique coordinates stored in this.x and this.y. The show() method\nuses those coordinates to draw the frog. The hop() method updates those\ncoordinates when called. Once a Frog instance is created, its data and\nmethods can be accessed using the dot operator . as follows:

\n
// Draw a lily pad.\nfill('green');\nstroke('green');\ncircle(fifi.x, fifi.y, 2 * fifi.size);\n\n// Show the Frog.\nfifi.show();\n\n// Hop.\nfifi.hop();\n
\n" +line: 1329 +isConstructor: false +itemtype: property +example: + - "\n
\n\n// Declare a frog variable.\nlet fifi;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variable a new Frog object.\n fifi = new Frog(50, 50, 20);\n\n describe('A frog face drawn on a blue background.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frog.\n fifi.show();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n}\n\n
\n\n
\n\n// Declare two frog variables.\nlet frog1;\nlet frog2;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variables a new Frog object.\n frog1 = new Frog(25, 50, 10);\n frog2 = new Frog(75, 50, 20);\n\n describe('Two frog faces drawn next to each other on a blue background.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frogs.\n frog1.show();\n frog2.show();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n}\n\n
\n\n
\n\n// Declare two frog variables.\nlet frog1;\nlet frog2;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variables a new Frog object.\n frog1 = new Frog(25, 50, 10);\n frog2 = new Frog(75, 50, 20);\n\n // Slow the frame rate.\n frameRate(1);\n\n describe('Two frog faces on a blue background. The frogs hop around randomly.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frogs.\n frog1.show();\n frog2.show();\n\n // Move the frogs.\n frog1.hop();\n frog2.hop();\n\n // Wrap around if they've hopped off the edge.\n frog1.checkEdges();\n frog2.checkEdges();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n\n hop() {\n this.x += random(-10, 10);\n this.y += random(-10, 10);\n }\n\n checkEdges() {\n if (this.x > width) {\n this.x = this.x - width;\n } else if (this.x < 0) {\n this.x = width - this.x;\n }\n\n if (this.y > height) {\n this.y = this.y - height;\n } else if (this.y < 0) {\n this.y = height - this.y;\n }\n }\n}\n\n
\n\n
\n\n// Create an array that will hold frogs.\nlet frogs = [];\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Add Frog objects to the array.\n for (let i = 0; i < 5; i += 1) {\n // Calculate random coordinates and size.\n let x = random(0, 100);\n let y = random(0, 100);\n let s = random(2, 20);\n\n // Create a new Frog object.\n let frog = new Frog(x, y, s);\n\n // Add the Frog to the array.\n frogs.push(frog);\n }\n\n // Slow the frame rate.\n frameRate(1);\n\n describe(\n 'Five frog faces on a blue background. The frogs hop around randomly.'\n );\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n for (let frog of frogs) {\n // Show the frog.\n frog.show();\n\n // Move the frog.\n frog.hop();\n\n // Wrap around if they've hopped off the edge.\n frog.checkEdges();\n }\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n\n hop() {\n this.x += random(-10, 10);\n this.y += random(-10, 10);\n }\n\n checkEdges() {\n if (this.x > width) {\n this.x = this.x - width;\n } else if (this.x < 0) {\n this.x = width - this.x;\n }\n\n if (this.y > height) {\n this.y = this.y - height;\n } else if (this.y < 0) {\n this.y = height - this.y;\n }\n }\n}\n\n
" +class: p5 +--- + + +# class diff --git a/src/content/reference/en/p5 copy/clear.mdx b/src/content/reference/en/p5 copy/clear.mdx new file mode 100644 index 0000000000..a096184afc --- /dev/null +++ b/src/content/reference/en/p5 copy/clear.mdx @@ -0,0 +1,108 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L673 +title: clear +module: Color +submodule: Setting +file: src/color/setting.js +description: > +

Clears the pixels on the canvas.

+ +

clear() makes every pixel 100% transparent. Calling + clear() doesn't + + clear objects created by createX() functions such as + + createGraphics(), + + createVideo(), and + + createImg(). These objects will remain + + unchanged after calling clear() and can be redrawn.

+ +

In WebGL mode, this function can clear the screen to a specific color. It + + interprets four numeric parameters as normalized RGBA color values. It also + + clears the depth buffer. If you are not using the WebGL renderer, these + + parameters will have no effect.

+line: 673 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + describe('A gray square. White circles are drawn as the user moves the mouse. The circles disappear when the user presses the mouse.'); + } + + function draw() { + circle(mouseX, mouseY, 20); + } + + function mousePressed() { + clear(); + background(200); + } + +
+ +
+ + let pg; + + function setup() { + createCanvas(100, 100); + background(200); + + pg = createGraphics(60, 60); + pg.background(200); + pg.noStroke(); + pg.circle(pg.width / 2, pg.height / 2, 15); + image(pg, 20, 20); + + describe('A white circle drawn on a gray square. The square gets smaller when the mouse is pressed.'); + } + + function mousePressed() { + clear(); + image(pg, 20, 20); + } + +
+class: p5 +params: + - name: r + description: | +

normalized red value.

+ type: Number + optional: true + - name: g + description: | +

normalized green value.

+ type: Number + optional: true + - name: b + description: | +

normalized blue value.

+ type: Number + optional: true + - name: a + description: | +

normalized alpha value.

+ type: Number + optional: true +chainable: true +--- + + +# clear diff --git a/src/content/reference/en/p5 copy/clearDepth.mdx b/src/content/reference/en/p5 copy/clearDepth.mdx new file mode 100644 index 0000000000..25425d1920 --- /dev/null +++ b/src/content/reference/en/p5 copy/clearDepth.mdx @@ -0,0 +1,113 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L635 +title: clearDepth +module: Rendering +submodule: Rendering +file: src/core/rendering.js +description: > +

Clears the depth buffer in WebGL mode.

+ +

clearDepth() clears information about how far objects are from + the camera + + in 3D space. This information is stored in an object called the + + depth buffer. Clearing the depth buffer ensures new objects aren't + drawn + + behind old ones. Doing so can be useful for feedback effects in which the + + previous frame serves as the background for the current frame.

+ +

The parameter, depth, is optional. If a number is passed, as + in + + clearDepth(0.5), it determines the range of objects to clear from + the + + depth buffer. 0 doesn't clear any depth information, 0.5 clears depth + + information halfway between the near and far clipping planes, and 1 clears + + depth information all the way to the far clipping plane. By default, + + depth is 1.

+ +

Note: clearDepth() can only be used in WebGL mode.

+line: 635 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let previous; + let current; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the p5.Framebuffer objects. + previous = createFramebuffer({ format: FLOAT }); + current = createFramebuffer({ format: FLOAT }); + + describe( + 'A multicolor box drifts from side to side on a white background. It leaves a trail that fades over time.' + ); + } + + function draw() { + // Swap the previous p5.Framebuffer and the + // current one so it can be used as a texture. + [previous, current] = [current, previous]; + + // Start drawing to the current p5.Framebuffer. + current.begin(); + + // Paint the background. + background(255); + + // Draw the previous p5.Framebuffer. + // Clear the depth buffer so the previous + // frame doesn't block the current one. + push(); + tint(255, 250); + image(previous, -50, -50); + clearDepth(); + pop(); + + // Draw the box on top of the previous frame. + push(); + let x = 25 * sin(frameCount * 0.01); + let y = 25 * sin(frameCount * 0.02); + translate(x, y, 0); + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + normalMaterial(); + box(12); + pop(); + + // Stop drawing to the current p5.Framebuffer. + current.end(); + + // Display the current p5.Framebuffer. + image(current, -50, -50); + } + +
+class: p5 +params: + - name: depth + description: | +

amount of the depth buffer to clear between 0 + (none) and 1 (far clipping plane). Defaults to 1.

+ type: Number + optional: true +chainable: false +--- + + +# clearDepth diff --git a/src/content/reference/en/p5 copy/clearStorage.mdx b/src/content/reference/en/p5 copy/clearStorage.mdx new file mode 100644 index 0000000000..d2c89e63bf --- /dev/null +++ b/src/content/reference/en/p5 copy/clearStorage.mdx @@ -0,0 +1,81 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/data/local_storage.js#L313 +title: clearStorage +module: Data +submodule: LocalStorage +file: src/data/local_storage.js +description: > +

Removes all items in the web browser's local storage.

+ +

Web browsers can save small amounts of data using the built-in + + localStorage object. + + Data stored in localStorage can be retrieved at any point, even + after + + refreshing a page or restarting the browser. Data are stored as key-value + + pairs. Calling clearStorage() removes all data from + localStorage.

+ +

Note: Sensitive data such as passwords or personal information shouldn't be + + stored in localStorage.

+line: 313 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Double-click to clear localStorage. + + function setup() { + createCanvas(100, 100); + + // Store the player's name. + storeItem('name', 'Feist'); + + // Store the player's score. + storeItem('score', 1234); + + describe( + 'The text "Feist: 1234" written in black on a gray background. The text "null: null" appears when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(14); + + // Retrieve the name. + let name = getItem('name'); + + // Retrieve the score. + let score = getItem('score'); + + // Display the score. + text(`${name}: ${score}`, 50, 50); + } + + // Clear localStorage when the user double-clicks. + function doubleClicked() { + clearStorage(); + } + +
+class: p5 +chainable: false +--- + + +# clearStorage diff --git a/src/content/reference/en/p5 copy/clip.mdx b/src/content/reference/en/p5 copy/clip.mdx new file mode 100644 index 0000000000..ae72687f03 --- /dev/null +++ b/src/content/reference/en/p5 copy/clip.mdx @@ -0,0 +1,225 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L222 +title: clip +module: Color +submodule: Setting +file: src/color/setting.js +description: > +

Defines a shape that will mask any shapes drawn afterward.

+ +

The first parameter, callback, is a function that defines the + mask. + + Any shapes drawn in callback will add to the mask shape. The + mask + + will apply to anything drawn after clip() is called.

+ +

The second parameter, options, is optional. If an object with + an invert + + property is passed, as in beginClip({ invert: true }), it will be + used to + + set the masking mode. { invert: true } inverts the mask, creating + holes + + in shapes that are masked. invert is false by + default.

+ +

Masks can be contained between the + + push() and pop() functions. + + Doing so allows unmasked shapes to be drawn after masked shapes.

+ +

Masks can also be defined with beginClip() + + and endClip().

+line: 222 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a mask. + clip(mask); + + // Draw a backing shape. + square(5, 5, 45); + + describe('A white triangle and circle on a gray background.'); + } + + // Declare a function that defines the mask. + function mask() { + triangle(15, 37, 30, 13, 43, 37); + circle(45, 45, 7); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an inverted mask. + clip(mask, { invert: true }); + + // Draw a backing shape. + square(5, 5, 45); + + describe('A white square at the top-left corner of a gray square. The white square has a triangle and a circle cut out of it.'); + } + + // Declare a function that defines the mask. + function mask() { + triangle(15, 37, 30, 13, 43, 37); + circle(45, 45, 7); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + noStroke(); + + // Draw a masked shape. + push(); + // Create a mask. + clip(mask); + + // Draw a backing shape. + square(5, 5, 45); + pop(); + + // Translate the origin to the center. + translate(50, 50); + + // Draw an inverted masked shape. + push(); + // Create an inverted mask. + clip(mask, { invert: true }); + + // Draw a backing shape. + square(5, 5, 45); + pop(); + + describe('In the top left, a white triangle and circle. In the bottom right, a white square with a triangle and circle cut out of it.'); + } + + // Declare a function that defines the mask. + function mask() { + triangle(15, 37, 30, 13, 43, 37); + circle(45, 45, 7); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A silhouette of a rotating torus colored fuchsia.'); + } + + function draw() { + background(200); + + // Create a mask. + clip(mask); + + // Draw a backing shape. + noStroke(); + fill('fuchsia'); + plane(100); + } + + // Declare a function that defines the mask. + function mask() { + push(); + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + scale(0.5); + torus(30, 15); + pop(); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A silhouette of a rotating torus colored with a gradient from cyan to purple.'); + } + + function draw() { + background(200); + + // Create a mask. + clip(mask); + + // Draw a backing shape. + noStroke(); + beginShape(QUAD_STRIP); + fill(0, 255, 255); + vertex(-width / 2, -height / 2); + vertex(width / 2, -height / 2); + fill(100, 0, 100); + vertex(-width / 2, height / 2); + vertex(width / 2, height / 2); + endShape(); + } + + // Declare a function that defines the mask. + function mask() { + push(); + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + scale(0.5); + torus(30, 15); + pop(); + } + +
+class: p5 +params: + - name: callback + description: | +

a function that draws the mask shape.

+ type: Function + - name: options + description: | +

an object containing clip settings.

+ type: Object + optional: true +chainable: false +--- + + +# clip diff --git a/src/content/reference/en/p5 copy/color.mdx b/src/content/reference/en/p5 copy/color.mdx new file mode 100644 index 0000000000..ad2bdbd8da --- /dev/null +++ b/src/content/reference/en/p5 copy/color.mdx @@ -0,0 +1,349 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L398 +title: color +module: Color +submodule: Creating & Reading +file: src/color/creating_reading.js +description: > +

Creates a p5.Color object.

+ +

By default, the parameters are interpreted as RGB values. Calling + + color(255, 204, 0) will return a bright yellow color. The way + these + + parameters are interpreted may be changed with the + + colorMode() function.

+ +

The version of color() with one parameter interprets the value + one of two + + ways. If the parameter is a number, it's interpreted as a grayscale value. + + If the parameter is a string, it's interpreted as a CSS color string.

+ +

The version of color() with two parameters interprets the + first one as a + + grayscale value. The second parameter sets the alpha (transparency) value.

+ +

The version of color() with three parameters interprets them + as RGB, HSB, + + or HSL colors, depending on the current colorMode().

+ +

The version of color() with four parameters interprets them as + RGBA, HSBA, + + or HSLA colors, depending on the current colorMode(). The last + parameter + + sets the alpha (transparency) value.

+line: 398 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object using RGB values. + let c = color(255, 204, 0); + + // Draw the square. + fill(c); + noStroke(); + square(30, 20, 55); + + describe('A yellow square on a gray canvas.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object using RGB values. + let c1 = color(255, 204, 0); + + // Draw the left circle. + fill(c1); + noStroke(); + circle(25, 25, 80); + + // Create a p5.Color object using a grayscale value. + let c2 = color(65); + + // Draw the right circle. + fill(c2); + circle(75, 75, 80); + + describe( + 'Two circles on a gray canvas. The circle in the top-left corner is yellow and the one at the bottom-right is gray.' + ); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object using a named color. + let c = color('magenta'); + + // Draw the square. + fill(c); + noStroke(); + square(20, 20, 60); + + describe('A magenta square on a gray canvas.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object using a hex color code. + let c1 = color('#0f0'); + + // Draw the left rectangle. + fill(c1); + noStroke(); + rect(0, 10, 45, 80); + + // Create a p5.Color object using a hex color code. + let c2 = color('#00ff00'); + + // Draw the right rectangle. + fill(c2); + rect(55, 10, 45, 80); + + describe('Two bright green rectangles on a gray canvas.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object using a RGB color string. + let c1 = color('rgb(0, 0, 255)'); + + // Draw the top-left square. + fill(c1); + square(10, 10, 35); + + // Create a p5.Color object using a RGB color string. + let c2 = color('rgb(0%, 0%, 100%)'); + + // Draw the top-right square. + fill(c2); + square(55, 10, 35); + + // Create a p5.Color object using a RGBA color string. + let c3 = color('rgba(0, 0, 255, 1)'); + + // Draw the bottom-left square. + fill(c3); + square(10, 55, 35); + + // Create a p5.Color object using a RGBA color string. + let c4 = color('rgba(0%, 0%, 100%, 1)'); + + // Draw the bottom-right square. + fill(c4); + square(55, 55, 35); + + describe('Four blue squares in the corners of a gray canvas.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object using a HSL color string. + let c1 = color('hsl(160, 100%, 50%)'); + + // Draw the left rectangle. + noStroke(); + fill(c1); + rect(0, 10, 45, 80); + + // Create a p5.Color object using a HSLA color string. + let c2 = color('hsla(160, 100%, 50%, 0.5)'); + + // Draw the right rectangle. + fill(c2); + rect(55, 10, 45, 80); + + describe('Two sea green rectangles. A darker rectangle on the left and a brighter one on the right.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object using a HSB color string. + let c1 = color('hsb(160, 100%, 50%)'); + + // Draw the left rectangle. + noStroke(); + fill(c1); + rect(0, 10, 45, 80); + + // Create a p5.Color object using a HSBA color string. + let c2 = color('hsba(160, 100%, 50%, 0.5)'); + + // Draw the right rectangle. + fill(c2); + rect(55, 10, 45, 80); + + describe('Two green rectangles. A darker rectangle on the left and a brighter one on the right.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object using RGB values. + let c1 = color(50, 55, 100); + + // Draw the left rectangle. + fill(c1); + rect(0, 10, 45, 80); + + // Switch the color mode to HSB. + colorMode(HSB, 100); + + // Create a p5.Color object using HSB values. + let c2 = color(50, 55, 100); + + // Draw the right rectangle. + fill(c2); + rect(55, 10, 45, 80); + + describe('Two blue rectangles. A darker rectangle on the left and a brighter one on the right.'); + } + +
+class: p5 +return: + description: resulting color. + type: p5.Color +overloads: + - line: 398 + params: + - name: gray + description: | +

number specifying value between white and black.

+ type: Number + - name: alpha + description: | +

alpha value relative to current color range + (default is 0-255).

+ type: Number + optional: true + return: + description: resulting color. + type: p5.Color + - line: 652 + params: + - name: v1 + description: | +

red or hue value relative to + the current color range.

+ type: Number + - name: v2 + description: | +

green or saturation value + relative to the current color range.

+ type: Number + - name: v3 + description: | +

blue or brightness value + relative to the current color range.

+ type: Number + - name: alpha + description: '' + type: Number + optional: true + return: + description: '' + type: p5.Color + - line: 664 + params: + - name: value + description: | +

a color string.

+ type: String + return: + description: '' + type: p5.Color + - line: 670 + params: + - name: values + description: | +

an array containing the red, green, blue, + and alpha components of the color.

+ type: 'Number[]' + return: + description: '' + type: p5.Color + - line: 677 + params: + - name: color + description: '' + type: p5.Color + return: + description: '' + type: p5.Color +chainable: false +--- + + +# color diff --git a/src/content/reference/en/p5 copy/colorMode.mdx b/src/content/reference/en/p5 copy/colorMode.mdx new file mode 100644 index 0000000000..b4aca3c9ce --- /dev/null +++ b/src/content/reference/en/p5 copy/colorMode.mdx @@ -0,0 +1,271 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L751 +title: colorMode +module: Color +submodule: Setting +file: src/color/setting.js +description: > +

Changes the way color values are interpreted.

+ +

By default, the Number parameters for fill(), + + stroke(), + + background(), and + + color() are defined by values between 0 and + 255 + + using the RGB color model. This is equivalent to calling + + colorMode(RGB, 255). Pure red is color(255, 0, 0) in + this model.

+ +

Calling colorMode(RGB, 100) sets colors to use RGB color + values + + between 0 and 100. Pure red is color(100, 0, 0) in this + model.

+ +

Calling colorMode(HSB) or colorMode(HSL) changes + to HSB or HSL system + + instead of RGB. Pure red is color(0, 100, 100) in HSB and + + color(0, 100, 50) in HSL.

+ +

p5.Color objects remember the mode + that they were + + created in. Changing modes doesn't affect their appearance.

+line: 751 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Fill with pure red. + fill(255, 0, 0); + + circle(50, 50, 25); + + describe('A gray square with a red circle at its center.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use RGB color with values in the range 0-100. + colorMode(RGB, 100); + + // Fill with pure red. + fill(100, 0, 0); + + circle(50, 50, 25); + + describe('A gray square with a red circle at its center.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use HSB color. + colorMode(HSB); + + // Fill with pure red. + fill(0, 100, 100); + + circle(50, 50, 25); + + describe('A gray square with a red circle at its center.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use HSL color. + colorMode(HSL); + + // Fill with pure red. + fill(0, 100, 50); + + circle(50, 50, 25); + + describe('A gray square with a red circle at its center.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Use RGB color with values in the range 0-100. + colorMode(RGB, 100); + + for (let x = 0; x < 100; x += 1) { + for (let y = 0; y < 100; y += 1) { + stroke(x, y, 0); + point(x, y); + } + } + + describe( + 'A diagonal green to red gradient from bottom-left to top-right with shading transitioning to black at top-left corner.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Use HSB color with values in the range 0-100. + colorMode(HSB, 100); + + for (let x = 0; x < 100; x += 1) { + for (let y = 0; y < 100; y += 1) { + stroke(x, y, 100); + point(x, y); + } + } + + describe('A rainbow gradient from left-to-right. Brightness transitions to white at the top.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Create a p5.Color object. + let myColor = color(180, 175, 230); + background(myColor); + + // Use RGB color with values in the range 0-1. + colorMode(RGB, 1); + + // Get the red, green, and blue color components. + let redValue = red(myColor); + let greenValue = green(myColor); + let blueValue = blue(myColor); + + // Round the color components for display. + redValue = round(redValue, 2); + greenValue = round(greenValue, 2); + blueValue = round(blueValue, 2); + + // Display the color components. + text(`Red: ${redValue}`, 10, 10, 80, 80); + text(`Green: ${greenValue}`, 10, 40, 80, 80); + text(`Blue: ${blueValue}`, 10, 70, 80, 80); + + describe('A purple canvas with the red, green, and blue decimal values of the color written on it.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(255); + + // Use RGB color with alpha values in the range 0-1. + colorMode(RGB, 255, 255, 255, 1); + + noFill(); + strokeWeight(4); + stroke(255, 0, 10, 0.3); + circle(40, 40, 50); + circle(50, 60, 50); + + describe('Two overlapping translucent pink circle outlines.'); + } + +
+class: p5 +overloads: + - line: 751 + params: + - name: mode + description: | +

either RGB, HSB or HSL, corresponding to + Red/Green/Blue and Hue/Saturation/Brightness + (or Lightness).

+ type: Constant + - name: max + description: | +

range for all values.

+ type: Number + optional: true + chainable: 1 + - line: 956 + params: + - name: mode + description: '' + type: Constant + - name: max1 + description: | +

range for the red or hue depending on the + current color mode.

+ type: Number + - name: max2 + description: | +

range for the green or saturation depending + on the current color mode.

+ type: Number + - name: max3 + description: | +

range for the blue or brightness/lightness + depending on the current color mode.

+ type: Number + - name: maxA + description: | +

range for the alpha.

+ type: Number + optional: true + chainable: 1 +chainable: true +--- + + +# colorMode diff --git a/src/content/reference/en/p5 copy/concat.mdx b/src/content/reference/en/p5 copy/concat.mdx new file mode 100644 index 0000000000..1e83bf84c0 --- /dev/null +++ b/src/content/reference/en/p5 copy/concat.mdx @@ -0,0 +1,54 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L112 +title: concat +module: Data +submodule: Array Functions +file: src/utilities/array_functions.js +description: | +

Concatenates two arrays, maps to Array.concat(). Does not modify the + input arrays.

+line: 112 +deprecated: >- + Use arr1.concat(arr2) + instead. +isConstructor: false +itemtype: method +example: + - |- + +
+ function setup() { + let arr1 = ['A', 'B', 'C']; + let arr2 = [1, 2, 3]; + + print(arr1); // ['A','B','C'] + print(arr2); // [1,2,3] + + let arr3 = concat(arr1, arr2); + + print(arr1); // ['A','B','C'] + print(arr2); // [1, 2, 3] + print(arr3); // ['A','B','C', 1, 2, 3] + } +
+class: p5 +params: + - name: a + description: | +

first Array to concatenate

+ type: Array + - name: b + description: | +

second Array to concatenate

+ type: Array +return: + description: concatenated array + type: Array +chainable: false +--- + + +# concat diff --git a/src/content/reference/en/p5 copy/cone.mdx b/src/content/reference/en/p5 copy/cone.mdx new file mode 100644 index 0000000000..ff0756d0a5 --- /dev/null +++ b/src/content/reference/en/p5 copy/cone.mdx @@ -0,0 +1,265 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L1730 +title: cone +module: Shape +submodule: 3D Primitives +file: src/webgl/3d_primitives.js +description: > +

Draws a cone.

+ +

A cone is a 3D shape with triangular faces that connect a flat bottom to a + + single point. Cones with few faces look like pyramids. Cones with many + + faces have smooth surfaces.

+ +

The first parameter, radius, is optional. If a + Number is passed, as in + + cone(20), it sets the radius of the cone’s base. By default, + radius is + + 50.

+ +

The second parameter, height, is also optional. If a + Number is passed, + + as in cone(20, 30), it sets the cone’s height. By default, + height is + + set to the cone’s radius.

+ +

The third parameter, detailX, is also optional. If a + Number is passed, + + as in cone(20, 30, 5), it sets the number of edges used to form + the + + cone's base. Using more edges makes the base look more like a circle. By + + default, detailX is 24.

+ +

The fourth parameter, detailY, is also optional. If a + Number is passed, + + as in cone(20, 30, 5, 7), it sets the number of triangle + subdivisions to + + use along the y-axis connecting the base to the tip. All 3D shapes are made + + by connecting triangles to form their surfaces. By default, + detailY is 1.

+ +

The fifth parameter, cap, is also optional. If a + false is passed, as + + in cone(20, 30, 5, 7, false) the cone’s base won’t be drawn. By + default, + + cap is true.

+ +

Note: cone() can only be used in WebGL mode.

+line: 1730 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cone on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cone. + cone(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cone on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cone. + // Set its radius and height to 30. + cone(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cone on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cone. + // Set its radius to 30 and height to 50. + cone(30, 50); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cone on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cone. + // Set its radius to 30 and height to 50. + // Set its detailX to 5. + cone(30, 50, 5); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white pyramid on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cone. + // Set its radius to 30 and height to 50. + // Set its detailX to 5. + cone(30, 50, 5); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cone on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cone. + // Set its radius to 30 and height to 50. + // Set its detailX to 24 and detailY to 2. + cone(30, 50, 24, 2); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cone on a gray background. Its base is missing.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cone. + // Set its radius to 30 and height to 50. + // Set its detailX to 24 and detailY to 1. + // Don't draw its base. + cone(30, 50, 24, 1, false); + } + +
+class: p5 +params: + - name: radius + description: | +

radius of the cone's base. Defaults to 50.

+ type: Number + optional: true + - name: height + description: | +

height of the cone. Defaults to the value of radius.

+ type: Number + optional: true + - name: detailX + description: | +

number of edges used to draw the base. Defaults to 24.

+ type: Integer + optional: true + - name: detailY + description: | +

number of triangle subdivisions along the y-axis. Defaults to 1.

+ type: Integer + optional: true + - name: cap + description: | +

whether to draw the cone's base. Defaults to true.

+ type: Boolean + optional: true +chainable: true +--- + + +# cone diff --git a/src/content/reference/en/p5 copy/console.mdx b/src/content/reference/en/p5 copy/console.mdx new file mode 100644 index 0000000000..411b08357e --- /dev/null +++ b/src/content/reference/en/p5 copy/console.mdx @@ -0,0 +1,99 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L1988 +title: console +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: > +

Prints a message to the web browser's console.

+ +

The console + + object is helpful for printing messages while debugging. For example, it's + + common to add a console.log() statement while studying how a + section of + + code works:

+ +
if (isPlaying === true) {
+    // Add a console.log() statement to make sure this block of code runs.
+    console.log('Got here!');
+
+    // Game logic.
+  }
+
+  
+ +

console.error() is helpful for tracking errors because it + prints + + formatted messages. For example, it's common to encounter errors when + + loading media assets:

+ +
// Logs an error message with special
+  formatting.
+
+  function handleFailure(error) {
+    console.error('Oops!', error);
+  }
+
+
+  // Try to load an image and call handleError() if it fails.
+
+  loadImage('https://example.com/cat.jpg', handleImage, handleError);
+
+  
+line: 1988 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + noCanvas(); + + // Prints "Hello!" to the console. + console.log('Hello!'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Try to load an image from a fake URL. + // Call handleError() if the image fails to load. + loadImage('https://example.com/cat.jpg', handleImage, handleError); + } + + // Displays the image. + function handleImage(img) { + image(img, 0, 0); + + describe('A cat on a gray background.'); + } + + // Prints the error. + function handleError(error) { + console.error('Oops!', error); + + describe('A gray square.'); + } + +
+class: p5 +--- + + +# console diff --git a/src/content/reference/en/p5 copy/constants/ADD.mdx b/src/content/reference/en/p5 copy/constants/ADD.mdx new file mode 100644 index 0000000000..9148f688e9 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/ADD.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L905 +title: ADD +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 905 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# ADD diff --git a/src/content/reference/en/p5 copy/constants/ALT.mdx b/src/content/reference/en/p5 copy/constants/ALT.mdx new file mode 100644 index 0000000000..a039e3919b --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/ALT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L820 +title: ALT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 820 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# ALT diff --git a/src/content/reference/en/p5 copy/constants/ARROW.mdx b/src/content/reference/en/p5 copy/constants/ARROW.mdx new file mode 100644 index 0000000000..d2a0e065a1 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/ARROW.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L55 +title: ARROW +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 55 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# ARROW diff --git a/src/content/reference/en/p5 copy/constants/AUTO.mdx b/src/content/reference/en/p5 copy/constants/AUTO.mdx new file mode 100644 index 0000000000..185fb15902 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/AUTO.mdx @@ -0,0 +1,25 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L810 +title: AUTO +module: Constants +submodule: Constants +file: src/core/constants.js +description: > +

AUTO allows us to automatically set the width or height of an element (but + not both), + + based on the current height and width of the element. Only one parameter can + + be passed to the size function as + AUTO, at a time.

+line: 810 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# AUTO diff --git a/src/content/reference/en/p5 copy/constants/AXES.mdx b/src/content/reference/en/p5 copy/constants/AXES.mdx new file mode 100644 index 0000000000..c6f60b6b89 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/AXES.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1171 +title: AXES +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1171 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# AXES diff --git a/src/content/reference/en/p5 copy/constants/BACKSPACE.mdx b/src/content/reference/en/p5 copy/constants/BACKSPACE.mdx new file mode 100644 index 0000000000..ee299ffcff --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/BACKSPACE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L826 +title: BACKSPACE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 826 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# BACKSPACE diff --git a/src/content/reference/en/p5 copy/constants/BASELINE.mdx b/src/content/reference/en/p5 copy/constants/BASELINE.mdx new file mode 100644 index 0000000000..200aa201ec --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/BASELINE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L675 +title: BASELINE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 675 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# BASELINE diff --git a/src/content/reference/en/p5 copy/constants/BEVEL.mdx b/src/content/reference/en/p5 copy/constants/BEVEL.mdx new file mode 100644 index 0000000000..a4af3693f7 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/BEVEL.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L777 +title: BEVEL +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 777 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# BEVEL diff --git a/src/content/reference/en/p5 copy/constants/BEZIER.mdx b/src/content/reference/en/p5 copy/constants/BEZIER.mdx new file mode 100644 index 0000000000..b2993b2c33 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/BEZIER.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1073 +title: BEZIER +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1073 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# BEZIER diff --git a/src/content/reference/en/p5 copy/constants/BLEND.mdx b/src/content/reference/en/p5 copy/constants/BLEND.mdx new file mode 100644 index 0000000000..bf367f05eb --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/BLEND.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L893 +title: BLEND +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 893 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# BLEND diff --git a/src/content/reference/en/p5 copy/constants/BLUR.mdx b/src/content/reference/en/p5 copy/constants/BLUR.mdx new file mode 100644 index 0000000000..5580994e74 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/BLUR.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1019 +title: BLUR +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1019 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# BLUR diff --git a/src/content/reference/en/p5 copy/constants/BOLD.mdx b/src/content/reference/en/p5 copy/constants/BOLD.mdx new file mode 100644 index 0000000000..6069c955e8 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/BOLD.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1036 +title: BOLD +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1036 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# BOLD diff --git a/src/content/reference/en/p5 copy/constants/BOLDITALIC.mdx b/src/content/reference/en/p5 copy/constants/BOLDITALIC.mdx new file mode 100644 index 0000000000..2967579a9c --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/BOLDITALIC.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1041 +title: BOLDITALIC +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1041 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# BOLDITALIC diff --git a/src/content/reference/en/p5 copy/constants/BOTTOM.mdx b/src/content/reference/en/p5 copy/constants/BOTTOM.mdx new file mode 100644 index 0000000000..b01ded11ea --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/BOTTOM.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L670 +title: BOTTOM +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 670 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# BOTTOM diff --git a/src/content/reference/en/p5 copy/constants/BURN.mdx b/src/content/reference/en/p5 copy/constants/BURN.mdx new file mode 100644 index 0000000000..7ba3764dac --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/BURN.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L976 +title: BURN +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 976 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# BURN diff --git a/src/content/reference/en/p5 copy/constants/CENTER.mdx b/src/content/reference/en/p5 copy/constants/CENTER.mdx new file mode 100644 index 0000000000..cab0205cef --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/CENTER.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L660 +title: CENTER +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 660 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# CENTER diff --git a/src/content/reference/en/p5 copy/constants/CHAR.mdx b/src/content/reference/en/p5 copy/constants/CHAR.mdx new file mode 100644 index 0000000000..564855787a --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/CHAR.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1046 +title: CHAR +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1046 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# CHAR diff --git a/src/content/reference/en/p5 copy/constants/CHORD.mdx b/src/content/reference/en/p5 copy/constants/CHORD.mdx new file mode 100644 index 0000000000..40896bb3a1 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/CHORD.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L750 +title: CHORD +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 750 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# CHORD diff --git a/src/content/reference/en/p5 copy/constants/CLAMP.mdx b/src/content/reference/en/p5 copy/constants/CLAMP.mdx new file mode 100644 index 0000000000..977b02599d --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/CLAMP.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1126 +title: CLAMP +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1126 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# CLAMP diff --git a/src/content/reference/en/p5 copy/constants/CLOSE.mdx b/src/content/reference/en/p5 copy/constants/CLOSE.mdx new file mode 100644 index 0000000000..34bc946fe5 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/CLOSE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L740 +title: CLOSE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 740 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# CLOSE diff --git a/src/content/reference/en/p5 copy/constants/CONTAIN.mdx b/src/content/reference/en/p5 copy/constants/CONTAIN.mdx new file mode 100644 index 0000000000..59d56be350 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/CONTAIN.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1188 +title: CONTAIN +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1188 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# CONTAIN diff --git a/src/content/reference/en/p5 copy/constants/CONTROL.mdx b/src/content/reference/en/p5 copy/constants/CONTROL.mdx new file mode 100644 index 0000000000..d620bb502d --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/CONTROL.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L831 +title: CONTROL +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 831 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# CONTROL diff --git a/src/content/reference/en/p5 copy/constants/CORNER.mdx b/src/content/reference/en/p5 copy/constants/CORNER.mdx new file mode 100644 index 0000000000..e8b5eced3e --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/CORNER.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L635 +title: CORNER +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 635 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# CORNER diff --git a/src/content/reference/en/p5 copy/constants/CORNERS.mdx b/src/content/reference/en/p5 copy/constants/CORNERS.mdx new file mode 100644 index 0000000000..85e4226b1e --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/CORNERS.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L640 +title: CORNERS +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 640 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# CORNERS diff --git a/src/content/reference/en/p5 copy/constants/COVER.mdx b/src/content/reference/en/p5 copy/constants/COVER.mdx new file mode 100644 index 0000000000..3714b4bec3 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/COVER.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1194 +title: COVER +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1194 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# COVER diff --git a/src/content/reference/en/p5 copy/constants/CROSS.mdx b/src/content/reference/en/p5 copy/constants/CROSS.mdx new file mode 100644 index 0000000000..eba1238e34 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/CROSS.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L60 +title: CROSS +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 60 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# CROSS diff --git a/src/content/reference/en/p5 copy/constants/CURVE.mdx b/src/content/reference/en/p5 copy/constants/CURVE.mdx new file mode 100644 index 0000000000..3e46bf2151 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/CURVE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1078 +title: CURVE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1078 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# CURVE diff --git a/src/content/reference/en/p5 copy/constants/DARKEST.mdx b/src/content/reference/en/p5 copy/constants/DARKEST.mdx new file mode 100644 index 0000000000..b86d06dec4 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/DARKEST.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L913 +title: DARKEST +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 913 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# DARKEST diff --git a/src/content/reference/en/p5 copy/constants/DEGREES.mdx b/src/content/reference/en/p5 copy/constants/DEGREES.mdx new file mode 100644 index 0000000000..c259f456ad --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/DEGREES.mdx @@ -0,0 +1,59 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L547 +title: DEGREES +module: Constants +submodule: Constants +file: src/core/constants.js +description: > +

A String constant that's used to set the + + angleMode().

+ +

By default, functions such as rotate() + and + + sin() expect angles measured in units of + radians. + + Calling angleMode(DEGREES) ensures that angles are measured in + units of + + degrees.

+ +

Note: TWO_PI radians equals 360˚.

+line: 547 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw a red arc from 0 to HALF_PI radians. + fill(255, 0, 0); + arc(50, 50, 80, 80, 0, HALF_PI); + + // Use degrees. + angleMode(DEGREES); + + // Draw a blue arc from 90˚ to 180˚. + fill(0, 0, 255); + arc(50, 50, 80, 80, 90, 180); + + describe('The bottom half of a circle drawn on a gray background. The bottom-right quarter is red. The bottom-left quarter is blue.'); + } + +
+class: p5 +type: String +--- + + +# DEGREES diff --git a/src/content/reference/en/p5 copy/constants/DELETE.mdx b/src/content/reference/en/p5 copy/constants/DELETE.mdx new file mode 100644 index 0000000000..3bef8a3983 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/DELETE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L836 +title: DELETE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 836 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# DELETE diff --git a/src/content/reference/en/p5 copy/constants/DIFFERENCE.mdx b/src/content/reference/en/p5 copy/constants/DIFFERENCE.mdx new file mode 100644 index 0000000000..27d7e0880c --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/DIFFERENCE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L924 +title: DIFFERENCE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 924 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# DIFFERENCE diff --git a/src/content/reference/en/p5 copy/constants/DILATE.mdx b/src/content/reference/en/p5 copy/constants/DILATE.mdx new file mode 100644 index 0000000000..5eca5b06dd --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/DILATE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1009 +title: DILATE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1009 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# DILATE diff --git a/src/content/reference/en/p5 copy/constants/DODGE.mdx b/src/content/reference/en/p5 copy/constants/DODGE.mdx new file mode 100644 index 0000000000..ba1594bfe4 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/DODGE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L970 +title: DODGE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 970 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# DODGE diff --git a/src/content/reference/en/p5 copy/constants/DOWN_ARROW.mdx b/src/content/reference/en/p5 copy/constants/DOWN_ARROW.mdx new file mode 100644 index 0000000000..c1d80ae679 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/DOWN_ARROW.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L841 +title: DOWN_ARROW +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 841 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# DOWN\_ARROW diff --git a/src/content/reference/en/p5 copy/constants/ENTER.mdx b/src/content/reference/en/p5 copy/constants/ENTER.mdx new file mode 100644 index 0000000000..0ded2aec7f --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/ENTER.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L846 +title: ENTER +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 846 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# ENTER diff --git a/src/content/reference/en/p5 copy/constants/ERODE.mdx b/src/content/reference/en/p5 copy/constants/ERODE.mdx new file mode 100644 index 0000000000..9dba021043 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/ERODE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1014 +title: ERODE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1014 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# ERODE diff --git a/src/content/reference/en/p5 copy/constants/ESCAPE.mdx b/src/content/reference/en/p5 copy/constants/ESCAPE.mdx new file mode 100644 index 0000000000..53256ed7ce --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/ESCAPE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L851 +title: ESCAPE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 851 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# ESCAPE diff --git a/src/content/reference/en/p5 copy/constants/EXCLUSION.mdx b/src/content/reference/en/p5 copy/constants/EXCLUSION.mdx new file mode 100644 index 0000000000..61c3572125 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/EXCLUSION.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L934 +title: EXCLUSION +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 934 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# EXCLUSION diff --git a/src/content/reference/en/p5 copy/constants/FALLBACK.mdx b/src/content/reference/en/p5 copy/constants/FALLBACK.mdx new file mode 100644 index 0000000000..6c9f4ec37c --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/FALLBACK.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1182 +title: FALLBACK +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1182 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# FALLBACK diff --git a/src/content/reference/en/p5 copy/constants/FILL.mdx b/src/content/reference/en/p5 copy/constants/FILL.mdx new file mode 100644 index 0000000000..9e2ca1ce96 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/FILL.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1090 +title: FILL +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1090 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# FILL diff --git a/src/content/reference/en/p5 copy/constants/FLAT.mdx b/src/content/reference/en/p5 copy/constants/FLAT.mdx new file mode 100644 index 0000000000..50d8b95b1e --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/FLAT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1138 +title: FLAT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1138 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# FLAT diff --git a/src/content/reference/en/p5 copy/constants/FLOAT.mdx b/src/content/reference/en/p5 copy/constants/FLOAT.mdx new file mode 100644 index 0000000000..b063ffc631 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/FLOAT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1212 +title: FLOAT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1212 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# FLOAT diff --git a/src/content/reference/en/p5 copy/constants/GRAY.mdx b/src/content/reference/en/p5 copy/constants/GRAY.mdx new file mode 100644 index 0000000000..ca8a56d090 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/GRAY.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L989 +title: GRAY +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 989 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# GRAY diff --git a/src/content/reference/en/p5 copy/constants/GRID.mdx b/src/content/reference/en/p5 copy/constants/GRID.mdx new file mode 100644 index 0000000000..683bbf43f9 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/GRID.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1165 +title: GRID +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1165 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# GRID diff --git a/src/content/reference/en/p5 copy/constants/HALF_FLOAT.mdx b/src/content/reference/en/p5 copy/constants/HALF_FLOAT.mdx new file mode 100644 index 0000000000..a70c409626 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/HALF_FLOAT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1218 +title: HALF_FLOAT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1218 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# HALF\_FLOAT diff --git a/src/content/reference/en/p5 copy/constants/HALF_PI.mdx b/src/content/reference/en/p5 copy/constants/HALF_PI.mdx new file mode 100644 index 0000000000..212458ee9e --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/HALF_PI.mdx @@ -0,0 +1,109 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L88 +title: HALF_PI +module: Constants +submodule: Constants +file: src/core/constants.js +description: > +

A Number constant that's approximately 1.5708.

+ +

HALF_PI is half the value of the mathematical constant π. It's + useful for + + many tasks that involve rotation and oscillation. For example, calling + + rotate(HALF_PI) rotates the coordinate system + HALF_PI radians, which is + + a quarter turn (90˚).

+ +

Note: TWO_PI radians equals 360˚, PI radians + equals 180˚, HALF_PI + + radians equals 90˚, and QUARTER_PI radians equals 45˚.

+line: 88 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw an arc from 0 to HALF_PI. + arc(50, 50, 80, 80, 0, HALF_PI); + + describe('The bottom-right quarter of a circle drawn in white on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Draw a line. + line(0, 0, 40, 0); + + // Rotate a quarter turn. + rotate(HALF_PI); + + // Draw the same line, rotated. + line(0, 0, 40, 0); + + describe('Two black lines on a gray background. One line extends from the center to the right. The other line extends from the center to the bottom.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A red circle and a blue circle oscillate from left to right on a gray background. The red circle appears to chase the blue circle.' + ); + } + + function draw() { + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Calculate the x-coordinates. + let x1 = 40 * sin(frameCount * 0.05); + let x2 = 40 * sin(frameCount * 0.05 + HALF_PI); + + // Style the oscillators. + noStroke(); + + // Draw the red oscillator. + fill(255, 0, 0); + circle(x1, 0, 20); + + // Draw the blue oscillator. + fill(0, 0, 255); + circle(x2, 0, 20); + } + +
+class: p5 +type: Number +--- + + +# HALF\_PI diff --git a/src/content/reference/en/p5 copy/constants/HAND.mdx b/src/content/reference/en/p5 copy/constants/HAND.mdx new file mode 100644 index 0000000000..0bd864fb59 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/HAND.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L65 +title: HAND +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 65 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# HAND diff --git a/src/content/reference/en/p5 copy/constants/HARD_LIGHT.mdx b/src/content/reference/en/p5 copy/constants/HARD_LIGHT.mdx new file mode 100644 index 0000000000..9f3f9742fc --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/HARD_LIGHT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L960 +title: HARD_LIGHT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 960 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# HARD\_LIGHT diff --git a/src/content/reference/en/p5 copy/constants/HSB.mdx b/src/content/reference/en/p5 copy/constants/HSB.mdx new file mode 100644 index 0000000000..d921d5405e --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/HSB.mdx @@ -0,0 +1,24 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L794 +title: HSB +module: Constants +submodule: Constants +file: src/core/constants.js +description: > +

HSB (hue, saturation, brightness) is a type of color model. + + You can learn more about it at + + HSB.

+line: 794 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# HSB diff --git a/src/content/reference/en/p5 copy/constants/HSL.mdx b/src/content/reference/en/p5 copy/constants/HSL.mdx new file mode 100644 index 0000000000..aa660c2da5 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/HSL.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L803 +title: HSL +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 803 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# HSL diff --git a/src/content/reference/en/p5 copy/constants/IMAGE.mdx b/src/content/reference/en/p5 copy/constants/IMAGE.mdx new file mode 100644 index 0000000000..479af890bb --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/IMAGE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1108 +title: IMAGE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1108 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# IMAGE diff --git a/src/content/reference/en/p5 copy/constants/IMMEDIATE.mdx b/src/content/reference/en/p5 copy/constants/IMMEDIATE.mdx new file mode 100644 index 0000000000..52b38ee8b5 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/IMMEDIATE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1100 +title: IMMEDIATE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1100 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# IMMEDIATE diff --git a/src/content/reference/en/p5 copy/constants/INVERT.mdx b/src/content/reference/en/p5 copy/constants/INVERT.mdx new file mode 100644 index 0000000000..9c383dd4d1 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/INVERT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L999 +title: INVERT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 999 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# INVERT diff --git a/src/content/reference/en/p5 copy/constants/ITALIC.mdx b/src/content/reference/en/p5 copy/constants/ITALIC.mdx new file mode 100644 index 0000000000..d0a9a1f2e5 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/ITALIC.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1031 +title: ITALIC +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1031 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# ITALIC diff --git a/src/content/reference/en/p5 copy/constants/LABEL.mdx b/src/content/reference/en/p5 copy/constants/LABEL.mdx new file mode 100644 index 0000000000..92786b3feb --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/LABEL.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1177 +title: LABEL +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1177 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# LABEL diff --git a/src/content/reference/en/p5 copy/constants/LANDSCAPE.mdx b/src/content/reference/en/p5 copy/constants/LANDSCAPE.mdx new file mode 100644 index 0000000000..c1709051cd --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/LANDSCAPE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1150 +title: LANDSCAPE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1150 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# LANDSCAPE diff --git a/src/content/reference/en/p5 copy/constants/LEFT.mdx b/src/content/reference/en/p5 copy/constants/LEFT.mdx new file mode 100644 index 0000000000..6e48fe2d99 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/LEFT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L655 +title: LEFT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 655 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# LEFT diff --git a/src/content/reference/en/p5 copy/constants/LEFT_ARROW.mdx b/src/content/reference/en/p5 copy/constants/LEFT_ARROW.mdx new file mode 100644 index 0000000000..8628e56688 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/LEFT_ARROW.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L856 +title: LEFT_ARROW +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 856 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# LEFT\_ARROW diff --git a/src/content/reference/en/p5 copy/constants/LIGHTEST.mdx b/src/content/reference/en/p5 copy/constants/LIGHTEST.mdx new file mode 100644 index 0000000000..bd15662468 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/LIGHTEST.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L918 +title: LIGHTEST +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 918 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# LIGHTEST diff --git a/src/content/reference/en/p5 copy/constants/LINEAR.mdx b/src/content/reference/en/p5 copy/constants/LINEAR.mdx new file mode 100644 index 0000000000..e56c663585 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/LINEAR.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1063 +title: LINEAR +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1063 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# LINEAR diff --git a/src/content/reference/en/p5 copy/constants/LINES.mdx b/src/content/reference/en/p5 copy/constants/LINES.mdx new file mode 100644 index 0000000000..9d7d5d2abc --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/LINES.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L687 +title: LINES +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 687 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# LINES diff --git a/src/content/reference/en/p5 copy/constants/LINE_LOOP.mdx b/src/content/reference/en/p5 copy/constants/LINE_LOOP.mdx new file mode 100644 index 0000000000..2a566fa4c7 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/LINE_LOOP.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L699 +title: LINE_LOOP +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 699 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# LINE\_LOOP diff --git a/src/content/reference/en/p5 copy/constants/LINE_STRIP.mdx b/src/content/reference/en/p5 copy/constants/LINE_STRIP.mdx new file mode 100644 index 0000000000..816e857d01 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/LINE_STRIP.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L693 +title: LINE_STRIP +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 693 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# LINE\_STRIP diff --git a/src/content/reference/en/p5 copy/constants/MIRROR.mdx b/src/content/reference/en/p5 copy/constants/MIRROR.mdx new file mode 100644 index 0000000000..9b2bcd7146 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/MIRROR.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1131 +title: MIRROR +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1131 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# MIRROR diff --git a/src/content/reference/en/p5 copy/constants/MITER.mdx b/src/content/reference/en/p5 copy/constants/MITER.mdx new file mode 100644 index 0000000000..533039ecc8 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/MITER.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L782 +title: MITER +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 782 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# MITER diff --git a/src/content/reference/en/p5 copy/constants/MOVE.mdx b/src/content/reference/en/p5 copy/constants/MOVE.mdx new file mode 100644 index 0000000000..aea9bf8a71 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/MOVE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L70 +title: MOVE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 70 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# MOVE diff --git a/src/content/reference/en/p5 copy/constants/MULTIPLY.mdx b/src/content/reference/en/p5 copy/constants/MULTIPLY.mdx new file mode 100644 index 0000000000..ce343b4bf2 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/MULTIPLY.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L939 +title: MULTIPLY +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 939 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# MULTIPLY diff --git a/src/content/reference/en/p5 copy/constants/NEAREST.mdx b/src/content/reference/en/p5 copy/constants/NEAREST.mdx new file mode 100644 index 0000000000..9fba7e46cf --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/NEAREST.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1116 +title: NEAREST +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1116 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# NEAREST diff --git a/src/content/reference/en/p5 copy/constants/NORMAL.mdx b/src/content/reference/en/p5 copy/constants/NORMAL.mdx new file mode 100644 index 0000000000..2c49e02fbf --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/NORMAL.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1026 +title: NORMAL +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1026 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# NORMAL diff --git a/src/content/reference/en/p5 copy/constants/OPAQUE.mdx b/src/content/reference/en/p5 copy/constants/OPAQUE.mdx new file mode 100644 index 0000000000..9ddf599dd1 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/OPAQUE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L994 +title: OPAQUE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 994 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# OPAQUE diff --git a/src/content/reference/en/p5 copy/constants/OPEN.mdx b/src/content/reference/en/p5 copy/constants/OPEN.mdx new file mode 100644 index 0000000000..29011d1e69 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/OPEN.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L745 +title: OPEN +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 745 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# OPEN diff --git a/src/content/reference/en/p5 copy/constants/OPTION.mdx b/src/content/reference/en/p5 copy/constants/OPTION.mdx new file mode 100644 index 0000000000..8ea0e625db --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/OPTION.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L861 +title: OPTION +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 861 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# OPTION diff --git a/src/content/reference/en/p5 copy/constants/OVERLAY.mdx b/src/content/reference/en/p5 copy/constants/OVERLAY.mdx new file mode 100644 index 0000000000..ccb03411bb --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/OVERLAY.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L955 +title: OVERLAY +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 955 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# OVERLAY diff --git a/src/content/reference/en/p5 copy/constants/P2D.mdx b/src/content/reference/en/p5 copy/constants/P2D.mdx new file mode 100644 index 0000000000..83f09b1d9c --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/P2D.mdx @@ -0,0 +1,19 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L18 +title: P2D +module: Constants +submodule: Constants +file: src/core/constants.js +description: | +

The default, two-dimensional renderer.

+line: 18 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# P2D diff --git a/src/content/reference/en/p5 copy/constants/PI.mdx b/src/content/reference/en/p5 copy/constants/PI.mdx new file mode 100644 index 0000000000..bddf509592 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/PI.mdx @@ -0,0 +1,108 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L178 +title: PI +module: Constants +submodule: Constants +file: src/core/constants.js +description: > +

A Number constant that's approximately 3.1416.

+ +

PI is the mathematical constant π. It's useful for many tasks + that + + involve rotation and oscillation. For example, calling rotate(PI) + rotates + + the coordinate system PI radians, which is a half turn + (180˚).

+ +

Note: TWO_PI radians equals 360˚, PI radians + equals 180˚, HALF_PI + + radians equals 90˚, and QUARTER_PI radians equals 45˚.

+line: 178 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw an arc from 0 to PI. + arc(50, 50, 80, 80, 0, PI); + + describe('The bottom half of a circle drawn in white on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Draw a line. + line(0, 0, 40, 0); + + // Rotate a half turn. + rotate(PI); + + // Draw the same line, rotated. + line(0, 0, 40, 0); + + describe('A horizontal black line on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A red circle and a blue circle oscillate from left to right on a gray background. The circles drift apart, then meet in the middle, over and over again.' + ); + } + + function draw() { + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Calculate the x-coordinates. + let x1 = 40 * sin(frameCount * 0.05); + let x2 = 40 * sin(frameCount * 0.05 + PI); + + // Style the oscillators. + noStroke(); + + // Draw the red oscillator. + fill(255, 0, 0); + circle(x1, 0, 20); + + // Draw the blue oscillator. + fill(0, 0, 255); + circle(x2, 0, 20); + } + +
+class: p5 +type: Number +--- + + +# PI diff --git a/src/content/reference/en/p5 copy/constants/PIE.mdx b/src/content/reference/en/p5 copy/constants/PIE.mdx new file mode 100644 index 0000000000..7be0810e6e --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/PIE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L755 +title: PIE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 755 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# PIE diff --git a/src/content/reference/en/p5 copy/constants/POINTS.mdx b/src/content/reference/en/p5 copy/constants/POINTS.mdx new file mode 100644 index 0000000000..8dea326a14 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/POINTS.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L681 +title: POINTS +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 681 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# POINTS diff --git a/src/content/reference/en/p5 copy/constants/PORTRAIT.mdx b/src/content/reference/en/p5 copy/constants/PORTRAIT.mdx new file mode 100644 index 0000000000..492546578c --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/PORTRAIT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1155 +title: PORTRAIT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1155 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# PORTRAIT diff --git a/src/content/reference/en/p5 copy/constants/POSTERIZE.mdx b/src/content/reference/en/p5 copy/constants/POSTERIZE.mdx new file mode 100644 index 0000000000..198c365591 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/POSTERIZE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1004 +title: POSTERIZE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1004 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# POSTERIZE diff --git a/src/content/reference/en/p5 copy/constants/PROJECT.mdx b/src/content/reference/en/p5 copy/constants/PROJECT.mdx new file mode 100644 index 0000000000..ce6f7dbaac --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/PROJECT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L760 +title: PROJECT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 760 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# PROJECT diff --git a/src/content/reference/en/p5 copy/constants/QUADRATIC.mdx b/src/content/reference/en/p5 copy/constants/QUADRATIC.mdx new file mode 100644 index 0000000000..49e8d2cc19 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/QUADRATIC.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1068 +title: QUADRATIC +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1068 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# QUADRATIC diff --git a/src/content/reference/en/p5 copy/constants/QUADS.mdx b/src/content/reference/en/p5 copy/constants/QUADS.mdx new file mode 100644 index 0000000000..c67a193a4f --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/QUADS.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L723 +title: QUADS +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 723 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# QUADS diff --git a/src/content/reference/en/p5 copy/constants/QUAD_STRIP.mdx b/src/content/reference/en/p5 copy/constants/QUAD_STRIP.mdx new file mode 100644 index 0000000000..c1ce9d4291 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/QUAD_STRIP.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L728 +title: QUAD_STRIP +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 728 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# QUAD\_STRIP diff --git a/src/content/reference/en/p5 copy/constants/QUARTER_PI.mdx b/src/content/reference/en/p5 copy/constants/QUARTER_PI.mdx new file mode 100644 index 0000000000..5f4cc24bc1 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/QUARTER_PI.mdx @@ -0,0 +1,109 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L267 +title: QUARTER_PI +module: Constants +submodule: Constants +file: src/core/constants.js +description: > +

A Number constant that's approximately 0.7854.

+ +

QUARTER_PI is one-fourth the value of the mathematical + constant π. It's + + useful for many tasks that involve rotation and oscillation. For example, + + calling rotate(QUARTER_PI) rotates the coordinate system + QUARTER_PI + + radians, which is an eighth of a turn (45˚).

+ +

Note: TWO_PI radians equals 360˚, PI radians + equals 180˚, HALF_PI + + radians equals 90˚, and QUARTER_PI radians equals 45˚.

+line: 267 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw an arc from 0 to QUARTER_PI. + arc(50, 50, 80, 80, 0, QUARTER_PI); + + describe('A one-eighth slice of a circle drawn in white on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Draw a line. + line(0, 0, 40, 0); + + // Rotate an eighth turn. + rotate(QUARTER_PI); + + // Draw the same line, rotated. + line(0, 0, 40, 0); + + describe('Two black lines that form a "V" opening towards the bottom-right corner of a gray square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A red circle and a blue circle oscillate from left to right on a gray background. The red circle appears to chase the blue circle.' + ); + } + + function draw() { + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Calculate the x-coordinates. + let x1 = 40 * sin(frameCount * 0.05); + let x2 = 40 * sin(frameCount * 0.05 + QUARTER_PI); + + // Style the oscillators. + noStroke(); + + // Draw the red oscillator. + fill(255, 0, 0); + circle(x1, 0, 20); + + // Draw the blue oscillator. + fill(0, 0, 255); + circle(x2, 0, 20); + } + +
+class: p5 +type: Number +--- + + +# QUARTER\_PI diff --git a/src/content/reference/en/p5 copy/constants/RADIANS.mdx b/src/content/reference/en/p5 copy/constants/RADIANS.mdx new file mode 100644 index 0000000000..856db37b9f --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/RADIANS.mdx @@ -0,0 +1,66 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L587 +title: RADIANS +module: Constants +submodule: Constants +file: src/core/constants.js +description: > +

A String constant that's used to set the + + angleMode().

+ +

By default, functions such as rotate() + and + + sin() expect angles measured in units of + radians. + + Calling angleMode(RADIANS) ensures that angles are measured in + units of + + radians. Doing so can be useful if the + + angleMode() has been set to + + DEGREES.

+ +

Note: TWO_PI radians equals 360˚.

+line: 587 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use degrees. + angleMode(DEGREES); + + // Draw a red arc from 0˚ to 90˚. + fill(255, 0, 0); + arc(50, 50, 80, 80, 0, 90); + + // Use radians. + angleMode(RADIANS); + + // Draw a blue arc from HALF_PI to PI. + fill(0, 0, 255); + arc(50, 50, 80, 80, HALF_PI, PI); + + describe('The bottom half of a circle drawn on a gray background. The bottom-right quarter is red. The bottom-left quarter is blue.'); + } + +
+class: p5 +type: String +--- + + +# RADIANS diff --git a/src/content/reference/en/p5 copy/constants/RADIUS.mdx b/src/content/reference/en/p5 copy/constants/RADIUS.mdx new file mode 100644 index 0000000000..95f1dcdeef --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/RADIUS.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L645 +title: RADIUS +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 645 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# RADIUS diff --git a/src/content/reference/en/p5 copy/constants/REMOVE.mdx b/src/content/reference/en/p5 copy/constants/REMOVE.mdx new file mode 100644 index 0000000000..c2daffc564 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/REMOVE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L899 +title: REMOVE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 899 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# REMOVE diff --git a/src/content/reference/en/p5 copy/constants/REPEAT.mdx b/src/content/reference/en/p5 copy/constants/REPEAT.mdx new file mode 100644 index 0000000000..c9e75c8bec --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/REPEAT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1121 +title: REPEAT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1121 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# REPEAT diff --git a/src/content/reference/en/p5 copy/constants/REPLACE.mdx b/src/content/reference/en/p5 copy/constants/REPLACE.mdx new file mode 100644 index 0000000000..8a04f06130 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/REPLACE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L949 +title: REPLACE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 949 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# REPLACE diff --git a/src/content/reference/en/p5 copy/constants/RETURN.mdx b/src/content/reference/en/p5 copy/constants/RETURN.mdx new file mode 100644 index 0000000000..3069efc256 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/RETURN.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L866 +title: RETURN +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 866 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# RETURN diff --git a/src/content/reference/en/p5 copy/constants/RGB.mdx b/src/content/reference/en/p5 copy/constants/RGB.mdx new file mode 100644 index 0000000000..b0ae826064 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/RGB.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L789 +title: RGB +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 789 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# RGB diff --git a/src/content/reference/en/p5 copy/constants/RGBA.mdx b/src/content/reference/en/p5 copy/constants/RGBA.mdx new file mode 100644 index 0000000000..256949cfd1 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/RGBA.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1224 +title: RGBA +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1224 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# RGBA diff --git a/src/content/reference/en/p5 copy/constants/RIGHT.mdx b/src/content/reference/en/p5 copy/constants/RIGHT.mdx new file mode 100644 index 0000000000..e9f69e8a80 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/RIGHT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L650 +title: RIGHT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 650 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# RIGHT diff --git a/src/content/reference/en/p5 copy/constants/RIGHT_ARROW.mdx b/src/content/reference/en/p5 copy/constants/RIGHT_ARROW.mdx new file mode 100644 index 0000000000..731ab29fb5 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/RIGHT_ARROW.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L871 +title: RIGHT_ARROW +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 871 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# RIGHT\_ARROW diff --git a/src/content/reference/en/p5 copy/constants/ROUND.mdx b/src/content/reference/en/p5 copy/constants/ROUND.mdx new file mode 100644 index 0000000000..50426d2636 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/ROUND.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L772 +title: ROUND +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 772 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# ROUND diff --git a/src/content/reference/en/p5 copy/constants/SCREEN.mdx b/src/content/reference/en/p5 copy/constants/SCREEN.mdx new file mode 100644 index 0000000000..65f2e6192d --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/SCREEN.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L944 +title: SCREEN +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 944 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# SCREEN diff --git a/src/content/reference/en/p5 copy/constants/SHIFT.mdx b/src/content/reference/en/p5 copy/constants/SHIFT.mdx new file mode 100644 index 0000000000..e48b091ab3 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/SHIFT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L876 +title: SHIFT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 876 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# SHIFT diff --git a/src/content/reference/en/p5 copy/constants/SMOOTH.mdx b/src/content/reference/en/p5 copy/constants/SMOOTH.mdx new file mode 100644 index 0000000000..816be1029b --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/SMOOTH.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1143 +title: SMOOTH +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1143 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# SMOOTH diff --git a/src/content/reference/en/p5 copy/constants/SOFT_LIGHT.mdx b/src/content/reference/en/p5 copy/constants/SOFT_LIGHT.mdx new file mode 100644 index 0000000000..846e6fe72b --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/SOFT_LIGHT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L965 +title: SOFT_LIGHT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 965 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# SOFT\_LIGHT diff --git a/src/content/reference/en/p5 copy/constants/SQUARE.mdx b/src/content/reference/en/p5 copy/constants/SQUARE.mdx new file mode 100644 index 0000000000..7b5da139d7 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/SQUARE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L766 +title: SQUARE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 766 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# SQUARE diff --git a/src/content/reference/en/p5 copy/constants/STROKE.mdx b/src/content/reference/en/p5 copy/constants/STROKE.mdx new file mode 100644 index 0000000000..16cfa32e5e --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/STROKE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1085 +title: STROKE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1085 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# STROKE diff --git a/src/content/reference/en/p5 copy/constants/SUBTRACT.mdx b/src/content/reference/en/p5 copy/constants/SUBTRACT.mdx new file mode 100644 index 0000000000..2bd6d94fe9 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/SUBTRACT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L929 +title: SUBTRACT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 929 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# SUBTRACT diff --git a/src/content/reference/en/p5 copy/constants/TAB.mdx b/src/content/reference/en/p5 copy/constants/TAB.mdx new file mode 100644 index 0000000000..cf89117ae4 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/TAB.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L881 +title: TAB +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 881 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# TAB diff --git a/src/content/reference/en/p5 copy/constants/TAU.mdx b/src/content/reference/en/p5 copy/constants/TAU.mdx new file mode 100644 index 0000000000..a553339913 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/TAU.mdx @@ -0,0 +1,114 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L357 +title: TAU +module: Constants +submodule: Constants +file: src/core/constants.js +description: > +

A Number constant that's approximately 6.2382.

+ +

TAU is twice the value of the mathematical constant π. It's + useful for + + many tasks that involve rotation and oscillation. For example, calling + + rotate(TAU) rotates the coordinate system TAU + radians, which is one + + full turn (360˚). TAU and TWO_PI are equal.

+ +

Note: TAU radians equals 360˚, PI radians equals + 180˚, HALF_PI + + radians equals 90˚, and QUARTER_PI radians equals 45˚.

+line: 357 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw an arc from 0 to TAU. + arc(50, 50, 80, 80, 0, TAU); + + describe('A white circle drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Draw a line. + line(0, 0, 40, 0); + + // Rotate a full turn. + rotate(TAU); + + // Style the second line. + strokeWeight(5); + + // Draw the same line, shorter and rotated. + line(0, 0, 20, 0); + + describe( + 'Two horizontal black lines on a gray background. A thick line extends from the center toward the right. A thin line extends from the end of the thick line.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A red circle with a blue center oscillates from left to right on a gray background.' + ); + } + + function draw() { + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Calculate the x-coordinates. + let x1 = 40 * sin(frameCount * 0.05); + let x2 = 40 * sin(frameCount * 0.05 + TAU); + + // Style the oscillators. + noStroke(); + + // Draw the red oscillator. + fill(255, 0, 0); + circle(x1, 0, 20); + + // Draw the blue oscillator, smaller. + fill(0, 0, 255); + circle(x2, 0, 10); + } + +
+class: p5 +type: Number +--- + + +# TAU diff --git a/src/content/reference/en/p5 copy/constants/TESS.mdx b/src/content/reference/en/p5 copy/constants/TESS.mdx new file mode 100644 index 0000000000..e6f853e8ab --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/TESS.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L734 +title: TESS +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 734 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# TESS diff --git a/src/content/reference/en/p5 copy/constants/TEXT.mdx b/src/content/reference/en/p5 copy/constants/TEXT.mdx new file mode 100644 index 0000000000..157a90001a --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/TEXT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L75 +title: TEXT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 75 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# TEXT diff --git a/src/content/reference/en/p5 copy/constants/TEXTURE.mdx b/src/content/reference/en/p5 copy/constants/TEXTURE.mdx new file mode 100644 index 0000000000..8ada92f376 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/TEXTURE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1095 +title: TEXTURE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1095 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# TEXTURE diff --git a/src/content/reference/en/p5 copy/constants/THRESHOLD.mdx b/src/content/reference/en/p5 copy/constants/THRESHOLD.mdx new file mode 100644 index 0000000000..f12e6ea336 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/THRESHOLD.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L984 +title: THRESHOLD +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 984 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# THRESHOLD diff --git a/src/content/reference/en/p5 copy/constants/TOP.mdx b/src/content/reference/en/p5 copy/constants/TOP.mdx new file mode 100644 index 0000000000..a91b5f4824 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/TOP.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L665 +title: TOP +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 665 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# TOP diff --git a/src/content/reference/en/p5 copy/constants/TRIANGLES.mdx b/src/content/reference/en/p5 copy/constants/TRIANGLES.mdx new file mode 100644 index 0000000000..ec281d033e --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/TRIANGLES.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L705 +title: TRIANGLES +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 705 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# TRIANGLES diff --git a/src/content/reference/en/p5 copy/constants/TRIANGLE_FAN.mdx b/src/content/reference/en/p5 copy/constants/TRIANGLE_FAN.mdx new file mode 100644 index 0000000000..bcd5d5f5a1 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/TRIANGLE_FAN.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L711 +title: TRIANGLE_FAN +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 711 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# TRIANGLE\_FAN diff --git a/src/content/reference/en/p5 copy/constants/TRIANGLE_STRIP.mdx b/src/content/reference/en/p5 copy/constants/TRIANGLE_STRIP.mdx new file mode 100644 index 0000000000..fefe226e17 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/TRIANGLE_STRIP.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L717 +title: TRIANGLE_STRIP +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 717 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# TRIANGLE\_STRIP diff --git a/src/content/reference/en/p5 copy/constants/TWO_PI.mdx b/src/content/reference/en/p5 copy/constants/TWO_PI.mdx new file mode 100644 index 0000000000..ed62a10b0f --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/TWO_PI.mdx @@ -0,0 +1,114 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L452 +title: TWO_PI +module: Constants +submodule: Constants +file: src/core/constants.js +description: > +

A Number constant that's approximately 6.2382.

+ +

TWO_PI is twice the value of the mathematical constant π. It's + useful for + + many tasks that involve rotation and oscillation. For example, calling + + rotate(TWO_PI) rotates the coordinate system TWO_PI + radians, which is + + one full turn (360˚). TWO_PI and TAU are equal.

+ +

Note: TWO_PI radians equals 360˚, PI radians + equals 180˚, HALF_PI + + radians equals 90˚, and QUARTER_PI radians equals 45˚.

+line: 452 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw an arc from 0 to TWO_PI. + arc(50, 50, 80, 80, 0, TWO_PI); + + describe('A white circle drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Draw a line. + line(0, 0, 40, 0); + + // Rotate a full turn. + rotate(TWO_PI); + + // Style the second line. + strokeWeight(5); + + // Draw the same line, shorter and rotated. + line(0, 0, 20, 0); + + describe( + 'Two horizontal black lines on a gray background. A thick line extends from the center toward the right. A thin line extends from the end of the thick line.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A red circle with a blue center oscillates from left to right on a gray background.' + ); + } + + function draw() { + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Calculate the x-coordinates. + let x1 = 40 * sin(frameCount * 0.05); + let x2 = 40 * sin(frameCount * 0.05 + TWO_PI); + + // Style the oscillators. + noStroke(); + + // Draw the red oscillator. + fill(255, 0, 0); + circle(x1, 0, 20); + + // Draw the blue oscillator, smaller. + fill(0, 0, 255); + circle(x2, 0, 10); + } + +
+class: p5 +type: Number +--- + + +# TWO\_PI diff --git a/src/content/reference/en/p5 copy/constants/UNSIGNED_BYTE.mdx b/src/content/reference/en/p5 copy/constants/UNSIGNED_BYTE.mdx new file mode 100644 index 0000000000..00acfe29c0 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/UNSIGNED_BYTE.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1200 +title: UNSIGNED_BYTE +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1200 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# UNSIGNED\_BYTE diff --git a/src/content/reference/en/p5 copy/constants/UNSIGNED_INT.mdx b/src/content/reference/en/p5 copy/constants/UNSIGNED_INT.mdx new file mode 100644 index 0000000000..f060682a13 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/UNSIGNED_INT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1206 +title: UNSIGNED_INT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1206 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# UNSIGNED\_INT diff --git a/src/content/reference/en/p5 copy/constants/UP_ARROW.mdx b/src/content/reference/en/p5 copy/constants/UP_ARROW.mdx new file mode 100644 index 0000000000..e0e0326aa6 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/UP_ARROW.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L886 +title: UP_ARROW +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 886 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# UP\_ARROW diff --git a/src/content/reference/en/p5 copy/constants/VERSION.mdx b/src/content/reference/en/p5 copy/constants/VERSION.mdx new file mode 100644 index 0000000000..f9f62fca55 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/VERSION.mdx @@ -0,0 +1,19 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L9 +title: VERSION +module: Constants +submodule: Constants +file: src/core/constants.js +description: | +

Version of this p5.js.

+line: 9 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# VERSION diff --git a/src/content/reference/en/p5 copy/constants/WAIT.mdx b/src/content/reference/en/p5 copy/constants/WAIT.mdx new file mode 100644 index 0000000000..833f77ee4f --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/WAIT.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L80 +title: WAIT +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 80 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# WAIT diff --git a/src/content/reference/en/p5 copy/constants/WEBGL.mdx b/src/content/reference/en/p5 copy/constants/WEBGL.mdx new file mode 100644 index 0000000000..2919ec489c --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/WEBGL.mdx @@ -0,0 +1,91 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L24 +title: WEBGL +module: Constants +submodule: Constants +file: src/core/constants.js +description: > +

One of the two render modes in p5.js, used for computationally intensive + tasks like 3D rendering and shaders.

+ +

WEBGL differs from the default P2D renderer in the following + ways:

+ + + +

To learn more about WEBGL mode, check out all the interactive WEBGL + tutorials in the "Tutorials" section of this website, or read the wiki + article "Getting + started with WebGL in p5".

+line: 24 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# WEBGL diff --git a/src/content/reference/en/p5 copy/constants/WEBGL2.mdx b/src/content/reference/en/p5 copy/constants/WEBGL2.mdx new file mode 100644 index 0000000000..68c6ca83fa --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/WEBGL2.mdx @@ -0,0 +1,21 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L45 +title: WEBGL2 +module: Constants +submodule: Constants +file: src/core/constants.js +description: | +

One of the two possible values of a WebGL canvas (either WEBGL or WEBGL2), + which can be used to determine what capabilities the rendering environment + has.

+line: 45 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# WEBGL2 diff --git a/src/content/reference/en/p5 copy/constants/WORD.mdx b/src/content/reference/en/p5 copy/constants/WORD.mdx new file mode 100644 index 0000000000..03f13b4874 --- /dev/null +++ b/src/content/reference/en/p5 copy/constants/WORD.mdx @@ -0,0 +1,18 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1051 +title: WORD +module: Constants +submodule: Constants +file: src/core/constants.js +description: '' +line: 1051 +isConstructor: false +itemtype: property +class: p5 +type: String +--- + + +# WORD diff --git a/src/content/reference/en/p5 copy/constrain.mdx b/src/content/reference/en/p5 copy/constrain.mdx new file mode 100644 index 0000000000..d869ce2e74 --- /dev/null +++ b/src/content/reference/en/p5 copy/constrain.mdx @@ -0,0 +1,86 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L91 +title: constrain +module: Math +submodule: Calculation +file: src/math/calculation.js +description: | +

Constrains a number between a minimum and maximum value.

+line: 91 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A black dot drawn on a gray square follows the mouse from left to right. Its movement is constrained to the middle third of the square.'); + } + + function draw() { + background(200); + + let x = constrain(mouseX, 33, 67); + let y = 50; + + strokeWeight(5); + point(x, y); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('Two vertical lines. Two circles move horizontally with the mouse. One circle stops at the vertical lines.'); + } + + function draw() { + background(200); + + // Set boundaries and draw them. + let leftWall = 25; + let rightWall = 75; + line(leftWall, 0, leftWall, 100); + line(rightWall, 0, rightWall, 100); + + // Draw a circle that follows the mouse freely. + fill(255); + circle(mouseX, 33, 9); + + // Draw a circle that's constrained. + let xc = constrain(mouseX, leftWall, rightWall); + fill(0); + circle(xc, 67, 9); + } + +
+class: p5 +params: + - name: 'n' + description: | +

number to constrain.

+ type: Number + - name: low + description: | +

minimum limit.

+ type: Number + - name: high + description: | +

maximum limit.

+ type: Number +return: + description: constrained number. + type: Number +chainable: false +--- + + +# constrain diff --git a/src/content/reference/en/p5 copy/copy.mdx b/src/content/reference/en/p5 copy/copy.mdx new file mode 100644 index 0000000000..059df56434 --- /dev/null +++ b/src/content/reference/en/p5 copy/copy.mdx @@ -0,0 +1,144 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L288 +title: copy +module: Image +submodule: Pixels +file: src/image/pixels.js +description: > +

Copies pixels from a source image to a region of the canvas.

+ +

The first parameter, srcImage, is the + + p5.Image object to blend. The source + image can be + + the canvas itself or a + + p5.Image object. copy() will + scale pixels from + + the source region if it isn't the same size as the destination region.

+ +

The next four parameters, sx, sy, + sw, and sh determine the region + + to copy from the source image. (sx, sy) is the top-left corner of + the + + region. sw and sh are the region's width and + height.

+ +

The next four parameters, dx, dy, + dw, and dh determine the region + + of the canvas to copy into. (dx, dy) is the top-left corner of + the + + region. dw and dh are the region's width and + height.

+line: 288 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/rockies.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Use the mountains as the background. + background(img); + + // Copy a region of pixels to another spot. + copy(img, 7, 22, 10, 10, 35, 25, 50, 50); + + // Outline the copied region. + stroke(255); + noFill(); + square(7, 22, 10); + + describe('An image of a mountain landscape. A square region is outlined in white. A larger square contains a pixelated view of the outlined region.'); + } + +
+class: p5 +overloads: + - line: 288 + params: + - name: srcImage + description: | +

source image.

+ type: p5.Image|p5.Element + - name: sx + description: | +

x-coordinate of the source's upper-left corner.

+ type: Integer + - name: sy + description: | +

y-coordinate of the source's upper-left corner.

+ type: Integer + - name: sw + description: | +

source image width.

+ type: Integer + - name: sh + description: | +

source image height.

+ type: Integer + - name: dx + description: | +

x-coordinate of the destination's upper-left corner.

+ type: Integer + - name: dy + description: | +

y-coordinate of the destination's upper-left corner.

+ type: Integer + - name: dw + description: | +

destination image width.

+ type: Integer + - name: dh + description: | +

destination image height.

+ type: Integer + - line: 345 + params: + - name: sx + description: '' + type: Integer + - name: sy + description: '' + type: Integer + - name: sw + description: '' + type: Integer + - name: sh + description: '' + type: Integer + - name: dx + description: '' + type: Integer + - name: dy + description: '' + type: Integer + - name: dw + description: '' + type: Integer + - name: dh + description: '' + type: Integer +chainable: false +--- + + +# copy diff --git a/src/content/reference/en/p5 copy/cos.mdx b/src/content/reference/en/p5 copy/cos.mdx new file mode 100644 index 0000000000..cd6468fc4f --- /dev/null +++ b/src/content/reference/en/p5 copy/cos.mdx @@ -0,0 +1,107 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L281 +title: cos +module: Math +submodule: Trigonometry +file: src/math/trigonometry.js +description: > +

Calculates the cosine of an angle.

+ +

cos() is useful for many geometric tasks in creative coding. + The values + + returned oscillate between -1 and 1 as the input angle increases. + cos() + + calculates the cosine of an angle, using radians by default, or according to + + if angleMode() setting (RADIANS or + DEGREES).

+line: 281 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A white ball on a string oscillates left and right.'); + } + + function draw() { + background(200); + + // Calculate the coordinates. + let x = 30 * cos(frameCount * 0.05) + 50; + let y = 50; + + // Draw the oscillator. + line(50, y, x, y); + circle(x, y, 20); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + describe('A series of black dots form a wave pattern.'); + } + + function draw() { + // Calculate the coordinates. + let x = frameCount; + let y = 30 * cos(x * 0.1) + 50; + + // Draw the point. + point(x, y); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + describe('A series of black dots form an infinity symbol.'); + } + + function draw() { + // Calculate the coordinates. + let x = 30 * cos(frameCount * 0.1) + 50; + let y = 10 * sin(frameCount * 0.2) + 50; + + // Draw the point. + point(x, y); + } + +
+class: p5 +params: + - name: angle + description: > +

the angle, in radians by default, or according to + + if angleMode() setting (RADIANS or + DEGREES).

+ type: Number +return: + description: cosine of the angle. + type: Number +chainable: false +--- + + +# cos diff --git a/src/content/reference/en/p5 copy/createA.mdx b/src/content/reference/en/p5 copy/createA.mdx new file mode 100644 index 0000000000..669ce45a27 --- /dev/null +++ b/src/content/reference/en/p5 copy/createA.mdx @@ -0,0 +1,93 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L724 +title: createA +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates an element that links to another web page.

+ +

The first parmeter, href, is a string that sets the URL of the + linked + + page.

+ +

The second parameter, html, is a string that sets the inner + HTML of the + + link. It's common to use text, images, or buttons as links.

+ +

The third parameter, target, is optional. It's a string that + tells the + + web browser where to open the link. By default, links open in the current + + browser tab. Passing '_blank' will cause the link to open in a + new + + browser tab. MDN describes a few + + other options.

+line: 724 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an anchor element that links to p5js.org. + let a = createA('https://p5js.org/', 'p5*js'); + a.position(25, 35); + + describe('The text "p5*js" written at the center of a gray square.'); + } + +
+ +
+ + function setup() { + background(200); + + // Create an anchor tag that links to p5js.org. + // Open the link in a new tab. + let a = createA('https://p5js.org/', 'p5*js', '_blank'); + a.position(25, 35); + + describe('The text "p5*js" written at the center of a gray square.'); + } + +
+class: p5 +params: + - name: href + description: | +

URL of linked page.

+ type: String + - name: html + description: | +

inner HTML of link element to display.

+ type: String + - name: target + description: | +

target where the new link should open, + either '_blank', '_self', '_parent', or '_top'.

+ type: String + optional: true +return: + description: new p5.Element object. + type: p5.Element +chainable: false +--- + + +# createA diff --git a/src/content/reference/en/p5 copy/createAudio.mdx b/src/content/reference/en/p5 copy/createAudio.mdx new file mode 100644 index 0000000000..24b3bce36b --- /dev/null +++ b/src/content/reference/en/p5 copy/createAudio.mdx @@ -0,0 +1,83 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L2213 +title: createAudio +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a hidden element for simple audio + playback.

+ +

createAudio() returns a new + + p5.MediaElement object.

+ +

The first parameter, src, is the path the video. If a single + string is + + passed, as in '/assets/video.mp4', a single video is loaded. An + array + + of strings can be used to load the same video in different formats. For + + example, ['/assets/video.mp4', '/assets/video.ogv', + '/assets/video.webm']. + + This is useful for ensuring that the video can play across different + + browsers with different capabilities. See + + MDN + + for more information about supported formats.

+ +

The second parameter, callback, is optional. It's a function + to call once + + the audio is ready to play.

+line: 2213 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + noCanvas(); + + // Load the audio. + let beat = createAudio('/assets/beat.mp3'); + + // Show the default audio controls. + beat.showControls(); + + describe('An audio beat plays when the user double-clicks the square.'); + } + +
+class: p5 +params: + - name: src + description: | +

path to an audio file, or an array of paths + for supporting different browsers.

+ type: 'String|String[]' + optional: true + - name: callback + description: | +

function to call once the audio is ready to play.

+ type: Function + optional: true +return: + description: new p5.MediaElement object. + type: p5.MediaElement +chainable: false +--- + + +# createAudio diff --git a/src/content/reference/en/p5 copy/createButton.mdx b/src/content/reference/en/p5 copy/createButton.mdx new file mode 100644 index 0000000000..9ff2d66faf --- /dev/null +++ b/src/content/reference/en/p5 copy/createButton.mdx @@ -0,0 +1,109 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L924 +title: createButton +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a element.

+ +

The first parameter, label, is a string that sets the label + displayed on + + the button.

+ +

The second parameter, value, is optional. It's a string that + sets the + + button's value. See + + MDN + + for more details.

+line: 924 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a button and place it beneath the canvas. + let button = createButton('click me'); + button.position(0, 100); + + // Call repaint() when the button is pressed. + button.mousePressed(repaint); + + describe('A gray square with a button that says "click me" beneath it. The square changes color when the button is clicked.'); + } + + // Change the background color. + function repaint() { + let g = random(255); + background(g); + } + +
+ +
+ + let button; + + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a button and set its value to 0. + // Place the button beneath the canvas. + button = createButton('click me', 'red'); + button.position(0, 100); + + // Call randomColor() when the button is pressed. + button.mousePressed(randomColor); + + describe('A red square with a button that says "click me" beneath it. The square changes color when the button is clicked.'); + } + + function draw() { + // Use the button's value to set the background color. + let c = button.value(); + background(c); + } + + // Set the button's value to a random color. + function randomColor() { + let c = random(['red', 'green', 'blue', 'yellow']); + button.value(c); + } + +
+class: p5 +params: + - name: label + description: | +

label displayed on the button.

+ type: String + - name: value + description: | +

value of the button.

+ type: String + optional: true +return: + description: new p5.Element object. + type: p5.Element +chainable: false +--- + + +# createButton diff --git a/src/content/reference/en/p5 copy/createCamera.mdx b/src/content/reference/en/p5 copy/createCamera.mdx new file mode 100644 index 0000000000..8fbb13ce5d --- /dev/null +++ b/src/content/reference/en/p5 copy/createCamera.mdx @@ -0,0 +1,99 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L638 +title: createCamera +module: 3D +submodule: Camera +file: src/webgl/p5.Camera.js +description: > +

Creates a new p5.Camera object and + sets it + + as the current (active) camera.

+ +

The new camera is initialized with a default position (0, 0, + 800) and a + + default perspective projection. Its properties can be controlled with + + p5.Camera methods such as + + myCamera.lookAt(0, 0, 0).

+ +

Note: Every 3D sketch starts with a default camera initialized. + + This camera can be controlled with the functions + + camera(), + + perspective(), + + ortho(), and + + frustum() if it's the only camera in the + scene.

+ +

Note: createCamera() can only be used in WebGL mode.

+line: 638 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Double-click to toggle between cameras. + + let cam1; + let cam2; + let usingCam1 = true; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the first camera. + // Keep its default settings. + cam1 = createCamera(); + + // Create the second camera. + // Place it at the top-left. + // Point it at the origin. + cam2 = createCamera(); + cam2.setPosition(400, -400, 800); + cam2.lookAt(0, 0, 0); + + // Set the current camera to cam1. + setCamera(cam1); + + describe('A white cube on a gray background. The camera toggles between frontal and aerial views when the user double-clicks.'); + } + + function draw() { + background(200); + + // Draw the box. + box(); + } + + // Toggle the current camera when the user double-clicks. + function doubleClicked() { + if (usingCam1 === true) { + setCamera(cam2); + usingCam1 = false; + } else { + setCamera(cam1); + usingCam1 = true; + } + } + +
+class: p5 +return: + description: the new camera. + type: p5.Camera +chainable: false +--- + + +# createCamera diff --git a/src/content/reference/en/p5 copy/createCanvas.mdx b/src/content/reference/en/p5 copy/createCanvas.mdx new file mode 100644 index 0000000000..600d7e3545 --- /dev/null +++ b/src/content/reference/en/p5 copy/createCanvas.mdx @@ -0,0 +1,191 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L15 +title: createCanvas +module: Rendering +submodule: Rendering +file: src/core/rendering.js +description: > +

Creates a canvas element on the web page.

+ +

createCanvas() creates the main drawing canvas for a sketch. + It should + + only be called once at the beginning of setup(). + + Calling createCanvas() more than once causes unpredictable + behavior.

+ +

The first two parameters, width and height, are + optional. They set the + + dimensions of the canvas and the values of the + + width and height system + + variables. For example, calling createCanvas(900, 500) creates a + canvas + + that's 900×500 pixels. By default, width and height + are both 100.

+ +

The third parameter is also optional. If either of the constants + P2D or + + WEBGL is passed, as in createCanvas(900, 500, + WEBGL), then it will set + + the sketch's rendering mode. If an existing + + HTMLCanvasElement + + is passed, as in createCanvas(900, 500, myCanvas), then it will + be used + + by the sketch.

+ +

The fourth parameter is also optional. If an existing + + HTMLCanvasElement + + is passed, as in createCanvas(900, 500, WEBGL, myCanvas), then it + will be + + used by the sketch.

+ +

Note: In WebGL mode, the canvas will use a WebGL2 context if it's supported + + by the browser. Check the webglVersion + + system variable to check what version is being used, or call + + setAttributes({ version: 1 }) to create a WebGL1 context.

+line: 15 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Draw a diagonal line. + line(0, 0, width, height); + + describe('A diagonal line drawn from top-left to bottom-right on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 50); + + background(180); + + // Draw a diagonal line. + line(0, 0, width, height); + + describe('A diagonal line drawn from top-left to bottom-right on a gray background.'); + } + +
+ +
+ + // Use WebGL mode. + + function setup() { + createCanvas(100, 100, WEBGL); + + background(180); + + // Draw a diagonal line. + line(-width / 2, -height / 2, width / 2, height / 2); + + describe('A diagonal line drawn from top-left to bottom-right on a gray background.'); + } + +
+ +
+ + function setup() { + // Create a p5.Renderer object. + let cnv = createCanvas(50, 50); + + // Position the canvas. + cnv.position(10, 20); + + background(180); + + // Draw a diagonal line. + line(0, 0, width, height); + + describe('A diagonal line drawn from top-left to bottom-right on a gray background.'); + } + +
+class: p5 +return: + description: new `p5.Renderer` that holds the canvas. + type: p5.Renderer +overloads: + - line: 15 + params: + - name: width + description: | +

width of the canvas. Defaults to 100.

+ type: Number + optional: true + - name: height + description: | +

height of the canvas. Defaults to 100.

+ type: Number + optional: true + - name: renderer + description: | +

either P2D or WEBGL. Defaults to P2D.

+ type: Constant + optional: true + - name: canvas + description: | +

existing canvas element that should be used for the sketch.

+ type: HTMLCanvasElement + optional: true + return: + description: new `p5.Renderer` that holds the canvas. + type: p5.Renderer + - line: 119 + params: + - name: width + description: '' + type: Number + optional: true + - name: height + description: '' + type: Number + optional: true + - name: canvas + description: '' + type: HTMLCanvasElement + optional: true + return: + description: '' + type: p5.Renderer +chainable: false +--- + + +# createCanvas diff --git a/src/content/reference/en/p5 copy/createCapture.mdx b/src/content/reference/en/p5 copy/createCapture.mdx new file mode 100644 index 0000000000..1087d14b1a --- /dev/null +++ b/src/content/reference/en/p5 copy/createCapture.mdx @@ -0,0 +1,189 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L2295 +title: createCapture +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a element that "captures" the audio/video + stream from + + the webcam and microphone.

+ +

createCapture() returns a new + + p5.MediaElement object. Videos are + shown by + + default. They can be hidden by calling capture.hide() and drawn + to the + + canvas using image().

+ +

The first parameter, type, is optional. It sets the type of + capture to + + use. By default, createCapture() captures both audio and video. + If VIDEO + + is passed, as in createCapture(VIDEO), only video will be + captured. + + If AUDIO is passed, as in createCapture(AUDIO), only + audio will be + + captured. A constraints object can also be passed to customize the stream. + + See the + + W3C documentation for possible properties. Different browsers support + different + + properties.

+ +

The 'flipped' property is an optional property which can be set to + {flipped:true} + + to mirror the video output.If it is true then it means that video will be + mirrored + + or flipped and if nothing is mentioned then by default it will be + false.

+ +

The second parameter,callback, is optional. It's a function to + call once + + the capture is ready for use. The callback function should have one + + parameter, stream, that's a + + MediaStream object.

+ +

Note: createCapture() only works when running a sketch locally + or using HTTPS. Learn more + + here + + and here.

+line: 2295 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + noCanvas(); + + // Create the video capture. + createCapture(VIDEO); + + describe('A video stream from the webcam.'); + } + +
+ +
+ + let capture; + + function setup() { + createCanvas(100, 100); + + // Create the video capture and hide the element. + capture = createCapture(VIDEO); + capture.hide(); + + describe('A video stream from the webcam with inverted colors.'); + } + + function draw() { + // Draw the video capture within the canvas. + image(capture, 0, 0, width, width * capture.height / capture.width); + + // Invert the colors in the stream. + filter(INVERT); + } + +
+
+ + let capture; + + function setup() { + createCanvas(100, 100); + + // Create the video capture with mirrored output. + capture = createCapture(VIDEO,{ flipped:true }); + capture.size(100,100); + + describe('A video stream from the webcam with flipped or mirrored output.'); + } + + +
+ +
+ + function setup() { + createCanvas(480, 120); + + // Create a constraints object. + let constraints = { + video: { + mandatory: { + minWidth: 1280, + minHeight: 720 + }, + optional: [{ maxFrameRate: 10 }] + }, + audio: false + }; + + // Create the video capture. + createCapture(constraints); + + describe('A video stream from the webcam.'); + } + +
+class: p5 +params: + - name: type + description: | +

type of capture, either AUDIO or VIDEO, + or a constraints object. Both video and audio + audio streams are captured by default.

+ type: String|Constant|Object + optional: true + - name: flipped + description: > +

flip the capturing video and mirror the output with + {flipped:true}. By + default it is false.

+ type: Object + optional: true + - name: callback + description: | +

function to call once the stream + has loaded.

+ type: Function + optional: true +return: + description: new p5.MediaElement object. + type: p5.MediaElement +chainable: false +--- + + +# createCapture diff --git a/src/content/reference/en/p5 copy/createCheckbox.mdx b/src/content/reference/en/p5 copy/createCheckbox.mdx new file mode 100644 index 0000000000..45335be2d4 --- /dev/null +++ b/src/content/reference/en/p5 copy/createCheckbox.mdx @@ -0,0 +1,131 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1008 +title: createCheckbox +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a checkbox element.

+ +

Checkboxes extend the p5.Element + class with a + + checked() method. Calling myBox.checked() returns + true if it the box + + is checked and false if not.

+ +

The first parameter, label, is optional. It's a string that + sets the label + + to display next to the checkbox.

+ +

The second parameter, value, is also optional. It's a boolean + that sets the + + checkbox's value.

+line: 1008 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let checkbox; + + function setup() { + createCanvas(100, 100); + + // Create a checkbox and place it beneath the canvas. + checkbox = createCheckbox(); + checkbox.position(0, 100); + + describe('A black square with a checkbox beneath it. The square turns white when the box is checked.'); + } + + function draw() { + // Use the checkbox to set the background color. + if (checkbox.checked()) { + background(255); + } else { + background(0); + } + } + +
+ +
+ + let checkbox; + + function setup() { + createCanvas(100, 100); + + // Create a checkbox and place it beneath the canvas. + // Label the checkbox "white". + checkbox = createCheckbox(' white'); + checkbox.position(0, 100); + + describe('A black square with a checkbox labeled "white" beneath it. The square turns white when the box is checked.'); + } + + function draw() { + // Use the checkbox to set the background color. + if (checkbox.checked()) { + background(255); + } else { + background(0); + } + } + +
+ +
+ + let checkbox; + + function setup() { + createCanvas(100, 100); + + // Create a checkbox and place it beneath the canvas. + // Label the checkbox "white" and set its value to true. + checkbox = createCheckbox(' white', true); + checkbox.position(0, 100); + + describe('A white square with a checkbox labeled "white" beneath it. The square turns black when the box is unchecked.'); + } + + function draw() { + // Use the checkbox to set the background color. + if (checkbox.checked()) { + background(255); + } else { + background(0); + } + } + +
+class: p5 +params: + - name: label + description: | +

label displayed after the checkbox.

+ type: String + optional: true + - name: value + description: > +

value of the checkbox. Checked is true and unchecked is + false.

+ type: Boolean + optional: true +return: + description: new p5.Element object. + type: p5.Element +chainable: false +--- + + +# createCheckbox diff --git a/src/content/reference/en/p5 copy/createColorPicker.mdx b/src/content/reference/en/p5 copy/createColorPicker.mdx new file mode 100644 index 0000000000..0c34a0593e --- /dev/null +++ b/src/content/reference/en/p5 copy/createColorPicker.mdx @@ -0,0 +1,101 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1759 +title: createColorPicker +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a color picker element.

+ +

The parameter, value, is optional. If a color string or + + p5.Color object is passed, it will set + the default + + color.

+ +

Color pickers extend the p5.Element + class with a + + couple of helpful methods for managing colors:

+ +
    + +
  • myPicker.value() returns the current color as a hex string in + the format '#rrggbb'.
  • + +
  • myPicker.color() returns the current color as a p5.Color object.
  • + +
+line: 1759 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let myPicker; + + function setup() { + createCanvas(100, 100); + + // Create a color picker and set its position. + myPicker = createColorPicker('deeppink'); + myPicker.position(0, 100); + + describe('A pink square with a color picker beneath it. The square changes color when the user picks a new color.'); + } + + function draw() { + // Use the color picker to paint the background. + let c = myPicker.color(); + background(c); + } + +
+ +
+ + let myPicker; + + function setup() { + createCanvas(100, 100); + + // Create a color picker and set its position. + myPicker = createColorPicker('deeppink'); + myPicker.position(0, 100); + + describe('A number with the format "#rrggbb" is displayed on a pink canvas. The background color and number change when the user picks a new color.'); + } + + function draw() { + // Use the color picker to paint the background. + let c = myPicker.value(); + background(c); + + // Display the current color as a hex string. + text(c, 25, 55); + } + +
+class: p5 +params: + - name: value + description: > +

default color as a CSS color string.

+ type: String|p5.Color + optional: true +return: + description: new p5.Element object. + type: p5.Element +chainable: false +--- + + +# createColorPicker diff --git a/src/content/reference/en/p5 copy/createConvolver.mdx b/src/content/reference/en/p5 copy/createConvolver.mdx new file mode 100644 index 0000000000..89fba3be4e --- /dev/null +++ b/src/content/reference/en/p5 copy/createConvolver.mdx @@ -0,0 +1,78 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L8885 +title: createConvolver +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: | +

Create a p5.Convolver. Accepts a path to a soundfile + that will be used to generate an impulse response.

+line: 8885 +isConstructor: false +itemtype: method +example: + - |- + +
+ let cVerb, sound; + function preload() { + // We have both MP3 and OGG versions of all sound assets + soundFormats('ogg', 'mp3'); + + // Try replacing 'bx-spring' with other soundfiles like + // 'concrete-tunnel' 'small-plate' 'drum' 'beatbox' + cVerb = createConvolver('/assets/bx-spring.mp3'); + + // Try replacing 'Damscray_DancingTiger' with + // 'beat', 'doorbell', lucky_dragons_-_power_melody' + sound = loadSound('/assets/Damscray_DancingTiger.mp3'); + } + + function setup() { + let cnv = createCanvas(100, 100); + cnv.mousePressed(playSound); + background(220); + text('tap to play', 20, 20); + + // disconnect from main output... + sound.disconnect(); + + // ...and process with cVerb + // so that we only hear the convolution + cVerb.process(sound); + } + + function playSound() { + sound.play(); + } +
+class: p5 +params: + - name: path + description: | +

path to a sound file

+ type: String + - name: callback + description: | +

function to call if loading is successful. + The object will be passed in as the argument + to the callback function.

+ type: Function + optional: true + - name: errorCallback + description: | +

function to call if loading is not successful. + A custom error will be passed in as the argument + to the callback function.

+ type: Function + optional: true +return: + description: '' + type: p5.Convolver +chainable: false +--- + + +# createConvolver diff --git a/src/content/reference/en/p5 copy/createDiv.mdx b/src/content/reference/en/p5 copy/createDiv.mdx new file mode 100644 index 0000000000..610e0a4f67 --- /dev/null +++ b/src/content/reference/en/p5 copy/createDiv.mdx @@ -0,0 +1,72 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L491 +title: createDiv +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a

element.

+ +

elements are commonly used as containers for + + other elements.

+ +

The parameter html is optional. It accepts a string that sets + the + + inner HTML of the new

.

+line: 491 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a div element and set its position. + let div = createDiv('p5*js'); + div.position(25, 35); + + describe('A gray square with the text "p5*js" written in its center.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an h3 element within the div. + let div = createDiv('

p5*js

'); + div.position(20, 5); + + describe('A gray square with the text "p5*js" written in its center.'); + } +
+
+class: p5 +params: + - name: html + description: > +

inner HTML for the new <div></div> + element.

+ type: String + optional: true +return: + description: new p5.Element object. + type: p5.Element +chainable: false +--- + + +# createDiv diff --git a/src/content/reference/en/p5 copy/createElement.mdx b/src/content/reference/en/p5 copy/createElement.mdx new file mode 100644 index 0000000000..5969416251 --- /dev/null +++ b/src/content/reference/en/p5 copy/createElement.mdx @@ -0,0 +1,78 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L2493 +title: createElement +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a new p5.Element object.

+ +

The first parameter, tag, is a string an HTML tag such as + 'h5'.

+ +

The second parameter, content, is optional. It's a string that + sets the + + HTML content to insert into the new element. New elements have no content + + by default.

+line: 2493 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an h5 element with nothing in it. + createElement('h5'); + + describe('A gray square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an h5 element with the content "p5*js". + let h5 = createElement('h5', 'p5*js'); + + // Set the element's style and position. + h5.style('color', 'deeppink'); + h5.position(30, 15); + + describe('The text "p5*js" written in pink in the middle of a gray square.'); + } + +
+class: p5 +params: + - name: tag + description: | +

tag for the new element.

+ type: String + - name: content + description: | +

HTML content to insert into the element.

+ type: String + optional: true +return: + description: new p5.Element object. + type: p5.Element +chainable: false +--- + + +# createElement diff --git a/src/content/reference/en/p5 copy/createFileInput.mdx b/src/content/reference/en/p5 copy/createFileInput.mdx new file mode 100644 index 0000000000..295f2a0434 --- /dev/null +++ b/src/content/reference/en/p5 copy/createFileInput.mdx @@ -0,0 +1,138 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1942 +title: createFileInput +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates an element of type + 'file'.

+ +

createFileInput() allows users to select local files for use + in a sketch. + + It returns a p5.File object.

+ +

The first parameter, callback, is a function that's called + when the file + + loads. The callback function should have one parameter, file, + that's a + + p5.File object.

+ +

The second parameter, multiple, is optional. It's a boolean + value that + + allows loading multiple files if set to true. If + true, callback + + will be called once per file.

+line: 1942 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Use the file input to select an image to + // load and display. + let input; + let img; + + function setup() { + createCanvas(100, 100); + + // Create a file input and place it beneath + // the canvas. + input = createFileInput(handleImage); + input.position(0, 100); + + describe('A gray square with a file input beneath it. If the user selects an image file to load, it is displayed on the square.'); + } + + function draw() { + background(200); + + // Draw the image if loaded. + if (img) { + image(img, 0, 0, width, height); + } + } + + // Create an image if the file is an image. + function handleImage(file) { + if (file.type === 'image') { + img = createImg(file.data, ''); + img.hide(); + } else { + img = null; + } + } + +
+ +
+ + // Use the file input to select multiple images + // to load and display. + let input; + let images = []; + + function setup() { + // Create a file input and place it beneath + // the canvas. Allow it to load multiple files. + input = createFileInput(handleImage, true); + input.position(0, 100); + } + + function draw() { + background(200); + + // Draw the images if loaded. Each image + // is drawn 20 pixels lower than the + // previous image. + for (let i = 0; i < images.length; i += 1) { + // Calculate the y-coordinate. + let y = i * 20; + + // Draw the image. + image(images[i], 0, y, 100, 100); + } + + describe('A gray square with a file input beneath it. If the user selects multiple image files to load, they are displayed on the square.'); + } + + // Create an image if the file is an image, + // then add it to the images array. + function handleImage(file) { + if (file.type === 'image') { + let img = createImg(file.data, ''); + img.hide(); + images.push(img); + } + } + +
+class: p5 +params: + - name: callback + description: | +

function to call once the file loads.

+ type: Function + - name: multiple + description: | +

allow multiple files to be selected.

+ type: Boolean + optional: true +return: + description: new p5.File object. + type: p5.File +chainable: false +--- + + +# createFileInput diff --git a/src/content/reference/en/p5 copy/createFilterShader.mdx b/src/content/reference/en/p5 copy/createFilterShader.mdx new file mode 100644 index 0000000000..5c6c9a4ec5 --- /dev/null +++ b/src/content/reference/en/p5 copy/createFilterShader.mdx @@ -0,0 +1,148 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L540 +title: createFilterShader +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Creates a p5.Shader object to be used + with the + + filter() function.

+ +

createFilterShader() works like + + createShader() but has a default + vertex + + shader included. createFilterShader() is intended to be used + along with + + filter() for filtering the contents of a + canvas. + + A filter shader will be applied to the whole canvas instead of just + + p5.Geometry objects.

+ +

The parameter, fragSrc, sets the fragment shader. It’s a + string that + + contains the fragment shader program written in + + GLSL.

+ +

The p5.Shader object that's created + has some + + uniforms that can be set:

+ +
    + +
  • sampler2D tex0, which contains the canvas contents as a + texture.
  • + +
  • vec2 canvasSize, which is the width and height of the canvas, + not including pixel density.
  • + +
  • vec2 texelSize, which is the size of a physical pixel + including pixel density. This is calculated as 1.0 / (width * + density) for the pixel width and 1.0 / (height * density) + for the pixel height.
  • + +
+ +

The p5.Shader that's created also + provides + + varying vec2 vTexCoord, a coordinate with values between 0 and 1. + + vTexCoord describes where on the canvas the pixel will be + drawn.

+ +

For more info about filters and shaders, see Adam Ferriss' repo of shader + examples + + or the Introduction to + Shaders tutorial.

+line: 540 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + let fragSrc = `precision highp float; + void main() { + gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); + }`; + + createCanvas(100, 100, WEBGL); + let s = createFilterShader(fragSrc); + filter(s); + describe('a yellow canvas'); + } + +
+ +
+ + let img, s; + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + function setup() { + let fragSrc = `precision highp float; + + // x,y coordinates, given from the vertex shader + varying vec2 vTexCoord; + + // the canvas contents, given from filter() + uniform sampler2D tex0; + // other useful information from the canvas + uniform vec2 texelSize; + uniform vec2 canvasSize; + // a custom variable from this sketch + uniform float darkness; + + void main() { + // get the color at current pixel + vec4 color = texture2D(tex0, vTexCoord); + // set the output color + color.b = 1.0; + color *= darkness; + gl_FragColor = vec4(color.rgb, 1.0); + }`; + + createCanvas(100, 100, WEBGL); + s = createFilterShader(fragSrc); + } + function draw() { + image(img, -50, -50); + s.setUniform('darkness', 0.5); + filter(s); + describe('a image of bricks tinted dark blue'); + } + +
+class: p5 +params: + - name: fragSrc + description: | +

source code for the fragment shader.

+ type: String +return: + description: new shader object created from the fragment shader. + type: p5.Shader +chainable: false +--- + + +# createFilterShader diff --git a/src/content/reference/en/p5 copy/createFramebuffer.mdx b/src/content/reference/en/p5 copy/createFramebuffer.mdx new file mode 100644 index 0000000000..80d8199779 --- /dev/null +++ b/src/content/reference/en/p5 copy/createFramebuffer.mdx @@ -0,0 +1,208 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L495 +title: createFramebuffer +module: Rendering +submodule: Rendering +file: src/core/rendering.js +description: > +

Creates and a new p5.Framebuffer + object.

+ +

p5.Framebuffer objects are + separate drawing + + surfaces that can be used as textures in WebGL mode. They're similar to + + p5.Graphics objects and generally run + much + + faster when used as textures.

+ +

The parameter, options, is optional. An object can be passed + to configure + + the p5.Framebuffer object. The + available + + properties are:

+ +
    + +
  • format: data format of the texture, either + UNSIGNED_BYTE, FLOAT, or HALF_FLOAT. + Default is UNSIGNED_BYTE.
  • + +
  • channels: whether to store RGB or + RGBA color channels. Default is to match the main canvas which is + RGBA.
  • + +
  • depth: whether to include a depth buffer. Default is + true.
  • + +
  • depthFormat: data format of depth information, either + UNSIGNED_INT or FLOAT. Default is + FLOAT.
  • + +
  • stencil: whether to include a stencil buffer for masking. + depth must be true for this feature to work. + Defaults to the value of depth which is true.
  • + +
  • antialias: whether to perform anti-aliasing. If set to + true, as in { antialias: true }, 2 samples will be + used by default. The number of samples can also be set, as in { + antialias: 4 }. Default is to match setAttributes() which is + false (true in Safari).
  • + +
  • width: width of the p5.Framebuffer object. Default is to + always match the main canvas width.
  • + +
  • height: height of the p5.Framebuffer object. Default is to + always match the main canvas height.
  • + +
  • density: pixel density of the p5.Framebuffer object. Default is to + always match the main canvas pixel density.
  • + +
  • textureFiltering: how to read values from the p5.Framebuffer object. Either + LINEAR (nearby pixels will be interpolated) or + NEAREST (no interpolation). Generally, use LINEAR + when using the texture as an image and NEAREST if reading the + texture as data. Default is LINEAR.
  • + +
+ +

If the width, height, or density + attributes are set, they won't automatically match the main canvas and must be + changed manually.

+ +

Note: createFramebuffer() can only be used in WebGL mode.

+line: 495 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let myBuffer; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Framebuffer object. + myBuffer = createFramebuffer(); + + describe('A grid of white toruses rotating against a dark gray background.'); + } + + function draw() { + background(50); + + // Start drawing to the p5.Framebuffer object. + myBuffer.begin(); + + // Clear the drawing surface. + clear(); + + // Turn on the lights. + lights(); + + // Rotate the coordinate system. + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + + // Style the torus. + noStroke(); + + // Draw the torus. + torus(20); + + // Stop drawing to the p5.Framebuffer object. + myBuffer.end(); + + // Iterate from left to right. + for (let x = -50; x < 50; x += 25) { + // Iterate from top to bottom. + for (let y = -50; y < 50; y += 25) { + // Draw the p5.Framebuffer object to the canvas. + image(myBuffer, x, y, 25, 25); + } + } + } + +
+ +
+ + let myBuffer; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create an options object. + let options = { width: 25, height: 25 }; + + // Create a p5.Framebuffer object. + // Use options for configuration. + myBuffer = createFramebuffer(options); + + describe('A grid of white toruses rotating against a dark gray background.'); + } + + function draw() { + background(50); + + // Start drawing to the p5.Framebuffer object. + myBuffer.begin(); + + // Clear the drawing surface. + clear(); + + // Turn on the lights. + lights(); + + // Rotate the coordinate system. + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + + // Style the torus. + noStroke(); + + // Draw the torus. + torus(5, 2.5); + + // Stop drawing to the p5.Framebuffer object. + myBuffer.end(); + + // Iterate from left to right. + for (let x = -50; x < 50; x += 25) { + // Iterate from top to bottom. + for (let y = -50; y < 50; y += 25) { + // Draw the p5.Framebuffer object to the canvas. + image(myBuffer, x, y); + } + } + } + +
+class: p5 +params: + - name: options + description: | +

configuration options.

+ type: Object + optional: true +return: + description: new framebuffer. + type: p5.Framebuffer +chainable: false +--- + + +# createFramebuffer diff --git a/src/content/reference/en/p5 copy/createGraphics.mdx b/src/content/reference/en/p5 copy/createGraphics.mdx new file mode 100644 index 0000000000..6d75f158f4 --- /dev/null +++ b/src/content/reference/en/p5 copy/createGraphics.mdx @@ -0,0 +1,191 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L370 +title: createGraphics +module: Rendering +submodule: Rendering +file: src/core/rendering.js +description: > +

Creates a p5.Graphics object.

+ +

createGraphics() creates an offscreen drawing canvas (graphics + buffer) + + and returns it as a p5.Graphics + object. Drawing + + to a separate graphics buffer can be helpful for performance and for + + organizing code.

+ +

The first two parameters, width and height, are + optional. They set the + + dimensions of the p5.Graphics object. + For + + example, calling createGraphics(900, 500) creates a graphics + buffer + + that's 900×500 pixels.

+ +

The third parameter is also optional. If either of the constants + P2D or + + WEBGL is passed, as in createGraphics(900, 500, + WEBGL), then it will set + + the p5.Graphics object's rendering + mode. If an + + existing + + HTMLCanvasElement + + is passed, as in createGraphics(900, 500, myCanvas), then it will + be used + + by the graphics buffer.

+ +

The fourth parameter is also optional. If an existing + + HTMLCanvasElement + + is passed, as in createGraphics(900, 500, WEBGL, myCanvas), then + it will be + + used by the graphics buffer.

+ +

Note: In WebGL mode, the p5.Graphics object + + will use a WebGL2 context if it's supported by the browser. Check the + + webglVersion system variable to + check what + + version is being used, or call setAttributes({ version: 1 }) to + create a + + WebGL1 context.

+line: 370 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Double-click to draw the contents of the graphics buffer. + + let pg; + + function setup() { + createCanvas(100, 100); + + background(180); + + // Create the p5.Graphics object. + pg = createGraphics(50, 50); + + // Draw to the graphics buffer. + pg.background(100); + pg.circle(pg.width / 2, pg.height / 2, 20); + + describe('A gray square. A smaller, darker square with a white circle at its center appears when the user double-clicks.'); + } + + // Display the graphics buffer when the user double-clicks. + function doubleClicked() { + if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { + image(pg, 25, 25); + } + } + +
+ +
+ + // Double-click to draw the contents of the graphics buffer. + + let pg; + + function setup() { + createCanvas(100, 100); + + background(180); + + // Create the p5.Graphics object in WebGL mode. + pg = createGraphics(50, 50, WEBGL); + + // Draw to the graphics buffer. + pg.background(100); + pg.lights(); + pg.noStroke(); + pg.rotateX(QUARTER_PI); + pg.rotateY(QUARTER_PI); + pg.torus(15, 5); + + describe('A gray square. A smaller, darker square with a white torus at its center appears when the user double-clicks.'); + } + + // Display the graphics buffer when the user double-clicks. + function doubleClicked() { + if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { + image(pg, 25, 25); + } + } + +
+class: p5 +return: + description: new graphics buffer. + type: p5.Graphics +overloads: + - line: 370 + params: + - name: width + description: | +

width of the graphics buffer.

+ type: Number + - name: height + description: | +

height of the graphics buffer.

+ type: Number + - name: renderer + description: | +

either P2D or WEBGL. Defaults to P2D.

+ type: Constant + optional: true + - name: canvas + description: | +

existing canvas element that should be + used for the graphics buffer..

+ type: HTMLCanvasElement + optional: true + return: + description: new graphics buffer. + type: p5.Graphics + - line: 475 + params: + - name: width + description: '' + type: Number + - name: height + description: '' + type: Number + - name: canvas + description: '' + type: HTMLCanvasElement + optional: true + return: + description: '' + type: p5.Graphics +chainable: false +--- + + +# createGraphics diff --git a/src/content/reference/en/p5 copy/createImage.mdx b/src/content/reference/en/p5 copy/createImage.mdx new file mode 100644 index 0000000000..33c151c315 --- /dev/null +++ b/src/content/reference/en/p5 copy/createImage.mdx @@ -0,0 +1,172 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/image.js#L15 +title: createImage +module: Image +submodule: Image +file: src/image/image.js +description: > +

Creates a new p5.Image object.

+ +

createImage() uses the width and + height parameters to set the new + + p5.Image object's dimensions in pixels. + The new + + p5.Image can be modified by updating its + + pixels array or by calling its + + get() and + + set() methods. The + + loadPixels() method must be + called + + before reading or modifying pixel values. The + + updatePixels() method must be + called + + for updates to take effect.

+ +

Note: The new p5.Image object is + transparent by + + default.

+line: 15 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Image object. + let img = createImage(66, 66); + + // Load the image's pixels into memory. + img.loadPixels(); + + // Set all the image's pixels to black. + for (let x = 0; x < img.width; x += 1) { + for (let y = 0; y < img.height; y += 1) { + img.set(x, y, 0); + } + } + + // Update the image's pixel values. + img.updatePixels(); + + // Draw the image. + image(img, 17, 17); + + describe('A black square drawn in the middle of a gray square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Image object. + let img = createImage(66, 66); + + // Load the image's pixels into memory. + img.loadPixels(); + + // Create a color gradient. + for (let x = 0; x < img.width; x += 1) { + for (let y = 0; y < img.height; y += 1) { + // Calculate the transparency. + let a = map(x, 0, img.width, 0, 255); + + // Create a p5.Color object. + let c = color(0, a); + + // Set the pixel's color. + img.set(x, y, c); + } + } + + // Update the image's pixels. + img.updatePixels(); + + // Display the image. + image(img, 17, 17); + + describe('A square with a horizontal color gradient that transitions from gray to black.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Image object. + let img = createImage(66, 66); + + // Load the pixels into memory. + img.loadPixels(); + // Get the current pixel density. + let d = pixelDensity(); + + // Calculate the pixel that is halfway through the image's pixel array. + let halfImage = 4 * (d * img.width) * (d * img.height / 2); + + // Set half of the image's pixels to black. + for (let i = 0; i < halfImage; i += 4) { + // Red. + img.pixels[i] = 0; + // Green. + img.pixels[i + 1] = 0; + // Blue. + img.pixels[i + 2] = 0; + // Alpha. + img.pixels[i + 3] = 255; + } + + // Update the image's pixels. + img.updatePixels(); + + // Display the image. + image(img, 17, 17); + + describe('A black square drawn in the middle of a gray square.'); + } + +
+class: p5 +params: + - name: width + description: | +

width in pixels.

+ type: Integer + - name: height + description: | +

height in pixels.

+ type: Integer +return: + description: new p5.Image object. + type: p5.Image +chainable: false +--- + + +# createImage diff --git a/src/content/reference/en/p5 copy/createImg.mdx b/src/content/reference/en/p5 copy/createImg.mdx new file mode 100644 index 0000000000..22b71d22c4 --- /dev/null +++ b/src/content/reference/en/p5 copy/createImg.mdx @@ -0,0 +1,115 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L649 +title: createImg +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates an element that can appear outside of the + canvas.

+ +

The first parameter, src, is a string with the path to the + image file. + + src should be a relative path, as in + '/assets/image.png', or a URL, as + + in 'https://example.com/image.png'.

+ +

The second parameter, alt, is a string with the + + alternate text + + for the image. An empty string '' can be used for images that + aren't displayed.

+ +

The third parameter, crossOrigin, is optional. It's a string + that sets the + + crossOrigin property + + of the image. Use 'anonymous' or 'use-credentials' + to fetch the image + + with cross-origin access.

+ +

The fourth parameter, callback, is also optional. It sets a + function to + + call after the image loads. The new image is passed to the callback + + function as a p5.Element object.

+line: 649 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + let img = createImg( + 'https://p5js.org//assets/img/asterisk-01.png', + 'The p5.js magenta asterisk.' + ); + img.position(0, -10); + + describe('A gray square with a magenta asterisk in its center.'); + } + +
+class: p5 +return: + description: new p5.Element object. + type: p5.Element +overloads: + - line: 649 + params: + - name: src + description: | +

relative path or URL for the image.

+ type: String + - name: alt + description: | +

alternate text for the image.

+ type: String + return: + description: new p5.Element object. + type: p5.Element + - line: 693 + params: + - name: src + description: '' + type: String + - name: alt + description: '' + type: String + - name: crossOrigin + description: | +

crossOrigin property to use when fetching the image.

+ type: String + optional: true + - name: successCallback + description: | +

function to call once the image loads. The new image will be passed + to the function as a p5.Element object.

+ type: Function + optional: true + return: + description: new p5.Element object. + type: p5.Element +chainable: false +--- + + +# createImg diff --git a/src/content/reference/en/p5 copy/createInput.mdx b/src/content/reference/en/p5 copy/createInput.mdx new file mode 100644 index 0000000000..3a790ee6b2 --- /dev/null +++ b/src/content/reference/en/p5 copy/createInput.mdx @@ -0,0 +1,118 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1859 +title: createInput +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a text element.

+ +

Call myInput.size() to set the length of the text box.

+ +

The first parameter, value, is optional. It's a string that + sets the + + input's default value. The input is blank by default.

+ +

The second parameter, type, is also optional. It's a string + that + + specifies the type of text being input. See MDN for a full + + list of options. + + The default is 'text'.

+line: 1859 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let myInput; + + function setup() { + createCanvas(100, 100); + + // Create an input element and place it + // beneath the canvas. + myInput = createInput(); + myInput.position(0, 100); + + describe('A gray square with a text box beneath it. The text in the square changes when the user types something new in the input bar.'); + } + + function draw() { + background(200); + + // Use the input to display a message. + let msg = myInput.value(); + text(msg, 25, 55); + } + +
+ +
+ + let myInput; + + function setup() { + createCanvas(100, 100); + + // Create an input element and place it + // beneath the canvas. Set its default + // text to "hello!". + myInput = createInput('hello!'); + myInput.position(0, 100); + + describe('The text "hello!" written at the center of a gray square. A text box beneath the square also says "hello!". The text in the square changes when the user types something new in the input bar.'); + } + + function draw() { + background(200); + + // Use the input to display a message. + let msg = myInput.value(); + text(msg, 25, 55); + } + +
+class: p5 +return: + description: new p5.Element object. + type: p5.Element +overloads: + - line: 1859 + params: + - name: value + description: > +

default value of the input box. Defaults to an empty string + ''.

+ type: String + optional: true + - name: type + description: | +

type of input. Defaults to 'text'.

+ type: String + optional: true + return: + description: new p5.Element object. + type: p5.Element + - line: 1929 + params: + - name: value + description: '' + type: String + optional: true + return: + description: '' + type: p5.Element +chainable: false +--- + + +# createInput diff --git a/src/content/reference/en/p5 copy/createModel.mdx b/src/content/reference/en/p5 copy/createModel.mdx new file mode 100644 index 0000000000..c94e95900f --- /dev/null +++ b/src/content/reference/en/p5 copy/createModel.mdx @@ -0,0 +1,193 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/loading.js#L1132 +title: createModel +module: Shape +submodule: 3D Models +file: src/webgl/loading.js +description: > +

Load a 3d model from an OBJ or STL string.

+ +

OBJ and STL files lack a built-in sense of scale, causing models exported + from different programs to vary in size. + + If your model doesn't display correctly, consider using + loadModel() with normalize set to true + to standardize its size. + + Further adjustments can be made using the scale() function.

+ +

Also, the support for colored STL files is not present. STL files with + color will be + + rendered without color properties.

+ +
    + +
  • Options can include:
  • + +
+ +
    + +
  • modelString: Specifies the plain text string of either an stl + or obj file to be loaded.
  • + +
  • fileType: Defines the file extension of the model.
  • + +
  • normalize: Enables standardized size scaling during loading + if set to true.
  • + +
  • successCallback: Callback for post-loading actions with the + 3D model object.
  • + +
  • failureCallback: Handles errors if model loading fails, + receiving an event error.
  • + +
  • flipU: Flips the U texture coordinates of the model.
  • + +
  • flipV: Flips the V texture coordinates of the model.
  • + +
+line: 1132 +isConstructor: false +itemtype: method +example: + - |- + +
+ + const octahedron_model = ` + v 0.000000E+00 0.000000E+00 40.0000 + v 22.5000 22.5000 0.000000E+00 + v 22.5000 -22.5000 0.000000E+00 + v -22.5000 -22.5000 0.000000E+00 + v -22.5000 22.5000 0.000000E+00 + v 0.000000E+00 0.000000E+00 -40.0000 + f 1 2 3 + f 1 3 4 + f 1 4 5 + f 1 5 2 + f 6 5 4 + f 6 4 3 + f 6 3 2 + f 6 2 5 + `; + //draw a spinning octahedron + let octahedron; + + function setup() { + createCanvas(100, 100, WEBGL); + octahedron = createModel(octahedron_model, '.obj'); + describe('Vertically rotating 3D octahedron.'); + } + + function draw() { + background(200); + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + model(octahedron); + } + +
+class: p5 +return: + description: the p5.Geometry object + type: p5.Geometry +overloads: + - line: 1132 + params: + - name: modelString + description: | +

String of the object to be loaded

+ type: String + - name: fileType + description: | +

The file extension of the model + (.stl, .obj).

+ type: String + optional: true + - name: normalize + description: | +

If true, scale the model to a + standardized size when loading

+ type: Boolean + - name: successCallback + description: | +

Function to be called + once the model is loaded. Will be passed + the 3D model object.

+ type: function(p5.Geometry) + optional: true + - name: failureCallback + description: | +

called with event error if + the model fails to load.

+ type: Function(Event) + optional: true + return: + description: the p5.Geometry object + type: p5.Geometry + - line: 1202 + params: + - name: modelString + description: '' + type: String + - name: fileType + description: '' + type: String + optional: true + - name: successCallback + description: '' + type: function(p5.Geometry) + optional: true + - name: failureCallback + description: '' + type: Function(Event) + optional: true + return: + description: the p5.Geometry object + type: p5.Geometry + - line: 1210 + params: + - name: modelString + description: '' + type: String + - name: fileType + description: '' + type: String + optional: true + - name: options + description: '' + type: Object + optional: true + props: + - name: successCallback + description: '' + type: function(p5.Geometry) + optional: true + - name: failureCallback + description: '' + type: Function(Event) + optional: true + - name: normalize + description: '' + type: Boolean + optional: true + - name: flipU + description: '' + type: Boolean + optional: true + - name: flipV + description: '' + type: Boolean + optional: true + return: + description: the p5.Geometry object + type: p5.Geometry +chainable: false +--- + + +# createModel diff --git a/src/content/reference/en/p5 copy/createNumberDict.mdx b/src/content/reference/en/p5 copy/createNumberDict.mdx new file mode 100644 index 0000000000..952410a222 --- /dev/null +++ b/src/content/reference/en/p5 copy/createNumberDict.mdx @@ -0,0 +1,57 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/data/p5.TypedDict.js#L48 +title: createNumberDict +module: Data +submodule: Dictionary +file: src/data/p5.TypedDict.js +description: > +

Creates a new instance of p5.NumberDict using the key-value pair + or object you provide.

+line: 48 +isConstructor: false +itemtype: method +example: + - |2- + +
+ + function setup() { + let myDictionary = createNumberDict(100, 42); + print(myDictionary.hasKey(100)); // logs true to console + let anotherDictionary = createNumberDict({ 200: 84 }); + print(anotherDictionary.hasKey(200)); // logs true to console + } +
+class: p5 +return: + description: '' + type: p5.NumberDict +overloads: + - line: 48 + params: + - name: key + description: '' + type: Number + - name: value + description: '' + type: Number + return: + description: '' + type: p5.NumberDict + - line: 71 + params: + - name: object + description: | +

object

+ type: Object + return: + description: '' + type: p5.NumberDict +chainable: false +--- + + +# createNumberDict diff --git a/src/content/reference/en/p5 copy/createP.mdx b/src/content/reference/en/p5 copy/createP.mdx new file mode 100644 index 0000000000..6d3005fc37 --- /dev/null +++ b/src/content/reference/en/p5 copy/createP.mdx @@ -0,0 +1,54 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L543 +title: createP +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a paragraph element.

+ +

elements are commonly used for paragraph-length + text.

+ +

The parameter html is optional. It accepts a string that sets + the + + inner HTML of the new

.

+line: 543 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a paragraph element and set its position. + let p = createP('Tell me a story.'); + p.position(5, 0); + + describe('A gray square displaying the text "Tell me a story." written in black.'); + } + +
+class: p5 +params: + - name: html + description: | +

inner HTML for the new <p></p> element.

+ type: String + optional: true +return: + description: new p5.Element object. + type: p5.Element +chainable: false +--- + + +# createP diff --git a/src/content/reference/en/p5 copy/createRadio.mdx b/src/content/reference/en/p5 copy/createRadio.mdx new file mode 100644 index 0000000000..f2b8a2a81c --- /dev/null +++ b/src/content/reference/en/p5 copy/createRadio.mdx @@ -0,0 +1,223 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1440 +title: createRadio +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a radio button element.

+ +

The parameter is optional. If a string is passed, as in + + let myRadio = createSelect('food'), then each radio option will + + have "food" as its name parameter: . + + If an existing

or + + element is passed, as in let myRadio = createSelect(container), + it will + + become the radio button's parent element.

+ +

Radio buttons extend the p5.Element + class with a few + + helpful methods for managing options:

+ +
    + +
  • myRadio.option(value, [label]) adds an option to the menu. + The first parameter, value, is a string that sets the option's + value and label. The second parameter, label, is optional. If + provided, it sets the label displayed for the value. If an option + with value already exists, its label is changed and its value is + returned.
  • + +
  • myRadio.value() returns the currently-selected option's + value.
  • + +
  • myRadio.selected() returns the currently-selected + option.
  • + +
  • myRadio.selected(value) selects the given option and returns + it as an HTMLInputElement.
  • + +
  • myRadio.disable(shouldDisable) Disables the radio button if + true is passed, and enables it if false is + passed.
  • + +
+line: 1440 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let style = document.createElement('style'); + style.innerHTML = ` + .p5-radio label { + display: flex; + align-items: center; + } + .p5-radio input { + margin-right: 5px; + } + `; + document.head.appendChild(style); + + let myRadio; + + function setup() { + createCanvas(100, 100); + + // Create a radio button element and place it + // in the top-left corner. + myRadio = createRadio(); + myRadio.position(0, 0); + myRadio.class('p5-radio'); + myRadio.size(60); + + // Add a few color options. + myRadio.option('red'); + myRadio.option('yellow'); + myRadio.option('blue'); + + // Choose a default option. + myRadio.selected('yellow'); + + describe('A yellow square with three color options listed, "red", "yellow", and "blue". The square changes color when the user selects a new option.'); + } + + function draw() { + // Set the background color using the radio button. + let g = myRadio.value(); + background(g); + } + +
+ +
+ + let myRadio; + + function setup() { + createCanvas(100, 100); + + // Create a radio button element and place it + // in the top-left corner. + myRadio = createRadio(); + myRadio.position(0, 0); + myRadio.size(50); + + // Add a few color options. + // Color values are labeled with + // emotions they evoke. + myRadio.option('red', 'love'); + myRadio.option('yellow', 'joy'); + myRadio.option('blue', 'trust'); + + // Choose a default option. + myRadio.selected('yellow'); + + describe('A yellow square with three options listed, "love", "joy", and "trust". The square changes color when the user selects a new option.'); + } + + function draw() { + // Set the background color using the radio button. + let c = myRadio.value(); + background(c); + } + +
+ +
+ + let myRadio; + + function setup() { + createCanvas(100, 100); + + // Create a radio button element and place it + // in the top-left corner. + myRadio = createRadio(); + myRadio.position(0, 0); + myRadio.class('p5-radio'); + myRadio.size(50); + + // Add a few color options. + myRadio.option('red'); + myRadio.option('yellow'); + myRadio.option('blue'); + + // Choose a default option. + myRadio.selected('yellow'); + + // Create a button and place it beneath the canvas. + let btn = createButton('disable'); + btn.position(0, 100); + + // Call disableRadio() when btn is pressed. + btn.mousePressed(disableRadio); + + describe('A yellow square with three options listed, "red", "yellow", and "blue". The square changes color when the user selects a new option. A "disable" button beneath the canvas disables the color options when pressed.'); + } + + function draw() { + // Set the background color using the radio button. + let c = myRadio.value(); + background(c); + } + + // Disable myRadio. + function disableRadio() { + myRadio.disable(true); + } + +
+class: p5 +return: + description: new p5.Element object. + type: p5.Element +overloads: + - line: 1440 + params: + - name: containerElement + description: > +

container HTML Element, either a + <div></div> + + or <span></span>.

+ type: Object + optional: true + return: + description: new p5.Element object. + type: p5.Element + - line: 1588 + params: + - name: name + description: > +

name parameter assigned to each option's + <input></input> element.

+ type: String + optional: true + return: + description: new p5.Element object. + type: p5.Element + - line: 1593 + params: [] + return: + description: new p5.Element object. + type: p5.Element +chainable: false +--- + + +# createRadio diff --git a/src/content/reference/en/p5 copy/createSelect.mdx b/src/content/reference/en/p5 copy/createSelect.mdx new file mode 100644 index 0000000000..496f4082e6 --- /dev/null +++ b/src/content/reference/en/p5 copy/createSelect.mdx @@ -0,0 +1,235 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1159 +title: createSelect +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a dropdown menu element.

+ +

The parameter is optional. If true is passed, as in + + let mySelect = createSelect(true), then the dropdown will support + + multiple selections. If an existing element + + is passed, as in let mySelect = createSelect(otherSelect), the + existing + + element will be wrapped in a new p5.Element + + object.

+ +

Dropdowns extend the p5.Element + class with a few + + helpful methods for managing options:

+ +
    + +
  • mySelect.option(name, [value]) adds an option to the menu. + The first paremeter, name, is a string that sets the option's + name and value. The second parameter, value, is optional. If + provided, it sets the value that corresponds to the key name. If + an option with name already exists, its value is changed to + value.
  • + +
  • mySelect.value() returns the currently-selected option's + value.
  • + +
  • mySelect.selected() returns the currently-selected + option.
  • + +
  • mySelect.selected(option) selects the given option by + default.
  • + +
  • mySelect.disable() marks the whole dropdown element as + disabled.
  • + +
  • mySelect.disable(option) marks a given option as + disabled.
  • + +
  • mySelect.enable() marks the whole dropdown element as + enabled.
  • + +
  • mySelect.enable(option) marks a given option as enabled.
  • + +
+line: 1159 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let mySelect; + + function setup() { + createCanvas(100, 100); + + // Create a dropdown and place it beneath the canvas. + mySelect = createSelect(); + mySelect.position(0, 100); + + // Add color options. + mySelect.option('red'); + mySelect.option('green'); + mySelect.option('blue'); + mySelect.option('yellow'); + + // Set the selected option to "red". + mySelect.selected('red'); + + describe('A red square with a dropdown menu beneath it. The square changes color when a new color is selected.'); + } + + function draw() { + // Use the selected value to paint the background. + let c = mySelect.selected(); + background(c); + } + +
+ +
+ + let mySelect; + + function setup() { + createCanvas(100, 100); + + // Create a dropdown and place it beneath the canvas. + mySelect = createSelect(); + mySelect.position(0, 100); + + // Add color options. + mySelect.option('red'); + mySelect.option('green'); + mySelect.option('blue'); + mySelect.option('yellow'); + + // Set the selected option to "red". + mySelect.selected('red'); + + // Disable the "yellow" option. + mySelect.disable('yellow'); + + describe('A red square with a dropdown menu beneath it. The square changes color when a new color is selected.'); + } + + function draw() { + // Use the selected value to paint the background. + let c = mySelect.selected(); + background(c); + } + +
+ +
+ + let mySelect; + + function setup() { + createCanvas(100, 100); + + // Create a dropdown and place it beneath the canvas. + mySelect = createSelect(); + mySelect.position(0, 100); + + // Add color options with names and values. + mySelect.option('one', 'red'); + mySelect.option('two', 'green'); + mySelect.option('three', 'blue'); + mySelect.option('four', 'yellow'); + + // Set the selected option to "one". + mySelect.selected('one'); + + describe('A red square with a dropdown menu beneath it. The square changes color when a new color is selected.'); + } + + function draw() { + // Use the selected value to paint the background. + let c = mySelect.selected(); + background(c); + } + +
+ +
+ + // Hold CTRL to select multiple options on Windows and Linux. + // Hold CMD to select multiple options on macOS. + let mySelect; + + function setup() { + createCanvas(100, 100); + + // Create a dropdown and allow multiple selections. + // Place it beneath the canvas. + mySelect = createSelect(true); + mySelect.position(0, 100); + + // Add color options. + mySelect.option('red'); + mySelect.option('green'); + mySelect.option('blue'); + mySelect.option('yellow'); + + describe('A gray square with a dropdown menu beneath it. Colorful circles appear when their color is selected.'); + } + + function draw() { + background(200); + + // Use the selected value(s) to draw circles. + let colors = mySelect.selected(); + for (let i = 0; i < colors.length; i += 1) { + // Calculate the x-coordinate. + let x = 10 + i * 20; + + // Access the color. + let c = colors[i]; + + // Draw the circle. + fill(c); + circle(x, 50, 20); + } + } + +
+class: p5 +return: + description: new p5.Element object. + type: p5.Element +overloads: + - line: 1159 + params: + - name: multiple + description: | +

support multiple selections.

+ type: Boolean + optional: true + return: + description: new p5.Element object. + type: p5.Element + - line: 1324 + params: + - name: existing + description: > +

select element to wrap, either as a p5.Element or + a HTMLSelectElement.

+ type: Object + return: + description: '' + type: p5.Element +chainable: false +--- + + +# createSelect diff --git a/src/content/reference/en/p5 copy/createShader.mdx b/src/content/reference/en/p5 copy/createShader.mdx new file mode 100644 index 0000000000..c595145529 --- /dev/null +++ b/src/content/reference/en/p5 copy/createShader.mdx @@ -0,0 +1,438 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L173 +title: createShader +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Creates a new p5.Shader object.

+ +

Shaders are programs that run on the graphics processing unit (GPU). They + + can process many pixels at the same time, making them fast for many + + graphics tasks. They’re written in a language called + + GLSL + + and run along with the rest of the code in a sketch.

+ +

Once the p5.Shader object is created, + it can be + + used with the shader() function, as in + + shader(myShader). A shader program consists of two parts, a + vertex shader + + and a fragment shader. The vertex shader affects where 3D geometry is drawn + + on the screen and the fragment shader affects color.

+ +

The first parameter, vertSrc, sets the vertex shader. It’s a + string that + + contains the vertex shader program written in GLSL.

+ +

The second parameter, fragSrc, sets the fragment shader. It’s + a string + + that contains the fragment shader program written in GLSL.

+ +

A shader can optionally describe hooks, which are functions in + GLSL that + + users may choose to provide to customize the behavior of the shader using the + + modify() method of + p5.Shader. These are added by + + describing the hooks in a third parameter, options, and + referencing the hooks in + + your vertSrc or fragSrc. Hooks for the vertex or + fragment shader are described under + + the vertex and fragment keys of + options. Each one is an object. where each key is + + the type and name of a hook function, and each value is a string with the + + parameter list and default implementation of the hook. For example, to let + users + + optionally run code at the start of the vertex shader, the options object + could + + include:

+ +
{
+    vertex: {
+      'void beforeVertex': '() {}'
+    }
+  }
+
+  
+ +

Then, in your vertex shader source, you can run a hook by calling a + function + + with the same name prefixed by HOOK_. If you want to check if the + default + + hook has been replaced, maybe to avoid extra overhead, you can check if the + + same name prefixed by AUGMENTED_HOOK_ has been defined:

+ +
void main() {
+    // In most cases, just calling the hook is fine:
+    HOOK_beforeVertex();
+
+    // Alternatively, for more efficiency:
+    #ifdef AUGMENTED_HOOK_beforeVertex
+    HOOK_beforeVertex();
+    #endif
+
+    // Add the rest of your shader code here!
+  }
+
+  
+ +

Note: Only filter shaders can be used in 2D mode. All shaders can be used + + in WebGL mode.

+line: 173 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Note: A "uniform" is a global variable within a shader program. + + // Create a string with the vertex shader program. + // The vertex shader is called for each vertex. + let vertSrc = ` + precision highp float; + uniform mat4 uModelViewMatrix; + uniform mat4 uProjectionMatrix; + attribute vec3 aPosition; + attribute vec2 aTexCoord; + varying vec2 vTexCoord; + + void main() { + vTexCoord = aTexCoord; + vec4 positionVec4 = vec4(aPosition, 1.0); + gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; + } + `; + + // Create a string with the fragment shader program. + // The fragment shader is called for each pixel. + let fragSrc = ` + precision highp float; + + void main() { + // Set each pixel's RGBA value to yellow. + gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); + } + `; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Shader object. + let shaderProgram = createShader(vertSrc, fragSrc); + + // Compile and apply the p5.Shader object. + shader(shaderProgram); + + // Style the drawing surface. + noStroke(); + + // Add a plane as a drawing surface. + plane(100, 100); + + describe('A yellow square.'); + } + +
+ +
+ + // Note: A "uniform" is a global variable within a shader program. + + // Create a string with the vertex shader program. + // The vertex shader is called for each vertex. + let vertSrc = ` + precision highp float; + uniform mat4 uModelViewMatrix; + uniform mat4 uProjectionMatrix; + attribute vec3 aPosition; + attribute vec2 aTexCoord; + varying vec2 vTexCoord; + + void main() { + vTexCoord = aTexCoord; + vec4 positionVec4 = vec4(aPosition, 1.0); + gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; + } + `; + + // Create a string with the fragment shader program. + // The fragment shader is called for each pixel. + let fragSrc = ` + precision highp float; + uniform vec2 p; + uniform float r; + const int numIterations = 500; + varying vec2 vTexCoord; + + void main() { + vec2 c = p + gl_FragCoord.xy * r; + vec2 z = c; + float n = 0.0; + + for (int i = numIterations; i > 0; i--) { + if (z.x * z.x + z.y * z.y > 4.0) { + n = float(i) / float(numIterations); + break; + } + z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c; + } + + gl_FragColor = vec4( + 0.5 - cos(n * 17.0) / 2.0, + 0.5 - cos(n * 13.0) / 2.0, + 0.5 - cos(n * 23.0) / 2.0, + 1.0 + ); + } + `; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Shader object. + let mandelbrot = createShader(vertSrc, fragSrc); + + // Compile and apply the p5.Shader object. + shader(mandelbrot); + + // Set the shader uniform p to an array. + // p is the center point of the Mandelbrot image. + mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); + + // Set the shader uniform r to 0.005. + // r is the size of the image in Mandelbrot-space. + mandelbrot.setUniform('r', 0.005); + + // Style the drawing surface. + noStroke(); + + // Add a plane as a drawing surface. + plane(100, 100); + + describe('A black fractal image on a magenta background.'); + } + +
+ +
+ + // Note: A "uniform" is a global variable within a shader program. + + // Create a string with the vertex shader program. + // The vertex shader is called for each vertex. + let vertSrc = ` + precision highp float; + uniform mat4 uModelViewMatrix; + uniform mat4 uProjectionMatrix; + + attribute vec3 aPosition; + attribute vec2 aTexCoord; + varying vec2 vTexCoord; + + void main() { + vTexCoord = aTexCoord; + vec4 positionVec4 = vec4(aPosition, 1.0); + gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; + } + `; + + // Create a string with the fragment shader program. + // The fragment shader is called for each pixel. + let fragSrc = ` + precision highp float; + uniform vec2 p; + uniform float r; + const int numIterations = 500; + varying vec2 vTexCoord; + + void main() { + vec2 c = p + gl_FragCoord.xy * r; + vec2 z = c; + float n = 0.0; + + for (int i = numIterations; i > 0; i--) { + if (z.x * z.x + z.y * z.y > 4.0) { + n = float(i) / float(numIterations); + break; + } + + z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c; + } + + gl_FragColor = vec4( + 0.5 - cos(n * 17.0) / 2.0, + 0.5 - cos(n * 13.0) / 2.0, + 0.5 - cos(n * 23.0) / 2.0, + 1.0 + ); + } + `; + + let mandelbrot; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Shader object. + mandelbrot = createShader(vertSrc, fragSrc); + + // Apply the p5.Shader object. + shader(mandelbrot); + + // Set the shader uniform p to an array. + // p is the center point of the Mandelbrot image. + mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); + + describe('A fractal image zooms in and out of focus.'); + } + + function draw() { + // Set the shader uniform r to a value that oscillates + // between 0 and 0.005. + // r is the size of the image in Mandelbrot-space. + let radius = 0.005 * (sin(frameCount * 0.01) + 1); + mandelbrot.setUniform('r', radius); + + // Style the drawing surface. + noStroke(); + + // Add a plane as a drawing surface. + plane(100, 100); + } + +
+ +
+ + // A shader with hooks. + let myShader; + + // A shader with modified hooks. + let modifiedShader; + + // Create a string with the vertex shader program. + // The vertex shader is called for each vertex. + let vertSrc = ` + precision highp float; + uniform mat4 uModelViewMatrix; + uniform mat4 uProjectionMatrix; + + attribute vec3 aPosition; + attribute vec2 aTexCoord; + + void main() { + vec4 positionVec4 = vec4(aPosition, 1.0); + gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; + } + `; + + // Create a fragment shader that uses a hook. + let fragSrc = ` + precision highp float; + void main() { + // Let users override the color + gl_FragColor = HOOK_getColor(vec4(1., 0., 0., 1.)); + } + `; + + function setup() { + createCanvas(50, 50, WEBGL); + + // Create a shader with hooks + myShader = createShader(vertSrc, fragSrc, { + fragment: { + 'vec4 getColor': '(vec4 color) { return color; }' + } + }); + + // Make a version of the shader with a hook overridden + modifiedShader = myShader.modify({ + 'vec4 getColor': `(vec4 color) { + return vec4(0., 0., 1., 1.); + }` + }); + } + + function draw() { + noStroke(); + + push(); + shader(myShader); + translate(-width/3, 0); + sphere(10); + pop(); + + push(); + shader(modifiedShader); + translate(width/3, 0); + sphere(10); + pop(); + } + +
+class: p5 +params: + - name: vertSrc + description: | +

source code for the vertex shader.

+ type: String + - name: fragSrc + description: | +

source code for the fragment shader.

+ type: String + - name: options + description: > +

An optional object describing how this shader can + + be augmented with hooks. It can include:

+ +
    + +
  • vertex: An object describing the available vertex shader + hooks.
  • + +
  • fragment: An object describing the available frament + shader hooks.
  • + +
+ type: Object + optional: true +return: + description: |- + new shader object created from the + vertex and fragment shaders. + type: p5.Shader +chainable: false +--- + + +# createShader diff --git a/src/content/reference/en/p5 copy/createSlider.mdx b/src/content/reference/en/p5 copy/createSlider.mdx new file mode 100644 index 0000000000..7bdf510078 --- /dev/null +++ b/src/content/reference/en/p5 copy/createSlider.mdx @@ -0,0 +1,162 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L789 +title: createSlider +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a slider element.

+ +

Range sliders are useful for quickly selecting numbers from a given + range.

+ +

The first two parameters, min and max, are + numbers that set the + + slider's minimum and maximum.

+ +

The third parameter, value, is optional. It's a number that + sets the + + slider's default value.

+ +

The fourth parameter, step, is also optional. It's a number + that sets the + + spacing between each value in the slider's range. Setting step to + 0 + + allows the slider to move smoothly from min to + max.

+line: 789 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let slider; + + function setup() { + createCanvas(100, 100); + + // Create a slider and place it at the top of the canvas. + slider = createSlider(0, 255); + slider.position(10, 10); + slider.size(80); + + describe('A dark gray square with a range slider at the top. The square changes color when the slider is moved.'); + } + + function draw() { + // Use the slider as a grayscale value. + let g = slider.value(); + background(g); + } + +
+ +
+ + let slider; + + function setup() { + createCanvas(100, 100); + + // Create a slider and place it at the top of the canvas. + // Set its default value to 0. + slider = createSlider(0, 255, 0); + slider.position(10, 10); + slider.size(80); + + describe('A black square with a range slider at the top. The square changes color when the slider is moved.'); + } + + function draw() { + // Use the slider as a grayscale value. + let g = slider.value(); + background(g); + } + +
+ +
+ + let slider; + + function setup() { + createCanvas(100, 100); + + // Create a slider and place it at the top of the canvas. + // Set its default value to 0. + // Set its step size to 50. + slider = createSlider(0, 255, 0, 50); + slider.position(10, 10); + slider.size(80); + + describe('A black square with a range slider at the top. The square changes color when the slider is moved.'); + } + + function draw() { + // Use the slider as a grayscale value. + let g = slider.value(); + background(g); + } + +
+ +
+ + let slider; + + function setup() { + createCanvas(100, 100); + + // Create a slider and place it at the top of the canvas. + // Set its default value to 0. + // Set its step size to 0 so that it moves smoothly. + slider = createSlider(0, 255, 0, 0); + slider.position(10, 10); + slider.size(80); + + describe('A black square with a range slider at the top. The square changes color when the slider is moved.'); + } + + function draw() { + // Use the slider as a grayscale value. + let g = slider.value(); + background(g); + } + +
+class: p5 +params: + - name: min + description: | +

minimum value of the slider.

+ type: Number + - name: max + description: | +

maximum value of the slider.

+ type: Number + - name: value + description: | +

default value of the slider.

+ type: Number + optional: true + - name: step + description: | +

size for each step in the slider's range.

+ type: Number + optional: true +return: + description: new p5.Element object. + type: p5.Element +chainable: false +--- + + +# createSlider diff --git a/src/content/reference/en/p5 copy/createSpan.mdx b/src/content/reference/en/p5 copy/createSpan.mdx new file mode 100644 index 0000000000..ed346b35dc --- /dev/null +++ b/src/content/reference/en/p5 copy/createSpan.mdx @@ -0,0 +1,93 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L578 +title: createSpan +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a element.

+ +

elements are commonly used as containers + + for inline elements. For example, a + + can hold part of a sentence that's a + + different style.

+ +

The parameter html is optional. It accepts a string that sets + the + + inner HTML of the new .

+line: 578 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a span element and set its position. + let span = createSpan('p5*js'); + span.position(25, 35); + + describe('A gray square with the text "p5*js" written in its center.'); + } + +
+ +
+ + function setup() { + background(200); + + // Create a div element as a container. + let div = createDiv(); + + // Place the div at the center. + div.position(25, 35); + + // Create a span element. + let s1 = createSpan('p5'); + + // Create a second span element. + let s2 = createSpan('*'); + + // Set the second span's font color. + s2.style('color', 'deeppink'); + + // Create a third span element. + let s3 = createSpan('js'); + + // Add all the spans to the container div. + s1.parent(div); + s2.parent(div); + s3.parent(div); + + describe('A gray square with the text "p5*js" written in black at its center. The asterisk is pink.'); + } + +
+class: p5 +params: + - name: html + description: > +

inner HTML for the new <span></span> + element.

+ type: String + optional: true +return: + description: new p5.Element object. + type: p5.Element +chainable: false +--- + + +# createSpan diff --git a/src/content/reference/en/p5 copy/createStringDict.mdx b/src/content/reference/en/p5 copy/createStringDict.mdx new file mode 100644 index 0000000000..bc080c1276 --- /dev/null +++ b/src/content/reference/en/p5 copy/createStringDict.mdx @@ -0,0 +1,56 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/data/p5.TypedDict.js#L14 +title: createStringDict +module: Data +submodule: Dictionary +file: src/data/p5.TypedDict.js +description: | +

Creates a new instance of p5.StringDict using the key-value pair + or the object you provide.

+line: 14 +isConstructor: false +itemtype: method +example: + - |2- + +
+ + function setup() { + let myDictionary = createStringDict('p5', 'js'); + print(myDictionary.hasKey('p5')); // logs true to console + let anotherDictionary = createStringDict({ happy: 'coding' }); + print(anotherDictionary.hasKey('happy')); // logs true to console + } +
+class: p5 +return: + description: '' + type: p5.StringDict +overloads: + - line: 14 + params: + - name: key + description: '' + type: String + - name: value + description: '' + type: String + return: + description: '' + type: p5.StringDict + - line: 37 + params: + - name: object + description: | +

object

+ type: Object + return: + description: '' + type: p5.StringDict +chainable: false +--- + + +# createStringDict diff --git a/src/content/reference/en/p5 copy/createVector.mdx b/src/content/reference/en/p5 copy/createVector.mdx new file mode 100644 index 0000000000..07ca75ec36 --- /dev/null +++ b/src/content/reference/en/p5 copy/createVector.mdx @@ -0,0 +1,133 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/math.js#L10 +title: createVector +module: Math +submodule: Vector +file: src/math/math.js +description: > +

Creates a new p5.Vector object.

+ +

A vector can be thought of in different ways. In one view, a vector is like + + an arrow pointing in space. Vectors have both magnitude (length) and + + direction. This view is helpful for programming motion.

+ +

A vector's components determine its magnitude and direction. For example, + + calling createVector(3, 4) creates a new + + p5.Vector object with an x-component of + 3 and a + + y-component of 4. From the origin, this vector's tip is 3 units to the + + right and 4 units down.

+ +

p5.Vector objects are often used to + program + + motion because they simplify the math. For example, a moving ball has a + + position and a velocity. Position describes where the ball is in space. The + + ball's position vector extends from the origin to the ball's center. + + Velocity describes the ball's speed and the direction it's moving. If the + + ball is moving straight up, its velocity vector points straight up. Adding + + the ball's velocity vector to its position vector moves it, as in + + pos.add(vel). Vector math relies on methods inside the + + p5.Vector class.

+line: 10 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create p5.Vector objects. + let p1 = createVector(25, 25); + let p2 = createVector(50, 50); + let p3 = createVector(75, 75); + + // Draw the dots. + strokeWeight(5); + point(p1); + point(p2); + point(p3); + + describe('Three black dots form a diagonal line from top left to bottom right.'); + } + +
+ +
+ + let pos; + let vel; + + function setup() { + createCanvas(100, 100); + + // Create p5.Vector objects. + pos = createVector(50, 100); + vel = createVector(0, -1); + + describe('A black dot moves from bottom to top on a gray square. The dot reappears at the bottom when it reaches the top.'); + } + + function draw() { + background(200); + + // Add velocity to position. + pos.add(vel); + + // If the dot reaches the top of the canvas, + // restart from the bottom. + if (pos.y < 0) { + pos.y = 100; + } + + // Draw the dot. + strokeWeight(5); + point(pos); + } + +
+class: p5 +params: + - name: x + description: | +

x component of the vector.

+ type: Number + optional: true + - name: 'y' + description: | +

y component of the vector.

+ type: Number + optional: true + - name: z + description: | +

z component of the vector.

+ type: Number + optional: true +return: + description: new p5.Vector object. + type: p5.Vector +chainable: false +--- + + +# createVector diff --git a/src/content/reference/en/p5 copy/createVideo.mdx b/src/content/reference/en/p5 copy/createVideo.mdx new file mode 100644 index 0000000000..a7053f80a0 --- /dev/null +++ b/src/content/reference/en/p5 copy/createVideo.mdx @@ -0,0 +1,135 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L2115 +title: createVideo +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Creates a element for simple audio/video playback.

+ +

createVideo() returns a new + + p5.MediaElement object. Videos are + shown by + + default. They can be hidden by calling video.hide() and drawn to + the + + canvas using image().

+ +

The first parameter, src, is the path the video. If a single + string is + + passed, as in '/assets/topsecret.mp4', a single video is loaded. + An array + + of strings can be used to load the same video in different formats. For + + example, ['/assets/topsecret.mp4', '/assets/topsecret.ogv', + '/assets/topsecret.webm']. + + This is useful for ensuring that the video can play across different browsers + with + + different capabilities. See + + MDN + + for more information about supported formats.

+ +

The second parameter, callback, is optional. It's a function + to call once + + the video is ready to play.

+line: 2115 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + noCanvas(); + + // Load a video and add it to the page. + // Note: this may not work in some browsers. + let video = createVideo('/assets/small.mp4'); + + // Show the default video controls. + video.showControls(); + + describe('A video of a toy robot with playback controls beneath it.'); + } + +
+ +
+ + function setup() { + noCanvas(); + + // Load a video and add it to the page. + // Provide an array options for different file formats. + let video = createVideo( + ['/assets/small.mp4', '/assets/small.ogv', '/assets/small.webm'] + ); + + // Show the default video controls. + video.showControls(); + + describe('A video of a toy robot with playback controls beneath it.'); + } + +
+ +
+ + let video; + + function setup() { + noCanvas(); + + // Load a video and add it to the page. + // Provide an array options for different file formats. + // Call mute() once the video loads. + video = createVideo( + ['/assets/small.mp4', '/assets/small.ogv', '/assets/small.webm'], + muteVideo + ); + + // Show the default video controls. + video.showControls(); + + describe('A video of a toy robot with playback controls beneath it.'); + } + + // Mute the video once it loads. + function muteVideo() { + video.volume(0); + } + +
+class: p5 +params: + - name: src + description: | +

path to a video file, or an array of paths for + supporting different browsers.

+ type: 'String|String[]' + - name: callback + description: | +

function to call once the video is ready to play.

+ type: Function + optional: true +return: + description: new p5.MediaElement object. + type: p5.MediaElement +chainable: false +--- + + +# createVideo diff --git a/src/content/reference/en/p5 copy/createWriter.mdx b/src/content/reference/en/p5 copy/createWriter.mdx new file mode 100644 index 0000000000..18928ff461 --- /dev/null +++ b/src/content/reference/en/p5 copy/createWriter.mdx @@ -0,0 +1,146 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1444 +title: createWriter +module: IO +submodule: Output +file: src/io/files.js +description: > +

Creates a new p5.PrintWriter + object.

+ +

p5.PrintWriter objects provide a + way to + + save a sequence of text data, called the print stream, to the user's + + computer. They're low-level objects that enable precise control of text + + output. Functions such as + + saveStrings() and + + saveJSON() are easier to use for simple + file + + saving.

+ +

The first parameter, filename, is the name of the file to be + written. If + + a string is passed, as in createWriter('words.txt'), a new + + p5.PrintWriter object will be + created that + + writes to a file named words.txt.

+ +

The second parameter, extension, is optional. If a string is + passed, as + + in createWriter('words', 'csv'), the first parameter will be + interpreted + + as the file name and the second parameter as the extension.

+line: 1444 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(12); + + // Display instructions. + text('Double-click to save', 5, 50, 90); + + describe('The text "Double-click to save" written in black on a gray background.'); + } + + // Save the file when the user double-clicks. + function doubleClicked() { + if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { + // Create a p5.PrintWriter object. + let myWriter = createWriter('xo.txt'); + + // Add some lines to the print stream. + myWriter.print('XOO'); + myWriter.print('OXO'); + myWriter.print('OOX'); + + // Save the file and close the print stream. + myWriter.close(); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(12); + + // Display instructions. + text('Double-click to save', 5, 50, 90); + + describe('The text "Double-click to save" written in black on a gray background.'); + } + + // Save the file when the user double-clicks. + function doubleClicked() { + if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { + // Create a p5.PrintWriter object. + // Use the file format .csv. + let myWriter = createWriter('mauna_loa_co2', 'csv'); + + // Add some lines to the print stream. + myWriter.print('date,ppm_co2'); + myWriter.print('1960-01-01,316.43'); + myWriter.print('1970-01-01,325.06'); + myWriter.print('1980-01-01,337.9'); + myWriter.print('1990-01-01,353.86'); + myWriter.print('2000-01-01,369.45'); + myWriter.print('2020-01-01,413.61'); + + // Save the file and close the print stream. + myWriter.close(); + } + } + +
+class: p5 +params: + - name: name + description: | +

name of the file to create.

+ type: String + - name: extension + description: | +

format to use for the file.

+ type: String + optional: true +return: + description: stream for writing data. + type: p5.PrintWriter +chainable: false +--- + + +# createWriter diff --git a/src/content/reference/en/p5 copy/cursor.mdx b/src/content/reference/en/p5 copy/cursor.mdx new file mode 100644 index 0000000000..8ada3a4379 --- /dev/null +++ b/src/content/reference/en/p5 copy/cursor.mdx @@ -0,0 +1,139 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L209 +title: cursor +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

Changes the cursor's appearance.

+ +

The first parameter, type, sets the type of cursor to display. + The + + built-in options are ARROW, CROSS, + HAND, MOVE, TEXT, and + WAIT. + + cursor() also recognizes standard CSS cursor properties passed as + + strings: 'help', 'wait', 'crosshair', + 'not-allowed', 'zoom-in', + + and 'grab'. If the path to an image is passed, as in + + cursor('/assets/target.png'), then the image will be used as the + cursor. + + Images must be in .cur, .gif, .jpg, .jpeg, or .png format and should be at + most 32 by 32 pixels large.

+ +

The parameters x and y are optional. If an image + is used for the + + cursor, x and y set the location pointed to within + the image. They are + + both 0 by default, so the cursor points to the image's top-left corner. + x + + and y must be less than the image's width and height, + respectively.

+line: 209 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A gray square. The cursor appears as crosshairs.'); + } + + function draw() { + background(200); + + // Set the cursor to crosshairs: + + cursor(CROSS); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A gray square divided into quadrants. The cursor image changes when the mouse moves to each quadrant.'); + } + + function draw() { + background(200); + + // Divide the canvas into quadrants. + line(50, 0, 50, 100); + line(0, 50, 100, 50); + + // Change cursor based on mouse position. + if (mouseX < 50 && mouseY < 50) { + cursor(CROSS); + } else if (mouseX > 50 && mouseY < 50) { + cursor('progress'); + } else if (mouseX > 50 && mouseY > 50) { + cursor('https://avatars0.githubusercontent.com/u/1617169?s=16'); + } else { + cursor('grab'); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('An image of three purple curves follows the mouse. The image shifts when the mouse is pressed.'); + } + + function draw() { + background(200); + + // Change the cursor's active spot + // when the mouse is pressed. + if (mouseIsPressed === true) { + cursor('https://avatars0.githubusercontent.com/u/1617169?s=16', 8, 8); + } else { + cursor('https://avatars0.githubusercontent.com/u/1617169?s=16'); + } + } + +
+class: p5 +params: + - name: type + description: | +

Built-in: either ARROW, CROSS, HAND, MOVE, TEXT, or WAIT. + Native CSS properties: 'grab', 'progress', and so on. + Path to cursor image.

+ type: String|Constant + - name: x + description: | +

horizontal active spot of the cursor.

+ type: Number + optional: true + - name: 'y' + description: | +

vertical active spot of the cursor.

+ type: Number + optional: true +chainable: false +--- + + +# cursor diff --git a/src/content/reference/en/p5 copy/curve.mdx b/src/content/reference/en/p5 copy/curve.mdx new file mode 100644 index 0000000000..9631e551e8 --- /dev/null +++ b/src/content/reference/en/p5 copy/curve.mdx @@ -0,0 +1,272 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L570 +title: curve +module: Shape +submodule: Curves +file: src/core/shape/curves.js +description: > +

Draws a curve using a Catmull-Rom spline.

+ +

Spline curves can form shapes and curves that slope gently. They’re like + + cables that are attached to a set of points. Splines are defined by two + + anchor points and two control points.

+ +

The first two parameters, x1 and y1, set the + first control point. This + + point isn’t drawn and can be thought of as the curve’s starting point.

+ +

The next four parameters, x2, y2, + x3, and y3, set the two anchor + + points. The anchor points are the start and end points of the curve’s + + visible segment.

+ +

The seventh and eighth parameters, x4 and y4, set + the last control + + point. This point isn’t drawn and can be thought of as the curve’s ending + + point.

+ +

Spline curves can also be drawn in 3D using WebGL mode. The 3D version of + + curve() has twelve arguments because each point has x-, y-, and + + z-coordinates.

+line: 570 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw a black spline curve. + noFill(); + strokeWeight(1); + stroke(0); + curve(5, 26, 73, 24, 73, 61, 15, 65); + + // Draw red spline curves from the anchor points to the control points. + stroke(255, 0, 0); + curve(5, 26, 5, 26, 73, 24, 73, 61); + curve(73, 24, 73, 61, 15, 65, 15, 65); + + // Draw the anchor points in black. + strokeWeight(5); + stroke(0); + point(73, 24); + point(73, 61); + + // Draw the control points in red. + stroke(255, 0, 0); + point(5, 26); + point(15, 65); + + describe( + 'A gray square with a curve drawn in three segments. The curve is a sideways U shape with red segments on top and bottom, and a black segment on the right. The endpoints of all the segments are marked with dots.' + ); + } + +
+ +
+ + let x1 = 5; + let y1 = 26; + let isChanging = false; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a curve drawn in three segments. The curve is a sideways U shape with red segments on top and bottom, and a black segment on the right. The endpoints of all the segments are marked with dots.' + ); + } + + function draw() { + background(200); + + // Draw a black spline curve. + noFill(); + strokeWeight(1); + stroke(0); + curve(x1, y1, 73, 24, 73, 61, 15, 65); + + // Draw red spline curves from the anchor points to the control points. + stroke(255, 0, 0); + curve(x1, y1, x1, y1, 73, 24, 73, 61); + curve(73, 24, 73, 61, 15, 65, 15, 65); + + // Draw the anchor points in black. + strokeWeight(5); + stroke(0); + point(73, 24); + point(73, 61); + + // Draw the control points in red. + stroke(255, 0, 0); + point(x1, y1); + point(15, 65); + } + + // Start changing the first control point if the user clicks near it. + function mousePressed() { + if (dist(mouseX, mouseY, x1, y1) < 20) { + isChanging = true; + } + } + + // Stop changing the first control point when the user releases the mouse. + function mouseReleased() { + isChanging = false; + } + + // Update the first control point while the user drags the mouse. + function mouseDragged() { + if (isChanging === true) { + x1 = mouseX; + y1 = mouseY; + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background('skyblue'); + + // Draw the red balloon. + fill('red'); + curve(-150, 275, 50, 60, 50, 60, 250, 275); + + // Draw the balloon string. + line(50, 60, 50, 80); + + describe('A red balloon in a blue sky.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A red balloon in a blue sky.'); + } + + function draw() { + background('skyblue'); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Draw the red balloon. + fill('red'); + curve(-200, 225, 0, 0, 10, 0, 0, 10, 0, 200, 225, 0); + + // Draw the balloon string. + line(0, 10, 0, 0, 30, 0); + } + +
+class: p5 +overloads: + - line: 570 + params: + - name: x1 + description: | +

x-coordinate of the first control point.

+ type: Number + - name: y1 + description: | +

y-coordinate of the first control point.

+ type: Number + - name: x2 + description: | +

x-coordinate of the first anchor point.

+ type: Number + - name: y2 + description: | +

y-coordinate of the first anchor point.

+ type: Number + - name: x3 + description: | +

x-coordinate of the second anchor point.

+ type: Number + - name: y3 + description: | +

y-coordinate of the second anchor point.

+ type: Number + - name: x4 + description: | +

x-coordinate of the second control point.

+ type: Number + - name: y4 + description: | +

y-coordinate of the second control point.

+ type: Number + chainable: 1 + - line: 746 + params: + - name: x1 + description: '' + type: Number + - name: y1 + description: '' + type: Number + - name: z1 + description: | +

z-coordinate of the first control point.

+ type: Number + - name: x2 + description: '' + type: Number + - name: y2 + description: '' + type: Number + - name: z2 + description: | +

z-coordinate of the first anchor point.

+ type: Number + - name: x3 + description: '' + type: Number + - name: y3 + description: '' + type: Number + - name: z3 + description: | +

z-coordinate of the second anchor point.

+ type: Number + - name: x4 + description: '' + type: Number + - name: y4 + description: '' + type: Number + - name: z4 + description: | +

z-coordinate of the second control point.

+ type: Number + chainable: 1 +chainable: true +--- + + +# curve diff --git a/src/content/reference/en/p5 copy/curveDetail.mdx b/src/content/reference/en/p5 copy/curveDetail.mdx new file mode 100644 index 0000000000..796ca5a026 --- /dev/null +++ b/src/content/reference/en/p5 copy/curveDetail.mdx @@ -0,0 +1,117 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L772 +title: curveDetail +module: Shape +submodule: Curves +file: src/core/shape/curves.js +description: > +

Sets the number of segments used to draw spline curves in WebGL mode.

+ +

In WebGL mode, smooth shapes are drawn using many flat segments. Adding + + more flat segments makes shapes appear smoother.

+ +

The parameter, detail, is the number of segments to use while + drawing a + + spline curve. For example, calling curveDetail(5) will use 5 + segments to + + draw curves with the curve() function. By + + default,detail is 20.

+ +

Note: curveDetail() has no effect in 2D mode.

+line: 772 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw a black spline curve. + noFill(); + strokeWeight(1); + stroke(0); + curve(5, 26, 73, 24, 73, 61, 15, 65); + + // Draw red spline curves from the anchor points to the control points. + stroke(255, 0, 0); + curve(5, 26, 5, 26, 73, 24, 73, 61); + curve(73, 24, 73, 61, 15, 65, 15, 65); + + // Draw the anchor points in black. + strokeWeight(5); + stroke(0); + point(73, 24); + point(73, 61); + + // Draw the control points in red. + stroke(255, 0, 0); + point(5, 26); + point(15, 65); + + describe( + 'A gray square with a curve drawn in three segments. The curve is a sideways U shape with red segments on top and bottom, and a black segment on the right. The endpoints of all the segments are marked with dots.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + // Set the curveDetail() to 3. + curveDetail(3); + + // Draw a black spline curve. + noFill(); + strokeWeight(1); + stroke(0); + curve(-45, -24, 0, 23, -26, 0, 23, 11, 0, -35, 15, 0); + + // Draw red spline curves from the anchor points to the control points. + stroke(255, 0, 0); + curve(-45, -24, 0, -45, -24, 0, 23, -26, 0, 23, 11, 0); + curve(23, -26, 0, 23, 11, 0, -35, 15, 0, -35, 15, 0); + + // Draw the anchor points in black. + strokeWeight(5); + stroke(0); + point(23, -26); + point(23, 11); + + // Draw the control points in red. + stroke(255, 0, 0); + point(-45, -24); + point(-35, 15); + + describe( + 'A gray square with a jagged curve drawn in three segments. The curve is a sideways U shape with red segments on top and bottom, and a black segment on the right. The endpoints of all the segments are marked with dots.' + ); + } + +
+class: p5 +params: + - name: resolution + description: | +

number of segments to use. Defaults to 20.

+ type: Number +chainable: true +--- + + +# curveDetail diff --git a/src/content/reference/en/p5 copy/curvePoint.mdx b/src/content/reference/en/p5 copy/curvePoint.mdx new file mode 100644 index 0000000000..761b468ca6 --- /dev/null +++ b/src/content/reference/en/p5 copy/curvePoint.mdx @@ -0,0 +1,160 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L930 +title: curvePoint +module: Shape +submodule: Curves +file: src/core/shape/curves.js +description: > +

Calculates coordinates along a spline curve using interpolation.

+ +

curvePoint() calculates coordinates along a spline curve using + the + + anchor and control points. It expects points in the same order as the + + curve() function. curvePoint() + works one axis + + at a time. Passing the anchor and control points' x-coordinates will + + calculate the x-coordinate of a point on the curve. Passing the anchor and + + control points' y-coordinates will calculate the y-coordinate of a point on + + the curve.

+ +

The first parameter, a, is the coordinate of the first control + point.

+ +

The second and third parameters, b and c, are the + coordinates of the + + anchor points.

+ +

The fourth parameter, d, is the coordinate of the last control + point.

+ +

The fifth parameter, t, is the amount to interpolate along the + curve. 0 + + is the first anchor point, 1 is the second anchor point, and 0.5 is halfway + + between them.

+line: 930 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Set the coordinates for the curve's anchor and control points. + let x1 = 5; + let y1 = 26; + let x2 = 73; + let y2 = 24; + let x3 = 73; + let y3 = 61; + let x4 = 15; + let y4 = 65; + + // Draw the curve. + noFill(); + curve(x1, y1, x2, y2, x3, y3, x4, y4); + + // Draw circles along the curve's path. + fill(255); + + // Top. + let x = curvePoint(x1, x2, x3, x4, 0); + let y = curvePoint(y1, y2, y3, y4, 0); + circle(x, y, 5); + + // Center. + x = curvePoint(x1, x2, x3, x4, 0.5); + y = curvePoint(y1, y2, y3, y4, 0.5); + circle(x, y, 5); + + // Bottom. + x = curvePoint(x1, x2, x3, x4, 1); + y = curvePoint(y1, y2, y3, y4, 1); + circle(x, y, 5); + + describe('A black curve on a gray square. The endpoints and center of the curve are marked with white circles.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A black curve on a gray square. A white circle moves back and forth along the curve.'); + } + + function draw() { + background(200); + + // Set the coordinates for the curve's anchor and control points. + let x1 = 5; + let y1 = 26; + let x2 = 73; + let y2 = 24; + let x3 = 73; + let y3 = 61; + let x4 = 15; + let y4 = 65; + + // Draw the curve. + noFill(); + curve(x1, y1, x2, y2, x3, y3, x4, y4); + + // Calculate the circle's coordinates. + let t = 0.5 * sin(frameCount * 0.01) + 0.5; + let x = curvePoint(x1, x2, x3, x4, t); + let y = curvePoint(y1, y2, y3, y4, t); + + // Draw the circle. + fill(255); + circle(x, y, 5); + } + +
+class: p5 +params: + - name: a + description: | +

coordinate of first control point.

+ type: Number + - name: b + description: | +

coordinate of first anchor point.

+ type: Number + - name: c + description: | +

coordinate of second anchor point.

+ type: Number + - name: d + description: | +

coordinate of second control point.

+ type: Number + - name: t + description: | +

amount to interpolate between 0 and 1.

+ type: Number +return: + description: coordinate of a point on the curve. + type: Number +chainable: false +--- + + +# curvePoint diff --git a/src/content/reference/en/p5 copy/curveTangent.mdx b/src/content/reference/en/p5 copy/curveTangent.mdx new file mode 100644 index 0000000000..005ade9aab --- /dev/null +++ b/src/content/reference/en/p5 copy/curveTangent.mdx @@ -0,0 +1,153 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L1054 +title: curveTangent +module: Shape +submodule: Curves +file: src/core/shape/curves.js +description: > +

Calculates coordinates along a line that's tangent to a spline curve.

+ +

Tangent lines skim the surface of a curve. A tangent line's slope equals + + the curve's slope at the point where it intersects.

+ +

curveTangent() calculates coordinates along a tangent line + using the + + spline curve's anchor and control points. It expects points in the same + + order as the curve() function. + curveTangent() + + works one axis at a time. Passing the anchor and control points' + + x-coordinates will calculate the x-coordinate of a point on the tangent + + line. Passing the anchor and control points' y-coordinates will calculate + + the y-coordinate of a point on the tangent line.

+ +

The first parameter, a, is the coordinate of the first control + point.

+ +

The second and third parameters, b and c, are the + coordinates of the + + anchor points.

+ +

The fourth parameter, d, is the coordinate of the last control + point.

+ +

The fifth parameter, t, is the amount to interpolate along the + curve. 0 + + is the first anchor point, 1 is the second anchor point, and 0.5 is halfway + + between them.

+line: 1054 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Set the coordinates for the curve's anchor and control points. + let x1 = 5; + let y1 = 26; + let x2 = 73; + let y2 = 24; + let x3 = 73; + let y3 = 61; + let x4 = 15; + let y4 = 65; + + // Draw the curve. + noFill(); + curve(x1, y1, x2, y2, x3, y3, x4, y4); + + // Draw tangents along the curve's path. + fill(255); + + // Top circle. + stroke(0); + let x = curvePoint(x1, x2, x3, x4, 0); + let y = curvePoint(y1, y2, y3, y4, 0); + circle(x, y, 5); + + // Top tangent line. + // Scale the tangent point to draw a shorter line. + stroke(255, 0, 0); + let tx = 0.2 * curveTangent(x1, x2, x3, x4, 0); + let ty = 0.2 * curveTangent(y1, y2, y3, y4, 0); + line(x + tx, y + ty, x - tx, y - ty); + + // Center circle. + stroke(0); + x = curvePoint(x1, x2, x3, x4, 0.5); + y = curvePoint(y1, y2, y3, y4, 0.5); + circle(x, y, 5); + + // Center tangent line. + // Scale the tangent point to draw a shorter line. + stroke(255, 0, 0); + tx = 0.2 * curveTangent(x1, x2, x3, x4, 0.5); + ty = 0.2 * curveTangent(y1, y2, y3, y4, 0.5); + line(x + tx, y + ty, x - tx, y - ty); + + // Bottom circle. + stroke(0); + x = curvePoint(x1, x2, x3, x4, 1); + y = curvePoint(y1, y2, y3, y4, 1); + circle(x, y, 5); + + // Bottom tangent line. + // Scale the tangent point to draw a shorter line. + stroke(255, 0, 0); + tx = 0.2 * curveTangent(x1, x2, x3, x4, 1); + ty = 0.2 * curveTangent(y1, y2, y3, y4, 1); + line(x + tx, y + ty, x - tx, y - ty); + + describe( + 'A black curve on a gray square. A white circle moves back and forth along the curve.' + ); + } + +
+class: p5 +params: + - name: a + description: | +

coordinate of first control point.

+ type: Number + - name: b + description: | +

coordinate of first anchor point.

+ type: Number + - name: c + description: | +

coordinate of second anchor point.

+ type: Number + - name: d + description: | +

coordinate of second control point.

+ type: Number + - name: t + description: | +

amount to interpolate between 0 and 1.

+ type: Number +return: + description: coordinate of a point on the tangent line. + type: Number +chainable: false +--- + + +# curveTangent diff --git a/src/content/reference/en/p5 copy/curveTightness.mdx b/src/content/reference/en/p5 copy/curveTightness.mdx new file mode 100644 index 0000000000..506066be18 --- /dev/null +++ b/src/content/reference/en/p5 copy/curveTightness.mdx @@ -0,0 +1,77 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L875 +title: curveTightness +module: Shape +submodule: Curves +file: src/core/shape/curves.js +description: > +

Adjusts the way curve() and + + curveVertex() draw.

+ +

Spline curves are like cables that are attached to a set of points. + + curveTightness() adjusts how tightly the cable is attached to the + points.

+ +

The parameter, tightness, determines how the curve fits to the + vertex + + points. By default, tightness is set to 0. Setting tightness to + 1, + + as in curveTightness(1), connects the curve's points using + straight + + lines. Values in the range from –5 to 5 deform curves while leaving them + + recognizable.

+line: 875 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Move the mouse left and right to see the curve change. + + function setup() { + createCanvas(100, 100); + + describe('A black curve forms a sideways U shape. The curve deforms as the user moves the mouse from left to right'); + } + + function draw() { + background(200); + + // Set the curve's tightness using the mouse. + let t = map(mouseX, 0, 100, -5, 5, true); + curveTightness(t); + + // Draw the curve. + noFill(); + beginShape(); + curveVertex(10, 26); + curveVertex(10, 26); + curveVertex(83, 24); + curveVertex(83, 61); + curveVertex(25, 65); + curveVertex(25, 65); + endShape(); + } + +
+class: p5 +params: + - name: amount + description: | +

amount of tightness.

+ type: Number +chainable: true +--- + + +# curveTightness diff --git a/src/content/reference/en/p5 copy/curveVertex.mdx b/src/content/reference/en/p5 copy/curveVertex.mdx new file mode 100644 index 0000000000..3d928fc0ce --- /dev/null +++ b/src/content/reference/en/p5 copy/curveVertex.mdx @@ -0,0 +1,407 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L832 +title: curveVertex +module: Shape +submodule: Vertex +file: src/core/shape/vertex.js +description: > +

Adds a spline curve segment to a custom shape.

+ +

curveVertex() adds a curved segment to custom shapes. The + spline curves + + it creates are defined like those made by the + + curve() function. + curveVertex() must be called + + between the beginShape() and + + endShape() functions.

+ +

Spline curves can form shapes and curves that slope gently. They’re like + + cables that are attached to a set of points. Splines are defined by two + + anchor points and two control points. curveVertex() must be + called at + + least four times between + + beginShape() and + + endShape() in order to draw a curve:

+ +
beginShape();
+
+
+  // Add the first control point.
+
+  curveVertex(84, 91);
+
+
+  // Add the anchor points to draw between.
+
+  curveVertex(68, 19);
+
+  curveVertex(21, 17);
+
+
+  // Add the second control point.
+
+  curveVertex(32, 91);
+
+
+  endShape();
+
+  
+ +

The code snippet above would only draw the curve between the anchor points, + + similar to the curve() function. The + segments + + between the control and anchor points can be drawn by calling + + curveVertex() with the coordinates of the control points:

+ +
beginShape();
+
+
+  // Add the first control point and draw a segment to it.
+
+  curveVertex(84, 91);
+
+  curveVertex(84, 91);
+
+
+  // Add the anchor points to draw between.
+
+  curveVertex(68, 19);
+
+  curveVertex(21, 17);
+
+
+  // Add the second control point.
+
+  curveVertex(32, 91);
+
+
+  // Uncomment the next line to draw the segment to the second control point.
+
+  // curveVertex(32, 91);
+
+
+  endShape();
+
+  
+ +

The first two parameters, x and y, set the + vertex’s location. For + + example, calling curveVertex(10, 10) adds a point to the curve at + + (10, 10).

+ +

Spline curves can also be drawn in 3D using WebGL mode. The 3D version of + + curveVertex() has three arguments because each point has x-, y-, + and + + z-coordinates. By default, the vertex’s z-coordinate is set to 0.

+ +

Note: curveVertex() won’t work when an argument is passed to + + beginShape().

+line: 832 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the shape. + noFill(); + strokeWeight(1); + + // Start drawing the shape. + beginShape(); + + // Add the first control point. + curveVertex(32, 91); + + // Add the anchor points. + curveVertex(21, 17); + curveVertex(68, 19); + + // Add the second control point. + curveVertex(84, 91); + + // Stop drawing the shape. + endShape(); + + // Style the anchor and control points. + strokeWeight(5); + + // Draw the anchor points in black. + stroke(0); + point(21, 17); + point(68, 19); + + // Draw the control points in red. + stroke(255, 0, 0); + point(32, 91); + point(84, 91); + + describe( + 'A black curve drawn on a gray background. The curve has black dots at its ends. Two red dots appear near the bottom of the canvas.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the shape. + noFill(); + strokeWeight(1); + + // Start drawing the shape. + beginShape(); + + // Add the first control point and draw a segment to it. + curveVertex(32, 91); + curveVertex(32, 91); + + // Add the anchor points. + curveVertex(21, 17); + curveVertex(68, 19); + + // Add the second control point. + curveVertex(84, 91); + + // Stop drawing the shape. + endShape(); + + // Style the anchor and control points. + strokeWeight(5); + + // Draw the anchor points in black. + stroke(0); + point(21, 17); + point(68, 19); + + // Draw the control points in red. + stroke(255, 0, 0); + point(32, 91); + point(84, 91); + + describe( + 'A black curve drawn on a gray background. The curve passes through one red dot and two black dots. Another red dot appears near the bottom of the canvas.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the shape. + noFill(); + strokeWeight(1); + + // Start drawing the shape. + beginShape(); + + // Add the first control point and draw a segment to it. + curveVertex(32, 91); + curveVertex(32, 91); + + // Add the anchor points. + curveVertex(21, 17); + curveVertex(68, 19); + + // Add the second control point and draw a segment to it. + curveVertex(84, 91); + curveVertex(84, 91); + + // Stop drawing the shape. + endShape(); + + // Style the anchor and control points. + strokeWeight(5); + + // Draw the anchor points in black. + stroke(0); + point(21, 17); + point(68, 19); + + // Draw the control points in red. + stroke(255, 0, 0); + point(32, 91); + point(84, 91); + + describe( + 'A black U curve drawn upside down on a gray background. The curve passes from one red dot through two black dots and ends at another red dot.' + ); + } + +
+ +
+ + // Click the mouse near the red dot in the bottom-left corner + // and drag to change the curve's shape. + + let x1 = 32; + let y1 = 91; + let isChanging = false; + + function setup() { + createCanvas(100, 100); + + describe( + 'A black U curve drawn upside down on a gray background. The curve passes from one red dot through two black dots and ends at another red dot.' + ); + } + + function draw() { + background(200); + + // Style the shape. + noFill(); + stroke(0); + strokeWeight(1); + + // Start drawing the shape. + beginShape(); + + // Add the first control point and draw a segment to it. + curveVertex(x1, y1); + curveVertex(x1, y1); + + // Add the anchor points. + curveVertex(21, 17); + curveVertex(68, 19); + + // Add the second control point and draw a segment to it. + curveVertex(84, 91); + curveVertex(84, 91); + + // Stop drawing the shape. + endShape(); + + // Style the anchor and control points. + strokeWeight(5); + + // Draw the anchor points in black. + stroke(0); + point(21, 17); + point(68, 19); + + // Draw the control points in red. + stroke(255, 0, 0); + point(x1, y1); + point(84, 91); + } + + // Start changing the first control point if the user clicks near it. + function mousePressed() { + if (dist(mouseX, mouseY, x1, y1) < 20) { + isChanging = true; + } + } + + // Stop changing the first control point when the user releases the mouse. + function mouseReleased() { + isChanging = false; + } + + // Update the first control point while the user drags the mouse. + function mouseDragged() { + if (isChanging === true) { + x1 = mouseX; + y1 = mouseY; + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + beginShape(); + + // Add the first control point and draw a segment to it. + curveVertex(32, 91); + curveVertex(32, 91); + + // Add the anchor points. + curveVertex(21, 17); + curveVertex(68, 19); + + // Add the second control point. + curveVertex(84, 91); + curveVertex(84, 91); + + // Stop drawing the shape. + endShape(); + + describe('A ghost shape drawn in white on a gray background.'); + } + +
+class: p5 +overloads: + - line: 832 + params: + - name: x + description: | +

x-coordinate of the vertex

+ type: Number + - name: 'y' + description: | +

y-coordinate of the vertex

+ type: Number + chainable: 1 + - line: 1160 + params: + - name: x + description: '' + type: Number + - name: 'y' + description: '' + type: Number + - name: z + description: | +

z-coordinate of the vertex.

+ type: Number + optional: true + chainable: 1 +chainable: true +--- + + +# curveVertex diff --git a/src/content/reference/en/p5 copy/cylinder.mdx b/src/content/reference/en/p5 copy/cylinder.mdx new file mode 100644 index 0000000000..dd81cd687f --- /dev/null +++ b/src/content/reference/en/p5 copy/cylinder.mdx @@ -0,0 +1,282 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L1477 +title: cylinder +module: Shape +submodule: 3D Primitives +file: src/webgl/3d_primitives.js +description: > +

Draws a cylinder.

+ +

A cylinder is a 3D shape with triangular faces that connect a flat bottom + + to a flat top. Cylinders with few faces look like boxes. Cylinders with + + many faces have smooth surfaces.

+ +

The first parameter, radius, is optional. If a + Number is passed, as in + + cylinder(20), it sets the radius of the cylinder’s base. By + default, + + radius is 50.

+ +

The second parameter, height, is also optional. If a + Number is passed, + + as in cylinder(20, 30), it sets the cylinder’s height. By + default, + + height is set to the cylinder’s radius.

+ +

The third parameter, detailX, is also optional. If a + Number is passed, + + as in cylinder(20, 30, 5), it sets the number of edges used to + form the + + cylinder's top and bottom. Using more edges makes the top and bottom look + + more like circles. By default, detailX is 24.

+ +

The fourth parameter, detailY, is also optional. If a + Number is passed, + + as in cylinder(20, 30, 5, 2), it sets the number of triangle + subdivisions + + to use along the y-axis, between cylinder's the top and bottom. All 3D + + shapes are made by connecting triangles to form their surfaces. By default, + + detailY is 1.

+ +

The fifth parameter, bottomCap, is also optional. If a + false is passed, + + as in cylinder(20, 30, 5, 2, false) the cylinder’s bottom won’t + be drawn. + + By default, bottomCap is true.

+ +

The sixth parameter, topCap, is also optional. If a + false is passed, as + + in cylinder(20, 30, 5, 2, false, false) the cylinder’s top won’t + be + + drawn. By default, topCap is true.

+ +

Note: cylinder() can only be used in WebGL mode.

+line: 1477 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cylinder on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cylinder. + cylinder(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cylinder on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cylinder. + // Set its radius and height to 30. + cylinder(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cylinder on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cylinder. + // Set its radius to 30 and height to 50. + cylinder(30, 50); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white box on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cylinder. + // Set its radius to 30 and height to 50. + // Set its detailX to 5. + cylinder(30, 50, 5); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cylinder on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cylinder. + // Set its radius to 30 and height to 50. + // Set its detailX to 24 and detailY to 2. + cylinder(30, 50, 24, 2); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cylinder on a gray background. Its top is missing.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cylinder. + // Set its radius to 30 and height to 50. + // Set its detailX to 24 and detailY to 1. + // Don't draw its bottom. + cylinder(30, 50, 24, 1, false); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cylinder on a gray background. Its top and bottom are missing.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the cylinder. + // Set its radius to 30 and height to 50. + // Set its detailX to 24 and detailY to 1. + // Don't draw its bottom or top. + cylinder(30, 50, 24, 1, false, false); + } + +
+class: p5 +params: + - name: radius + description: | +

radius of the cylinder. Defaults to 50.

+ type: Number + optional: true + - name: height + description: > +

height of the cylinder. Defaults to the value of + radius.

+ type: Number + optional: true + - name: detailX + description: | +

number of edges along the top and bottom. Defaults to 24.

+ type: Integer + optional: true + - name: detailY + description: | +

number of triangle subdivisions along the y-axis. Defaults to 1.

+ type: Integer + optional: true + - name: bottomCap + description: > +

whether to draw the cylinder's bottom. Defaults to + true.

+ type: Boolean + optional: true + - name: topCap + description: | +

whether to draw the cylinder's top. Defaults to true.

+ type: Boolean + optional: true +chainable: true +--- + + +# cylinder diff --git a/src/content/reference/en/p5 copy/day.mdx b/src/content/reference/en/p5 copy/day.mdx new file mode 100644 index 0000000000..f029fcb983 --- /dev/null +++ b/src/content/reference/en/p5 copy/day.mdx @@ -0,0 +1,47 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L10 +title: day +module: IO +submodule: Time & Date +file: src/utilities/time_date.js +description: | +

Returns the current day as a number from 1–31.

+line: 10 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Get the current day. + let d = day(); + + // Style the text. + textAlign(LEFT, CENTER); + textSize(12); + textFont('Courier New'); + + // Display the day. + text(`Current day: ${d}`, 20, 50, 60); + + describe(`The text 'Current day: ${d}' written in black on a gray background.`); + } + +
+class: p5 +return: + description: current day between 1 and 31. + type: Integer +chainable: false +--- + + +# day diff --git a/src/content/reference/en/p5 copy/debugMode.mdx b/src/content/reference/en/p5 copy/debugMode.mdx new file mode 100644 index 0000000000..19ccdfb63f --- /dev/null +++ b/src/content/reference/en/p5 copy/debugMode.mdx @@ -0,0 +1,362 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/interaction.js#L471 +title: debugMode +module: 3D +submodule: Interaction +file: src/webgl/interaction.js +description: > +

Adds a grid and an axes icon to clarify orientation in 3D sketches.

+ +

debugMode() adds a grid that shows where the “ground” is in a + sketch. By + + default, the grid will run through the origin (0, 0, 0) of the + sketch + + along the XZ plane. debugMode() also adds an axes icon that + points along + + the positive x-, y-, and z-axes. Calling debugMode() displays the + grid + + and axes icon with their default size and position.

+ +

There are four ways to call debugMode() with optional + parameters to + + customize the debugging environment.

+ +

The first way to call debugMode() has one parameter, + mode. If the + + system constant GRID is passed, as in + debugMode(GRID), then the grid + + will be displayed and the axes icon will be hidden. If the constant + AXES + + is passed, as in debugMode(AXES), then the axes icon will be + displayed + + and the grid will be hidden.

+ +

The second way to call debugMode() has six parameters. The + first + + parameter, mode, selects either GRID or + AXES to be displayed. The + + next five parameters, gridSize, gridDivisions, + xOff, yOff, and + + zOff are optional. They’re numbers that set the appearance of the + grid + + (gridSize and gridDivisions) and the placement of + the axes icon + + (xOff, yOff, and zOff). For example, + calling + + debugMode(20, 5, 10, 10, 10) sets the gridSize to 20 + pixels, the number + + of gridDivisions to 5, and offsets the axes icon by 10 pixels + along the + + x-, y-, and z-axes.

+ +

The third way to call debugMode() has five parameters. The + first + + parameter, mode, selects either GRID or + AXES to be displayed. The + + next four parameters, axesSize, xOff, + yOff, and zOff are optional. + + They’re numbers that set the appearance of the size of the axes icon + + (axesSize) and its placement (xOff, + yOff, and zOff).

+ +

The fourth way to call debugMode() has nine optional + parameters. The + + first five parameters, gridSize, gridDivisions, + gridXOff, gridYOff, + + and gridZOff are numbers that set the appearance of the grid. For + + example, calling debugMode(100, 5, 0, 0, 0) sets the + gridSize to 100, + + the number of gridDivisions to 5, and sets all the offsets to 0 + so that + + the grid is centered at the origin. The next four parameters, + axesSize, + + xOff, yOff, and zOff are numbers that + set the appearance of the size + + of the axes icon (axesSize) and its placement + (axesXOff, axesYOff, + + and axesZOff). For example, calling + + debugMode(100, 5, 0, 0, 0, 50, 10, 10, 10) sets the + gridSize to 100, + + the number of gridDivisions to 5, and sets all the offsets to 0 + so that + + the grid is centered at the origin. It then sets the axesSize to + 50 and + + offsets the icon 10 pixels along each axis.

+line: 471 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + // Enable debug mode. + debugMode(); + + describe('A multicolor box on a gray background. A grid and axes icon are displayed near the box.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the box. + normalMaterial(); + + // Draw the box. + box(20, 40); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + // Enable debug mode. + // Only display the axes icon. + debugMode(AXES); + + describe('A multicolor box on a gray background. A grid and axes icon are displayed near the box.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the box. + normalMaterial(); + + // Draw the box. + box(20, 40); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + // Enable debug mode. + // Only display the grid and customize it: + // - size: 50 + // - divisions: 10 + // - offsets: 0, 20, 0 + debugMode(GRID, 50, 10, 0, 20, 0); + + describe('A multicolor box on a gray background. A grid is displayed below the box.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the box. + normalMaterial(); + + // Draw the box. + box(20, 40); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + // Enable debug mode. + // Display the grid and axes icon and customize them: + // Grid + // ---- + // - size: 50 + // - divisions: 10 + // - offsets: 0, 20, 0 + // Axes + // ---- + // - size: 50 + // - offsets: 0, 0, 0 + debugMode(50, 10, 0, 20, 0, 50, 0, 0, 0); + + describe('A multicolor box on a gray background. A grid is displayed below the box. An axes icon is displayed at the center of the box.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the box. + normalMaterial(); + + // Draw the box. + box(20, 40); + } + +
+class: p5 +overloads: + - line: 471 + params: [] + - line: 650 + params: + - name: mode + description: | +

either GRID or AXES

+ type: Constant + - line: 655 + params: + - name: mode + description: '' + type: Constant + - name: gridSize + description: | +

side length of the grid.

+ type: Number + optional: true + - name: gridDivisions + description: | +

number of divisions in the grid.

+ type: Number + optional: true + - name: xOff + description: | +

offset from origin along the x-axis.

+ type: Number + optional: true + - name: yOff + description: | +

offset from origin along the y-axis.

+ type: Number + optional: true + - name: zOff + description: | +

offset from origin along the z-axis.

+ type: Number + optional: true + - line: 665 + params: + - name: mode + description: '' + type: Constant + - name: axesSize + description: | +

length of axes icon markers.

+ type: Number + optional: true + - name: xOff + description: '' + type: Number + optional: true + - name: yOff + description: '' + type: Number + optional: true + - name: zOff + description: '' + type: Number + optional: true + - line: 674 + params: + - name: gridSize + description: '' + type: Number + optional: true + - name: gridDivisions + description: '' + type: Number + optional: true + - name: gridXOff + description: | +

grid offset from the origin along the x-axis.

+ type: Number + optional: true + - name: gridYOff + description: | +

grid offset from the origin along the y-axis.

+ type: Number + optional: true + - name: gridZOff + description: | +

grid offset from the origin along the z-axis.

+ type: Number + optional: true + - name: axesSize + description: '' + type: Number + optional: true + - name: axesXOff + description: | +

axes icon offset from the origin along the x-axis.

+ type: Number + optional: true + - name: axesYOff + description: | +

axes icon offset from the origin along the y-axis.

+ type: Number + optional: true + - name: axesZOff + description: | +

axes icon offset from the origin along the z-axis.

+ type: Number + optional: true +chainable: false +--- + + +# debugMode diff --git a/src/content/reference/en/p5 copy/degrees.mdx b/src/content/reference/en/p5 copy/degrees.mdx new file mode 100644 index 0000000000..730b361384 --- /dev/null +++ b/src/content/reference/en/p5 copy/degrees.mdx @@ -0,0 +1,53 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L485 +title: degrees +module: Math +submodule: Trigonometry +file: src/math/trigonometry.js +description: | +

Converts an angle measured in radians to its value in degrees.

+

Degrees and radians are both units for measuring angles. There are 360˚ in + one full rotation. A full rotation is 2 × π (about 6.28) radians.

+

The same angle can be expressed in with either unit. For example, 90° is a + quarter of a full rotation. The same angle is 2 × π ÷ 4 + (about 1.57) radians.

+line: 485 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Calculate the angle conversion. + let rad = QUARTER_PI; + let deg = degrees(rad); + + // Display the conversion. + text(`${round(rad, 2)} rad = ${deg}˚`, 10, 50); + + describe('The text "0.79 rad = 45˚".'); + } + +
+class: p5 +params: + - name: radians + description: | +

radians value to convert to degrees.

+ type: Number +return: + description: converted angle. + type: Number +chainable: false +--- + + +# degrees diff --git a/src/content/reference/en/p5 copy/deltaTime.mdx b/src/content/reference/en/p5 copy/deltaTime.mdx new file mode 100644 index 0000000000..0915a014c2 --- /dev/null +++ b/src/content/reference/en/p5 copy/deltaTime.mdx @@ -0,0 +1,68 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L124 +title: deltaTime +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

A Number variable that tracks the number of milliseconds it + took to draw + + the last frame.

+ +

deltaTime contains the amount of time it took + + draw() to execute during the previous frame. + It's + + useful for simulating physics.

+line: 124 +isConstructor: false +itemtype: property +example: + - |- + +
+ + let x = 0; + let speed = 0.05; + + function setup() { + createCanvas(100, 100); + + // Set the frameRate to 30. + frameRate(30); + + describe('A white circle moves from left to right on a gray background. It reappears on the left side when it reaches the right side.'); + } + + function draw() { + background(200); + + // Use deltaTime to calculate + // a change in position. + let deltaX = speed * deltaTime; + + // Update the x variable. + x += deltaX; + + // Reset x to 0 if it's + // greater than 100. + if (x > 100) { + x = 0; + } + + // Use x to set the circle's + // position. + circle(x, 50, 20); + } + +
+class: p5 +type: Integer +--- + + +# deltaTime diff --git a/src/content/reference/en/p5 copy/describe.mdx b/src/content/reference/en/p5 copy/describe.mdx new file mode 100644 index 0000000000..dee815b9f1 --- /dev/null +++ b/src/content/reference/en/p5 copy/describe.mdx @@ -0,0 +1,137 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/accessibility/describe.js#L18 +title: describe +module: Environment +submodule: Environment +file: src/accessibility/describe.js +description: > +

Creates a screen reader-accessible description of the canvas.

+ +

The first parameter, text, is the description of the + canvas.

+ +

The second parameter, display, is optional. It determines how + the + + description is displayed. If LABEL is passed, as in + + describe('A description.', LABEL), the description will be + visible in + + a div element next to the canvas. If FALLBACK is passed, as in + + describe('A description.', FALLBACK), the description will only + be + + visible to screen readers. This is the default mode.

+ +

Read + + Writing + accessible canvas descriptions + + to learn more about making sketches accessible.

+line: 18 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + background('pink'); + + // Draw a heart. + fill('red'); + noStroke(); + circle(67, 67, 20); + circle(83, 67, 20); + triangle(91, 73, 75, 95, 59, 73); + + // Add a general description of the canvas. + describe('A pink square with a red heart in the bottom-right corner.'); + } + +
+ +
+ + function setup() { + background('pink'); + + // Draw a heart. + fill('red'); + noStroke(); + circle(67, 67, 20); + circle(83, 67, 20); + triangle(91, 73, 75, 95, 59, 73); + + // Add a general description of the canvas + // and display it for debugging. + describe('A pink square with a red heart in the bottom-right corner.', LABEL); + } + +
+ +
+ + function draw() { + background(200); + + // The expression + // frameCount % 100 + // causes x to increase from 0 + // to 99, then restart from 0. + let x = frameCount % 100; + + // Draw the circle. + fill(0, 255, 0); + circle(x, 50, 40); + + // Add a general description of the canvas. + describe(`A green circle at (${x}, 50) moves from left to right on a gray square.`); + } + +
+ +
+ + function draw() { + background(200); + + // The expression + // frameCount % 100 + // causes x to increase from 0 + // to 99, then restart from 0. + let x = frameCount % 100; + + // Draw the circle. + fill(0, 255, 0); + circle(x, 50, 40); + + // Add a general description of the canvas + // and display it for debugging. + describe(`A green circle at (${x}, 50) moves from left to right on a gray square.`, LABEL); + } + +
+class: p5 +params: + - name: text + description: | +

description of the canvas.

+ type: String + - name: display + description: | +

either LABEL or FALLBACK.

+ type: Constant + optional: true +chainable: false +--- + + +# describe diff --git a/src/content/reference/en/p5 copy/describeElement.mdx b/src/content/reference/en/p5 copy/describeElement.mdx new file mode 100644 index 0000000000..0b7bc8b330 --- /dev/null +++ b/src/content/reference/en/p5 copy/describeElement.mdx @@ -0,0 +1,127 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/accessibility/describe.js#L162 +title: describeElement +module: Environment +submodule: Environment +file: src/accessibility/describe.js +description: > +

Creates a screen reader-accessible description of elements in the + canvas.

+ +

Elements are shapes or groups of shapes that create meaning together. For + + example, a few overlapping circles could make an "eye" element.

+ +

The first parameter, name, is the name of the element.

+ +

The second parameter, text, is the description of the + element.

+ +

The third parameter, display, is optional. It determines how + the + + description is displayed. If LABEL is passed, as in + + describe('A description.', LABEL), the description will be + visible in + + a div element next to the canvas. Using LABEL creates unhelpful + + duplicates for screen readers. Only use LABEL during development. + If + + FALLBACK is passed, as in describe('A description.', + FALLBACK), the + + description will only be visible to screen readers. This is the default + + mode.

+ +

Read + + Writing + accessible canvas descriptions + + to learn more about making sketches accessible.

+line: 162 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + background('pink'); + + // Describe the first element + // and draw it. + describeElement('Circle', 'A yellow circle in the top-left corner.'); + noStroke(); + fill('yellow'); + circle(25, 25, 40); + + // Describe the second element + // and draw it. + describeElement('Heart', 'A red heart in the bottom-right corner.'); + fill('red'); + circle(66.6, 66.6, 20); + circle(83.2, 66.6, 20); + triangle(91.2, 72.6, 75, 95, 58.6, 72.6); + + // Add a general description of the canvas. + describe('A red heart and yellow circle over a pink background.'); + } + +
+ +
+ + function setup() { + background('pink'); + + // Describe the first element + // and draw it. Display the + // description for debugging. + describeElement('Circle', 'A yellow circle in the top-left corner.', LABEL); + noStroke(); + fill('yellow'); + circle(25, 25, 40); + + // Describe the second element + // and draw it. Display the + // description for debugging. + describeElement('Heart', 'A red heart in the bottom-right corner.', LABEL); + fill('red'); + circle(66.6, 66.6, 20); + circle(83.2, 66.6, 20); + triangle(91.2, 72.6, 75, 95, 58.6, 72.6); + + // Add a general description of the canvas. + describe('A red heart and yellow circle over a pink background.'); + } + +
+class: p5 +params: + - name: name + description: | +

name of the element.

+ type: String + - name: text + description: | +

description of the element.

+ type: String + - name: display + description: | +

either LABEL or FALLBACK.

+ type: Constant + optional: true +chainable: false +--- + + +# describeElement diff --git a/src/content/reference/en/p5 copy/deviceMoved.mdx b/src/content/reference/en/p5 copy/deviceMoved.mdx new file mode 100644 index 0000000000..90e9ce91fb --- /dev/null +++ b/src/content/reference/en/p5 copy/deviceMoved.mdx @@ -0,0 +1,49 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L501 +title: deviceMoved +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

The deviceMoved() function is + called when the device is moved by more than + + the threshold value along X, Y or Z axis. The default threshold is set to 0.5. + + The threshold value can be changed using setMoveThreshold().

+line: 501 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Run this example on a mobile device + // Move the device around + // to change the value. + + let value = 0; + 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; + if (value > 255) { + value = 0; + } + } + +
+class: p5 +chainable: false +--- + + +# deviceMoved diff --git a/src/content/reference/en/p5 copy/deviceOrientation.mdx b/src/content/reference/en/p5 copy/deviceOrientation.mdx new file mode 100644 index 0000000000..a18763fc87 --- /dev/null +++ b/src/content/reference/en/p5 copy/deviceOrientation.mdx @@ -0,0 +1,22 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L11 +title: deviceOrientation +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: | +

The system variable deviceOrientation always contains the orientation of + the device. The value of this variable will either be set 'landscape' + or 'portrait'. If no data is available it will be set to 'undefined'. + either LANDSCAPE or PORTRAIT.

+line: 11 +isConstructor: false +itemtype: property +class: p5 +type: Constant +--- + + +# deviceOrientation diff --git a/src/content/reference/en/p5 copy/deviceShaken.mdx b/src/content/reference/en/p5 copy/deviceShaken.mdx new file mode 100644 index 0000000000..0c1cce17f8 --- /dev/null +++ b/src/content/reference/en/p5 copy/deviceShaken.mdx @@ -0,0 +1,50 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L589 +title: deviceShaken +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

The deviceShaken() function is + called when the device total acceleration + + changes of accelerationX and accelerationY values is more than + + the threshold value. The default threshold is set to 30. + + The threshold value can be changed using setShakeThreshold().

+line: 589 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Run this example on a mobile device + // Shake the device to change the value. + + let value = 0; + 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; + if (value > 255) { + value = 0; + } + } + +
+class: p5 +chainable: false +--- + + +# deviceShaken diff --git a/src/content/reference/en/p5 copy/deviceTurned.mdx b/src/content/reference/en/p5 copy/deviceTurned.mdx new file mode 100644 index 0000000000..28f760eb6f --- /dev/null +++ b/src/content/reference/en/p5 copy/deviceTurned.mdx @@ -0,0 +1,80 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L531 +title: deviceTurned +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

The deviceTurned() function is + called when the device rotates by + + more than 90 degrees continuously.

+ +

The axis that triggers the deviceTurned() method is stored in the + turnAxis + + variable. The deviceTurned() method + can be locked to trigger on any axis: + + X, Y or Z by comparing the turnAxis variable to 'X', 'Y' or 'Z'.

+line: 531 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Run this example on a mobile device + // Rotate the device by 90 degrees + // to change the value. + + let value = 0; + 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) { + value = 255; + } else if (value === 255) { + value = 0; + } + } + +
+
+ + // Run this example on a mobile device + // Rotate the device by 90 degrees in the + // X-axis to change the value. + + let value = 0; + 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') { + if (value === 0) { + value = 255; + } else if (value === 255) { + value = 0; + } + } + } + +
+class: p5 +chainable: false +--- + + +# deviceTurned diff --git a/src/content/reference/en/p5 copy/directionalLight.mdx b/src/content/reference/en/p5 copy/directionalLight.mdx new file mode 100644 index 0000000000..b2b3e011a3 --- /dev/null +++ b/src/content/reference/en/p5 copy/directionalLight.mdx @@ -0,0 +1,277 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L461 +title: directionalLight +module: 3D +submodule: Lights +file: src/webgl/light.js +description: > +

Creates a light that shines in one direction.

+ +

Directional lights don’t shine from a specific point. They’re like a sun + + that shines from somewhere offscreen. The light’s direction is set using + + three (x, y, z) values between -1 and 1. For example, setting a + light’s + + direction as (1, 0, 0) will light p5.Geometry + + objects from the left since the light faces directly to the right. A + + maximum of 5 directional lights can be active at once.

+ +

There are four ways to call directionalLight() with parameters + to set the + + light’s color and direction.

+ +

The first way to call directionalLight() has six parameters. + The first + + three parameters, v1, v2, and v3, set + the light’s color using the + + current colorMode(). The last three + + parameters, x, y, and z, set the + light’s direction. For example, + + directionalLight(255, 0, 0, 1, 0, 0) creates a red (255, 0, + 0) light + + that shines to the right (1, 0, 0).

+ +

The second way to call directionalLight() has four parameters. + The first + + three parameters, v1, v2, and v3, set + the light’s color using the + + current colorMode(). The last + parameter, + + direction sets the light’s direction using a + p5.Vector object. For example, + directionalLight(255, 0, 0, lightDir) creates a red (255, + 0, 0) light + + that shines in the direction the lightDir vector points.

+ +

The third way to call directionalLight() has four parameters. + The first + + parameter, color, sets the light’s color using a + + p5.Color object or an array of color + values. The + + last three parameters, x, y, and z, set + the light’s direction. For + + example, directionalLight(myColor, 1, 0, 0) creates a light that + shines + + to the right (1, 0, 0) with the color value of + myColor.

+ +

The fourth way to call directionalLight() has two parameters. + The first + + parameter, color, sets the light’s color using a + + p5.Color object or an array of color + values. The + + second parameter, direction, sets the light’s direction using a + + p5.Color object. For example, + + directionalLight(myColor, lightDir) creates a light that shines + in the + + direction the lightDir vector points with the color value of + myColor.

+line: 461 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click to turn on the directional light. + + let isLit = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A sphere drawn on a gray background. A red light starts shining from above when the user double-clicks.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Control the light. + if (isLit === true) { + // Add a red directional light from above. + // Use RGB values and XYZ directions. + directionalLight(255, 0, 0, 0, 1, 0); + } + + // Style the sphere. + noStroke(); + + // Draw the sphere. + sphere(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Add a red directional light from above. + // Use a p5.Color object and XYZ directions. + let c = color(255, 0, 0); + directionalLight(c, 0, 1, 0); + + // Style the sphere. + noStroke(); + + // Draw the sphere. + sphere(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Add a red directional light from above. + // Use a p5.Color object and a p5.Vector object. + let c = color(255, 0, 0); + let lightDir = createVector(0, 1, 0); + directionalLight(c, lightDir); + + // Style the sphere. + noStroke(); + + // Draw the sphere. + sphere(30); + } + +
+class: p5 +overloads: + - line: 461 + params: + - name: v1 + description: | +

red or hue value in the current + colorMode().

+ type: Number + - name: v2 + description: | +

green or saturation value in the current + colorMode().

+ type: Number + - name: v3 + description: | +

blue, brightness, or lightness value in the current + colorMode().

+ type: Number + - name: x + description: | +

x-component of the light's direction between -1 and 1.

+ type: Number + - name: 'y' + description: | +

y-component of the light's direction between -1 and 1.

+ type: Number + - name: z + description: | +

z-component of the light's direction between -1 and 1.

+ type: Number + chainable: 1 + - line: 614 + params: + - name: v1 + description: '' + type: Number + - name: v2 + description: '' + type: Number + - name: v3 + description: '' + type: Number + - name: direction + description: | +

direction of the light as a + p5.Vector object.

+ type: p5.Vector + chainable: 1 + - line: 624 + params: + - name: color + description: | +

color as a p5.Color object, + an array of color values, or as a CSS string.

+ type: 'p5.Color|Number[]|String' + - name: x + description: '' + type: Number + - name: 'y' + description: '' + type: Number + - name: z + description: '' + type: Number + chainable: 1 + - line: 634 + params: + - name: color + description: '' + type: 'p5.Color|Number[]|String' + - name: direction + description: '' + type: p5.Vector + chainable: 1 +chainable: true +--- + + +# directionalLight diff --git a/src/content/reference/en/p5 copy/disableFriendlyErrors.mdx b/src/content/reference/en/p5 copy/disableFriendlyErrors.mdx new file mode 100644 index 0000000000..a72ec28678 --- /dev/null +++ b/src/content/reference/en/p5 copy/disableFriendlyErrors.mdx @@ -0,0 +1,55 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L872 +title: disableFriendlyErrors +module: Structure +submodule: Structure +file: src/core/main.js +description: > +

Turns off the parts of the Friendly Error System (FES) that impact + performance.

+ +

The FES + + can cause sketches to draw slowly because it does extra work behind the + + scenes. For example, the FES checks the arguments passed to functions, + + which takes time to process. Disabling the FES can significantly improve + + performance by turning off these checks.

+line: 872 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // Disable the FES. + p5.disableFriendlyErrors = true; + + function setup() { + createCanvas(100, 100); + + background(200); + + // The circle() function requires three arguments. The + // next line would normally display a friendly error that + // points this out. Instead, nothing happens and it fails + // silently. + circle(50, 50); + + describe('A gray square.'); + } + +
+class: p5 +type: Boolean +--- + + +# disableFriendlyErrors diff --git a/src/content/reference/en/p5 copy/displayDensity.mdx b/src/content/reference/en/p5 copy/displayDensity.mdx new file mode 100644 index 0000000000..e52be83ec2 --- /dev/null +++ b/src/content/reference/en/p5 copy/displayDensity.mdx @@ -0,0 +1,55 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L1078 +title: displayDensity +module: Environment +submodule: Environment +file: src/core/environment.js +description: | +

Returns the display's current pixel density.

+line: 1078 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + // Set the pixel density to 1. + pixelDensity(1); + + // Create a canvas and draw + // a circle. + createCanvas(100, 100); + background(200); + circle(50, 50, 70); + + describe('A fuzzy white circle drawn on a gray background. The circle becomes sharper when the mouse is pressed.'); + } + + function mousePressed() { + // Get the current display density. + let d = displayDensity(); + + // Use the display density to set + // the sketch's pixel density. + pixelDensity(d); + + // Paint the background and + // draw a circle. + background(200); + circle(50, 50, 70); + } + +
+class: p5 +return: + description: current pixel density of the display. + type: Number +chainable: false +--- + + +# displayDensity diff --git a/src/content/reference/en/p5 copy/displayHeight.mdx b/src/content/reference/en/p5 copy/displayHeight.mdx new file mode 100644 index 0000000000..d392419e70 --- /dev/null +++ b/src/content/reference/en/p5 copy/displayHeight.mdx @@ -0,0 +1,47 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L621 +title: displayHeight +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

A Number variable that stores the height of the screen + display.

+ +

displayHeight is useful for running full-screen programs. Its + value + + depends on the current pixelDensity().

+ +

Note: The actual screen height can be computed as + + displayHeight * pixelDensity().

+line: 621 +isConstructor: false +itemtype: property +alt: This example does not render anything. +example: + - |- + +
+ + function setup() { + // Set the canvas' width and height + // using the display's dimensions. + createCanvas(displayWidth, displayHeight); + + background(200); + + describe('A gray canvas that is the same size as the display.'); + } + +
+class: p5 +type: Number +--- + + +# displayHeight diff --git a/src/content/reference/en/p5 copy/displayWidth.mdx b/src/content/reference/en/p5 copy/displayWidth.mdx new file mode 100644 index 0000000000..9ab79a09db --- /dev/null +++ b/src/content/reference/en/p5 copy/displayWidth.mdx @@ -0,0 +1,47 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L590 +title: displayWidth +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

A Number variable that stores the width of the screen + display.

+ +

displayWidth is useful for running full-screen programs. Its + value + + depends on the current pixelDensity().

+ +

Note: The actual screen width can be computed as + + displayWidth * pixelDensity().

+line: 590 +isConstructor: false +itemtype: property +alt: This example does not render anything. +example: + - |- + +
+ + function setup() { + // Set the canvas' width and height + // using the display's dimensions. + createCanvas(displayWidth, displayHeight); + + background(200); + + describe('A gray canvas that is the same size as the display.'); + } + +
+class: p5 +type: Number +--- + + +# displayWidth diff --git a/src/content/reference/en/p5 copy/dist.mdx b/src/content/reference/en/p5 copy/dist.mdx new file mode 100644 index 0000000000..60b7155b9b --- /dev/null +++ b/src/content/reference/en/p5 copy/dist.mdx @@ -0,0 +1,121 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L155 +title: dist +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Calculates the distance between two points.

+ +

The version of dist() with four parameters calculates distance + in two + + dimensions.

+ +

The version of dist() with six parameters calculates distance + in three + + dimensions.

+ +

Use p5.Vector.dist() to calculate + the + + distance between two p5.Vector + objects.

+line: 155 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Set the coordinates. + let x1 = 10; + let y1 = 50; + let x2 = 90; + let y2 = 50; + + // Draw the points and a line connecting them. + line(x1, y1, x2, y2); + strokeWeight(5); + point(x1, y1); + point(x2, y2); + + // Calculate the distance. + let d = dist(x1, y1, x2, y2); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the distance. + text(d, 43, 40); + + describe('Two dots connected by a horizontal line. The number 80 is written above the center of the line.'); + } + +
+class: p5 +return: + description: distance between the two points. + type: Number +overloads: + - line: 155 + params: + - name: x1 + description: | +

x-coordinate of the first point.

+ type: Number + - name: y1 + description: | +

y-coordinate of the first point.

+ type: Number + - name: x2 + description: | +

x-coordinate of the second point.

+ type: Number + - name: y2 + description: | +

y-coordinate of the second point.

+ type: Number + return: + description: distance between the two points. + type: Number + - line: 209 + params: + - name: x1 + description: '' + type: Number + - name: y1 + description: '' + type: Number + - name: z1 + description: | +

z-coordinate of the first point.

+ type: Number + - name: x2 + description: '' + type: Number + - name: y2 + description: '' + type: Number + - name: z2 + description: | +

z-coordinate of the second point.

+ type: Number + return: + description: distance between the two points. + type: Number +chainable: false +--- + + +# dist diff --git a/src/content/reference/en/p5 copy/doubleClicked.mdx b/src/content/reference/en/p5 copy/doubleClicked.mdx new file mode 100644 index 0000000000..3e148c677f --- /dev/null +++ b/src/content/reference/en/p5 copy/doubleClicked.mdx @@ -0,0 +1,157 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1599 +title: doubleClicked +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A function that's called once when a mouse button is clicked twice + quickly.

+ +

Declaring the function doubleClicked() sets a code block to + run + + automatically when the user presses and releases the mouse button twice + + quickly:

+ +
function doubleClicked() {
+    // Code to run.
+  }
+
+  
+ +

The mouse system variables, such as mouseX and + + mouseY, will be updated with their most + recent + + value when doubleClicked() is called by p5.js:

+ +
function doubleClicked() {
+    if (mouseX < 50) {
+      // Code to run if the mouse is on the left.
+    }
+
+    if (mouseY > 50) {
+      // Code to run if the mouse is near the bottom.
+    }
+  }
+
+  
+ +

The parameter, event, is optional. + doubleClicked() is always passed a + + MouseEvent + + object with properties that describe the double-click event:

+ +
function doubleClicked(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

On touchscreen devices, code placed in doubleClicked() will + run after two + + touches that occur within a short time.

+ +

Browsers may have default behaviors attached to various mouse events. For + + example, some browsers highlight text when the user moves the mouse while + + pressing a mouse button. To prevent any default behavior for this event, + + add return false; to the end of the function.

+line: 1599 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square changes color when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Toggle the square's color when the user double-clicks. + function doubleClicked() { + if (value === 0) { + value = 255; + } else { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+ +
+ + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black circle at its center. When the user double-clicks on the circle, it changes color to white.' + ); + } + + function draw() { + background(200); + + // Style the circle. + fill(value); + + // Draw the circle. + circle(50, 50, 80); + } + + // Reassign value to 255 when the user double-clicks on the circle. + function doubleClicked() { + if (dist(50, 50, mouseX, mouseY) < 40) { + value = 255; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+class: p5 +params: + - name: event + description: | +

optional MouseEvent argument.

+ type: MouseEvent + optional: true +chainable: false +--- + + +# doubleClicked diff --git a/src/content/reference/en/p5 copy/draw.mdx b/src/content/reference/en/p5 copy/draw.mdx new file mode 100644 index 0000000000..dba2e2b44a --- /dev/null +++ b/src/content/reference/en/p5 copy/draw.mdx @@ -0,0 +1,129 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L176 +title: draw +module: Structure +submodule: Structure +file: src/core/main.js +description: > +

A function that's called repeatedly while the sketch runs.

+ +

Declaring the function draw() sets a code block to run + repeatedly + + once the sketch starts. It’s used to create animations and respond to + + user inputs:

+ +
function draw() {
+    // Code to run repeatedly.
+  }
+
+  
+ +

This is often called the "draw loop" because p5.js calls the code in + + draw() in a loop behind the scenes. By default, + draw() tries to run + + 60 times per second. The actual rate depends on many factors. The + + drawing rate, called the "frame rate", can be controlled by calling + + frameRate(). The number of times + draw() + + has run is stored in the system variable + + frameCount().

+ +

Code placed within draw() begins looping after + + setup() runs. draw() will run + until the user + + closes the sketch. draw() can be stopped by calling the + + noLoop() function. draw() can + be resumed by + + calling the loop() function.

+line: 176 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Paint the background once. + background(200); + + describe( + 'A white circle on a gray background. The circle follows the mouse as the user moves, leaving a trail.' + ); + } + + function draw() { + // Draw circles repeatedly. + circle(mouseX, mouseY, 40); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A white circle on a gray background. The circle follows the mouse as the user moves.' + ); + } + + function draw() { + // Paint the background repeatedly. + background(200); + + // Draw circles repeatedly. + circle(mouseX, mouseY, 40); + } + +
+ +
+ + // Double-click the canvas to change the circle's color. + + function setup() { + createCanvas(100, 100); + + describe( + 'A white circle on a gray background. The circle follows the mouse as the user moves. The circle changes color to pink when the user double-clicks.' + ); + } + + function draw() { + // Paint the background repeatedly. + background(200); + + // Draw circles repeatedly. + circle(mouseX, mouseY, 40); + } + + // Change the fill color when the user double-clicks. + function doubleClicked() { + fill('deeppink'); + } + +
+class: p5 +chainable: false +--- + + +# draw diff --git a/src/content/reference/en/p5 copy/drawingContext.mdx b/src/content/reference/en/p5 copy/drawingContext.mdx new file mode 100644 index 0000000000..3cf1335733 --- /dev/null +++ b/src/content/reference/en/p5 copy/drawingContext.mdx @@ -0,0 +1,78 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L1198 +title: drawingContext +module: Rendering +submodule: Rendering +file: src/core/rendering.js +description: > +

A system variable that provides direct access to the sketch's + + element.

+ +

The element provides many specialized features that + aren't + + included in the p5.js library. The drawingContext system variable + + provides access to these features by exposing the sketch's + + CanvasRenderingContext2D + + object.

+line: 1198 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(180); + + // Style the circle using shadows. + drawingContext.shadowOffsetX = 5; + drawingContext.shadowOffsetY = -5; + drawingContext.shadowBlur = 10; + drawingContext.shadowColor = 'black'; + + // Draw the circle. + circle(50, 50, 40); + + describe("A white circle on a gray background. The circle's edges are shadowy."); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background('skyblue'); + + // Style the circle using a color gradient. + let myGradient = drawingContext.createRadialGradient(50, 50, 3, 50, 50, 40); + myGradient.addColorStop(0, 'yellow'); + myGradient.addColorStop(0.6, 'orangered'); + myGradient.addColorStop(1, 'yellow'); + drawingContext.fillStyle = myGradient; + drawingContext.strokeStyle = 'rgba(0, 0, 0, 0)'; + + // Draw the circle. + circle(50, 50, 40); + + describe('A fiery sun drawn on a light blue background.'); + } + +
+class: p5 +--- + + +# drawingContext diff --git a/src/content/reference/en/p5 copy/ellipse.mdx b/src/content/reference/en/p5 copy/ellipse.mdx new file mode 100644 index 0000000000..6c07765230 --- /dev/null +++ b/src/content/reference/en/p5 copy/ellipse.mdx @@ -0,0 +1,164 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L371 +title: ellipse +module: Shape +submodule: 2D Primitives +file: src/core/shape/2d_primitives.js +description: > +

Draws an ellipse (oval).

+ +

An ellipse is a round shape defined by the x, y, + w, and + + h parameters. x and y set the location + of its center. w and + + h set its width and height. See + + ellipseMode() for other ways to set + + its position.

+ +

If no height is set, the value of width is used for both the width and + + height. If a negative height or width is specified, the absolute value is + + taken.

+ +

The fifth parameter, detail, is also optional. It determines + how many + + vertices are used to draw the ellipse in WebGL mode. The default value is + + 25.

+line: 371 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + ellipse(50, 50, 80, 80); + + describe('A white circle on a gray canvas.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + ellipse(50, 50, 80); + + describe('A white circle on a gray canvas.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + ellipse(50, 50, 80, 40); + + describe('A white ellipse on a gray canvas.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + ellipse(0, 0, 80, 40); + + describe('A white ellipse on a gray canvas.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + // Use 6 vertices. + ellipse(0, 0, 80, 40, 6); + + describe('A white hexagon on a gray canvas.'); + } + +
+class: p5 +overloads: + - line: 371 + params: + - name: x + description: | +

x-coordinate of the center of the ellipse.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the center of the ellipse.

+ type: Number + - name: w + description: | +

width of the ellipse.

+ type: Number + - name: h + description: | +

height of the ellipse.

+ type: Number + optional: true + chainable: 1 + - line: 472 + params: + - name: x + description: '' + type: Number + - name: 'y' + description: '' + type: Number + - name: w + description: '' + type: Number + - name: h + description: '' + type: Number + - name: detail + description: | +

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.

+ type: Integer + optional: true +chainable: true +--- + + +# ellipse diff --git a/src/content/reference/en/p5 copy/ellipseMode.mdx b/src/content/reference/en/p5 copy/ellipseMode.mdx new file mode 100644 index 0000000000..0826de63f4 --- /dev/null +++ b/src/content/reference/en/p5 copy/ellipseMode.mdx @@ -0,0 +1,113 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L12 +title: ellipseMode +module: Shape +submodule: Attributes +file: src/core/shape/attributes.js +description: > +

Changes where ellipses, circles, and arcs are drawn.

+ +

By default, the first two parameters of + + ellipse(), circle(), + + and arc() + + are the x- and y-coordinates of the shape's center. The next parameters set + + the shape's width and height. This is the same as calling + + ellipseMode(CENTER).

+ +

ellipseMode(RADIUS) also uses the first two parameters to set + the x- and + + y-coordinates of the shape's center. The next parameters are half of the + + shapes's width and height. Calling ellipse(0, 0, 10, 15) draws a + shape + + with a width of 20 and height of 30.

+ +

ellipseMode(CORNER) uses the first two parameters as the + upper-left + + corner of the shape. The next parameters are its width and height.

+ +

ellipseMode(CORNERS) uses the first two parameters as the + location of one + + corner of the ellipse's bounding box. The next parameters are the location + + of the opposite corner.

+ +

The argument passed to ellipseMode() must be written in ALL + CAPS because + + the constants CENTER, RADIUS, CORNER, + and CORNERS are defined this + + way. JavaScript is a case-sensitive language.

+line: 12 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // White ellipse. + ellipseMode(RADIUS); + fill(255); + ellipse(50, 50, 30, 30); + + // Gray ellipse. + ellipseMode(CENTER); + fill(100); + ellipse(50, 50, 30, 30); + + describe('A white circle with a gray circle at its center. Both circles have black outlines.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // White ellipse. + ellipseMode(CORNER); + fill(255); + ellipse(25, 25, 50, 50); + + // Gray ellipse. + ellipseMode(CORNERS); + fill(100); + ellipse(25, 25, 50, 50); + + describe('A white circle with a gray circle at its top-left corner. Both circles have black outlines.'); + } + +
+class: p5 +params: + - name: mode + description: | +

either CENTER, RADIUS, CORNER, or CORNERS

+ type: Constant +chainable: true +--- + + +# ellipseMode diff --git a/src/content/reference/en/p5 copy/ellipsoid.mdx b/src/content/reference/en/p5 copy/ellipsoid.mdx new file mode 100644 index 0000000000..56d86709b7 --- /dev/null +++ b/src/content/reference/en/p5 copy/ellipsoid.mdx @@ -0,0 +1,233 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L1965 +title: ellipsoid +module: Shape +submodule: 3D Primitives +file: src/webgl/3d_primitives.js +description: > +

Draws an ellipsoid.

+ +

An ellipsoid is a 3D shape with triangular faces that connect to form a + + round surface. Ellipsoids with few faces look like crystals. Ellipsoids + + with many faces have smooth surfaces and look like eggs. + ellipsoid() + + defines a shape by its radii. This is different from + + ellipse() which uses diameters + + (width and height).

+ +

The first parameter, radiusX, is optional. If a + Number is passed, as in + + ellipsoid(20), it sets the radius of the ellipsoid along the + x-axis. By + + default, radiusX is 50.

+ +

The second parameter, radiusY, is also optional. If a + Number is passed, + + as in ellipsoid(20, 30), it sets the ellipsoid’s radius along the + y-axis. + + By default, radiusY is set to the ellipsoid’s + radiusX.

+ +

The third parameter, radiusZ, is also optional. If a + Number is passed, + + as in ellipsoid(20, 30, 40), it sets the ellipsoid’s radius along + the + + z-axis. By default, radiusZ is set to the ellipsoid’s + radiusY.

+ +

The fourth parameter, detailX, is also optional. If a + Number is passed, + + as in ellipsoid(20, 30, 40, 5), it sets the number of triangle + + subdivisions to use along the x-axis. All 3D shapes are made by connecting + + triangles to form their surfaces. By default, detailX is 24.

+ +

The fifth parameter, detailY, is also optional. If a + Number is passed, + + as in ellipsoid(20, 30, 40, 5, 7), it sets the number of triangle + + subdivisions to use along the y-axis. All 3D shapes are made by connecting + + triangles to form their surfaces. By default, detailY is 16.

+ +

Note: ellipsoid() can only be used in WebGL mode.

+line: 1965 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white sphere on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the ellipsoid. + // Set its radiusX to 30. + ellipsoid(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white ellipsoid on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the ellipsoid. + // Set its radiusX to 30. + // Set its radiusY to 40. + ellipsoid(30, 40); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white ellipsoid on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the ellipsoid. + // Set its radiusX to 30. + // Set its radiusY to 40. + // Set its radiusZ to 50. + ellipsoid(30, 40, 50); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white ellipsoid on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the ellipsoid. + // Set its radiusX to 30. + // Set its radiusY to 40. + // Set its radiusZ to 50. + // Set its detailX to 4. + ellipsoid(30, 40, 50, 4); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white ellipsoid on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the ellipsoid. + // Set its radiusX to 30. + // Set its radiusY to 40. + // Set its radiusZ to 50. + // Set its detailX to 4. + // Set its detailY to 3. + ellipsoid(30, 40, 50, 4, 3); + } + +
+class: p5 +params: + - name: radiusX + description: | +

radius of the ellipsoid along the x-axis. Defaults to 50.

+ type: Number + optional: true + - name: radiusY + description: > +

radius of the ellipsoid along the y-axis. Defaults to + radiusX.

+ type: Number + optional: true + - name: radiusZ + description: > +

radius of the ellipsoid along the z-axis. Defaults to + radiusY.

+ type: Number + optional: true + - name: detailX + description: | +

number of triangle subdivisions along the x-axis. Defaults to 24.

+ type: Integer + optional: true + - name: detailY + description: | +

number of triangle subdivisions along the y-axis. Defaults to 16.

+ type: Integer + optional: true +chainable: true +--- + + +# ellipsoid diff --git a/src/content/reference/en/p5 copy/emissiveMaterial.mdx b/src/content/reference/en/p5 copy/emissiveMaterial.mdx new file mode 100644 index 0000000000..10037c3c86 --- /dev/null +++ b/src/content/reference/en/p5 copy/emissiveMaterial.mdx @@ -0,0 +1,140 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2647 +title: emissiveMaterial +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Sets the emissive color of shapes’ surface material.

+ +

The emissiveMaterial() color sets a color shapes display at + full + + strength, regardless of lighting. This can give the appearance that a shape + + is glowing. However, emissive materials don’t actually emit light that + + can affect surrounding objects.

+ +

emissiveMaterial() can be called three ways with different + parameters to + + set the material’s color.

+ +

The first way to call emissiveMaterial() has one parameter, + gray. + + Grayscale values between 0 and 255, as in emissiveMaterial(50), + can be + + passed to set the material’s color. Higher grayscale values make shapes + + appear brighter.

+ +

The second way to call emissiveMaterial() has one parameter, + color. A + + p5.Color object, an array of color + values, or a + + CSS color string, as in emissiveMaterial('magenta'), can be + passed to set + + the material’s color.

+ +

The third way to call emissiveMaterial() has four parameters, + v1, v2, + + v3, and alpha. alpha is optional. RGBA, + HSBA, or HSLA values can be + + passed to set the material’s colors, as in emissiveMaterial(255, 0, + 0) or + + emissiveMaterial(255, 0, 0, 30). Color values will be interpreted + using + + the current colorMode().

+ +

Note: emissiveMaterial() can only be used in WebGL mode.

+line: 2647 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A red cube drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on a white ambient light. + ambientLight(255, 255, 255); + + // Add a red emissive material using RGB values. + emissiveMaterial(255, 0, 0); + + // Draw the box. + box(); + } + +
+class: p5 +overloads: + - line: 2647 + params: + - name: v1 + description: | +

red or hue value in the current + colorMode().

+ type: Number + - name: v2 + description: | +

green or saturation value in the + current colorMode().

+ type: Number + - name: v3 + description: | +

blue, brightness, or lightness value in the + current colorMode().

+ type: Number + - name: alpha + description: | +

alpha value in the current + colorMode().

+ type: Number + optional: true + chainable: 1 + - line: 2717 + params: + - name: gray + description: | +

grayscale value between 0 (black) and 255 (white).

+ type: Number + chainable: 1 + - line: 2723 + params: + - name: color + description: | +

color as a p5.Color object, + an array of color values, or a CSS string.

+ type: 'p5.Color|Number[]|String' + chainable: 1 +chainable: true +--- + + +# emissiveMaterial diff --git a/src/content/reference/en/p5 copy/endClip.mdx b/src/content/reference/en/p5 copy/endClip.mdx new file mode 100644 index 0000000000..69bf243858 --- /dev/null +++ b/src/content/reference/en/p5 copy/endClip.mdx @@ -0,0 +1,43 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L190 +title: endClip +module: Color +submodule: Setting +file: src/color/setting.js +description: | +

Ends defining a mask that was started with + beginClip().

+line: 190 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a mask. + beginClip(); + triangle(15, 37, 30, 13, 43, 37); + circle(45, 45, 7); + endClip(); + + // Draw a backing shape. + square(5, 5, 45); + + describe('A white triangle and circle on a gray background.'); + } + +
+class: p5 +chainable: false +--- + + +# endClip diff --git a/src/content/reference/en/p5 copy/endContour.mdx b/src/content/reference/en/p5 copy/endContour.mdx new file mode 100644 index 0000000000..5965b72db8 --- /dev/null +++ b/src/content/reference/en/p5 copy/endContour.mdx @@ -0,0 +1,133 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L1224 +title: endContour +module: Shape +submodule: Vertex +file: src/core/shape/vertex.js +description: > +

Stops creating a hole within a flat shape.

+ +

The beginContour() and + endContour() + + functions allow for creating negative space within custom shapes that are + + flat. beginContour() begins adding + vertices + + to a negative space and endContour() stops adding them. + + beginContour() and + endContour() must be + + called between beginShape() and + + endShape().

+ +

Transformations such as translate(), + + rotate(), and scale() + + don't work between beginContour() + and + + endContour(). It's also not possible to use other shapes, such as + + ellipse() or rect(), + + between beginContour() and + endContour().

+ +

Note: The vertices that define a negative space must "wind" in the opposite + + direction from the outer shape. First, draw vertices for the outer shape + + clockwise order. Then, draw vertices for the negative space in + + counter-clockwise order.

+line: 1224 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + beginShape(); + + // Exterior vertices, clockwise winding. + vertex(10, 10); + vertex(90, 10); + vertex(90, 90); + vertex(10, 90); + + // Interior vertices, counter-clockwise winding. + beginContour(); + vertex(30, 30); + vertex(30, 70); + vertex(70, 70); + vertex(70, 30); + endContour(); + + // Stop drawing the shape. + endShape(CLOSE); + + describe('A white square with a square hole in its center drawn on a gray background.'); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white square with a square hole in its center drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Start drawing the shape. + beginShape(); + + // Exterior vertices, clockwise winding. + vertex(-40, -40); + vertex(40, -40); + vertex(40, 40); + vertex(-40, 40); + + // Interior vertices, counter-clockwise winding. + beginContour(); + vertex(-20, -20); + vertex(-20, 20); + vertex(20, 20); + vertex(20, -20); + endContour(); + + // Stop drawing the shape. + endShape(CLOSE); + } + +
+class: p5 +chainable: true +--- + + +# endContour diff --git a/src/content/reference/en/p5 copy/endGeometry.mdx b/src/content/reference/en/p5 copy/endGeometry.mdx new file mode 100644 index 0000000000..bfbeb81c7b --- /dev/null +++ b/src/content/reference/en/p5 copy/endGeometry.mdx @@ -0,0 +1,285 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L266 +title: endGeometry +module: Shape +submodule: 3D Primitives +file: src/webgl/3d_primitives.js +description: > +

Stops adding shapes to a new + + p5.Geometry object and returns the + object.

+ +

The beginGeometry() and endGeometry() + + functions help with creating complex 3D shapes from simpler ones such as + + sphere(). beginGeometry() + begins adding shapes + + to a custom p5.Geometry object and + + endGeometry() stops adding them.

+ +

beginGeometry() and endGeometry() can help + + to make sketches more performant. For example, if a complex 3D shape + + doesn’t change while a sketch runs, then it can be created with + + beginGeometry() and endGeometry(). + + Creating a p5.Geometry object once and + then + + drawing it will run faster than repeatedly drawing the individual pieces.

+ +

See buildGeometry() for another + way to + + build 3D shapes.

+ +

Note: endGeometry() can only be used in WebGL mode.

+line: 266 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Start building the p5.Geometry object. + beginGeometry(); + + // Add a cone. + cone(); + + // Stop building the p5.Geometry object. + shape = endGeometry(); + + describe('A white cone drawn on a gray background.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the p5.Geometry object. + noStroke(); + + // Draw the p5.Geometry object. + model(shape); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the p5.Geometry object. + createArrow(); + + describe('A white arrow drawn on a gray background.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the p5.Geometry object. + noStroke(); + + // Draw the p5.Geometry object. + model(shape); + } + + function createArrow() { + // Start building the p5.Geometry object. + beginGeometry(); + + // Add shapes. + push(); + rotateX(PI); + cone(10); + translate(0, -10, 0); + cylinder(3, 20); + pop(); + + // Stop building the p5.Geometry object. + shape = endGeometry(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let blueArrow; + let redArrow; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the arrows. + redArrow = createArrow('red'); + blueArrow = createArrow('blue'); + + describe('A red arrow and a blue arrow drawn on a gray background. The blue arrow rotates slowly.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the arrows. + noStroke(); + + // Draw the red arrow. + model(redArrow); + + // Translate and rotate the coordinate system. + translate(30, 0, 0); + rotateZ(frameCount * 0.01); + + // Draw the blue arrow. + model(blueArrow); + } + + function createArrow(fillColor) { + // Start building the p5.Geometry object. + beginGeometry(); + + fill(fillColor); + + // Add shapes to the p5.Geometry object. + push(); + rotateX(PI); + cone(10); + translate(0, -10, 0); + cylinder(3, 20); + pop(); + + // Stop building the p5.Geometry object. + let shape = endGeometry(); + + return shape; + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let button; + let particles; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a button to reset the particle system. + button = createButton('Reset'); + + // Call resetModel() when the user presses the button. + button.mousePressed(resetModel); + + // Add the original set of particles. + resetModel(); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the particles. + noStroke(); + + // Draw the particles. + model(particles); + } + + function resetModel() { + // If the p5.Geometry object has already been created, + // free those resources. + if (particles) { + freeGeometry(particles); + } + + // Create a new p5.Geometry object with random spheres. + particles = createParticles(); + } + + function createParticles() { + // Start building the p5.Geometry object. + beginGeometry(); + + // Add shapes. + for (let i = 0; i < 60; i += 1) { + // Calculate random coordinates. + let x = randomGaussian(0, 20); + let y = randomGaussian(0, 20); + let z = randomGaussian(0, 20); + + push(); + // Translate to the particle's coordinates. + translate(x, y, z); + // Draw the particle. + sphere(5); + pop(); + } + + // Stop building the p5.Geometry object. + let shape = endGeometry(); + + return shape; + } + +
+class: p5 +return: + description: new 3D shape. + type: p5.Geometry +chainable: false +--- + + +# endGeometry diff --git a/src/content/reference/en/p5 copy/endShape.mdx b/src/content/reference/en/p5 copy/endShape.mdx new file mode 100644 index 0000000000..198b6d7497 --- /dev/null +++ b/src/content/reference/en/p5 copy/endShape.mdx @@ -0,0 +1,256 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L1344 +title: endShape +module: Shape +submodule: Vertex +file: src/core/shape/vertex.js +description: > +

Stops adding vertices to a custom shape.

+ +

The beginShape() and + endShape() functions + + allow for creating custom shapes in 2D or 3D. + + beginShape() begins adding vertices to + a + + custom shape and endShape() stops adding them.

+ +

The first parameter, mode, is optional. By default, the first + and last + + vertices of a shape aren't connected. If the constant CLOSE is + passed, as + + in endShape(CLOSE), then the first and last vertices will be + connected.

+ +

The second parameter, count, is also optional. In WebGL mode, + it’s more + + efficient to draw many copies of the same shape using a technique called + + instancing. + + The count parameter tells WebGL mode how many copies to draw. For + + example, calling endShape(CLOSE, 400) after drawing a custom + shape will + + make it efficient to draw 400 copies. This feature requires + + writing + a custom shader.

+ +

After calling beginShape(), shapes + can be + + built by calling vertex(), + + bezierVertex(), + + quadraticVertex(), and/or + + curveVertex(). Calling + + endShape() will stop adding vertices to the + + shape. Each shape will be outlined with the current stroke color and filled + + with the current fill color.

+ +

Transformations such as translate(), + + rotate(), and + + scale() don't work between + + beginShape() and + endShape(). It's also not + + possible to use other shapes, such as ellipse() or + + rect(), between + + beginShape() and + endShape().

+line: 1344 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the shapes. + noFill(); + + // Left triangle. + beginShape(); + vertex(20, 20); + vertex(45, 20); + vertex(45, 80); + endShape(CLOSE); + + // Right triangle. + beginShape(); + vertex(50, 20); + vertex(75, 20); + vertex(75, 80); + endShape(); + + describe( + 'Two sets of black lines drawn on a gray background. The three lines on the left form a right triangle. The two lines on the right form a right angle.' + ); + } + +
+ +
+ + function setup() { + createCanvas(200, 100); + + background(240); + + noFill(); + stroke(0); + + // Open shape (left) + beginShape(); + vertex(20, 20); + vertex(80, 20); + vertex(80, 80); + endShape(); // Not closed + + // Closed shape (right) + beginShape(); + vertex(120, 20); + vertex(180, 20); + vertex(180, 80); + endShape(CLOSE); // Closed + + describe( + 'Two right-angled shapes on a light gray background. The left shape is open with three lines. The right shape is closed, forming a triangle.' + ); + } + +
+ +
+ + // Note: A "uniform" is a global variable within a shader program. + + // Create a string with the vertex shader program. + // The vertex shader is called for each vertex. + let vertSrc = `#version 300 es + + precision mediump float; + + in vec3 aPosition; + flat out int instanceID; + + uniform mat4 uModelViewMatrix; + uniform mat4 uProjectionMatrix; + + void main() { + + // Copy the instance ID to the fragment shader. + instanceID = gl_InstanceID; + vec4 positionVec4 = vec4(aPosition, 1.0); + + // gl_InstanceID represents a numeric value for each instance. + // Using gl_InstanceID allows us to move each instance separately. + // Here we move each instance horizontally by ID * 23. + float xOffset = float(gl_InstanceID) * 23.0; + + // Apply the offset to the final position. + gl_Position = uProjectionMatrix * uModelViewMatrix * (positionVec4 - + vec4(xOffset, 0.0, 0.0, 0.0)); + } + `; + + // Create a string with the fragment shader program. + // The fragment shader is called for each pixel. + let fragSrc = `#version 300 es + + precision mediump float; + + out vec4 outColor; + flat in int instanceID; + uniform float numInstances; + + void main() { + vec4 red = vec4(1.0, 0.0, 0.0, 1.0); + vec4 blue = vec4(0.0, 0.0, 1.0, 1.0); + + // Normalize the instance ID. + float normId = float(instanceID) / numInstances; + + // Mix between two colors using the normalized instance ID. + outColor = mix(red, blue, normId); + } + `; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Shader object. + let myShader = createShader(vertSrc, fragSrc); + + background(220); + + // Compile and apply the p5.Shader. + shader(myShader); + + // Set the numInstances uniform. + myShader.setUniform('numInstances', 4); + + // Translate the origin to help align the drawing. + translate(25, -10); + + // Style the shapes. + noStroke(); + + // Draw the shapes. + beginShape(); + vertex(0, 0); + vertex(0, 20); + vertex(20, 20); + vertex(20, 0); + vertex(0, 0); + endShape(CLOSE, 4); + + describe('A row of four squares. Their colors transition from purple on the left to red on the right'); + } + +
+class: p5 +params: + - name: mode + description: | +

use CLOSE to close the shape

+ type: Constant + optional: true + - name: count + description: > +

number of times you want to draw/instance the shape (for WebGL + mode).

+ type: Integer + optional: true +chainable: true +--- + + +# endShape diff --git a/src/content/reference/en/p5 copy/erase.mdx b/src/content/reference/en/p5 copy/erase.mdx new file mode 100644 index 0000000000..24f1397e8e --- /dev/null +++ b/src/content/reference/en/p5 copy/erase.mdx @@ -0,0 +1,123 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1629 +title: erase +module: Color +submodule: Setting +file: src/color/setting.js +description: > +

Starts using shapes to erase parts of the canvas.

+ +

All drawing that follows erase() will subtract from the + canvas, revealing + + the web page underneath. The erased areas will become transparent, allowing + + the content behind the canvas to show through. The + + fill(), stroke(), and + + blendMode() have no effect once + erase() is + + called.

+ +

The erase() function has two optional parameters. The first + parameter + + sets the strength of erasing by the shape's interior. A value of 0 means + + that no erasing will occur. A value of 255 means that the shape's interior + + will fully erase the content underneath. The default value is 255 + + (full strength).

+ +

The second parameter sets the strength of erasing by the shape's edge. A + + value of 0 means that no erasing will occur. A value of 255 means that the + + shape's edge will fully erase the content underneath. The default value is + + 255 (full strength).

+ +

To cancel the erasing effect, use the noErase() + + function.

+ +

erase() has no effect on drawing done with the + + image() and + + background() functions.

+line: 1629 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(100, 100, 250); + + // Draw a pink square. + fill(250, 100, 100); + square(20, 20, 60); + + // Erase a circular area. + erase(); + circle(25, 30, 30); + noErase(); + + describe('A purple canvas with a pink square in the middle. A circle is erased from the top-left, leaving a hole.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(100, 100, 250); + + // Draw a pink square. + fill(250, 100, 100); + square(20, 20, 60); + + // Erase a circular area. + strokeWeight(5); + erase(150, 255); + circle(25, 30, 30); + noErase(); + + describe('A purple canvas with a pink square in the middle. A circle at the top-left partially erases its interior and a fully erases its outline.'); + } + +
+class: p5 +params: + - name: strengthFill + description: | +

a number (0-255) for the strength of erasing under a shape's interior. + Defaults to 255, which is full strength.

+ type: Number + optional: true + - name: strengthStroke + description: | +

a number (0-255) for the strength of erasing under a shape's edge. + Defaults to 255, which is full strength.

+ type: Number + optional: true +chainable: true +--- + + +# erase diff --git a/src/content/reference/en/p5 copy/exitPointerLock.mdx b/src/content/reference/en/p5 copy/exitPointerLock.mdx new file mode 100644 index 0000000000..db8a989422 --- /dev/null +++ b/src/content/reference/en/p5 copy/exitPointerLock.mdx @@ -0,0 +1,82 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1946 +title: exitPointerLock +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

Exits a pointer lock started with + + requestPointerLock.

+ +

Calling requestPointerLock() locks the values of + + mouseX, mouseY, + + pmouseX, and pmouseY. + + Calling exitPointerLock() resumes updating the mouse system + variables.

+ +

Note: Most browsers require an input, such as a click, before calling + + requestPointerLock(). It’s recommended to call + requestPointerLock() in + + an event function such as doubleClicked().

+line: 1946 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let isLocked = false; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a word at its center. The word changes between "Unlocked" and "Locked" when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Tell the user whether the pointer is locked. + if (isLocked === true) { + text('Locked', 50, 50); + } else { + text('Unlocked', 50, 50); + } + } + + // Toggle the pointer lock when the user double-clicks. + function doubleClicked() { + if (isLocked === true) { + exitPointerLock(); + isLocked = false; + } else { + requestPointerLock(); + isLocked = true; + } + } + +
+class: p5 +chainable: false +--- + + +# exitPointerLock diff --git a/src/content/reference/en/p5 copy/exp.mdx b/src/content/reference/en/p5 copy/exp.mdx new file mode 100644 index 0000000000..e75a420dab --- /dev/null +++ b/src/content/reference/en/p5 copy/exp.mdx @@ -0,0 +1,83 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L230 +title: exp +module: Math +submodule: Calculation +file: src/math/calculation.js +description: | +

Calculates the value of Euler's number e (2.71828...) raised to the power + of a number.

+line: 230 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Top-left. + let d = exp(1); + circle(10, 10, d); + + // Left-center. + d = exp(2); + circle(20, 20, d); + + // Right-center. + d = exp(3); + circle(40, 40, d); + + // Bottom-right. + d = exp(4); + circle(80, 80, d); + + describe('A series of circles that grow exponentially from top left to bottom right.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + describe('A series of black dots that grow exponentially from left to right.'); + } + + function draw() { + // Invert the y-axis. + scale(1, -1); + translate(0, -100); + + // Calculate the coordinates. + let x = frameCount; + let y = 0.005 * exp(x * 0.1); + + // Draw a point. + point(x, y); + } + +
+class: p5 +params: + - name: 'n' + description: | +

exponent to raise.

+ type: Number +return: + description: e^n + type: Number +chainable: false +--- + + +# exp diff --git a/src/content/reference/en/p5 copy/fill.mdx b/src/content/reference/en/p5 copy/fill.mdx new file mode 100644 index 0000000000..84f074abd4 --- /dev/null +++ b/src/content/reference/en/p5 copy/fill.mdx @@ -0,0 +1,312 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1000 +title: fill +module: Color +submodule: Setting +file: src/color/setting.js +description: > +

Sets the color used to fill shapes.

+ +

Calling fill(255, 165, 0) or fill('orange') means + all shapes drawn + + after the fill command will be filled with the color orange.

+ +

The version of fill() with one parameter interprets the value + one of + + three ways. If the parameter is a Number, it's interpreted as a + grayscale + + value. If the parameter is a String, it's interpreted as a CSS + color + + string. A p5.Color object can also be + provided to + + set the fill color.

+ +

The version of fill() with three parameters interprets them as + RGB, HSB, + + or HSL colors, depending on the current + + colorMode(). The default color space is + RGB, + + with each value in the range from 0 to 255.

+ +

The version of fill() with four parameters interprets them as + RGBA, HSBA, + + or HSLA colors, depending on the current colorMode(). The last parameter + + sets the alpha (transparency) value.

+line: 1000 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // A grayscale value. + fill(51); + square(20, 20, 60); + + describe('A dark charcoal gray square with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // R, G & B values. + fill(255, 204, 0); + square(20, 20, 60); + + describe('A yellow square with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // R, G, B, and Alpha values. + fill(255, 0, 0, 128); + square(20, 20, 60); + + describe('A semi-transparent red square with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(100); + + // Use HSB color. + colorMode(HSB); + + // H, S & B values. + fill(255, 204, 100); + square(20, 20, 60); + + describe('A royal blue square with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // A CSS named color. + fill('red'); + square(20, 20, 60); + + describe('A red square with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Three-digit hex RGB notation. + fill('#fae'); + square(20, 20, 60); + + describe('A pink square with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Six-digit hex RGB notation. + fill('#A251FA'); + square(20, 20, 60); + + describe('A purple square with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Integer RGB notation. + fill('rgb(0, 255, 0)'); + square(20, 20, 60); + + describe('A bright green square with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Integer RGBA notation. + fill('rgba(0, 255, 0, 0.25)'); + square(20, 20, 60); + + describe('A soft green rectange with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Percentage RGB notation. + fill('rgb(100%, 0%, 10%)'); + square(20, 20, 60); + + describe('A red square with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Percentage RGBA notation. + fill('rgba(100%, 0%, 100%, 0.5)'); + square(20, 20, 60); + + describe('A dark fuchsia square with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // A p5.Color object. + let c = color(0, 0, 255); + fill(c); + square(20, 20, 60); + + describe('A blue square with a black outline.'); + } + +
+class: p5 +overloads: + - line: 1000 + params: + - name: v1 + description: > +

red value if color mode is RGB or hue value if color mode is + HSB.

+ type: Number + - name: v2 + description: > +

green value if color mode is RGB or saturation value if color mode + is HSB.

+ type: Number + - name: v3 + description: > +

blue value if color mode is RGB or brightness value if color mode + is HSB.

+ type: Number + - name: alpha + description: > +

alpha value, controls transparency (0 - transparent, 255 - + opaque).

+ type: Number + optional: true + chainable: 1 + - line: 1225 + params: + - name: value + description: | +

a color string.

+ type: String + chainable: 1 + - line: 1231 + params: + - name: gray + description: | +

a grayscale value.

+ type: Number + - name: alpha + description: '' + type: Number + optional: true + chainable: 1 + - line: 1238 + params: + - name: values + description: | +

an array containing the red, green, blue & + and alpha components of the color.

+ type: 'Number[]' + chainable: 1 + - line: 1245 + params: + - name: color + description: | +

the fill color.

+ type: p5.Color + chainable: 1 +chainable: true +--- + + +# fill diff --git a/src/content/reference/en/p5 copy/filter.mdx b/src/content/reference/en/p5 copy/filter.mdx new file mode 100644 index 0000000000..5496568d48 --- /dev/null +++ b/src/content/reference/en/p5 copy/filter.mdx @@ -0,0 +1,330 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L442 +title: filter +module: Image +submodule: Pixels +file: src/image/pixels.js +description: > +

Applies an image filter to the canvas.

+ +

The preset options are:

+ +

INVERT + + Inverts the colors in the image. No parameter is used.

+ +

GRAY + + Converts the image to grayscale. No parameter is used.

+ +

THRESHOLD + + Converts the image to black and white. Pixels with a grayscale value + + above a given threshold are converted to white. The rest are converted to + + black. The threshold must be between 0.0 (black) and 1.0 (white). If no + + value is specified, 0.5 is used.

+ +

OPAQUE + + Sets the alpha channel to entirely opaque. No parameter is used.

+ +

POSTERIZE + + Limits the number of colors in the image. Each color channel is limited to + + the number of colors specified. Values between 2 and 255 are valid, but + + results are most noticeable with lower values. The default value is 4.

+ +

BLUR + + Blurs the image. The level of blurring is specified by a blur radius. Larger + + values increase the blur. The default value is 4. A gaussian blur is used + + in P2D mode. A box blur is used in WEBGL mode.

+ +

ERODE + + Reduces the light areas. No parameter is used.

+ +

DILATE + + Increases the light areas. No parameter is used.

+ +

filter() uses WebGL in the background by default because it's + faster. + + This can be disabled in P2D mode by adding a false + argument, as in + + filter(BLUR, false). This may be useful to keep computation off + the GPU + + or to work around a lack of WebGL support.

+ +

In WebgL mode, filter() can also use custom shaders. See + + createFilterShader() for more + + information.

+line: 442 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Apply the INVERT filter. + filter(INVERT); + + describe('A blue brick wall.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Apply the GRAY filter. + filter(GRAY); + + describe('A brick wall drawn in grayscale.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Apply the THRESHOLD filter. + filter(THRESHOLD); + + describe('A brick wall drawn in black and white.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Apply the OPAQUE filter. + filter(OPAQUE); + + describe('A red brick wall.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Apply the POSTERIZE filter. + filter(POSTERIZE, 3); + + describe('An image of a red brick wall drawn with limited color palette.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Apply the BLUR filter. + filter(BLUR, 3); + + describe('A blurry image of a red brick wall.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Apply the DILATE filter. + filter(DILATE); + + describe('A red brick wall with bright lines between each brick.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Apply the ERODE filter. + filter(ERODE); + + describe('A red brick wall with faint lines between each brick.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Apply the BLUR filter. + // Don't use WebGL. + filter(BLUR, 3, false); + + describe('A blurry image of a red brick wall.'); + } + +
+class: p5 +overloads: + - line: 442 + params: + - name: filterType + description: | +

either THRESHOLD, GRAY, OPAQUE, INVERT, + POSTERIZE, BLUR, ERODE, DILATE or BLUR.

+ type: Constant + - name: filterParam + description: | +

parameter unique to each filter.

+ type: Number + optional: true + - name: useWebGL + description: | +

flag to control whether to use fast + WebGL filters (GPU) or original image + filters (CPU); defaults to true.

+ type: Boolean + optional: true + - line: 715 + params: + - name: filterType + description: '' + type: Constant + - name: useWebGL + description: '' + type: Boolean + optional: true + - line: 720 + params: + - name: shaderFilter + description: | +

shader that's been loaded, with the + frag shader using a tex0 uniform.

+ type: p5.Shader +chainable: false +--- + + +# filter diff --git a/src/content/reference/en/p5 copy/float.mdx b/src/content/reference/en/p5 copy/float.mdx new file mode 100644 index 0000000000..fffd6bfc1b --- /dev/null +++ b/src/content/reference/en/p5 copy/float.mdx @@ -0,0 +1,116 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L10 +title: float +module: Data +submodule: Conversion +file: src/utilities/conversion.js +description: > +

Converts a String to a floating point (decimal) + Number.

+ +

float() converts strings that resemble numbers, such as + '12.34', into + + numbers.

+ +

The parameter, str, is the string value to convert. For + example, calling + + float('12.34') returns the number 12.34. If an + array of strings is + + passed, as in float(['12.34', '56.78']), then an array of numbers + will be + + returned.

+ +

Note: If a string can't be converted to a number, as in + float('giraffe'), + + then the value NaN (not a number) will be returned.

+line: 10 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let original = '12.3'; + + // Convert the string to a number. + let converted = float(original); + + // Double the converted value. + let twice = converted * 2; + + // Style the text. + textAlign(CENTER, CENTER); + textSize(12); + + // Display the original and converted values. + text(`${original} × 2 = ${twice}`, 50, 50); + + describe('The text "12.3 × 2 = 24.6" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of strings. + let original = ['60', '30', '15']; + + // Convert the strings to numbers. + let diameters = float(original); + + for (let d of diameters) { + // Draw a circle. + circle(50, 50, d); + } + + describe('Three white, concentric circles on a gray background.'); + } + +
+class: p5 +return: + description: converted number. + type: Number +overloads: + - line: 10 + params: + - name: str + description: | +

string to convert.

+ type: String + return: + description: converted number. + type: Number + - line: 80 + params: + - name: ns + description: | +

array of strings to convert.

+ type: 'String[]' + return: + description: converted numbers. + type: 'Number[]' +chainable: false +--- + + +# float diff --git a/src/content/reference/en/p5 copy/floor.mdx b/src/content/reference/en/p5 copy/floor.mdx new file mode 100644 index 0000000000..a9e97965a3 --- /dev/null +++ b/src/content/reference/en/p5 copy/floor.mdx @@ -0,0 +1,57 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L294 +title: floor +module: Math +submodule: Calculation +file: src/math/calculation.js +description: | +

Calculates the closest integer value that is less than or equal to the + value of a number.

+line: 294 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Use RGB color with values from 0 to 1. + colorMode(RGB, 1); + + noStroke(); + + // Draw the left rectangle. + let r = 0.8; + fill(r, 0, 0); + rect(0, 0, 50, 100); + + // Round r down to 0. + r = floor(r); + + // Draw the right rectangle. + fill(r, 0, 0); + rect(50, 0, 50, 100); + + describe('Two rectangles. The one on the left is bright red and the one on the right is black.'); + } + +
+class: p5 +params: + - name: 'n' + description: | +

number to round down.

+ type: Number +return: + description: rounded down number. + type: Integer +chainable: false +--- + + +# floor diff --git a/src/content/reference/en/p5 copy/focused.mdx b/src/content/reference/en/p5 copy/focused.mdx new file mode 100644 index 0000000000..1e95f25927 --- /dev/null +++ b/src/content/reference/en/p5 copy/focused.mdx @@ -0,0 +1,50 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L174 +title: focused +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

A Boolean variable that's true if the browser is + focused and false if + + not.

+ +

Note: The browser window can only receive input if it's focused.

+line: 174 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // Open this example in two separate browser + // windows placed side-by-side to demonstrate. + + function setup() { + createCanvas(100, 100); + + describe('A square changes color from green to red when the browser window is out of focus.'); + } + + function draw() { + // Change the background color + // when the browser window + // goes in/out of focus. + if (focused === true) { + background(0, 255, 0); + } else { + background(255, 0, 0); + } + } + +
+class: p5 +type: Boolean +--- + + +# focused diff --git a/src/content/reference/en/p5 copy/for.mdx b/src/content/reference/en/p5 copy/for.mdx new file mode 100644 index 0000000000..dc71d1c2ca --- /dev/null +++ b/src/content/reference/en/p5 copy/for.mdx @@ -0,0 +1,290 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L1648 +title: for +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: > +

A way to repeat a block of code when the number of iterations is known.

+ +

for loops are helpful for repeating statements a certain + number of times. + + For example, a for loop makes it easy to express the idea + + "draw five lines" like so:

+ +
for (let x = 10; x < 100; x += 20) {
+    line(x, 25, x, 75);
+  }
+
+  
+ +

The loop's header begins with the keyword for. Loops generally + count up + + or count down as they repeat, or iterate. The statements in parentheses + + let x = 10; x < 100; x += 20 tell the loop how it should + repeat:

+ +
    + +
  • let x = 10 tells the loop to start counting at + 10 and keep track of iterations using the variable + x.
  • + +
  • x < 100 tells the loop to count up to, but not including, + 100.
  • + +
  • x += 20 tells the loop to count up by 20 at the + end of each iteration.
  • + +
+ +

The code between the curly braces {} is the loop's body. + Statements in the + + loop body are repeated during each iteration of the loop.

+ +

It's common to create infinite loops accidentally. When this happens, + + sketches may become unresponsive and the web browser may display a warning. + + For example, the following loop never stops iterating because it doesn't + + count up:

+ +
for (let x = 10; x < 100; x = 20) {
+    line(x, 25, x, 75);
+  }
+
+  
+ +

The statement x = 20 keeps the variable x stuck + at 20, which is + + always less than 100.

+ +

for loops can also count down:

+ +
for (let d = 100; d > 0; d -= 10) {
+    circle(50, 50, d);
+  }
+
+  
+ +

for loops can also contain other loops. The following nested + loop draws a + + grid of points:

+ +
// Loop from left to right.
+
+  for (let x = 10; x < 100; x += 10) {
+
+    // Loop from top to bottom.
+    for (let y = 10; y < 100; y += 10) {
+      point(x, y);
+    }
+
+  }
+
+  
+ +

for loops are also helpful for iterating through the elements + of an + + array. For example, it's common to iterate through an array that contains + + information about where or what to draw:

+ +
// Create an array of x-coordinates.
+
+  let xCoordinates = [20, 40, 60];
+
+
+  for (let i = 0; i < xCoordinates.length; i += 1) {
+    // Update the element.
+    xCoordinates[i] += random(-1, 1);
+
+    // Draw a circle.
+    circle(xCoordinates[i], 50, 20);
+  }
+
+  
+ +

If the array's values aren't modified, the for...of statement + can + + simplify the code. They're similar to for loops in Python and + for-each + + loops in C++ and Java. The following loops have the same effect:

+ +
// Draw circles with a for loop.
+
+  let xCoordinates = [20, 40, 60];
+
+
+  for (let i = 0; i < xCoordinates.length; i += 1) {
+    circle(xCoordinates[i], 50, 20);
+  }
+
+  
+ +
// Draw circles with a for...of statement.
+
+  let xCoordinates = [20, 40, 60];
+
+
+  for (let x of xCoordinates) {
+    circle(x, 50, 20);
+  }
+
+  
+ +

In the code snippets above, the variables i and x + have different roles.

+ +

In the first snippet, i counts from 0 up to + 2, which is one less than + + xCoordinates.length. i is used to access the element + in xCoordinates + + at index i.

+ +

In the second code snippet, x isn't keeping track of the + loop's progress + + or an index. During each iteration, x contains the next element + of + + xCoordinates. x starts from the beginning of + xCoordinates (20) and + + updates its value to 40 and then 60 during the next + iterations.

+line: 1648 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('Five black vertical lines on a gray background.'); + } + + function draw() { + background(200); + + // Draw vertical lines using a loop. + for (let x = 10; x < 100; x += 20) { + line(x, 25, x, 75); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('Five white concentric circles drawn on a gray background.'); + } + + function draw() { + background(200); + + // Draw concentric circles using a loop. + for (let d = 100; d > 0; d -= 20) { + circle(50, 50, d); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A grid of black dots on a gray background.'); + } + + function draw() { + background(200); + + // Set the spacing for points on the grid. + let space = 10; + + // Increase the stroke weight. + strokeWeight(3); + + // Loop from the left to the right. + for (let x = space; x < 100; x += space) { + // Loop from the top to the bottom. + for (let y = space; y < 100; y += space) { + point(x, y); + } + } + } + +
+ +
+ + // Declare the variable xCoordinates and assign it an array of numbers. + let xCoordinates = [20, 40, 60, 80]; + + function setup() { + createCanvas(100, 100); + + describe('Four white circles drawn in a horizontal line on a gray background.'); + } + + function draw() { + background(200); + + // Access the element at index i and use it to draw a circle. + for (let i = 0; i < xCoordinates.length; i += 1) { + circle(xCoordinates[i], 50, 20); + } + } + +
+ +
+ + // Declare the variable xCoordinates and assign it an array of numbers. + let xCoordinates = [20, 40, 60, 80]; + + function setup() { + createCanvas(100, 100); + + describe('Four white circles drawn in a horizontal line on a gray background.'); + } + + function draw() { + background(200); + + // Access each element of the array and use it to draw a circle. + for (let x of xCoordinates) { + circle(x, 50, 20); + } + } + +
+class: p5 +--- + + +# for diff --git a/src/content/reference/en/p5 copy/fract.mdx b/src/content/reference/en/p5 copy/fract.mdx new file mode 100644 index 0000000000..399f144c09 --- /dev/null +++ b/src/content/reference/en/p5 copy/fract.mdx @@ -0,0 +1,55 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L1048 +title: fract +module: Math +submodule: Calculation +file: src/math/calculation.js +description: | +

Calculates the fractional part of a number.

+

A number's fractional part includes its decimal values. For example, + fract(12.34) returns 0.34.

+line: 1048 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Original number. + let n = 56.78; + text(n, 50, 33); + + // Fractional part. + let f = fract(n); + text(f, 50, 67); + + describe('The number 56.78 written above the number 0.78.'); + } + +
+class: p5 +params: + - name: 'n' + description: | +

number whose fractional part will be found.

+ type: Number +return: + description: fractional part of n. + type: Number +chainable: false +--- + + +# fract diff --git a/src/content/reference/en/p5 copy/frameCount.mdx b/src/content/reference/en/p5 copy/frameCount.mdx new file mode 100644 index 0000000000..f2d02603a0 --- /dev/null +++ b/src/content/reference/en/p5 copy/frameCount.mdx @@ -0,0 +1,73 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L69 +title: frameCount +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

A Number variable that tracks the number of frames drawn since + the sketch + + started.

+ +

frameCount's value is 0 inside setup(). It + + increments by 1 each time the code in draw() + + finishes executing.

+line: 69 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Display the value of + // frameCount. + textSize(30); + textAlign(CENTER, CENTER); + text(frameCount, 50, 50); + + describe('The number 0 written in black in the middle of a gray square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Set the frameRate to 30. + frameRate(30); + + textSize(30); + textAlign(CENTER, CENTER); + + describe('A number written in black in the middle of a gray square. Its value increases rapidly.'); + } + + function draw() { + background(200); + + // Display the value of + // frameCount. + text(frameCount, 50, 50); + } + +
+class: p5 +type: Integer +--- + + +# frameCount diff --git a/src/content/reference/en/p5 copy/frameRate.mdx b/src/content/reference/en/p5 copy/frameRate.mdx new file mode 100644 index 0000000000..38ccddd0d6 --- /dev/null +++ b/src/content/reference/en/p5 copy/frameRate.mdx @@ -0,0 +1,107 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L330 +title: frameRate +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

Sets the number of frames to draw per second.

+ +

Calling frameRate() with one numeric argument, as in + frameRate(30), + + attempts to draw 30 frames per second (FPS). The target frame rate may not + + be achieved depending on the sketch's processing needs. Most computers + + default to a frame rate of 60 FPS. Frame rates of 24 FPS and above are + + fast enough for smooth animations.

+ +

Calling frameRate() without an argument returns the current + frame rate. + + The value returned is an approximation.

+line: 330 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A white circle on a gray background. The circle moves from left to right in a loop. It slows down when the mouse is pressed.'); + } + + function draw() { + background(200); + + // Set the x variable based + // on the current frameCount. + let x = frameCount % 100; + + // If the mouse is pressed, + // decrease the frame rate. + if (mouseIsPressed === true) { + frameRate(10); + } else { + frameRate(60); + } + + // Use x to set the circle's + // position. + circle(x, 50, 20); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A number written in black on a gray background. The number decreases when the mouse is pressed.'); + } + + function draw() { + background(200); + + // If the mouse is pressed, do lots + // of math to slow down drawing. + if (mouseIsPressed === true) { + for (let i = 0; i < 1000000; i += 1) { + random(); + } + } + + // Get the current frame rate + // and display it. + let fps = frameRate(); + text(fps, 50, 50); + } + +
+class: p5 +overloads: + - line: 330 + params: + - name: fps + description: | +

number of frames to draw per second.

+ type: Number + chainable: 1 + - line: 404 + params: [] + return: + description: current frame rate. + type: Number +chainable: true +--- + + +# frameRate diff --git a/src/content/reference/en/p5 copy/freeGeometry.mdx b/src/content/reference/en/p5 copy/freeGeometry.mdx new file mode 100644 index 0000000000..7af36d8620 --- /dev/null +++ b/src/content/reference/en/p5 copy/freeGeometry.mdx @@ -0,0 +1,152 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L748 +title: freeGeometry +module: Shape +submodule: 3D Primitives +file: src/webgl/3d_primitives.js +description: > +

Clears a p5.Geometry object from + the graphics + + processing unit (GPU) memory.

+ +

p5.Geometry objects can contain + lots of data + + about their vertices, surface normals, colors, and so on. Complex 3D shapes + + can use lots of memory which is a limited resource in many GPUs. Calling + + freeGeometry() can improve performance by freeing a + + p5.Geometry object’s resources from + GPU memory. + + freeGeometry() works with p5.Geometry objects + + created with beginGeometry() and + + endGeometry(), + + buildGeometry(), and + + loadModel().

+ +

The parameter, geometry, is the p5.Geometry + + object to be freed.

+ +

Note: A p5.Geometry object can + still be drawn + + after its resources are cleared from GPU memory. It may take longer to draw + + the first time it’s redrawn.

+ +

Note: freeGeometry() can only be used in WebGL mode.

+line: 748 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + // Create a p5.Geometry object. + beginGeometry(); + cone(); + let shape = endGeometry(); + + // Draw the shape. + model(shape); + + // Free the shape's resources. + freeGeometry(shape); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let button; + let particles; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a button to reset the particle system. + button = createButton('Reset'); + + // Call resetModel() when the user presses the button. + button.mousePressed(resetModel); + + // Add the original set of particles. + resetModel(); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the particles. + noStroke(); + + // Draw the particles. + model(particles); + } + + function resetModel() { + // If the p5.Geometry object has already been created, + // free those resources. + if (particles) { + freeGeometry(particles); + } + + // Create a new p5.Geometry object with random spheres. + particles = buildGeometry(createParticles); + } + + function createParticles() { + for (let i = 0; i < 60; i += 1) { + // Calculate random coordinates. + let x = randomGaussian(0, 20); + let y = randomGaussian(0, 20); + let z = randomGaussian(0, 20); + + push(); + // Translate to the particle's coordinates. + translate(x, y, z); + // Draw the particle. + sphere(5); + pop(); + } + } + +
+class: p5 +params: + - name: geometry + description: | +

3D shape whose resources should be freed.

+ type: p5.Geometry +chainable: false +--- + + +# freeGeometry diff --git a/src/content/reference/en/p5 copy/freqToMidi.mdx b/src/content/reference/en/p5 copy/freqToMidi.mdx new file mode 100644 index 0000000000..12c6e1eff9 --- /dev/null +++ b/src/content/reference/en/p5 copy/freqToMidi.mdx @@ -0,0 +1,29 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L825 +title: freqToMidi +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: | +

Returns the closest MIDI note value for + a given frequency.

+line: 825 +isConstructor: false +itemtype: method +class: p5 +params: + - name: frequency + description: | +

A freqeuncy, for example, the "A" + above Middle C is 440Hz

+ type: Number +return: + description: MIDI note value + type: Number +chainable: false +--- + + +# freqToMidi diff --git a/src/content/reference/en/p5 copy/frustum.mdx b/src/content/reference/en/p5 copy/frustum.mdx new file mode 100644 index 0000000000..01ffd87883 --- /dev/null +++ b/src/content/reference/en/p5 copy/frustum.mdx @@ -0,0 +1,175 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L522 +title: frustum +module: 3D +submodule: Camera +file: src/webgl/p5.Camera.js +description: > +

Sets the frustum of the current camera in a 3D sketch.

+ +

In a frustum projection, shapes that are further from the camera appear + + smaller than shapes that are near the camera. This technique, called + + foreshortening, creates realistic 3D scenes.

+ +

frustum() changes the default camera’s perspective by changing + its + + viewing frustum. The frustum is the volume of space that’s visible to the + + camera. The frustum’s shape is a pyramid with its top cut off. The camera + + is placed where the top of the pyramid should be and points towards the + + base of the pyramid. It views everything within the frustum.

+ +

The first four parameters, left, right, + bottom, and top, set the + + coordinates of the frustum’s sides, bottom, and top. For example, calling + + frustum(-100, 100, 200, -200) creates a frustum that’s 200 pixels + wide + + and 400 pixels tall. By default, these coordinates are set based on the + + sketch’s width and height, as in + + ortho(-width / 20, width / 20, height / 20, -height / 20).

+ +

The last two parameters, near and far, set the + distance of the + + frustum’s near and far plane from the camera. For example, calling + + ortho(-100, 100, 200, -200, 50, 1000) creates a frustum that’s + 200 pixels + + wide, 400 pixels tall, starts 50 pixels from the camera, and ends 1,000 + + pixels from the camera. By default, near is set to 0.1 * 800, + which is + + 1/10th the default distance between the camera and the origin. + far is set + + to 10 * 800, which is 10 times the default distance between the + camera + + and the origin.

+ +

Note: frustum() can only be used in WebGL mode.

+line: 522 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A row of white cubes on a gray background.'); + } + + function draw() { + background(200); + + // Apply the default frustum projection. + frustum(); + + // Translate the origin toward the camera. + translate(-10, 10, 600); + + // Rotate the coordinate system. + rotateY(-0.1); + rotateX(-0.1); + + // Draw the row of boxes. + for (let i = 0; i < 6; i += 1) { + translate(0, 0, -40); + box(10); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Adjust the frustum. + // Center it. + // Set its width and height to 20 pixels. + // Place its near plane 300 pixels from the camera. + // Place its far plane 350 pixels from the camera. + frustum(-10, 10, -10, 10, 300, 350); + + // Translate the origin toward the camera. + translate(-10, 10, 600); + + // Rotate the coordinate system. + rotateY(-0.1); + rotateX(-0.1); + + // Draw the row of boxes. + for (let i = 0; i < 6; i += 1) { + translate(0, 0, -40); + box(10); + } + } + +
+class: p5 +params: + - name: left + description: > +

x-coordinate of the frustum’s left plane. Defaults to -width / + 20.

+ type: Number + optional: true + - name: right + description: > +

x-coordinate of the frustum’s right plane. Defaults to width / + 20.

+ type: Number + optional: true + - name: bottom + description: > +

y-coordinate of the frustum’s bottom plane. Defaults to height / + 20.

+ type: Number + optional: true + - name: top + description: > +

y-coordinate of the frustum’s top plane. Defaults to -height / + 20.

+ type: Number + optional: true + - name: near + description: > +

z-coordinate of the frustum’s near plane. Defaults to 0.1 * + 800.

+ type: Number + optional: true + - name: far + description: > +

z-coordinate of the frustum’s far plane. Defaults to 10 * + 800.

+ type: Number + optional: true +chainable: true +--- + + +# frustum diff --git a/src/content/reference/en/p5 copy/fullscreen.mdx b/src/content/reference/en/p5 copy/fullscreen.mdx new file mode 100644 index 0000000000..1c6b2eb7fe --- /dev/null +++ b/src/content/reference/en/p5 copy/fullscreen.mdx @@ -0,0 +1,63 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L950 +title: fullscreen +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

Toggles full-screen mode or returns the current mode.

+ +

Calling fullscreen(true) makes the sketch full-screen. Calling + + fullscreen(false) makes the sketch its original size.

+ +

Calling fullscreen() without an argument returns + true if the sketch + + is in full-screen mode and false if not.

+ +

Note: Due to browser restrictions, fullscreen() can only be + called with + + user input such as a mouse press.

+line: 950 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + background(200); + + describe('A gray canvas that switches between default and full-screen display when clicked.'); + } + + // If the mouse is pressed, + // toggle full-screen mode. + function mousePressed() { + if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) { + let fs = fullscreen(); + fullscreen(!fs); + } + } + +
+class: p5 +params: + - name: val + description: | +

whether the sketch should be in fullscreen mode.

+ type: Boolean + optional: true +return: + description: current fullscreen state. + type: Boolean +chainable: false +--- + + +# fullscreen diff --git a/src/content/reference/en/p5 copy/function.mdx b/src/content/reference/en/p5 copy/function.mdx new file mode 100644 index 0000000000..e213633c86 --- /dev/null +++ b/src/content/reference/en/p5 copy/function.mdx @@ -0,0 +1,19 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L317 +title: function +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: "

A named group of statements.

\n

Functions\nhelp with organizing and reusing code. For example, functions make it easy\nto express the idea \"Draw a flower.\":

\n
function drawFlower() {\n  // Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(20);\n\n  // Draw a flower emoji.\n  text('\U0001F338', 50, 50);\n}\n
\n

The function header begins with the keyword function. The function's\nname, drawFlower, is followed by parentheses () and curly braces {}.\nThe code between the curly braces is called the function's body. The\nfunction's body runs when the function is called like so:

\n
drawFlower();\n
\n

Functions can accept inputs by adding parameters to their headers.\nParameters are placeholders for values that will be provided when the\nfunction is called. For example, the drawFlower() function could include\na parameter for the flower's size:

\n
function drawFlower(size) {\n  // Style the text.\n  textAlign(CENTER, CENTER);\n\n  // Use the size parameter.\n  textSize(size);\n\n  // Draw a flower emoji.\n  text('\U0001F338', 50, 50);\n}\n
\n

Parameters are part of the function's declaration. Arguments are provided\nby the code that calls a function. When a function is called, arguments are\nassigned to parameters:

\n
// The argument 20 is assigned to the parameter size.\ndrawFlower(20);\n
\n

Functions can have multiple parameters separated by commas. Parameters\ncan have any type. For example, the drawFlower() function could accept\nNumber parameters for the flower's x- and y-coordinates along with its\nsize:

\n
function drawFlower(x, y, size) {\n  // Style the text.\n  textAlign(CENTER, CENTER);\n\n  // Use the size parameter.\n  textSize(size);\n\n  // Draw a flower emoji.\n  // Use the x and y parameters.\n  text('\U0001F338', x, y);\n}\n
\n

Functions can also produce outputs by adding a return statement:

\n
function double(x) {\n  let answer = 2 * x;\n  return answer;\n}\n
\n

The expression following return can produce an output that's used\nelsewhere. For example, the output of the double() function can be\nassigned to a variable:

\n
let six = double(3);\ntext(`3 x 2 = ${six}`, 50, 50);\n
\n" +line: 317 +isConstructor: false +itemtype: property +example: + - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n describe('A pink flower on a gray background.');\n}\n\nfunction draw() {\n background(200);\n\n // Call the drawFlower() function.\n drawFlower();\n}\n\n// Declare a function that draws a flower at the\n// center of the canvas.\nfunction drawFlower() {\n // Style the text.\n textAlign(CENTER, CENTER);\n textSize(20);\n\n // Draw a flower emoji.\n text('\U0001F338', 50, 50);\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n describe('A pink flower on a gray background.');\n}\n\nfunction draw() {\n background(200);\n\n // Call the drawFlower() function and pass values for\n // its position and size.\n drawFlower(50, 50, 20);\n}\n\n// Declare a function that draws a flower at the\n// center of the canvas.\nfunction drawFlower(x, y, size) {\n // Style the text.\n textAlign(CENTER, CENTER);\n\n // Use the size parameter.\n textSize(size);\n\n // Draw a flower emoji.\n // Use the x and y parameters.\n text('\U0001F338', x, y);\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n describe('The message \"Hello, \U0001F30D!\" written on a gray background.');\n}\n\nfunction draw() {\n background(200);\n\n // Create a greeting.\n let greeting = createGreeting('\U0001F30D');\n\n // Style the text.\n textAlign(CENTER, CENTER);\n textSize(16);\n\n // Display the greeting.\n text(greeting, 50, 50);\n}\n\n// Return a string with a personalized greeting.\nfunction createGreeting(name) {\n let message = `Hello, ${name}!`;\n return message;\n}\n\n
" +class: p5 +--- + + +# function diff --git a/src/content/reference/en/p5 copy/get.mdx b/src/content/reference/en/p5 copy/get.mdx new file mode 100644 index 0000000000..42cbb8e7f8 --- /dev/null +++ b/src/content/reference/en/p5 copy/get.mdx @@ -0,0 +1,178 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L820 +title: get +module: Image +submodule: Pixels +file: src/image/pixels.js +description: > +

Gets a pixel or a region of pixels from the canvas.

+ +

get() is easy to use but it's not as fast as + + pixels. Use pixels + + to read many pixel values.

+ +

The version of get() with no parameters returns the entire + canvas.

+ +

The version of get() with two parameters interprets them as + + coordinates. It returns an array with the [R, G, B, A] values of + the + + pixel at the given point.

+ +

The version of get() with four parameters interprets them as + coordinates + + and dimensions. It returns a subsection of the canvas as a + + p5.Image object. The first two parameters + are the + + coordinates for the upper-left corner of the subsection. The last two + + parameters are the width and height of the subsection.

+ +

Use p5.Image.get() to work directly + with + + p5.Image objects.

+line: 820 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/rockies.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Get the entire canvas. + let c = get(); + + // Display half the canvas. + image(c, 50, 0); + + describe('Two identical mountain landscapes shown side-by-side.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/rockies.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Get the color of a pixel. + let c = get(50, 90); + + // Style the square with the pixel's color. + fill(c); + noStroke(); + + // Display the square. + square(25, 25, 50); + + describe('A mountain landscape with an olive green square in its center.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/rockies.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + // Get a region of the image. + let c = get(0, 0, 50, 50); + + // Display the region. + image(c, 50, 50); + + describe('A mountain landscape drawn on top of another mountain landscape.'); + } + +
+class: p5 +return: + description: subsection as a p5.Image object. + type: p5.Image +overloads: + - line: 820 + params: + - name: x + description: | +

x-coordinate of the pixel.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the pixel.

+ type: Number + - name: w + description: | +

width of the subsection to be returned.

+ type: Number + - name: h + description: | +

height of the subsection to be returned.

+ type: Number + return: + description: subsection as a p5.Image object. + type: p5.Image + - line: 931 + params: [] + return: + description: whole canvas as a p5.Image. + type: p5.Image + - line: 935 + params: + - name: x + description: '' + type: Number + - name: 'y' + description: '' + type: Number + return: + description: 'color of the pixel at (x, y) in array format `[R, G, B, A]`.' + type: 'Number[]' +chainable: false +--- + + +# get diff --git a/src/content/reference/en/p5 copy/getAudioContext.mdx b/src/content/reference/en/p5 copy/getAudioContext.mdx new file mode 100644 index 0000000000..c7291c5cdf --- /dev/null +++ b/src/content/reference/en/p5 copy/getAudioContext.mdx @@ -0,0 +1,56 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L159 +title: getAudioContext +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: >- +

Returns the Audio Context for this sketch. Useful for users + + who would like to dig deeper into the Web Audio API + + .

+ + +

Some browsers require users to startAudioContext + + with a user gesture, such as touchStarted in the example below.

+line: 159 +isConstructor: false +itemtype: method +example: + - |- + +
+ function draw() { + background(255); + textAlign(CENTER); + + if (getAudioContext().state !== 'running') { + text('click to start audio', width/2, height/2); + } else { + text('audio is enabled', width/2, height/2); + } + } + + function touchStarted() { + if (getAudioContext().state !== 'running') { + getAudioContext().resume(); + } + var synth = new p5.MonoSynth(); + synth.play('A4', 0.5, 0, 0.2); + } + +
+class: p5 +return: + description: AudioContext for this sketch + type: Object +chainable: false +--- + + +# getAudioContext diff --git a/src/content/reference/en/p5 copy/getItem.mdx b/src/content/reference/en/p5 copy/getItem.mdx new file mode 100644 index 0000000000..5747f67366 --- /dev/null +++ b/src/content/reference/en/p5 copy/getItem.mdx @@ -0,0 +1,151 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/data/local_storage.js#L164 +title: getItem +module: Data +submodule: LocalStorage +file: src/data/local_storage.js +description: > +

Returns a value in the web browser's local storage.

+ +

Web browsers can save small amounts of data using the built-in + + localStorage object. + + Data stored in localStorage can be retrieved at any point, even + after + + refreshing a page or restarting the browser. Data are stored as key-value + + pairs.

+ +

storeItem() makes it easy to store + values in + + localStorage and getItem() makes it easy to retrieve + them.

+ +

The first parameter, key, is the name of the value to be + stored as a + + string.

+ +

The second parameter, value, is the value to be retrieved a + string. For + + example, calling getItem('size') retrieves the value with the key + size.

+ +

Note: Sensitive data such as passwords or personal information shouldn't be + + stored in localStorage.

+line: 164 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Store the player's name. + storeItem('name', 'Feist'); + + // Store the player's score. + storeItem('score', 1234); + + describe('The text "Feist: 1234" written in black on a gray background.'); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(14); + + // Retrieve the name. + let name = getItem('name'); + + // Retrieve the score. + let score = getItem('score'); + + // Display the score. + text(`${name}: ${score}`, 50, 50); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Create an object. + let p = { x: 50, y: 50 }; + + // Store the object. + storeItem('position', p); + + describe('A white circle on a gray background.'); + } + + function draw() { + background(200); + + // Retrieve the object. + let p = getItem('position'); + + // Draw the circle. + circle(p.x, p.y, 30); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Create a p5.Color object. + let c = color('deeppink'); + + // Store the object. + storeItem('color', c); + + describe('A pink circle on a gray background.'); + } + + function draw() { + background(200); + + // Retrieve the object. + let c = getItem('color'); + + // Style the circle. + fill(c); + + // Draw the circle. + circle(50, 50, 30); + } + +
+class: p5 +params: + - name: key + description: | +

name of the value.

+ type: String +return: + description: stored item. + type: String|Number|Boolean|Object|Array +chainable: false +--- + + +# getItem diff --git a/src/content/reference/en/p5 copy/getOutputVolume.mdx b/src/content/reference/en/p5 copy/getOutputVolume.mdx new file mode 100644 index 0000000000..6542c5edb6 --- /dev/null +++ b/src/content/reference/en/p5 copy/getOutputVolume.mdx @@ -0,0 +1,25 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L726 +title: getOutputVolume +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: | +

Returns a number representing the output volume for sound + in this sketch.

+line: 726 +isConstructor: false +itemtype: method +class: p5 +return: + description: |- + Output volume for sound in this sketch. + Should be between 0.0 (silence) and 1.0. + type: Number +chainable: false +--- + + +# getOutputVolume diff --git a/src/content/reference/en/p5 copy/getTargetFrameRate.mdx b/src/content/reference/en/p5 copy/getTargetFrameRate.mdx new file mode 100644 index 0000000000..10e3c74a4b --- /dev/null +++ b/src/content/reference/en/p5 copy/getTargetFrameRate.mdx @@ -0,0 +1,48 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L447 +title: getTargetFrameRate +module: Environment +submodule: Environment +file: src/core/environment.js +description: | +

Returns the target frame rate.

+

The value is either the system frame rate or the last value passed to + frameRate().

+line: 447 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('The number 20 written in black on a gray background.'); + } + + function draw() { + background(200); + + // Set the frame rate to 20. + frameRate(20); + + // Get the target frame rate and + // display it. + let fps = getTargetFrameRate(); + text(fps, 43, 54); + } + +
+class: p5 +return: + description: _targetFrameRate + type: Number +chainable: false +--- + + +# getTargetFrameRate diff --git a/src/content/reference/en/p5 copy/getURL.mdx b/src/content/reference/en/p5 copy/getURL.mdx new file mode 100644 index 0000000000..01ccdc8e11 --- /dev/null +++ b/src/content/reference/en/p5 copy/getURL.mdx @@ -0,0 +1,46 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L1149 +title: getURL +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

Returns the sketch's current + + URL + + as a String.

+line: 1149 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + background(200); + + // Get the sketch's URL + // and display it. + let url = getURL(); + textWrap(CHAR); + text(url, 0, 40, 100); + + describe('The URL "https://p5js.org/reference/p5/getURL" written in black on a gray background.'); + } + +
+class: p5 +return: + description: url + type: String +chainable: false +--- + + +# getURL diff --git a/src/content/reference/en/p5 copy/getURLParams.mdx b/src/content/reference/en/p5 copy/getURLParams.mdx new file mode 100644 index 0000000000..c08c77f23f --- /dev/null +++ b/src/content/reference/en/p5 copy/getURLParams.mdx @@ -0,0 +1,59 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L1208 +title: getURLParams +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

Returns the current + + URL parameters + + in an Object.

+ +

For example, calling getURLParams() in a sketch hosted at the + URL + + https://p5js.org?year=2014&month=May&day=15 returns + + { year: 2014, month: 'May', day: 15 }.

+line: 1208 +isConstructor: false +itemtype: method +alt: This example does not render anything. +example: + - |- + +
+ + // Imagine this sketch is hosted at the following URL: + // https://p5js.org?year=2014&month=May&day=15 + + function setup() { + background(200); + + // Get the sketch's URL + // parameters and display + // them. + let params = getURLParams(); + text(params.day, 10, 20); + text(params.month, 10, 40); + text(params.year, 10, 60); + + describe('The text "15", "May", and "2014" written in black on separate lines.'); + } + +
+class: p5 +return: + description: URL params + type: Object +chainable: false +--- + + +# getURLParams diff --git a/src/content/reference/en/p5 copy/getURLPath.mdx b/src/content/reference/en/p5 copy/getURLPath.mdx new file mode 100644 index 0000000000..e71b7746ad --- /dev/null +++ b/src/content/reference/en/p5 copy/getURLPath.mdx @@ -0,0 +1,58 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L1175 +title: getURLPath +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

Returns the current + + URL + + path as an Array of Strings.

+ +

For example, consider a sketch hosted at the URL + + https://example.com/sketchbook. Calling getURLPath() + returns + + ['sketchbook']. For a sketch hosted at the URL + + https://example.com/sketchbook/monday, getURLPath() + returns + + ['sketchbook', 'monday'].

+line: 1175 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + background(200); + + // Get the sketch's URL path + // and display the first + // part. + let path = getURLPath(); + text(path[0], 25, 54); + + describe('The word "reference" written in black on a gray background.'); + } + +
+class: p5 +return: + description: path components. + type: 'String[]' +chainable: false +--- + + +# getURLPath diff --git a/src/content/reference/en/p5 copy/green.mdx b/src/content/reference/en/p5 copy/green.mdx new file mode 100644 index 0000000000..72634492fb --- /dev/null +++ b/src/content/reference/en/p5 copy/green.mdx @@ -0,0 +1,159 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L692 +title: green +module: Color +submodule: Creating & Reading +file: src/color/creating_reading.js +description: > +

Gets the green value of a color.

+ +

green() extracts the green value from a + + p5.Color object, an array of color + components, or + + a CSS color string.

+ +

By default, green() returns a color's green value in the range + 0 + + to 255. If the colorMode() is set to + RGB, it + + returns the green value in the given range.

+line: 692 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object. + let c = color(175, 100, 220); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'greenValue' to 100. + let greenValue = green(c); + + // Draw the right rectangle. + fill(0, greenValue, 0); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is dark green.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a color array. + let c = [175, 100, 220]; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'greenValue' to 100. + let greenValue = green(c); + + // Draw the right rectangle. + fill(0, greenValue, 0); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is dark green.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a CSS color string. + let c = 'rgb(175, 100, 220)'; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'greenValue' to 100. + let greenValue = green(c); + + // Draw the right rectangle. + fill(0, greenValue, 0); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is dark green.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use RGB color with values in the range 0-100. + colorMode(RGB, 100); + + // Create a p5.Color object using RGB values. + let c = color(69, 39, 86); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'greenValue' to 39. + let greenValue = green(c); + + // Draw the right rectangle. + fill(0, greenValue, 0); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is dark green.'); + } + +
+class: p5 +params: + - name: color + description: | +

p5.Color object, array of + color components, or CSS color string.

+ type: 'p5.Color|Number[]|String' +return: + description: the green value. + type: Number +chainable: false +--- + + +# green diff --git a/src/content/reference/en/p5 copy/gridOutput.mdx b/src/content/reference/en/p5 copy/gridOutput.mdx new file mode 100644 index 0000000000..c80c3efaf2 --- /dev/null +++ b/src/content/reference/en/p5 copy/gridOutput.mdx @@ -0,0 +1,189 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/accessibility/outputs.js#L161 +title: gridOutput +module: Environment +submodule: Environment +file: src/accessibility/outputs.js +description: > +

Creates a screen reader-accessible description of shapes on the canvas.

+ +

gridOutput() adds a general description, table of shapes, and + list of + + shapes to the web page. The general description includes the canvas size, + + canvas color, and number of shapes. For example, + + gray canvas, 100 by 100 pixels, contains 2 shapes: 1 circle 1 + square.

+ +

gridOutput() uses its table of shapes as a grid. Each shape in + the grid + + is placed in a cell whose row and column correspond to the shape's location + + on the canvas. The grid cells describe the color and type of shape at that + + location. For example, red circle. These descriptions can be + selected + + individually to get more details. This is different from + + textOutput(), which uses its table as + a list.

+ +

A list of shapes follows the table. The list describes the color, type, + + location, and area of each shape. For example, + + red circle, location = middle, area = 3 %.

+ +

The display parameter is optional. It determines how the + description is + + displayed. If LABEL is passed, as in + gridOutput(LABEL), the description + + will be visible in a div element next to the canvas. Using LABEL + creates + + unhelpful duplicates for screen readers. Only use LABEL during + + development. If FALLBACK is passed, as in + gridOutput(FALLBACK), the + + description will only be visible to screen readers. This is the default + + mode.

+ +

Read + + Writing + accessible canvas descriptions + + to learn more about making sketches accessible.

+ +

gridOutput() generates descriptions in English only. Text + drawn with + + text() is not described. Shapes created with + + beginShape() are not described. WEBGL + mode + + and 3D shapes are not supported.

+ +

Use describe() and + + describeElement() for more + control + + over canvas descriptions.

+line: 161 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + // Add the grid description. + gridOutput(); + + // Draw a couple of shapes. + background(200); + fill(255, 0, 0); + circle(20, 20, 20); + fill(0, 0, 255); + square(50, 50, 50); + + // Add a general description of the canvas. + describe('A red circle and a blue square on a gray background.'); + } + +
+ +
+ + function setup() { + // Add the grid description and + // display it for debugging. + gridOutput(LABEL); + + // Draw a couple of shapes. + background(200); + fill(255, 0, 0); + circle(20, 20, 20); + fill(0, 0, 255); + square(50, 50, 50); + + // Add a general description of the canvas. + describe('A red circle and a blue square on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + } + + function draw() { + // Add the grid description. + gridOutput(); + + // Draw a moving circle. + background(200); + let x = frameCount * 0.1; + fill(255, 0, 0); + circle(x, 20, 20); + fill(0, 0, 255); + square(50, 50, 50); + + // Add a general description of the canvas. + describe('A red circle moves from left to right above a blue square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + } + + function draw() { + // Add the grid description and + // display it for debugging. + gridOutput(LABEL); + + // Draw a moving circle. + background(200); + let x = frameCount * 0.1; + fill(255, 0, 0); + circle(x, 20, 20); + fill(0, 0, 255); + square(50, 50, 50); + + // Add a general description of the canvas. + describe('A red circle moves from left to right above a blue square.'); + } + +
+class: p5 +params: + - name: display + description: | +

either FALLBACK or LABEL.

+ type: Constant + optional: true +chainable: false +--- + + +# gridOutput diff --git a/src/content/reference/en/p5 copy/height.mdx b/src/content/reference/en/p5 copy/height.mdx new file mode 100644 index 0000000000..f6321218df --- /dev/null +++ b/src/content/reference/en/p5 copy/height.mdx @@ -0,0 +1,87 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L881 +title: height +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

A Number variable that stores the height of the canvas in + pixels.

+ +

height's default value is 100. Calling + + createCanvas() or + + resizeCanvas() changes the value of + + height. Calling noCanvas() + sets its value to + + 0.

+line: 881 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + background(200); + + // Display the canvas' height. + text(height, 42, 54); + + describe('The number 100 written in black on a gray square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 50); + + background(200); + + // Display the canvas' height. + text(height, 42, 27); + + describe('The number 50 written in black on a gray rectangle.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Display the canvas' height. + text(height, 42, 54); + + describe('The number 100 written in black on a gray square. When the mouse is pressed, the square becomes a rectangle and the number becomes 50.'); + } + + // If the mouse is pressed, reisze + // the canvas and display its new + // height. + function mousePressed() { + if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) { + resizeCanvas(100, 50); + background(200); + text(height, 42, 27); + } + } + +
+class: p5 +type: Number +--- + + +# height diff --git a/src/content/reference/en/p5 copy/hex.mdx b/src/content/reference/en/p5 copy/hex.mdx new file mode 100644 index 0000000000..5475af324a --- /dev/null +++ b/src/content/reference/en/p5 copy/hex.mdx @@ -0,0 +1,166 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L818 +title: hex +module: Data +submodule: Conversion +file: src/utilities/conversion.js +description: > +

Converts a Number to a String with its + hexadecimal value.

+ +

hex() converts a number to a string with its hexadecimal + number value. + + Hexadecimal (hex) numbers are base-16, which means there are 16 unique + + digits. Hex extends the numbers 0–9 with the letters A–F. For example, the + + number 11 (eleven) in base-10 is written as the letter + B in hex.

+ +

The first parameter, n, is the number to convert. For example, + hex(20), + + returns the string '00000014'. If an array is passed, as in + + hex([1, 10, 100]), an array of hexadecimal strings is + returned.

+ +

The second parameter, digits, is optional. If a number is + passed, as in + + hex(20, 2), it sets the number of hexadecimal digits to display. + For + + example, calling hex(20, 2) returns the string + '14'.

+line: 818 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a number variable. + let original = 20; + + // Convert the number to a hex string. + let converted = hex(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(14); + + // Display the original and converted values. + text(`${original} = ${converted}`, 50, 50); + + describe('The text "20 = 00000014" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a number variable. + let original = 20; + + // Convert the number to a hex string. + // Only display two hex digits. + let converted = hex(original, 2); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the original and converted values. + text(`${original} = ${converted}`, 50, 50); + + describe('The text "20 = 14" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of numbers. + let original = [1, 10, 100]; + + // Convert the numbers to hex strings. + // Only use two hex digits. + let converted = hex(original, 2); + + // Style the text. + textAlign(RIGHT, CENTER); + textSize(16); + + // Iterate over the converted values. + for (let i = 0; i < converted.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 25; + + // Display the original and converted values. + text(`${ original[i]} = ${converted[i]}`, 75, y); + } + + describe( + 'The text "1 = 01", "10 = 0A", and "100 = 64" written on three separate lines. The text is in black on a gray background.' + ); + } + +
+class: p5 +return: + description: converted hexadecimal value. + type: String +overloads: + - line: 818 + params: + - name: 'n' + description: | +

value to convert.

+ type: Number + - name: digits + description: | +

number of digits to include.

+ type: Number + optional: true + return: + description: converted hexadecimal value. + type: String + - line: 926 + params: + - name: ns + description: | +

values to convert.

+ type: 'Number[]' + - name: digits + description: '' + type: Number + optional: true + return: + description: converted hexadecimal values. + type: 'String[]' +chainable: false +--- + + +# hex diff --git a/src/content/reference/en/p5 copy/hour.mdx b/src/content/reference/en/p5 copy/hour.mdx new file mode 100644 index 0000000000..802a809d72 --- /dev/null +++ b/src/content/reference/en/p5 copy/hour.mdx @@ -0,0 +1,47 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L44 +title: hour +module: IO +submodule: Time & Date +file: src/utilities/time_date.js +description: | +

Returns the current hour as a number from 0–23.

+line: 44 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Get the current hour. + let h = hour(); + + // Style the text. + textAlign(LEFT, CENTER); + textSize(12); + textFont('Courier New'); + + // Display the hour. + text(`Current hour: ${h}`, 20, 50, 60); + + describe(`The text 'Current hour: ${h}' written in black on a gray background.`); + } + +
+class: p5 +return: + description: current hour between 0 and 23. + type: Integer +chainable: false +--- + + +# hour diff --git a/src/content/reference/en/p5 copy/httpDo.mdx b/src/content/reference/en/p5 copy/httpDo.mdx new file mode 100644 index 0000000000..52d6553248 --- /dev/null +++ b/src/content/reference/en/p5 copy/httpDo.mdx @@ -0,0 +1,150 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1208 +title: httpDo +module: IO +submodule: Input +file: src/io/files.js +description: > +

Method for executing an HTTP request. If data type is not specified, + + p5 will try to guess based on the URL, defaulting to text.

+ + For more advanced use, you may also pass in the path as the first argument + + and a object as the second argument, the signature follows the one specified + + in the Fetch API specification. + + This method is suitable for fetching files up to size of 64MB when "GET" is + used.

+line: 1208 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Examples use USGS Earthquake API: + // https://earthquake.usgs.gov/fdsnws/event/1/#methods + + // displays an animation of all USGS earthquakes + let earthquakes; + let eqFeatureIndex = 0; + + function preload() { + let url = 'https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson'; + httpDo( + url, + { + method: 'GET', + // Other Request options, like special headers for apis + headers: { authorization: 'Bearer secretKey' } + }, + function(res) { + earthquakes = res; + } + ); + } + + function draw() { + // wait until the data is loaded + if (!earthquakes || !earthquakes.features[eqFeatureIndex]) { + return; + } + clear(); + + let feature = earthquakes.features[eqFeatureIndex]; + let mag = feature.properties.mag; + let rad = mag / 11 * ((width + height) / 2); + fill(255, 0, 0, 100); + ellipse(width / 2 + random(-2, 2), height / 2 + random(-2, 2), rad, rad); + + if (eqFeatureIndex >= earthquakes.features.length) { + eqFeatureIndex = 0; + } else { + eqFeatureIndex += 1; + } + } + +
+class: p5 +return: + description: |- + A promise that resolves with the data when the operation + completes successfully or rejects with the error after + one occurs. + type: Promise +overloads: + - line: 1208 + params: + - name: path + description: | +

name of the file or url to load

+ type: String + - name: method + description: | +

either "GET", "POST", or "PUT", + defaults to "GET"

+ type: String + optional: true + - name: datatype + description: | +

"json", "jsonp", "xml", or "text"

+ type: String + optional: true + - name: data + description: | +

param data passed sent with request

+ type: Object + optional: true + - name: callback + description: | +

function to be executed after + httpGet() completes, data is passed in + as first argument

+ type: Function + optional: true + - name: errorCallback + description: | +

function to be executed if + there is an error, response is passed + in as first argument

+ type: Function + optional: true + return: + description: |- + A promise that resolves with the data when the operation + completes successfully or rejects with the error after + one occurs. + type: Promise + - line: 1279 + params: + - name: path + description: '' + type: String + - name: options + description: > +

Request object options as documented in the + "fetch" API + reference

+ type: Object + - name: callback + description: '' + type: Function + optional: true + - name: errorCallback + description: '' + type: Function + optional: true + return: + description: '' + type: Promise +chainable: false +--- + + +# httpDo diff --git a/src/content/reference/en/p5 copy/httpGet.mdx b/src/content/reference/en/p5 copy/httpGet.mdx new file mode 100644 index 0000000000..9e8591e059 --- /dev/null +++ b/src/content/reference/en/p5 copy/httpGet.mdx @@ -0,0 +1,140 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1043 +title: httpGet +module: IO +submodule: Input +file: src/io/files.js +description: > +

Method for executing an HTTP GET request. If data type is not specified, + + p5 will try to guess based on the URL, defaulting to text. This is equivalent + to + + calling httpDo(path, 'GET'). The 'binary' datatype will return + + a Blob object, and the 'arrayBuffer' datatype will return an ArrayBuffer + + which can be used to initialize typed arrays (such as Uint8Array).

+line: 1043 +isConstructor: false +itemtype: method +example: + - |- + +
+ // Examples use USGS Earthquake API: + // https://earthquake.usgs.gov/fdsnws/event/1/#methods + let earthquakes; + function preload() { + // Get the most recent earthquake in the database + let url = + 'https://earthquake.usgs.gov/fdsnws/event/1/query?' + + 'format=geojson&limit=1&orderby=time'; + httpGet(url, 'jsonp', false, function(response) { + // when the HTTP request completes, populate the variable that holds the + // earthquake data used in the visualization. + earthquakes = response; + }); + } + + function draw() { + if (!earthquakes) { + // Wait until the earthquake data has loaded before drawing. + return; + } + background(200); + // Get the magnitude and name of the earthquake out of the loaded JSON + let earthquakeMag = earthquakes.features[0].properties.mag; + let earthquakeName = earthquakes.features[0].properties.place; + ellipse(width / 2, height / 2, earthquakeMag * 10, earthquakeMag * 10); + textAlign(CENTER); + text(earthquakeName, 0, height - 30, width, 30); + noLoop(); + } +
+class: p5 +return: + description: |- + A promise that resolves with the data when the operation + completes successfully or rejects with the error after + one occurs. + type: Promise +overloads: + - line: 1043 + params: + - name: path + description: | +

name of the file or url to load

+ type: String + - name: datatype + description: | +

"json", "jsonp", "binary", "arrayBuffer", + "xml", or "text"

+ type: String + optional: true + - name: data + description: | +

param data passed sent with request

+ type: Object|Boolean + optional: true + - name: callback + description: | +

function to be executed after + httpGet() completes, data is passed in + as first argument

+ type: Function + optional: true + - name: errorCallback + description: | +

function to be executed if + there is an error, response is passed + in as first argument

+ type: Function + optional: true + return: + description: |- + A promise that resolves with the data when the operation + completes successfully or rejects with the error after + one occurs. + type: Promise + - line: 1097 + params: + - name: path + description: '' + type: String + - name: data + description: '' + type: Object|Boolean + - name: callback + description: '' + type: Function + optional: true + - name: errorCallback + description: '' + type: Function + optional: true + return: + description: '' + type: Promise + - line: 1105 + params: + - name: path + description: '' + type: String + - name: callback + description: '' + type: Function + - name: errorCallback + description: '' + type: Function + optional: true + return: + description: '' + type: Promise +chainable: false +--- + + +# httpGet diff --git a/src/content/reference/en/p5 copy/httpPost.mdx b/src/content/reference/en/p5 copy/httpPost.mdx new file mode 100644 index 0000000000..39f4fc75a0 --- /dev/null +++ b/src/content/reference/en/p5 copy/httpPost.mdx @@ -0,0 +1,165 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1119 +title: httpPost +module: IO +submodule: Input +file: src/io/files.js +description: > +

Method for executing an HTTP POST request. If data type is not specified, + + p5 will try to guess based on the URL, defaulting to text. This is equivalent + to + + calling httpDo(path, 'POST').

+line: 1119 +isConstructor: false +itemtype: method +example: + - >- + +
+ + + + // Examples use jsonplaceholder.typicode.com for a Mock Data API + + + let url = 'https://jsonplaceholder.typicode.com/posts'; + + let postData = { userId: 1, title: 'p5 Clicked!', body: 'p5.js is very + cool.' }; + + + function setup() { + createCanvas(100, 100); + background(200); + } + + + function mousePressed() { + httpPost(url, 'json', postData, function(result) { + strokeWeight(2); + text(result.body, mouseX, mouseY); + }); + } + + + +
+ + +
+ + let url = 'ttps://invalidURL'; // A bad URL that will cause errors + + let postData = { title: 'p5 Clicked!', body: 'p5.js is very cool.' }; + + + function setup() { + createCanvas(100, 100); + background(200); + } + + + function mousePressed() { + httpPost( + url, + 'json', + postData, + function(result) { + // ... won't be called + }, + function(error) { + strokeWeight(2); + text(error.toString(), mouseX, mouseY); + } + ); + } + +
+class: p5 +return: + description: |- + A promise that resolves with the data when the operation + completes successfully or rejects with the error after + one occurs. + type: Promise +overloads: + - line: 1119 + params: + - name: path + description: | +

name of the file or url to load

+ type: String + - name: datatype + description: | +

"json", "jsonp", "xml", or "text". + If omitted, httpPost() will guess.

+ type: String + optional: true + - name: data + description: | +

param data passed sent with request

+ type: Object|Boolean + optional: true + - name: callback + description: | +

function to be executed after + httpPost() completes, data is passed in + as first argument

+ type: Function + optional: true + - name: errorCallback + description: | +

function to be executed if + there is an error, response is passed + in as first argument

+ type: Function + optional: true + return: + description: |- + A promise that resolves with the data when the operation + completes successfully or rejects with the error after + one occurs. + type: Promise + - line: 1186 + params: + - name: path + description: '' + type: String + - name: data + description: '' + type: Object|Boolean + - name: callback + description: '' + type: Function + optional: true + - name: errorCallback + description: '' + type: Function + optional: true + return: + description: '' + type: Promise + - line: 1194 + params: + - name: path + description: '' + type: String + - name: callback + description: '' + type: Function + - name: errorCallback + description: '' + type: Function + optional: true + return: + description: '' + type: Promise +chainable: false +--- + + +# httpPost diff --git a/src/content/reference/en/p5 copy/hue.mdx b/src/content/reference/en/p5 copy/hue.mdx new file mode 100644 index 0000000000..6baca2b9ce --- /dev/null +++ b/src/content/reference/en/p5 copy/hue.mdx @@ -0,0 +1,145 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L828 +title: hue +module: Color +submodule: Creating & Reading +file: src/color/creating_reading.js +description: > +

Gets the hue value of a color.

+ +

hue() extracts the hue value from a + + p5.Color object, an array of color + components, or + + a CSS color string.

+ +

Hue describes a color's position on the color wheel. By default, + hue() + + returns a color's HSL hue in the range 0 to 360. If the + + colorMode() is set to HSB or HSL, it + returns the hue + + value in the given mode.

+line: 828 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use HSL color. + colorMode(HSL); + + // Create a p5.Color object. + let c = color(0, 50, 100); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 20, 35, 60); + + // Set 'hueValue' to 0. + let hueValue = hue(c); + + // Draw the right rectangle. + fill(hueValue); + rect(50, 20, 35, 60); + + describe( + 'Two rectangles. The rectangle on the left is salmon pink and the one on the right is black.' + ); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use HSL color. + colorMode(HSL); + + // Create a color array. + let c = [0, 50, 100]; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 20, 35, 60); + + // Set 'hueValue' to 0. + let hueValue = hue(c); + + // Draw the right rectangle. + fill(hueValue); + rect(50, 20, 35, 60); + + describe( + 'Two rectangles. The rectangle on the left is salmon pink and the one on the right is black.' + ); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use HSL color. + colorMode(HSL); + + // Create a CSS color string. + let c = 'rgb(255, 128, 128)'; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 20, 35, 60); + + // Set 'hueValue' to 0. + let hueValue = hue(c); + + // Draw the right rectangle. + fill(hueValue); + rect(50, 20, 35, 60); + + describe( + 'Two rectangles. The rectangle on the left is salmon pink and the one on the right is black.' + ); + } + +
+class: p5 +params: + - name: color + description: | +

p5.Color object, array of + color components, or CSS color string.

+ type: 'p5.Color|Number[]|String' +return: + description: the hue value. + type: Number +chainable: false +--- + + +# hue diff --git a/src/content/reference/en/p5 copy/if.mdx b/src/content/reference/en/p5 copy/if.mdx new file mode 100644 index 0000000000..88228b3ed0 --- /dev/null +++ b/src/content/reference/en/p5 copy/if.mdx @@ -0,0 +1,268 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L110 +title: if +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: > +

A way to choose whether to run a block of code.

+ +

if statements are helpful for running a block of code based on + a + + condition. For example, an if statement makes it easy to express + the + + idea "Draw a circle if the mouse is pressed.":

+ +
if (mouseIsPressed === true) {
+    circle(mouseX, mouseY, 20);
+  }
+
+  
+ +

The statement header begins with the keyword if. The + expression in + + parentheses mouseIsPressed === true is a Boolean + expression that's + + either true or false. The code between the curly + braces {} is the if + + statement's body. The body only runs if the Boolean expression is + true.

+ +

The mouseIsPressed system + variable is + + always true or false, so the code snippet above + could also be written + + as follows:

+ +
if (mouseIsPressed) {
+    circle(mouseX, mouseY, 20);
+  }
+
+  
+ +

An if-else statement adds a block of code that + runs if the Boolean + + expression is false. For example, here's an + if-else statement that + + expresses the idea "Draw a circle if the mouse is pressed. Otherwise, + + display a message.":

+ +
if (mouseIsPressed === true) {
+    // When true.
+    circle(mouseX, mouseY, 20);
+  } else {
+    // When false.
+    text('Click me!', 50, 50);
+  }
+
+  
+ +

There are two possible paths, or branches, in this code snippet. The + + program must follow one branch or the other.

+ +

An else-if statement makes it possible to add + more branches. + + else-if statements run different blocks of code + under different + + conditions. For example, an else-if statement makes + it easy to express + + the idea "If the mouse is on the left, paint the canvas white. If the mouse + + is in the middle, paint the canvas gray. Otherwise, paint the canvas + + black.":

+ +
if (mouseX < 33) {
+    background(255);
+  } else if (mouseX < 67) {
+    background(200);
+  } else {
+    background(0);
+  }
+
+  
+ +

if statements can add as many + else-if statements as needed. However, + + there can only be one else statement and it must be last.

+ +

if statements can also check for multiple conditions at once. + For + + example, the Boolean operator && (AND) checks + whether two expressions + + are both true:

+ +
if (keyIsPressed === true && key === 'p') {
+    text('You pressed the "p" key!', 50, 50);
+  }
+
+  
+ +

If the user is pressing a key AND that key is 'p', then a + message will + + display.

+ +

The Boolean operator || (OR) checks whether at + least one of two + + expressions is true:

+ +
if (keyIsPressed === true || mouseIsPressed ===
+  true) {
+    text('You did something!', 50, 50);
+  }
+
+  
+ +

If the user presses a key, or presses a mouse button, or both, then a + + message will display.

+ +

The body of an if statement can contain another + if statement. This is + + called a "nested if statement." For example, nested + if statements make + + it easy to express the idea "If a key is pressed, then check if the key is + + 'r'. If it is, then set the fill to red.":

+ +
if (keyIsPressed === true) {
+    if (key === 'r') {
+      fill('red');
+    }
+  }
+
+  
+ +

See Boolean and Number + + to learn more about these data types and the operations they support.

+line: 110 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // Click the mouse to show the circle. + + function setup() { + createCanvas(100, 100); + + describe( + 'A white circle on a gray background. The circle follows the mouse user clicks on the canvas.' + ); + } + + function draw() { + background(200); + + if (mouseIsPressed === true) { + circle(mouseX, mouseY, 20); + } + } + +
+ +
+ + // Click the mouse to show different shapes. + + function setup() { + createCanvas(100, 100); + + describe( + 'A white ellipse on a gray background. The ellipse becomes a circle when the user presses the mouse.' + ); + } + + function draw() { + background(200); + + if (mouseIsPressed === true) { + circle(50, 50, 20); + } else { + ellipse(50, 50, 20, 50); + } + } + +
+ +
+ + // Move the mouse to change the background color. + + function setup() { + createCanvas(100, 100); + + describe( + 'A square changes color from white to black as the user moves the mouse from left to right.' + ); + } + + function draw() { + if (mouseX < 33) { + background(255); + } else if (mouseX < 67) { + background(200); + } else { + background(0); + } + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + function setup() { + createCanvas(100, 100); + + describe( + 'A white circle drawn on a gray background. The circle changes color to red when the user presses the "r" key.' + ); + } + + function draw() { + background(200); + + if (keyIsPressed === true) { + if (key === 'r') { + fill('red'); + } + } + + circle(50, 50, 40); + } + +
+class: p5 +--- + + +# if diff --git a/src/content/reference/en/p5 copy/image.mdx b/src/content/reference/en/p5 copy/image.mdx new file mode 100644 index 0000000000..9dbd36fd22 --- /dev/null +++ b/src/content/reference/en/p5 copy/image.mdx @@ -0,0 +1,327 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L888 +title: image +module: Image +submodule: Loading & Displaying +file: src/image/loading_displaying.js +description: > +

Draws an image to the canvas.

+ +

The first parameter, img, is the source image to be drawn. + img can be + + any of the following objects:

+ + + +

The second and third parameters, dx and dy, set + the coordinates of the + + destination image's top left corner. See + + imageMode() for other ways to position + images.

+ +

Here's a diagram that explains how optional parameters work in + image():

+ +

+ +

The fourth and fifth parameters, dw and dh, are + optional. They set the + + the width and height to draw the destination image. By default, + image() + + draws the full source image at its original size.

+ +

The sixth and seventh parameters, sx and sy, are + also optional. + + These coordinates define the top left corner of a subsection to draw from + + the source image.

+ +

The eighth and ninth parameters, sw and sh, are + also optional. + + They define the width and height of a subsection to draw from the source + + image. By default, image() draws the full subsection that begins + at + + (sx, sy) and extends to the edges of the source image.

+ +

The ninth parameter, fit, is also optional. It enables a + subsection of + + the source image to be drawn without affecting its aspect ratio. If + + CONTAIN is passed, the full subsection will appear within the + destination + + rectangle. If COVER is passed, the subsection will completely + cover the + + destination rectangle. This may have the effect of zooming into the + + subsection.

+ +

The tenth and eleventh parameters, xAlign and + yAlign, are also + + optional. They determine how to align the fitted subsection. + xAlign can + + be set to either LEFT, RIGHT, or + CENTER. yAlign can be set to + + either TOP, BOTTOM, or CENTER. By + default, both xAlign and yAlign + + are set to CENTER.

+line: 888 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100); + + background(50); + + // Draw the image. + image(img, 0, 0); + + describe('An image of the underside of a white umbrella with a gridded ceiling above.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100); + + background(50); + + // Draw the image. + image(img, 10, 10); + + describe('An image of the underside of a white umbrella with a gridded ceiling above. The image has dark gray borders on its left and top.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100); + + background(50); + + // Draw the image 50x50. + image(img, 0, 0, 50, 50); + + describe('An image of the underside of a white umbrella with a gridded ceiling above. The image is drawn in the top left corner of a dark gray square.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100); + + background(50); + + // Draw the center of the image. + image(img, 25, 25, 50, 50, 25, 25, 50, 50); + + describe('An image of a gridded ceiling drawn in the center of a dark gray square.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/moonwalk.jpg'); + } + + function setup() { + createCanvas(100, 100); + + background(50); + + // Draw the image and scale it to fit within the canvas. + image(img, 0, 0, width, height, 0, 0, img.width, img.height, CONTAIN); + + describe('An image of an astronaut on the moon. The top and bottom borders of the image are dark gray.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + // Image is 50 x 50 pixels. + img = loadImage('/assets/laDefense50.png'); + } + + function setup() { + createCanvas(100, 100); + + background(50); + + // Draw the image and scale it to cover the canvas. + image(img, 0, 0, width, height, 0, 0, img.width, img.height, COVER); + + describe('A pixelated image of the underside of a white umbrella with a gridded ceiling above.'); + } + +
+class: p5 +overloads: + - line: 888 + params: + - name: img + description: | +

image to display.

+ type: p5.Image|p5.Element|p5.Texture|p5.Framebuffer|p5.FramebufferTexture + - name: x + description: | +

x-coordinate of the top-left corner of the image.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the top-left corner of the image.

+ type: Number + - name: width + description: | +

width to draw the image.

+ type: Number + optional: true + - name: height + description: | +

height to draw the image.

+ type: Number + optional: true + - line: 1074 + params: + - name: img + description: '' + type: p5.Image|p5.Element|p5.Texture|p5.Framebuffer|p5.FramebufferTexture + - name: dx + description: | +

the x-coordinate of the destination + rectangle in which to draw the source image

+ type: Number + - name: dy + description: | +

the y-coordinate of the destination + rectangle in which to draw the source image

+ type: Number + - name: dWidth + description: | +

the width of the destination rectangle

+ type: Number + - name: dHeight + description: | +

the height of the destination rectangle

+ type: Number + - name: sx + description: | +

the x-coordinate of the subsection of the source + image to draw into the destination rectangle

+ type: Number + - name: sy + description: | +

the y-coordinate of the subsection of the source + image to draw into the destination rectangle

+ type: Number + - name: sWidth + description: | +

the width of the subsection of the + source image to draw into the destination + rectangle

+ type: Number + optional: true + - name: sHeight + description: | +

the height of the subsection of the + source image to draw into the destination rectangle

+ type: Number + optional: true + - name: fit + description: | +

either CONTAIN or COVER

+ type: Constant + optional: true + - name: xAlign + description: | +

either LEFT, RIGHT or CENTER default is CENTER

+ type: Constant + optional: true + - name: yAlign + description: | +

either TOP, BOTTOM or CENTER default is CENTER

+ type: Constant + optional: true +chainable: false +--- + + +# image diff --git a/src/content/reference/en/p5 copy/imageLight.mdx b/src/content/reference/en/p5 copy/imageLight.mdx new file mode 100644 index 0000000000..70b001f3e5 --- /dev/null +++ b/src/content/reference/en/p5 copy/imageLight.mdx @@ -0,0 +1,86 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L956 +title: imageLight +module: 3D +submodule: Lights +file: src/webgl/light.js +description: > +

Creates an ambient light from an image.

+ +

imageLight() simulates a light shining from all directions. + The effect is + + like placing the sketch at the center of a giant sphere that uses the image + + as its texture. The image's diffuse light will be affected by + + fill() and the specular reflections will be + + affected by specularMaterial() + and + + shininess().

+ +

The parameter, img, is the p5.Image object to + + use as the light source.

+line: 956 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + let img; + + // Load an image and create a p5.Image object. + function preload() { + img = loadImage('/assets/outdoor_spheremap.jpg'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A sphere floating above a landscape. The surface of the sphere reflects the landscape.'); + } + + function draw() { + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the image as a panorama (360˚ background). + panorama(img); + + // Add a soft ambient light. + ambientLight(50); + + // Add light from the image. + imageLight(img); + + // Style the sphere. + specularMaterial(20); + shininess(100); + noStroke(); + + // Draw the sphere. + sphere(30); + } + +
+class: p5 +params: + - name: img + description: | +

image to use as the light source.

+ type: p5.image +chainable: false +--- + + +# imageLight diff --git a/src/content/reference/en/p5 copy/imageMode.mdx b/src/content/reference/en/p5 copy/imageMode.mdx new file mode 100644 index 0000000000..f7d41c6d54 --- /dev/null +++ b/src/content/reference/en/p5 copy/imageMode.mdx @@ -0,0 +1,129 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L1395 +title: imageMode +module: Image +submodule: Loading & Displaying +file: src/image/loading_displaying.js +description: > +

Changes the location from which images are drawn when + + image() is called.

+ +

By default, the first + + two parameters of image() are the x- and + + y-coordinates of the image's upper-left corner. The next parameters are + + its width and height. This is the same as calling + imageMode(CORNER).

+ +

imageMode(CORNERS) also uses the first two parameters of + + image() as the x- and y-coordinates of the + image's + + top-left corner. The third and fourth parameters are the coordinates of its + + bottom-right corner.

+ +

imageMode(CENTER) uses the first two parameters of + + image() as the x- and y-coordinates of the + image's + + center. The next parameters are its width and height.

+line: 1395 +isConstructor: false +itemtype: method +example: + - |- + + +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Use CORNER mode. + imageMode(CORNER); + + // Display the image. + image(img, 10, 10, 50, 50); + + describe('A square image of a brick wall is drawn at the top left of a gray square.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Use CORNERS mode. + imageMode(CORNERS); + + // Display the image. + image(img, 10, 10, 90, 40); + + describe('An image of a brick wall is drawn on a gray square. The image is squeezed into a small rectangular area.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Use CENTER mode. + imageMode(CENTER); + + // Display the image. + image(img, 50, 50, 80, 80); + + describe('A square image of a brick wall is drawn on a gray square.'); + } + +
+class: p5 +params: + - name: mode + description: | +

either CORNER, CORNERS, or CENTER.

+ type: Constant +chainable: false +--- + + +# imageMode diff --git a/src/content/reference/en/p5 copy/input.mdx b/src/content/reference/en/p5 copy/input.mdx new file mode 100644 index 0000000000..83f71feabc --- /dev/null +++ b/src/content/reference/en/p5 copy/input.mdx @@ -0,0 +1,88 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L405 +title: input +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Calls a function when the element receives input.

+ +

myElement.input() is often used to with text inputs and + sliders. Calling + + myElement.input(false) disables the function.

+line: 405 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let slider; + + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a slider and place it beneath the canvas. + slider = createSlider(0, 255, 200); + slider.position(0, 100); + + // Call repaint() when the slider changes. + slider.input(repaint); + + describe('A gray square with a range slider underneath it. The background changes shades of gray when the slider is moved.'); + } + + // Paint the background using slider's value. + function repaint() { + let g = slider.value(); + background(g); + } + +
+ +
+ + let input; + + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an input and place it beneath the canvas. + input = createInput(''); + input.position(0, 100); + + // Call repaint() when input is detected. + input.input(repaint); + + describe('A gray square with a text input bar beneath it. Any text written in the input appears in the middle of the square.'); + } + + // Paint the background gray and display the input's value. + function repaint() { + background(200); + let msg = input.value(); + text(msg, 5, 50); + } + +
+class: p5 +params: + - name: fxn + description: | +

function to call when input is detected within + the element. + false disables the function.

+ type: Function|Boolean +chainable: true +--- + + +# input diff --git a/src/content/reference/en/p5 copy/int.mdx b/src/content/reference/en/p5 copy/int.mdx new file mode 100644 index 0000000000..5d5fe8826a --- /dev/null +++ b/src/content/reference/en/p5 copy/int.mdx @@ -0,0 +1,169 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L92 +title: int +module: Data +submodule: Conversion +file: src/utilities/conversion.js +description: > +

Converts a Boolean, String, or decimal + Number to an integer.

+ +

int() converts values to integers. Integers are positive or + negative + + numbers without decimals. If the original value has decimals, as in -34.56, + + they're removed to produce an integer such as -34.

+ +

The parameter, n, is the value to convert. If n + is a Boolean, as in + + int(false) or int(true), then the number 0 + (false) or 1 (true) will + + be returned. If n is a string or number, as in + int('45') or + + int(67.89), then an integer will be returned. If an array is + passed, as + + in int([12.34, 56.78]), then an array of integers will be + returned.

+ +

Note: If a value can't be converted to a number, as in + int('giraffe'), + + then the value NaN (not a number) will be returned.

+line: 92 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a Boolean variable. + let original = false; + + // Convert the Boolean to an integer. + let converted = int(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the original and converted values. + text(`${original} : ${converted}`, 50, 50); + + describe('The text "false : 0" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let original = '12.34'; + + // Convert the string to an integer. + let converted = int(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(14); + + // Display the original and converted values. + text(`${original} ≈ ${converted}`, 50, 50); + + describe('The text "12.34 ≈ 12" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a decimal number variable. + let original = 12.34; + + // Convert the decimal number to an integer. + let converted = int(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(14); + + // Display the original and converted values. + text(`${original} ≈ ${converted}`, 50, 50); + + describe('The text "12.34 ≈ 12" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of strings. + let original = ['60', '30', '15']; + + // Convert the strings to integers. + let diameters = int(original); + + for (let d of diameters) { + // Draw a circle. + circle(50, 50, d); + } + + describe('Three white, concentric circles on a gray background.'); + } + +
+class: p5 +return: + description: converted number. + type: Number +overloads: + - line: 92 + params: + - name: 'n' + description: | +

value to convert.

+ type: String|Boolean|Number + return: + description: converted number. + type: Number + - line: 211 + params: + - name: ns + description: | +

values to convert.

+ type: Array + return: + description: converted numbers. + type: 'Number[]' +chainable: false +--- + + +# int diff --git a/src/content/reference/en/p5 copy/isLooping.mdx b/src/content/reference/en/p5 copy/isLooping.mdx new file mode 100644 index 0000000000..622fd77d9b --- /dev/null +++ b/src/content/reference/en/p5 copy/isLooping.mdx @@ -0,0 +1,65 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L224 +title: isLooping +module: Structure +submodule: Structure +file: src/core/structure.js +description: > +

Returns true if the draw loop is running and + false if not.

+ +

By default, draw() tries to run 60 times + per + + second. Calling noLoop() stops + + draw() from repeating. The draw loop can be + + restarted by calling loop().

+ +

The isLooping() function can be used to check whether a sketch + is + + looping, as in isLooping() === true.

+line: 224 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A white circle drawn against a gray background. When the user double-clicks, the circle stops or resumes following the mouse.'); + } + + function draw() { + background(200); + + // Draw the circle at the mouse's position. + circle(mouseX, mouseY, 20); + } + + // Toggle the draw loop when the user double-clicks. + function doubleClicked() { + if (isLooping() === true) { + noLoop(); + } else { + loop(); + } + } + +
+class: p5 +return: + description: '' + type: Boolean +chainable: false +--- + + +# isLooping diff --git a/src/content/reference/en/p5 copy/join.mdx b/src/content/reference/en/p5 copy/join.mdx new file mode 100644 index 0000000000..23222a6db4 --- /dev/null +++ b/src/content/reference/en/p5 copy/join.mdx @@ -0,0 +1,70 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L15 +title: join +module: Data +submodule: String Functions +file: src/utilities/string_functions.js +description: > +

Combines an array of strings into one string.

+ +

The first parameter, list, is the array of strings to + join.

+ +

The second parameter, separator, is the character(s) that + should be used + + to separate the combined strings. For example, calling + + join(myWords, ' : ') would return a string of words each + separated by a + + colon and spaces.

+line: 15 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of strings. + let myWords = ['one', 'two', 'three']; + + // Create a combined string + let combined = join(myWords, ' : '); + + // Style the text. + textAlign(CENTER, CENTER); + + // Display the combined string. + text(combined, 50, 50); + + describe('The text "one : two : three" written in black on a gray canvas.'); + } + +
+class: p5 +params: + - name: list + description: | +

array of strings to combine.

+ type: Array + - name: separator + description: | +

character(s) to place between strings when they're combined.

+ type: String +return: + description: combined string. + type: String +chainable: false +--- + + +# join diff --git a/src/content/reference/en/p5 copy/key.mdx b/src/content/reference/en/p5 copy/key.mdx new file mode 100644 index 0000000000..63fc144fa3 --- /dev/null +++ b/src/content/reference/en/p5 copy/key.mdx @@ -0,0 +1,106 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L102 +title: key +module: Events +submodule: Keyboard +file: src/events/keyboard.js +description: > +

A String system variable that contains the value of the last + key typed.

+ +

The key variable is helpful for checking whether an + + ASCII + + key has been typed. For example, the expression key === "a" + evaluates to + + true if the a key was typed and false + if not. key doesn’t update + + for special keys such as LEFT_ARROW and ENTER. Use + keyCode instead for + + special keys. The keyIsDown() function + should + + be used to check for multiple different key presses at the same time.

+line: 102 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // Click on the canvas to begin detecting key presses. + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square. The last key pressed is displayed at the center.' + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the last key pressed. + text(key, 50, 50); + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + let x = 50; + let y = 50; + + function setup() { + createCanvas(100, 100); + + background(200); + + describe( + 'A gray square with a black circle at its center. The circle moves when the user presses the keys "w", "a", "s", or "d". It leaves a trail as it moves.' + ); + } + + function draw() { + // Update x and y if a key is pressed. + if (keyIsPressed === true) { + if (key === 'w') { + y -= 1; + } else if (key === 's') { + y += 1; + } else if (key === 'a') { + x -= 1; + } else if (key === 'd') { + x += 1; + } + } + + // Style the circle. + fill(0); + + // Draw the circle at (x, y). + circle(x, y, 5); + } + +
+class: p5 +type: String +--- + + +# key diff --git a/src/content/reference/en/p5 copy/keyCode.mdx b/src/content/reference/en/p5 copy/keyCode.mdx new file mode 100644 index 0000000000..808526b788 --- /dev/null +++ b/src/content/reference/en/p5 copy/keyCode.mdx @@ -0,0 +1,128 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L184 +title: keyCode +module: Events +submodule: Keyboard +file: src/events/keyboard.js +description: > +

A Number system variable that contains the code of the last + key typed.

+ +

All keys have a keyCode. For example, the a key + has the keyCode 65. + + The keyCode variable is helpful for checking whether a special + key has + + been typed. For example, the following conditional checks whether the enter + + key has been typed:

+ +
if (keyCode === 13) {
+    // Code to run if the enter key was pressed.
+  }
+
+  
+ +

The same code can be written more clearly using the system variable + ENTER + + which has a value of 13:

+ +
if (keyCode === ENTER) {
+    // Code to run if the enter key was pressed.
+  }
+
+  
+ +

The system variables BACKSPACE, DELETE, + ENTER, RETURN, TAB, + + ESCAPE, SHIFT, CONTROL, + OPTION, ALT, UP_ARROW, + DOWN_ARROW, + + LEFT_ARROW, and RIGHT_ARROW are all helpful + shorthands the key codes of + + special keys. Key codes can be found on websites such as + + keycode.info.

+line: 184 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // Click on the canvas to begin detecting key presses. + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square. The last key pressed and its code are displayed at the center.' + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the last key pressed and its code. + text(`${key} : ${keyCode}`, 50, 50); + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + let x = 50; + let y = 50; + + function setup() { + createCanvas(100, 100); + + background(200); + + describe( + 'A gray square with a black circle at its center. The circle moves when the user presses an arrow key. It leaves a trail as it moves.' + ); + } + + function draw() { + // Update x and y if an arrow key is pressed. + if (keyIsPressed === true) { + if (keyCode === UP_ARROW) { + y -= 1; + } else if (keyCode === DOWN_ARROW) { + y += 1; + } else if (keyCode === LEFT_ARROW) { + x -= 1; + } else if (keyCode === RIGHT_ARROW) { + x += 1; + } + } + + // Style the circle. + fill(0); + + // Draw the circle at (x, y). + circle(x, y, 5); + } + +
+class: p5 +type: Integer +--- + + +# keyCode diff --git a/src/content/reference/en/p5 copy/keyIsDown.mdx b/src/content/reference/en/p5 copy/keyIsDown.mdx new file mode 100644 index 0000000000..8afe4b0bdf --- /dev/null +++ b/src/content/reference/en/p5 copy/keyIsDown.mdx @@ -0,0 +1,142 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L811 +title: keyIsDown +module: Events +submodule: Keyboard +file: src/events/keyboard.js +description: > +

Returns true if the key it’s checking is pressed and + false if not.

+ +

keyIsDown() is helpful when checking for multiple different + key presses. + + For example, keyIsDown() can be used to check if both + LEFT_ARROW and + + UP_ARROW are pressed:

+ +
if (keyIsDown(LEFT_ARROW) &&
+  keyIsDown(UP_ARROW)) {
+    // Move diagonally.
+  }
+
+  
+ +

keyIsDown() can check for key presses using + + keyCode values, as in + keyIsDown(37) or + + keyIsDown(LEFT_ARROW). Key codes can be found on websites such as + + keycode.info.

+line: 811 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click on the canvas to begin detecting key presses. + + let x = 50; + let y = 50; + + function setup() { + createCanvas(100, 100); + + background(200); + + describe( + 'A gray square with a black circle at its center. The circle moves when the user presses an arrow key. It leaves a trail as it moves.' + ); + } + + function draw() { + // Update x and y if an arrow key is pressed. + if (keyIsDown(LEFT_ARROW) === true) { + x -= 1; + } + + if (keyIsDown(RIGHT_ARROW) === true) { + x += 1; + } + + if (keyIsDown(UP_ARROW) === true) { + y -= 1; + } + + if (keyIsDown(DOWN_ARROW) === true) { + y += 1; + } + + // Style the circle. + fill(0); + + // Draw the circle. + circle(x, y, 5); + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + let x = 50; + let y = 50; + + function setup() { + createCanvas(100, 100); + + background(200); + + describe( + 'A gray square with a black circle at its center. The circle moves when the user presses an arrow key. It leaves a trail as it moves.' + ); + } + + function draw() { + // Update x and y if an arrow key is pressed. + if (keyIsDown(37) === true) { + x -= 1; + } + + if (keyIsDown(39) === true) { + x += 1; + } + + if (keyIsDown(38) === true) { + y -= 1; + } + + if (keyIsDown(40) === true) { + y += 1; + } + + // Style the circle. + fill(0); + + // Draw the circle. + circle(x, y, 5); + } + +
+class: p5 +params: + - name: code + description: | +

key to check.

+ type: Number +return: + description: whether the key is down or not. + type: Boolean +chainable: false +--- + + +# keyIsDown diff --git a/src/content/reference/en/p5 copy/keyIsPressed.mdx b/src/content/reference/en/p5 copy/keyIsPressed.mdx new file mode 100644 index 0000000000..0b129c49e8 --- /dev/null +++ b/src/content/reference/en/p5 copy/keyIsPressed.mdx @@ -0,0 +1,105 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L10 +title: keyIsPressed +module: Events +submodule: Keyboard +file: src/events/keyboard.js +description: > +

A Boolean system variable that's true if any key + is currently pressed + + and false if not.

+line: 10 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // Click on the canvas to begin detecting key presses. + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a white square at its center. The white square turns black when the user presses a key.' + ); + } + + function draw() { + background(200); + + // Style the square. + if (keyIsPressed === true) { + fill(0); + } else { + fill(255); + } + + // Draw the square. + square(25, 25, 50); + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a white square at its center. The white square turns black when the user presses a key.' + ); + } + + function draw() { + background(200); + + // Style the square. + if (keyIsPressed) { + fill(0); + } else { + fill(255); + } + + // Draw the square. + square(25, 25, 50); + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with the word "false" at its center. The word switches to "true" when the user presses a key.' + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the value of keyIsPressed. + text(keyIsPressed, 50, 50); + } + +
+class: p5 +type: Boolean +--- + + +# keyIsPressed diff --git a/src/content/reference/en/p5 copy/keyPressed.mdx b/src/content/reference/en/p5 copy/keyPressed.mdx new file mode 100644 index 0000000000..4a4007f09a --- /dev/null +++ b/src/content/reference/en/p5 copy/keyPressed.mdx @@ -0,0 +1,192 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L284 +title: keyPressed +module: Events +submodule: Keyboard +file: src/events/keyboard.js +description: > +

A function that's called once when any key is pressed.

+ +

Declaring the function keyPressed() sets a code block to run + once + + automatically when the user presses any key:

+ +
function keyPressed() {
+    // Code to run.
+  }
+
+  
+ +

The key and keyCode + + variables will be updated with the most recently typed value when + + keyPressed() is called by p5.js:

+ +
function keyPressed() {
+    if (key === 'c') {
+      // Code to run.
+    }
+
+    if (keyCode === ENTER) {
+      // Code to run.
+    }
+  }
+
+  
+ +

The parameter, event, is optional. keyPressed() + is always passed a + + KeyboardEvent + + object with properties that describe the key press event:

+ +
function keyPressed(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

Browsers may have default behaviors attached to various key events. For + + example, some browsers may jump to the bottom of a web page when the + + SPACE key is pressed. To prevent any default behavior for this + event, add + + return false; to the end of the function.

+line: 284 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click on the canvas to begin detecting key presses. + + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square changes color when the user presses a key.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Toggle the background color when the user presses a key. + function keyPressed() { + if (value === 0) { + value = 255; + } else { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a white square at its center. The inner square turns black when the user presses the "b" key. It turns white when the user presses the "a" key.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Reassign value when the user presses the 'a' or 'b' key. + function keyPressed() { + if (key === 'a') { + value = 255; + } else if (key === 'b') { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square turns white when the user presses the left arrow key. It turns black when the user presses the right arrow key.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Toggle the background color when the user presses an arrow key. + function keyPressed() { + if (keyCode === LEFT_ARROW) { + value = 255; + } else if (keyCode === RIGHT_ARROW) { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+class: p5 +params: + - name: event + description: | +

optional KeyboardEvent callback argument.

+ type: KeyboardEvent + optional: true +chainable: false +--- + + +# keyPressed diff --git a/src/content/reference/en/p5 copy/keyReleased.mdx b/src/content/reference/en/p5 copy/keyReleased.mdx new file mode 100644 index 0000000000..e19da953f1 --- /dev/null +++ b/src/content/reference/en/p5 copy/keyReleased.mdx @@ -0,0 +1,188 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L474 +title: keyReleased +module: Events +submodule: Keyboard +file: src/events/keyboard.js +description: > +

A function that's called once when any key is released.

+ +

Declaring the function keyReleased() sets a code block to run + once + + automatically when the user releases any key:

+ +
function keyReleased() {
+    // Code to run.
+  }
+
+  
+ +

The key and keyCode + + variables will be updated with the most recently released value when + + keyReleased() is called by p5.js:

+ +
function keyReleased() {
+    if (key === 'c') {
+      // Code to run.
+    }
+
+    if (keyCode === ENTER) {
+      // Code to run.
+    }
+  }
+
+  
+ +

The parameter, event, is optional. keyReleased() + is always passed a + + KeyboardEvent + + object with properties that describe the key press event:

+ +
function keyReleased(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

Browsers may have default behaviors attached to various key events. To + + prevent any default behavior for this event, add return false; to + the end + + of the function.

+line: 474 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click on the canvas to begin detecting key presses. + + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square changes color when the user releases a key.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Toggle value when the user releases a key. + function keyReleased() { + if (value === 0) { + value = 255; + } else { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square becomes white when the user releases the "w" key.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Set value to 255 the user releases the 'w' key. + function keyReleased() { + if (key === 'w') { + value = 255; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square turns white when the user presses and releases the left arrow key. It turns black when the user presses and releases the right arrow key.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Toggle the background color when the user releases an arrow key. + function keyReleased() { + if (keyCode === LEFT_ARROW) { + value = 255; + } else if (keyCode === RIGHT_ARROW) { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+class: p5 +params: + - name: event + description: | +

optional KeyboardEvent callback argument.

+ type: KeyboardEvent + optional: true +chainable: false +--- + + +# keyReleased diff --git a/src/content/reference/en/p5 copy/keyTyped.mdx b/src/content/reference/en/p5 copy/keyTyped.mdx new file mode 100644 index 0000000000..a591db9e60 --- /dev/null +++ b/src/content/reference/en/p5 copy/keyTyped.mdx @@ -0,0 +1,170 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L655 +title: keyTyped +module: Events +submodule: Keyboard +file: src/events/keyboard.js +description: > +

A function that's called once when keys with printable characters are + pressed.

+ +

Declaring the function keyTyped() sets a code block to run + once + + automatically when the user presses any key with a printable character such + + as a or 1. Modifier keys such as SHIFT, + CONTROL, and the arrow keys + + will be ignored:

+ +
function keyTyped() {
+    // Code to run.
+  }
+
+  
+ +

The key and keyCode + + variables will be updated with the most recently released value when + + keyTyped() is called by p5.js:

+ +
function keyTyped() {
+    // Check for the "c" character using key.
+    if (key === 'c') {
+      // Code to run.
+    }
+
+    // Check for "c" using keyCode.
+    if (keyCode === 67) {
+      // Code to run.
+    }
+  }
+
+  
+ +

The parameter, event, is optional. keyTyped() is + always passed a + + KeyboardEvent + + object with properties that describe the key press event:

+ +
function keyReleased(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

Note: Use the keyPressed() function + and + + keyCode system variable to respond to + modifier + + keys such as ALT.

+ +

Browsers may have default behaviors attached to various key events. To + + prevent any default behavior for this event, add return false; to + the end + + of the function.

+line: 655 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click on the canvas to begin detecting key presses. + // Note: Pressing special keys such as SPACE have no effect. + + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a white square at its center. The inner square changes color when the user presses a key.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Toggle the square's color when the user types a printable key. + function keyTyped() { + if (value === 0) { + value = 255; + } else { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a white square at its center. The inner square turns black when the user types the "b" key. It turns white when the user types the "a" key.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Reassign value when the user types the 'a' or 'b' key. + function keyTyped() { + if (key === 'a') { + value = 255; + } else if (key === 'b') { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+class: p5 +params: + - name: event + description: | +

optional KeyboardEvent callback argument.

+ type: KeyboardEvent + optional: true +chainable: false +--- + + +# keyTyped diff --git a/src/content/reference/en/p5 copy/lerp.mdx b/src/content/reference/en/p5 copy/lerp.mdx new file mode 100644 index 0000000000..84c4b5bc7a --- /dev/null +++ b/src/content/reference/en/p5 copy/lerp.mdx @@ -0,0 +1,122 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L332 +title: lerp +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Calculates a number between two numbers at a specific increment.

+ +

The amt parameter is the amount to interpolate between the two + numbers. + + 0.0 is equal to the first number, 0.1 is very near the first number, 0.5 is + + half-way in between, and 1.0 is equal to the second number. The + lerp() + + function is convenient for creating motion along a straight path and for + + drawing dotted lines.

+ +

If the value of amt is less than 0 or more than 1, + lerp() will return a + + number outside of the original interval. For example, calling + + lerp(0, 10, 1.5) will return 15.

+line: 332 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Declare variables for coordinates. + let a = 20; + let b = 80; + let c = lerp(a, b, 0.2); + let d = lerp(a, b, 0.5); + let e = lerp(a, b, 0.8); + + strokeWeight(5); + + // Draw the original points in black. + stroke(0); + point(a, 50); + point(b, 50); + + // Draw the lerped points in gray. + stroke(100); + point(c, 50); + point(d, 50); + point(e, 50); + + describe('Five points in a horizontal line. The outer points are black and the inner points are gray.'); + } + +
+ +
+ + let x = 50; + let y = 50; + let targetX = 50; + let targetY = 50; + + function setup() { + createCanvas(100, 100); + + background(200); + + describe('A white circle at the center of a gray canvas. The circle moves to where the user clicks, then moves smoothly back to the center.'); + } + + function draw() { + background(220); + + // Move x and y toward the target. + x = lerp(x, targetX, 0.05); + y = lerp(y, targetY, 0.05); + + // Draw the circle. + circle(x, y, 20); + } + + // Set x and y when the user clicks the mouse. + function mouseClicked() { + x = mouseX; + y = mouseY; + } + +
+class: p5 +params: + - name: start + description: | +

first value.

+ type: Number + - name: stop + description: | +

second value.

+ type: Number + - name: amt + description: | +

number.

+ type: Number +return: + description: lerped value. + type: Number +chainable: false +--- + + +# lerp diff --git a/src/content/reference/en/p5 copy/lerpColor.mdx b/src/content/reference/en/p5 copy/lerpColor.mdx new file mode 100644 index 0000000000..d815ba9ddb --- /dev/null +++ b/src/content/reference/en/p5 copy/lerpColor.mdx @@ -0,0 +1,96 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L949 +title: lerpColor +module: Color +submodule: Creating & Reading +file: src/color/creating_reading.js +description: > +

Blends two colors to find a third color between them.

+ +

The amt parameter specifies the amount to interpolate between + the two + + values. 0 is equal to the first color, 0.1 is very near the first color, + + 0.5 is halfway between the two colors, and so on. Negative numbers are set + + to 0. Numbers greater than 1 are set to 1. This differs from the behavior of + + lerp. It's necessary because numbers outside + of the + + interval [0, 1] will produce strange and unexpected colors.

+ +

The way that colors are interpolated depends on the current + + colorMode().

+line: 949 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create p5.Color objects to interpolate between. + let from = color(218, 165, 32); + let to = color(72, 61, 139); + + // Create intermediate colors. + let interA = lerpColor(from, to, 0.33); + let interB = lerpColor(from, to, 0.66); + + // Draw the left rectangle. + noStroke(); + fill(from); + rect(10, 20, 20, 60); + + // Draw the left-center rectangle. + fill(interA); + rect(30, 20, 20, 60); + + // Draw the right-center rectangle. + fill(interB); + rect(50, 20, 20, 60); + + // Draw the right rectangle. + fill(to); + rect(70, 20, 20, 60); + + describe( + 'Four rectangles. From left to right, the rectangles are tan, brown, brownish purple, and purple.' + ); + } + +
+class: p5 +params: + - name: c1 + description: > +

interpolate from this color (any value created by the color() + function).

+ type: p5.Color + - name: c2 + description: > +

interpolate to this color (any value created by the color() + function).

+ type: p5.Color + - name: amt + description: | +

number between 0 and 1.

+ type: Number +return: + description: interpolated color. + type: p5.Color +chainable: false +--- + + +# lerpColor diff --git a/src/content/reference/en/p5 copy/let.mdx b/src/content/reference/en/p5 copy/let.mdx new file mode 100644 index 0000000000..f04902a9b0 --- /dev/null +++ b/src/content/reference/en/p5 copy/let.mdx @@ -0,0 +1,91 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L7 +title: let +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: > +

Declares a new variable.

+ +

A variable is a container for a value. For example, a variable might + + contain a creature's x-coordinate as a Number or its name as a + + String. Variables can change value by reassigning them as + follows:

+ +
// Declare the variable x and assign it the
+  value 10.
+
+  let x = 10;
+
+
+  // Reassign x to 50.
+
+  x = 50;
+
+  
+ +

Variables have block scope. When a variable is declared between curly + + braces {}, it only exists within the block defined by those + braces. For + + example, the following code would throw a ReferenceError because + x is + + declared within the setup() function's block:

+ +
function setup() {
+    createCanvas(100, 100);
+
+    let x = 50;
+  }
+
+
+  function draw() {
+    background(200);
+
+    // x was declared in setup(), so it can't be referenced here.
+    circle(x, 50, 20);
+  }
+
+  
+ +

Variables declared outside of all curly braces {} are in the + global + + scope. A variable that's in the global scope can be used and changed + + anywhere in a sketch:

+ +
let x = 50;
+
+
+  function setup() {
+    createCanvas(100, 100);
+  }
+
+
+  function draw() {
+    background(200);
+
+    // Change the value of x.
+    x += 10;
+
+    circle(x, 50, 20);
+  }
+
+  
+line: 7 +isConstructor: false +itemtype: property +example: + - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(220);\n\n // Style the text.\n textAlign(CENTER);\n textSize(16);\n\n // Create the message variable.\n let message = 'Hello, \U0001F30D!';\n\n // Display the message.\n text(message, 50, 50);\n\n describe('The text \"Hello, \U0001F30D!\" written on a gray background.');\n}\n\n
\n\n
\n\nlet x = 0;\n\nfunction setup() {\n createCanvas(100, 100);\n\n describe('A white circle moves from left to right against a gray background.');\n}\n\nfunction draw() {\n background(220);\n\n // Change the value of x.\n x += 1;\n\n circle(x, 50, 20);\n}\n\n
" +class: p5 +--- + + +# let diff --git a/src/content/reference/en/p5 copy/lightFalloff.mdx b/src/content/reference/en/p5 copy/lightFalloff.mdx new file mode 100644 index 0000000000..e8b8245064 --- /dev/null +++ b/src/content/reference/en/p5 copy/lightFalloff.mdx @@ -0,0 +1,100 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L1161 +title: lightFalloff +module: 3D +submodule: Lights +file: src/webgl/light.js +description: > +

Sets the falloff rate for pointLight() + + and spotLight().

+ +

A light’s falloff describes the intensity of its beam at a distance. For + + example, a lantern has a slow falloff, a flashlight has a medium falloff, + + and a laser pointer has a sharp falloff.

+ +

lightFalloff() has three parameters, constant, + linear, and + + quadratic. They’re numbers used to calculate falloff at a + distance, d, + + as follows:

+ +

falloff = 1 / (constant + d * linear + (d * d) * + quadratic)

+ +

Note: constant, linear, and + quadratic should always be set to values + + greater than 0.

+line: 1161 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click to change the falloff rate. + + let useFalloff = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A sphere drawn against a gray background. The intensity of the light changes when the user double-clicks.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Set the light falloff. + if (useFalloff === true) { + lightFalloff(2, 0, 0); + } + + // Add a white point light from the front. + pointLight(255, 255, 255, 0, 0, 100); + + // Style the sphere. + noStroke(); + + // Draw the sphere. + sphere(30); + } + + // Change the falloff value when the user double-clicks. + function doubleClicked() { + useFalloff = true; + } + +
+class: p5 +params: + - name: constant + description: | +

constant value for calculating falloff.

+ type: Number + - name: linear + description: | +

linear value for calculating falloff.

+ type: Number + - name: quadratic + description: | +

quadratic value for calculating falloff.

+ type: Number +chainable: true +--- + + +# lightFalloff diff --git a/src/content/reference/en/p5 copy/lightness.mdx b/src/content/reference/en/p5 copy/lightness.mdx new file mode 100644 index 0000000000..284523dcc8 --- /dev/null +++ b/src/content/reference/en/p5 copy/lightness.mdx @@ -0,0 +1,168 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L1134 +title: lightness +module: Color +submodule: Creating & Reading +file: src/color/creating_reading.js +description: > +

Gets the lightness value of a color.

+ +

lightness() extracts the HSL lightness value from a + + p5.Color object, an array of color + components, or + + a CSS color string.

+ +

By default, lightness() returns a color's HSL lightness in the + range 0 + + to 100. If the colorMode() is set to + HSL, it + + returns the lightness value in the given range.

+line: 1134 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(50); + + // Use HSL color. + colorMode(HSL); + + // Create a p5.Color object using HSL values. + let c = color(0, 100, 75); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'lightValue' to 75. + let lightValue = lightness(c); + + // Draw the right rectangle. + fill(lightValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is gray.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(50); + + // Use HSL color. + colorMode(HSL); + + // Create a color array. + let c = [0, 100, 75]; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'lightValue' to 75. + let lightValue = lightness(c); + + // Draw the right rectangle. + fill(lightValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is gray.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(50); + + // Use HSL color. + colorMode(HSL); + + // Create a CSS color string. + let c = 'rgb(255, 128, 128)'; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'lightValue' to 75. + let lightValue = lightness(c); + + // Draw the right rectangle. + fill(lightValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is gray.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(50); + + // Use HSL color with values in the range 0-255. + colorMode(HSL, 255); + + // Create a p5.Color object using HSL values. + let c = color(0, 255, 191.5); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'lightValue' to 191.5. + let lightValue = lightness(c); + + // Draw the right rectangle. + fill(lightValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is gray.'); + } + +
+class: p5 +params: + - name: color + description: | +

p5.Color object, array of + color components, or CSS color string.

+ type: 'p5.Color|Number[]|String' +return: + description: the lightness value. + type: Number +chainable: false +--- + + +# lightness diff --git a/src/content/reference/en/p5 copy/lights.mdx b/src/content/reference/en/p5 copy/lights.mdx new file mode 100644 index 0000000000..a7cf3ba7ae --- /dev/null +++ b/src/content/reference/en/p5 copy/lights.mdx @@ -0,0 +1,88 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L1077 +title: lights +module: 3D +submodule: Lights +file: src/webgl/light.js +description: | +

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.

+line: 1077 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click to turn on the lights. + + let isLit = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white box drawn against a gray background. The quality of the light changes when the user double-clicks.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Control the lights. + if (isLit === true) { + lights(); + } + + // Draw the box. + box(); + } + + // Turn on the lights when the user double-clicks. + function doubleClicked() { + isLit = true; + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white box drawn against a gray background.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + ambientLight(128, 128, 128); + directionalLight(128, 128, 128, 0, 0, -1); + + // Draw the box. + box(); + } + +
+class: p5 +chainable: true +--- + + +# lights diff --git a/src/content/reference/en/p5 copy/line.mdx b/src/content/reference/en/p5 copy/line.mdx new file mode 100644 index 0000000000..b225222235 --- /dev/null +++ b/src/content/reference/en/p5 copy/line.mdx @@ -0,0 +1,194 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L564 +title: line +module: Shape +submodule: 2D Primitives +file: src/core/shape/2d_primitives.js +description: > +

Draws a straight line between two points.

+ +

A line's default width is one pixel. The version of line() + with four + + parameters draws the line in 2D. To color a line, use the + + stroke() function. To change its width, + use the + + strokeWeight() function. A line + + can't be filled, so the fill() function + won't + + affect the line's color.

+ +

The version of line() with six parameters allows the line to + be drawn in + + 3D space. Doing so requires adding the WEBGL argument to + + createCanvas().

+line: 564 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + line(30, 20, 85, 75); + + describe( + 'A black line on a gray canvas running from top-center to bottom-right.' + ); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the line. + stroke('magenta'); + strokeWeight(5); + + line(30, 20, 85, 75); + + describe( + 'A thick, magenta line on a gray canvas running from top-center to bottom-right.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Top. + line(30, 20, 85, 20); + + // Right. + stroke(126); + line(85, 20, 85, 75); + + // Bottom. + stroke(255); + line(85, 75, 30, 75); + + describe( + 'Three lines drawn in grayscale on a gray canvas. They form the top, right, and bottom sides of a square.' + ); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + line(-20, -30, 35, 25); + + describe( + 'A black line on a gray canvas running from top-center to bottom-right.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A black line connecting two spheres. The scene spins slowly.'); + } + + function draw() { + background(200); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Draw a line. + line(0, 0, 0, 30, 20, -10); + + // Draw the center sphere. + sphere(10); + + // Translate to the second point. + translate(30, 20, -10); + + // Draw the bottom-right sphere. + sphere(10); + } + +
+class: p5 +overloads: + - line: 564 + params: + - name: x1 + description: | +

the x-coordinate of the first point.

+ type: Number + - name: y1 + description: | +

the y-coordinate of the first point.

+ type: Number + - name: x2 + description: | +

the x-coordinate of the second point.

+ type: Number + - name: y2 + description: | +

the y-coordinate of the second point.

+ type: Number + chainable: 1 + - line: 696 + params: + - name: x1 + description: '' + type: Number + - name: y1 + description: '' + type: Number + - name: z1 + description: | +

the z-coordinate of the first point.

+ type: Number + - name: x2 + description: '' + type: Number + - name: y2 + description: '' + type: Number + - name: z2 + description: | +

the z-coordinate of the second point.

+ type: Number + chainable: 1 +chainable: true +--- + + +# line diff --git a/src/content/reference/en/p5 copy/linePerspective.mdx b/src/content/reference/en/p5 copy/linePerspective.mdx new file mode 100644 index 0000000000..80bf539c73 --- /dev/null +++ b/src/content/reference/en/p5 copy/linePerspective.mdx @@ -0,0 +1,164 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L280 +title: linePerspective +module: 3D +submodule: Camera +file: src/webgl/p5.Camera.js +description: > +

Enables or disables perspective for lines in 3D sketches.

+ +

In WebGL mode, lines can be drawn with a thinner stroke when they’re + + further from the camera. Doing so gives them a more realistic appearance.

+ +

By default, lines are drawn differently based on the type of perspective + + being used:

+ +
    + +
  • perspective() and frustum() simulate a realistic + perspective. In + + these modes, stroke weight is affected by the line’s distance from the + + camera. Doing so results in a more natural appearance. + perspective() is + + the default mode for 3D sketches.
  • + +
  • ortho() doesn’t simulate a realistic perspective. In this + mode, stroke + + weights are consistent regardless of the line’s distance from the camera. + + Doing so results in a more predictable and consistent appearance.
  • + +
+ +

linePerspective() can override the default line drawing + mode.

+ +

The parameter, enable, is optional. It’s a + Boolean value that sets the + + way lines are drawn. If true is passed, as in + linePerspective(true), + + then lines will appear thinner when they are further from the camera. If + + false is passed, as in linePerspective(false), then + lines will have + + consistent stroke weights regardless of their distance from the camera. By + + default, linePerspective() is enabled.

+ +

Calling linePerspective() without passing an argument returns + true if + + it's enabled and false if not.

+ +

Note: linePerspective() can only be used in WebGL mode.

+line: 280 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Double-click the canvas to toggle the line perspective. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'A white cube with black edges on a gray background. Its edges toggle between thick and thin when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Translate the origin toward the camera. + translate(-10, 10, 600); + + // Rotate the coordinate system. + rotateY(-0.1); + rotateX(-0.1); + + // Draw the row of boxes. + for (let i = 0; i < 6; i += 1) { + translate(0, 0, -40); + box(10); + } + } + + // Toggle the line perspective when the user double-clicks. + function doubleClicked() { + let isEnabled = linePerspective(); + linePerspective(!isEnabled); + } + +
+ +
+ + // Double-click the canvas to toggle the line perspective. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'A row of cubes with black edges on a gray background. Their edges toggle between thick and thin when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Use an orthographic projection. + ortho(); + + // Translate the origin toward the camera. + translate(-10, 10, 600); + + // Rotate the coordinate system. + rotateY(-0.1); + rotateX(-0.1); + + // Draw the row of boxes. + for (let i = 0; i < 6; i += 1) { + translate(0, 0, -40); + box(10); + } + } + + // Toggle the line perspective when the user double-clicks. + function doubleClicked() { + let isEnabled = linePerspective(); + linePerspective(!isEnabled); + } + +
+class: p5 +overloads: + - line: 280 + params: + - name: enable + description: | +

whether to enable line perspective.

+ type: Boolean + - line: 392 + params: [] + return: + description: whether line perspective is enabled. + type: Boolean +chainable: false +--- + + +# linePerspective diff --git a/src/content/reference/en/p5 copy/loadBytes.mdx b/src/content/reference/en/p5 copy/loadBytes.mdx new file mode 100644 index 0000000000..8b02c0683e --- /dev/null +++ b/src/content/reference/en/p5 copy/loadBytes.mdx @@ -0,0 +1,56 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L986 +title: loadBytes +module: IO +submodule: Input +file: src/io/files.js +description: | +

This method is suitable for fetching files up to size of 64MB.

+line: 986 +isConstructor: false +itemtype: method +example: + - |- + +
+ let data; + + function preload() { + data = loadBytes('/assets/mammals.xml'); + } + + function setup() { + for (let i = 0; i < 5; i++) { + console.log(data.bytes[i].toString(16)); + } + describe('no image displayed'); + } +
+class: p5 +params: + - name: file + description: | +

name of the file or URL to load

+ type: String + - name: callback + description: | +

function to be executed after loadBytes() + completes

+ type: Function + optional: true + - name: errorCallback + description: | +

function to be executed if there + is an error

+ type: Function + optional: true +return: + description: an object whose 'bytes' property will be the loaded buffer + type: Object +chainable: false +--- + + +# loadBytes diff --git a/src/content/reference/en/p5 copy/loadFont.mdx b/src/content/reference/en/p5 copy/loadFont.mdx new file mode 100644 index 0000000000..86af4b7123 --- /dev/null +++ b/src/content/reference/en/p5 copy/loadFont.mdx @@ -0,0 +1,171 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/loading_displaying.js#L16 +title: loadFont +module: Typography +submodule: Loading & Displaying +file: src/typography/loading_displaying.js +description: > +

Loads a font and creates a p5.Font + object. + + loadFont() can load fonts in either .otf or .ttf format. Loaded + fonts can + + be used to style text on the canvas and in HTML elements.

+ +

The first parameter, path, is the path to a font file. + + Paths to local files should be relative. For example, + + '/assets/inconsolata.otf'. The Inconsolata font used in the + following + + examples can be downloaded for free + + here. + + Paths to remote files should be URLs. For example, + + 'https://example.com/inconsolata.otf'. URLs may be blocked due to + browser + + security.

+ +

The second parameter, successCallback, is optional. If a + function is + + passed, it will be called once the font has loaded. The callback function + + may use the new p5.Font object if + needed.

+ +

The third parameter, failureCallback, is also optional. If a + function is + + passed, it will be called if the font fails to load. The callback function + + may use the error + + Event + + object if needed.

+ +

Fonts can take time to load. Calling loadFont() in + + preload() ensures fonts load before + they're + + used in setup() or + + draw().

+line: 16 +isConstructor: false +itemtype: method +example: + - |- + + +
+ + let font; + + function preload() { + font = loadFont('/assets/inconsolata.otf'); + } + + function setup() { + fill('deeppink'); + textFont(font); + textSize(36); + text('p5*js', 10, 50); + + describe('The text "p5*js" written in pink on a white background.'); + } + +
+ +
+ + function setup() { + loadFont('/assets/inconsolata.otf', font => { + fill('deeppink'); + textFont(font); + textSize(36); + text('p5*js', 10, 50); + + describe('The text "p5*js" written in pink on a white background.'); + }); + } + +
+ +
+ + function setup() { + loadFont('/assets/inconsolata.otf', success, failure); + } + + function success(font) { + fill('deeppink'); + textFont(font); + textSize(36); + text('p5*js', 10, 50); + + describe('The text "p5*js" written in pink on a white background.'); + } + + function failure(event) { + console.error('Oops!', event); + } + +
+ +
+ + function preload() { + loadFont('/assets/inconsolata.otf'); + } + + function setup() { + let p = createP('p5*js'); + p.style('color', 'deeppink'); + p.style('font-family', 'Inconsolata'); + p.style('font-size', '36px'); + p.position(10, 50); + + describe('The text "p5*js" written in pink on a white background.'); + } + +
+class: p5 +params: + - name: path + description: | +

path of the font to be loaded.

+ type: String + - name: successCallback + description: | +

function called with the + p5.Font object after it + loads.

+ type: Function + optional: true + - name: failureCallback + description: | +

function called with the error + Event + object if the font fails to load.

+ type: Function + optional: true +return: + description: p5.Font object. + type: p5.Font +chainable: false +--- + + +# loadFont diff --git a/src/content/reference/en/p5 copy/loadImage.mdx b/src/content/reference/en/p5 copy/loadImage.mdx new file mode 100644 index 0000000000..7e5b8bf0b7 --- /dev/null +++ b/src/content/reference/en/p5 copy/loadImage.mdx @@ -0,0 +1,137 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L18 +title: loadImage +module: Image +submodule: Loading & Displaying +file: src/image/loading_displaying.js +description: > +

Loads an image to create a p5.Image + object.

+ +

loadImage() interprets the first parameter one of three ways. + If the path + + to an image file is provided, loadImage() will load it. Paths to + local + + files should be relative, such as '/assets/thundercat.jpg'. URLs + such as + + 'https://example.com/thundercat.jpg' may be blocked due to + browser + + security. Raw image data can also be passed as a base64 encoded image in + + the form 'data:image/png;base64,arandomsequenceofcharacters'.

+ +

The second parameter is optional. If a function is passed, it will be + + called once the image has loaded. The callback function can optionally use + + the new p5.Image object.

+ +

The third parameter is also optional. If a function is passed, it will be + + called if the image fails to load. The callback function can optionally use + + the event error.

+ +

Images can take time to load. Calling loadImage() in + + preload() ensures images load before + they're + + used in setup() or draw().

+line: 18 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load the image and create a p5.Image object. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Draw the image. + image(img, 0, 0); + + describe('Image of the underside of a white umbrella and a gridded ceiling.'); + } + +
+ +
+ + function setup() { + // Call handleImage() once the image loads. + loadImage('/assets/laDefense.jpg', handleImage); + + describe('Image of the underside of a white umbrella and a gridded ceiling.'); + } + + // Display the image. + function handleImage(img) { + image(img, 0, 0); + } + +
+ +
+ + function setup() { + // Call handleImage() once the image loads or + // call handleError() if an error occurs. + loadImage('/assets/laDefense.jpg', handleImage, handleError); + } + + // Display the image. + function handleImage(img) { + image(img, 0, 0); + + describe('Image of the underside of a white umbrella and a gridded ceiling.'); + } + + // Log the error. + function handleError(event) { + console.error('Oops!', event); + } + +
+class: p5 +params: + - name: path + description: | +

path of the image to be loaded or base64 encoded image.

+ type: String + - name: successCallback + description: | +

function called with + p5.Image once it + loads.

+ type: function(p5.Image) + optional: true + - name: failureCallback + description: | +

function called with event + error if the image fails to load.

+ type: Function(Event) + optional: true +return: + description: the p5.Image object. + type: p5.Image +chainable: false +--- + + +# loadImage diff --git a/src/content/reference/en/p5 copy/loadJSON.mdx b/src/content/reference/en/p5 copy/loadJSON.mdx new file mode 100644 index 0000000000..95fd0552b5 --- /dev/null +++ b/src/content/reference/en/p5 copy/loadJSON.mdx @@ -0,0 +1,288 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L17 +title: loadJSON +module: IO +submodule: Input +file: src/io/files.js +description: > +

Loads a JSON file to create an Object.

+ +

JavaScript Object Notation + + (JSON) + + is a standard format for sending data between applications. The format is + + based on JavaScript objects which have keys and values. JSON files store + + data in an object with strings as keys. Values can be strings, numbers, + + Booleans, arrays, null, or other objects.

+ +

The first parameter, path, is always a string with the path to + the file. + + Paths to local files should be relative, as in + + loadJSON('/assets/data.json'). URLs such as + + 'https://example.com/data.json' may be blocked due to browser + security.

+ +

The second parameter, successCallback, is optional. If a + function is + + passed, as in loadJSON('/assets/data.json', handleData), then the + + handleData() function will be called once the data loads. The + object + + created from the JSON data will be passed to handleData() as its + only argument.

+ +

The third parameter, failureCallback, is also optional. If a + function is + + passed, as in loadJSON('/assets/data.json', handleData, + handleFailure), + + then the handleFailure() function will be called if an error + occurs while + + loading. The Error object will be passed to + handleFailure() as its only + + argument.

+ +

Note: Data can take time to load. Calling loadJSON() within + + preload() ensures data loads before it's + used in + + setup() or draw().

+line: 17 +isConstructor: false +itemtype: method +example: + - |- + + +
+ + let myData; + + // Load the JSON and create an object. + function preload() { + myData = loadJSON('/assets/data.json'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the circle. + fill(myData.color); + noStroke(); + + // Draw the circle. + circle(myData.x, myData.y, myData.d); + + describe('A pink circle on a gray background.'); + } + +
+ +
+ + let myData; + + // Load the JSON and create an object. + function preload() { + myData = loadJSON('/assets/data.json'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object and make it transparent. + let c = color(myData.color); + c.setAlpha(80); + + // Style the circles. + fill(c); + noStroke(); + + // Iterate over the myData.bubbles array. + for (let b of myData.bubbles) { + // Draw a circle for each bubble. + circle(b.x, b.y, b.d); + } + + describe('Several pink bubbles floating in a blue sky.'); + } + +
+ +
+ + let myData; + + // Load the GeoJSON and create an object. + function preload() { + myData = loadJSON('https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Get data about the most recent earthquake. + let quake = myData.features[0].properties; + + // Draw a circle based on the earthquake's magnitude. + circle(50, 50, quake.mag * 10); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(11); + + // Display the earthquake's location. + text(quake.place, 5, 80, 100); + + describe(`A white circle on a gray background. The text "${quake.place}" is written beneath the circle.`); + } + +
+ +
+ + let bigQuake; + + // Load the GeoJSON and preprocess it. + function preload() { + loadJSON( + 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson', + handleData + ); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw a circle based on the earthquake's magnitude. + circle(50, 50, bigQuake.mag * 10); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(11); + + // Display the earthquake's location. + text(bigQuake.place, 5, 80, 100); + + describe(`A white circle on a gray background. The text "${bigQuake.place}" is written beneath the circle.`); + } + + // Find the biggest recent earthquake. + function handleData(data) { + let maxMag = 0; + // Iterate over the earthquakes array. + for (let quake of data.features) { + // Reassign bigQuake if a larger + // magnitude quake is found. + if (quake.properties.mag > maxMag) { + bigQuake = quake.properties; + } + } + } + +
+ +
+ + let bigQuake; + + // Load the GeoJSON and preprocess it. + function preload() { + loadJSON( + 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson', + handleData, + handleError + ); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw a circle based on the earthquake's magnitude. + circle(50, 50, bigQuake.mag * 10); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(11); + + // Display the earthquake's location. + text(bigQuake.place, 5, 80, 100); + + describe(`A white circle on a gray background. The text "${bigQuake.place}" is written beneath the circle.`); + } + + // Find the biggest recent earthquake. + function handleData(data) { + let maxMag = 0; + // Iterate over the earthquakes array. + for (let quake of data.features) { + // Reassign bigQuake if a larger + // magnitude quake is found. + if (quake.properties.mag > maxMag) { + bigQuake = quake.properties; + } + } + } + + // Log any errors to the console. + function handleError(error) { + console.log('Oops!', error); + } + +
+class: p5 +params: + - name: path + description: | +

path of the JSON file to be loaded.

+ type: String + - name: successCallback + description: > +

function to call once the data is loaded. Will be passed the + object.

+ type: Function + optional: true + - name: errorCallback + description: > +

function to call if the data fails to load. Will be passed an + Error event object.

+ type: Function + optional: true +return: + description: object containing the loaded data. + type: Object +chainable: false +--- + + +# loadJSON diff --git a/src/content/reference/en/p5 copy/loadModel.mdx b/src/content/reference/en/p5 copy/loadModel.mdx new file mode 100644 index 0000000000..56b2230e1e --- /dev/null +++ b/src/content/reference/en/p5 copy/loadModel.mdx @@ -0,0 +1,469 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/loading.js#L13 +title: loadModel +module: Shape +submodule: 3D Models +file: src/webgl/loading.js +description: > +

Loads a 3D model to create a + + p5.Geometry object.

+ +

loadModel() can load 3D models from OBJ and STL files. Once + the model is + + loaded, it can be displayed with the + + model() function, as in + model(shape).

+ +

There are three ways to call loadModel() with optional + parameters to help + + process the model.

+ +

The first parameter, path, is always a String + with the path to the + + file. Paths to local files should be relative, as in + + loadModel('/assets/model.obj'). URLs such as + + 'https://example.com/model.obj' may be blocked due to browser + security.

+ +

Note: When loading a .obj file that references materials + stored in + + .mtl files, p5.js will attempt to load and apply those materials. + + To ensure that the .obj file reads the .mtl file + correctly include the + + .mtl file alongside it.

+ +

The first way to call loadModel() has three optional + parameters after the + + file path. The first optional parameter, successCallback, is a + function + + to call once the model loads. For example, + + loadModel('/assets/model.obj', handleModel) will call the + handleModel() + + function once the model loads. The second optional parameter, + + failureCallback, is a function to call if the model fails to + load. For + + example, loadModel('/assets/model.obj', handleModel, + handleFailure) will + + call the handleFailure() function if an error occurs while + loading. The + + third optional parameter, fileType, is the model’s file extension + as a + + string. For example, + + loadModel('/assets/model', handleModel, handleFailure, '.obj') + will try to + + load the file model as a .obj file.

+ +

The second way to call loadModel() has four optional + parameters after the + + file path. The first optional parameter is a Boolean value. If + true is + + passed, as in loadModel('/assets/model.obj', true), then the + model will be + + resized to ensure it fits the canvas. The next three parameters are + + successCallback, failureCallback, and + fileType as described above.

+ +

The third way to call loadModel() has one optional parameter + after the + + file path. The optional parameter, options, is an + Object with options, + + as in loadModel('/assets/model.obj', options). The + options object can + + have the following properties:

+ +
let options = {
+    // Enables standardized size scaling during loading if set to true.
+    normalize: true,
+
+    // Function to call once the model loads.
+    successCallback: handleModel,
+
+    // Function to call if an error occurs while loading.
+    failureCallback: handleError,
+
+    // Model's file extension.
+    fileType: '.stl',
+
+    // Flips the U texture coordinates of the model.
+    flipU: false,
+
+    // Flips the V texture coordinates of the model.
+    flipV: false
+  };
+
+
+  // Pass the options object to loadModel().
+
+  loadModel('/assets/model.obj', options);
+
+  
+ +

Models can take time to load. Calling loadModel() in + + preload() ensures models load before + they're + + used in setup() or draw().

+ +

Note: There’s no support for colored STL files. STL files with color will + + be rendered without color.

+line: 13 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + // Load the file and create a p5.Geometry object. + function preload() { + shape = loadModel('/assets/teapot.obj'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white teapot drawn against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the shape. + model(shape); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + // Load the file and create a p5.Geometry object. + // Normalize the geometry's size to fit the canvas. + function preload() { + shape = loadModel('/assets/teapot.obj', true); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white teapot drawn against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the shape. + model(shape); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + // Load the file and create a p5.Geometry object. + function preload() { + loadModel('/assets/teapot.obj', true, handleModel); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white teapot drawn against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the shape. + model(shape); + } + + // Set the shape variable and log the geometry's + // ID to the console. + function handleModel(data) { + shape = data; + console.log(shape.gid); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + // Load the file and create a p5.Geometry object. + function preload() { + loadModel('/assets/wrong.obj', true, handleModel, handleError); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white teapot drawn against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the shape. + model(shape); + } + + // Set the shape variable and print the geometry's + // ID to the console. + function handleModel(data) { + shape = data; + console.log(shape.gid); + } + + // Print an error message if the file doesn't load. + function handleError(error) { + console.error('Oops!', error); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + // Load the file and create a p5.Geometry object. + function preload() { + loadModel('/assets/teapot.obj', true, handleModel, handleError, '.obj'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white teapot drawn against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the shape. + model(shape); + } + + // Set the shape variable and print the geometry's + // ID to the console. + function handleModel(data) { + shape = data; + console.log(shape.gid); + } + + // Print an error message if the file doesn't load. + function handleError(error) { + console.error('Oops!', error); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + let options = { + normalize: true, + successCallback: handleModel, + failureCallback: handleError, + fileType: '.obj' + }; + + // Load the file and create a p5.Geometry object. + function preload() { + loadModel('/assets/teapot.obj', options); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white teapot drawn against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the shape. + model(shape); + } + + // Set the shape variable and print the geometry's + // ID to the console. + function handleModel(data) { + shape = data; + console.log(shape.gid); + } + + // Print an error message if the file doesn't load. + function handleError(error) { + console.error('Oops!', error); + } + +
+class: p5 +return: + description: the p5.Geometry object + type: p5.Geometry +overloads: + - line: 13 + params: + - name: path + description: | +

path of the model to be loaded.

+ type: String + - name: normalize + description: | +

if true, scale the model to fit the canvas.

+ type: Boolean + - name: successCallback + description: | +

function to call once the model is loaded. Will be passed + the p5.Geometry object.

+ type: function(p5.Geometry) + optional: true + - name: failureCallback + description: > +

function to call if the model fails to load. Will be passed an + Error event object.

+ type: Function(Event) + optional: true + - name: fileType + description: > +

model’s file extension. Either '.obj' or + '.stl'.

+ type: String + optional: true + return: + description: the p5.Geometry object + type: p5.Geometry + - line: 324 + params: + - name: path + description: '' + type: String + - name: successCallback + description: '' + type: function(p5.Geometry) + optional: true + - name: failureCallback + description: '' + type: Function(Event) + optional: true + - name: fileType + description: '' + type: String + optional: true + return: + description: new p5.Geometry object. + type: p5.Geometry + - line: 332 + params: + - name: path + description: '' + type: String + - name: options + description: | +

loading options.

+ type: Object + optional: true + props: + - name: successCallback + description: '' + type: function(p5.Geometry) + optional: true + - name: failureCallback + description: '' + type: Function(Event) + optional: true + - name: fileType + description: '' + type: String + optional: true + - name: normalize + description: '' + type: Boolean + optional: true + - name: flipU + description: '' + type: Boolean + optional: true + - name: flipV + description: '' + type: Boolean + optional: true + return: + description: new p5.Geometry object. + type: p5.Geometry +chainable: false +--- + + +# loadModel diff --git a/src/content/reference/en/p5 copy/loadPixels.mdx b/src/content/reference/en/p5 copy/loadPixels.mdx new file mode 100644 index 0000000000..424a87765f --- /dev/null +++ b/src/content/reference/en/p5 copy/loadPixels.mdx @@ -0,0 +1,61 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L946 +title: loadPixels +module: Image +submodule: Pixels +file: src/image/pixels.js +description: | +

Loads the current value of each pixel on the canvas into the + pixels array.

+

loadPixels() must be called before reading from or writing to + pixels.

+line: 946 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/rockies.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0, 100, 100); + + // Get the pixel density. + let d = pixelDensity(); + + // Calculate the halfway index in the pixels array. + let halfImage = 4 * (d * width) * (d * height / 2); + + // Load the pixels array. + loadPixels(); + + // Copy the top half of the canvas to the bottom. + for (let i = 0; i < halfImage; i += 1) { + pixels[i + halfImage] = pixels[i]; + } + + // Update the canvas. + updatePixels(); + + describe('Two identical images of mountain landscapes, one on top of the other.'); + } + +
+class: p5 +chainable: false +--- + + +# loadPixels diff --git a/src/content/reference/en/p5 copy/loadShader.mdx b/src/content/reference/en/p5 copy/loadShader.mdx new file mode 100644 index 0000000000..1180e6c487 --- /dev/null +++ b/src/content/reference/en/p5 copy/loadShader.mdx @@ -0,0 +1,172 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L12 +title: loadShader +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Loads vertex and fragment shaders to create a + + p5.Shader object.

+ +

Shaders are programs that run on the graphics processing unit (GPU). They + + can process many pixels at the same time, making them fast for many + + graphics tasks. They’re written in a language called + + GLSL + + and run along with the rest of the code in a sketch.

+ +

Once the p5.Shader object is created, + it can be + + used with the shader() function, as in + + shader(myShader). A shader program consists of two files, a + vertex shader + + and a fragment shader. The vertex shader affects where 3D geometry is drawn + + on the screen and the fragment shader affects color.

+ +

loadShader() loads the vertex and fragment shaders from their + .vert and + + .frag files. For example, calling + + loadShader('/assets/shader.vert', '/assets/shader.frag') loads + both + + required shaders and returns a p5.Shader + object.

+ +

The third parameter, successCallback, is optional. If a + function is + + passed, it will be called once the shader has loaded. The callback function + + can use the new p5.Shader object as its + + parameter.

+ +

The fourth parameter, failureCallback, is also optional. If a + function is + + passed, it will be called if the shader fails to load. The callback + + function can use the event error as its parameter.

+ +

Shaders can take time to load. Calling loadShader() in + + preload() ensures shaders load before + they're + + used in setup() or draw().

+ +

Note: Shaders can only be used in WebGL mode.

+line: 12 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Note: A "uniform" is a global variable within a shader program. + + let mandelbrot; + + // Load the shader and create a p5.Shader object. + function preload() { + mandelbrot = loadShader('/assets/shader.vert', '/assets/shader.frag'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + // Compile and apply the p5.Shader object. + shader(mandelbrot); + + // Set the shader uniform p to an array. + mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); + + // Set the shader uniform r to the value 1.5. + mandelbrot.setUniform('r', 1.5); + + // Add a quad as a display surface for the shader. + quad(-1, -1, 1, -1, 1, 1, -1, 1); + + describe('A black fractal image on a magenta background.'); + } + +
+ +
+ + // Note: A "uniform" is a global variable within a shader program. + + let mandelbrot; + + // Load the shader and create a p5.Shader object. + function preload() { + mandelbrot = loadShader('/assets/shader.vert', '/assets/shader.frag'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + // Use the p5.Shader object. + shader(mandelbrot); + + // Set the shader uniform p to an array. + mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); + + describe('A fractal image zooms in and out of focus.'); + } + + function draw() { + // Set the shader uniform r to a value that oscillates between 0 and 2. + mandelbrot.setUniform('r', sin(frameCount * 0.01) + 1); + + // Add a quad as a display surface for the shader. + quad(-1, -1, 1, -1, 1, 1, -1, 1); + } + +
+class: p5 +params: + - name: vertFilename + description: | +

path of the vertex shader to be loaded.

+ type: String + - name: fragFilename + description: | +

path of the fragment shader to be loaded.

+ type: String + - name: successCallback + description: | +

function to call once the shader is loaded. Can be passed the + p5.Shader object.

+ type: Function + optional: true + - name: failureCallback + description: | +

function to call if the shader fails to load. Can be passed an + Error event object.

+ type: Function + optional: true +return: + description: new shader created from the vertex and fragment shader files. + type: p5.Shader +chainable: false +--- + + +# loadShader diff --git a/src/content/reference/en/p5 copy/loadSound.mdx b/src/content/reference/en/p5 copy/loadSound.mdx new file mode 100644 index 0000000000..be9dd1ac29 --- /dev/null +++ b/src/content/reference/en/p5 copy/loadSound.mdx @@ -0,0 +1,78 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L2946 +title: loadSound +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: | +

loadSound() returns a new p5.SoundFile from a specified + path. If called during preload(), the p5.SoundFile will be ready + to play in time for setup() and draw(). If called outside of + preload, the p5.SoundFile will not be ready immediately, so + loadSound accepts a callback as the second parameter. Using a + + local server is recommended when loading external files.

+line: 2946 +isConstructor: false +itemtype: method +example: + - |- + +
+ let mySound; + function preload() { + soundFormats('mp3', 'ogg'); + mySound = loadSound('/assets/doorbell'); + } + + function setup() { + let cnv = createCanvas(100, 100); + cnv.mousePressed(canvasPressed); + background(220); + text('tap here to play', 10, 20); + } + + function canvasPressed() { + // playing a sound file on a user gesture + // is equivalent to `userStartAudio()` + mySound.play(); + } +
+class: p5 +params: + - name: path + description: | +

Path to the sound file, or an array with + paths to soundfiles in multiple formats + i.e. ['sound.ogg', 'sound.mp3']. + Alternately, accepts an object: either + from the HTML5 File API, or a p5.File.

+ type: String|Array + - name: successCallback + description: | +

Name of a function to call once file loads

+ type: Function + optional: true + - name: errorCallback + description: | +

Name of a function to call if there is + an error loading the file.

+ type: Function + optional: true + - name: whileLoading + description: | +

Name of a function to call while file is loading. + This function will receive the percentage loaded + so far, from 0.0 to 1.0.

+ type: Function + optional: true +return: + description: Returns a p5.SoundFile + type: SoundFile +chainable: false +--- + + +# loadSound diff --git a/src/content/reference/en/p5 copy/loadStrings.mdx b/src/content/reference/en/p5 copy/loadStrings.mdx new file mode 100644 index 0000000000..ce011835bc --- /dev/null +++ b/src/content/reference/en/p5 copy/loadStrings.mdx @@ -0,0 +1,188 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L309 +title: loadStrings +module: IO +submodule: Input +file: src/io/files.js +description: > +

Loads a text file to create an Array.

+ +

The first parameter, path, is always a string with the path to + the file. + + Paths to local files should be relative, as in + + loadStrings('/assets/data.txt'). URLs such as + + 'https://example.com/data.txt' may be blocked due to browser + security.

+ +

The second parameter, successCallback, is optional. If a + function is + + passed, as in loadStrings('/assets/data.txt', handleData), then + the + + handleData() function will be called once the data loads. The + array + + created from the text data will be passed to handleData() as its + only + + argument.

+ +

The third parameter, failureCallback, is also optional. If a + function is + + passed, as in loadStrings('/assets/data.txt', handleData, + handleFailure), + + then the handleFailure() function will be called if an error + occurs while + + loading. The Error object will be passed to + handleFailure() as its only + + argument.

+ +

Note: Data can take time to load. Calling loadStrings() within + + preload() ensures data loads before it's + used in + + setup() or draw().

+line: 309 +isConstructor: false +itemtype: method +example: + - |- + + +
+ + let myData; + + // Load the text and create an array. + function preload() { + myData = loadStrings('/assets/test.txt'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Select a random line from the text. + let phrase = random(myData); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(12); + + // Display the text. + text(phrase, 10, 50, 90); + + describe(`The text "${phrase}" written in black on a gray background.`); + } + +
+ +
+ + let lastLine; + + // Load the text and preprocess it. + function preload() { + loadStrings('/assets/test.txt', handleData); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(12); + + // Display the text. + text(lastLine, 10, 50, 90); + + describe('The text "I talk like an orange" written in black on a gray background.'); + } + + // Select the last line from the text. + function handleData(data) { + lastLine = data[data.length - 1]; + } + +
+ +
+ + let lastLine; + + // Load the text and preprocess it. + function preload() { + loadStrings('/assets/test.txt', handleData, handleError); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(12); + + // Display the text. + text(lastLine, 10, 50, 90); + + describe('The text "I talk like an orange" written in black on a gray background.'); + } + + // Select the last line from the text. + function handleData(data) { + lastLine = data[data.length - 1]; + } + + // Log any errors to the console. + function handleError(error) { + console.error('Oops!', error); + } + +
+class: p5 +params: + - name: path + description: | +

path of the text file to be loaded.

+ type: String + - name: successCallback + description: | +

function to call once the data is + loaded. Will be passed the array.

+ type: Function + optional: true + - name: errorCallback + description: | +

function to call if the data fails to + load. Will be passed an Error event + object.

+ type: Function + optional: true +return: + description: new array containing the loaded text. + type: 'String[]' +chainable: false +--- + + +# loadStrings diff --git a/src/content/reference/en/p5 copy/loadTable.mdx b/src/content/reference/en/p5 copy/loadTable.mdx new file mode 100644 index 0000000000..d93e40a3da --- /dev/null +++ b/src/content/reference/en/p5 copy/loadTable.mdx @@ -0,0 +1,124 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L505 +title: loadTable +module: IO +submodule: Input +file: src/io/files.js +description: > +

Reads the contents of a file or URL and creates a p5.Table object with + + its values. If a file is specified, it must be located in the sketch's + + "data" folder. The filename parameter can also be a URL to a file found + + online. By default, the file is assumed to be comma-separated (in CSV + + format). Table only looks for a header row if the 'header' option is + + included.

+ +

This method is asynchronous, meaning it may not finish before the next + + line in your sketch is executed. Calling loadTable() inside preload() + + guarantees to complete the operation before setup() and draw() are called. + + Outside of preload(), you may supply a + callback function to handle the + + object:

+ +

All files loaded and saved use UTF-8 encoding. This method is suitable for + fetching files up to size of 64MB.

+line: 505 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Given the following CSV file called "mammals.csv" + // located in the project's "assets" folder: + // + // id,species,name + // 0,Capra hircus,Goat + // 1,Panthera pardus,Leopard + // 2,Equus zebra,Zebra + + let table; + + function preload() { + //my table is comma separated value "csv" + //and has a header specifying the columns labels + table = loadTable('/assets/mammals.csv', 'csv', 'header'); + //the file can be remote + //table = loadTable("https://p5js.org/reference//assets/mammals.csv", + // "csv", "header"); + } + + function setup() { + //count the columns + print(table.getRowCount() + ' total rows in table'); + print(table.getColumnCount() + ' total columns in table'); + + print(table.getColumn('name')); + //["Goat", "Leopard", "Zebra"] + + //cycle through the table + for (let r = 0; r < table.getRowCount(); r++) + 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"`); + } + +
+class: p5 +params: + - name: filename + description: | +

name of the file or URL to load

+ type: String + - name: extension + description: | +

parse the table by comma-separated values "csv", semicolon-separated + values "ssv", or tab-separated values "tsv"

+ type: String + optional: true + - name: header + description: | +

"header" to indicate table has header row

+ type: String + optional: true + - name: callback + description: | +

function to be executed after + loadTable() completes. On success, the + Table object is passed in as the + first argument.

+ type: Function + optional: true + - name: errorCallback + description: | +

function to be executed if + there is an error, response is passed + in as first argument

+ type: Function + optional: true +return: + description: Table object containing data + type: Object +chainable: false +--- + + +# loadTable diff --git a/src/content/reference/en/p5 copy/loadXML.mdx b/src/content/reference/en/p5 copy/loadXML.mdx new file mode 100644 index 0000000000..859a3c895d --- /dev/null +++ b/src/content/reference/en/p5 copy/loadXML.mdx @@ -0,0 +1,220 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L780 +title: loadXML +module: IO +submodule: Input +file: src/io/files.js +description: > +

Loads an XML file to create a p5.XML + object.

+ +

Extensible Markup Language + + (XML) + + is a standard format for sending data between applications. Like HTML, the + + XML format is based on tags and attributes, as in + + .

+ +

The first parameter, path, is always a string with the path to + the file. + + Paths to local files should be relative, as in + + loadXML('/assets/data.xml'). URLs such as + 'https://example.com/data.xml' + + may be blocked due to browser security.

+ +

The second parameter, successCallback, is optional. If a + function is + + passed, as in loadXML('/assets/data.xml', handleData), then the + + handleData() function will be called once the data loads. The + + p5.XML object created from the data will be + passed + + to handleData() as its only argument.

+ +

The third parameter, failureCallback, is also optional. If a + function is + + passed, as in loadXML('/assets/data.xml', handleData, + handleFailure), then + + the handleFailure() function will be called if an error occurs + while + + loading. The Error object will be passed to + handleFailure() as its only + + argument.

+ +

Note: Data can take time to load. Calling loadXML() within + + preload() ensures data loads before it's + used in + + setup() or draw().

+line: 780 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let myXML; + + // Load the XML and create a p5.XML object. + function preload() { + myXML = loadXML('/assets/animals.xml'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Get an array with all mammal tags. + let mammals = myXML.getChildren('mammal'); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(14); + + // Iterate over the mammals array. + for (let i = 0; i < mammals.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 25; + + // Get the mammal's common name. + let name = mammals[i].getContent(); + + // Display the mammal's name. + text(name, 20, y); + } + + describe( + 'The words "Goat", "Leopard", and "Zebra" written on three separate lines. The text is black on a gray background.' + ); + } + +
+ +
+ + let lastMammal; + + // Load the XML and create a p5.XML object. + function preload() { + loadXML('/assets/animals.xml', handleData); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(CENTER, CENTER); + textFont('Courier New'); + textSize(16); + + // Display the content of the last mammal element. + text(lastMammal, 50, 50); + + describe('The word "Zebra" written in black on a gray background.'); + } + + // Get the content of the last mammal element. + function handleData(data) { + // Get an array with all mammal elements. + let mammals = data.getChildren('mammal'); + + // Get the content of the last mammal. + lastMammal = mammals[mammals.length - 1].getContent(); + } + +
+ +
+ + let lastMammal; + + // Load the XML and preprocess it. + function preload() { + loadXML('/assets/animals.xml', handleData, handleError); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(CENTER, CENTER); + textFont('Courier New'); + textSize(16); + + // Display the content of the last mammal element. + text(lastMammal, 50, 50); + + describe('The word "Zebra" written in black on a gray background.'); + } + + // Get the content of the last mammal element. + function handleData(data) { + // Get an array with all mammal elements. + let mammals = data.getChildren('mammal'); + + // Get the content of the last mammal. + lastMammal = mammals[mammals.length - 1].getContent(); + } + + // Log any errors to the console. + function handleError(error) { + console.error('Oops!', error); + } + +
+class: p5 +params: + - name: path + description: | +

path of the XML file to be loaded.

+ type: String + - name: successCallback + description: | +

function to call once the data is + loaded. Will be passed the + p5.XML object.

+ type: Function + optional: true + - name: errorCallback + description: | +

function to call if the data fails to + load. Will be passed an Error event + object.

+ type: Function + optional: true +return: + description: |- + XML data loaded into a p5.XML + object. + type: p5.XML +chainable: false +--- + + +# loadXML diff --git a/src/content/reference/en/p5 copy/log.mdx b/src/content/reference/en/p5 copy/log.mdx new file mode 100644 index 0000000000..c84c6d5a4b --- /dev/null +++ b/src/content/reference/en/p5 copy/log.mdx @@ -0,0 +1,79 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L423 +title: log +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Calculates the natural logarithm (the base-e logarithm) of a number.

+ +

log() expects the n parameter to be a value + greater than 0 because + + the natural logarithm is defined that way.

+line: 423 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Top-left. + let d = log(50); + circle(33, 33, d); + + // Bottom-right. + d = log(500000000); + circle(67, 67, d); + + describe('Two white circles. The circle at the top-left is small. The circle at the bottom-right is about five times larger.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + describe('A series of black dots that get higher slowly from left to right.'); + } + + function draw() { + // Invert the y-axis. + scale(1, -1); + translate(0, -100); + + // Calculate coordinates. + let x = frameCount; + let y = 15 * log(x); + + // Draw a point. + point(x, y); + } + +
+class: p5 +params: + - name: 'n' + description: | +

number greater than 0.

+ type: Number +return: + description: natural logarithm of n. + type: Number +chainable: false +--- + + +# log diff --git a/src/content/reference/en/p5 copy/loop.mdx b/src/content/reference/en/p5 copy/loop.mdx new file mode 100644 index 0000000000..a73432d2c1 --- /dev/null +++ b/src/content/reference/en/p5 copy/loop.mdx @@ -0,0 +1,111 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L127 +title: loop +module: Structure +submodule: Structure +file: src/core/structure.js +description: > +

Resumes the draw loop after noLoop() + has been + + called.

+ +

By default, draw() tries to run 60 times + per + + second. Calling noLoop() stops + + draw() from repeating. The draw loop can be + + restarted by calling loop().

+ +

The isLooping() function can be used + to check + + whether a sketch is looping, as in isLooping() === true.

+line: 127 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Turn off the draw loop. + noLoop(); + + describe( + 'A white half-circle on the left edge of a gray square. The circle starts moving to the right when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Calculate the circle's x-coordinate. + let x = frameCount; + + // Draw the circle. + circle(x, 50, 20); + } + + // Resume the draw loop when the user double-clicks. + function doubleClicked() { + loop(); + } + +
+ +
+ + let startButton; + let stopButton; + + function setup() { + createCanvas(100, 100); + + // Create the button elements and place them + // beneath the canvas. + startButton = createButton('▶'); + startButton.position(0, 100); + startButton.size(50, 20); + stopButton = createButton('◾'); + stopButton.position(50, 100); + stopButton.size(50, 20); + + // Set functions to call when the buttons are pressed. + startButton.mousePressed(loop); + stopButton.mousePressed(noLoop); + + // Slow the frame rate. + frameRate(5); + + describe( + 'A white circle moves randomly on a gray background. Play and stop buttons are shown beneath the canvas. The circle stops or starts moving when the user presses a button.' + ); + } + + function draw() { + background(200); + + // Calculate the circle's coordinates. + let x = random(0, 100); + let y = random(0, 100); + + // Draw the circle. + // Normally, the circle would move from left to right. + circle(x, y, 20); + } + +
+class: p5 +chainable: false +--- + + +# loop diff --git a/src/content/reference/en/p5 copy/mag.mdx b/src/content/reference/en/p5 copy/mag.mdx new file mode 100644 index 0000000000..4d46565b07 --- /dev/null +++ b/src/content/reference/en/p5 copy/mag.mdx @@ -0,0 +1,84 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L481 +title: mag +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Calculates the magnitude, or length, of a vector.

+ +

A vector can be thought of in different ways. In one view, a vector is a + + point in space. The vector's components, x and y, + are the point's + + coordinates (x, y). A vector's magnitude is the distance from the + origin + + (0, 0) to (x, y). mag(x, y) is a + shortcut for calling + + dist(0, 0, x, y).

+ +

A vector can also be thought of as an arrow pointing in space. This view is + + helpful for programming motion. See p5.Vector for + + more details.

+ +

Use p5.Vector.mag() to calculate + the + + magnitude of a p5.Vector object.

+line: 481 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Set the vector's components. + let x = 30; + let y = 40; + + // Calculate the magnitude. + let m = mag(x, y); + + // Style the text. + textSize(16); + + // Display the vector and its magnitude. + line(0, 0, x, y); + text(m, x, y); + + describe('A diagonal line is drawn from the top left of the canvas. The number 50 is written at the end of the line.'); + } + +
+class: p5 +params: + - name: x + description: | +

first component.

+ type: Number + - name: 'y' + description: | +

second component.

+ type: Number +return: + description: magnitude of vector. + type: Number +chainable: false +--- + + +# mag diff --git a/src/content/reference/en/p5 copy/map.mdx b/src/content/reference/en/p5 copy/map.mdx new file mode 100644 index 0000000000..a94e6e4dd7 --- /dev/null +++ b/src/content/reference/en/p5 copy/map.mdx @@ -0,0 +1,119 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L534 +title: map +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Re-maps a number from one range to another.

+ +

For example, calling map(2, 0, 10, 0, 100) returns 20. The + first three + + arguments set the original value to 2 and the original range from 0 to 10. + + The last two arguments set the target range from 0 to 100. 20's position + + in the target range [0, 100] is proportional to 2's position in the + + original range [0, 10].

+ +

The sixth parameter, withinBounds, is optional. By default, + map() can + + return values outside of the target range. For example, + + map(11, 0, 10, 0, 100) returns 110. Passing true as + the sixth parameter + + constrains the remapped value to the target range. For example, + + map(11, 0, 10, 0, 100, true) returns 100.

+line: 534 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('Two horizontal lines. The top line grows horizontally as the mouse moves to the right. The bottom line also grows horizontally but is scaled to stay on the left half of the canvas.'); + } + + function draw() { + background(200); + + // Draw the top line. + line(0, 25, mouseX, 25); + + // Remap mouseX from [0, 100] to [0, 50]. + let x = map(mouseX, 0, 100, 0, 50); + + // Draw the bottom line. + line(0, 75, x, 75); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A circle changes color from black to white as the mouse moves from left to right.'); + } + + function draw() { + background(200); + + // Remap mouseX from [0, 100] to [0, 255] + let c = map(mouseX, 0, 100, 0, 255); + + // Style the circle. + fill(c); + + // Draw the circle. + circle(50, 50, 20); + } + +
+class: p5 +params: + - name: value + description: | +

the value to be remapped.

+ type: Number + - name: start1 + description: | +

lower bound of the value's current range.

+ type: Number + - name: stop1 + description: | +

upper bound of the value's current range.

+ type: Number + - name: start2 + description: | +

lower bound of the value's target range.

+ type: Number + - name: stop2 + description: | +

upper bound of the value's target range.

+ type: Number + - name: withinBounds + description: | +

constrain the value to the newly mapped range.

+ type: Boolean + optional: true +return: + description: remapped number. + type: Number +chainable: false +--- + + +# map diff --git a/src/content/reference/en/p5 copy/match.mdx b/src/content/reference/en/p5 copy/match.mdx new file mode 100644 index 0000000000..c93425e96d --- /dev/null +++ b/src/content/reference/en/p5 copy/match.mdx @@ -0,0 +1,91 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L60 +title: match +module: Data +submodule: String Functions +file: src/utilities/string_functions.js +description: > +

Applies a regular expression to a string and returns an array with the + + first match.

+ +

match() uses regular expressions (regex) to match patterns in + text. For + + example, the regex abc can be used to search a string for the + exact + + sequence of characters abc. See + + MDN. + + for more information about regexes.

+ +

The first parameter, str, is the string to search.

+ +

The second parameter, regex, is a string with the regular + expression to + + apply. For example, calling match('Hello, p5*js!', '[a-z][0-9]') + would + + return the array ['p5'].

+ +

Note: If no matches are found, null is returned.

+line: 60 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let string = 'Hello, p5*js!'; + + // Match the characters that are lowercase + // letters followed by digits. + let matches = match(string, '[a-z][0-9]'); + + // Print the matches array to the console: + // ['p5'] + print(matches); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the matches. + text(matches, 50, 50); + + describe('The text "p5" written in black on a gray canvas.'); + } + +
+class: p5 +params: + - name: str + description: | +

string to search.

+ type: String + - name: regexp + description: | +

regular expression to match.

+ type: String +return: + description: match if found. + type: 'String[]' +chainable: false +--- + + +# match diff --git a/src/content/reference/en/p5 copy/matchAll.mdx b/src/content/reference/en/p5 copy/matchAll.mdx new file mode 100644 index 0000000000..371d596b61 --- /dev/null +++ b/src/content/reference/en/p5 copy/matchAll.mdx @@ -0,0 +1,107 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L119 +title: matchAll +module: Data +submodule: String Functions +file: src/utilities/string_functions.js +description: > +

Applies a regular expression to a string and returns an array of + matches.

+ +

match() uses regular expressions (regex) to match patterns in + text. For + + example, the regex abc can be used to search a string for the + exact + + sequence of characters abc. See + + MDN. + + for more information about regexes. matchAll() is different from + + match() because it returns every match, not + just + + the first.

+ +

The first parameter, str, is the string to search.

+ +

The second parameter, regex, is a string with the regular + expression to + + apply. For example, calling + + matchAll('p5*js is easier than abc123', '[a-z][0-9]') would + return the + + 2D array [['p5'], ['c1']].

+ +

Note: If no matches are found, an empty array [] is + returned.

+line: 119 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let string = 'p5*js is easier than abc123'; + + // Match the character sequences that are + // lowercase letters followed by digits. + let matches = matchAll(string, '[a-z][0-9]'); + + // Print the matches array to the console: + // [['p5'], ['c1']] + print(matches); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Iterate over the matches array. + for (let i = 0; i < matches.length; i += 1) { + + // Calculate the y-coordainate. + let y = (i + 1) * 33; + + // Display the match. + text(matches[i], 50, y); + } + + describe( + 'The text "p5" and "c1" written on separate lines. The text is black on a gray background.' + ); + } + +
+class: p5 +params: + - name: str + description: | +

string to search.

+ type: String + - name: regexp + description: | +

regular expression to match.

+ type: String +return: + description: matches found. + type: 'String[]' +chainable: false +--- + + +# matchAll diff --git a/src/content/reference/en/p5 copy/max.mdx b/src/content/reference/en/p5 copy/max.mdx new file mode 100644 index 0000000000..0dd0ee142c --- /dev/null +++ b/src/content/reference/en/p5 copy/max.mdx @@ -0,0 +1,104 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L618 +title: max +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Returns the largest value in a sequence of numbers.

+ +

The version of max() with one parameter interprets it as an + array of + + numbers and returns the largest number.

+ +

The version of max() with two or more parameters interprets + them as + + individual numbers and returns the largest number.

+line: 618 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Calculate the maximum of 10, 5, and 20. + let m = max(10, 5, 20); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the max. + text(m, 50, 50); + + describe('The number 20 written in the middle of a gray square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of numbers. + let numbers = [10, 5, 20]; + + // Calculate the maximum of the array. + let m = max(numbers); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the max. + text(m, 50, 50); + + describe('The number 20 written in the middle of a gray square.'); + } + +
+class: p5 +return: + description: maximum number. + type: Number +overloads: + - line: 618 + params: + - name: n0 + description: | +

first number to compare.

+ type: Number + - name: n1 + description: | +

second number to compare.

+ type: Number + return: + description: maximum number. + type: Number + - line: 680 + params: + - name: nums + description: | +

numbers to compare.

+ type: 'Number[]' + return: + description: '' + type: Number +chainable: false +--- + + +# max diff --git a/src/content/reference/en/p5 copy/metalness.mdx b/src/content/reference/en/p5 copy/metalness.mdx new file mode 100644 index 0000000000..ef378bc2a9 --- /dev/null +++ b/src/content/reference/en/p5 copy/metalness.mdx @@ -0,0 +1,142 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L3069 +title: metalness +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Sets the amount of "metalness" of a + + specularMaterial().

+ +

metalness() can make materials appear more metallic. It + affects the way + + materials reflect light sources including + + affects the way materials reflect light sources including + + directionalLight(), + + pointLight(), + + spotLight(), and + + imageLight().

+ +

The parameter, metallic, is a number that sets the amount of + metalness. + + metallic must be greater than 1, which is its default value. + Higher + + values, such as metalness(100), make specular materials appear + more + + metallic.

+line: 3069 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'Two blue spheres drawn on a gray background. White light reflects from their surfaces as the mouse moves. The right sphere is more metallic than the left sphere.' + ); + } + + function draw() { + background(200); + + // Turn on an ambient light. + ambientLight(200); + + // Get the mouse's coordinates. + let mx = mouseX - 50; + let my = mouseY - 50; + + // Turn on a white point light that follows the mouse. + pointLight(255, 255, 255, mx, my, 50); + + // Style the spheres. + noStroke(); + fill(30, 30, 255); + specularMaterial(255); + shininess(20); + + // Draw the left sphere with low metalness. + translate(-25, 0, 0); + metalness(1); + sphere(20); + + // Draw the right sphere with high metalness. + translate(50, 0, 0); + metalness(50); + sphere(20); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let img; + + function preload() { + img = loadImage('/assets/outdoor_spheremap.jpg'); + } + + function setup() { + createCanvas(100 ,100 ,WEBGL); + + describe( + 'Two spheres floating above a landscape. The surface of the spheres reflect the landscape. The right sphere is more reflective than the left sphere.' + ); + } + + function draw() { + // Add the panorama. + panorama(img); + + // Enable orbiting with the mouse. + orbitControl(); + + // Use the image as a light source. + imageLight(img); + + // Style the spheres. + noStroke(); + specularMaterial(50); + shininess(200); + + // Draw the left sphere with low metalness. + translate(-25, 0, 0); + metalness(1); + sphere(20); + + // Draw the right sphere with high metalness. + translate(50, 0, 0); + metalness(50); + sphere(20); + } + +
+class: p5 +params: + - name: metallic + description: | +

amount of metalness.

+ type: Number +chainable: false +--- + + +# metalness diff --git a/src/content/reference/en/p5 copy/midiToFreq.mdx b/src/content/reference/en/p5 copy/midiToFreq.mdx new file mode 100644 index 0000000000..ada29d80ea --- /dev/null +++ b/src/content/reference/en/p5 copy/midiToFreq.mdx @@ -0,0 +1,66 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L841 +title: midiToFreq +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: | +

Returns the frequency value of a MIDI note value. + General MIDI treats notes as integers where middle C + is 60, C# is 61, D is 62 etc. Useful for generating + musical frequencies with oscillators.

+line: 841 +isConstructor: false +itemtype: method +example: + - |- + +
+ let midiNotes = [60, 64, 67, 72]; + let noteIndex = 0; + let midiVal, freq; + + function setup() { + let cnv = createCanvas(100, 100); + cnv.mousePressed(startSound); + osc = new p5.TriOsc(); + env = new p5.Envelope(); + } + + function draw() { + background(220); + text('tap to play', 10, 20); + if (midiVal) { + text('MIDI: ' + midiVal, 10, 40); + text('Freq: ' + freq, 10, 60); + } + } + + function startSound() { + // see also: userStartAudio(); + osc.start(); + + midiVal = midiNotes[noteIndex % midiNotes.length]; + freq = midiToFreq(midiVal); + osc.freq(freq); + env.ramp(osc, 0, 1.0, 0); + + noteIndex++; + } +
+class: p5 +params: + - name: midiNote + description: | +

The number of a MIDI note

+ type: Number +return: + description: Frequency value of the given MIDI note + type: Number +chainable: false +--- + + +# midiToFreq diff --git a/src/content/reference/en/p5 copy/millis.mdx b/src/content/reference/en/p5 copy/millis.mdx new file mode 100644 index 0000000000..18f1ac06d0 --- /dev/null +++ b/src/content/reference/en/p5 copy/millis.mdx @@ -0,0 +1,147 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L112 +title: millis +module: IO +submodule: Time & Date +file: src/utilities/time_date.js +description: > +

Returns the number of milliseconds since a sketch started running.

+ +

millis() keeps track of how long a sketch has been running in + + milliseconds (thousandths of a second). This information is often + + helpful for timing events and animations.

+ +

If a sketch has a + + setup() function, then + millis() begins tracking + + time before the code in setup() runs. If a + + sketch includes a preload() function, + then + + millis() begins tracking time as soon as the code in + + preload() starts running.

+line: 112 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Get the number of milliseconds the sketch has run. + let ms = millis(); + + // Style the text. + textAlign(LEFT, CENTER); + textSize(10); + textFont('Courier New'); + + // Display how long it took setup() to be called. + text(`Startup time: ${round(ms, 2)} ms`, 5, 50, 90); + + describe( + `The text 'Startup time: ${round(ms, 2)} ms' written in black on a gray background.` + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('The text "Running time: S sec" written in black on a gray background. The number S increases as the sketch runs.'); + } + + function draw() { + background(200); + + // Get the number of seconds the sketch has run. + let s = millis() / 1000; + + // Style the text. + textAlign(LEFT, CENTER); + textSize(10); + textFont('Courier New'); + + // Display how long the sketch has run. + text(`Running time: ${nf(s, 1, 1)} sec`, 5, 50, 90); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A white circle oscillates left and right on a gray background.'); + } + + function draw() { + background(200); + + // Get the number of seconds the sketch has run. + let s = millis() / 1000; + + // Calculate an x-coordinate. + let x = 30 * sin(s) + 50; + + // Draw the circle. + circle(x, 50, 30); + } + +
+ +
+ + // Load the GeoJSON. + function preload() { + loadJSON('https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Get the number of milliseconds the sketch has run. + let ms = millis(); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(11); + + // Display how long it took to load the data. + text(`It took ${round(ms, 2)} ms to load the data`, 5, 50, 100); + + describe( + `The text "It took ${round(ms, 2)} ms to load the data" written in black on a gray background.` + ); + } + +
+class: p5 +return: + description: number of milliseconds since starting the sketch. + type: Number +chainable: false +--- + + +# millis diff --git a/src/content/reference/en/p5 copy/min.mdx b/src/content/reference/en/p5 copy/min.mdx new file mode 100644 index 0000000000..67af3b37f1 --- /dev/null +++ b/src/content/reference/en/p5 copy/min.mdx @@ -0,0 +1,104 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L695 +title: min +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Returns the smallest value in a sequence of numbers.

+ +

The version of min() with one parameter interprets it as an + array of + + numbers and returns the smallest number.

+ +

The version of min() with two or more parameters interprets + them as + + individual numbers and returns the smallest number.

+line: 695 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Calculate the minimum of 10, 5, and 20. + let m = min(10, 5, 20); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the min. + text(m, 50, 50); + + describe('The number 5 written in the middle of a gray square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of numbers. + let numbers = [10, 5, 20]; + + // Calculate the minimum of the array. + let m = min(numbers); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the min. + text(m, 50, 50); + + describe('The number 5 written in the middle of a gray square.'); + } + +
+class: p5 +return: + description: minimum number. + type: Number +overloads: + - line: 695 + params: + - name: n0 + description: | +

first number to compare.

+ type: Number + - name: n1 + description: | +

second number to compare.

+ type: Number + return: + description: minimum number. + type: Number + - line: 757 + params: + - name: nums + description: | +

numbers to compare.

+ type: 'Number[]' + return: + description: '' + type: Number +chainable: false +--- + + +# min diff --git a/src/content/reference/en/p5 copy/minute.mdx b/src/content/reference/en/p5 copy/minute.mdx new file mode 100644 index 0000000000..3ac966c800 --- /dev/null +++ b/src/content/reference/en/p5 copy/minute.mdx @@ -0,0 +1,47 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L78 +title: minute +module: IO +submodule: Time & Date +file: src/utilities/time_date.js +description: | +

Returns the current minute as a number from 0–59.

+line: 78 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Get the current minute. + let m = minute(); + + // Style the text. + textAlign(LEFT, CENTER); + textSize(12); + textFont('Courier New'); + + // Display the minute. + text(`Current minute: ${m}`, 10, 50, 80); + + describe(`The text 'Current minute: ${m}' written in black on a gray background.`); + } + +
+class: p5 +return: + description: current minute between 0 and 59. + type: Integer +chainable: false +--- + + +# minute diff --git a/src/content/reference/en/p5 copy/model.mdx b/src/content/reference/en/p5 copy/model.mdx new file mode 100644 index 0000000000..e925350407 --- /dev/null +++ b/src/content/reference/en/p5 copy/model.mdx @@ -0,0 +1,155 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/loading.js#L991 +title: model +module: Shape +submodule: 3D Models +file: src/webgl/loading.js +description: > +

Draws a p5.Geometry object to the + canvas.

+ +

The parameter, model, is the + + p5.Geometry object to draw. + + p5.Geometry objects can be built with + + buildGeometry(), or + + beginGeometry() and + + endGeometry(). They can also be + loaded from + + a file with loadGeometry().

+ +

Note: model() can only be used in WebGL mode.

+line: 991 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the p5.Geometry object. + shape = buildGeometry(createShape); + + describe('A white cone drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the p5.Geometry object. + model(shape); + } + + // Create p5.Geometry object from a single cone. + function createShape() { + cone(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the p5.Geometry object. + shape = buildGeometry(createArrow); + + describe('Two white arrows drawn on a gray background. The arrow on the right rotates slowly.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the arrows. + noStroke(); + + // Draw the p5.Geometry object. + model(shape); + + // Translate and rotate the coordinate system. + translate(30, 0, 0); + rotateZ(frameCount * 0.01); + + // Draw the p5.Geometry object again. + model(shape); + } + + function createArrow() { + // Add shapes to the p5.Geometry object. + push(); + rotateX(PI); + cone(10); + translate(0, -10, 0); + cylinder(3, 20); + pop(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let shape; + + // Load the file and create a p5.Geometry object. + function preload() { + shape = loadModel('/assets/octahedron.obj'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white octahedron drawn against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the shape. + model(shape); + } + +
+class: p5 +params: + - name: model + description: | +

3D shape to be drawn.

+ type: p5.Geometry +chainable: false +--- + + +# model diff --git a/src/content/reference/en/p5 copy/month.mdx b/src/content/reference/en/p5 copy/month.mdx new file mode 100644 index 0000000000..d2e248235c --- /dev/null +++ b/src/content/reference/en/p5 copy/month.mdx @@ -0,0 +1,47 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L242 +title: month +module: IO +submodule: Time & Date +file: src/utilities/time_date.js +description: | +

Returns the current month as a number from 1–12.

+line: 242 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Get the current month. + let m = month(); + + // Style the text. + textAlign(LEFT, CENTER); + textSize(12); + textFont('Courier New'); + + // Display the month. + text(`Current month: ${m}`, 10, 50, 80); + + describe(`The text 'Current month: ${m}' written in black on a gray background.`); + } + +
+class: p5 +return: + description: current month between 1 and 12. + type: Integer +chainable: false +--- + + +# month diff --git a/src/content/reference/en/p5 copy/mouseButton.mdx b/src/content/reference/en/p5 copy/mouseButton.mdx new file mode 100644 index 0000000000..82128f97a3 --- /dev/null +++ b/src/content/reference/en/p5 copy/mouseButton.mdx @@ -0,0 +1,87 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L687 +title: mouseButton +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A String system variable that contains the value of the last mouse button + + pressed.

+ +

The mouseButton variable is either LEFT, + RIGHT, or CENTER, + + depending on which button was pressed last.

+ +

Note: Different browsers may track mouseButton differently. + See + + MDN + + for more information.

+line: 687 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with black text at its center. The text changes from 0 to either "left" or "right" when the user clicks a mouse button.' + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the mouse button. + text(mouseButton, 50, 50); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + "A gray square. Different shapes appear at its center depending on the mouse button that's clicked." + ); + } + + function draw() { + background(200); + + if (mouseIsPressed === true) { + if (mouseButton === LEFT) { + circle(50, 50, 50); + } + if (mouseButton === RIGHT) { + square(25, 25, 50); + } + if (mouseButton === CENTER) { + triangle(23, 75, 50, 20, 78, 75); + } + } + } + +
+class: p5 +type: Constant +--- + + +# mouseButton diff --git a/src/content/reference/en/p5 copy/mouseClicked.mdx b/src/content/reference/en/p5 copy/mouseClicked.mdx new file mode 100644 index 0000000000..80bd80b0a2 --- /dev/null +++ b/src/content/reference/en/p5 copy/mouseClicked.mdx @@ -0,0 +1,196 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1443 +title: mouseClicked +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A function that's called once after a mouse button is pressed and + released.

+ +

Declaring the function mouseClicked() sets a code block to run + + automatically when the user releases a mouse button after having pressed + + it:

+ +
function mouseClicked() {
+    // Code to run.
+  }
+
+  
+ +

The mouse system variables, such as mouseX and + + mouseY, will be updated with their most + recent + + value when mouseClicked() is called by p5.js:

+ +
function mouseClicked() {
+    if (mouseX < 50) {
+      // Code to run if the mouse is on the left.
+    }
+
+    if (mouseY > 50) {
+      // Code to run if the mouse is near the bottom.
+    }
+  }
+
+  
+ +

The parameter, event, is optional. mouseClicked() + is always passed a + + MouseEvent + + object with properties that describe the mouse click event:

+ +
function mouseClicked(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

On touchscreen devices, mouseClicked() will run when a user’s + touch + + ends if touchEnded() isn’t declared. + If + + touchEnded() is declared, then + + touchEnded() will run when a user’s + touch + + ends and mouseClicked() won’t.

+ +

Browsers may have default behaviors attached to various mouse events. For + + example, some browsers highlight text when the user moves the mouse while + + pressing a mouse button. To prevent any default behavior for this event, + + add return false; to the end of the function.

+ +

Note: mousePressed(), + + mouseReleased(), + + and mouseClicked() are all related. + + mousePressed() runs as soon as the + user + + clicks the mouse. mouseReleased() + runs as + + soon as the user releases the mouse click. mouseClicked() runs + + immediately after mouseReleased().

+line: 1443 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square changes color when the user presses and releases a mouse button.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Toggle the square's color when the user clicks. + function mouseClicked() { + if (value === 0) { + value = 255; + } else { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Style the circle. + fill('orange'); + stroke('royalblue'); + strokeWeight(10); + + describe( + 'An orange circle with a thick, blue border drawn on a gray background. When the user presses and holds the mouse, the border becomes thin and pink. When the user releases the mouse, the border becomes thicker and changes color to blue.' + ); + } + + function draw() { + background(220); + + // Draw the circle. + circle(50, 50, 20); + } + + // Set the stroke color and weight as soon as the user clicks. + function mousePressed() { + stroke('deeppink'); + strokeWeight(3); + } + + // Set the stroke and fill colors as soon as the user releases + // the mouse. + function mouseReleased() { + stroke('royalblue'); + + // This is never visible because fill() is called + // in mouseClicked() which runs immediately after + // mouseReleased(); + fill('limegreen'); + } + + // Set the fill color and stroke weight after + // mousePressed() and mouseReleased() are called. + function mouseClicked() { + fill('orange'); + strokeWeight(10); + } + +
+class: p5 +params: + - name: event + description: | +

optional MouseEvent argument.

+ type: MouseEvent + optional: true +chainable: false +--- + + +# mouseClicked diff --git a/src/content/reference/en/p5 copy/mouseDragged.mdx b/src/content/reference/en/p5 copy/mouseDragged.mdx new file mode 100644 index 0000000000..26fea21fe9 --- /dev/null +++ b/src/content/reference/en/p5 copy/mouseDragged.mdx @@ -0,0 +1,130 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L982 +title: mouseDragged +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A function that's called when the mouse moves while a button is + pressed.

+ +

Declaring the function mouseDragged() sets a code block to run + + automatically when the user clicks and drags the mouse:

+ +
function mouseDragged() {
+    // Code to run.
+  }
+
+  
+ +

The mouse system variables, such as mouseX and + + mouseY, will be updated with their most + recent + + value when mouseDragged() is called by p5.js:

+ +
function mouseDragged() {
+    if (mouseX < 50) {
+      // Code to run if the mouse is on the left.
+    }
+
+    if (mouseY > 50) {
+      // Code to run if the mouse is near the bottom.
+    }
+  }
+
+  
+ +

The parameter, event, is optional. mouseDragged() + is always passed a + + MouseEvent + + object with properties that describe the mouse drag event:

+ +
function mouseDragged(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

On touchscreen devices, mouseDragged() will run when a user + moves a touch + + point if touchMoved() isn’t declared. + If + + touchMoved() is declared, then + + touchMoved() will run when a user + moves a + + touch point and mouseDragged() won’t.

+ +

Browsers may have default behaviors attached to various mouse events. For + + example, some browsers highlight text when the user moves the mouse while + + pressing a mouse button. To prevent any default behavior for this event, + + add return false; to the end of the function.

+line: 982 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square becomes lighter as the user drags the mouse.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + function mouseDragged() { + // Update the grayscale value. + value += 5; + + // Reset the grayscale value. + if (value > 255) { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+class: p5 +params: + - name: event + description: | +

optional MouseEvent argument.

+ type: MouseEvent + optional: true +chainable: false +--- + + +# mouseDragged diff --git a/src/content/reference/en/p5 copy/mouseIsPressed.mdx b/src/content/reference/en/p5 copy/mouseIsPressed.mdx new file mode 100644 index 0000000000..37109eb364 --- /dev/null +++ b/src/content/reference/en/p5 copy/mouseIsPressed.mdx @@ -0,0 +1,73 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L755 +title: mouseIsPressed +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A Boolean system variable that's true if the + mouse is pressed and + + false if not.

+line: 755 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with the word "false" at its center. The word changes to "true" when the user presses a mouse button.' + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the mouseIsPressed variable. + text(mouseIsPressed, 25, 50); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a white square at its center. The inner square turns black when the user presses the mouse.' + ); + } + + function draw() { + background(200); + + // Style the square. + if (mouseIsPressed === true) { + fill(0); + } else { + fill(255); + } + + // Draw the square. + square(25, 25, 50); + } + +
+class: p5 +type: Boolean +--- + + +# mouseIsPressed diff --git a/src/content/reference/en/p5 copy/mouseMoved.mdx b/src/content/reference/en/p5 copy/mouseMoved.mdx new file mode 100644 index 0000000000..14928fdc5e --- /dev/null +++ b/src/content/reference/en/p5 copy/mouseMoved.mdx @@ -0,0 +1,118 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L896 +title: mouseMoved +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A function that's called when the mouse moves.

+ +

Declaring the function mouseMoved() sets a code block to run + + automatically when the user moves the mouse without clicking any mouse + + buttons:

+ +
function mouseMoved() {
+    // Code to run.
+  }
+
+  
+ +

The mouse system variables, such as mouseX and + + mouseY, will be updated with their most + recent + + value when mouseMoved() is called by p5.js:

+ +
function mouseMoved() {
+    if (mouseX < 50) {
+      // Code to run if the mouse is on the left.
+    }
+
+    if (mouseY > 50) {
+      // Code to run if the mouse is near the bottom.
+    }
+  }
+
+  
+ +

The parameter, event, is optional. mouseMoved() + is always passed a + + MouseEvent + + object with properties that describe the mouse move event:

+ +
function mouseMoved(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

Browsers may have default behaviors attached to various mouse events. For + + example, some browsers highlight text when the user moves the mouse while + + pressing a mouse button. To prevent any default behavior for this event, + + add return false; to the end of the function.

+line: 896 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square becomes lighter as the mouse moves.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + function mouseMoved() { + // Update the grayscale value. + value += 5; + + // Reset the grayscale value. + if (value > 255) { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+class: p5 +params: + - name: event + description: | +

optional MouseEvent argument.

+ type: MouseEvent + optional: true +chainable: false +--- + + +# mouseMoved diff --git a/src/content/reference/en/p5 copy/mousePressed.mdx b/src/content/reference/en/p5 copy/mousePressed.mdx new file mode 100644 index 0000000000..81181859c1 --- /dev/null +++ b/src/content/reference/en/p5 copy/mousePressed.mdx @@ -0,0 +1,193 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1098 +title: mousePressed +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A function that's called once when a mouse button is pressed.

+ +

Declaring the function mousePressed() sets a code block to run + + automatically when the user presses a mouse button:

+ +
function mousePressed() {
+    // Code to run.
+  }
+
+  
+ +

The mouse system variables, such as mouseX and + + mouseY, will be updated with their most + recent + + value when mousePressed() is called by p5.js:

+ +
function mousePressed() {
+    if (mouseX < 50) {
+      // Code to run if the mouse is on the left.
+    }
+
+    if (mouseY > 50) {
+      // Code to run if the mouse is near the bottom.
+    }
+  }
+
+  
+ +

The parameter, event, is optional. mousePressed() + is always passed a + + MouseEvent + + object with properties that describe the mouse press event:

+ +
function mousePressed(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

On touchscreen devices, mousePressed() will run when a user’s + touch + + begins if touchStarted() isn’t + declared. If + + touchStarted() is declared, then + + touchStarted() will run when a + user’s touch + + begins and mousePressed() won’t.

+ +

Browsers may have default behaviors attached to various mouse events. For + + example, some browsers highlight text when the user moves the mouse while + + pressing a mouse button. To prevent any default behavior for this event, + + add return false; to the end of the function.

+ +

Note: mousePressed(), mouseReleased(), + + and mouseClicked() are all related. + + mousePressed() runs as soon as the user clicks the mouse. + + mouseReleased() runs as soon as the + user + + releases the mouse click. mouseClicked() + + runs immediately after mouseReleased().

+line: 1098 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square becomes lighter when the user presses a mouse button.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + function mousePressed() { + // Update the grayscale value. + value += 5; + + // Reset the grayscale value. + if (value > 255) { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Style the circle. + fill('orange'); + stroke('royalblue'); + strokeWeight(10); + + describe( + 'An orange circle with a thick, blue border drawn on a gray background. When the user presses and holds the mouse, the border becomes thin and pink. When the user releases the mouse, the border becomes thicker and changes color to blue.' + ); + } + + function draw() { + background(220); + + // Draw the circle. + circle(50, 50, 20); + } + + // Set the stroke color and weight as soon as the user clicks. + function mousePressed() { + stroke('deeppink'); + strokeWeight(3); + } + + // Set the stroke and fill colors as soon as the user releases + // the mouse. + function mouseReleased() { + stroke('royalblue'); + + // This is never visible because fill() is called + // in mouseClicked() which runs immediately after + // mouseReleased(); + fill('limegreen'); + } + + // Set the fill color and stroke weight after + // mousePressed() and mouseReleased() are called. + function mouseClicked() { + fill('orange'); + strokeWeight(10); + } + +
+class: p5 +params: + - name: event + description: | +

optional MouseEvent argument.

+ type: MouseEvent + optional: true +chainable: false +--- + + +# mousePressed diff --git a/src/content/reference/en/p5 copy/mouseReleased.mdx b/src/content/reference/en/p5 copy/mouseReleased.mdx new file mode 100644 index 0000000000..6f52911162 --- /dev/null +++ b/src/content/reference/en/p5 copy/mouseReleased.mdx @@ -0,0 +1,195 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1270 +title: mouseReleased +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A function that's called once when a mouse button is released.

+ +

Declaring the function mouseReleased() sets a code block to + run + + automatically when the user releases a mouse button after having pressed + + it:

+ +
function mouseReleased() {
+    // Code to run.
+  }
+
+  
+ +

The mouse system variables, such as mouseX and + + mouseY, will be updated with their most + recent + + value when mouseReleased() is called by p5.js:

+ +
function mouseReleased() {
+    if (mouseX < 50) {
+      // Code to run if the mouse is on the left.
+    }
+
+    if (mouseY > 50) {
+      // Code to run if the mouse is near the bottom.
+    }
+  }
+
+  
+ +

The parameter, event, is optional. + mouseReleased() is always passed a + + MouseEvent + + object with properties that describe the mouse release event:

+ +
function mouseReleased(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

On touchscreen devices, mouseReleased() will run when a user’s + touch + + ends if touchEnded() isn’t declared. + If + + touchEnded() is declared, then + + touchEnded() will run when a user’s + touch + + ends and mouseReleased() won’t.

+ +

Browsers may have default behaviors attached to various mouse events. For + + example, some browsers highlight text when the user moves the mouse while + + pressing a mouse button. To prevent any default behavior for this event, + + add return false; to the end of the function.

+ +

Note: mousePressed(), + mouseReleased(), + + and mouseClicked() are all related. + + mousePressed() runs as soon as the + user + + clicks the mouse. mouseReleased() runs as soon as the user + releases the + + mouse click. mouseClicked() runs + + immediately after mouseReleased().

+line: 1270 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square becomes lighter when the user presses and releases a mouse button.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + function mouseReleased() { + // Update the grayscale value. + value += 5; + + // Reset the grayscale value. + if (value > 255) { + value = 0; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Style the circle. + fill('orange'); + stroke('royalblue'); + strokeWeight(10); + + describe( + 'An orange circle with a thick, blue border drawn on a gray background. When the user presses and holds the mouse, the border becomes thin and pink. When the user releases the mouse, the border becomes thicker and changes color to blue.' + ); + } + + function draw() { + background(220); + + // Draw the circle. + circle(50, 50, 20); + } + + // Set the stroke color and weight as soon as the user clicks. + function mousePressed() { + stroke('deeppink'); + strokeWeight(3); + } + + // Set the stroke and fill colors as soon as the user releases + // the mouse. + function mouseReleased() { + stroke('royalblue'); + + // This is never visible because fill() is called + // in mouseClicked() which runs immediately after + // mouseReleased(); + fill('limegreen'); + } + + // Set the fill color and stroke weight after + // mousePressed() and mouseReleased() are called. + function mouseClicked() { + fill('orange'); + strokeWeight(10); + } + +
+class: p5 +params: + - name: event + description: | +

optional MouseEvent argument.

+ type: MouseEvent + optional: true +chainable: false +--- + + +# mouseReleased diff --git a/src/content/reference/en/p5 copy/mouseWheel.mdx b/src/content/reference/en/p5 copy/mouseWheel.mdx new file mode 100644 index 0000000000..a659ea3cec --- /dev/null +++ b/src/content/reference/en/p5 copy/mouseWheel.mdx @@ -0,0 +1,162 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1746 +title: mouseWheel +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A function that's called once when the mouse wheel moves.

+ +

Declaring the function mouseWheel() sets a code block to run + + automatically when the user scrolls with the mouse wheel:

+ +
function mouseWheel() {
+    // Code to run.
+  }
+
+  
+ +

The mouse system variables, such as mouseX and + + mouseY, will be updated with their most + recent + + value when mouseWheel() is called by p5.js:

+ +
function mouseWheel() {
+    if (mouseX < 50) {
+      // Code to run if the mouse is on the left.
+    }
+
+    if (mouseY > 50) {
+      // Code to run if the mouse is near the bottom.
+    }
+  }
+
+  
+ +

The parameter, event, is optional. mouseWheel() + is always passed a + + MouseEvent + + object with properties that describe the mouse scroll event:

+ +
function mouseWheel(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

The event object has many properties including + delta, a Number + + containing the distance that the user scrolled. For example, + event.delta + + might have the value 5 when the user scrolls up. event.delta is + positive + + if the user scrolls up and negative if they scroll down. The signs are + + opposite on macOS with "natural" scrolling enabled.

+ +

Browsers may have default behaviors attached to various mouse events. For + + example, some browsers highlight text when the user moves the mouse while + + pressing a mouse button. To prevent any default behavior for this event, + + add return false; to the end of the function.

+ +

Note: On Safari, mouseWheel() may only work as expected if + + return false; is added at the end of the function.

+line: 1746 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let circleSize = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square. A white circle at its center grows up when the user scrolls the mouse wheel.' + ); + } + + function draw() { + background(200); + + // Draw the circle + circle(50, 50, circleSize); + } + + // Increment circleSize when the user scrolls the mouse wheel. + function mouseWheel() { + circleSize += 1; + // Uncomment to prevent any default behavior. + // return false; + } + +
+ +
+ + let direction = ''; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square. An arrow at its center points up when the user scrolls up. The arrow points down when the user scrolls down.' + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Draw an arrow that points where + // the mouse last scrolled. + text(direction, 50, 50); + } + + // Change direction when the user scrolls the mouse wheel. + function mouseWheel(event) { + if (event.delta > 0) { + direction = '▲'; + } else { + direction = '▼'; + } + // Uncomment to prevent any default behavior. + // return false; + } + +
+class: p5 +params: + - name: event + description: | +

optional WheelEvent argument.

+ type: WheelEvent + optional: true +chainable: false +--- + + +# mouseWheel diff --git a/src/content/reference/en/p5 copy/mouseX.mdx b/src/content/reference/en/p5 copy/mouseX.mdx new file mode 100644 index 0000000000..7c0ba7f4a3 --- /dev/null +++ b/src/content/reference/en/p5 copy/mouseX.mdx @@ -0,0 +1,124 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L119 +title: mouseX +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A Number system variable that tracks the mouse's horizontal + position.

+ +

mouseX keeps track of the mouse's position relative to the + + top-left corner of the canvas. For example, if the mouse is 50 pixels from + + the left edge of the canvas, then mouseX will be 50.

+ +

If touch is used instead of the mouse, then mouseX will hold + the + + x-coordinate of the most recent touch point.

+line: 119 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe("A vertical black line moves left and right following the mouse's x-position."); + } + + function draw() { + background(200); + + // Draw a vertical line that follows the mouse's x-coordinate. + line(mouseX, 0, mouseX, 100); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe("A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse."); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the mouse's coordinates. + text(`x: ${mouseX} y: ${mouseY}`, 50, 50); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe("A vertical black line moves left and right following the mouse's x-position."); + } + + function draw() { + background(200); + + // Adjust coordinates for WebGL mode. + // The origin (0, 0) is at the center of the canvas. + let mx = mouseX - 50; + + // Draw the line. + line(mx, -50, mx, 50); + } + +
+ +
+ + let font; + + // Load a font for WebGL mode. + function preload() { + font = loadFont('/assets/inconsolata.otf'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + "A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse." + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + textFont(font); + fill(0); + + // Display the mouse's coordinates. + text(`x: ${mouseX} y: ${mouseY}`, 0, 0); + } + +
+class: p5 +type: Number +--- + + +# mouseX diff --git a/src/content/reference/en/p5 copy/mouseY.mdx b/src/content/reference/en/p5 copy/mouseY.mdx new file mode 100644 index 0000000000..dc268025a4 --- /dev/null +++ b/src/content/reference/en/p5 copy/mouseY.mdx @@ -0,0 +1,124 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L226 +title: mouseY +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A Number system variable that tracks the mouse's vertical + position.

+ +

mouseY keeps track of the mouse's position relative to the + + top-left corner of the canvas. For example, if the mouse is 50 pixels from + + the top edge of the canvas, then mouseY will be 50.

+ +

If touch is used instead of the mouse, then mouseY will hold + the + + y-coordinate of the most recent touch point.

+line: 226 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe("A horizontal black line moves up and down following the mouse's y-position."); + } + + function draw() { + background(200); + + // Draw a horizontal line that follows the mouse's y-coordinate. + line(0, mouseY, 100, mouseY); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe("A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse."); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the mouse's coordinates. + text(`x: ${mouseX} y: ${mouseY}`, 50, 50); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe("A horizontal black line moves up and down following the mouse's y-position."); + } + + function draw() { + background(200); + + // Adjust coordinates for WebGL mode. + // The origin (0, 0) is at the center of the canvas. + let my = mouseY - 50; + + // Draw the line. + line(-50, my, 50, my); + } + +
+ +
+ + let font; + + // Load a font for WebGL mode. + function preload() { + font = loadFont('/assets/inconsolata.otf'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + "A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse." + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + textFont(font); + fill(0); + + // Display the mouse's coordinates. + text(`x: ${mouseX} y: ${mouseY}`, 0, 0); + } + +
+class: p5 +type: Number +--- + + +# mouseY diff --git a/src/content/reference/en/p5 copy/movedX.mdx b/src/content/reference/en/p5 copy/movedX.mdx new file mode 100644 index 0000000000..454b577166 --- /dev/null +++ b/src/content/reference/en/p5 copy/movedX.mdx @@ -0,0 +1,78 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L12 +title: movedX +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A Number system variable that tracks the mouse's horizontal + movement.

+ +

movedX tracks how many pixels the mouse moves left or right + between + + frames. movedX will have a negative value if the mouse moves left + between + + frames and a positive value if it moves right. movedX can be + calculated + + as mouseX - pmouseX.

+ +

Note: movedX continues updating even when + + requestPointerLock() is + active. + + But keep in mind that during an active pointer lock, mouseX and pmouseX + + are locked, so movedX is based on + + the + MouseEvent's movementX value + + (which may behave differently in different browsers when the user + + is zoomed in or out).

+line: 12 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square. The text ">>" appears when the user moves the mouse to the right. The text "<<" appears when the user moves the mouse to the left.' + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display >> when movedX is positive and + // << when it's negative. + if (movedX > 0) { + text('>>', 50, 50); + } else if (movedX < 0) { + text('<<', 50, 50); + } + } + +
+class: p5 +type: Number +--- + + +# movedX diff --git a/src/content/reference/en/p5 copy/movedY.mdx b/src/content/reference/en/p5 copy/movedY.mdx new file mode 100644 index 0000000000..00f4a28d5b --- /dev/null +++ b/src/content/reference/en/p5 copy/movedY.mdx @@ -0,0 +1,78 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L62 +title: movedY +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A Number system variable that tracks the mouse's vertical + movement.

+ +

movedY tracks how many pixels the mouse moves up or down + between + + frames. movedY will have a negative value if the mouse moves up + between + + frames and a positive value if it moves down. movedY can be + calculated + + as mouseY - pmouseY.

+ +

Note: movedY continues updating even when + + requestPointerLock() is + active. + + But keep in mind that during an active pointer lock, mouseX and pmouseX + + are locked, so movedX is based on + + the + MouseEvent's movementX value + + (which may behave differently in different browsers when the user + + is zoomed in or out).

+line: 62 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square. The text "▲" appears when the user moves the mouse upward. The text "▼" appears when the user moves the mouse downward.' + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display ▼ when movedY is positive and + // ▲ when it's negative. + if (movedY > 0) { + text('▼', 50, 50); + } else if (movedY < 0) { + text('▲', 50, 50); + } + } + +
+class: p5 +type: Number +--- + + +# movedY diff --git a/src/content/reference/en/p5 copy/nf.mdx b/src/content/reference/en/p5 copy/nf.mdx new file mode 100644 index 0000000000..ab64244d9f --- /dev/null +++ b/src/content/reference/en/p5 copy/nf.mdx @@ -0,0 +1,159 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L199 +title: nf +module: Data +submodule: String Functions +file: src/utilities/string_functions.js +description: > +

Converts a Number into a String with a given + number of digits.

+ +

nf() converts numbers such as 123.45 into strings + formatted with a set + + number of digits, as in '123.4500'.

+ +

The first parameter, num, is the number to convert to a + string. For + + example, calling nf(123.45) returns the string + '123.45'. If an array of + + numbers is passed, as in nf([123.45, 67.89]), an array of + formatted + + strings will be returned.

+ +

The second parameter, left, is optional. If a number is + passed, as in + + nf(123.45, 4), it sets the minimum number of digits to include to + the + + left of the decimal place. If left is larger than the number of + digits in + + num, then unused digits will be set to 0. For example, calling + + nf(123.45, 4) returns the string '0123.45'.

+ +

The third parameter, right, is also optional. If a number is + passed, as + + in nf(123.45, 4, 1), it sets the minimum number of digits to + include to + + the right of the decimal place. If right is smaller than the + number of + + decimal places in num, then num will be rounded to + the given number of + + decimal places. For example, calling nf(123.45, 4, 1) returns the + string + + '0123.5'. If right is larger than the number of decimal places in + num, + + then unused decimal places will be set to 0. For example, calling + + nf(123.45, 4, 3) returns the string '0123.450'.

+ +

When the number is negative, for example, calling nf(-123.45, 5, + 2) + + returns the string '-00123.45'.

+line: 199 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textSize(16); + + // Create a number variable. + let number = 123.45; + + // Display the number as a string. + let formatted = nf(number); + text(formatted, 20, 20); + + let negative = nf(-number, 4, 2); + text(negative, 20, 40); + + // Display the number with four digits + // to the left of the decimal. + let left = nf(number, 4); + text(left, 20, 60); + + // Display the number with four digits + // to the left of the decimal and one + // to the right. + let right = nf(number, 4, 1); + text(right, 20, 80); + + describe( + 'The numbers "123.45", "-0123.45", "0123.45", and "0123.5" written on four separate lines. The text is in black on a gray background.' + ); + } + +
+class: p5 +return: + description: formatted string. + type: String +overloads: + - line: 199 + params: + - name: num + description: | +

number to format.

+ type: Number|String + - name: left + description: | +

number of digits to include to the left of + the decimal point.

+ type: Integer|String + optional: true + - name: right + description: | +

number of digits to include to the right + of the decimal point.

+ type: Integer|String + optional: true + return: + description: formatted string. + type: String + - line: 276 + params: + - name: nums + description: | +

numbers to format.

+ type: 'Number[]' + - name: left + description: '' + type: Integer|String + optional: true + - name: right + description: '' + type: Integer|String + optional: true + return: + description: formatted strings. + type: 'String[]' +chainable: false +--- + + +# nf diff --git a/src/content/reference/en/p5 copy/nfc.mdx b/src/content/reference/en/p5 copy/nfc.mdx new file mode 100644 index 0000000000..ba49f689fa --- /dev/null +++ b/src/content/reference/en/p5 copy/nfc.mdx @@ -0,0 +1,153 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L322 +title: nfc +module: Data +submodule: String Functions +file: src/utilities/string_functions.js +description: > +

Converts a Number into a String with commas to + mark units of 1,000.

+ +

nfc() converts numbers such as 12345 into strings formatted + with commas + + to mark the thousands place, as in '12,345'.

+ +

The first parameter, num, is the number to convert to a + string. For + + example, calling nfc(12345) returns the string + '12,345'.

+ +

The second parameter, right, is optional. If a number is + passed, as in + + nfc(12345, 1), it sets the minimum number of digits to include to + the + + right of the decimal place. If right is smaller than the number + of + + decimal places in num, then num will be rounded to + the given number of + + decimal places. For example, calling nfc(12345.67, 1) returns the + string + + '12,345.7'. If right is larger than the number of + decimal places in + + num, then unused decimal places will be set to 0. For example, + calling + + nfc(12345.67, 3) returns the string + '12,345.670'.

+line: 322 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textSize(16); + + // Create a number variable. + let number = 12345; + + // Display the number as a string. + let commas = nfc(number); + text(commas, 15, 33); + + // Display the number with four digits + // to the left of the decimal. + let decimals = nfc(number, 2); + text(decimals, 15, 67); + + describe( + 'The numbers "12,345" and "12,345.00" written on separate lines. The text is in black on a gray background.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of numbers. + let numbers = [12345, 6789]; + + // Convert the numbers to formatted strings. + let formatted = nfc(numbers); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(14); + + // Iterate over the array. + for (let i = 0; i < formatted.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 33; + + // Display the original and formatted numbers. + text(`${numbers[i]} : ${formatted[i]}`, 50, y); + } + + describe( + 'The text "12345 : 12,345" and "6789 : 6,789" written on two separate lines. The text is in black on a gray background.' + ); + } + +
+class: p5 +return: + description: formatted string. + type: String +overloads: + - line: 322 + params: + - name: num + description: | +

number to format.

+ type: Number|String + - name: right + description: | +

number of digits to include to the right + of the decimal point.

+ type: Integer|String + optional: true + return: + description: formatted string. + type: String + - line: 411 + params: + - name: nums + description: | +

numbers to format.

+ type: 'Number[]' + - name: right + description: '' + type: Integer|String + optional: true + return: + description: formatted strings. + type: 'String[]' +chainable: false +--- + + +# nfc diff --git a/src/content/reference/en/p5 copy/nfp.mdx b/src/content/reference/en/p5 copy/nfp.mdx new file mode 100644 index 0000000000..dbd80ca5d7 --- /dev/null +++ b/src/content/reference/en/p5 copy/nfp.mdx @@ -0,0 +1,188 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L447 +title: nfp +module: Data +submodule: String Functions +file: src/utilities/string_functions.js +description: > +

Converts a Number into a String with a plus or + minus sign.

+ +

nfp() converts numbers such as 123 into strings formatted with + a + or + + - symbol to mark whether they're positive or negative, as in + '+123'.

+ +

The first parameter, num, is the number to convert to a + string. For + + example, calling nfp(123.45) returns the string + '+123.45'. If an array + + of numbers is passed, as in nfp([123.45, -6.78]), an array of + formatted + + strings will be returned.

+ +

The second parameter, left, is optional. If a number is + passed, as in + + nfp(123.45, 4), it sets the minimum number of digits to include + to the + + left of the decimal place. If left is larger than the number of + digits in + + num, then unused digits will be set to 0. For example, calling + + nfp(123.45, 4) returns the string '+0123.45'.

+ +

The third parameter, right, is also optional. If a number is + passed, as + + in nfp(123.45, 4, 1), it sets the minimum number of digits to + include to + + the right of the decimal place. If right is smaller than the + number of + + decimal places in num, then num will be rounded to + the given number of + + decimal places. For example, calling nfp(123.45, 4, 1) returns + the + + string '+0123.5'. If right is larger than the number + of decimal places + + in num, then unused decimal places will be set to 0. For + example, + + calling nfp(123.45, 4, 3) returns the string + '+0123.450'.

+line: 447 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create number variables. + let positive = 123; + let negative = -123; + + // Convert the positive number to a formatted string. + let p = nfp(positive); + + // Convert the negative number to a formatted string + // with four digits to the left of the decimal + // and two digits to the right of the decimal. + let n = nfp(negative, 4, 2); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(14); + + // Display the original and formatted numbers. + text(`${positive} : ${p}`, 50, 33); + text(`${negative} : ${n}`, 50, 67); + + describe( + 'The text "123 : +123" and "-123 : -123.00" written on separate lines. The text is in black on a gray background.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create number variables. + let numbers = [123, -4.56]; + + // Convert the numbers to formatted strings + // with four digits to the left of the decimal + // and one digit to the right of the decimal. + let formatted = nfp(numbers, 4, 1); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(14); + + // Iterate over the array. + for (let i = 0; i < formatted.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 33; + + // Display the original and formatted numbers. + text(`${numbers[i]} : ${formatted[i]}`, 50, y); + } + + describe( + 'The text "123 : +0123.0" and "-4.56 : 00-4.6" written on separate lines. The text is in black on a gray background.' + ); + } + +
+class: p5 +return: + description: formatted string. + type: String +overloads: + - line: 447 + params: + - name: num + description: | +

number to format.

+ type: Number + - name: left + description: | +

number of digits to include to the left of the + decimal point.

+ type: Integer + optional: true + - name: right + description: | +

number of digits to include to the right of the + decimal point.

+ type: Integer + optional: true + return: + description: formatted string. + type: String + - line: 552 + params: + - name: nums + description: | +

numbers to format.

+ type: 'Number[]' + - name: left + description: '' + type: Integer + optional: true + - name: right + description: '' + type: Integer + optional: true + return: + description: formatted strings. + type: 'String[]' +chainable: false +--- + + +# nfp diff --git a/src/content/reference/en/p5 copy/nfs.mdx b/src/content/reference/en/p5 copy/nfs.mdx new file mode 100644 index 0000000000..80c144e391 --- /dev/null +++ b/src/content/reference/en/p5 copy/nfs.mdx @@ -0,0 +1,176 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L573 +title: nfs +module: Data +submodule: String Functions +file: src/utilities/string_functions.js +description: > +

Converts a positive Number into a String with an + extra space in front.

+ +

nfs() converts positive numbers such as 123.45 into strings + formatted + + with an extra space in front, as in ' 123.45'. Doing so can be helpful for + + aligning positive and negative numbers.

+ +

The first parameter, num, is the number to convert to a + string. For + + example, calling nfs(123.45) returns the string ' + 123.45'.

+ +

The second parameter, left, is optional. If a number is + passed, as in + + nfs(123.45, 4), it sets the minimum number of digits to include + to the + + left of the decimal place. If left is larger than the number of + digits in + + num, then unused digits will be set to 0. For example, calling + + nfs(123.45, 4) returns the string ' 0123.45'.

+ +

The third parameter, right, is also optional. If a number is + passed, as + + in nfs(123.45, 4, 1), it sets the minimum number of digits to + include to + + the right of the decimal place. If right is smaller than the + number of + + decimal places in num, then num will be rounded to + the given number of + + decimal places. For example, calling nfs(123.45, 4, 1) returns + the + + string ' 0123.5'. If right is larger than the number + of decimal places + + in num, then unused decimal places will be set to 0. For + example, + + calling nfs(123.45, 4, 3) returns the string ' + 0123.450'.

+line: 573 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create number variables. + let positive = 123; + let negative = -123; + + // Convert the positive number to a formatted string. + let formatted = nfs(positive); + + // Style the text. + textAlign(CENTER, CENTER); + textFont('Courier New'); + textSize(16); + + // Display the negative number and the formatted positive number. + text(negative, 50, 33); + text(formatted, 50, 67); + + describe( + 'The numbers -123 and 123 written on separate lines. The numbers align vertically. The text is in black on a gray background.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a number variable. + let number = 123.45; + + // Convert the positive number to a formatted string. + // Use four digits to the left of the decimal and + // one digit to the right. + let formatted = nfs(number, 4, 1); + + // Style the text. + textAlign(CENTER, CENTER); + textFont('Courier New'); + textSize(16); + + // Display a negative version of the number and + // the formatted positive version. + text('-0123.5', 50, 33); + text(formatted, 50, 67); + + describe( + 'The numbers "-0123.5" and "0123.5" written on separate lines. The numbers align vertically. The text is in black on a gray background.' + ); + } + +
+class: p5 +return: + description: formatted string. + type: String +overloads: + - line: 573 + params: + - name: num + description: | +

number to format.

+ type: Number + - name: left + description: | +

number of digits to include to the left of the + decimal point.

+ type: Integer + optional: true + - name: right + description: | +

number of digits to include to the right of the + decimal point.

+ type: Integer + optional: true + return: + description: formatted string. + type: String + - line: 669 + params: + - name: nums + description: | +

numbers to format.

+ type: Array + - name: left + description: '' + type: Integer + optional: true + - name: right + description: '' + type: Integer + optional: true + return: + description: formatted strings. + type: 'String[]' +chainable: false +--- + + +# nfs diff --git a/src/content/reference/en/p5 copy/noCanvas.mdx b/src/content/reference/en/p5 copy/noCanvas.mdx new file mode 100644 index 0000000000..08fcdda5e5 --- /dev/null +++ b/src/content/reference/en/p5 copy/noCanvas.mdx @@ -0,0 +1,36 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L346 +title: noCanvas +module: Rendering +submodule: Rendering +file: src/core/rendering.js +description: > +

Removes the default canvas.

+ +

By default, a 100×100 pixels canvas is created without needing to call + + createCanvas(). + noCanvas() removes the + + default canvas for sketches that don't need it.

+line: 346 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + noCanvas(); + } + +
+class: p5 +chainable: false +--- + + +# noCanvas diff --git a/src/content/reference/en/p5 copy/noCursor.mdx b/src/content/reference/en/p5 copy/noCursor.mdx new file mode 100644 index 0000000000..37ac72c0cf --- /dev/null +++ b/src/content/reference/en/p5 copy/noCursor.mdx @@ -0,0 +1,38 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L482 +title: noCursor +module: Environment +submodule: Environment +file: src/core/environment.js +description: | +

Hides the cursor from view.

+line: 482 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + // Hide the cursor. + noCursor(); + } + + function draw() { + background(200); + + circle(mouseX, mouseY, 10); + + describe('A white circle on a gray background. The circle follows the mouse as it moves. The cursor is hidden.'); + } + +
+class: p5 +chainable: false +--- + + +# noCursor diff --git a/src/content/reference/en/p5 copy/noDebugMode.mdx b/src/content/reference/en/p5 copy/noDebugMode.mdx new file mode 100644 index 0000000000..19d36eba2b --- /dev/null +++ b/src/content/reference/en/p5 copy/noDebugMode.mdx @@ -0,0 +1,54 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/interaction.js#L725 +title: noDebugMode +module: 3D +submodule: Interaction +file: src/webgl/interaction.js +description: > +

Turns off debugMode() in a 3D + sketch.

+line: 725 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + // Enable debug mode. + debugMode(); + + describe('A multicolor box on a gray background. A grid and axes icon are displayed near the box. They disappear when the user double-clicks.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the box. + normalMaterial(); + + // Draw the box. box(20, 40); + } + + // Disable debug mode when the user double-clicks. + function doubleClicked() { + noDebugMode(); + } + +
+class: p5 +chainable: false +--- + + +# noDebugMode diff --git a/src/content/reference/en/p5 copy/noErase.mdx b/src/content/reference/en/p5 copy/noErase.mdx new file mode 100644 index 0000000000..e959433b77 --- /dev/null +++ b/src/content/reference/en/p5 copy/noErase.mdx @@ -0,0 +1,55 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1716 +title: noErase +module: Color +submodule: Setting +file: src/color/setting.js +description: > +

Ends erasing that was started with erase().

+ +

The fill(), stroke(), and + + blendMode() settings will return to + what they + + were prior to calling erase().

+line: 1716 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(235, 145, 15); + + // Draw the left rectangle. + noStroke(); + fill(30, 45, 220); + rect(30, 10, 10, 80); + + // Erase a circle. + erase(); + circle(50, 50, 60); + noErase(); + + // Draw the right rectangle. + rect(70, 10, 10, 80); + + describe('An orange canvas with two tall blue rectangles. A circular hole in the center erases the rectangle on the left but not the one on the right.'); + } + +
+class: p5 +chainable: true +--- + + +# noErase diff --git a/src/content/reference/en/p5 copy/noFill.mdx b/src/content/reference/en/p5 copy/noFill.mdx new file mode 100644 index 0000000000..67a3979778 --- /dev/null +++ b/src/content/reference/en/p5 copy/noFill.mdx @@ -0,0 +1,73 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1257 +title: noFill +module: Color +submodule: Setting +file: src/color/setting.js +description: > +

Disables setting the fill color for shapes.

+ +

Calling noFill() is the same as making the fill completely + transparent, + + as in fill(0, 0). If both noStroke() and + + noFill() are called, nothing will be drawn to the screen.

+line: 1257 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw the top square. + square(32, 10, 35); + + // Draw the bottom square. + noFill(); + square(32, 55, 35); + + describe('A white square on above an empty square. Both squares have black outlines.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A purple cube wireframe spinning on a black canvas.'); + } + + function draw() { + background(0); + + // Style the box. + noFill(); + stroke(100, 100, 240); + + // Rotate the coordinates. + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + + // Draw the box. + box(45); + } + +
+class: p5 +chainable: true +--- + + +# noFill diff --git a/src/content/reference/en/p5 copy/noLights.mdx b/src/content/reference/en/p5 copy/noLights.mdx new file mode 100644 index 0000000000..1f85888bf6 --- /dev/null +++ b/src/content/reference/en/p5 copy/noLights.mdx @@ -0,0 +1,79 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L1687 +title: noLights +module: 3D +submodule: Lights +file: src/webgl/light.js +description: > +

Removes all lights from the sketch.

+ +

Calling noLights() removes any lights created with + + lights(), + + ambientLight(), + + directionalLight(), + + pointLight(), or + + spotLight(). These functions may be + called + + after noLights() to create a new lighting scheme.

+line: 1687 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('Two spheres drawn against a gray background. The top sphere is white and the bottom sphere is red.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the spheres. + noStroke(); + + // Draw the top sphere. + push(); + translate(0, -25, 0); + sphere(20); + pop(); + + // Turn off the lights. + noLights(); + + // Add a red directional light that points into the screen. + directionalLight(255, 0, 0, 0, 0, -1); + + // Draw the bottom sphere. + push(); + translate(0, 25, 0); + sphere(20); + pop(); + } + +
+class: p5 +chainable: true +--- + + +# noLights diff --git a/src/content/reference/en/p5 copy/noLoop.mdx b/src/content/reference/en/p5 copy/noLoop.mdx new file mode 100644 index 0000000000..fe1897a8cb --- /dev/null +++ b/src/content/reference/en/p5 copy/noLoop.mdx @@ -0,0 +1,139 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L9 +title: noLoop +module: Structure +submodule: Structure +file: src/core/structure.js +description: > +

Stops the code in draw() from running + repeatedly.

+ +

By default, draw() tries to run 60 times + per + + second. Calling noLoop() stops draw() from + + repeating. The draw loop can be restarted by calling + + loop(). draw() can be run + + once by calling redraw().

+ +

The isLooping() function can be used + to check + + whether a sketch is looping, as in isLooping() === true.

+line: 9 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Turn off the draw loop. + noLoop(); + + describe('A white half-circle on the left edge of a gray square.'); + } + + function draw() { + background(200); + + // Calculate the circle's x-coordinate. + let x = frameCount; + + // Draw the circle. + // Normally, the circle would move from left to right. + circle(x, 50, 20); + } + +
+ +
+ + // Double-click to stop the draw loop. + + function setup() { + createCanvas(100, 100); + + // Slow the frame rate. + frameRate(5); + + describe('A white circle moves randomly on a gray background. It stops moving when the user double-clicks.'); + } + + function draw() { + background(200); + + // Calculate the circle's coordinates. + let x = random(0, 100); + let y = random(0, 100); + + // Draw the circle. + // Normally, the circle would move from left to right. + circle(x, y, 20); + } + + // Stop the draw loop when the user double-clicks. + function doubleClicked() { + noLoop(); + } + +
+ +
+ + let startButton; + let stopButton; + + function setup() { + createCanvas(100, 100); + + // Create the button elements and place them + // beneath the canvas. + startButton = createButton('▶'); + startButton.position(0, 100); + startButton.size(50, 20); + stopButton = createButton('◾'); + stopButton.position(50, 100); + stopButton.size(50, 20); + + // Set functions to call when the buttons are pressed. + startButton.mousePressed(loop); + stopButton.mousePressed(noLoop); + + // Slow the frame rate. + frameRate(5); + + describe( + 'A white circle moves randomly on a gray background. Play and stop buttons are shown beneath the canvas. The circle stops or starts moving when the user presses a button.' + ); + } + + function draw() { + background(200); + + // Calculate the circle's coordinates. + let x = random(0, 100); + let y = random(0, 100); + + // Draw the circle. + // Normally, the circle would move from left to right. + circle(x, y, 20); + } + +
+class: p5 +chainable: false +--- + + +# noLoop diff --git a/src/content/reference/en/p5 copy/noSmooth.mdx b/src/content/reference/en/p5 copy/noSmooth.mdx new file mode 100644 index 0000000000..a1af76d10d --- /dev/null +++ b/src/content/reference/en/p5 copy/noSmooth.mdx @@ -0,0 +1,92 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L100 +title: noSmooth +module: Shape +submodule: Attributes +file: src/core/shape/attributes.js +description: > +

Draws certain features with jagged (aliased) edges.

+ +

smooth() is active by default. In 2D + mode, + + noSmooth() is helpful for scaling up images without blurring. The + + functions don't affect shapes or fonts.

+ +

In WebGL mode, noSmooth() causes all shapes to be drawn with + jagged + + (aliased) edges. The functions don't affect images or fonts.

+line: 100 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let heart; + + // Load a pixelated heart image from an image data string. + function preload() { + heart = loadImage('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAAXNSR0IArs4c6QAAAEZJREFUGFd9jcsNACAIQ9tB2MeR3YdBMBBq8CIXPi2vBICIiOwkOedatllqWO6Y8yOWoyuNf1GZwgmf+RRG2YXr+xVFmA8HZ9Mx/KGPMtcAAAAASUVORK5CYII='); + } + + function setup() { + createCanvas(100, 100); + + background(50); + + // Antialiased hearts. + image(heart, 10, 10); + image(heart, 20, 10, 16, 16); + image(heart, 40, 10, 32, 32); + + // Aliased hearts. + noSmooth(); + image(heart, 10, 60); + image(heart, 20, 60, 16, 16); + image(heart, 40, 60, 32, 32); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + circle(0, 0, 80); + + describe('A white circle on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + // Disable smoothing. + noSmooth(); + + background(200); + + circle(0, 0, 80); + + describe('A pixelated white circle on a gray background.'); + } + +
+class: p5 +chainable: true +--- + + +# noSmooth diff --git a/src/content/reference/en/p5 copy/noStroke.mdx b/src/content/reference/en/p5 copy/noStroke.mdx new file mode 100644 index 0000000000..7c4fe80960 --- /dev/null +++ b/src/content/reference/en/p5 copy/noStroke.mdx @@ -0,0 +1,71 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1317 +title: noStroke +module: Color +submodule: Setting +file: src/color/setting.js +description: > +

Disables drawing points, lines, and the outlines of shapes.

+ +

Calling noStroke() is the same as making the stroke completely + transparent, + + as in stroke(0, 0). If both noStroke() and + + noFill() are called, nothing will be drawn + to the + + screen.

+line: 1317 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + noStroke(); + square(20, 20, 60); + + describe('A white square with no outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A pink cube with no edge outlines spinning on a black canvas.'); + } + + function draw() { + background(0); + + // Style the box. + noStroke(); + fill(240, 150, 150); + + // Rotate the coordinates. + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + + // Draw the box. + box(45); + } + +
+class: p5 +chainable: true +--- + + +# noStroke diff --git a/src/content/reference/en/p5 copy/noTint.mdx b/src/content/reference/en/p5 copy/noTint.mdx new file mode 100644 index 0000000000..e3b0aeea19 --- /dev/null +++ b/src/content/reference/en/p5 copy/noTint.mdx @@ -0,0 +1,51 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L1345 +title: noTint +module: Image +submodule: Loading & Displaying +file: src/image/loading_displaying.js +description: > +

Removes the current tint set by tint().

+ +

noTint() restores images to their original colors.

+line: 1345 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Left. + // Tint with a CSS color string. + tint('red'); + image(img, 0, 0); + + // Right. + // Remove the tint. + noTint(); + image(img, 50, 0); + + describe('Two images of an umbrella and a ceiling side-by-side. The image on the left has a red tint.'); + } + +
+class: p5 +chainable: false +--- + + +# noTint diff --git a/src/content/reference/en/p5 copy/noise.mdx b/src/content/reference/en/p5 copy/noise.mdx new file mode 100644 index 0000000000..1b67f49cb9 --- /dev/null +++ b/src/content/reference/en/p5 copy/noise.mdx @@ -0,0 +1,282 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/noise.js#L36 +title: noise +module: Math +submodule: Noise +file: src/math/noise.js +description: > +

Returns random numbers that can be tuned to feel organic.

+ +

Values returned by random() and + + randomGaussian() can change by + large + + amounts between function calls. By contrast, values returned by + noise() + + can be made "smooth". Calls to noise() with similar inputs will + produce + + similar outputs. noise() is used to create textures, motion, + shapes, + + terrains, and so on. Ken Perlin invented noise() while animating + the + + original Tron film in the 1980s.

+ +

noise() always returns values between 0 and 1. It returns the + same value + + for a given input while a sketch is running. noise() produces + different + + results each time a sketch runs. The + + noiseSeed() function can be used to + generate + + the same sequence of Perlin noise values each time a sketch runs.

+ +

The character of the noise can be adjusted in two ways. The first way is to + + scale the inputs. noise() interprets inputs as coordinates. The + sequence + + of noise values will be smoother when the input coordinates are closer. The + + second way is to use the noiseDetail() + + function.

+ +

The version of noise() with one parameter computes noise + values in one + + dimension. This dimension can be thought of as space, as in + noise(x), or + + time, as in noise(t).

+ +

The version of noise() with two parameters computes noise + values in two + + dimensions. These dimensions can be thought of as space, as in + + noise(x, y), or space and time, as in noise(x, + t).

+ +

The version of noise() with three parameters computes noise + values in + + three dimensions. These dimensions can be thought of as space, as in + + noise(x, y, z), or space and time, as in noise(x, y, + t).

+line: 36 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A black dot moves randomly on a gray square.'); + } + + function draw() { + background(200); + + // Calculate the coordinates. + let x = 100 * noise(0.005 * frameCount); + let y = 100 * noise(0.005 * frameCount + 10000); + + // Draw the point. + strokeWeight(5); + point(x, y); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A black dot moves randomly on a gray square.'); + } + + function draw() { + background(200); + + // Set the noise level and scale. + let noiseLevel = 100; + let noiseScale = 0.005; + + // Scale the input coordinate. + let nt = noiseScale * frameCount; + + // Compute the noise values. + let x = noiseLevel * noise(nt); + let y = noiseLevel * noise(nt + 10000); + + // Draw the point. + strokeWeight(5); + point(x, y); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A hilly terrain drawn in gray against a black sky.'); + } + + function draw() { + // Set the noise level and scale. + let noiseLevel = 100; + let noiseScale = 0.02; + + // Scale the input coordinate. + let x = frameCount; + let nx = noiseScale * x; + + // Compute the noise value. + let y = noiseLevel * noise(nx); + + // Draw the line. + line(x, 0, x, y); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A calm sea drawn in gray against a black sky.'); + } + + function draw() { + background(200); + + // Set the noise level and scale. + let noiseLevel = 100; + let noiseScale = 0.002; + + // Iterate from left to right. + for (let x = 0; x < width; x += 1) { + // Scale the input coordinates. + let nx = noiseScale * x; + let nt = noiseScale * frameCount; + + // Compute the noise value. + let y = noiseLevel * noise(nx, nt); + + // Draw the line. + line(x, 0, x, y); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Set the noise level and scale. + let noiseLevel = 255; + let noiseScale = 0.01; + + // Iterate from top to bottom. + for (let y = 0; y < height; y += 1) { + // Iterate from left to right. + for (let x = 0; x < width; x += 1) { + // Scale the input coordinates. + let nx = noiseScale * x; + let ny = noiseScale * y; + + // Compute the noise value. + let c = noiseLevel * noise(nx, ny); + + // Draw the point. + stroke(c); + point(x, y); + } + } + + describe('A gray cloudy pattern.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A gray cloudy pattern that changes.'); + } + + function draw() { + // Set the noise level and scale. + let noiseLevel = 255; + let noiseScale = 0.009; + + // Iterate from top to bottom. + for (let y = 0; y < height; y += 1) { + // Iterate from left to right. + for (let x = 0; x < width; x += 1) { + // Scale the input coordinates. + let nx = noiseScale * x; + let ny = noiseScale * y; + let nt = noiseScale * frameCount; + + // Compute the noise value. + let c = noiseLevel * noise(nx, ny, nt); + + // Draw the point. + stroke(c); + point(x, y); + } + } + } + +
+class: p5 +params: + - name: x + description: | +

x-coordinate in noise space.

+ type: Number + - name: 'y' + description: | +

y-coordinate in noise space.

+ type: Number + optional: true + - name: z + description: | +

z-coordinate in noise space.

+ type: Number + optional: true +return: + description: Perlin noise value at specified coordinates. + type: Number +chainable: false +--- + + +# noise diff --git a/src/content/reference/en/p5 copy/noiseDetail.mdx b/src/content/reference/en/p5 copy/noiseDetail.mdx new file mode 100644 index 0000000000..973ac515ab --- /dev/null +++ b/src/content/reference/en/p5 copy/noiseDetail.mdx @@ -0,0 +1,100 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/noise.js#L331 +title: noiseDetail +module: Math +submodule: Noise +file: src/math/noise.js +description: > +

Adjusts the character of the noise produced by the + + noise() function.

+ +

Perlin noise values are created by adding layers of noise together. The + + noise layers, called octaves, are similar to harmonics in music. Lower + + octaves contribute more to the output signal. They define the overall + + intensity of the noise. Higher octaves create finer-grained details.

+ +

By default, noise values are created by combining four octaves. Each higher + + octave contributes half as much (50% less) compared to its predecessor. + + noiseDetail() changes the number of octaves and the falloff + amount. For + + example, calling noiseDetail(6, 0.25) ensures that + + noise() will use six octaves. Each higher + octave + + will contribute 25% as much (75% less) compared to its predecessor. Falloff + + values between 0 and 1 are valid. However, falloff values greater than 0.5 + + might result in noise values greater than 1.

+line: 331 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Set the noise level and scale. + let noiseLevel = 255; + let noiseScale = 0.02; + + // Iterate from top to bottom. + for (let y = 0; y < height; y += 1) { + // Iterate from left to right. + for (let x = 0; x < width / 2; x += 1) { + // Scale the input coordinates. + let nx = noiseScale * x; + let ny = noiseScale * y; + + // Compute the noise value with six octaves + // and a low falloff factor. + noiseDetail(6, 0.25); + let c = noiseLevel * noise(nx, ny); + + // Draw the left side. + stroke(c); + point(x, y); + + // Compute the noise value with four octaves + // and a high falloff factor. + noiseDetail(4, 0.5); + c = noiseLevel * noise(nx, ny); + + // Draw the right side. + stroke(c); + point(x + 50, y); + } + } + + describe('Two gray cloudy patterns. The pattern on the right is cloudier than the pattern on the left.'); + } + +
+class: p5 +params: + - name: lod + description: | +

number of octaves to be used by the noise.

+ type: Number + - name: falloff + description: | +

falloff factor for each octave.

+ type: Number +chainable: false +--- + + +# noiseDetail diff --git a/src/content/reference/en/p5 copy/noiseSeed.mdx b/src/content/reference/en/p5 copy/noiseSeed.mdx new file mode 100644 index 0000000000..a1f2ce6fbd --- /dev/null +++ b/src/content/reference/en/p5 copy/noiseSeed.mdx @@ -0,0 +1,68 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/noise.js#L405 +title: noiseSeed +module: Math +submodule: Noise +file: src/math/noise.js +description: > +

Sets the seed value for the noise() + function.

+ +

By default, noise() produces different + results + + each time a sketch is run. Calling noiseSeed() with a constant + argument, + + such as noiseSeed(99), makes noise() produce the + + same results each time a sketch is run.

+line: 405 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Set the noise seed for consistent results. + noiseSeed(99); + + describe('A black rectangle that grows randomly, first to the right and then to the left.'); + } + + function draw() { + // Set the noise level and scale. + let noiseLevel = 100; + let noiseScale = 0.005; + + // Scale the input coordinate. + let nt = noiseScale * frameCount; + + // Compute the noise value. + let x = noiseLevel * noise(nt); + + // Draw the line. + line(x, 0, x, height); + } + +
+class: p5 +params: + - name: seed + description: | +

seed value.

+ type: Number +chainable: false +--- + + +# noiseSeed diff --git a/src/content/reference/en/p5 copy/norm.mdx b/src/content/reference/en/p5 copy/norm.mdx new file mode 100644 index 0000000000..d52a73e4c5 --- /dev/null +++ b/src/content/reference/en/p5 copy/norm.mdx @@ -0,0 +1,69 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L772 +title: norm +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Maps a number from one range to a value between 0 and 1.

+ +

For example, norm(2, 0, 10) returns 0.2. 2's position in the + original + + range [0, 10] is proportional to 0.2's position in the range [0, 1]. This + + is the same as calling map(2, 0, 10, 0, 1).

+ +

Numbers outside of the original range are not constrained between 0 and 1. + + Out-of-range values are often intentional and useful.

+line: 772 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Use RGB color with values from 0 to 1. + colorMode(RGB, 1); + + describe('A square changes color from black to red as the mouse moves from left to right.'); + } + + function draw() { + // Calculate the redValue. + let redValue = norm(mouseX, 0, 100); + + // Paint the background. + background(redValue, 0, 0); + } + +
+class: p5 +params: + - name: value + description: | +

incoming value to be normalized.

+ type: Number + - name: start + description: | +

lower bound of the value's current range.

+ type: Number + - name: stop + description: | +

upper bound of the value's current range.

+ type: Number +return: + description: normalized number. + type: Number +chainable: false +--- + + +# norm diff --git a/src/content/reference/en/p5 copy/normal.mdx b/src/content/reference/en/p5 copy/normal.mdx new file mode 100644 index 0000000000..a109745b80 --- /dev/null +++ b/src/content/reference/en/p5 copy/normal.mdx @@ -0,0 +1,250 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L2097 +title: normal +module: Shape +submodule: Vertex +file: src/core/shape/vertex.js +description: > +

Sets the normal vector for vertices in a custom 3D shape.

+ +

3D shapes created with beginShape() + and + + endShape() are made by connecting sets + of + + points called vertices. Each vertex added with + + vertex() has a normal vector that points + away + + from it. The normal vector controls how light reflects off the shape.

+ +

normal() can be called two ways with different parameters to + define the + + normal vector's components.

+ +

The first way to call normal() has three parameters, + x, y, and z. + + If Numbers are passed, as in normal(1, 2, 3), they + set the x-, y-, and + + z-components of the normal vector.

+ +

The second way to call normal() has one parameter, + vector. If a + + p5.Vector object is passed, as in + + normal(myVector), its components will be used to set the normal + vector.

+ +

normal() changes the normal vector of vertices added to a + custom shape + + with vertex(). normal() must + be called between + + the beginShape() and + + endShape() functions, just like + + vertex(). The normal vector set by calling + + normal() will affect all following vertices until + normal() is called + + again:

+ +
beginShape();
+
+
+  // Set the vertex normal.
+
+  normal(-0.4, -0.4, 0.8);
+
+
+  // Add a vertex.
+
+  vertex(-30, -30, 0);
+
+
+  // Set the vertex normal.
+
+  normal(0, 0, 1);
+
+
+  // Add vertices.
+
+  vertex(30, -30, 0);
+
+  vertex(30, 30, 0);
+
+
+  // Set the vertex normal.
+
+  normal(0.4, -0.4, 0.8);
+
+
+  // Add a vertex.
+
+  vertex(-30, 30, 0);
+
+
+  endShape();
+
+  
+line: 2097 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click the and drag the mouse to view the scene from a different angle. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'A colorful square on a black background. The square changes color and rotates when the user drags the mouse. Parts of its surface reflect light in different directions.' + ); + } + + function draw() { + background(0); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the shape. + normalMaterial(); + noStroke(); + + // Draw the shape. + beginShape(); + vertex(-30, -30, 0); + vertex(30, -30, 0); + vertex(30, 30, 0); + vertex(-30, 30, 0); + endShape(); + } + +
+ +
+ + // Click the and drag the mouse to view the scene from a different angle. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'A colorful square on a black background. The square changes color and rotates when the user drags the mouse. Parts of its surface reflect light in different directions.' + ); + } + + function draw() { + background(0); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the shape. + normalMaterial(); + noStroke(); + + // Draw the shape. + // Use normal() to set vertex normals. + beginShape(); + normal(-0.4, -0.4, 0.8); + vertex(-30, -30, 0); + + normal(0, 0, 1); + vertex(30, -30, 0); + vertex(30, 30, 0); + + normal(0.4, -0.4, 0.8); + vertex(-30, 30, 0); + endShape(); + } + +
+ +
+ + // Click the and drag the mouse to view the scene from a different angle. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'A colorful square on a black background. The square changes color and rotates when the user drags the mouse. Parts of its surface reflect light in different directions.' + ); + } + + function draw() { + background(0); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the shape. + normalMaterial(); + noStroke(); + + // Create p5.Vector objects. + let n1 = createVector(-0.4, -0.4, 0.8); + let n2 = createVector(0, 0, 1); + let n3 = createVector(0.4, -0.4, 0.8); + + // Draw the shape. + // Use normal() to set vertex normals. + beginShape(); + normal(n1); + vertex(-30, -30, 0); + + normal(n2); + vertex(30, -30, 0); + vertex(30, 30, 0); + + normal(n3); + vertex(-30, 30, 0); + endShape(); + } + +
+class: p5 +overloads: + - line: 2097 + params: + - name: vector + description: | +

vertex normal as a p5.Vector object.

+ type: p5.Vector + chainable: 1 + - line: 2272 + params: + - name: x + description: | +

x-component of the vertex normal.

+ type: Number + - name: 'y' + description: | +

y-component of the vertex normal.

+ type: Number + - name: z + description: | +

z-component of the vertex normal.

+ type: Number + chainable: 1 +chainable: true +--- + + +# normal diff --git a/src/content/reference/en/p5 copy/normalMaterial.mdx b/src/content/reference/en/p5 copy/normalMaterial.mdx new file mode 100644 index 0000000000..0652b349d4 --- /dev/null +++ b/src/content/reference/en/p5 copy/normalMaterial.mdx @@ -0,0 +1,55 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2365 +title: normalMaterial +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Sets the current material as a normal material.

+ +

A normal material sets surfaces facing the x-axis to red, those facing the + + y-axis to green, and those facing the z-axis to blue. Normal material isn't + + affected by light. It’s often used as a placeholder material when + debugging.

+ +

Note: normalMaterial() can only be used in WebGL mode.

+line: 2365 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A multicolor torus drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the torus. + normalMaterial(); + + // Draw the torus. + torus(30); + } + +
+class: p5 +chainable: true +--- + + +# normalMaterial diff --git a/src/content/reference/en/p5 copy/orbitControl.mdx b/src/content/reference/en/p5 copy/orbitControl.mdx new file mode 100644 index 0000000000..be2fd25452 --- /dev/null +++ b/src/content/reference/en/p5 copy/orbitControl.mdx @@ -0,0 +1,203 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/interaction.js#L11 +title: orbitControl +module: 3D +submodule: Interaction +file: src/webgl/interaction.js +description: > +

Allows the user to orbit around a 3D sketch using a mouse, trackpad, or + + touchscreen.

+ +

3D sketches are viewed through an imaginary camera. Calling + + orbitControl() within the draw() function allows + + the user to change the camera’s position:

+ +
function draw() {
+    background(200);
+
+    // Enable orbiting with the mouse.
+    orbitControl();
+
+    // Rest of sketch.
+  }
+
+  
+ +

Left-clicking and dragging or swipe motion will rotate the camera position + + about the center of the sketch. Right-clicking and dragging or multi-swipe + + will pan the camera position without rotation. Using the mouse wheel + + (scrolling) or pinch in/out will move the camera further or closer from the + + center of the sketch.

+ +

The first three parameters, sensitivityX, + sensitivityY, and + + sensitivityZ, are optional. They’re numbers that set the sketch’s + + sensitivity to movement along each axis. For example, calling + + orbitControl(1, 2, -1) keeps movement along the x-axis at its + default + + value, makes the sketch twice as sensitive to movement along the y-axis, + + and reverses motion along the z-axis. By default, all sensitivity values + + are 1.

+ +

The fourth parameter, options, is also optional. It’s an + object that + + changes the behavior of orbiting. For example, calling + + orbitControl(1, 1, 1, options) keeps the default sensitivity + values while + + changing the behaviors set with options. The object can have the + + following properties:

+ +
let options = {
+    // Setting this to false makes mobile interactions smoother by
+    // preventing accidental interactions with the page while orbiting.
+    // By default, it's true.
+    disableTouchActions: true,
+
+    // Setting this to true makes the camera always rotate in the
+    // direction the mouse/touch is moving.
+    // By default, it's false.
+    freeRotation: false
+  };
+
+
+  orbitControl(1, 1, 1, options);
+
+  
+line: 11 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A multicolor box on a gray background. The camera angle changes when the user interacts using a mouse, trackpad, or touchscreen.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the box. + normalMaterial(); + + // Draw the box. + box(30, 50); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A multicolor box on a gray background. The camera angle changes when the user interacts using a mouse, trackpad, or touchscreen.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + // Make the interactions 3X sensitive. + orbitControl(3, 3, 3); + + // Style the box. + normalMaterial(); + + // Draw the box. + box(30, 50); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A multicolor box on a gray background. The camera angle changes when the user interacts using a mouse, trackpad, or touchscreen.'); + } + + function draw() { + background(200); + + // Create an options object. + let options = { + disableTouchActions: false, + freeRotation: true + }; + + // Enable orbiting with the mouse. + // Prevent accidental touch actions on touchscreen devices + // and enable free rotation. + orbitControl(1, 1, 1, options); + + // Style the box. + normalMaterial(); + + // Draw the box. + box(30, 50); + } + +
+class: p5 +params: + - name: sensitivityX + description: | +

sensitivity to movement along the x-axis. Defaults to 1.

+ type: Number + optional: true + - name: sensitivityY + description: | +

sensitivity to movement along the y-axis. Defaults to 1.

+ type: Number + optional: true + - name: sensitivityZ + description: | +

sensitivity to movement along the z-axis. Defaults to 1.

+ type: Number + optional: true + - name: options + description: | +

object with two optional properties, disableTouchActions + and freeRotation. Both are Booleans. disableTouchActions + defaults to true and freeRotation defaults to false.

+ type: Object + optional: true +chainable: true +--- + + +# orbitControl diff --git a/src/content/reference/en/p5 copy/ortho.mdx b/src/content/reference/en/p5 copy/ortho.mdx new file mode 100644 index 0000000000..5fb384ba48 --- /dev/null +++ b/src/content/reference/en/p5 copy/ortho.mdx @@ -0,0 +1,168 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L412 +title: ortho +module: 3D +submodule: Camera +file: src/webgl/p5.Camera.js +description: > +

Sets an orthographic projection for the current camera in a 3D sketch.

+ +

In an orthographic projection, shapes with the same size always appear the + + same size, regardless of whether they are near or far from the camera.

+ +

ortho() changes the camera’s perspective by changing its + viewing frustum + + from a truncated pyramid to a rectangular prism. The camera is placed in + + front of the frustum and views everything between the frustum’s near plane + + and its far plane. ortho() has six optional parameters to define + the + + frustum.

+ +

The first four parameters, left, right, + bottom, and top, set the + + coordinates of the frustum’s sides, bottom, and top. For example, calling + + ortho(-100, 100, 200, -200) creates a frustum that’s 200 pixels + wide and + + 400 pixels tall. By default, these coordinates are set based on the + + sketch’s width and height, as in + + ortho(-width / 2, width / 2, -height / 2, height / 2).

+ +

The last two parameters, near and far, set the + distance of the + + frustum’s near and far plane from the camera. For example, calling + + ortho(-100, 100, 200, 200, 50, 1000) creates a frustum that’s 200 + pixels + + wide, 400 pixels tall, starts 50 pixels from the camera, and ends 1,000 + + pixels from the camera. By default, near and far are + set to 0 and + + max(width, height) + 800, respectively.

+ +

Note: ortho() can only be used in WebGL mode.

+line: 412 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A row of tiny, white cubes on a gray background. All the cubes appear the same size.'); + } + + function draw() { + background(200); + + // Apply an orthographic projection. + ortho(); + + // Translate the origin toward the camera. + translate(-10, 10, 600); + + // Rotate the coordinate system. + rotateY(-0.1); + rotateX(-0.1); + + // Draw the row of boxes. + for (let i = 0; i < 6; i += 1) { + translate(0, 0, -40); + box(10); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Apply an orthographic projection. + // Center the frustum. + // Set its width and height to 20. + // Place its near plane 300 pixels from the camera. + // Place its far plane 350 pixels from the camera. + ortho(-10, 10, -10, 10, 300, 350); + + // Translate the origin toward the camera. + translate(-10, 10, 600); + + // Rotate the coordinate system. + rotateY(-0.1); + rotateX(-0.1); + + // Draw the row of boxes. + for (let i = 0; i < 6; i += 1) { + translate(0, 0, -40); + box(10); + } + } + +
+class: p5 +params: + - name: left + description: > +

x-coordinate of the frustum’s left plane. Defaults to -width / + 2.

+ type: Number + optional: true + - name: right + description: > +

x-coordinate of the frustum’s right plane. Defaults to width / + 2.

+ type: Number + optional: true + - name: bottom + description: > +

y-coordinate of the frustum’s bottom plane. Defaults to height / + 2.

+ type: Number + optional: true + - name: top + description: > +

y-coordinate of the frustum’s top plane. Defaults to -height / + 2.

+ type: Number + optional: true + - name: near + description: | +

z-coordinate of the frustum’s near plane. Defaults to 0.

+ type: Number + optional: true + - name: far + description: > +

z-coordinate of the frustum’s far plane. Defaults to max(width, + height) + 800.

+ type: Number + optional: true +chainable: true +--- + + +# ortho diff --git a/src/content/reference/en/p5 copy/outputVolume.mdx b/src/content/reference/en/p5 copy/outputVolume.mdx new file mode 100644 index 0000000000..fe618922fb --- /dev/null +++ b/src/content/reference/en/p5 copy/outputVolume.mdx @@ -0,0 +1,51 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L738 +title: outputVolume +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: |- +

Scale the output of all sound in this sketch

+ Scaled between 0.0 (silence) and 1.0 (full volume). + 1.0 is the maximum amplitude of a digital sound, so multiplying + by greater than 1.0 may cause digital distortion. To + fade, provide a rampTime parameter. For more + complex fades, see the Envelope class. + +

Alternately, you can pass in a signal source such as an + oscillator to modulate the amplitude with an audio signal.

+

How This Works: When you load the p5.sound module, it + creates a single instance of p5sound. All sound objects in this + module output to p5sound before reaching your computer's output. + So if you change the amplitude of p5sound, it impacts all of the + sound in this module.

+ +

If no value is provided, returns a Web Audio API Gain Node

+line: 738 +isConstructor: false +itemtype: method +class: p5 +params: + - name: volume + description: | +

Volume (amplitude) between 0.0 + and 1.0 or modulating signal/oscillator

+ type: Number|Object + - name: rampTime + description: | +

Fade for t seconds

+ type: Number + optional: true + - name: timeFromNow + description: | +

Schedule this event to happen at + t seconds in the future

+ type: Number + optional: true +chainable: false +--- + + +# outputVolume diff --git a/src/content/reference/en/p5 copy/p5.Camera.mdx b/src/content/reference/en/p5 copy/p5.Camera.mdx new file mode 100644 index 0000000000..cc2090e329 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Camera.mdx @@ -0,0 +1,659 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L723 +title: p5.Camera +module: 3D +submodule: Camera +file: src/webgl/p5.Camera.js +description: > +

A class to describe a camera for viewing a 3D sketch.

+ +

Each p5.Camera object represents a camera that views a section + of 3D + + space. It stores information about the camera’s position, orientation, and + + projection.

+ +

In WebGL mode, the default camera is a p5.Camera object that + can be + + controlled with the camera(), + + perspective(), + + ortho(), and + + frustum() functions. Additional cameras + can be + + created with createCamera() and + activated + + with setCamera().

+ +

Note: p5.Camera’s methods operate in two coordinate + systems:

+ +
    + +
  • The “world” coordinate system describes positions in terms of their + + relationship to the origin along the x-, y-, and z-axes. For example, + + calling myCamera.setPosition() places the camera in 3D space + using + + "world" coordinates.
  • + +
  • The "local" coordinate system describes positions from the camera's point + + of view: left-right, up-down, and forward-backward. For example, calling + + myCamera.move() moves the camera along its own axes.
  • + +
+line: 723 +isConstructor: true +params: + - name: rendererGL + description: | +

instance of WebGL renderer

+ type: RendererGL +example: + - |- + +
+ + let cam; + let delta = 0.001; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Camera object. + cam = createCamera(); + + // Place the camera at the top-center. + cam.setPosition(0, -400, 800); + + // Point the camera at the origin. + cam.lookAt(0, 0, 0); + + describe( + 'A white cube on a gray background. The cube goes in and out of view as the camera pans left and right.' + ); + } + + function draw() { + background(200); + + // Turn the camera left and right, called "panning". + cam.pan(delta); + + // Switch directions every 120 frames. + if (frameCount % 120 === 0) { + delta *= -1; + } + + // Draw the box. + box(); + } + +
+ +
+ + // Double-click to toggle between cameras. + + let cam1; + let cam2; + let isDefaultCamera = true; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the first camera. + // Keep its default settings. + cam1 = createCamera(); + + // Create the second camera. + // Place it at the top-left. + // Point it at the origin. + cam2 = createCamera(); + cam2.setPosition(400, -400, 800); + cam2.lookAt(0, 0, 0); + + // Set the current camera to cam1. + setCamera(cam1); + + describe( + 'A white cube on a gray background. The camera toggles between frontal and aerial views when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Draw the box. + box(); + } + + // Toggle the current camera when the user double-clicks. + function doubleClicked() { + if (isDefaultCamera === true) { + setCamera(cam2); + isDefaultCamera = false; + } else { + setCamera(cam1); + isDefaultCamera = true; + } + } + +
+methods: + perspective: + description: > +

Sets a perspective projection for the camera.

+ +

In a perspective projection, shapes that are further from the camera + appear + + smaller than shapes that are near the camera. This technique, called + + foreshortening, creates realistic 3D scenes. It’s applied by default in + new + + p5.Camera objects.

+ +

myCamera.perspective() changes the camera’s perspective by + changing its + + viewing frustum. The frustum is the volume of space that’s visible to the + + camera. The frustum’s shape is a pyramid with its top cut off. The camera + + is placed where the top of the pyramid should be and points towards the + + base of the pyramid. It views everything within the frustum.

+ +

The first parameter, fovy, is the camera’s vertical field + of view. It’s + + an angle that describes how tall or narrow a view the camera has. For + + example, calling myCamera.perspective(0.5) sets the camera’s + vertical + + field of view to 0.5 radians. By default, fovy is calculated + based on the + + sketch’s height and the camera’s default z-coordinate, which is 800. The + + formula for the default fovy is 2 * atan(height / 2 / + 800).

+ +

The second parameter, aspect, is the camera’s aspect + ratio. It’s a number + + that describes the ratio of the top plane’s width to its height. For + + example, calling myCamera.perspective(0.5, 1.5) sets the + camera’s field + + of view to 0.5 radians and aspect ratio to 1.5, which would make shapes + + appear thinner on a square canvas. By default, aspect is set + to + + width / height.

+ +

The third parameter, near, is the distance from the camera + to the near + + plane. For example, calling myCamera.perspective(0.5, 1.5, + 100) sets the + + camera’s field of view to 0.5 radians, its aspect ratio to 1.5, and places + + the near plane 100 pixels from the camera. Any shapes drawn less than 100 + + pixels from the camera won’t be visible. By default, near is + set to + + 0.1 * 800, which is 1/10th the default distance between the + camera and + + the origin.

+ +

The fourth parameter, far, is the distance from the camera + to the far + + plane. For example, calling myCamera.perspective(0.5, 1.5, 100, + 10000) + + sets the camera’s field of view to 0.5 radians, its aspect ratio to 1.5, + + places the near plane 100 pixels from the camera, and places the far plane + + 10,000 pixels from the camera. Any shapes drawn more than 10,000 pixels + + from the camera won’t be visible. By default, far is set to + 10 * 800, + + which is 10 times the default distance between the camera and the + origin.

+ path: p5.Camera/perspective + ortho: + description: > +

Sets an orthographic projection for the camera.

+ +

In an orthographic projection, shapes with the same size always appear + the + + same size, regardless of whether they are near or far from the camera.

+ +

myCamera.ortho() changes the camera’s perspective by + changing its viewing + + frustum from a truncated pyramid to a rectangular prism. The frustum is + the + + volume of space that’s visible to the camera. The camera is placed in + front + + of the frustum and views everything within the frustum. + myCamera.ortho() + + has six optional parameters to define the viewing frustum.

+ +

The first four parameters, left, right, + bottom, and top, set the + + coordinates of the frustum’s sides, bottom, and top. For example, calling + + myCamera.ortho(-100, 100, 200, -200) creates a frustum that’s + 200 pixels + + wide and 400 pixels tall. By default, these dimensions are set based on + + the sketch’s width and height, as in + + myCamera.ortho(-width / 2, width / 2, -height / 2, height / + 2).

+ +

The last two parameters, near and far, set + the distance of the + + frustum’s near and far plane from the camera. For example, calling + + myCamera.ortho(-100, 100, 200, -200, 50, 1000) creates a + frustum that’s + + 200 pixels wide, 400 pixels tall, starts 50 pixels from the camera, and + + ends 1,000 pixels from the camera. By default, near and + far are set to + + 0 and max(width, height) + 800, respectively.

+ path: p5.Camera/ortho + frustum: + description: > +

Sets the camera's frustum.

+ +

In a frustum projection, shapes that are further from the camera appear + + smaller than shapes that are near the camera. This technique, called + + foreshortening, creates realistic 3D scenes.

+ +

myCamera.frustum() changes the camera’s perspective by + changing its + + viewing frustum. The frustum is the volume of space that’s visible to the + + camera. The frustum’s shape is a pyramid with its top cut off. The camera + + is placed where the top of the pyramid should be and points towards the + + base of the pyramid. It views everything within the frustum.

+ +

The first four parameters, left, right, + bottom, and top, set the + + coordinates of the frustum’s sides, bottom, and top. For example, calling + + myCamera.frustum(-100, 100, 200, -200) creates a frustum + that’s 200 + + pixels wide and 400 pixels tall. By default, these coordinates are set + + based on the sketch’s width and height, as in + + myCamera.frustum(-width / 20, width / 20, height / 20, -height / + 20).

+ +

The last two parameters, near and far, set + the distance of the + + frustum’s near and far plane from the camera. For example, calling + + myCamera.frustum(-100, 100, 200, -200, 50, 1000) creates a + frustum that’s + + 200 pixels wide, 400 pixels tall, starts 50 pixels from the camera, and + ends + + 1,000 pixels from the camera. By default, near is set to 0.1 * + 800, which + + is 1/10th the default distance between the camera and the origin. + far is + + set to 10 * 800, which is 10 times the default distance + between the + + camera and the origin.

+ path: p5.Camera/frustum + roll: + description: > +

Rotates the camera in a clockwise/counter-clockwise direction.

+ +

Rolling rotates the camera without changing its orientation. The + rotation + + happens in the camera’s "local" space.

+ +

The parameter, angle, is the angle the camera should + rotate. Passing a + + positive angle, as in myCamera.roll(0.001), rotates the + camera in counter-clockwise direction. + + Passing a negative angle, as in myCamera.roll(-0.001), + rotates the + + camera in clockwise direction.

+ +

Note: Angles are interpreted based on the current + + angleMode().

+ path: p5.Camera/roll + pan: + description: > +

Rotates the camera left and right.

+ +

Panning rotates the camera without changing its position. The rotation + + happens in the camera’s "local" space.

+ +

The parameter, angle, is the angle the camera should + rotate. Passing a + + positive angle, as in myCamera.pan(0.001), rotates the camera + to the + + right. Passing a negative angle, as in myCamera.pan(-0.001), + rotates the + + camera to the left.

+ +

Note: Angles are interpreted based on the current + + angleMode().

+ path: p5.Camera/pan + tilt: + description: > +

Rotates the camera up and down.

+ +

Tilting rotates the camera without changing its position. The rotation + + happens in the camera’s "local" space.

+ +

The parameter, angle, is the angle the camera should + rotate. Passing a + + positive angle, as in myCamera.tilt(0.001), rotates the + camera down. + + Passing a negative angle, as in myCamera.tilt(-0.001), + rotates the camera + + up.

+ +

Note: Angles are interpreted based on the current + + angleMode().

+ path: p5.Camera/tilt + lookAt: + description: > +

Points the camera at a location.

+ +

myCamera.lookAt() changes the camera’s orientation without + changing its + + position.

+ +

The parameters, x, y, and z, are + the coordinates in "world" space + + where the camera should point. For example, calling + + myCamera.lookAt(10, 20, 30) points the camera at the + coordinates + + (10, 20, 30).

+ path: p5.Camera/lookAt + camera: + description: > +

Sets the position and orientation of the camera.

+ +

myCamera.camera() allows objects to be viewed from + different angles. It + + has nine parameters that are all optional.

+ +

The first three parameters, x, y, and + z, are the coordinates of the + + camera’s position in "world" space. For example, calling + + myCamera.camera(0, 0, 0) places the camera at the origin + (0, 0, 0). By + + default, the camera is placed at (0, 0, 800).

+ +

The next three parameters, centerX, centerY, + and centerZ are the + + coordinates of the point where the camera faces in "world" space. For + + example, calling myCamera.camera(0, 0, 0, 10, 20, 30) places + the camera + + at the origin (0, 0, 0) and points it at (10, 20, + 30). By default, the + + camera points at the origin (0, 0, 0).

+ +

The last three parameters, upX, upY, and + upZ are the components of + + the "up" vector in "local" space. The "up" vector orients the camera’s + + y-axis. For example, calling + + myCamera.camera(0, 0, 0, 10, 20, 30, 0, -1, 0) places the + camera at the + + origin (0, 0, 0), points it at (10, 20, 30), and + sets the "up" vector + + to (0, -1, 0) which is like holding it upside-down. By + default, the "up" + + vector is (0, 1, 0).

+ path: p5.Camera/camera + move: + description: > +

Moves the camera along its "local" axes without changing its + orientation.

+ +

The parameters, x, y, and z, are + the distances the camera should + + move. For example, calling myCamera.move(10, 20, 30) moves + the camera 10 + + pixels to the right, 20 pixels down, and 30 pixels backward in its "local" + + space.

+ path: p5.Camera/move + setPosition: + description: > +

Sets the camera’s position in "world" space without changing its + + orientation.

+ +

The parameters, x, y, and z, are + the coordinates where the camera + + should be placed. For example, calling myCamera.setPosition(10, 20, + 30) + + places the camera at coordinates (10, 20, 30) in "world" + space.

+ path: p5.Camera/setPosition + set: + description: > +

Sets the camera’s position, orientation, and projection by copying + another + + camera.

+ +

The parameter, cam, is the p5.Camera object + to copy. For example, calling + + cam2.set(cam1) will set cam2 using + cam1’s configuration.

+ path: p5.Camera/set + slerp: + description: > +

Sets the camera’s position and orientation to values that are + in-between + + those of two other cameras.

+ +

myCamera.slerp() uses spherical linear interpolation to + calculate a + + position and orientation that’s in-between two other cameras. Doing so is + + helpful for transitioning smoothly between two perspectives.

+ +

The first two parameters, cam0 and cam1, are + the p5.Camera objects + + that should be used to set the current camera.

+ +

The third parameter, amt, is the amount to interpolate + between cam0 and + + cam1. 0.0 keeps the camera’s position and orientation equal + to cam0’s, + + 0.5 sets them halfway between cam0’s and cam1’s + , and 1.0 sets the + + position and orientation equal to cam1’s.

+ +

For example, calling myCamera.slerp(cam0, cam1, 0.1) sets + cam’s position + + and orientation very close to cam0’s. Calling + + myCamera.slerp(cam0, cam1, 0.9) sets cam’s position and + orientation very + + close to cam1’s.

+ +

Note: All of the cameras must use the same projection.

+ path: p5.Camera/slerp +properties: + eyeX: + description: | +

The camera’s x-coordinate.

+

By default, the camera’s x-coordinate is set to 0 in "world" space.

+ path: p5.Camera/eyeX + eyeY: + description: | +

The camera’s y-coordinate.

+

By default, the camera’s y-coordinate is set to 0 in "world" space.

+ path: p5.Camera/eyeY + eyeZ: + description: > +

The camera’s z-coordinate.

+ +

By default, the camera’s z-coordinate is set to 800 in "world" + space.

+ path: p5.Camera/eyeZ + centerX: + description: > +

The x-coordinate of the place where the camera looks.

+ +

By default, the camera looks at the origin (0, 0, 0) in + "world" space, so + + myCamera.centerX is 0.

+ path: p5.Camera/centerX + centerY: + description: > +

The y-coordinate of the place where the camera looks.

+ +

By default, the camera looks at the origin (0, 0, 0) in + "world" space, so + + myCamera.centerY is 0.

+ path: p5.Camera/centerY + centerZ: + description: > +

The y-coordinate of the place where the camera looks.

+ +

By default, the camera looks at the origin (0, 0, 0) in + "world" space, so + + myCamera.centerZ is 0.

+ path: p5.Camera/centerZ + upX: + description: > +

The x-component of the camera's "up" vector.

+ +

The camera's "up" vector orients its y-axis. By default, the "up" + vector is + + (0, 1, 0), so its x-component is 0 in "local" space.

+ path: p5.Camera/upX + upY: + description: > +

The y-component of the camera's "up" vector.

+ +

The camera's "up" vector orients its y-axis. By default, the "up" + vector is + + (0, 1, 0), so its y-component is 1 in "local" space.

+ path: p5.Camera/upY + upZ: + description: > +

The z-component of the camera's "up" vector.

+ +

The camera's "up" vector orients its y-axis. By default, the "up" + vector is + + (0, 1, 0), so its z-component is 0 in "local" space.

+ path: p5.Camera/upZ +chainable: false +--- + + +# p5.Camera diff --git a/src/content/reference/en/p5 copy/p5.Color.mdx b/src/content/reference/en/p5 copy/p5.Color.mdx new file mode 100644 index 0000000000..b804e5ee95 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Color.mdx @@ -0,0 +1,116 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/p5.Color.js#L318 +title: p5.Color +module: Color +submodule: Creating & Reading +file: src/color/p5.Color.js +description: > +

A class to describe a color.

+ +

Each p5.Color object stores the color mode + + and level maxes that were active during its construction. These values are + + used to interpret the arguments passed to the object's constructor. They + + also determine output formatting such as when + + saturation() is called.

+ +

Color is stored internally as an array of ideal RGBA values in floating + + point form, normalized from 0 to 1. These values are used to calculate the + + closest screen colors, which are RGBA levels from 0 to 255. Screen colors + + are sent to the renderer.

+ +

When different color representations are calculated, the results are cached + + for performance. These values are normalized, floating-point numbers.

+ +

Note: color() is the recommended way to + create an + + instance of this class.

+line: 318 +isConstructor: true +params: + - name: pInst + description: | +

pointer to p5 instance.

+ type: P5 + optional: true + - name: vals + description: | +

an array containing the color values + for red, green, blue and alpha channel + or CSS color.

+ type: 'Number[]|String' +methods: + toString: + description: > +

Returns the color formatted as a String.

+ +

Calling myColor.toString() can be useful for debugging, as + in + + print(myColor.toString()). It's also helpful for using p5.js + with other + + libraries.

+ +

The parameter, format, is optional. If a format string is + passed, as in + + myColor.toString('#rrggbb'), it will determine how the color + string is + + formatted. By default, color strings are formatted as 'rgba(r, g, b, + a)'.

+ path: p5.Color/toString + setRed: + description: > +

Sets the red component of a color.

+ +

The range depends on the colorMode(). In the + + default RGB mode it's between 0 and 255.

+ path: p5.Color/setRed + setGreen: + description: > +

Sets the green component of a color.

+ +

The range depends on the colorMode(). In the + + default RGB mode it's between 0 and 255.

+ path: p5.Color/setGreen + setBlue: + description: > +

Sets the blue component of a color.

+ +

The range depends on the colorMode(). In the + + default RGB mode it's between 0 and 255.

+ path: p5.Color/setBlue + setAlpha: + description: > +

Sets the alpha (transparency) value of a color.

+ +

The range depends on the + + colorMode(). In the default RGB + mode it's + + between 0 and 255.

+ path: p5.Color/setAlpha +chainable: false +--- + + +# p5.Color diff --git a/src/content/reference/en/p5 copy/p5.Element.mdx b/src/content/reference/en/p5 copy/p5.Element.mdx new file mode 100644 index 0000000000..c07b10ae79 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Element.mdx @@ -0,0 +1,545 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/p5.Element.js#L9 +title: p5.Element +module: DOM +submodule: DOM +file: src/core/p5.Element.js +description: > +

A class to describe an + + HTML element.

+ +

Sketches can use many elements. Common elements include the drawing canvas, + + buttons, sliders, webcam feeds, and so on.

+ +

All elements share the methods of the p5.Element class. + They're created + + with functions such as createCanvas() and + + createButton().

+line: 9 +isConstructor: true +params: + - name: elt + description: | +

wrapped DOM element.

+ type: HTMLElement + - name: pInst + description: | +

pointer to p5 instance.

+ type: P5 + optional: true +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a button element and + // place it beneath the canvas. + let btn = createButton('change'); + btn.position(0, 100); + + // Call randomColor() when + // the button is pressed. + btn.mousePressed(randomColor); + + describe('A gray square with a button that says "change" beneath it. The square changes color when the user presses the button.'); + } + + // Paint the background either + // red, yellow, blue, or green. + function randomColor() { + let c = random(['red', 'yellow', 'blue', 'green']); + background(c); + } + +
+methods: + parent: + description: > +

Attaches the element to a parent element.

+ +

For example, a

element may be used as a box to + + hold two pieces of text, a header and a paragraph. The + +
is the parent element of both the header and + + paragraph.

+ +

The parameter parent can have one of three types. + parent can be a + + string with the parent element's ID, as in + + myElement.parent('container'). It can also be another + + p5.Element object, as in + + myElement.parent(myDiv). Finally, parent can be + an HTMLElement + + object, as in myElement.parent(anotherElement).

+ +

Calling myElement.parent() without an argument returns the + element's + + parent.

+ path: p5.Element/parent + id: + description: > +

Sets the element's ID using a given string.

+ +

Calling myElement.id() without an argument returns its ID + as a string.

+ path: p5.Element/id + class: + description: > +

Adds a + + class attribute + + to the element using a given string.

+ +

Calling myElement.class() without an argument returns a + string with its current classes.

+ path: p5.Element/class + mousePressed: + description: > +

Calls a function when the mouse is pressed over the element.

+ +

Calling myElement.mousePressed(false) disables the + function.

+ +

Note: Some mobile browsers may also trigger this event when the element + + receives a quick tap.

+ path: p5.Element/mousePressed + doubleClicked: + description: > +

Calls a function when the mouse is pressed twice over the element.

+ +

Calling myElement.doubleClicked(false) disables the + function.

+ path: p5.Element/doubleClicked + mouseWheel: + description: > +

Calls a function when the mouse wheel scrolls over the element.

+ +

The callback function, fxn, is passed an + event object. event has + + two numeric properties, deltaY and deltaX. + event.deltaY is + + negative if the mouse wheel rotates away from the user. It's positive if + + the mouse wheel rotates toward the user. event.deltaX is + positive if + + the mouse wheel moves to the right. It's negative if the mouse wheel moves + + to the left.

+ +

Calling myElement.mouseWheel(false) disables the + function.

+ path: p5.Element/mouseWheel + mouseReleased: + description: > +

Calls a function when the mouse is released over the element.

+ +

Calling myElement.mouseReleased(false) disables the + function.

+ +

Note: Some mobile browsers may also trigger this event when the element + + receives a quick tap.

+ path: p5.Element/mouseReleased + mouseClicked: + description: > +

Calls a function when the mouse is pressed and released over the + element.

+ +

Calling myElement.mouseReleased(false) disables the + function.

+ +

Note: Some mobile browsers may also trigger this event when the element + + receives a quick tap.

+ path: p5.Element/mouseClicked + mouseMoved: + description: > +

Calls a function when the mouse moves over the element.

+ +

Calling myElement.mouseMoved(false) disables the + function.

+ path: p5.Element/mouseMoved + mouseOver: + description: > +

Calls a function when the mouse moves onto the element.

+ +

Calling myElement.mouseOver(false) disables the + function.

+ path: p5.Element/mouseOver + mouseOut: + description: > +

Calls a function when the mouse moves off the element.

+ +

Calling myElement.mouseOut(false) disables the + function.

+ path: p5.Element/mouseOut + touchStarted: + description: > +

Calls a function when the element is touched.

+ +

Calling myElement.touchStarted(false) disables the + function.

+ +

Note: Touch functions only work on mobile devices.

+ path: p5.Element/touchStarted + touchMoved: + description: > +

Calls a function when the user touches the element and moves.

+ +

Calling myElement.touchMoved(false) disables the + function.

+ +

Note: Touch functions only work on mobile devices.

+ path: p5.Element/touchMoved + touchEnded: + description: > +

Calls a function when the user stops touching the element.

+ +

Calling myElement.touchMoved(false) disables the + function.

+ +

Note: Touch functions only work on mobile devices.

+ path: p5.Element/touchEnded + dragOver: + description: > +

Calls a function when a file is dragged over the element.

+ +

Calling myElement.dragOver(false) disables the + function.

+ path: p5.Element/dragOver + dragLeave: + description: > +

Calls a function when a file is dragged off the element.

+ +

Calling myElement.dragLeave(false) disables the + function.

+ path: p5.Element/dragLeave + addClass: + description: | +

Adds a class to the element.

+ path: p5.Element/addClass + removeClass: + description: | +

Removes a class from the element.

+ path: p5.Element/removeClass + hasClass: + description: | +

Checks if a class is already applied to element.

+ path: p5.Element/hasClass + toggleClass: + description: | +

Toggles whether a class is applied to the element.

+ path: p5.Element/toggleClass + child: + description: > +

Attaches the element as a child of another element.

+ +

myElement.child() accepts either a string ID, DOM node, or + + p5.Element. For example, + + myElement.child(otherElement). If no argument is provided, an + array of + + children DOM nodes is returned.

+ path: p5.Element/child + center: + description: > +

Centers the element either vertically, horizontally, or both.

+ +

center() will center the element relative to its parent or + according to + + the page's body if the element has no parent.

+ +

If no argument is passed, as in myElement.center() the + element is aligned + + both vertically and horizontally.

+ path: p5.Element/center + html: + description: > +

Sets the inner HTML of the element, replacing any existing HTML.

+ +

The second parameter, append, is optional. If + true is passed, as in + + myElement.html('hi', true), the HTML is appended instead of + replacing + + existing HTML.

+ +

If no arguments are passed, as in myElement.html(), the + element's inner + + HTML is returned.

+ path: p5.Element/html + position: + description: > +

Sets the element's position.

+ +

The first two parameters, x and y, set the + element's position relative + + to the top-left corner of the web page.

+ +

The third parameter, positionType, is optional. It sets + the element's + + positioning + scheme. + + positionType is a string that can be either + 'static', 'fixed', + + 'relative', 'sticky', 'initial', or + 'inherit'.

+ +

If no arguments passed, as in myElement.position(), the + method returns + + the element's position in an object, as in { x: 0, y: 0 + }.

+ path: p5.Element/position + style: + description: > +

Applies a style to the element by adding a + + CSS declaration.

+ +

The first parameter, property, is a string. If the name of + a style + + property is passed, as in myElement.style('color'), the + method returns + + the current value as a string or null if it hasn't been set. + If a + + property:style string is passed, as in + + myElement.style('color:deeppink'), the method sets the style + property + + to value.

+ +

The second parameter, value, is optional. It sets the + property's value. + + value can be a string, as in + + myElement.style('color', 'deeppink'), or a + + p5.Color object, as in + + myElement.style('color', myColor).

+ path: p5.Element/style + attribute: + description: > +

Adds an + + attribute + + to the element.

+ +

This method is useful for advanced tasks. Most commonly-used + attributes, + + such as id, can be set with their dedicated methods. For + example, + + nextButton.id('next') sets an element's id + attribute. Calling + + nextButton.attribute('id', 'next') has the same effect.

+ +

The first parameter, attr, is the attribute's name as a + string. Calling + + myElement.attribute('align') returns the attribute's current + value as a + + string or null if it hasn't been set.

+ +

The second parameter, value, is optional. It's a string + used to set the + + attribute's value. For example, calling + + myElement.attribute('align', 'center') sets the element's + horizontal + + alignment to center.

+ path: p5.Element/attribute + removeAttribute: + description: > +

Removes an attribute from the element.

+ +

The parameter attr is the attribute's name as a string. + For example, + + calling myElement.removeAttribute('align') removes its + align + + attribute if it's been set.

+ path: p5.Element/removeAttribute + value: + description: > +

Returns or sets the element's value.

+ +

Calling myElement.value() returns the element's current + value.

+ +

The parameter, value, is an optional number or string. If + provided, + + as in myElement.value(123), it's used to set the element's + value.

+ path: p5.Element/value + show: + description: | +

Shows the current element.

+ path: p5.Element/show + hide: + description: | +

Hides the current element.

+ path: p5.Element/hide + size: + description: > +

Sets the element's width and height.

+ +

Calling myElement.size() without an argument returns the + element's size + + as an object with the properties width and + height. For example, + { width: 20, height: 10 }.

+

The first parameter, width, is optional. It's a number + used to set the + + element's width. Calling myElement.size(10)

+ +

The second parameter, 'height, is also optional. It's a number + used to set the element's height. For example, calling + myElement.size(20, 10)` sets the element's width to 20 pixels and + height + + to 10 pixels.

+ +

The constant AUTO can be used to adjust one dimension at a + time while + + maintaining the aspect ratio, which is width / height. For + example, + + consider an element that's 200 pixels wide and 100 pixels tall. Calling + + myElement.size(20, AUTO) sets the width to 20 pixels and + height to 10 + + pixels.

+ +

Note: In the case of elements that need to load data, such as images, + wait + + to call myElement.size() until after the data loads.

+ path: p5.Element/size + remove: + description: | +

Removes the element, stops all audio/video streams, and removes all + callback functions.

+ path: p5.Element/remove + drop: + description: > +

Calls a function when the user drops a file on the element.

+ +

The first parameter, callback, is a function to call once + the file loads. + + The callback function should have one parameter, file, that's + a + + p5.File object. If the user drops + multiple files on + + the element, callback, is called once for each file.

+ +

The second parameter, fxn, is a function to call when the + browser detects + + one or more dropped files. The callback function should have one + + parameter, event, that's a + + DragEvent.

+ path: p5.Element/drop + draggable: + description: > +

Makes the element draggable.

+ +

The parameter, elmnt, is optional. If another + + p5.Element object is passed, as in + + myElement.draggable(otherElement), the other element will + become draggable.

+ path: p5.Element/draggable +properties: + elt: + description: > +

The element's underlying HTMLElement object.

+ +

The + + HTMLElement + + object's properties and methods can be used directly.

+ path: p5.Element/elt + width: + description: | +

A Number property that stores the element's width.

+ path: p5.Element/width + height: + description: | +

A Number property that stores the element's height.

+ path: p5.Element/height +chainable: false +--- + + +# p5.Element diff --git a/src/content/reference/en/p5 copy/p5.File.mdx b/src/content/reference/en/p5 copy/p5.File.mdx new file mode 100644 index 0000000000..78675c7a98 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.File.mdx @@ -0,0 +1,153 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L5482 +title: p5.File +module: DOM +submodule: DOM +file: src/dom/dom.js +description: | +

A class to describe a file.

+

p5.File objects are used by + myElement.drop() and + created by + createFileInput.

+line: 5482 +isConstructor: true +params: + - name: file + description: | +

wrapped file.

+ type: File +example: + - |- + +
+ + // Use the file input to load a + // file and display its info. + + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a file input and place it beneath the canvas. + // Call displayInfo() when the file loads. + let input = createFileInput(displayInfo); + input.position(0, 100); + + describe('A gray square with a file input beneath it. If the user loads a file, its info is written in black.'); + } + + // Display the p5.File's info once it loads. + function displayInfo(file) { + background(200); + + // Display the p5.File's name. + text(file.name, 10, 10, 80, 40); + + // Display the p5.File's type and subtype. + text(`${file.type}/${file.subtype}`, 10, 70); + + // Display the p5.File's size in bytes. + text(file.size, 10, 90); + } + +
+ +
+ + // Use the file input to select an image to + // load and display. + let img; + + function setup() { + createCanvas(100, 100); + + // Create a file input and place it beneath the canvas. + // Call handleImage() when the file image loads. + let input = createFileInput(handleImage); + input.position(0, 100); + + describe('A gray square with a file input beneath it. If the user selects an image file to load, it is displayed on the square.'); + } + + function draw() { + background(200); + + // Draw the image if it's ready. + if (img) { + image(img, 0, 0, width, height); + } + } + + // Use the p5.File's data once it loads. + function handleImage(file) { + // Check the p5.File's type. + if (file.type === 'image') { + // Create an image using using the p5.File's data. + img = createImg(file.data, ''); + + // Hide the image element so it doesn't appear twice. + img.hide(); + } else { + img = null; + } + } + +
+properties: + file: + description: > +

Underlying + + File + + object. All File properties and methods are accessible.

+ path: p5.File/file + type: + description: > +

The file + + MIME type + + as a string.

+ +

For example, 'image' and 'text' are both MIME + types.

+ path: p5.File/type + subtype: + description: > +

The file subtype as a string.

+ +

For example, a file with an 'image' + + MIME type + + may have a subtype such as png or jpeg.

+ path: p5.File/subtype + name: + description: | +

The file name as a string.

+ path: p5.File/name + size: + description: | +

The number of bytes in the file.

+ path: p5.File/size + data: + description: | +

A string containing the file's data.

+

Data can be either image data, text contents, or a parsed object in the + case of JSON and p5.XML objects.

+ path: p5.File/data +chainable: false +--- + + +# p5.File diff --git a/src/content/reference/en/p5 copy/p5.Font.mdx b/src/content/reference/en/p5 copy/p5.Font.mdx new file mode 100644 index 0000000000..615d0406ee --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Font.mdx @@ -0,0 +1,146 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/p5.Font.js#L13 +title: p5.Font +module: Typography +submodule: Loading & Displaying +file: src/typography/p5.Font.js +description: | +

A class to describe fonts.

+line: 13 +isConstructor: true +params: + - name: pInst + description: | +

pointer to p5 instance.

+ type: P5 + optional: true +example: + - |- + +
+ + let font; + + function preload() { + // Creates a p5.Font object. + font = loadFont('/assets/inconsolata.otf'); + } + + function setup() { + createCanvas(100, 100); + + // Style the text. + fill('deeppink'); + textFont(font); + textSize(36); + + // Display the text. + text('p5*js', 10, 50); + + describe('The text "p5*js" written in pink on a gray background.'); + } + +
+methods: + textBounds: + description: > +

Returns the bounding box for a string of text written using the + font.

+ +

The bounding box is the smallest rectangle that can contain a string of + + text. font.textBounds() returns an object with the bounding + box's + + location and size. For example, calling font.textBounds('p5*js', 5, + 20) + + returns an object in the format + + { x: 5.7, y: 12.1 , w: 9.9, h: 28.6 }. The x and + y properties are + + always the coordinates of the bounding box's top-left corner.

+ +

The first parameter, str, is a string of text. The second + and third + + parameters, x and y, are the text's position. By + default, they set the + + coordinates of the bounding box's bottom-left corner. See + + textAlign() for more ways to align + text.

+ +

The fourth parameter, fontSize, is optional. It sets the + font size used to + + determine the bounding box. By default, font.textBounds() + will use the + + current textSize().

+ path: p5.Font/textBounds + textToPoints: + description: > +

Returns an array of points outlining a string of text written using the + + font.

+ +

Each point object in the array has three properties that describe the + + point's location and orientation, called its path angle. For example, + + { x: 10, y: 20, alpha: 450 }.

+ +

The first parameter, str, is a string of text. The second + and third + + parameters, x and y, are the text's position. By + default, they set the + + coordinates of the bounding box's bottom-left corner. See + + textAlign() for more ways to align + text.

+ +

The fourth parameter, fontSize, is optional. It sets the + text's font + + size. By default, font.textToPoints() will use the current + + textSize().

+ +

The fifth parameter, options, is also optional. + font.textToPoints() + + expects an object with the following properties:

+ +

sampleFactor is the ratio of the text's path length to the + number of + + samples. It defaults to 0.1. Higher values produce more points along the + + path and are more precise.

+ +

simplifyThreshold removes collinear points if it's set to + a number other + + than 0. The value represents the threshold angle to use when determining + + whether two edges are collinear.

+ path: p5.Font/textToPoints +properties: + font: + description: | +

The font's underlying + opentype.js + font object.

+ path: p5.Font/font +chainable: false +--- + + +# p5.Font diff --git a/src/content/reference/en/p5 copy/p5.Framebuffer.mdx b/src/content/reference/en/p5 copy/p5.Framebuffer.mdx new file mode 100644 index 0000000000..8100f48199 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Framebuffer.mdx @@ -0,0 +1,443 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Framebuffer.js#L76 +title: p5.Framebuffer +module: Rendering +file: src/webgl/p5.Framebuffer.js +description: > +

A class to describe a high-performance drawing surface for textures.

+ +

Each p5.Framebuffer object provides a dedicated drawing + surface called + + a framebuffer. They're similar to + + p5.Graphics objects but can run much + faster. + + Performance is improved because the framebuffer shares the same WebGL + + context as the canvas used to create it.

+ +

p5.Framebuffer objects have all the drawing features of the + main + + canvas. Drawing instructions meant for the framebuffer must be placed + + between calls to + + myBuffer.begin() and + + myBuffer.end(). The resulting + image + + can be applied as a texture by passing the p5.Framebuffer object + to the + + texture() function, as in + texture(myBuffer). + + It can also be displayed on the main canvas by passing it to the + + image() function, as in + image(myBuffer, 0, 0).

+ +

Note: createFramebuffer() is + the + + recommended way to create an instance of this class.

+line: 76 +isConstructor: true +params: + - name: target + description: | +

sketch instance or + p5.Graphics + object.

+ type: p5.Graphics|p5 + - name: settings + description: | +

configuration options.

+ type: Object + optional: true +methods: + resize: + description: > +

Resizes the framebuffer to a given width and height.

+ +

The parameters, width and height, set the + dimensions of the + + framebuffer. For example, calling myBuffer.resize(300, 500) + resizes + + the framebuffer to 300×500 pixels, then sets myBuffer.width + to 300 + + and myBuffer.height 500.

+ path: p5.Framebuffer/resize + pixelDensity: + description: > +

Sets the framebuffer's pixel density or returns its current + density.

+ +

Computer displays are grids of little lights called pixels. A display's + + pixel density describes how many pixels it packs into an area. Displays + + with smaller pixels have a higher pixel density and create sharper + + images.

+ +

The parameter, density, is optional. If a number is + passed, as in + + myBuffer.pixelDensity(1), it sets the framebuffer's pixel + density. By + + default, the framebuffer's pixel density will match that of the canvas + + where it was created. All canvases default to match the display's pixel + + density.

+ +

Calling myBuffer.pixelDensity() without an argument + returns its current + + pixel density.

+ path: p5.Framebuffer/pixelDensity + autoSized: + description: > +

Toggles the framebuffer's autosizing mode or returns the current + mode.

+ +

By default, the framebuffer automatically resizes to match the canvas + + that created it. Calling myBuffer.autoSized(false) disables + this + + behavior and calling myBuffer.autoSized(true) re-enables + it.

+ +

Calling myBuffer.autoSized() without an argument returns + true if + + the framebuffer automatically resizes and false if not.

+ path: p5.Framebuffer/autoSized + createCamera: + description: > +

Creates a new + + p5.Camera object to use with the + framebuffer.

+ +

The new camera is initialized with a default position (0, 0, + 800) and a + + default perspective projection. Its properties can be controlled with + + p5.Camera methods such as + myCamera.lookAt(0, 0, 0).

+ +

Framebuffer cameras should be created between calls to + + myBuffer.begin() and + + myBuffer.end() like so:

+ +
let myCamera;
+
+
+      myBuffer.begin();
+
+
+      // Create the camera for the framebuffer.
+
+      myCamera = myBuffer.createCamera();
+
+
+      myBuffer.end();
+
+      
+ +

Calling setCamera() updates the + + framebuffer's projection using the camera. + + resetMatrix() must also be called + for the + + view to change properly:

+ +
myBuffer.begin();
+
+
+      // Set the camera for the framebuffer.
+
+      setCamera(myCamera);
+
+
+      // Reset all transformations.
+
+      resetMatrix();
+
+
+      // Draw stuff...
+
+
+      myBuffer.end();
+
+      
+ path: p5.Framebuffer/createCamera + remove: + description: > +

Deletes the framebuffer from GPU memory.

+ +

Calling myBuffer.remove() frees the GPU memory used by the + framebuffer. + + The framebuffer also uses a bit of memory on the CPU which can be freed + + like so:

+ +
// Delete the framebuffer from GPU memory.
+
+      myBuffer.remove();
+
+
+      // Delete the framebuffer from CPU memory.
+
+      myBuffer = undefined;
+
+      
+ +

Note: All variables that reference the framebuffer must be assigned + + the value undefined to delete the framebuffer from CPU + memory. If any + + variable still refers to the framebuffer, then it won't be garbage + + collected.

+ path: p5.Framebuffer/remove + begin: + description: > +

Begins drawing shapes to the framebuffer.

+ +

myBuffer.begin() and myBuffer.end() + + allow shapes to be drawn to the framebuffer. myBuffer.begin() + begins + + drawing to the framebuffer and + + myBuffer.end() stops drawing + to the + + framebuffer. Changes won't be visible until the framebuffer is displayed + + as an image or texture.

+ path: p5.Framebuffer/begin + end: + description: > +

Stops drawing shapes to the framebuffer.

+ +

myBuffer.begin() and + myBuffer.end() + + allow shapes to be drawn to the framebuffer. + + myBuffer.begin() begins + drawing to + + the framebuffer and myBuffer.end() stops drawing to the + framebuffer. + + Changes won't be visible until the framebuffer is displayed as an image + + or texture.

+ path: p5.Framebuffer/end + draw: + description: > +

Draws to the framebuffer by calling a function that contains drawing + + instructions.

+ +

The parameter, callback, is a function with the drawing + instructions + + for the framebuffer. For example, calling + myBuffer.draw(myFunction) + + will call a function named myFunction() to draw to the + framebuffer. + + Doing so has the same effect as the following:

+ +
myBuffer.begin();
+
+      myFunction();
+
+      myBuffer.end();
+
+      
+ path: p5.Framebuffer/draw + loadPixels: + description: > +

Loads the current value of each pixel in the framebuffer into its + + pixels array.

+ +

myBuffer.loadPixels() must be called before reading from + or writing to + + myBuffer.pixels.

+ path: p5.Framebuffer/loadPixels + get: + description: > +

Gets a pixel or a region of pixels from the framebuffer.

+ +

myBuffer.get() is easy to use but it's not as fast as + + myBuffer.pixels. Use + + myBuffer.pixels to read + many pixel + + values.

+ +

The version of myBuffer.get() with no parameters returns + the entire + + framebuffer as a a p5.Image + object.

+ +

The version of myBuffer.get() with two parameters + interprets them as + + coordinates. It returns an array with the [R, G, B, A] values + of the + + pixel at the given point.

+ +

The version of myBuffer.get() with four parameters + interprets them as + + coordinates and dimensions. It returns a subsection of the framebuffer as + + a p5.Image object. The first two + parameters are + + the coordinates for the upper-left corner of the subsection. The last two + + parameters are the width and height of the subsection.

+ path: p5.Framebuffer/get + updatePixels: + description: > +

Updates the framebuffer with the RGBA values in the + + pixels array.

+ +

myBuffer.updatePixels() only needs to be called after + changing values + + in the myBuffer.pixels + array. Such + + changes can be made directly after calling + + myBuffer.loadPixels().

+ path: p5.Framebuffer/updatePixels +properties: + pixels: + description: > +

An array containing the color of each pixel in the framebuffer.

+ +

myBuffer.loadPixels() + must be + + called before accessing the myBuffer.pixels array. + + myBuffer.updatePixels() + + must be called after any changes are made.

+ +

Note: Updating pixels via this property is slower than drawing to the + + framebuffer directly. Consider using a + + p5.Shader object instead of looping + over + + myBuffer.pixels.

+ path: p5.Framebuffer/pixels + color: + description: > +

An object that stores the framebuffer's color data.

+ +

Each framebuffer uses a + + WebGLTexture + + object internally to store its color data. The myBuffer.color + property + + makes it possible to pass this data directly to other functions. For + + example, calling texture(myBuffer.color) or + + myShader.setUniform('colorTexture', myBuffer.color) may be + helpful for + + advanced use cases.

+ +

Note: By default, a framebuffer's y-coordinates are flipped compared to + + images and videos. It's easy to flip a framebuffer's y-coordinates as + + needed when applying it as a texture. For example, calling + + plane(myBuffer.width, -myBuffer.height) will flip the + framebuffer.

+ path: p5.Framebuffer/color + depth: + description: > +

An object that stores the framebuffer's depth data.

+ +

Each framebuffer uses a + + WebGLTexture + + object internally to store its depth data. The myBuffer.depth + property + + makes it possible to pass this data directly to other functions. For + + example, calling texture(myBuffer.depth) or + + myShader.setUniform('depthTexture', myBuffer.depth) may be + helpful for + + advanced use cases.

+ +

Note: By default, a framebuffer's y-coordinates are flipped compared to + + images and videos. It's easy to flip a framebuffer's y-coordinates as + + needed when applying it as a texture. For example, calling + + plane(myBuffer.width, -myBuffer.height) will flip the + framebuffer.

+ path: p5.Framebuffer/depth +chainable: false +--- + + +# p5.Framebuffer diff --git a/src/content/reference/en/p5 copy/p5.Geometry.mdx b/src/content/reference/en/p5 copy/p5.Geometry.mdx new file mode 100644 index 0000000000..0faa7daf7a --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Geometry.mdx @@ -0,0 +1,793 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Geometry.js#L13 +title: p5.Geometry +module: Shape +submodule: 3D Primitives +file: src/webgl/p5.Geometry.js +description: > +

A class to describe a 3D shape.

+ +

Each p5.Geometry object represents a 3D shape as a set of + connected + + points called vertices. All 3D shapes are made by connecting vertices + to + + form triangles that are stitched together. Each triangular patch on the + + geometry's surface is called a face. The geometry stores information + + about its vertices and faces for use with effects such as lighting and + + texture mapping.

+ +

The first parameter, detailX, is optional. If a number is + passed, as in + + new p5.Geometry(24), it sets the number of triangle subdivisions + to use + + along the geometry's x-axis. By default, detailX is 1.

+ +

The second parameter, detailY, is also optional. If a number + is passed, + + as in new p5.Geometry(24, 16), it sets the number of triangle + + subdivisions to use along the geometry's y-axis. By default, + detailX is + + 1.

+ +

The third parameter, callback, is also optional. If a function + is passed, + + as in new p5.Geometry(24, 16, createShape), it will be called + once to add + + vertices to the new 3D shape.

+line: 13 +isConstructor: true +params: + - name: detailX + description: | +

number of vertices along the x-axis.

+ type: Integer + optional: true + - name: detailY + description: | +

number of vertices along the y-axis.

+ type: Integer + optional: true + - name: callback + description: | +

function to call once the geometry is created.

+ type: Function + optional: true +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + let myGeometry; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Geometry object. + myGeometry = new p5.Geometry(); + + // Create p5.Vector objects to position the vertices. + let v0 = createVector(-40, 0, 0); + let v1 = createVector(0, -40, 0); + let v2 = createVector(40, 0, 0); + + // Add the vertices to the p5.Geometry object's vertices array. + myGeometry.vertices.push(v0, v1, v2); + + describe('A white triangle drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the p5.Geometry object. + model(myGeometry); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let myGeometry; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Geometry object using a callback function. + myGeometry = new p5.Geometry(1, 1, createShape); + + describe('A white triangle drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the p5.Geometry object. + model(myGeometry); + } + + function createShape() { + // Create p5.Vector objects to position the vertices. + let v0 = createVector(-40, 0, 0); + let v1 = createVector(0, -40, 0); + let v2 = createVector(40, 0, 0); + + // "this" refers to the p5.Geometry object being created. + + // Add the vertices to the p5.Geometry object's vertices array. + this.vertices.push(v0, v1, v2); + + // Add an array to list which vertices belong to the face. + // Vertices are listed in clockwise "winding" order from + // left to top to right. + this.faces.push([0, 1, 2]); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + let myGeometry; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Geometry object using a callback function. + myGeometry = new p5.Geometry(1, 1, createShape); + + describe('A white triangle drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the p5.Geometry object. + model(myGeometry); + } + + function createShape() { + // Create p5.Vector objects to position the vertices. + let v0 = createVector(-40, 0, 0); + let v1 = createVector(0, -40, 0); + let v2 = createVector(40, 0, 0); + + // "this" refers to the p5.Geometry object being created. + + // Add the vertices to the p5.Geometry object's vertices array. + this.vertices.push(v0, v1, v2); + + // Add an array to list which vertices belong to the face. + // Vertices are listed in clockwise "winding" order from + // left to top to right. + this.faces.push([0, 1, 2]); + + // Compute the surface normals to help with lighting. + this.computeNormals(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + // Adapted from Paul Wheeler's wonderful p5.Geometry tutorial. + // https://www.paulwheeler.us/articles/custom-3d-geometry-in-p5js/ + // CC-BY-SA 4.0 + + let myGeometry; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the p5.Geometry object. + // Set detailX to 48 and detailY to 2. + // >>> try changing them. + myGeometry = new p5.Geometry(48, 2, createShape); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the p5.Geometry object. + strokeWeight(0.2); + + // Draw the p5.Geometry object. + model(myGeometry); + } + + function createShape() { + // "this" refers to the p5.Geometry object being created. + + // Define the Möbius strip with a few parameters. + let spread = 0.1; + let radius = 30; + let stripWidth = 15; + let xInterval = 4 * PI / this.detailX; + let yOffset = -stripWidth / 2; + let yInterval = stripWidth / this.detailY; + + for (let j = 0; j <= this.detailY; j += 1) { + // Calculate the "vertical" point along the strip. + let v = yOffset + yInterval * j; + + for (let i = 0; i <= this.detailX; i += 1) { + // Calculate the angle of rotation around the strip. + let u = i * xInterval; + + // Calculate the coordinates of the vertex. + let x = (radius + v * cos(u / 2)) * cos(u) - sin(u / 2) * 2 * spread; + let y = (radius + v * cos(u / 2)) * sin(u); + if (u < TWO_PI) { + y += sin(u) * spread; + } else { + y -= sin(u) * spread; + } + let z = v * sin(u / 2) + sin(u / 4) * 4 * spread; + + // Create a p5.Vector object to position the vertex. + let vert = createVector(x, y, z); + + // Add the vertex to the p5.Geometry object's vertices array. + this.vertices.push(vert); + } + } + + // Compute the faces array. + this.computeFaces(); + + // Compute the surface normals to help with lighting. + this.computeNormals(); + } + +
+methods: + calculateBoundingBox: + description: > +

Calculates the position and size of the smallest box that contains the + geometry.

+ +

A bounding box is the smallest rectangular prism that contains the + entire + + geometry. It's defined by the box's minimum and maximum coordinates along + + each axis, as well as the size (length) and offset (center).

+ +

Calling myGeometry.calculateBoundingBox() returns an + object with four + + properties that describe the bounding box:

+ +
// Get myGeometry's bounding box.
+
+      let bbox = myGeometry.calculateBoundingBox();
+
+
+      // Print the bounding box to the console.
+
+      console.log(bbox);
+
+
+      // {
+
+      //  // The minimum coordinate along each axis.
+
+      //  min: { x: -1, y: -2, z: -3 },
+
+      //
+
+      //  // The maximum coordinate along each axis.
+
+      //  max: { x: 1, y: 2, z: 3},
+
+      //
+
+      //  // The size (length) along each axis.
+
+      //  size: { x: 2, y: 4, z: 6},
+
+      //
+
+      //  // The offset (center) along each axis.
+
+      //  offset: { x: 0, y: 0, z: 0}
+
+      // }
+
+      
+ path: p5.Geometry/calculateBoundingBox + clearColors: + description: > +

Removes the geometry’s internal colors.

+ +

p5.Geometry objects can be created with "internal colors" + assigned to + + vertices or the entire shape. When a geometry has internal colors, + + fill() has no effect. Calling + + myGeometry.clearColors() allows the + + fill() function to apply color to the + geometry.

+ path: p5.Geometry/clearColors + saveObj: + description: > +

The saveObj() function exports p5.Geometry + objects as + + 3D models in the Wavefront .obj file format. + + This way, you can use the 3D shapes you create in p5.js in other software + + for rendering, animation, 3D printing, or more.

+ +

The exported .obj file will include the faces and vertices of the + p5.Geometry, + + as well as its texture coordinates and normals, if it has them.

+ path: p5.Geometry/saveObj + saveStl: + description: > +

The saveStl() function exports p5.Geometry + objects as + + 3D models in the STL stereolithography file format. + + This way, you can use the 3D shapes you create in p5.js in other software + + for rendering, animation, 3D printing, or more.

+ +

The exported .stl file will include the faces, vertices, and normals of + the p5.Geometry.

+ +

By default, this method saves a text-based .stl file. Alternatively, + you can save a more compact + + but less human-readable binary .stl file by passing { binary: true + } as a second parameter.

+ path: p5.Geometry/saveStl + flipU: + description: > +

Flips the geometry’s texture u-coordinates.

+ +

In order for texture() to work, + the geometry + + needs a way to map the points on its surface to the pixels in a + rectangular + + image that's used as a texture. The geometry's vertex at coordinates + + (x, y, z) maps to the texture image's pixel at coordinates + (u, v).

+ +

The myGeometry.uvs array + stores the + + (u, v) coordinates for each vertex in the order it was added + to the + + geometry. Calling myGeometry.flipU() flips a geometry's + u-coordinates + + so that the texture appears mirrored horizontally.

+ +

For example, a plane's four vertices are added clockwise starting from + the + + top-left corner. Here's how calling myGeometry.flipU() would + change a + + plane's texture coordinates:

+ +
// Print the original texture coordinates.
+
+      // Output: [0, 0, 1, 0, 0, 1, 1, 1]
+
+      console.log(myGeometry.uvs);
+
+
+      // Flip the u-coordinates.
+
+      myGeometry.flipU();
+
+
+      // Print the flipped texture coordinates.
+
+      // Output: [1, 0, 0, 0, 1, 1, 0, 1]
+
+      console.log(myGeometry.uvs);
+
+
+      // Notice the swaps:
+
+      // Top vertices: [0, 0, 1, 0] --> [1, 0, 0, 0]
+
+      // Bottom vertices: [0, 1, 1, 1] --> [1, 1, 0, 1]
+
+      
+ path: p5.Geometry/flipU + flipV: + description: > +

Flips the geometry’s texture v-coordinates.

+ +

In order for texture() to work, + the geometry + + needs a way to map the points on its surface to the pixels in a + rectangular + + image that's used as a texture. The geometry's vertex at coordinates + + (x, y, z) maps to the texture image's pixel at coordinates + (u, v).

+ +

The myGeometry.uvs array + stores the + + (u, v) coordinates for each vertex in the order it was added + to the + + geometry. Calling myGeometry.flipV() flips a geometry's + v-coordinates + + so that the texture appears mirrored vertically.

+ +

For example, a plane's four vertices are added clockwise starting from + the + + top-left corner. Here's how calling myGeometry.flipV() would + change a + + plane's texture coordinates:

+ +
// Print the original texture coordinates.
+
+      // Output: [0, 0, 1, 0, 0, 1, 1, 1]
+
+      console.log(myGeometry.uvs);
+
+
+      // Flip the v-coordinates.
+
+      myGeometry.flipV();
+
+
+      // Print the flipped texture coordinates.
+
+      // Output: [0, 1, 1, 1, 0, 0, 1, 0]
+
+      console.log(myGeometry.uvs);
+
+
+      // Notice the swaps:
+
+      // Left vertices: [0, 0] <--> [1, 0]
+
+      // Right vertices: [1, 0] <--> [1, 1]
+
+      
+ path: p5.Geometry/flipV + computeFaces: + description: > +

Computes the geometry's faces using its vertices.

+ +

All 3D shapes are made by connecting sets of points called + vertices. A + + geometry's surface is formed by connecting vertices to form triangles that + + are stitched together. Each triangular patch on the geometry's surface is + + called a face. myGeometry.computeFaces() performs + the math needed to + + define each face based on the distances between vertices.

+ +

The geometry's vertices are stored as p5.Vector + + objects in the myGeometry.vertices + + array. The geometry's first vertex is the + + p5.Vector object at + myGeometry.vertices[0], + + its second vertex is myGeometry.vertices[1], its third vertex + is + + myGeometry.vertices[2], and so on.

+ +

Calling myGeometry.computeFaces() fills the + + myGeometry.faces array with + three-element + + arrays that list the vertices that form each face. For example, a geometry + + made from a rectangle has two faces because a rectangle is made by joining + + two triangles. myGeometry.faces for a + + rectangle would be the two-dimensional array + + [[0, 1, 2], [2, 1, 3]]. The first face, + myGeometry.faces[0], is the + + array [0, 1, 2] because it's formed by connecting + + myGeometry.vertices[0], + myGeometry.vertices[1],and + + myGeometry.vertices[2]. The second face, + myGeometry.faces[1], is the + + array [2, 1, 3] because it's formed by connecting + + myGeometry.vertices[2], myGeometry.vertices[1], + and + + myGeometry.vertices[3].

+ +

Note: myGeometry.computeFaces() only works when geometries + have four or more vertices.

+ path: p5.Geometry/computeFaces + computeNormals: + description: > +

Calculates the normal vector for each vertex on the geometry.

+ +

All 3D shapes are made by connecting sets of points called + vertices. A + + geometry's surface is formed by connecting vertices to create triangles + + that are stitched together. Each triangular patch on the geometry's + + surface is called a face. + myGeometry.computeNormals() performs the + + math needed to orient each face. Orientation is important for lighting + + and other effects.

+ +

A face's orientation is defined by its normal vector which + points out + + of the face and is normal (perpendicular) to the surface. Calling + + myGeometry.computeNormals() first calculates each face's + normal vector. + + Then it calculates the normal vector for each vertex by averaging the + + normal vectors of the faces surrounding the vertex. The vertex normals + + are stored as p5.Vector objects in + the + + myGeometry.vertexNormals + array.

+ +

The first parameter, shadingType, is optional. Passing the + constant + + FLAT, as in myGeometry.computeNormals(FLAT), + provides neighboring + + faces with their own copies of the vertices they share. Surfaces appear + + tiled with flat shading. Passing the constant SMOOTH, as in + + myGeometry.computeNormals(SMOOTH), makes neighboring faces + reuse their + + shared vertices. Surfaces appear smoother with smooth shading. By + + default, shadingType is FLAT.

+ +

The second parameter, options, is also optional. If an + object with a + + roundToPrecision property is passed, as in + + myGeometry.computeNormals(SMOOTH, { roundToPrecision: 5 }), + it sets the + + number of decimal places to use for calculations. By default, + + roundToPrecision uses 3 decimal places.

+ path: p5.Geometry/computeNormals + normalize: + description: > +

Transforms the geometry's vertices to fit snugly within a 100×100×100 + box + + centered at the origin.

+ +

Calling myGeometry.normalize() translates the geometry's + vertices so that + + they're centered at the origin (0, 0, 0). Then it scales the + vertices so + + that they fill a 100×100×100 box. As a result, small geometries will grow + + and large geometries will shrink.

+ +

Note: myGeometry.normalize() only works when called in the + + setup() function.

+ path: p5.Geometry/normalize +properties: + vertices: + description: > +

An array with the geometry's vertices.

+ +

The geometry's vertices are stored as + + p5.Vector objects in the + myGeometry.vertices + + array. The geometry's first vertex is the + + p5.Vector object at + myGeometry.vertices[0], + + its second vertex is myGeometry.vertices[1], its third vertex + is + + myGeometry.vertices[2], and so on.

+ path: p5.Geometry/vertices + vertexNormals: + description: > +

An array with the vectors that are normal to the geometry's + vertices.

+ +

A face's orientation is defined by its normal vector which + points out + + of the face and is normal (perpendicular) to the surface. Calling + + myGeometry.computeNormals() first calculates each face's + normal + + vector. Then it calculates the normal vector for each vertex by + + averaging the normal vectors of the faces surrounding the vertex. The + + vertex normals are stored as p5.Vector + + objects in the myGeometry.vertexNormals array.

+ path: p5.Geometry/vertexNormals + faces: + description: > +

An array that lists which of the geometry's vertices form each of its + + faces.

+ +

All 3D shapes are made by connecting sets of points called + vertices. A + + geometry's surface is formed by connecting vertices to form triangles + + that are stitched together. Each triangular patch on the geometry's + + surface is called a face.

+ +

The geometry's vertices are stored as + + p5.Vector objects in the + + myGeometry.vertices array. + The + + geometry's first vertex is the p5.Vector + + object at myGeometry.vertices[0], its second vertex is + + myGeometry.vertices[1], its third vertex is + myGeometry.vertices[2], + + and so on.

+ +

For example, a geometry made from a rectangle has two faces because a + + rectangle is made by joining two triangles. myGeometry.faces + for a + + rectangle would be the two-dimensional array [[0, 1, 2], [2, 1, + 3]]. + + The first face, myGeometry.faces[0], is the array [0, + 1, 2] because + + it's formed by connecting myGeometry.vertices[0], + + myGeometry.vertices[1],and + myGeometry.vertices[2]. The second face, + + myGeometry.faces[1], is the array [2, 1, 3] + because it's formed by + + connecting myGeometry.vertices[2], + myGeometry.vertices[1],and + + myGeometry.vertices[3].

+ path: p5.Geometry/faces + uvs: + description: > +

An array that lists the texture coordinates for each of the geometry's + + vertices.

+ +

In order for texture() to work, + the geometry + + needs a way to map the points on its surface to the pixels in a + + rectangular image that's used as a texture. The geometry's vertex at + + coordinates (x, y, z) maps to the texture image's pixel at + coordinates + + (u, v).

+ +

The myGeometry.uvs array stores the (u, v) + coordinates for each + + vertex in the order it was added to the geometry. For example, the + + first vertex, myGeometry.vertices[0], has its (u, + v) coordinates + + stored at myGeometry.uvs[0] and + myGeometry.uvs[1].

+ path: p5.Geometry/uvs +chainable: false +--- + + +# p5.Geometry diff --git a/src/content/reference/en/p5 copy/p5.Graphics.mdx b/src/content/reference/en/p5 copy/p5.Graphics.mdx new file mode 100644 index 0000000000..d0b7c3aff8 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Graphics.mdx @@ -0,0 +1,261 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/p5.Graphics.js#L10 +title: p5.Graphics +module: Rendering +submodule: Rendering +file: src/core/p5.Graphics.js +description: > +

A class to describe a drawing surface that's separate from the main + canvas.

+ +

Each p5.Graphics object provides a dedicated drawing surface + called a + + graphics buffer. Graphics buffers are helpful when drawing should + happen + + offscreen. For example, separate scenes can be drawn offscreen and + + displayed only when needed.

+ +

p5.Graphics objects have nearly all the drawing features of + the main + + canvas. For example, calling the method myGraphics.circle(50, 50, + 20) + + draws to the graphics buffer. The resulting image can be displayed on the + + main canvas by passing the p5.Graphics object to the + + image() function, as in + image(myGraphics, 0, 0).

+ +

Note: createGraphics() is the + recommended + + way to create an instance of this class.

+line: 10 +isConstructor: true +params: + - name: width + description: | +

width of the graphics buffer in pixels.

+ type: Number + - name: height + description: | +

height of the graphics buffer in pixels.

+ type: Number + - name: renderer + description: | +

renderer to use, either P2D or WEBGL.

+ type: Constant + - name: pInst + description: | +

sketch instance.

+ type: P5 + optional: true + - name: canvas + description: | +

existing <canvas> element to use.

+ type: HTMLCanvasElement + optional: true +example: + - |- + +
+ + let pg; + + function setup() { + createCanvas(100, 100); + + // Create a p5.Graphics object. + pg = createGraphics(50, 50); + + // Draw to the p5.Graphics object. + pg.background(100); + pg.circle(25, 25, 20); + + describe('A dark gray square with a white circle at its center drawn on a gray background.'); + } + + function draw() { + background(200); + + // Display the p5.Graphics object. + image(pg, 25, 25); + } + +
+ +
+ + // Click the canvas to display the graphics buffer. + + let pg; + + function setup() { + createCanvas(100, 100); + + // Create a p5.Graphics object. + pg = createGraphics(50, 50); + + describe('A square appears on a gray background when the user presses the mouse. The square cycles between white and black.'); + } + + function draw() { + background(200); + + // Calculate the background color. + let bg = frameCount % 255; + + // Draw to the p5.Graphics object. + pg.background(bg); + + // Display the p5.Graphics object while + // the user presses the mouse. + if (mouseIsPressed === true) { + image(pg, 25, 25); + } + } + +
+methods: + reset: + description: > +

Resets the graphics buffer's transformations and lighting.

+ +

By default, the main canvas resets certain transformation and lighting + + values each time draw() executes. + p5.Graphics + + objects must reset these values manually by calling + myGraphics.reset().

+ path: p5.Graphics/reset + remove: + description: > +

Removes the graphics buffer from the web page.

+ +

Calling myGraphics.remove() removes the graphics buffer's + + element from the web page. The graphics buffer also + uses + + a bit of memory on the CPU that can be freed like so:

+ +
// Remove the graphics buffer from the web
+      page.
+
+      myGraphics.remove();
+
+
+      // Delete the graphics buffer from CPU memory.
+
+      myGraphics = undefined;
+
+      
+ +

Note: All variables that reference the graphics buffer must be assigned + + the value undefined to delete the graphics buffer from CPU + memory. If any + + variable still refers to the graphics buffer, then it won't be garbage + + collected.

+ path: p5.Graphics/remove + createFramebuffer: + description: > +

Creates a new p5.Framebuffer + object with + + the same WebGL context as the graphics buffer.

+ +

p5.Framebuffer objects are + separate drawing + + surfaces that can be used as textures in WebGL mode. They're similar to + + p5.Graphics objects and generally + run much + + faster when used as textures. Creating a + + p5.Framebuffer object in the + same context + + as the graphics buffer makes this speedup possible.

+ +

The parameter, options, is optional. An object can be + passed to configure + + the p5.Framebuffer object. The + available + + properties are:

+ +
    + +
  • format: data format of the texture, either + UNSIGNED_BYTE, FLOAT, or + HALF_FLOAT. Default is UNSIGNED_BYTE.
  • + +
  • channels: whether to store RGB or + RGBA color channels. Default is to match the graphics buffer + which is RGBA.
  • + +
  • depth: whether to include a depth buffer. Default is + true.
  • + +
  • depthFormat: data format of depth information, either + UNSIGNED_INT or FLOAT. Default is + FLOAT.
  • + +
  • stencil: whether to include a stencil buffer for masking. + depth must be true for this feature to work. + Defaults to the value of depth which is + true.
  • + +
  • antialias: whether to perform anti-aliasing. If set to + true, as in { antialias: true }, 2 samples will + be used by default. The number of samples can also be set, as in { + antialias: 4 }. Default is to match setAttributes() which is + false (true in Safari).
  • + +
  • width: width of the p5.Framebuffer object. Default is + to always match the graphics buffer width.
  • + +
  • height: height of the p5.Framebuffer object. Default is + to always match the graphics buffer height.
  • + +
  • density: pixel density of the p5.Framebuffer object. Default is + to always match the graphics buffer pixel density.
  • + +
  • textureFiltering: how to read values from the p5.Framebuffer object. Either + LINEAR (nearby pixels will be interpolated) or + NEAREST (no interpolation). Generally, use + LINEAR when using the texture as an image and + NEAREST if reading the texture as data. Default is + LINEAR.
  • + +
+ +

If the width, height, or density + attributes are set, they won't + + automatically match the graphics buffer and must be changed manually.

+ path: p5.Graphics/createFramebuffer +chainable: false +--- + + +# p5.Graphics diff --git a/src/content/reference/en/p5 copy/p5.Image.mdx b/src/content/reference/en/p5 copy/p5.Image.mdx new file mode 100644 index 0000000000..63e2a668fe --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Image.mdx @@ -0,0 +1,519 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/p5.Image.js#L21 +title: p5.Image +module: Image +submodule: Image +file: src/image/p5.Image.js +description: > +

A class to describe an image.

+ +

Images are rectangular grids of pixels that can be displayed and + modified.

+ +

Existing images can be loaded by calling + + loadImage(). Blank images can be + created by + + calling createImage(). + p5.Image objects + + have methods for common tasks such as applying filters and modifying + + pixel values.

+line: 21 +isConstructor: true +params: + - name: width + description: '' + type: Number + - name: height + description: '' + type: Number +example: + - |- + +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0); + + describe('An image of a brick wall.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Apply the GRAY filter. + img.filter(GRAY); + + // Display the image. + image(img, 0, 0); + + describe('A grayscale image of a brick wall.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Image object. + let img = createImage(66, 66); + + // Load the image's pixels. + img.loadPixels(); + + // Set the pixels to black. + for (let x = 0; x < img.width; x += 1) { + for (let y = 0; y < img.height; y += 1) { + img.set(x, y, 0); + } + } + + // Update the image. + img.updatePixels(); + + // Display the image. + image(img, 17, 17); + + describe('A black square drawn in the middle of a gray square.'); + } + +
+methods: + pixelDensity: + description: | +

Gets or sets the pixel density for high pixel density displays.

+

By default, the density will be set to 1.

+

Call this method with no arguments to get the default density, or pass + in a number to set the density. If a non-positive number is provided, + it defaults to 1.

+ path: p5.Image/pixelDensity + loadPixels: + description: > +

Loads the current value of each pixel in the image into the + img.pixels + + array.

+ +

img.loadPixels() must be called before reading or + modifying pixel + + values.

+ path: p5.Image/loadPixels + updatePixels: + description: > +

Updates the canvas with the RGBA values in the + + img.pixels array.

+ +

img.updatePixels() only needs to be called after changing + values in + + the img.pixels array. Such + changes can be + + made directly after calling + + img.loadPixels() or by + calling + + img.set().

+ +

The optional parameters x, y, + width, and height define a + + subsection of the image to update. Doing so can improve performance in + + some cases.

+ +

If the image was loaded from a GIF, then calling + img.updatePixels() + + will update the pixels in current frame.

+ path: p5.Image/updatePixels + get: + description: > +

Gets a pixel or a region of pixels from the image.

+ +

img.get() is easy to use but it's not as fast as + + img.pixels. Use + + img.pixels to read many pixel + values.

+ +

The version of img.get() with no parameters returns the + entire image.

+ +

The version of img.get() with two parameters, as in + img.get(10, 20), + + interprets them as coordinates. It returns an array with the + + [R, G, B, A] values of the pixel at the given point.

+ +

The version of img.get() with four parameters, as in + + img,get(10, 20, 50, 90), interprets them as + + coordinates and dimensions. The first two parameters are the coordinates + + of the upper-left corner of the subsection. The last two parameters are + + the width and height of the subsection. It returns a subsection of the + + canvas in a new p5.Image object.

+ +

Use img.get() instead of get() to work directly + + with images.

+ path: p5.Image/get + set: + description: > +

Sets the color of one or more pixels within an image.

+ +

img.set() is easy to use but it's not as fast as + + img.pixels. Use + + img.pixels to set many pixel + values.

+ +

img.set() interprets the first two parameters as x- and + y-coordinates. It + + interprets the last parameter as a grayscale value, a [R, G, B, + A] pixel + + array, a p5.Color object, or another + + p5.Image object.

+ +

img.updatePixels() must + be called + + after using img.set() for changes to appear.

+ path: p5.Image/set + resize: + description: > +

Resizes the image to a given width and height.

+ +

The image's original aspect ratio can be kept by passing 0 for either + + width or height. For example, calling + img.resize(50, 0) on an image + + that was 500 × 300 pixels will resize it to 50 × 30 pixels.

+ path: p5.Image/resize + copy: + description: > +

Copies pixels from a source image to this image.

+ +

The first parameter, srcImage, is an optional + + p5.Image object to copy. If a source + image isn't + + passed, then img.copy() can copy a region of this image to + another + + region.

+ +

The next four parameters, sx, sy, + sw, and sh determine the region + + to copy from the source image. (sx, sy) is the top-left + corner of the + + region. sw and sh are the region's width and + height.

+ +

The next four parameters, dx, dy, + dw, and dh determine the region + + of this image to copy into. (dx, dy) is the top-left corner + of the + + region. dw and dh are the region's width and + height.

+ +

Calling img.copy() will scale pixels from the source + region if it isn't + + the same size as the destination region.

+ path: p5.Image/copy + mask: + description: > +

Masks part of the image with another.

+ +

img.mask() uses another p5.Image object's + + alpha channel as the alpha channel for this image. Masks are cumulative + + and can't be removed once applied. If the mask has a different + + pixel density from this image, the mask will be scaled.

+ path: p5.Image/mask + filter: + description: > +

Applies an image filter to the image.

+ +

The preset options are:

+ +

INVERT + + Inverts the colors in the image. No parameter is used.

+ +

GRAY + + Converts the image to grayscale. No parameter is used.

+ +

THRESHOLD + + Converts the image to black and white. Pixels with a grayscale value + + above a given threshold are converted to white. The rest are converted to + + black. The threshold must be between 0.0 (black) and 1.0 (white). If no + + value is specified, 0.5 is used.

+ +

OPAQUE + + Sets the alpha channel to be entirely opaque. No parameter is used.

+ +

POSTERIZE + + Limits the number of colors in the image. Each color channel is limited to + + the number of colors specified. Values between 2 and 255 are valid, but + + results are most noticeable with lower values. The default value is 4.

+ +

BLUR + + Blurs the image. The level of blurring is specified by a blur radius. + Larger + + values increase the blur. The default value is 4. A gaussian blur is used + + in P2D mode. A box blur is used in WEBGL + mode.

+ +

ERODE + + Reduces the light areas. No parameter is used.

+ +

DILATE + + Increases the light areas. No parameter is used.

+ path: p5.Image/filter + blend: + description: > +

Copies a region of pixels from another image into this one.

+ +

The first parameter, srcImage, is the + + p5.Image object to blend.

+ +

The next four parameters, sx, sy, + sw, and sh determine the region + + to blend from the source image. (sx, sy) is the top-left + corner of the + + region. sw and sh are the regions width and + height.

+ +

The next four parameters, dx, dy, + dw, and dh determine the region + + of the canvas to blend into. (dx, dy) is the top-left corner + of the + + region. dw and dh are the regions width and + height.

+ +

The tenth parameter, blendMode, sets the effect used to + blend the images' + + colors. The options are BLEND, DARKEST, + LIGHTEST, DIFFERENCE, + + MULTIPLY, EXCLUSION, SCREEN, + REPLACE, OVERLAY, HARD_LIGHT, + + SOFT_LIGHT, DODGE, BURN, + ADD, or NORMAL.

+ path: p5.Image/blend + save: + description: > +

Saves the image to a file.

+ +

By default, img.save() saves the image as a PNG image + called + + untitled.png.

+ +

The first parameter, filename, is optional. It's a string + that sets the + + file's name. If a file extension is included, as in + + img.save('drawing.png'), then the image will be saved using + that + + format.

+ +

The second parameter, extension, is also optional. It sets + the files format. + + Either 'png' or 'jpg' can be used. For example, + img.save('drawing', 'jpg') + + saves the canvas to a file called drawing.jpg.

+ +

Note: The browser will either save the file immediately or prompt the + user + + with a dialogue window.

+ +

The image will only be downloaded as an animated GIF if it was loaded + + from a GIF file. See saveGif() to + create new + + GIFs.

+ path: p5.Image/save + reset: + description: | +

Restarts an animated GIF at its first frame.

+ path: p5.Image/reset + getCurrentFrame: + description: | +

Gets the index of the current frame in an animated GIF.

+ path: p5.Image/getCurrentFrame + setFrame: + description: | +

Sets the current frame in an animated GIF.

+ path: p5.Image/setFrame + numFrames: + description: | +

Returns the number of frames in an animated GIF.

+ path: p5.Image/numFrames + play: + description: | +

Plays an animated GIF that was paused with + img.pause().

+ path: p5.Image/play + pause: + description: | +

Pauses an animated GIF.

+

The GIF can be resumed by calling + img.play().

+ path: p5.Image/pause + delay: + description: > +

Changes the delay between frames in an animated GIF.

+ +

The first parameter, delay, is the length of the delay in + milliseconds.

+ +

The second parameter, index, is optional. If provided, + only the frame + + at index will have its delay modified. All other frames will + keep + + their default delay.

+ path: p5.Image/delay +properties: + width: + description: | +

The image's width in pixels.

+ path: p5.Image/width + height: + description: | +

The image's height in pixels.

+ path: p5.Image/height + pixels: + description: > +

An array containing the color of each pixel in the image.

+ +

Colors are stored as numbers representing red, green, blue, and alpha + + (RGBA) values. img.pixels is a one-dimensional array for + performance + + reasons.

+ +

Each pixel occupies four elements in the pixels array, one for each + + RGBA value. For example, the pixel at coordinates (0, 0) stores its + + RGBA values at img.pixels[0], img.pixels[1], + img.pixels[2], + + and img.pixels[3], respectively. The next pixel at + coordinates (1, 0) + + stores its RGBA values at img.pixels[4], + img.pixels[5], + + img.pixels[6], and img.pixels[7]. And so on. The + img.pixels array + + for a 100×100 p5.Image object has + + 100 × 100 × 4 = 40,000 elements.

+ +

Accessing the RGBA values for a pixel in the image requires a little + + math as shown in the examples below. The + + img.loadPixels() + + method must be called before accessing the img.pixels array. + The + + img.updatePixels() method + must be + + called after any changes are made.

+ path: p5.Image/pixels +chainable: false +--- + + +# p5.Image diff --git a/src/content/reference/en/p5 copy/p5.MediaElement.mdx b/src/content/reference/en/p5 copy/p5.MediaElement.mdx new file mode 100644 index 0000000000..ee05412502 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.MediaElement.mdx @@ -0,0 +1,258 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L4099 +title: p5.MediaElement +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

A class to handle audio and video.

+ +

p5.MediaElement extends p5.Element with + + methods to handle audio and video. p5.MediaElement objects are + created by + + calling createVideo, + + createAudio, and + + createCapture.

+line: 4099 +isConstructor: true +params: + - name: elt + description: | +

DOM node that is wrapped

+ type: String +example: + - |- + +
+ + let capture; + + function setup() { + createCanvas(100, 100); + + // Create a p5.MediaElement using createCapture(). + capture = createCapture(VIDEO); + capture.hide(); + + describe('A webcam feed with inverted colors.'); + } + + function draw() { + // Display the video stream and invert the colors. + image(capture, 0, 0, width, width * capture.height / capture.width); + filter(INVERT); + } + +
+methods: + play: + description: | +

Plays audio or video from a media element.

+ path: p5.MediaElement/play + stop: + description: > +

Stops a media element and sets its current time to 0.

+ +

Calling media.play() will restart playing audio/video from + the beginning.

+ path: p5.MediaElement/stop + pause: + description: > +

Pauses a media element.

+ +

Calling media.play() will resume playing audio/video from + the moment it paused.

+ path: p5.MediaElement/pause + loop: + description: | +

Plays the audio/video repeatedly in a loop.

+ path: p5.MediaElement/loop + noLoop: + description: | +

Stops the audio/video from playing in a loop.

+

The media will stop when it finishes playing.

+ path: p5.MediaElement/noLoop + autoplay: + description: > +

Sets the audio/video to play once it's loaded.

+ +

The parameter, shouldAutoplay, is optional. Calling + + media.autoplay() without an argument causes the media to play + + automatically. If true is passed, as in + media.autoplay(true), the + + media will automatically play. If false is passed, as in + + media.autoPlay(false), it won't play automatically.

+ path: p5.MediaElement/autoplay + volume: + description: > +

Sets the audio/video volume.

+ +

Calling media.volume() without an argument returns the + current volume + + as a number in the range 0 (off) to 1 (maximum).

+ +

The parameter, val, is optional. It's a number that sets + the volume + + from 0 (off) to 1 (maximum). For example, calling + media.volume(0.5) + + sets the volume to half of its maximum.

+ path: p5.MediaElement/volume + speed: + description: > +

Sets the audio/video playback speed.

+ +

The parameter, val, is optional. It's a number that sets + the playback + + speed. 1 plays the media at normal speed, 0.5 plays it at half speed, 2 + + plays it at double speed, and so on. -1 plays the media at normal speed + + in reverse.

+ +

Calling media.speed() returns the current speed as a + number.

+ +

Note: Not all browsers support backward playback. Even if they do, + + playback might not be smooth.

+ path: p5.MediaElement/speed + time: + description: > +

Sets the media element's playback time.

+ +

The parameter, time, is optional. It's a number that + specifies the + + time, in seconds, to jump to when playback begins.

+ +

Calling media.time() without an argument returns the + number of seconds + + the audio/video has played.

+ +

Note: Time resets to 0 when looping media restarts.

+ path: p5.MediaElement/time + duration: + description: | +

Returns the audio/video's duration in seconds.

+ path: p5.MediaElement/duration + onended: + description: > +

Calls a function when the audio/video reaches the end of its + playback.

+ +

The element is passed as an argument to the callback function.

+ +

Note: The function won't be called if the media is looping.

+ path: p5.MediaElement/onended + connect: + description: > +

Sends the element's audio to an output.

+ +

The parameter, audioNode, can be an AudioNode + or an object from the + + p5.sound library.

+ +

If no element is provided, as in myElement.connect(), the + element + + connects to the main output. All connections are removed by the + + .disconnect() method.

+ +

Note: This method is meant to be used with the p5.sound.js addon + library.

+ path: p5.MediaElement/connect + disconnect: + description: > +

Disconnect all Web Audio routing, including to the main output.

+ +

This is useful if you want to re-route the output through audio + effects, + + for example.

+ path: p5.MediaElement/disconnect + showControls: + description: > +

Show the default + + HTMLMediaElement + + controls.

+ +

Note: The controls vary between web browsers.

+ path: p5.MediaElement/showControls + hideControls: + description: > +

Hide the default + + HTMLMediaElement + + controls.

+ path: p5.MediaElement/hideControls + addCue: + description: > +

Schedules a function to call when the audio/video reaches a specific + time + + during its playback.

+ +

The first parameter, time, is the time, in seconds, when + the function + + should run. This value is passed to callback as its first + argument.

+ +

The second parameter, callback, is the function to call at + the specified + + cue time.

+ +

The third parameter, value, is optional and can be any + type of value. + + value is passed to callback.

+ +

Calling media.addCue() returns an ID as a string. This is + useful for + + removing the cue later.

+ path: p5.MediaElement/addCue + removeCue: + description: | +

Removes a callback based on its ID.

+ path: p5.MediaElement/removeCue + clearCues: + description: | +

Removes all functions scheduled with media.addCue().

+ path: p5.MediaElement/clearCues +properties: + src: + description: | +

Path to the media element's source as a string.

+ path: p5.MediaElement/src +chainable: false +--- + + +# p5.MediaElement diff --git a/src/content/reference/en/p5 copy/p5.NumberDict.mdx b/src/content/reference/en/p5 copy/p5.NumberDict.mdx new file mode 100644 index 0000000000..d385eb1468 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.NumberDict.mdx @@ -0,0 +1,63 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/data/p5.TypedDict.js#L415 +title: p5.NumberDict +module: Data +submodule: Dictionary +file: src/data/p5.TypedDict.js +description: | +

A simple Dictionary class for Numbers.

+line: 415 +isConstructor: true +methods: + add: + description: | +

Add the given number to the value currently stored at the given key. + The sum then replaces the value previously stored in the Dictionary.

+ path: p5.NumberDict/add + sub: + description: > +

Subtract the given number from the value currently stored at the given + key. + + The difference then replaces the value previously stored in the + Dictionary.

+ path: p5.NumberDict/sub + mult: + description: > +

Multiply the given number with the value currently stored at the given + key. + + The product then replaces the value previously stored in the + Dictionary.

+ path: p5.NumberDict/mult + div: + description: > +

Divide the given number with the value currently stored at the given + key. + + The quotient then replaces the value previously stored in the + Dictionary.

+ path: p5.NumberDict/div + minValue: + description: | +

Return the lowest number currently stored in the Dictionary.

+ path: p5.NumberDict/minValue + maxValue: + description: | +

Return the highest number currently stored in the Dictionary.

+ path: p5.NumberDict/maxValue + minKey: + description: | +

Return the lowest key currently used in the Dictionary.

+ path: p5.NumberDict/minKey + maxKey: + description: | +

Return the highest key currently used in the Dictionary.

+ path: p5.NumberDict/maxKey +chainable: false +--- + + +# p5.NumberDict diff --git a/src/content/reference/en/p5 copy/p5.PrintWriter.mdx b/src/content/reference/en/p5 copy/p5.PrintWriter.mdx new file mode 100644 index 0000000000..7662b4f910 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.PrintWriter.mdx @@ -0,0 +1,35 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1565 +title: p5.PrintWriter +module: IO +submodule: Output +file: src/io/files.js +description: > +

A class to describe a print stream.

+ +

Each p5.PrintWriter object provides a way to save a sequence + of text + + data, called the print stream, to the user's computer. It's a + low-level + + object that enables precise control of text output. Functions such as + + saveStrings() and + + saveJSON() are easier to use for simple + file + + saving.

+ +

Note: createWriter() is the + recommended way + + to make an instance of this class.

+line: 1565 +--- + + +# p5.PrintWriter diff --git a/src/content/reference/en/p5 copy/p5.Renderer.mdx b/src/content/reference/en/p5 copy/p5.Renderer.mdx new file mode 100644 index 0000000000..5fa9dd1cd1 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Renderer.mdx @@ -0,0 +1,34 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/p5.Renderer.js#L10 +title: p5.Renderer +module: Rendering +submodule: Rendering +file: src/core/p5.Renderer.js +description: | +

Main graphics and rendering context, as well as the base API + implementation for p5.js "core". To be used as the superclass for + Renderer2D and Renderer3D classes, respectively.

+line: 10 +isConstructor: true +params: + - name: elt + description: | +

DOM node that is wrapped

+ type: HTMLElement + - name: pInst + description: | +

pointer to p5 instance

+ type: P5 + optional: true + - name: isMainCanvas + description: | +

whether we're using it as main canvas

+ type: Boolean + optional: true +chainable: false +--- + + +# p5.Renderer diff --git a/src/content/reference/en/p5 copy/p5.Shader.mdx b/src/content/reference/en/p5 copy/p5.Shader.mdx new file mode 100644 index 0000000000..1730091ac1 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Shader.mdx @@ -0,0 +1,433 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Shader.js#L11 +title: p5.Shader +module: 3D +submodule: Material +file: src/webgl/p5.Shader.js +description: > +

A class to describe a shader program.

+ +

Each p5.Shader object contains a shader program that runs on + the graphics + + processing unit (GPU). Shaders can process many pixels or vertices at the + + same time, making them fast for many graphics tasks. They’re written in a + + language called + + GLSL + + and run along with the rest of the code in a sketch.

+ +

A shader program consists of two files, a vertex shader and a fragment + + shader. The vertex shader affects where 3D geometry is drawn on the screen + + and the fragment shader affects color. Once the p5.Shader object + is + + created, it can be used with the shader() + + function, as in shader(myShader).

+ +

A shader can optionally describe hooks, which are functions in + GLSL that + + users may choose to provide to customize the behavior of the shader. For the + + vertex or the fragment shader, users can pass in an object where each key is + + the type and name of a hook function, and each value is a string with the + + parameter list and default implementation of the hook. For example, to let + users + + optionally run code at the start of the vertex shader, the options object + could + + include:

+ +
{
+    vertex: {
+      'void beforeVertex': '() {}'
+    }
+  }
+
+  
+ +

Then, in your vertex shader source, you can run a hook by calling a + function + + with the same name prefixed by HOOK_:

+ +
void main() {
+    HOOK_beforeVertex();
+    // Add the rest of your shader code here!
+  }
+
+  
+ +

Note: createShader(), + + createFilterShader(), and + + loadShader() are the recommended ways + to + + create an instance of this class.

+line: 11 +isConstructor: true +params: + - name: renderer + description: | +

WebGL context for this shader.

+ type: p5.RendererGL + - name: vertSrc + description: | +

source code for the vertex shader program.

+ type: String + - name: fragSrc + description: | +

source code for the fragment shader program.

+ type: String + - name: options + description: > +

An optional object describing how this shader can + + be augmented with hooks. It can include:

+ +
    + +
  • vertex: An object describing the available vertex shader + hooks.
  • + +
  • fragment: An object describing the available frament + shader hooks.
  • + +
+ type: Object + optional: true +example: + - |- + +
+ + // Note: A "uniform" is a global variable within a shader program. + + // Create a string with the vertex shader program. + // The vertex shader is called for each vertex. + let vertSrc = ` + precision highp float; + uniform mat4 uModelViewMatrix; + uniform mat4 uProjectionMatrix; + + attribute vec3 aPosition; + attribute vec2 aTexCoord; + varying vec2 vTexCoord; + + void main() { + vTexCoord = aTexCoord; + vec4 positionVec4 = vec4(aPosition, 1.0); + gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; + } + `; + + // Create a string with the fragment shader program. + // The fragment shader is called for each pixel. + let fragSrc = ` + precision highp float; + + void main() { + // Set each pixel's RGBA value to yellow. + gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); + } + `; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Shader object. + let myShader = createShader(vertSrc, fragSrc); + + // Apply the p5.Shader object. + shader(myShader); + + // Style the drawing surface. + noStroke(); + + // Add a plane as a drawing surface. + plane(100, 100); + + describe('A yellow square.'); + } + +
+ +
+ + // Note: A "uniform" is a global variable within a shader program. + + let mandelbrot; + + // Load the shader and create a p5.Shader object. + function preload() { + mandelbrot = loadShader('/assets/shader.vert', '/assets/shader.frag'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + // Use the p5.Shader object. + shader(mandelbrot); + + // Set the shader uniform p to an array. + mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); + + describe('A fractal image zooms in and out of focus.'); + } + + function draw() { + // Set the shader uniform r to a value that oscillates between 0 and 2. + mandelbrot.setUniform('r', sin(frameCount * 0.01) + 1); + + // Add a quad as a display surface for the shader. + quad(-1, -1, 1, -1, 1, 1, -1, 1); + } + +
+methods: + inspectHooks: + description: > +

Logs the hooks available in this shader, and their current + implementation.

+ +

Each shader may let you override bits of its behavior. Each bit is + called + + a hook. A hook is either for the vertex shader, if it + affects the + + position of vertices, or in the fragment shader, if it affects + the pixel + + color. This method logs those values to the console, letting you know what + + you are able to use in a call to + + modify().

+ +

For example, this shader will produce the following output:

+ +
myShader = baseMaterialShader().modify({
+        declarations: 'uniform float time;',
+        'vec3 getWorldPosition': `(vec3 pos) {
+          pos.y += 20. * sin(time * 0.001 + pos.x * 0.05);
+          return pos;
+        }`
+      });
+
+      myShader.inspectHooks();
+
+      
+ +
==== Vertex shader hooks: ====
+
+      void beforeVertex() {}
+
+      vec3 getLocalPosition(vec3 position) { return position; }
+
+      [MODIFIED] vec3 getWorldPosition(vec3 pos) {
+            pos.y += 20. * sin(time * 0.001 + pos.x * 0.05);
+            return pos;
+          }
+      vec3 getLocalNormal(vec3 normal) { return normal; }
+
+      vec3 getWorldNormal(vec3 normal) { return normal; }
+
+      vec2 getUV(vec2 uv) { return uv; }
+
+      vec4 getVertexColor(vec4 color) { return color; }
+
+      void afterVertex() {}
+
+
+      ==== Fragment shader hooks: ====
+
+      void beforeFragment() {}
+
+      Inputs getPixelInputs(Inputs inputs) { return inputs; }
+
+      vec4 combineColors(ColorComponents components) {
+                      vec4 color = vec4(0.);
+                      color.rgb += components.diffuse * components.baseColor;
+                      color.rgb += components.ambient * components.ambientColor;
+                      color.rgb += components.specular * components.specularColor;
+                      color.rgb += components.emissive;
+                      color.a = components.opacity;
+                      return color;
+                    }
+      vec4 getFinalColor(vec4 color) { return color; }
+
+      void afterFragment() {}
+
+      
+ path: p5.Shader/inspectHooks + modify: + description: > +

Returns a new shader, based on the original, but with custom snippets + + of shader code replacing default behaviour.

+ +

Each shader may let you override bits of its behavior. Each bit is + called + + a hook. A hook is either for the vertex shader, if it + affects the + + position of vertices, or in the fragment shader, if it affects + the pixel + + color. You can inspect the different hooks available by calling + + yourShader.inspectHooks(). + You can + + also read the reference for the default material, normal material, color, + line, and point shaders to + + see what hooks they have available.

+ +

modify() takes one parameter, hooks, an + object with the hooks you want + + to override. Each key of the hooks object is the name + + of a hook, and the value is a string with the GLSL code for your hook.

+ +

If you supply functions that aren't existing hooks, they will get added + at the start of + + the shader as helper functions so that you can use them in your hooks.

+ +

To add new uniforms to + your shader, you can pass in a uniforms object containing + + the type and name of the uniform as the key, and a default value or + function returning + + a default value as its value. These will be automatically set when the + shader is set + + with shader(yourShader).

+ +

You can also add a declarations key, where the value is a + GLSL string declaring + + custom uniform variables, globals, and functions shared + + between hooks. To add declarations just in a vertex or fragment shader, + add + + vertexDeclarations and fragmentDeclarations + keys.

+ path: p5.Shader/modify + copyToContext: + description: > +

Copies the shader from one drawing context to another.

+ +

Each p5.Shader object must be compiled by calling + + shader() before it can run. + Compilation happens + + in a drawing context which is usually the main canvas or an instance of + + p5.Graphics. A shader can only be + used in the + + context where it was compiled. The copyToContext() method + compiles the + + shader again and copies it to another drawing context where it can be + + reused.

+ +

The parameter, context, is the drawing context where the + shader will be + + used. The shader can be copied to an instance of + + p5.Graphics, as in + + myShader.copyToContext(pg). The shader can also be copied + from a + + p5.Graphics object to the main + canvas using + + the window variable, as in + myShader.copyToContext(window).

+ +

Note: A p5.Shader object created + with + + createShader(), + + createFilterShader(), or + + loadShader() + + can be used directly with a p5.Framebuffer + + object created with + + createFramebuffer(). Both + objects + + have the same context as the main canvas.

+ path: p5.Shader/copyToContext + setUniform: + description: > +

Sets the shader’s uniform (global) variables.

+ +

Shader programs run on the computer’s graphics processing unit (GPU). + + They live in part of the computer’s memory that’s completely separate + + from the sketch that runs them. Uniforms are global variables within a + + shader program. They provide a way to pass values from a sketch running + + on the CPU to a shader program running on the GPU.

+ +

The first parameter, uniformName, is a string with the + uniform’s name. + + For the shader above, uniformName would be + 'r'.

+ +

The second parameter, data, is the value that should be + used to set the + + uniform. For example, calling myShader.setUniform('r', 0.5) + would set + + the r uniform in the shader above to 0.5. data + should match the + + uniform’s type. Numbers, strings, booleans, arrays, and many types of + + images can all be passed to a shader with setUniform().

+ path: p5.Shader/setUniform +chainable: false +--- + + +# p5.Shader diff --git a/src/content/reference/en/p5 copy/p5.StringDict.mdx b/src/content/reference/en/p5 copy/p5.StringDict.mdx new file mode 100644 index 0000000000..5ca466e5d1 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.StringDict.mdx @@ -0,0 +1,15 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/data/p5.TypedDict.js#L397 +title: p5.StringDict +module: Data +submodule: Dictionary +file: src/data/p5.TypedDict.js +description: | +

A simple Dictionary class for Strings.

+line: 397 +--- + + +# p5.StringDict diff --git a/src/content/reference/en/p5 copy/p5.Table.mdx b/src/content/reference/en/p5 copy/p5.Table.mdx new file mode 100644 index 0000000000..41ad72b0d1 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Table.mdx @@ -0,0 +1,213 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/p5.Table.js#L33 +title: p5.Table +module: IO +submodule: Table +file: src/io/p5.Table.js +description: > +

Table objects store data with multiple + rows and columns, much + + like in a traditional spreadsheet. Tables can be generated from + + scratch, dynamically, or using data from an existing file.

+line: 33 +isConstructor: true +params: + - name: rows + description: | +

An array of p5.TableRow objects

+ type: 'p5.TableRow[]' + optional: true +methods: + addRow: + description: > +

Use addRow() to add a new row of + data to a p5.Table object. By + default, + + an empty row is created. Typically, you would store a reference to + + the new row in a TableRow object (see newRow in the example above), + + and then set individual values using set().

+ +

If a p5.TableRow object is + included as a parameter, then that row is + + duplicated and added to the table.

+ path: p5.Table/addRow + removeRow: + description: | +

Removes a row from the table object.

+ path: p5.Table/removeRow + getRow: + description: > +

Returns a reference to the specified p5.TableRow. The reference + + can then be used to get and set values of the selected row.

+ path: p5.Table/getRow + getRows: + description: > +

Gets all rows from the table. Returns an array of p5.TableRows.

+ path: p5.Table/getRows + findRow: + description: | +

Finds the first row in the Table that contains the value + provided, and returns a reference to that row. Even if + multiple rows are possible matches, only the first matching + row is returned. The column to search may be specified by + either its ID or title.

+ path: p5.Table/findRow + findRows: + description: | +

Finds the rows in the Table that contain the value + provided, and returns references to those rows. Returns an + Array, so for must be used to iterate through all the rows, + as shown in the example above. The column to search may be + specified by either its ID or title.

+ path: p5.Table/findRows + matchRow: + description: | +

Finds the first row in the Table that matches the regular + expression provided, and returns a reference to that row. + Even if multiple rows are possible matches, only the first + matching row is returned. The column to search may be + specified by either its ID or title.

+ path: p5.Table/matchRow + matchRows: + description: | +

Finds the rows in the Table that match the regular expression provided, + and returns references to those rows. Returns an array, so for must be + used to iterate through all the rows, as shown in the example. The + column to search may be specified by either its ID or title.

+ path: p5.Table/matchRows + getColumn: + description: | +

Retrieves all values in the specified column, and returns them + as an array. The column may be specified by either its ID or title.

+ path: p5.Table/getColumn + clearRows: + description: | +

Removes all rows from a Table. While all rows are removed, + columns and column titles are maintained.

+ path: p5.Table/clearRows + addColumn: + description: > +

Use addColumn() to add a new + column to a Table object. + + Typically, you will want to specify a title, so the column + + may be easily referenced later by name. (If no title is + + specified, the new column's title will be null.)

+ path: p5.Table/addColumn + getColumnCount: + description: | +

Returns the total number of columns in a Table.

+ path: p5.Table/getColumnCount + getRowCount: + description: | +

Returns the total number of rows in a Table.

+ path: p5.Table/getRowCount + removeTokens: + description: | +

Removes any of the specified characters (or "tokens").

+

If no column is specified, then the values in all columns and + rows are processed. A specific column may be referenced by + either its ID or title.

+ path: p5.Table/removeTokens + trim: + description: | +

Trims leading and trailing whitespace, such as spaces and tabs, + from String table values. If no column is specified, then the + values in all columns and rows are trimmed. A specific column + may be referenced by either its ID or title.

+ path: p5.Table/trim + removeColumn: + description: > +

Use removeColumn() to remove + an existing column from a Table + + object. The column to be removed may be identified by either + + its title (a String) or its index value (an int). + + removeColumn(0) would remove the first column, removeColumn(1) + + would remove the second column, and so on.

+ path: p5.Table/removeColumn + set: + description: | +

Stores a value in the Table's specified row and column. + The row is specified by its ID, while the column may be specified + by either its ID or title.

+ path: p5.Table/set + setNum: + description: | +

Stores a Float value in the Table's specified row and column. + The row is specified by its ID, while the column may be specified + by either its ID or title.

+ path: p5.Table/setNum + setString: + description: | +

Stores a String value in the Table's specified row and column. + The row is specified by its ID, while the column may be specified + by either its ID or title.

+ path: p5.Table/setString + get: + description: | +

Retrieves a value from the Table's specified row and column. + The row is specified by its ID, while the column may be specified by + either its ID or title.

+ path: p5.Table/get + getNum: + description: | +

Retrieves a Float value from the Table's specified row and column. + The row is specified by its ID, while the column may be specified by + either its ID or title.

+ path: p5.Table/getNum + getString: + description: | +

Retrieves a String value from the Table's specified row and column. + The row is specified by its ID, while the column may be specified by + either its ID or title.

+ path: p5.Table/getString + getObject: + description: | +

Retrieves all table data and returns as an object. If a column name is + passed in, each row object will be stored with that attribute as its + title.

+ path: p5.Table/getObject + getArray: + description: > +

Retrieves all table data and returns it as a multidimensional + array.

+ path: p5.Table/getArray +properties: + columns: + description: > +

An array containing the names of the columns in the table, if the + "header" the table is + + loaded with the "header" parameter.

+ path: p5.Table/columns + rows: + description: > +

An array containing the p5.TableRow objects that make up the + + rows of the table. The same result as calling getRows()

+ path: p5.Table/rows +chainable: false +--- + + +# p5.Table diff --git a/src/content/reference/en/p5 copy/p5.TableRow.mdx b/src/content/reference/en/p5 copy/p5.TableRow.mdx new file mode 100644 index 0000000000..00081f9654 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.TableRow.mdx @@ -0,0 +1,66 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/p5.TableRow.js#L9 +title: p5.TableRow +module: IO +submodule: Table +file: src/io/p5.TableRow.js +description: | +

A TableRow object represents a single row of data values, + stored in columns, from a table.

+

A Table Row contains both an ordered array, and an unordered + JSON object.

+line: 9 +isConstructor: true +params: + - name: str + description: | +

optional: populate the row with a + string of values, separated by the + separator

+ type: String + optional: true + - name: separator + description: | +

comma separated values (csv) by default

+ type: String + optional: true +methods: + set: + description: | +

Stores a value in the TableRow's specified column. + The column may be specified by either its ID or title.

+ path: p5.TableRow/set + setNum: + description: | +

Stores a Float value in the TableRow's specified column. + The column may be specified by either its ID or title.

+ path: p5.TableRow/setNum + setString: + description: | +

Stores a String value in the TableRow's specified column. + The column may be specified by either its ID or title.

+ path: p5.TableRow/setString + get: + description: | +

Retrieves a value from the TableRow's specified column. + The column may be specified by either its ID or title.

+ path: p5.TableRow/get + getNum: + description: | +

Retrieves a Float value from the TableRow's specified + column. The column may be specified by either its ID or + title.

+ path: p5.TableRow/getNum + getString: + description: | +

Retrieves an String value from the TableRow's specified + column. The column may be specified by either its ID or + title.

+ path: p5.TableRow/getString +chainable: false +--- + + +# p5.TableRow diff --git a/src/content/reference/en/p5 copy/p5.TypedDict.mdx b/src/content/reference/en/p5 copy/p5.TypedDict.mdx new file mode 100644 index 0000000000..2bcb7b5752 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.TypedDict.mdx @@ -0,0 +1,66 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/data/p5.TypedDict.js#L82 +title: p5.TypedDict +module: Data +submodule: Dictionary +file: src/data/p5.TypedDict.js +description: | +

Base class for all p5.Dictionary types. Specifically + typed Dictionary classes inherit from this class.

+line: 82 +isConstructor: true +methods: + size: + description: > +

Returns the number of key-value pairs currently stored in the + Dictionary.

+ path: p5.TypedDict/size + hasKey: + description: | +

Returns true if the given key exists in the Dictionary, + otherwise returns false.

+ path: p5.TypedDict/hasKey + get: + description: | +

Returns the value stored at the given key.

+ path: p5.TypedDict/get + set: + description: > +

Updates the value associated with the given key in case it already + exists + + in the Dictionary. Otherwise a new key-value pair is added.

+ path: p5.TypedDict/set + create: + description: | +

Creates a new key-value pair in the Dictionary.

+ path: p5.TypedDict/create + clear: + description: | +

Removes all previously stored key-value pairs from the Dictionary.

+ path: p5.TypedDict/clear + remove: + description: > +

Removes the key-value pair stored at the given key from the + Dictionary.

+ path: p5.TypedDict/remove + print: + description: > +

Logs the set of items currently stored in the Dictionary to the + console.

+ path: p5.TypedDict/print + saveTable: + description: | +

Converts the Dictionary into a CSV file for local download.

+ path: p5.TypedDict/saveTable + saveJSON: + description: | +

Converts the Dictionary into a JSON file for local download.

+ path: p5.TypedDict/saveJSON +chainable: false +--- + + +# p5.TypedDict diff --git a/src/content/reference/en/p5 copy/p5.Vector.mdx b/src/content/reference/en/p5 copy/p5.Vector.mdx new file mode 100644 index 0000000000..ff67d7562c --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.Vector.mdx @@ -0,0 +1,673 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/p5.Vector.js#L11 +title: p5.Vector +module: Math +submodule: Vector +file: src/math/p5.Vector.js +description: > +

A class to describe a two or three-dimensional vector.

+ +

A vector can be thought of in different ways. In one view, a vector is like + + an arrow pointing in space. Vectors have both magnitude (length) and + + direction.

+ +

p5.Vector objects are often used to program motion because + they simplify + + the math. For example, a moving ball has a position and a velocity. + + Position describes where the ball is in space. The ball's position vector + + extends from the origin to the ball's center. Velocity describes the ball's + + speed and the direction it's moving. If the ball is moving straight up, its + + velocity vector points straight up. Adding the ball's velocity vector to + + its position vector moves it, as in pos.add(vel). Vector math + relies on + + methods inside the p5.Vector class.

+ +

Note: createVector() is the + recommended way + + to make an instance of this class.

+line: 11 +isConstructor: true +params: + - name: x + description: | +

x component of the vector.

+ type: Number + optional: true + - name: 'y' + description: | +

y component of the vector.

+ type: Number + optional: true + - name: z + description: | +

z component of the vector.

+ type: Number + optional: true +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create p5.Vector objects. + let p1 = createVector(25, 25); + let p2 = createVector(75, 75); + + // Style the points. + strokeWeight(5); + + // Draw the first point using a p5.Vector. + point(p1); + + // Draw the second point using a p5.Vector's components. + point(p2.x, p2.y); + + describe('Two black dots on a gray square, one at the top left and the other at the bottom right.'); + } + +
+ +
+ + let pos; + let vel; + + function setup() { + createCanvas(100, 100); + + // Create p5.Vector objects. + pos = createVector(50, 100); + vel = createVector(0, -1); + + describe('A black dot moves from bottom to top on a gray square. The dot reappears at the bottom when it reaches the top.'); + } + + function draw() { + background(200); + + // Add velocity to position. + pos.add(vel); + + // If the dot reaches the top of the canvas, + // restart from the bottom. + if (pos.y < 0) { + pos.y = 100; + } + + // Draw the dot. + strokeWeight(5); + point(pos); + } + +
+methods: + toString: + description: > +

Returns a string representation of a vector.

+ +

Calling toString() is useful for printing vectors to the + console while + + debugging.

+ path: p5.Vector/toString + set: + description: > +

Sets the vector's x, y, and z + components.

+ +

set() can use separate numbers, as in v.set(1, 2, + 3), a + + p5.Vector object, as in + v.set(v2), or an + + array of numbers, as in v.set([1, 2, 3]).

+ +

If a value isn't provided for a component, it will be set to 0. For + + example, v.set(4, 5) sets v.x to 4, + v.y to 5, and v.z to 0. + + Calling set() with no arguments, as in v.set(), + sets all the vector's + + components to 0.

+ path: p5.Vector/set + copy: + description: > +

Returns a copy of the p5.Vector + object.

+ path: p5.Vector/copy + add: + description: > +

Adds to a vector's x, y, and z + components.

+ +

add() can use separate numbers, as in v.add(1, 2, + 3), + + another p5.Vector object, as in + v.add(v2), or + + an array of numbers, as in v.add([1, 2, 3]).

+ +

If a value isn't provided for a component, it won't change. For + + example, v.add(4, 5) adds 4 to v.x, 5 to + v.y, and 0 to v.z. + + Calling add() with no arguments, as in v.add(), + has no effect.

+ +

The static version of add(), as in p5.Vector.add(v2, + v1), returns a new + + p5.Vector object and doesn't change + the + + originals.

+ path: p5.Vector/add + rem: + description: > +

Performs modulo (remainder) division with a vector's x, + y, and z + + components.

+ +

rem() can use separate numbers, as in v.rem(1, 2, + 3), + + another p5.Vector object, as in + v.rem(v2), or + + an array of numbers, as in v.rem([1, 2, 3]).

+ +

If only one value is provided, as in v.rem(2), then all + the components + + will be set to their values modulo 2. If two values are provided, as in + + v.rem(2, 3), then v.z won't change. Calling + rem() with no + + arguments, as in v.rem(), has no effect.

+ +

The static version of rem(), as in p5.Vector.rem(v2, + v1), returns a + + new p5.Vector object and doesn't + change the + + originals.

+ path: p5.Vector/rem + sub: + description: > +

Subtracts from a vector's x, y, and + z components.

+ +

sub() can use separate numbers, as in v.sub(1, 2, + 3), another + + p5.Vector object, as in + v.sub(v2), or an array + + of numbers, as in v.sub([1, 2, 3]).

+ +

If a value isn't provided for a component, it won't change. For + + example, v.sub(4, 5) subtracts 4 from v.x, 5 + from v.y, and 0 from v.z. + + Calling sub() with no arguments, as in v.sub(), + has no effect.

+ +

The static version of sub(), as in p5.Vector.sub(v2, + v1), returns a new + + p5.Vector object and doesn't change + the + + originals.

+ path: p5.Vector/sub + mult: + description: > +

Multiplies a vector's x, y, and + z components.

+ +

mult() can use separate numbers, as in v.mult(1, 2, + 3), another + + p5.Vector object, as in + v.mult(v2), or an array + + of numbers, as in v.mult([1, 2, 3]).

+ +

If only one value is provided, as in v.mult(2), then all + the components + + will be multiplied by 2. If a value isn't provided for a component, it + + won't change. For example, v.mult(4, 5) multiplies + v.x by 4, v.y by 5, + + and v.z by 1. Calling mult() with no arguments, + as in v.mult(), has + + no effect.

+ +

The static version of mult(), as in + p5.Vector.mult(v, 2), returns a new + + p5.Vector object and doesn't change + the + + originals.

+ path: p5.Vector/mult + div: + description: > +

Divides a vector's x, y, and z + components.

+ +

div() can use separate numbers, as in v.div(1, 2, + 3), another + + p5.Vector object, as in + v.div(v2), or an array + + of numbers, as in v.div([1, 2, 3]).

+ +

If only one value is provided, as in v.div(2), then all + the components + + will be divided by 2. If a value isn't provided for a component, it + + won't change. For example, v.div(4, 5) divides + v.x by, v.y by 5, + + and v.z by 1. Calling div() with no arguments, + as in v.div(), has + + no effect.

+ +

The static version of div(), as in p5.Vector.div(v, + 2), returns a new + + p5.Vector object and doesn't change + the + + originals.

+ path: p5.Vector/div + mag: + description: > +

Calculates the magnitude (length) of the vector.

+ +

Use mag() to calculate the magnitude + of a 2D vector + + using components as in mag(x, y).

+ path: p5.Vector/mag + magSq: + description: | +

Calculates the magnitude (length) of the vector squared.

+ path: p5.Vector/magSq + dot: + description: > +

Calculates the dot product of two vectors.

+ +

The dot product is a number that describes the overlap between two + vectors. + + Visually, the dot product can be thought of as the "shadow" one vector + + casts on another. The dot product's magnitude is largest when two vectors + + point in the same or opposite directions. Its magnitude is 0 when two + + vectors form a right angle.

+ +

The version of dot() with one parameter interprets it as + another + + p5.Vector object.

+ +

The version of dot() with multiple parameters interprets + them as the + + x, y, and z components of another + vector.

+ +

The static version of dot(), as in p5.Vector.dot(v1, + v2), is the same + + as calling v1.dot(v2).

+ path: p5.Vector/dot + cross: + description: > +

Calculates the cross product of two vectors.

+ +

The cross product is a vector that points straight out of the plane + created + + by two vectors. The cross product's magnitude is the area of the + parallelogram + + formed by the original two vectors.

+ +

The static version of cross(), as in + p5.Vector.cross(v1, v2), is the same + + as calling v1.cross(v2).

+ path: p5.Vector/cross + dist: + description: > +

Calculates the distance between two points represented by vectors.

+ +

A point's coordinates can be represented by the components of a vector + + that extends from the origin to the point.

+ +

The static version of dist(), as in + p5.Vector.dist(v1, v2), is the same + + as calling v1.dist(v2).

+ +

Use dist() to calculate the distance + between points + + using coordinates as in dist(x1, y1, x2, y2).

+ path: p5.Vector/dist + normalize: + description: > +

Scales the components of a p5.Vector object so + + that its magnitude is 1.

+ +

The static version of normalize(), as in + p5.Vector.normalize(v), + + returns a new p5.Vector object and + doesn't change + + the original.

+ path: p5.Vector/normalize + limit: + description: > +

Limits a vector's magnitude to a maximum value.

+ +

The static version of limit(), as in + p5.Vector.limit(v, 5), returns a + + new p5.Vector object and doesn't + change the + + original.

+ path: p5.Vector/limit + setMag: + description: > +

Sets a vector's magnitude to a given value.

+ +

The static version of setMag(), as in + p5.Vector.setMag(v, 10), returns + + a new p5.Vector object and doesn't + change the + + original.

+ path: p5.Vector/setMag + heading: + description: > +

Calculates the angle a 2D vector makes with the positive x-axis.

+ +

By convention, the positive x-axis has an angle of 0. Angles increase + in + + the clockwise direction.

+ +

If the vector was created with + + createVector(), + heading() returns angles + + in the units of the current angleMode().

+ +

The static version of heading(), as in + p5.Vector.heading(v), works the + + same way.

+ path: p5.Vector/heading + setHeading: + description: > +

Rotates a 2D vector to a specific angle without changing its + magnitude.

+ +

By convention, the positive x-axis has an angle of 0. Angles increase + in + + the clockwise direction.

+ +

If the vector was created with + + createVector(), + setHeading() uses + + the units of the current angleMode().

+ path: p5.Vector/setHeading + rotate: + description: > +

Rotates a 2D vector by an angle without changing its magnitude.

+ +

By convention, the positive x-axis has an angle of 0. Angles increase + in + + the clockwise direction.

+ +

If the vector was created with + + createVector(), + rotate() uses + + the units of the current angleMode().

+ +

The static version of rotate(), as in + p5.Vector.rotate(v, PI), + + returns a new p5.Vector object and + doesn't change + + the original.

+ path: p5.Vector/rotate + angleBetween: + description: > +

Calculates the angle between two vectors.

+ +

The angles returned are signed, which means that + + v1.angleBetween(v2) === -v2.angleBetween(v1).

+ +

If the vector was created with + + createVector(), + angleBetween() returns + + angles in the units of the current + + angleMode().

+ path: p5.Vector/angleBetween + lerp: + description: > +

Calculates new x, y, and z + components that are proportionally the + + same distance between two vectors.

+ +

The amt parameter is the amount to interpolate between the + old vector and + + the new vector. 0.0 keeps all components equal to the old vector's, 0.5 is + + halfway between, and 1.0 sets all components equal to the new + vector's.

+ +

The static version of lerp(), as in + p5.Vector.lerp(v0, v1, 0.5), + + returns a new p5.Vector object and + doesn't change + + the original.

+ path: p5.Vector/lerp + slerp: + description: > +

Calculates a new heading and magnitude that are between two + vectors.

+ +

The amt parameter is the amount to interpolate between the + old vector and + + the new vector. 0.0 keeps the heading and magnitude equal to the old + + vector's, 0.5 sets them halfway between, and 1.0 sets the heading and + + magnitude equal to the new vector's.

+ +

slerp() differs from lerp() because + + it interpolates magnitude. Calling v0.slerp(v1, 0.5) sets + v0's + + magnitude to a value halfway between its original magnitude and + v1's. + + Calling v0.lerp(v1, 0.5) makes no such guarantee.

+ +

The static version of slerp(), as in + p5.Vector.slerp(v0, v1, 0.5), + + returns a new p5.Vector object and + doesn't change + + the original.

+ path: p5.Vector/slerp + reflect: + description: > +

Reflects a vector about a line in 2D or a plane in 3D.

+ +

The orientation of the line or plane is described by a normal vector + that + + points away from the shape.

+ +

The static version of reflect(), as in + p5.Vector.reflect(v, n), + + returns a new p5.Vector object and + doesn't change + + the original.

+ path: p5.Vector/reflect + array: + description: | +

Returns the vector's components as an array of numbers.

+ path: p5.Vector/array + equals: + description: > +

Checks whether all the vector's components are equal to another + vector's.

+ +

equals() returns true if the vector's + components are all the same as another + + vector's and false if not.

+ +

The version of equals() with one parameter interprets it + as another + + p5.Vector object.

+ +

The version of equals() with multiple parameters + interprets them as the + + components of another vector. Any missing parameters are assigned the + value + + 0.

+ +

The static version of equals(), as in + p5.Vector.equals(v0, v1), + + interprets both parameters as p5.Vector objects.

+ path: p5.Vector/equals + fromAngle: + description: | +

Creates a new 2D vector from an angle.

+ path: p5.Vector/fromAngle + fromAngles: + description: | +

Creates a new 3D vector from a pair of ISO spherical angles.

+ path: p5.Vector/fromAngles + random2D: + description: | +

Creates a new 2D unit vector with a random heading.

+ path: p5.Vector/random2D + random3D: + description: | +

Creates a new 3D unit vector with a random heading.

+ path: p5.Vector/random3D + clampToZero: + description: > +

Replaces the components of a p5.Vector that are very close to zero + with zero.

+ +

In computers, handling numbers with decimals can give slightly + imprecise answers due to the way those numbers are represented. + + This can make it hard to check if a number is zero, as it may be close but + not exactly zero. + + This method rounds very close numbers to zero to make those checks + easier

+ +

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON

+ path: p5.Vector/clampToZero +properties: + x: + description: | +

The x component of the vector

+ path: p5.Vector/x + 'y': + description: | +

The y component of the vector

+ path: p5.Vector/y + z: + description: | +

The z component of the vector

+ path: p5.Vector/z +chainable: false +--- + + +# p5.Vector diff --git a/src/content/reference/en/p5 copy/p5.XML.mdx b/src/content/reference/en/p5 copy/p5.XML.mdx new file mode 100644 index 0000000000..71904fded2 --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.XML.mdx @@ -0,0 +1,321 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/p5.XML.js#L9 +title: p5.XML +module: IO +submodule: Input +file: src/io/p5.XML.js +description: > +

A class to describe an XML object.

+ +

Each p5.XML object provides an easy way to interact with XML + data. + + Extensible Markup Language + + (XML) + + is a standard format for sending data between applications. Like HTML, the + + XML format is based on tags and attributes, as in + + .

+ +

Note: Use loadXML() to load external + XML files.

+line: 9 +isConstructor: true +example: + - |- + +
+ + let myXML; + + // Load the XML and create a p5.XML object. + function preload() { + myXML = loadXML('/assets/animals.xml'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Get an array with all mammal tags. + let mammals = myXML.getChildren('mammal'); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(14); + + // Iterate over the mammals array. + for (let i = 0; i < mammals.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 25; + + // Get the mammal's common name. + let name = mammals[i].getContent(); + + // Display the mammal's name. + text(name, 20, y); + } + + describe( + 'The words "Goat", "Leopard", and "Zebra" written on three separate lines. The text is black on a gray background.' + ); + } + +
+methods: + getParent: + description: > +

Returns the element's parent element as a new p5.XML + + object.

+ path: p5.XML/getParent + getName: + description: > +

Returns the element's name as a String.

+ +

An XML element's name is given by its tag. For example, the element + + JavaScript has the name + language.

+ path: p5.XML/getName + setName: + description: > +

Sets the element's tag name.

+ +

An XML element's name is given by its tag. For example, the element + + JavaScript has the name + language.

+ +

The parameter, name, is the element's new name as a + string. For example, + + calling myXML.setName('planet') will make the element's new + tag name + + .

+ path: p5.XML/setName + hasChildren: + description: > +

Returns true if the element has child elements and + false if not.

+ path: p5.XML/hasChildren + listChildren: + description: | +

Returns an array with the names of the element's child elements as + Strings.

+ path: p5.XML/listChildren + getChildren: + description: > +

Returns an array with the element's child elements as new + + p5.XML objects.

+ +

The parameter, name, is optional. If a string is passed, + as in + + myXML.getChildren('cat'), then the method will only return + child elements + + with the tag .

+ path: p5.XML/getChildren + getChild: + description: > +

Returns the first matching child element as a new + + p5.XML object.

+ +

The parameter, name, is optional. If a string is passed, + as in + + myXML.getChild('cat'), then the first child element with the + tag + + will be returned. If a number is passed, as in + + myXML.getChild(1), then the child element at that index will + be returned.

+ path: p5.XML/getChild + addChild: + description: > +

Adds a new child element and returns a reference to it.

+ +

The parameter, child, is the p5.XML object to add + + as a child element. For example, calling + myXML.addChild(otherXML) inserts + + otherXML as a child element of myXML.

+ path: p5.XML/addChild + removeChild: + description: > +

Removes the first matching child element.

+ +

The parameter, name, is the child element to remove. If a + string is + + passed, as in myXML.removeChild('cat'), then the first child + element + + with the tag will be removed. If a number is passed, as + in + + myXML.removeChild(1), then the child element at that index + will be + + removed.

+ path: p5.XML/removeChild + getAttributeCount: + description: | +

Returns the number of attributes the element has.

+ path: p5.XML/getAttributeCount + listAttributes: + description: > +

Returns an Array with the names of the element's + attributes.

+ +

Note: Use + + myXML.getString() or + + myXML.getNum() to return an + attribute's value.

+ path: p5.XML/listAttributes + hasAttribute: + description: > +

Returns true if the element has a given attribute and + false if not.

+ +

The parameter, name, is a string with the name of the + attribute being + + checked.

+ +

Note: Use + + myXML.getString() or + + myXML.getNum() to return an + attribute's value.

+ path: p5.XML/hasAttribute + getNum: + description: > +

Return an attribute's value as a Number.

+ +

The first parameter, name, is a string with the name of + the attribute + + being checked. For example, calling myXML.getNum('id') + returns the + + element's id attribute as a number.

+ +

The second parameter, defaultValue, is optional. If a + number is passed, + + as in myXML.getNum('id', -1), it will be returned if the + attribute + + doesn't exist or can't be converted to a number.

+ +

Note: Use + + myXML.getString() or + + myXML.getNum() to return an + attribute's value.

+ path: p5.XML/getNum + getString: + description: > +

Return an attribute's value as a string.

+ +

The first parameter, name, is a string with the name of + the attribute + + being checked. For example, calling myXML.getString('color') + returns the + + element's id attribute as a string.

+ +

The second parameter, defaultValue, is optional. If a + string is passed, + + as in myXML.getString('color', 'deeppink'), it will be + returned if the + + attribute doesn't exist.

+ +

Note: Use + + myXML.getString() or + + myXML.getNum() to return an + attribute's value.

+ path: p5.XML/getString + setAttribute: + description: > +

Sets an attribute to a given value.

+ +

The first parameter, name, is a string with the name of + the attribute + + being set.

+ +

The second parameter, value, is the attribute's new value. + For example, + + calling myXML.setAttribute('id', 123) sets the + id attribute to the + + value 123.

+ path: p5.XML/setAttribute + getContent: + description: > +

Returns the element's content as a String.

+ +

The parameter, defaultValue, is optional. If a string is + passed, as in + + myXML.getContent('???'), it will be returned if the element + has no + + content.

+ path: p5.XML/getContent + setContent: + description: > +

Sets the element's content.

+ +

An element's content is the text between its tags. For example, the + element + + JavaScript has the content + JavaScript.

+ +

The parameter, content, is a string with the element's new + content.

+ path: p5.XML/setContent + serialize: + description: > +

Returns the element as a String.

+ +

myXML.serialize() is useful for sending the element over + the network or + + saving it to a file.

+ path: p5.XML/serialize +chainable: false +--- + + +# p5.XML diff --git a/src/content/reference/en/p5 copy/p5.mdx b/src/content/reference/en/p5 copy/p5.mdx new file mode 100644 index 0000000000..c51b8f8bff --- /dev/null +++ b/src/content/reference/en/p5 copy/p5.mdx @@ -0,0 +1,51 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L12 +title: p5 +module: IO +submodule: Output +file: src/core/main.js +description: > +

This is the p5 instance constructor.

+ +

A p5 instance holds all the properties and methods related to + + a p5 sketch. It expects an incoming sketch closure and it can also + + take an optional node parameter for attaching the generated p5 canvas + + to a node. The sketch closure takes the newly created p5 instance as + + its sole argument and may optionally set preload(), + + setup(), and/or + + draw() properties on it for running a + sketch.

+ +

A p5 sketch can run in "global" or "instance" mode: + + "global" - all properties and methods are attached to the window + + "instance" - all properties and methods are bound to this p5 object

+line: 12 +isConstructor: true +params: + - name: sketch + description: | +

a closure that can set optional preload(), + setup(), and/or draw() properties on the + given p5 instance

+ type: Function(p5) + - name: node + description: | +

element to attach canvas to

+ type: HTMLElement + optional: true +chainable: false +--- + + +# p5 diff --git a/src/content/reference/en/p5 copy/pAccelerationX.mdx b/src/content/reference/en/p5 copy/pAccelerationX.mdx new file mode 100644 index 0000000000..ab1f3e49d1 --- /dev/null +++ b/src/content/reference/en/p5 copy/pAccelerationX.mdx @@ -0,0 +1,21 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L90 +title: pAccelerationX +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: | +

The system variable pAccelerationX always contains the acceleration of the + device along the x axis in the frame previous to the current frame. Value + is represented as meters per second squared.

+line: 90 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# pAccelerationX diff --git a/src/content/reference/en/p5 copy/pAccelerationY.mdx b/src/content/reference/en/p5 copy/pAccelerationY.mdx new file mode 100644 index 0000000000..188ae8f77c --- /dev/null +++ b/src/content/reference/en/p5 copy/pAccelerationY.mdx @@ -0,0 +1,21 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L100 +title: pAccelerationY +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: | +

The system variable pAccelerationY always contains the acceleration of the + device along the y axis in the frame previous to the current frame. Value + is represented as meters per second squared.

+line: 100 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# pAccelerationY diff --git a/src/content/reference/en/p5 copy/pAccelerationZ.mdx b/src/content/reference/en/p5 copy/pAccelerationZ.mdx new file mode 100644 index 0000000000..f291e6b707 --- /dev/null +++ b/src/content/reference/en/p5 copy/pAccelerationZ.mdx @@ -0,0 +1,21 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L110 +title: pAccelerationZ +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: | +

The system variable pAccelerationZ always contains the acceleration of the + device along the z axis in the frame previous to the current frame. Value + is represented as meters per second squared.

+line: 110 +isConstructor: false +itemtype: property +class: p5 +type: Number +--- + + +# pAccelerationZ diff --git a/src/content/reference/en/p5 copy/pRotationX.mdx b/src/content/reference/en/p5 copy/pRotationX.mdx new file mode 100644 index 0000000000..03d80f8ae5 --- /dev/null +++ b/src/content/reference/en/p5 copy/pRotationX.mdx @@ -0,0 +1,63 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L234 +title: pRotationX +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

The system variable pRotationX always contains the rotation of the + + device along the x axis in the frame previous to the current frame. + + If the sketch angleMode() is set to + DEGREES, + + the value will be -180 to 180. If it is set to RADIANS, the value will + + be -PI to PI.

+ +

pRotationX can also be used with rotationX to determine the rotate + + direction of the device along the X-axis.

+line: 234 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // A simple if statement looking at whether + // rotationX - pRotationX < 0 is true or not will be + // sufficient for determining the rotate direction + // in most cases. + + // Some extra logic is needed to account for cases where + // the angles wrap around. + let rotateDirection = 'clockwise'; + + // Simple range conversion to make things simpler. + // This is not absolutely necessary but the logic + // will be different in that case. + + let rX = rotationX + 180; + let pRX = pRotationX + 180; + + if ((rX - pRX > 0 && rX - pRX < 270) || rX - pRX < -270) { + rotateDirection = 'clockwise'; + } else if (rX - pRX < 0 || rX - pRX > 270) { + rotateDirection = 'counter-clockwise'; + } + + print(rotateDirection); + describe('no image to display.'); + +
+class: p5 +type: Number +--- + + +# pRotationX diff --git a/src/content/reference/en/p5 copy/pRotationY.mdx b/src/content/reference/en/p5 copy/pRotationY.mdx new file mode 100644 index 0000000000..3a15f47f43 --- /dev/null +++ b/src/content/reference/en/p5 copy/pRotationY.mdx @@ -0,0 +1,62 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L278 +title: pRotationY +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

The system variable pRotationY always contains the rotation of the + + device along the y axis in the frame previous to the current frame. + + If the sketch angleMode() is set to + DEGREES, + + the value will be -90 to 90. If it is set to RADIANS, the value will + + be -PI/2 to PI/2.

+ +

pRotationY can also be used with rotationY to determine the rotate + + direction of the device along the Y-axis.

+line: 278 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // A simple if statement looking at whether + // rotationY - pRotationY < 0 is true or not will be + // sufficient for determining the rotate direction + // in most cases. + + // Some extra logic is needed to account for cases where + // the angles wrap around. + let rotateDirection = 'clockwise'; + + // Simple range conversion to make things simpler. + // This is not absolutely necessary but the logic + // will be different in that case. + + let rY = rotationY + 180; + let pRY = pRotationY + 180; + + if ((rY - pRY > 0 && rY - pRY < 270) || rY - pRY < -270) { + rotateDirection = 'clockwise'; + } else if (rY - pRY < 0 || rY - pRY > 270) { + rotateDirection = 'counter-clockwise'; + } + print(rotateDirection); + describe('no image to display.'); + +
+class: p5 +type: Number +--- + + +# pRotationY diff --git a/src/content/reference/en/p5 copy/pRotationZ.mdx b/src/content/reference/en/p5 copy/pRotationZ.mdx new file mode 100644 index 0000000000..4ae6d5e63f --- /dev/null +++ b/src/content/reference/en/p5 copy/pRotationZ.mdx @@ -0,0 +1,58 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L321 +title: pRotationZ +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

The system variable pRotationZ always contains the rotation of the + + device along the z axis in the frame previous to the current frame. + + If the sketch angleMode() is set to + DEGREES, + + the value will be 0 to 360. If it is set to RADIANS, the value will + + be 0 to 2*PI.

+ +

pRotationZ can also be used with rotationZ to determine the rotate + + direction of the device along the Z-axis.

+line: 321 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // A simple if statement looking at whether + // rotationZ - pRotationZ < 0 is true or not will be + // sufficient for determining the rotate direction + // in most cases. + + // Some extra logic is needed to account for cases where + // the angles wrap around. + let rotateDirection = 'clockwise'; + + if ( + (rotationZ - pRotationZ > 0 && rotationZ - pRotationZ < 270) || + rotationZ - pRotationZ < -270 + ) { + rotateDirection = 'clockwise'; + } else if (rotationZ - pRotationZ < 0 || rotationZ - pRotationZ > 270) { + rotateDirection = 'counter-clockwise'; + } + print(rotateDirection); + describe('no image to display.'); + +
+class: p5 +type: Number +--- + + +# pRotationZ diff --git a/src/content/reference/en/p5 copy/paletteLerp.mdx b/src/content/reference/en/p5 copy/paletteLerp.mdx new file mode 100644 index 0000000000..54e8c9f885 --- /dev/null +++ b/src/content/reference/en/p5 copy/paletteLerp.mdx @@ -0,0 +1,66 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L1079 +title: paletteLerp +module: Color +submodule: Creating & Reading +file: src/color/creating_reading.js +description: > +

Blends multiple colors to find a color between them.

+ +

The amt parameter specifies the amount to interpolate between + the color + + stops which are colors at each amt value "location" with + amt values + + that are between 2 color stops interpolating between them based on its + relative + + distance to both.

+ +

The way that colors are interpolated depends on the current + + colorMode().

+line: 1079 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(400, 400); + } + + function draw() { + // The background goes from white to red to green to blue fill + background(paletteLerp([ + ['white', 0], + ['red', 0.05], + ['green', 0.25], + ['blue', 1] + ], millis() / 10000 % 1)); + } + +
+class: p5 +params: + - name: colors_stops + description: | +

color stops to interpolate from

+ type: '[p5.Color, Number][]' + - name: amt + description: | +

number to use to interpolate relative to color stops

+ type: Number +return: + description: interpolated color. + type: p5.Color +chainable: false +--- + + +# paletteLerp diff --git a/src/content/reference/en/p5 copy/panorama.mdx b/src/content/reference/en/p5 copy/panorama.mdx new file mode 100644 index 0000000000..97ee1fd9ca --- /dev/null +++ b/src/content/reference/en/p5 copy/panorama.mdx @@ -0,0 +1,76 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L1021 +title: panorama +module: 3D +submodule: Lights +file: src/webgl/light.js +description: > +

Creates an immersive 3D background.

+ +

panorama() transforms images containing 360˚ content, such as + maps or + + HDRIs, into immersive 3D backgrounds that surround a sketch. Exploring the + + space requires changing the camera's perspective with functions such as + + orbitControl() or + + camera().

+line: 1021 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + let img; + + // Load an image and create a p5.Image object. + function preload() { + img = loadImage('/assets/outdoor_spheremap.jpg'); + } + + function setup() { + createCanvas(100 ,100 ,WEBGL); + + describe('A sphere floating above a landscape. The surface of the sphere reflects the landscape. The full landscape is viewable in 3D as the user drags the mouse.'); + } + + function draw() { + // Add the panorama. + panorama(img); + + // Enable orbiting with the mouse. + orbitControl(); + + // Use the image as a light source. + imageLight(img); + + // Style the sphere. + noStroke(); + specularMaterial(50); + shininess(200); + metalness(100); + + // Draw the sphere. + sphere(30); + } + +
+class: p5 +params: + - name: img + description: | +

360˚ image to use as the background.

+ type: p5.Image +chainable: false +--- + + +# panorama diff --git a/src/content/reference/en/p5 copy/perspective.mdx b/src/content/reference/en/p5 copy/perspective.mdx new file mode 100644 index 0000000000..21cca35746 --- /dev/null +++ b/src/content/reference/en/p5 copy/perspective.mdx @@ -0,0 +1,194 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L148 +title: perspective +module: 3D +submodule: Camera +file: src/webgl/p5.Camera.js +description: > +

Sets a perspective projection for the current camera in a 3D sketch.

+ +

In a perspective projection, shapes that are further from the camera appear + + smaller than shapes that are near the camera. This technique, called + + foreshortening, creates realistic 3D scenes. It’s applied by default in + + WebGL mode.

+ +

perspective() changes the camera’s perspective by changing its + viewing + + frustum. The frustum is the volume of space that’s visible to the camera. + + Its shape is a pyramid with its top cut off. The camera is placed where + + the top of the pyramid should be and views everything between the frustum’s + + top (near) plane and its bottom (far) plane.

+ +

The first parameter, fovy, is the camera’s vertical field of + view. It’s + + an angle that describes how tall or narrow a view the camera has. For + + example, calling perspective(0.5) sets the camera’s vertical + field of + + view to 0.5 radians. By default, fovy is calculated based on the + sketch’s + + height and the camera’s default z-coordinate, which is 800. The formula for + + the default fovy is 2 * atan(height / 2 / 800).

+ +

The second parameter, aspect, is the camera’s aspect ratio. + It’s a number + + that describes the ratio of the top plane’s width to its height. For + + example, calling perspective(0.5, 1.5) sets the camera’s field of + view to + + 0.5 radians and aspect ratio to 1.5, which would make shapes appear thinner + + on a square canvas. By default, aspect is set to width / + height.

+ +

The third parameter, near, is the distance from the camera to + the near + + plane. For example, calling perspective(0.5, 1.5, 100) sets the + camera’s + + field of view to 0.5 radians, its aspect ratio to 1.5, and places the near + + plane 100 pixels from the camera. Any shapes drawn less than 100 pixels + + from the camera won’t be visible. By default, near is set to 0.1 * + 800, + + which is 1/10th the default distance between the camera and the origin.

+ +

The fourth parameter, far, is the distance from the camera to + the far + + plane. For example, calling perspective(0.5, 1.5, 100, 10000) + sets the + + camera’s field of view to 0.5 radians, its aspect ratio to 1.5, places the + + near plane 100 pixels from the camera, and places the far plane 10,000 + + pixels from the camera. Any shapes drawn more than 10,000 pixels from the + + camera won’t be visible. By default, far is set to 10 * 800, + which is 10 + + times the default distance between the camera and the origin.

+ +

Note: perspective() can only be used in WebGL mode.

+line: 148 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Double-click to squeeze the box. + + let isSqueezed = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white rectangular prism on a gray background. The box appears to become thinner when the user double-clicks.'); + } + + function draw() { + background(200); + + // Place the camera at the top-right. + camera(400, -400, 800); + + if (isSqueezed === true) { + // Set fovy to 0.2. + // Set aspect to 1.5. + perspective(0.2, 1.5); + } + + // Draw the box. + box(); + } + + // Change the camera's perspective when the user double-clicks. + function doubleClicked() { + isSqueezed = true; + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white rectangular prism on a gray background. The prism moves away from the camera until it disappears.'); + } + + function draw() { + background(200); + + // Place the camera at the top-right. + camera(400, -400, 800); + + // Set fovy to 0.2. + // Set aspect to 1.5. + // Set near to 600. + // Set far to 1200. + perspective(0.2, 1.5, 600, 1200); + + // Move the origin away from the camera. + let x = -frameCount; + let y = frameCount; + let z = -2 * frameCount; + translate(x, y, z); + + // Draw the box. + box(); + } + +
+class: p5 +params: + - name: fovy + description: | +

camera frustum vertical field of view. Defaults to + 2 * atan(height / 2 / 800).

+ type: Number + optional: true + - name: aspect + description: | +

camera frustum aspect ratio. Defaults to + width / height.

+ type: Number + optional: true + - name: near + description: | +

distance from the camera to the near clipping plane. + Defaults to 0.1 * 800.

+ type: Number + optional: true + - name: far + description: | +

distance from the camera to the far clipping plane. + Defaults to 10 * 800.

+ type: Number + optional: true +chainable: true +--- + + +# perspective diff --git a/src/content/reference/en/p5 copy/pixelDensity.mdx b/src/content/reference/en/p5 copy/pixelDensity.mdx new file mode 100644 index 0000000000..808ebab227 --- /dev/null +++ b/src/content/reference/en/p5 copy/pixelDensity.mdx @@ -0,0 +1,90 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L1005 +title: pixelDensity +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

Sets the pixel density or returns the current density.

+ +

Computer displays are grids of little lights called pixels. A + + display's pixel density describes how many pixels it packs into an + + area. Displays with smaller pixels have a higher pixel density and create + + sharper images.

+ +

pixelDensity() sets the pixel scaling for high pixel density + displays. + + By default, the pixel density is set to match the display's density. + + Calling pixelDensity(1) turn this off.

+ +

Calling pixelDensity() without an argument returns the current + pixel + + density.

+line: 1005 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + // Set the pixel density to 1. + pixelDensity(1); + + // Create a canvas and draw + // a circle. + createCanvas(100, 100); + background(200); + circle(50, 50, 70); + + describe('A fuzzy white circle on a gray canvas.'); + } + +
+ +
+ + function setup() { + // Set the pixel density to 3. + pixelDensity(3); + + // Create a canvas, paint the + // background, and draw a + // circle. + createCanvas(100, 100); + background(200); + circle(50, 50, 70); + + describe('A sharp white circle on a gray canvas.'); + } + +
+class: p5 +overloads: + - line: 1005 + params: + - name: val + description: | +

desired pixel density.

+ type: Number + optional: true + chainable: 1 + - line: 1059 + params: [] + return: + description: current pixel density of the sketch. + type: Number +chainable: true +--- + + +# pixelDensity diff --git a/src/content/reference/en/p5 copy/pixels.mdx b/src/content/reference/en/p5 copy/pixels.mdx new file mode 100644 index 0000000000..7185d708bf --- /dev/null +++ b/src/content/reference/en/p5 copy/pixels.mdx @@ -0,0 +1,173 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L12 +title: pixels +module: Image +submodule: Pixels +file: src/image/pixels.js +description: > +

An array containing the color of each pixel on the canvas.

+ +

Colors are stored as numbers representing red, green, blue, and alpha + + (RGBA) values. pixels is a one-dimensional array for performance + reasons.

+ +

Each pixel occupies four elements in the pixels array, one for + each RGBA + + value. For example, the pixel at coordinates (0, 0) stores its RGBA values + + at pixels[0], pixels[1], pixels[2], and + pixels[3], respectively. + + The next pixel at coordinates (1, 0) stores its RGBA values at + pixels[4], + + pixels[5], pixels[6], and pixels[7]. + And so on. The pixels array + + for a 100×100 canvas has 100 × 100 × 4 = 40,000 elements.

+ +

Some displays use several smaller pixels to set the color at a single + + point. The pixelDensity() function + returns + + the pixel density of the canvas. High density displays often have a + + pixelDensity() of 2. On such a + display, the + + pixels array for a 100×100 canvas has 200 × 200 × 4 = + + 160,000 elements.

+ +

Accessing the RGBA values for a point on the canvas requires a little math + + as shown below. The loadPixels() + function + + must be called before accessing the pixels array. The + + updatePixels() function must be + called + + after any changes are made.

+line: 12 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Load the pixels array. + loadPixels(); + + // Set the dot's coordinates. + let x = 50; + let y = 50; + + // Get the pixel density. + let d = pixelDensity(); + + // Set the pixel(s) at the center of the canvas black. + for (let i = 0; i < d; i += 1) { + for (let j = 0; j < d; j += 1) { + let index = 4 * ((y * d + j) * width * d + (x * d + i)); + // Red. + pixels[index] = 0; + // Green. + pixels[index + 1] = 0; + // Blue. + pixels[index + 2] = 0; + // Alpha. + pixels[index + 3] = 255; + } + } + + // Update the canvas. + updatePixels(); + + describe('A black dot in the middle of a gray rectangle.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Load the pixels array. + loadPixels(); + + // Get the pixel density. + let d = pixelDensity(); + + // Calculate the halfway index in the pixels array. + let halfImage = 4 * (d * width) * (d * height / 2); + + // Make the top half of the canvas red. + for (let i = 0; i < halfImage; i += 4) { + // Red. + pixels[i] = 255; + // Green. + pixels[i + 1] = 0; + // Blue. + pixels[i + 2] = 0; + // Alpha. + pixels[i + 3] = 255; + } + + // Update the canvas. + updatePixels(); + + describe('A red rectangle drawn above a gray rectangle.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Create a p5.Color object. + let pink = color(255, 102, 204); + + // Load the pixels array. + loadPixels(); + + // Get the pixel density. + let d = pixelDensity(); + + // Calculate the halfway index in the pixels array. + let halfImage = 4 * (d * width) * (d * height / 2); + + // Make the top half of the canvas red. + for (let i = 0; i < halfImage; i += 4) { + pixels[i] = red(pink); + pixels[i + 1] = green(pink); + pixels[i + 2] = blue(pink); + pixels[i + 3] = alpha(pink); + } + + // Update the canvas. + updatePixels(); + + describe('A pink rectangle drawn above a gray rectangle.'); + } + +
+class: p5 +type: 'Number[]' +--- + + +# pixels diff --git a/src/content/reference/en/p5 copy/plane.mdx b/src/content/reference/en/p5 copy/plane.mdx new file mode 100644 index 0000000000..eefeb29b7a --- /dev/null +++ b/src/content/reference/en/p5 copy/plane.mdx @@ -0,0 +1,152 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L866 +title: plane +module: Shape +submodule: 3D Primitives +file: src/webgl/3d_primitives.js +description: > +

Draws a plane.

+ +

A plane is a four-sided, flat shape with every angle measuring 90˚. It’s + + similar to a rectangle and offers advanced drawing features in WebGL mode.

+ +

The first parameter, width, is optional. If a + Number is passed, as in + + plane(20), it sets the plane’s width and height. By default, + width is + + 50.

+ +

The second parameter, height, is also optional. If a + Number is passed, + + as in plane(20, 30), it sets the plane’s height. By default, + height is + + set to the plane’s width.

+ +

The third parameter, detailX, is also optional. If a + Number is passed, + + as in plane(20, 30, 5) it sets the number of triangle + subdivisions to use + + along the x-axis. All 3D shapes are made by connecting triangles to form + + their surfaces. By default, detailX is 1.

+ +

The fourth parameter, detailY, is also optional. If a + Number is passed, + + as in plane(20, 30, 5, 7) it sets the number of triangle + subdivisions to + + use along the y-axis. All 3D shapes are made by connecting triangles to + + form their surfaces. By default, detailY is 1.

+ +

Note: plane() can only be used in WebGL mode.

+line: 866 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white plane on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the plane. + plane(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white plane on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the plane. + // Set its width and height to 30. + plane(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white plane on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the plane. + // Set its width to 30 and height to 50. + plane(30, 50); + } + +
+class: p5 +params: + - name: width + description: | +

width of the plane.

+ type: Number + optional: true + - name: height + description: | +

height of the plane.

+ type: Number + optional: true + - name: detailX + description: | +

number of triangle subdivisions along the x-axis.

+ type: Integer + optional: true + - name: detailY + description: | +

number of triangle subdivisions along the y-axis.

+ type: Integer + optional: true +chainable: true +--- + + +# plane diff --git a/src/content/reference/en/p5 copy/pmouseX.mdx b/src/content/reference/en/p5 copy/pmouseX.mdx new file mode 100644 index 0000000000..5f5e8ff7f7 --- /dev/null +++ b/src/content/reference/en/p5 copy/pmouseX.mdx @@ -0,0 +1,88 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L333 +title: pmouseX +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A Number system variable that tracks the mouse's previous + horizontal + + position.

+ +

pmouseX keeps track of the mouse's position relative to the + + top-left corner of the canvas. Its value is + + mouseX from the previous frame. For + example, if + + the mouse was 50 pixels from the left edge of the canvas during the last + + frame, then pmouseX will be 50.

+ +

If touch is used instead of the mouse, then pmouseX will hold + the + + x-coordinate of the last touch point.

+ +

Note: pmouseX is reset to the current mouseX + + value at the start of each touch event.

+line: 333 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Slow the frame rate. + frameRate(10); + + describe('A line follows the mouse as it moves. The line grows longer with faster movements.'); + } + + function draw() { + background(200); + + line(pmouseX, pmouseY, mouseX, mouseY); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A line follows the mouse as it moves. The line grows longer with faster movements.'); + } + + function draw() { + background(200); + + // Adjust coordinates for WebGL mode. + // The origin (0, 0) is at the center of the canvas. + let pmx = pmouseX - 50; + let pmy = pmouseY - 50; + let mx = mouseX - 50; + let my = mouseY - 50; + + // Draw the line. + line(pmx, pmy, mx, my); + } + +
+class: p5 +type: Number +--- + + +# pmouseX diff --git a/src/content/reference/en/p5 copy/pmouseY.mdx b/src/content/reference/en/p5 copy/pmouseY.mdx new file mode 100644 index 0000000000..558747e43f --- /dev/null +++ b/src/content/reference/en/p5 copy/pmouseY.mdx @@ -0,0 +1,88 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L398 +title: pmouseY +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A Number system variable that tracks the mouse's previous + vertical + + position.

+ +

pmouseY keeps track of the mouse's position relative to the + + top-left corner of the canvas. Its value is + + mouseY from the previous frame. For + example, if + + the mouse was 50 pixels from the top edge of the canvas during the last + + frame, then pmouseY will be 50.

+ +

If touch is used instead of the mouse, then pmouseY will hold + the + + y-coordinate of the last touch point.

+ +

Note: pmouseY is reset to the current mouseY + + value at the start of each touch event.

+line: 398 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Slow the frame rate. + frameRate(10); + + describe('A line follows the mouse as it moves. The line grows longer with faster movements.'); + } + + function draw() { + background(200); + + line(pmouseX, pmouseY, mouseX, mouseY); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A line follows the mouse as it moves. The line grows longer with faster movements.'); + } + + function draw() { + background(200); + + // Adjust coordinates for WebGL mode. + // The origin (0, 0) is at the center of the canvas. + let pmx = pmouseX - 50; + let pmy = pmouseY - 50; + let mx = mouseX - 50; + let my = mouseY - 50; + + // Draw the line. + line(pmx, pmy, mx, my); + } + +
+class: p5 +type: Number +--- + + +# pmouseY diff --git a/src/content/reference/en/p5 copy/point.mdx b/src/content/reference/en/p5 copy/point.mdx new file mode 100644 index 0000000000..7912c06cbb --- /dev/null +++ b/src/content/reference/en/p5 copy/point.mdx @@ -0,0 +1,229 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L721 +title: point +module: Shape +submodule: 2D Primitives +file: src/core/shape/2d_primitives.js +description: > +

Draws a single point in space.

+ +

A point's default width is one pixel. To color a point, use the + + stroke() function. To change its width, + use the + + strokeWeight() function. A point + + can't be filled, so the fill() function + won't + + affect the point's color.

+ +

The version of point() with two parameters allows the point's + location to + + be set with its x- and y-coordinates, as in point(10, 20).

+ +

The version of point() with three parameters allows the point + to be drawn + + in 3D space with x-, y-, and z-coordinates, as in point(10, 20, + 30). + + Doing so requires adding the WEBGL argument to + + createCanvas().

+ +

The version of point() with one parameter allows the point's + location to + + be set with a p5.Vector object.

+line: 721 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + + // Making point to 5 pixels + strokeWeight(5); + + + // Top-left. + point(30, 20); + + // Top-right. + point(85, 20); + + // Bottom-right. + point(85, 75); + + // Bottom-left. + point(30, 75); + + describe( + 'Four small, black points drawn on a gray canvas. The points form the corners of a square.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + + // Making point to 5 pixels. + strokeWeight(5); + + + // Top-left. + point(30, 20); + + // Top-right. + point(70, 20); + + // Style the next points. + stroke('purple'); + strokeWeight(10); + + // Bottom-right. + point(70, 80); + + // Bottom-left. + point(30, 80); + + describe( + 'Four points drawn on a gray canvas. Two are black and two are purple. The points form the corners of a square.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + + // Making point to 5 pixels. + strokeWeight(5); + + + // Top-left. + let a = createVector(30, 20); + point(a); + + // Top-right. + let b = createVector(70, 20); + point(b); + + // Bottom-right. + let c = createVector(70, 80); + point(c); + + // Bottom-left. + let d = createVector(30, 80); + point(d); + + describe( + 'Four small, black points drawn on a gray canvas. The points form the corners of a square.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('Two purple points drawn on a gray canvas.'); + } + + function draw() { + background(200); + + // Style the points. + stroke('purple'); + strokeWeight(10); + + // Top-left. + point(-20, -30); + + // Bottom-right. + point(20, 30); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('Two purple points drawn on a gray canvas. The scene spins slowly.'); + } + + function draw() { + background(200); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Style the points. + stroke('purple'); + strokeWeight(10); + + // Top-left. + point(-20, -30, 0); + + // Bottom-right. + point(20, 30, -50); + } + +
+class: p5 +overloads: + - line: 721 + params: + - name: x + description: | +

the x-coordinate.

+ type: Number + - name: 'y' + description: | +

the y-coordinate.

+ type: Number + - name: z + description: | +

the z-coordinate (for WebGL mode).

+ type: Number + optional: true + chainable: 1 + - line: 900 + params: + - name: coordinateVector + description: | +

the coordinate vector.

+ type: p5.Vector + chainable: 1 +chainable: true +--- + + +# point diff --git a/src/content/reference/en/p5 copy/pointLight.mdx b/src/content/reference/en/p5 copy/pointLight.mdx new file mode 100644 index 0000000000..c6f10715b9 --- /dev/null +++ b/src/content/reference/en/p5 copy/pointLight.mdx @@ -0,0 +1,329 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L683 +title: pointLight +module: 3D +submodule: Lights +file: src/webgl/light.js +description: > +

Creates a light that shines from a point in all directions.

+ +

Point lights are like light bulbs that shine in all directions. They can be + + placed at different positions to achieve different lighting effects. A + + maximum of 5 point lights can be active at once.

+ +

There are four ways to call pointLight() with parameters to + set the + + light’s color and position.

+ +

The first way to call pointLight() has six parameters. The + first three + + parameters, v1, v2, and v3, set the + light’s color using the current + + colorMode(). The last three parameters, + x, + + y, and z, set the light’s position. For example, + + pointLight(255, 0, 0, 50, 0, 0) creates a red (255, 0, + 0) light that + + shines from the coordinates (50, 0, 0).

+ +

The second way to call pointLight() has four parameters. The + first three + + parameters, v1, v2, and v3, set the + light’s color using the current + + colorMode(). The last parameter, + position sets + + the light’s position using a p5.Vector + object. + + For example, pointLight(255, 0, 0, lightPos) creates a red + (255, 0, 0) + + light that shines from the position set by the lightPos + vector.

+ +

The third way to call pointLight() has four parameters. The + first + + parameter, color, sets the light’s color using a + + p5.Color object or an array of color + values. The + + last three parameters, x, y, and z, set + the light’s position. For + + example, directionalLight(myColor, 50, 0, 0) creates a light that + shines + + from the coordinates (50, 0, 0) with the color value of + myColor.

+ +

The fourth way to call pointLight() has two parameters. The + first + + parameter, color, sets the light’s color using a + + p5.Color object or an array of color + values. The + + second parameter, position, sets the light’s position using a + + p5.Vector object. For example, + + directionalLight(myColor, lightPos) creates a light that shines + from the + + position set by the lightPos vector with the color value of + myColor.

+line: 683 +isConstructor: false +itemtype: method +example: + - |- + + +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click to turn on the point light. + + let isLit = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A sphere drawn on a gray background. A red light starts shining from above when the user double-clicks.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Control the light. + if (isLit === true) { + // Add a red point light from above. + // Use RGB values and XYZ coordinates. + pointLight(255, 0, 0, 0, -150, 0); + } + + // Style the sphere. + noStroke(); + + // Draw the sphere. + sphere(30); + } + + // Turn on the point light when the user double-clicks. + function doubleClicked() { + isLit = true; + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Add a red point light from above. + // Use a p5.Color object and XYZ directions. + let c = color(255, 0, 0); + pointLight(c, 0, -150, 0); + + // Style the sphere. + noStroke(); + + // Draw the sphere. + sphere(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Add a red point light from above. + // Use a p5.Color object and a p5.Vector object. + let c = color(255, 0, 0); + let lightPos = createVector(0, -150, 0); + pointLight(c, lightPos); + + // Style the sphere. + noStroke(); + + // Draw the sphere. + sphere(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('Four spheres arranged in a square and drawn on a gray background. The spheres appear bright red toward the center of the square. The color gets darker toward the corners of the square.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Add a red point light that points to the center of the scene. + // Use a p5.Color object and a p5.Vector object. + let c = color(255, 0, 0); + let lightPos = createVector(0, 0, 65); + pointLight(c, lightPos); + + // Style the spheres. + noStroke(); + + // Draw a sphere up and to the left. + push(); + translate(-25, -25, 25); + sphere(10); + pop(); + + // Draw a box up and to the right. + push(); + translate(25, -25, 25); + sphere(10); + pop(); + + // Draw a sphere down and to the left. + push(); + translate(-25, 25, 25); + sphere(10); + pop(); + + // Draw a box down and to the right. + push(); + translate(25, 25, 25); + sphere(10); + pop(); + } + +
+class: p5 +overloads: + - line: 683 + params: + - name: v1 + description: | +

red or hue value in the current + colorMode().

+ type: Number + - name: v2 + description: | +

green or saturation value in the current + colorMode().

+ type: Number + - name: v3 + description: | +

blue, brightness, or lightness value in the current + colorMode().

+ type: Number + - name: x + description: | +

x-coordinate of the light.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the light.

+ type: Number + - name: z + description: | +

z-coordinate of the light.

+ type: Number + chainable: 1 + - line: 890 + params: + - name: v1 + description: '' + type: Number + - name: v2 + description: '' + type: Number + - name: v3 + description: '' + type: Number + - name: position + description: | +

position of the light as a + p5.Vector object.

+ type: p5.Vector + chainable: 1 + - line: 900 + params: + - name: color + description: | +

color as a p5.Color object, + an array of color values, or a CSS string.

+ type: 'p5.Color|Number[]|String' + - name: x + description: '' + type: Number + - name: 'y' + description: '' + type: Number + - name: z + description: '' + type: Number + chainable: 1 + - line: 910 + params: + - name: color + description: '' + type: 'p5.Color|Number[]|String' + - name: position + description: '' + type: p5.Vector + chainable: 1 +chainable: true +--- + + +# pointLight diff --git a/src/content/reference/en/p5 copy/pop.mdx b/src/content/reference/en/p5 copy/pop.mdx new file mode 100644 index 0000000000..72b5c1db21 --- /dev/null +++ b/src/content/reference/en/p5 copy/pop.mdx @@ -0,0 +1,20 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L553 +title: pop +module: Structure +submodule: Structure +file: src/core/structure.js +description: "

Ends a drawing group that contains its own styles and transformations.

\n

By default, styles such as fill() and\ntransformations such as rotate() are applied to\nall drawing that follows. The push() and pop()\nfunctions can limit the effect of styles and transformations to a specific\ngroup of shapes, images, and text. For example, a group of shapes could be\ntranslated to follow the mouse without affecting the rest of the sketch:

\n
// Begin the drawing group.\npush();\n\n// Translate the origin to the mouse's position.\ntranslate(mouseX, mouseY);\n\n// Style the face.\nnoStroke();\nfill('green');\n\n// Draw the face.\ncircle(0, 0, 60);\n\n// Style the eyes.\nfill('white');\n\n// Draw the left eye.\nellipse(-20, -20, 30, 20);\n\n// Draw the right eye.\nellipse(20, -20, 30, 20);\n\n// End the drawing group.\npop();\n\n// Draw a bug.\nlet x = random(0, 100);\nlet y = random(0, 100);\ntext('\U0001F99F', x, y);\n
\n

In the code snippet above, the bug's position isn't affected by\ntranslate(mouseX, mouseY) because that transformation is contained\nbetween push() and pop(). The bug moves around\nthe entire canvas as expected.

\n

Note: push() and pop() are always called as a\npair. Both functions are required to begin and end a drawing group.

\n

push() and pop() can also be nested to create\nsubgroups. For example, the code snippet above could be changed to give\nmore detail to the frog’s eyes:

\n
// Begin the drawing group.\npush();\n\n// Translate the origin to the mouse's position.\ntranslate(mouseX, mouseY);\n\n// Style the face.\nnoStroke();\nfill('green');\n\n// Draw a face.\ncircle(0, 0, 60);\n\n// Style the eyes.\nfill('white');\n\n// Draw the left eye.\npush();\ntranslate(-20, -20);\nellipse(0, 0, 30, 20);\nfill('black');\ncircle(0, 0, 8);\npop();\n\n// Draw the right eye.\npush();\ntranslate(20, -20);\nellipse(0, 0, 30, 20);\nfill('black');\ncircle(0, 0, 8);\npop();\n\n// End the drawing group.\npop();\n\n// Draw a bug.\nlet x = random(0, 100);\nlet y = random(0, 100);\ntext('\U0001F99F', x, y);\n
\n

In this version, the code to draw each eye is contained between its own\npush() and pop() functions. Doing so makes it\neasier to add details in the correct part of a drawing.

\n

push() and pop() contain the effects of the\nfollowing functions:

\n\n

In WebGL mode, push() and pop() contain the\neffects of a few additional styles:

\n\n" +line: 553 +isConstructor: false +itemtype: method +example: + - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Draw the left circle.\n circle(25, 50, 20);\n\n // Begin the drawing group.\n push();\n\n // Translate the origin to the center.\n translate(50, 50);\n\n // Style the circle.\n strokeWeight(5);\n stroke('royalblue');\n fill('orange');\n\n // Draw the circle.\n circle(0, 0, 20);\n\n // End the drawing group.\n pop();\n\n // Draw the right circle.\n circle(75, 50, 20);\n\n describe(\n 'Three circles drawn in a row on a gray background. The left and right circles are white with thin, black borders. The middle circle is orange with a thick, blue border.'\n );\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Slow the frame rate.\n frameRate(24);\n\n describe('A mosquito buzzes in front of a green frog. The frog follows the mouse as the user moves.');\n}\n\nfunction draw() {\n background(200);\n\n // Begin the drawing group.\n push();\n\n // Translate the origin to the mouse's position.\n translate(mouseX, mouseY);\n\n // Style the face.\n noStroke();\n fill('green');\n\n // Draw a face.\n circle(0, 0, 60);\n\n // Style the eyes.\n fill('white');\n\n // Draw the left eye.\n push();\n translate(-20, -20);\n ellipse(0, 0, 30, 20);\n fill('black');\n circle(0, 0, 8);\n pop();\n\n // Draw the right eye.\n push();\n translate(20, -20);\n ellipse(0, 0, 30, 20);\n fill('black');\n circle(0, 0, 8);\n pop();\n\n // End the drawing group.\n pop();\n\n // Draw a bug.\n let x = random(0, 100);\n let y = random(0, 100);\n text('\U0001F99F', x, y);\n}\n\n
\n\n
\n\n// Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n\n describe(\n 'Two spheres drawn on a gray background. The sphere on the left is red and lit from the front. The sphere on the right is a blue wireframe.'\n );\n}\n\nfunction draw() {\n background(200);\n\n // Enable orbiting with the mouse.\n orbitControl();\n\n // Draw the red sphere.\n push();\n translate(-25, 0, 0);\n noStroke();\n directionalLight(255, 0, 0, 0, 0, -1);\n sphere(20);\n pop();\n\n // Draw the blue sphere.\n push();\n translate(25, 0, 0);\n strokeWeight(0.3);\n stroke(0, 0, 255);\n noFill();\n sphere(20);\n pop();\n}\n\n
" +class: p5 +chainable: false +--- + + +# pop diff --git a/src/content/reference/en/p5 copy/pow.mdx b/src/content/reference/en/p5 copy/pow.mdx new file mode 100644 index 0000000000..18201ec3c2 --- /dev/null +++ b/src/content/reference/en/p5 copy/pow.mdx @@ -0,0 +1,67 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L815 +title: pow +module: Math +submodule: Calculation +file: src/math/calculation.js +description: | +

Calculates exponential expressions such as 23.

+

For example, pow(2, 3) evaluates the expression + 2 × 2 × 2. pow(2, -3) evaluates 1 ÷ + (2 × 2 × 2).

+line: 815 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Set the base of the exponent. + let base = 3; + + // Top-left. + let d = pow(base, 1); + circle(10, 10, d); + + // Left-center. + d = pow(base, 2); + circle(20, 20, d); + + // Right-center. + d = pow(base, 3); + circle(40, 40, d); + + // Bottom-right. + d = pow(base, 4); + circle(80, 80, d); + + describe('A series of circles that grow exponentially from top left to bottom right.'); + } + +
+class: p5 +params: + - name: 'n' + description: | +

base of the exponential expression.

+ type: Number + - name: e + description: | +

power by which to raise the base.

+ type: Number +return: + description: n^e. + type: Number +chainable: false +--- + + +# pow diff --git a/src/content/reference/en/p5 copy/preload.mdx b/src/content/reference/en/p5 copy/preload.mdx new file mode 100644 index 0000000000..66d5db4378 --- /dev/null +++ b/src/content/reference/en/p5 copy/preload.mdx @@ -0,0 +1,70 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L41 +title: preload +module: Structure +submodule: Structure +file: src/core/main.js +description: > +

A function that's called once to load assets before the sketch runs.

+ +

Declaring the function preload() sets a code block to run once + + automatically before setup() or + + draw(). It's used to load assets including + + multimedia files, fonts, data, and 3D models:

+ +
function preload() {
+    // Code to run before the rest of the sketch.
+  }
+
+  
+ +

Functions such as loadImage(), + + loadFont(), + + loadJSON(), and + + loadModel() are guaranteed to either + + finish loading or raise an error if they're called within + preload(). + + Doing so ensures that assets are available when the sketch begins + + running.

+line: 41 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load an image and create a p5.Image object. + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Draw the image. + image(img, 0, 0); + + describe('A red brick wall.'); + } + +
+class: p5 +chainable: false +--- + + +# preload diff --git a/src/content/reference/en/p5 copy/print.mdx b/src/content/reference/en/p5 copy/print.mdx new file mode 100644 index 0000000000..50137586ae --- /dev/null +++ b/src/content/reference/en/p5 copy/print.mdx @@ -0,0 +1,55 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L21 +title: print +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

Displays text in the web browser's console.

+ +

print() is helpful for printing values while debugging. Each + call to + + print() creates a new line of text.

+ +

Note: Call print('\n') to print a blank line. Calling + print() without + + an argument opens the browser's dialog for printing documents.

+line: 21 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + // Prints "hello, world" to the console. + print('hello, world'); + } + +
+ +
+ + function setup() { + let name = 'ada'; + // Prints "hello, ada" to the console. + print(`hello, ${name}`); + } + +
+class: p5 +params: + - name: contents + description: | +

content to print to the console.

+ type: Any +chainable: false +--- + + +# print diff --git a/src/content/reference/en/p5 copy/push.mdx b/src/content/reference/en/p5 copy/push.mdx new file mode 100644 index 0000000000..ee1a386cee --- /dev/null +++ b/src/content/reference/en/p5 copy/push.mdx @@ -0,0 +1,20 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L269 +title: push +module: Structure +submodule: Structure +file: src/core/structure.js +description: "

Begins a drawing group that contains its own styles and transformations.

\n

By default, styles such as fill() and\ntransformations such as rotate() are applied to\nall drawing that follows. The push() and pop()\nfunctions can limit the effect of styles and transformations to a specific\ngroup of shapes, images, and text. For example, a group of shapes could be\ntranslated to follow the mouse without affecting the rest of the sketch:

\n
// Begin the drawing group.\npush();\n\n// Translate the origin to the mouse's position.\ntranslate(mouseX, mouseY);\n\n// Style the face.\nnoStroke();\nfill('green');\n\n// Draw the face.\ncircle(0, 0, 60);\n\n// Style the eyes.\nfill('white');\n\n// Draw the left eye.\nellipse(-20, -20, 30, 20);\n\n// Draw the right eye.\nellipse(20, -20, 30, 20);\n\n// End the drawing group.\npop();\n\n// Draw a bug.\nlet x = random(0, 100);\nlet y = random(0, 100);\ntext('\U0001F99F', x, y);\n
\n

In the code snippet above, the bug's position isn't affected by\ntranslate(mouseX, mouseY) because that transformation is contained\nbetween push() and pop(). The bug moves around\nthe entire canvas as expected.

\n

Note: push() and pop() are always called as a\npair. Both functions are required to begin and end a drawing group.

\n

push() and pop() can also be nested to create\nsubgroups. For example, the code snippet above could be changed to give\nmore detail to the frog’s eyes:

\n
// Begin the drawing group.\npush();\n\n// Translate the origin to the mouse's position.\ntranslate(mouseX, mouseY);\n\n// Style the face.\nnoStroke();\nfill('green');\n\n// Draw a face.\ncircle(0, 0, 60);\n\n// Style the eyes.\nfill('white');\n\n// Draw the left eye.\npush();\ntranslate(-20, -20);\nellipse(0, 0, 30, 20);\nfill('black');\ncircle(0, 0, 8);\npop();\n\n// Draw the right eye.\npush();\ntranslate(20, -20);\nellipse(0, 0, 30, 20);\nfill('black');\ncircle(0, 0, 8);\npop();\n\n// End the drawing group.\npop();\n\n// Draw a bug.\nlet x = random(0, 100);\nlet y = random(0, 100);\ntext('\U0001F99F', x, y);\n
\n

In this version, the code to draw each eye is contained between its own\npush() and pop() functions. Doing so makes it\neasier to add details in the correct part of a drawing.

\n

push() and pop() contain the effects of the\nfollowing functions:

\n\n

In WebGL mode, push() and pop() contain the\neffects of a few additional styles:

\n\n" +line: 269 +isConstructor: false +itemtype: method +example: + - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Draw the left circle.\n circle(25, 50, 20);\n\n // Begin the drawing group.\n push();\n\n // Translate the origin to the center.\n translate(50, 50);\n\n // Style the circle.\n strokeWeight(5);\n stroke('royalblue');\n fill('orange');\n\n // Draw the circle.\n circle(0, 0, 20);\n\n // End the drawing group.\n pop();\n\n // Draw the right circle.\n circle(75, 50, 20);\n\n describe(\n 'Three circles drawn in a row on a gray background. The left and right circles are white with thin, black borders. The middle circle is orange with a thick, blue border.'\n );\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Slow the frame rate.\n frameRate(24);\n\n describe('A mosquito buzzes in front of a green frog. The frog follows the mouse as the user moves.');\n}\n\nfunction draw() {\n background(200);\n\n // Begin the drawing group.\n push();\n\n // Translate the origin to the mouse's position.\n translate(mouseX, mouseY);\n\n // Style the face.\n noStroke();\n fill('green');\n\n // Draw a face.\n circle(0, 0, 60);\n\n // Style the eyes.\n fill('white');\n\n // Draw the left eye.\n push();\n translate(-20, -20);\n ellipse(0, 0, 30, 20);\n fill('black');\n circle(0, 0, 8);\n pop();\n\n // Draw the right eye.\n push();\n translate(20, -20);\n ellipse(0, 0, 30, 20);\n fill('black');\n circle(0, 0, 8);\n pop();\n\n // End the drawing group.\n pop();\n\n // Draw a bug.\n let x = random(0, 100);\n let y = random(0, 100);\n text('\U0001F99F', x, y);\n}\n\n
\n\n
\n\n// Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n\n describe(\n 'Two spheres drawn on a gray background. The sphere on the left is red and lit from the front. The sphere on the right is a blue wireframe.'\n );\n}\n\nfunction draw() {\n background(200);\n\n // Enable orbiting with the mouse.\n orbitControl();\n\n // Draw the red sphere.\n push();\n translate(-25, 0, 0);\n noStroke();\n directionalLight(255, 0, 0, 0, 0, -1);\n sphere(20);\n pop();\n\n // Draw the blue sphere.\n push();\n translate(25, 0, 0);\n strokeWeight(0.3);\n stroke(0, 0, 255);\n noFill();\n sphere(20);\n pop();\n}\n\n
" +class: p5 +chainable: false +--- + + +# push diff --git a/src/content/reference/en/p5 copy/pwinMouseX.mdx b/src/content/reference/en/p5 copy/pwinMouseX.mdx new file mode 100644 index 0000000000..cb869aea71 --- /dev/null +++ b/src/content/reference/en/p5 copy/pwinMouseX.mdx @@ -0,0 +1,99 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L545 +title: pwinMouseX +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A Number variable that tracks the mouse's previous horizontal + position + + within the browser.

+ +

pwinMouseX keeps track of the mouse's position relative to the + top-left + + corner of the browser window. Its value is + + winMouseX from the previous frame. For + + example, if the mouse was 50 pixels from + + the left edge of the browser during the last frame, then + pwinMouseX will + + be 50.

+ +

On a touchscreen device, pwinMouseX will hold the x-coordinate + of the most + + recent touch point. pwinMouseX is reset to the current + + winMouseX value at the start of each + touch + + event.

+ +

Note: Use pmouseX to track the mouse’s + previous + + x-coordinate within the canvas.

+line: 545 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Slow the frame rate. + frameRate(10); + + describe('A gray square. A white circle at its center grows larger when the mouse moves horizontally.'); + } + + function draw() { + background(200); + + // Calculate the circle's diameter. + let d = winMouseX - pwinMouseX; + + // Draw the circle. + circle(50, 50, d); + } + +
+ +
+ + function setup() { + // Create the canvas and set its position. + let cnv = createCanvas(100, 100); + cnv.position(20, 20); + + describe('A gray square with a number at its center. The number changes as the user moves the mouse vertically.'); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display pwinMouseX. + text(pwinMouseX, 50, 50); + } + +
+class: p5 +type: Number +--- + + +# pwinMouseX diff --git a/src/content/reference/en/p5 copy/pwinMouseY.mdx b/src/content/reference/en/p5 copy/pwinMouseY.mdx new file mode 100644 index 0000000000..2f36580a23 --- /dev/null +++ b/src/content/reference/en/p5 copy/pwinMouseY.mdx @@ -0,0 +1,99 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L616 +title: pwinMouseY +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A Number variable that tracks the mouse's previous vertical + position + + within the browser.

+ +

pwinMouseY keeps track of the mouse's position relative to the + top-left + + corner of the browser window. Its value is + + winMouseY from the previous frame. For + + example, if the mouse was 50 pixels from + + the top edge of the browser during the last frame, then + pwinMouseY will + + be 50.

+ +

On a touchscreen device, pwinMouseY will hold the y-coordinate + of the most + + recent touch point. pwinMouseY is reset to the current + + winMouseY value at the start of each + touch + + event.

+ +

Note: Use pmouseY to track the mouse’s + previous + + y-coordinate within the canvas.

+line: 616 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Slow the frame rate. + frameRate(10); + + describe('A gray square. A white circle at its center grows larger when the mouse moves vertically.'); + } + + function draw() { + background(200); + + // Calculate the circle's diameter. + let d = winMouseY - pwinMouseY; + + // Draw the circle. + circle(50, 50, d); + } + +
+ +
+ + function setup() { + // Create the canvas and set its position. + let cnv = createCanvas(100, 100); + cnv.position(20, 20); + + describe('A gray square with a number at its center. The number changes as the user moves the mouse vertically.'); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display pwinMouseY. + text(pwinMouseY, 50, 50); + } + +
+class: p5 +type: Number +--- + + +# pwinMouseY diff --git a/src/content/reference/en/p5 copy/quad.mdx b/src/content/reference/en/p5 copy/quad.mdx new file mode 100644 index 0000000000..fbc09fa0a3 --- /dev/null +++ b/src/content/reference/en/p5 copy/quad.mdx @@ -0,0 +1,233 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L928 +title: quad +module: Shape +submodule: 2D Primitives +file: src/core/shape/2d_primitives.js +description: > +

Draws a quadrilateral (four-sided shape).

+ +

Quadrilaterals include rectangles, squares, rhombuses, and trapezoids. The + + first pair of parameters (x1, y1) sets the quad's first point. + The next + + three pairs of parameters set the coordinates for its next three points + + (x2, y2), (x3, y3), and (x4, y4). + Points should be added in either + + clockwise or counter-clockwise order.

+ +

The version of quad() with twelve parameters allows the quad + to be drawn + + in 3D space. Doing so requires adding the WEBGL argument to + + createCanvas().

+ +

The thirteenth and fourteenth parameters are optional. In WebGL mode, they + + set the number of segments used to draw the quadrilateral in the x- and + + y-directions. They're both 2 by default.

+line: 928 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + quad(20, 20, 80, 20, 80, 80, 20, 80); + + describe('A white square with a black outline drawn on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + quad(20, 30, 80, 30, 80, 70, 20, 70); + + describe('A white rectangle with a black outline drawn on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + quad(50, 62, 86, 50, 50, 38, 14, 50); + + describe('A white rhombus with a black outline drawn on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + quad(20, 50, 80, 30, 80, 70, 20, 70); + + describe('A white trapezoid with a black outline drawn on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + quad(-30, -30, 30, -30, 30, 30, -30, 30); + + describe('A white square with a black outline drawn on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A wavy white surface spins around on gray canvas.'); + } + + function draw() { + background(200); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Draw the quad. + quad(-30, -30, 0, 30, -30, 0, 30, 30, 20, -30, 30, -20); + } + +
+class: p5 +overloads: + - line: 928 + params: + - name: x1 + description: | +

the x-coordinate of the first point.

+ type: Number + - name: y1 + description: | +

the y-coordinate of the first point.

+ type: Number + - name: x2 + description: | +

the x-coordinate of the second point.

+ type: Number + - name: y2 + description: | +

the y-coordinate of the second point.

+ type: Number + - name: x3 + description: | +

the x-coordinate of the third point.

+ type: Number + - name: y3 + description: | +

the y-coordinate of the third point.

+ type: Number + - name: x4 + description: | +

the x-coordinate of the fourth point.

+ type: Number + - name: y4 + description: | +

the y-coordinate of the fourth point.

+ type: Number + - name: detailX + description: | +

number of segments in the x-direction.

+ type: Integer + optional: true + - name: detailY + description: | +

number of segments in the y-direction.

+ type: Integer + optional: true + chainable: 1 + - line: 1048 + params: + - name: x1 + description: '' + type: Number + - name: y1 + description: '' + type: Number + - name: z1 + description: | +

the z-coordinate of the first point.

+ type: Number + - name: x2 + description: '' + type: Number + - name: y2 + description: '' + type: Number + - name: z2 + description: | +

the z-coordinate of the second point.

+ type: Number + - name: x3 + description: '' + type: Number + - name: y3 + description: '' + type: Number + - name: z3 + description: | +

the z-coordinate of the third point.

+ type: Number + - name: x4 + description: '' + type: Number + - name: y4 + description: '' + type: Number + - name: z4 + description: | +

the z-coordinate of the fourth point.

+ type: Number + - name: detailX + description: '' + type: Integer + optional: true + - name: detailY + description: '' + type: Integer + optional: true + chainable: 1 +chainable: true +--- + + +# quad diff --git a/src/content/reference/en/p5 copy/quadraticVertex.mdx b/src/content/reference/en/p5 copy/quadraticVertex.mdx new file mode 100644 index 0000000000..e319e38769 --- /dev/null +++ b/src/content/reference/en/p5 copy/quadraticVertex.mdx @@ -0,0 +1,303 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L1600 +title: quadraticVertex +module: Shape +submodule: Vertex +file: src/core/shape/vertex.js +description: > +

Adds a quadratic Bézier curve segment to a custom shape.

+ +

quadraticVertex() adds a curved segment to custom shapes. The + Bézier + + curve segments it creates are similar to those made by the + + bezierVertex() function. + + quadraticVertex() must be called between the + + beginShape() and + + endShape() functions. The curved segment + uses + + the previous vertex as the first anchor point, so there must be at least + + one call to vertex() before + quadraticVertex() can + + be used.

+ +

The first two parameters, cx and cy, set the + curve’s control point. + + The control point "pulls" the curve towards its.

+ +

The last two parameters, x3, and y3, set the last + anchor point. The + + last anchor point is where the curve ends.

+ +

Bézier curves can also be drawn in 3D using WebGL mode. The 3D version of + + bezierVertex() has eight arguments because each point has x-, y-, + and + + z-coordinates.

+ +

Note: quadraticVertex() won’t work when an argument is passed + to + + beginShape().

+line: 1600 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the curve. + noFill(); + + // Draw the curve. + beginShape(); + vertex(20, 20); + quadraticVertex(80, 20, 50, 50); + endShape(); + + describe('A black curve drawn on a gray square. The curve starts at the top-left corner and ends at the center.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw the curve. + noFill(); + beginShape(); + vertex(20, 20); + quadraticVertex(80, 20, 50, 50); + endShape(); + + // Draw red lines from the anchor points to the control point. + stroke(255, 0, 0); + line(20, 20, 80, 20); + line(50, 50, 80, 20); + + // Draw the anchor points in black. + strokeWeight(5); + stroke(0); + point(20, 20); + point(50, 50); + + // Draw the control point in red. + stroke(255, 0, 0); + point(80, 20); + + describe('A black curve that starts at the top-left corner and ends at the center. Its anchor and control points are marked with dots. Red lines connect both anchor points to the control point.'); + } + +
+ +
+ + // Click the mouse near the red dot in the top-right corner + // and drag to change the curve's shape. + + let x2 = 80; + let y2 = 20; + let isChanging = false; + + function setup() { + createCanvas(100, 100); + + describe('A black curve that starts at the top-left corner and ends at the center. Its anchor and control points are marked with dots. Red lines connect both anchor points to the control point.'); + } + + function draw() { + background(200); + + // Style the curve. + noFill(); + strokeWeight(1); + stroke(0); + + // Draw the curve. + beginShape(); + vertex(20, 20); + quadraticVertex(x2, y2, 50, 50); + endShape(); + + // Draw red lines from the anchor points to the control point. + stroke(255, 0, 0); + line(20, 20, x2, y2); + line(50, 50, x2, y2); + + // Draw the anchor points in black. + strokeWeight(5); + stroke(0); + point(20, 20); + point(50, 50); + + // Draw the control point in red. + stroke(255, 0, 0); + point(x2, y2); + } + + // Start changing the first control point if the user clicks near it. + function mousePressed() { + if (dist(mouseX, mouseY, x2, y2) < 20) { + isChanging = true; + } + } + + // Stop changing the first control point when the user releases the mouse. + function mouseReleased() { + isChanging = false; + } + + // Update the first control point while the user drags the mouse. + function mouseDragged() { + if (isChanging === true) { + x2 = mouseX; + y2 = mouseY; + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + beginShape(); + + // Add the curved segments. + vertex(20, 20); + quadraticVertex(80, 20, 50, 50); + quadraticVertex(20, 80, 80, 80); + + // Add the straight segments. + vertex(80, 10); + vertex(20, 10); + vertex(20, 20); + + // Stop drawing the shape. + endShape(); + + describe('A white puzzle piece drawn on a gray background.'); + } + +
+ +
+ + // Click the and drag the mouse to view the scene from a different angle. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white puzzle piece on a dark gray background. When the user clicks and drags the scene, the outline of a second puzzle piece is revealed.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the first puzzle piece. + noStroke(); + fill(255); + + // Draw the first puzzle piece. + beginShape(); + vertex(-30, -30, 0); + quadraticVertex(30, -30, 0, 0, 0, 0); + quadraticVertex(-30, 30, 0, 30, 30, 0); + vertex(30, -40, 0); + vertex(-30, -40, 0); + vertex(-30, -30, 0); + endShape(); + + // Style the second puzzle piece. + stroke(255); + noFill(); + + // Draw the second puzzle piece. + beginShape(); + vertex(-30, -30, -20); + quadraticVertex(30, -30, -20, 0, 0, -20); + quadraticVertex(-30, 30, -20, 30, 30, -20); + vertex(30, -40, -20); + vertex(-30, -40, -20); + vertex(-30, -30, -20); + endShape(); + } + +
+class: p5 +overloads: + - line: 1600 + params: + - name: cx + description: | +

x-coordinate of the control point.

+ type: Number + - name: cy + description: | +

y-coordinate of the control point.

+ type: Number + - name: x3 + description: | +

x-coordinate of the anchor point.

+ type: Number + - name: y3 + description: | +

y-coordinate of the anchor point.

+ type: Number + chainable: 1 + - line: 1832 + params: + - name: cx + description: '' + type: Number + - name: cy + description: '' + type: Number + - name: cz + description: | +

z-coordinate of the control point.

+ type: Number + - name: x3 + description: '' + type: Number + - name: y3 + description: '' + type: Number + - name: z3 + description: | +

z-coordinate of the anchor point.

+ type: Number +chainable: true +--- + + +# quadraticVertex diff --git a/src/content/reference/en/p5 copy/radians.mdx b/src/content/reference/en/p5 copy/radians.mdx new file mode 100644 index 0000000000..da0adc1ff7 --- /dev/null +++ b/src/content/reference/en/p5 copy/radians.mdx @@ -0,0 +1,53 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L521 +title: radians +module: Math +submodule: Trigonometry +file: src/math/trigonometry.js +description: | +

Converts an angle measured in degrees to its value in radians.

+

Degrees and radians are both units for measuring angles. There are 360˚ in + one full rotation. A full rotation is 2 × π (about 6.28) radians.

+

The same angle can be expressed in with either unit. For example, 90° is a + quarter of a full rotation. The same angle is 2 × π ÷ 4 + (about 1.57) radians.

+line: 521 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Calculate the angle conversion. + let deg = 45; + let rad = radians(deg); + + // Display the angle conversion. + text(`${deg}˚ = ${round(rad, 3)} rad`, 10, 50); + + describe('The text "45˚ = 0.785 rad".'); + } + +
+class: p5 +params: + - name: degrees + description: | +

degree value to convert to radians.

+ type: Number +return: + description: converted angle. + type: Number +chainable: false +--- + + +# radians diff --git a/src/content/reference/en/p5 copy/random.mdx b/src/content/reference/en/p5 copy/random.mdx new file mode 100644 index 0000000000..aef8e546e8 --- /dev/null +++ b/src/content/reference/en/p5 copy/random.mdx @@ -0,0 +1,48 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/random.js#L86 +title: random +module: Math +submodule: Random +file: src/math/random.js +description: "

Returns a random number or a random element from an array.

\n

random() follows uniform distribution, which means that all outcomes are\nequally likely. When random() is used to generate numbers, all\nnumbers in the output range are equally likely to be returned. When\nrandom() is used to select elements from an array, all elements are\nequally likely to be chosen.

\n

By default, random() produces different results each time a sketch runs.\nThe randomSeed() function can be used to\ngenerate the same sequence of numbers or choices each time a sketch runs.

\n

The version of random() with no parameters returns a random number from 0\nup to but not including 1.

\n

The version of random() with one parameter works one of two ways. If the\nargument passed is a number, random() returns a random number from 0 up\nto but not including the number. For example, calling random(5) returns\nvalues between 0 and 5. If the argument passed is an array, random()\nreturns a random element from that array. For example, calling\nrandom(['\U0001F981', '\U0001F42F', '\U0001F43B']) returns either a lion, tiger, or bear emoji.

\n

The version of random() with two parameters returns a random number from\na given range. The arguments passed set the range's lower and upper bounds.\nFor example, calling random(-5, 10.2) returns values from -5 up to but\nnot including 10.2.

\n" +line: 86 +isConstructor: false +itemtype: method +example: + - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Get random coordinates between 0 and 100.\n let x = random(0, 100);\n let y = random(0, 100);\n\n // Draw a point.\n strokeWeight(5);\n point(x, y);\n\n describe('A black dot appears in a random position on a gray square.');\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Get random coordinates between 0 and 100.\n let x = random(100);\n let y = random(100);\n\n // Draw the point.\n strokeWeight(5);\n point(x, y);\n\n describe('A black dot appears in a random position on a gray square.');\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Create an array of emoji strings.\n let animals = ['\U0001F981', '\U0001F42F', '\U0001F43B'];\n\n // Choose a random element from the array.\n let choice = random(animals);\n\n // Style the text.\n textAlign(CENTER);\n textSize(20);\n\n // Display the emoji.\n text(choice, 50, 50);\n\n describe('An animal face is displayed at random. Either a lion, tiger, or bear.');\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Slow the frame rate.\n frameRate(5);\n\n describe('A black dot moves around randomly on a gray square.');\n}\n\nfunction draw() {\n background(200);\n\n // Get random coordinates between 0 and 100.\n let x = random(100);\n let y = random(100);\n\n // Draw the point.\n strokeWeight(5);\n point(x, y);\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Slow the frame rate.\n frameRate(5);\n\n describe('A black dot moves around randomly in the middle of a gray square.');\n}\n\nfunction draw() {\n background(200);\n\n // Get random coordinates between 45 and 55.\n let x = random(45, 55);\n let y = random(45, 55);\n\n // Draw the point.\n strokeWeight(5);\n point(x, y);\n}\n\n
\n\n
\n\nlet x = 50;\nlet y = 50;\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n describe('A black dot moves around randomly leaving a trail.');\n}\n\nfunction draw() {\n // Update x and y randomly.\n x += random(-1, 1);\n y += random(-1, 1);\n\n // Draw the point.\n point(x, y);\n}\n\n
" +class: p5 +return: + description: random number. + type: Number +overloads: + - line: 86 + params: + - name: min + description: | +

lower bound (inclusive).

+ type: Number + optional: true + - name: max + description: | +

upper bound (exclusive).

+ type: Number + optional: true + return: + description: random number. + type: Number + - line: 259 + params: + - name: choices + description: | +

array to choose from.

+ type: Array + return: + description: random element from the array. + type: '*' +chainable: false +--- + + +# random diff --git a/src/content/reference/en/p5 copy/randomGaussian.mdx b/src/content/reference/en/p5 copy/randomGaussian.mdx new file mode 100644 index 0000000000..24893f378b --- /dev/null +++ b/src/content/reference/en/p5 copy/randomGaussian.mdx @@ -0,0 +1,104 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/random.js#L292 +title: randomGaussian +module: Math +submodule: Random +file: src/math/random.js +description: > +

Returns a random number fitting a Gaussian, or normal, distribution.

+ +

Normal distributions look like bell curves when plotted. Values from a + + normal distribution cluster around a central value called the mean. The + + cluster's standard deviation describes its spread.

+ +

By default, randomGaussian() produces different results each + time a + + sketch runs. The randomSeed() function + can be + + used to generate the same sequence of numbers each time a sketch runs.

+ +

There's no minimum or maximum value that randomGaussian() + might return. + + Values far from the mean are very unlikely and values near the mean are + + very likely.

+ +

The version of randomGaussian() with no parameters returns + values with a + + mean of 0 and standard deviation of 1.

+ +

The version of randomGaussian() with one parameter interprets + the + + argument passed as the mean. The standard deviation is 1.

+ +

The version of randomGaussian() with two parameters interprets + the first + + argument passed as the mean and the second as the standard deviation.

+line: 292 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + describe('Three horizontal black lines are filled in randomly. The top line spans entire canvas. The middle line is very short. The bottom line spans two-thirds of the canvas.'); + } + + function draw() { + // Style the circles. + noStroke(); + fill(0, 10); + + // Uniform distribution between 0 and 100. + let x = random(100); + let y = 25; + circle(x, y, 5); + + // Gaussian distribution with a mean of 50 and sd of 1. + x = randomGaussian(50); + y = 50; + circle(x, y, 5); + + // Gaussian distribution with a mean of 50 and sd of 10. + x = randomGaussian(50, 10); + y = 75; + circle(x, y, 5); + } + +
+class: p5 +params: + - name: mean + description: | +

mean.

+ type: Number + optional: true + - name: sd + description: | +

standard deviation.

+ type: Number + optional: true +return: + description: random number. + type: Number +chainable: false +--- + + +# randomGaussian diff --git a/src/content/reference/en/p5 copy/randomSeed.mdx b/src/content/reference/en/p5 copy/randomSeed.mdx new file mode 100644 index 0000000000..dbd1a6ae3d --- /dev/null +++ b/src/content/reference/en/p5 copy/randomSeed.mdx @@ -0,0 +1,71 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/random.js#L37 +title: randomSeed +module: Math +submodule: Random +file: src/math/random.js +description: > +

Sets the seed value for the random() + and + + randomGaussian() functions.

+ +

By default, random() and + + randomGaussian() produce different + + results each time a sketch is run. Calling randomSeed() with a + constant + + argument, such as randomSeed(99), makes these functions produce + the same + + results each time a sketch is run.

+line: 37 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Get random coordinates. + let x = random(0, 100); + let y = random(0, 100); + + // Draw the white circle. + circle(x, y, 10); + + // Set a random seed for consistency. + randomSeed(99); + + // Get random coordinates. + x = random(0, 100); + y = random(0, 100); + + // Draw the black circle. + fill(0); + circle(x, y, 10); + + describe('A white circle appears at a random position. A black circle appears at (27.4, 25.8).'); + } + +
+class: p5 +params: + - name: seed + description: | +

seed value.

+ type: Number +chainable: false +--- + + +# randomSeed diff --git a/src/content/reference/en/p5 copy/rect.mdx b/src/content/reference/en/p5 copy/rect.mdx new file mode 100644 index 0000000000..6876ab536d --- /dev/null +++ b/src/content/reference/en/p5 copy/rect.mdx @@ -0,0 +1,209 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L1091 +title: rect +module: Shape +submodule: 2D Primitives +file: src/core/shape/2d_primitives.js +description: > +

Draws a rectangle.

+ +

A rectangle is a four-sided shape defined by the x, + y, w, and h + + parameters. x and y set the location of its top-left + corner. w sets + + its width and h sets its height. Every angle in the rectangle + measures + + 90˚. See rectMode() for other ways to + define + + rectangles.

+ +

The version of rect() with five parameters creates a rounded + rectangle. The + + fifth parameter sets the radius for all four corners.

+ +

The version of rect() with eight parameters also creates a + rounded + + rectangle. Each of the last four parameters set the radius of a corner. The + + radii start with the top-left corner and move clockwise around the + + rectangle. If any of these parameters are omitted, they are set to the + + value of the last radius that was set.

+line: 1091 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + rect(30, 20, 55, 55); + + describe('A white square with a black outline on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + rect(30, 20, 55, 40); + + describe('A white rectangle with a black outline on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Give all corners a radius of 20. + rect(30, 20, 55, 50, 20); + + describe('A white rectangle with a black outline and round edges on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Give each corner a unique radius. + rect(30, 20, 55, 50, 20, 15, 10, 5); + + describe('A white rectangle with a black outline and round edges of different radii.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + rect(-20, -30, 55, 55); + + describe('A white square with a black outline on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white square spins around on gray canvas.'); + } + + function draw() { + background(200); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Draw the rectangle. + rect(-20, -30, 55, 55); + } + +
+class: p5 +overloads: + - line: 1091 + params: + - name: x + description: | +

x-coordinate of the rectangle.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the rectangle.

+ type: Number + - name: w + description: | +

width of the rectangle.

+ type: Number + - name: h + description: | +

height of the rectangle.

+ type: Number + optional: true + - name: tl + description: | +

optional radius of top-left corner.

+ type: Number + optional: true + - name: tr + description: | +

optional radius of top-right corner.

+ type: Number + optional: true + - name: br + description: | +

optional radius of bottom-right corner.

+ type: Number + optional: true + - name: bl + description: | +

optional radius of bottom-left corner.

+ type: Number + optional: true + chainable: 1 + - line: 1214 + params: + - name: x + description: '' + type: Number + - name: 'y' + description: '' + type: Number + - name: w + description: '' + type: Number + - name: h + description: '' + type: Number + - name: detailX + description: | +

number of segments in the x-direction (for WebGL mode).

+ type: Integer + optional: true + - name: detailY + description: | +

number of segments in the y-direction (for WebGL mode).

+ type: Integer + optional: true + chainable: 1 +chainable: true +--- + + +# rect diff --git a/src/content/reference/en/p5 copy/rectMode.mdx b/src/content/reference/en/p5 copy/rectMode.mdx new file mode 100644 index 0000000000..5d444cb16e --- /dev/null +++ b/src/content/reference/en/p5 copy/rectMode.mdx @@ -0,0 +1,142 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L184 +title: rectMode +module: Shape +submodule: Attributes +file: src/core/shape/attributes.js +description: > +

Changes where rectangles and squares are drawn.

+ +

By default, the first two parameters of + + rect() and square(), + + are the x- and y-coordinates of the shape's upper left corner. The next + parameters set + + the shape's width and height. This is the same as calling + + rectMode(CORNER).

+ +

rectMode(CORNERS) also uses the first two parameters as the + location of + + one of the corners. The next parameters are the location of the opposite + + corner. This mode only works for rect().

+ +

rectMode(CENTER) uses the first two parameters as the x- and + + y-coordinates of the shape's center. The next parameters are its width and + + height.

+ +

rectMode(RADIUS) also uses the first two parameters as the x- + and + + y-coordinates of the shape's center. The next parameters are + + half of the shape's width and height.

+ +

The argument passed to rectMode() must be written in ALL CAPS + because the + + constants CENTER, RADIUS, CORNER, and + CORNERS are defined this way. + + JavaScript is a case-sensitive language.

+line: 184 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + rectMode(CORNER); + fill(255); + rect(25, 25, 50, 50); + + rectMode(CORNERS); + fill(100); + rect(25, 25, 50, 50); + + describe('A small gray square drawn at the top-left corner of a white square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + rectMode(RADIUS); + fill(255); + rect(50, 50, 30, 30); + + rectMode(CENTER); + fill(100); + rect(50, 50, 30, 30); + + describe('A small gray square drawn at the center of a white square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + rectMode(CORNER); + fill(255); + square(25, 25, 50); + + describe('A white square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + rectMode(RADIUS); + fill(255); + square(50, 50, 30); + + rectMode(CENTER); + fill(100); + square(50, 50, 30); + + describe('A small gray square drawn at the center of a white square.'); + } + +
+class: p5 +params: + - name: mode + description: | +

either CORNER, CORNERS, CENTER, or RADIUS

+ type: Constant +chainable: true +--- + + +# rectMode diff --git a/src/content/reference/en/p5 copy/red.mdx b/src/content/reference/en/p5 copy/red.mdx new file mode 100644 index 0000000000..819478b246 --- /dev/null +++ b/src/content/reference/en/p5 copy/red.mdx @@ -0,0 +1,158 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L1279 +title: red +module: Color +submodule: Creating & Reading +file: src/color/creating_reading.js +description: > +

Gets the red value of a color.

+ +

red() extracts the red value from a + + p5.Color object, an array of color + components, or + + a CSS color string.

+ +

By default, red() returns a color's red value in the range 0 + + to 255. If the colorMode() is set to + RGB, it + + returns the red value in the given range.

+line: 1279 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object. + let c = color(175, 100, 220); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'redValue' to 175. + let redValue = red(c); + + // Draw the right rectangle. + fill(redValue, 0, 0); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is red.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a color array. + let c = [175, 100, 220]; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'redValue' to 175. + let redValue = red(c); + + // Draw the right rectangle. + fill(redValue, 0, 0); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is red.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a CSS color string. + let c = 'rgb(175, 100, 220)'; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'redValue' to 175. + let redValue = red(c); + + // Draw the right rectangle. + fill(redValue, 0, 0); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is red.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use RGB color with values in the range 0-100. + colorMode(RGB, 100); + + // Create a p5.Color object. + let c = color(69, 39, 86); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'redValue' to 69. + let redValue = red(c); + + // Draw the right rectangle. + fill(redValue, 0, 0); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is light purple and the right one is red.'); + } + +
+class: p5 +params: + - name: color + description: | +

p5.Color object, array of + color components, or CSS color string.

+ type: 'p5.Color|Number[]|String' +return: + description: the red value. + type: Number +chainable: false +--- + + +# red diff --git a/src/content/reference/en/p5 copy/redraw.mdx b/src/content/reference/en/p5 copy/redraw.mdx new file mode 100644 index 0000000000..6519f322f0 --- /dev/null +++ b/src/content/reference/en/p5 copy/redraw.mdx @@ -0,0 +1,117 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L838 +title: redraw +module: Structure +submodule: Structure +file: src/core/structure.js +description: > +

Runs the code in draw() once.

+ +

By default, draw() tries to run 60 times + per + + second. Calling noLoop() stops + + draw() from repeating. Calling + redraw() will + + execute the code in the draw() function a + set + + number of times.

+ +

The parameter, n, is optional. If a number is passed, as in + redraw(5), + + then the draw loop will run the given number of times. By default, + n is + + 1.

+line: 838 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Double-click the canvas to move the circle. + + let x = 0; + + function setup() { + createCanvas(100, 100); + + // Turn off the draw loop. + noLoop(); + + describe( + 'A white half-circle on the left edge of a gray square. The circle moves a little to the right when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Draw the circle. + circle(x, 50, 20); + + // Increment x. + x += 5; + } + + // Run the draw loop when the user double-clicks. + function doubleClicked() { + redraw(); + } + +
+ +
+ + // Double-click the canvas to move the circle. + + let x = 0; + + function setup() { + createCanvas(100, 100); + + // Turn off the draw loop. + noLoop(); + + describe( + 'A white half-circle on the left edge of a gray square. The circle hops to the right when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Draw the circle. + circle(x, 50, 20); + + // Increment x. + x += 5; + } + + // Run the draw loop three times when the user double-clicks. + function doubleClicked() { + redraw(3); + } + +
+class: p5 +params: + - name: 'n' + description: > +

number of times to run draw(). Defaults to + 1.

+ type: Integer + optional: true +chainable: false +--- + + +# redraw diff --git a/src/content/reference/en/p5 copy/remove.mdx b/src/content/reference/en/p5 copy/remove.mdx new file mode 100644 index 0000000000..552822f5a3 --- /dev/null +++ b/src/content/reference/en/p5 copy/remove.mdx @@ -0,0 +1,57 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L559 +title: remove +module: Structure +submodule: Structure +file: src/core/main.js +description: > +

Removes the sketch from the web page.

+ +

Calling remove() stops the draw loop and removes any HTML + elements + + created by the sketch, including the canvas. A new sketch can be + + created by using the p5() constructor, as in + + new p5().

+line: 559 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Double-click to remove the canvas. + + function setup() { + createCanvas(100, 100); + + describe( + 'A white circle on a gray background. The circle follows the mouse as the user moves. The sketch disappears when the user double-clicks.' + ); + } + + function draw() { + // Paint the background repeatedly. + background(200); + + // Draw circles repeatedly. + circle(mouseX, mouseY, 40); + } + + // Remove the sketch when the user double-clicks. + function doubleClicked() { + remove(); + } + +
+class: p5 +chainable: false +--- + + +# remove diff --git a/src/content/reference/en/p5 copy/removeElements.mdx b/src/content/reference/en/p5 copy/removeElements.mdx new file mode 100644 index 0000000000..51e712026b --- /dev/null +++ b/src/content/reference/en/p5 copy/removeElements.mdx @@ -0,0 +1,85 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L256 +title: removeElements +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Removes all elements created by p5.js, including any event handlers.

+ +

There are two exceptions: + + canvas elements created by createCanvas() + + and p5.Render objects created by + + createGraphics().

+line: 256 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a paragraph element and place + // it in the middle of the canvas. + let p = createP('p5*js'); + p.position(25, 25); + + describe('A gray square with the text "p5*js" written in its center. The text disappears when the mouse is pressed.'); + } + + // Remove all elements when the mouse is pressed. + function mousePressed() { + removeElements(); + } + +
+ +
+ + let slider; + + function setup() { + createCanvas(100, 100); + + // Create a paragraph element and place + // it at the top of the canvas. + let p = createP('p5*js'); + p.position(25, 25); + + // Create a slider element and place it + // beneath the canvas. + slider = createSlider(0, 255, 200); + slider.position(0, 100); + + describe('A gray square with the text "p5*js" written in its center and a range slider beneath it. The square changes color when the slider is moved. The text and slider disappear when the square is double-clicked.'); + } + + function draw() { + // Use the slider value to change the background color. + let g = slider.value(); + background(g); + } + + // Remove all elements when the mouse is double-clicked. + function doubleClicked() { + removeElements(); + } + +
+class: p5 +chainable: false +--- + + +# removeElements diff --git a/src/content/reference/en/p5 copy/removeItem.mdx b/src/content/reference/en/p5 copy/removeItem.mdx new file mode 100644 index 0000000000..ba091b00b4 --- /dev/null +++ b/src/content/reference/en/p5 copy/removeItem.mdx @@ -0,0 +1,97 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/data/local_storage.js#L380 +title: removeItem +module: Data +submodule: LocalStorage +file: src/data/local_storage.js +description: > +

Removes an item from the web browser's local storage.

+ +

Web browsers can save small amounts of data using the built-in + + localStorage object. + + Data stored in localStorage can be retrieved at any point, even + after + + refreshing a page or restarting the browser. Data are stored as key-value + + pairs.

+ +

storeItem() makes it easy to store + values in + + localStorage and removeItem() makes it easy to + delete them.

+ +

The parameter, key, is the name of the value to remove as a + string. For + + example, calling removeItem('size') removes the item with the key + size.

+ +

Note: Sensitive data such as passwords or personal information shouldn't be + + stored in localStorage.

+line: 380 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Double-click to remove an item from localStorage. + + function setup() { + createCanvas(100, 100); + + // Store the player's name. + storeItem('name', 'Feist'); + + // Store the player's score. + storeItem('score', 1234); + + describe( + 'The text "Feist: 1234" written in black on a gray background. The text "Feist: null" appears when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(14); + + // Retrieve the name. + let name = getItem('name'); + + // Retrieve the score. + let score = getItem('score'); + + // Display the score. + text(`${name}: ${score}`, 50, 50); + } + + // Remove the word from localStorage when the user double-clicks. + function doubleClicked() { + removeItem('score'); + } + +
+class: p5 +params: + - name: key + description: | +

name of the value to remove.

+ type: String +chainable: false +--- + + +# removeItem diff --git a/src/content/reference/en/p5 copy/requestPointerLock.mdx b/src/content/reference/en/p5 copy/requestPointerLock.mdx new file mode 100644 index 0000000000..621ce063ce --- /dev/null +++ b/src/content/reference/en/p5 copy/requestPointerLock.mdx @@ -0,0 +1,85 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1880 +title: requestPointerLock +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

Locks the mouse pointer to its current position and makes it invisible.

+ +

requestPointerLock() allows the mouse to move forever without + leaving the + + screen. Calling requestPointerLock() locks the values of + + mouseX, mouseY, + + pmouseX, and pmouseY. + + movedX and movedY + + continue updating and can be used to get the distance the mouse moved since + + the last frame was drawn. Calling + + exitPointerLock() resumes + updating the + + mouse system variables.

+ +

Note: Most browsers require an input, such as a click, before calling + + requestPointerLock(). It’s recommended to call + requestPointerLock() in + + an event function such as doubleClicked().

+line: 1880 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let score = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with the text "Score: X" at its center. The score increases when the user moves the mouse upward. It decreases when the user moves the mouse downward.' + ); + } + + function draw() { + background(200); + + // Update the score. + score -= movedY; + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the score. + text(`Score: ${score}`, 50, 50); + } + + // Lock the pointer when the user double-clicks. + function doubleClicked() { + requestPointerLock(); + } + +
+class: p5 +chainable: false +--- + + +# requestPointerLock diff --git a/src/content/reference/en/p5 copy/resetMatrix.mdx b/src/content/reference/en/p5 copy/resetMatrix.mdx new file mode 100644 index 0000000000..af797b49db --- /dev/null +++ b/src/content/reference/en/p5 copy/resetMatrix.mdx @@ -0,0 +1,52 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L246 +title: resetMatrix +module: Transform +submodule: Transform +file: src/core/transform.js +description: | +

Clears all transformations applied to the coordinate system.

+line: 246 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'Two circles drawn on a gray background. A blue circle is at the top-left and a red circle is at the bottom-right.' + ); + } + + function draw() { + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Draw a blue circle at the coordinates (25, 25). + fill('blue'); + circle(25, 25, 20); + + // Clear all transformations. + // The origin is now at the top-left corner. + resetMatrix(); + + // Draw a red circle at the coordinates (25, 25). + fill('red'); + circle(25, 25, 20); + } + +
+class: p5 +chainable: true +--- + + +# resetMatrix diff --git a/src/content/reference/en/p5 copy/resetShader.mdx b/src/content/reference/en/p5 copy/resetShader.mdx new file mode 100644 index 0000000000..850ca0773c --- /dev/null +++ b/src/content/reference/en/p5 copy/resetShader.mdx @@ -0,0 +1,95 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1628 +title: resetShader +module: 3D +submodule: Material +file: src/webgl/material.js +description: | +

Restores the default shaders.

+

resetShader() deactivates any shaders previously applied by + shader().

+

Note: Shaders can only be used in WebGL mode.

+line: 1628 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Create a string with the vertex shader program. + // The vertex shader is called for each vertex. + let vertSrc = ` + attribute vec3 aPosition; + attribute vec2 aTexCoord; + uniform mat4 uProjectionMatrix; + uniform mat4 uModelViewMatrix; + varying vec2 vTexCoord; + + void main() { + vTexCoord = aTexCoord; + vec4 position = vec4(aPosition, 1.0); + gl_Position = uProjectionMatrix * uModelViewMatrix * position; + } + `; + + // Create a string with the fragment shader program. + // The fragment shader is called for each pixel. + let fragSrc = ` + precision mediump float; + varying vec2 vTexCoord; + + void main() { + vec2 uv = vTexCoord; + vec3 color = vec3(uv.x, uv.y, min(uv.x + uv.y, 1.0)); + gl_FragColor = vec4(color, 1.0); + } + `; + + let myShader; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Shader object. + myShader = createShader(vertSrc, fragSrc); + + describe( + 'Two rotating cubes on a gray background. The left one has a blue-purple gradient on each face. The right one is red.' + ); + } + + function draw() { + background(200); + + // Draw a box using the p5.Shader. + // shader() sets the active shader to myShader. + shader(myShader); + push(); + translate(-25, 0, 0); + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + box(width / 4); + pop(); + + // Draw a box using the default fill shader. + // resetShader() restores the default fill shader. + resetShader(); + fill(255, 0, 0); + push(); + translate(25, 0, 0); + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + box(width / 4); + pop(); + } + +
+class: p5 +chainable: true +--- + + +# resetShader diff --git a/src/content/reference/en/p5 copy/resizeCanvas.mdx b/src/content/reference/en/p5 copy/resizeCanvas.mdx new file mode 100644 index 0000000000..fde0561563 --- /dev/null +++ b/src/content/reference/en/p5 copy/resizeCanvas.mdx @@ -0,0 +1,133 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L221 +title: resizeCanvas +module: Rendering +submodule: Rendering +file: src/core/rendering.js +description: > +

Resizes the canvas to a given width and height.

+ +

resizeCanvas() immediately clears the canvas and calls + + redraw(). It's common to call + resizeCanvas() + + within the body of windowResized() + like + + so:

+ +
function windowResized() {
+    resizeCanvas(windowWidth, windowHeight);
+  }
+
+  
+ +

The first two parameters, width and height, set + the dimensions of the + + canvas. They also the values of the width + and + + height system variables. For example, + calling + + resizeCanvas(300, 500) resizes the canvas to 300×500 pixels, then + sets + + width to 300 and + + height 500.

+ +

The third parameter, noRedraw, is optional. If + true is passed, as in + + resizeCanvas(300, 500, true), then the canvas will be canvas to + 300×500 + + pixels but the redraw() function won't be + called + + immediately. By default, redraw() is + called + + immediately when resizeCanvas() finishes executing.

+line: 221 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Double-click to resize the canvas. + + function setup() { + createCanvas(100, 100); + + describe( + 'A white circle drawn on a gray background. The canvas shrinks by half the first time the user double-clicks.' + ); + } + + function draw() { + background(180); + + // Draw a circle at the center of the canvas. + circle(width / 2, height / 2, 20); + } + + // Resize the canvas when the user double-clicks. + function doubleClicked() { + resizeCanvas(50, 50); + } + +
+ +
+ + // Resize the web browser to change the canvas size. + + function setup() { + createCanvas(windowWidth, windowHeight); + + describe('A white circle drawn on a gray background.'); + } + + function draw() { + background(180); + + // Draw a circle at the center of the canvas. + circle(width / 2, height / 2, 20); + } + + // Always resize the canvas to fill the browser window. + function windowResized() { + resizeCanvas(windowWidth, windowHeight); + } + +
+class: p5 +params: + - name: width + description: | +

width of the canvas.

+ type: Number + - name: height + description: | +

height of the canvas.

+ type: Number + - name: noRedraw + description: | +

whether to delay calling + redraw(). Defaults + to false.

+ type: Boolean + optional: true +chainable: false +--- + + +# resizeCanvas diff --git a/src/content/reference/en/p5 copy/reverse.mdx b/src/content/reference/en/p5 copy/reverse.mdx new file mode 100644 index 0000000000..bf7a6571ac --- /dev/null +++ b/src/content/reference/en/p5 copy/reverse.mdx @@ -0,0 +1,43 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L141 +title: reverse +module: Data +submodule: Array Functions +file: src/utilities/array_functions.js +description: | +

Reverses the order of an array, maps to Array.reverse()

+line: 141 +deprecated: >- + Use array.reverse() + instead. +isConstructor: false +itemtype: method +example: + - |- + +
+ function setup() { + let myArray = ['A', 'B', 'C']; + print(myArray); // ['A','B','C'] + + reverse(myArray); + print(myArray); // ['C','B','A'] + } +
+class: p5 +params: + - name: list + description: | +

Array to reverse

+ type: Array +return: + description: the reversed list + type: Array +chainable: false +--- + + +# reverse diff --git a/src/content/reference/en/p5 copy/rotate.mdx b/src/content/reference/en/p5 copy/rotate.mdx new file mode 100644 index 0000000000..bbb4f8e5f8 --- /dev/null +++ b/src/content/reference/en/p5 copy/rotate.mdx @@ -0,0 +1,226 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L289 +title: rotate +module: Transform +submodule: Transform +file: src/core/transform.js +description: > +

Rotates the coordinate system.

+ +

By default, the positive x-axis points to the right and the positive y-axis + + points downward. The rotate() function changes this orientation + by + + rotating the coordinate system about the origin. Everything drawn after + + rotate() is called will appear to be rotated.

+ +

The first parameter, angle, is the amount to rotate. For + example, calling + + rotate(1) rotates the coordinate system clockwise 1 radian which + is + + nearly 57˚. rotate() interprets angle values using the current + + angleMode().

+ +

The second parameter, axis, is optional. It's used to orient + 3D rotations + + in WebGL mode. If a p5.Vector is passed, + as in + + rotate(QUARTER_PI, myVector), then the coordinate system will + rotate + + QUARTER_PI radians about myVector. If an array of + vector components is + + passed, as in rotate(QUARTER_PI, [1, 0, 0]), then the coordinate + system + + will rotate QUARTER_PI radians about a vector with the components + + [1, 0, 0].

+ +

By default, transformations accumulate. For example, calling + rotate(1) + + twice has the same effect as calling rotate(2) once. The + + push() and pop() functions + + can be used to isolate transformations within distinct drawing groups.

+ +

Note: Transformations are reset at the beginning of the draw loop. Calling + + rotate(1) inside the draw() + function won't cause + + shapes to spin.

+line: 289 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe( + "A white rectangle on a gray background. The rectangle's long axis runs from top-left to bottom-right." + ); + } + + function draw() { + background(200); + + // Rotate the coordinate system 1/8 turn. + rotate(QUARTER_PI); + + // Draw a rectangle at coordinates (50, 0). + rect(50, 0, 40, 20); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + "A white rectangle on a gray background. The rectangle's long axis runs from top-left to bottom-right." + ); + } + + function draw() { + background(200); + + // Rotate the coordinate system 1/16 turn. + rotate(QUARTER_PI / 2); + + // Rotate the coordinate system another 1/16 turn. + rotate(QUARTER_PI / 2); + + // Draw a rectangle at coordinates (50, 0). + rect(50, 0, 40, 20); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Use degrees. + angleMode(DEGREES); + + describe( + "A white rectangle on a gray background. The rectangle's long axis runs from top-left to bottom-right." + ); + } + + function draw() { + background(200); + + // Rotate the coordinate system 1/8 turn. + rotate(45); + + // Draw a rectangle at coordinates (50, 0). + rect(50, 0, 40, 20); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'A white rectangle on a gray background. The rectangle rotates slowly about the top-left corner. It disappears and reappears periodically.' + ); + } + + function draw() { + background(200); + + // Rotate the coordinate system a little more each frame. + let angle = frameCount * 0.01; + rotate(angle); + + // Draw a rectangle at coordinates (50, 0). + rect(50, 0, 40, 20); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe("A cube on a gray background. The cube's front face points to the top-right."); + } + + function draw() { + background(200); + + // Rotate the coordinate system 1/8 turn about + // the axis [1, 1, 0]. + let axis = createVector(1, 1, 0); + rotate(QUARTER_PI, axis); + + // Draw a box. + box(); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe("A cube on a gray background. The cube's front face points to the top-right."); + } + + function draw() { + background(200); + + // Rotate the coordinate system 1/8 turn about + // the axis [1, 1, 0]. + let axis = [1, 1, 0]; + rotate(QUARTER_PI, axis); + + // Draw a box. + box(); + } + +
+class: p5 +params: + - name: angle + description: > +

angle of rotation in the current angleMode().

+ type: Number + - name: axis + description: | +

axis to rotate about in 3D.

+ type: 'p5.Vector|Number[]' + optional: true +chainable: true +--- + + +# rotate diff --git a/src/content/reference/en/p5 copy/rotateX.mdx b/src/content/reference/en/p5 copy/rotateX.mdx new file mode 100644 index 0000000000..c519976bce --- /dev/null +++ b/src/content/reference/en/p5 copy/rotateX.mdx @@ -0,0 +1,161 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L470 +title: rotateX +module: Transform +submodule: Transform +file: src/core/transform.js +description: > +

Rotates the coordinate system about the x-axis in WebGL mode.

+ +

The parameter, angle, is the amount to rotate. For example, + calling + + rotateX(1) rotates the coordinate system about the x-axis by 1 + radian. + + rotateX() interprets angle values using the current + + angleMode().

+ +

By default, transformations accumulate. For example, calling + rotateX(1) + + twice has the same effect as calling rotateX(2) once. The + + push() and pop() functions + + can be used to isolate transformations within distinct drawing groups.

+ +

Note: Transformations are reset at the beginning of the draw loop. Calling + + rotateX(1) inside the draw() + function won't cause + + shapes to spin.

+line: 470 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system 1/8 turn. + rotateX(QUARTER_PI); + + // Draw a box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system 1/16 turn. + rotateX(QUARTER_PI / 2); + + // Rotate the coordinate system 1/16 turn. + rotateX(QUARTER_PI / 2); + + // Draw a box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + // Use degrees. + angleMode(DEGREES); + + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system 1/8 turn. + rotateX(45); + + // Draw a box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube rotates slowly against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system a little more each frame. + let angle = frameCount * 0.01; + rotateX(angle); + + // Draw a box. + box(); + } + +
+class: p5 +params: + - name: angle + description: > +

angle of rotation in the current angleMode().

+ type: Number +chainable: true +--- + + +# rotateX diff --git a/src/content/reference/en/p5 copy/rotateY.mdx b/src/content/reference/en/p5 copy/rotateY.mdx new file mode 100644 index 0000000000..c7976c5a44 --- /dev/null +++ b/src/content/reference/en/p5 copy/rotateY.mdx @@ -0,0 +1,161 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L606 +title: rotateY +module: Transform +submodule: Transform +file: src/core/transform.js +description: > +

Rotates the coordinate system about the y-axis in WebGL mode.

+ +

The parameter, angle, is the amount to rotate. For example, + calling + + rotateY(1) rotates the coordinate system about the y-axis by 1 + radian. + + rotateY() interprets angle values using the current + + angleMode().

+ +

By default, transformations accumulate. For example, calling + rotateY(1) + + twice has the same effect as calling rotateY(2) once. The + + push() and pop() functions + + can be used to isolate transformations within distinct drawing groups.

+ +

Note: Transformations are reset at the beginning of the draw loop. Calling + + rotateY(1) inside the draw() + function won't cause + + shapes to spin.

+line: 606 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system 1/8 turn. + rotateY(QUARTER_PI); + + // Draw a box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system 1/16 turn. + rotateY(QUARTER_PI / 2); + + // Rotate the coordinate system 1/16 turn. + rotateY(QUARTER_PI / 2); + + // Draw a box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + // Use degrees. + angleMode(DEGREES); + + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system 1/8 turn. + rotateY(45); + + // Draw a box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube rotates slowly against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system a little more each frame. + let angle = frameCount * 0.01; + rotateY(angle); + + // Draw a box. + box(); + } + +
+class: p5 +params: + - name: angle + description: > +

angle of rotation in the current angleMode().

+ type: Number +chainable: true +--- + + +# rotateY diff --git a/src/content/reference/en/p5 copy/rotateZ.mdx b/src/content/reference/en/p5 copy/rotateZ.mdx new file mode 100644 index 0000000000..317bd7fe88 --- /dev/null +++ b/src/content/reference/en/p5 copy/rotateZ.mdx @@ -0,0 +1,161 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L742 +title: rotateZ +module: Transform +submodule: Transform +file: src/core/transform.js +description: > +

Rotates the coordinate system about the z-axis in WebGL mode.

+ +

The parameter, angle, is the amount to rotate. For example, + calling + + rotateZ(1) rotates the coordinate system about the z-axis by 1 + radian. + + rotateZ() interprets angle values using the current + + angleMode().

+ +

By default, transformations accumulate. For example, calling + rotateZ(1) + + twice has the same effect as calling rotateZ(2) once. The + + push() and pop() functions + + can be used to isolate transformations within distinct drawing groups.

+ +

Note: Transformations are reset at the beginning of the draw loop. Calling + + rotateZ(1) inside the draw() + function won't cause + + shapes to spin.

+line: 742 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system 1/8 turn. + rotateZ(QUARTER_PI); + + // Draw a box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system 1/16 turn. + rotateZ(QUARTER_PI / 2); + + // Rotate the coordinate system 1/16 turn. + rotateZ(QUARTER_PI / 2); + + // Draw a box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + // Use degrees. + angleMode(DEGREES); + + describe('A white cube on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system 1/8 turn. + rotateZ(45); + + // Draw a box. + box(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white cube rotates slowly against a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Rotate the coordinate system a little more each frame. + let angle = frameCount * 0.01; + rotateZ(angle); + + // Draw a box. + box(); + } + +
+class: p5 +params: + - name: angle + description: > +

angle of rotation in the current angleMode().

+ type: Number +chainable: true +--- + + +# rotateZ diff --git a/src/content/reference/en/p5 copy/rotationX.mdx b/src/content/reference/en/p5 copy/rotationX.mdx new file mode 100644 index 0000000000..98dfd287dc --- /dev/null +++ b/src/content/reference/en/p5 copy/rotationX.mdx @@ -0,0 +1,45 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L131 +title: rotationX +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: | +

The system variable rotationX always contains the rotation of the + device along the x axis. If the sketch + angleMode() is set to DEGREES, the value will be -180 to 180. If + it is set to RADIANS, the value will be -PI to PI.

+

Note: The order the rotations are called is important, ie. if used + together, it must be called in the order Z-X-Y or there might be + unexpected behaviour.

+line: 131 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + } + + function draw() { + background(200); + //rotateZ(radians(rotationZ)); + rotateX(radians(rotationX)); + //rotateY(radians(rotationY)); + box(200, 200, 200); + describe(`red horizontal line right, green vertical line bottom. + black background.`); + } + +
+class: p5 +type: Number +--- + + +# rotationX diff --git a/src/content/reference/en/p5 copy/rotationY.mdx b/src/content/reference/en/p5 copy/rotationY.mdx new file mode 100644 index 0000000000..f06a033bb7 --- /dev/null +++ b/src/content/reference/en/p5 copy/rotationY.mdx @@ -0,0 +1,45 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L164 +title: rotationY +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: | +

The system variable rotationY always contains the rotation of the + device along the y axis. If the sketch + angleMode() is set to DEGREES, the value will be -90 to 90. If + it is set to RADIANS, the value will be -PI/2 to PI/2.

+

Note: The order the rotations are called is important, ie. if used + together, it must be called in the order Z-X-Y or there might be + unexpected behaviour.

+line: 164 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + } + + function draw() { + background(200); + //rotateZ(radians(rotationZ)); + //rotateX(radians(rotationX)); + rotateY(radians(rotationY)); + box(200, 200, 200); + describe(`red horizontal line right, green vertical line bottom. + black background.`); + } + +
+class: p5 +type: Number +--- + + +# rotationY diff --git a/src/content/reference/en/p5 copy/rotationZ.mdx b/src/content/reference/en/p5 copy/rotationZ.mdx new file mode 100644 index 0000000000..47d6d965aa --- /dev/null +++ b/src/content/reference/en/p5 copy/rotationZ.mdx @@ -0,0 +1,47 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L197 +title: rotationZ +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: | +

The system variable rotationZ always contains the rotation of the + device along the z axis. If the sketch + angleMode() is set to DEGREES, the value will be 0 to 360. If + it is set to RADIANS, the value will be 0 to 2*PI.

+

Unlike rotationX and rotationY, this variable is available for devices + with a built-in compass only.

+

Note: The order the rotations are called is important, ie. if used + together, it must be called in the order Z-X-Y or there might be + unexpected behaviour.

+line: 197 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + } + + function draw() { + background(200); + rotateZ(radians(rotationZ)); + //rotateX(radians(rotationX)); + //rotateY(radians(rotationY)); + box(200, 200, 200); + describe(`red horizontal line right, green vertical line bottom. + black background.`); + } + +
+class: p5 +type: Number +--- + + +# rotationZ diff --git a/src/content/reference/en/p5 copy/round.mdx b/src/content/reference/en/p5 copy/round.mdx new file mode 100644 index 0000000000..3f6efea6eb --- /dev/null +++ b/src/content/reference/en/p5 copy/round.mdx @@ -0,0 +1,88 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L861 +title: round +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Calculates the integer closest to a number.

+ +

For example, round(133.8) returns the value 134.

+ +

The second parameter, decimals, is optional. It sets the + number of + + decimal places to use when rounding. For example, round(12.34, 1) + returns + + 12.3. decimals is 0 by default.

+line: 861 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Round a number. + let x = round(4.2); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the rounded number. + text(x, 50, 50); + + describe('The number 4 written in middle of the canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Round a number to 2 decimal places. + let x = round(12.782383, 2); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the rounded number. + text(x, 50, 50); + + describe('The number 12.78 written in middle of canvas.'); + } + +
+class: p5 +params: + - name: 'n' + description: | +

number to round.

+ type: Number + - name: decimals + description: | +

number of decimal places to round to, default is 0.

+ type: Number + optional: true +return: + description: rounded number. + type: Integer +chainable: false +--- + + +# round diff --git a/src/content/reference/en/p5 copy/sampleRate.mdx b/src/content/reference/en/p5 copy/sampleRate.mdx new file mode 100644 index 0000000000..3608ee22be --- /dev/null +++ b/src/content/reference/en/p5 copy/sampleRate.mdx @@ -0,0 +1,26 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L811 +title: sampleRate +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: | +

Returns a number representing the sample rate, in samples per second, + of all sound objects in this audio context. It is determined by the + sampling rate of your operating system's sound card, and it is not + currently possile to change. + It is often 44100, or twice the range of human hearing.

+line: 811 +isConstructor: false +itemtype: method +class: p5 +return: + description: samplerate samples per second + type: Number +chainable: false +--- + + +# sampleRate diff --git a/src/content/reference/en/p5 copy/saturation.mdx b/src/content/reference/en/p5 copy/saturation.mdx new file mode 100644 index 0000000000..7552fe927d --- /dev/null +++ b/src/content/reference/en/p5 copy/saturation.mdx @@ -0,0 +1,201 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L1415 +title: saturation +module: Color +submodule: Creating & Reading +file: src/color/creating_reading.js +description: > +

Gets the saturation value of a color.

+ +

saturation() extracts the saturation value from a + + p5.Color object, an array of color + components, or + + a CSS color string.

+ +

Saturation is scaled differently in HSB and HSL. By default, + saturation() + + returns a color's HSL saturation in the range 0 to 100. If the + + colorMode() is set to HSB or HSL, it + returns the + + saturation value in the given mode.

+line: 1415 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(50); + + // Use HSB color. + colorMode(HSB); + + // Create a p5.Color object. + let c = color(0, 50, 100); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'satValue' to 50. + let satValue = saturation(c); + + // Draw the right rectangle. + fill(satValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is dark gray.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(50); + + // Use HSB color. + colorMode(HSB); + + // Create a color array. + let c = [0, 50, 100]; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'satValue' to 100. + let satValue = saturation(c); + + // Draw the right rectangle. + fill(satValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is gray.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(50); + + // Use HSB color. + colorMode(HSB); + + // Create a CSS color string. + let c = 'rgb(255, 128, 128)'; + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'satValue' to 100. + let satValue = saturation(c); + + // Draw the right rectangle. + fill(satValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is gray.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(50); + + // Use HSL color. + colorMode(HSL); + + // Create a p5.Color object. + let c = color(0, 100, 75); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'satValue' to 100. + let satValue = saturation(c); + + // Draw the right rectangle. + fill(satValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is white.'); + } + +
+ - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(50); + + // Use HSL color with values in the range 0-255. + colorMode(HSL, 255); + + // Create a p5.Color object. + let c = color(0, 255, 191.5); + + // Draw the left rectangle. + noStroke(); + fill(c); + rect(15, 15, 35, 70); + + // Set 'satValue' to 255. + let satValue = saturation(c); + + // Draw the right rectangle. + fill(satValue); + rect(50, 15, 35, 70); + + describe('Two rectangles. The left one is salmon pink and the right one is white.'); + } + +
+class: p5 +params: + - name: color + description: | +

p5.Color object, array of + color components, or CSS color string.

+ type: 'p5.Color|Number[]|String' +return: + description: the saturation value + type: Number +chainable: false +--- + + +# saturation diff --git a/src/content/reference/en/p5 copy/save.mdx b/src/content/reference/en/p5 copy/save.mdx new file mode 100644 index 0000000000..fb8b67cd74 --- /dev/null +++ b/src/content/reference/en/p5 copy/save.mdx @@ -0,0 +1,140 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1835 +title: save +module: IO +submodule: Output +file: src/io/files.js +description: > +

Saves a given element(image, text, json, csv, wav, or html) to the client's + + computer. The first parameter can be a pointer to element we want to save. + + The element can be one of p5.Element,an + Array of + + Strings, an Array of JSON, a JSON object, a p5.Table + + , a p5.Image, or a p5.SoundFile + (requires + + p5.sound). The second parameter is a filename (including extension).The + + third parameter is for options specific to this type of object. This method + + will save a file that fits the given parameters. + + If it is called without specifying an element, by default it will save the + + whole canvas as an image file. You can optionally specify a filename as + + the first parameter in such a case. + + Note that it is not recommended to + + call this method within draw, as it will open a new save dialog on every + + render.

+line: 1835 +isConstructor: false +itemtype: method +example: + - |2- + +
+ // Saves the canvas as an image + cnv = createCanvas(300, 300); + save(cnv, 'myCanvas.jpg'); + + // 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.'); +
+ +
+ let myTable = new p5.Table(); + // Saves table as html file + save(myTable, 'myTable.html'); + + // Comma Separated Values + save(myTable, 'myTable.csv'); + + // Tab Separated Values + save(myTable, 'myTable.tsv'); + + describe(`An example showing how to save a table in formats of + HTML, CSV and TSV.`); +
+ +
+ let myJSON = { a: 1, b: true }; + + // Saves pretty JSON + save(myJSON, 'my.json'); + + // 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.`); +
+class: p5 +params: + - name: objectOrFilename + description: | +

If filename is provided, will + save canvas as an image with + either png or jpg extension + depending on the filename. + If object is provided, will + save depending on the object + and filename (see examples + above).

+ type: Object|String + optional: true + - name: filename + description: | +

If an object is provided as the first + parameter, then the second parameter + indicates the filename, + and should include an appropriate + file extension (see examples above).

+ type: String + optional: true + - name: options + description: | +

Additional options depend on + filetype. For example, when saving JSON, + true indicates that the + output will be optimized for filesize, + rather than readability.

+ type: Boolean|String + optional: true +chainable: false +--- + + +# save diff --git a/src/content/reference/en/p5 copy/saveCanvas.mdx b/src/content/reference/en/p5 copy/saveCanvas.mdx new file mode 100644 index 0000000000..159bf101ce --- /dev/null +++ b/src/content/reference/en/p5 copy/saveCanvas.mdx @@ -0,0 +1,166 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/image.js#L153 +title: saveCanvas +module: Image +submodule: Image +file: src/image/image.js +description: > +

Saves the current canvas as an image.

+ +

By default, saveCanvas() saves the canvas as a PNG image + called + + untitled.png.

+ +

The first parameter, filename, is optional. It's a string that + sets the + + file's name. If a file extension is included, as in + + saveCanvas('drawing.png'), then the image will be saved using + that + + format.

+ +

The second parameter, extension, is also optional. It sets the + files format. + + Either 'png', 'webp', or 'jpg' can be + used. For example, saveCanvas('drawing', 'jpg') + + saves the canvas to a file called drawing.jpg.

+ +

Note: The browser will either save the file immediately or prompt the user + + with a dialogue window.

+line: 153 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + background(255); + + // Save the canvas to 'untitled.png'. + saveCanvas(); + + describe('A white square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(255); + + // Save the canvas to 'myCanvas.jpg'. + saveCanvas('myCanvas.jpg'); + + describe('A white square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(255); + + // Save the canvas to 'myCanvas.jpg'. + saveCanvas('myCanvas', 'jpg'); + + describe('A white square.'); + } + +
+ +
+ + function setup() { + let cnv = createCanvas(100, 100); + + background(255); + + // Save the canvas to 'untitled.png'. + saveCanvas(cnv); + + describe('A white square.'); + } + +
+ +
+ + function setup() { + let cnv = createCanvas(100, 100); + + background(255); + + // Save the canvas to 'myCanvas.jpg'. + saveCanvas(cnv, 'myCanvas.jpg'); + + describe('A white square.'); + } + +
+ +
+ + function setup() { + let cnv = createCanvas(100, 100); + + background(255); + + // Save the canvas to 'myCanvas.jpg'. + saveCanvas(cnv, 'myCanvas', 'jpg'); + + describe('A white square.'); + } + +
+class: p5 +overloads: + - line: 153 + params: + - name: selectedCanvas + description: | +

reference to a + specific HTML5 canvas element.

+ type: p5.Framebuffer|p5.Element|HTMLCanvasElement + - name: filename + description: | +

file name. Defaults to 'untitled'.

+ type: String + optional: true + - name: extension + description: > +

file extension, either 'png', 'webp', or 'jpg'. Defaults to + 'png'.

+ type: String + optional: true + - line: 267 + params: + - name: filename + description: '' + type: String + optional: true + - name: extension + description: '' + type: String + optional: true +chainable: false +--- + + +# saveCanvas diff --git a/src/content/reference/en/p5 copy/saveFrames.mdx b/src/content/reference/en/p5 copy/saveFrames.mdx new file mode 100644 index 0000000000..72b8d7d987 --- /dev/null +++ b/src/content/reference/en/p5 copy/saveFrames.mdx @@ -0,0 +1,175 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/image.js#L561 +title: saveFrames +module: Image +submodule: Image +file: src/image/image.js +description: > +

Captures a sequence of frames from the canvas that can be saved as + images.

+ +

saveFrames() creates an array of frame objects. Each frame is + stored as + + an object with its file type, file name, and image data as a string. For + + example, the first saved frame might have the following properties:

+ +

{ ext: 'png', filename: 'frame0', imageData: + 'data:image/octet-stream;base64, abc123' }.

+ +

The first parameter, filename, sets the prefix for the file + names. For + + example, setting the prefix to 'frame' would generate the image + files + + frame0.png, frame1.png, and so on.

+ +

The second parameter, extension, sets the file type to either + 'png' or + + 'jpg'.

+ +

The third parameter, duration, sets the duration to record in + seconds. + + The maximum duration is 15 seconds.

+ +

The fourth parameter, framerate, sets the number of frames to + record per + + second. The maximum frame rate value is 22. Limits are placed on + duration + + and framerate to avoid using too much memory. Recording large + canvases + + can easily crash sketches or even web browsers.

+ +

The fifth parameter, callback, is optional. If a function is + passed, + + image files won't be saved by default. The callback function can be used + + to process an array containing the data for each captured frame. The array + + of image data contains a sequence of objects with three properties for each + + frame: imageData, filename, and + extension.

+ +

Note: Frames are downloaded as individual image files by default.

+line: 561 +isConstructor: false +itemtype: method +example: + - >- + +
+ + + + function setup() { + createCanvas(100, 100); + + describe('A square repeatedly changes color from blue to pink.'); + } + + + function draw() { + let r = frameCount % 255; + let g = 50; + let b = 100; + background(r, g, b); + } + + + // Save the frames when the user presses the 's' key. + + function keyPressed() { + if (key === 's') { + saveFrames('frame', 'png', 1, 5); + } + } + + + +
+ + +
+ + + + function setup() { + createCanvas(100, 100); + + describe('A square repeatedly changes color from blue to pink.'); + } + + + function draw() { + let r = frameCount % 255; + let g = 50; + let b = 100; + background(r, g, b); + } + + + // Print 5 frames when the user presses the mouse. + + function mousePressed() { + saveFrames('frame', 'png', 1, 5, printFrames); + } + + + // Prints an array of objects containing raw image data, filenames, and + extensions. + + function printFrames(frames) { + for (let frame of frames) { + print(frame); + } + } + + + +
+class: p5 +params: + - name: filename + description: | +

prefix of file name.

+ type: String + - name: extension + description: | +

file extension, either 'jpg' or 'png'.

+ type: String + - name: duration + description: > +

duration in seconds to record. This parameter will be constrained to be + less or equal to 15.

+ type: Number + - name: framerate + description: > +

number of frames to save per second. This parameter will be constrained + to be less or equal to 22.

+ type: Number + - name: callback + description: | +

callback function that will be executed + to handle the image data. This function + should accept an array as argument. The + array will contain the specified number of + frames of objects. Each object has three + properties: imageData, filename, and extension.

+ type: Function(Array) + optional: true +chainable: false +--- + + +# saveFrames diff --git a/src/content/reference/en/p5 copy/saveGif.mdx b/src/content/reference/en/p5 copy/saveGif.mdx new file mode 100644 index 0000000000..9b520993ac --- /dev/null +++ b/src/content/reference/en/p5 copy/saveGif.mdx @@ -0,0 +1,119 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L204 +title: saveGif +module: Image +submodule: Loading & Displaying +file: src/image/loading_displaying.js +description: > +

Generates a gif from a sketch and saves it to a file.

+ +

saveGif() may be called in setup() or at any + + point while a sketch is running.

+ +

The first parameter, fileName, sets the gif's file name.

+ +

The second parameter, duration, sets the gif's duration in + seconds.

+ +

The third parameter, options, is optional. If an object is + passed, + + saveGif() will use its properties to customize the gif. + saveGif() + + recognizes the properties delay, units, + silent, + + notificationDuration, and notificationID.

+line: 204 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A circle drawn in the middle of a gray square. The circle changes color from black to white, then repeats.'); + } + + function draw() { + background(200); + + // Style the circle. + let c = frameCount % 255; + fill(c); + + // Display the circle. + circle(50, 50, 25); + } + + // Save a 5-second gif when the user presses the 's' key. + function keyPressed() { + if (key === 's') { + saveGif('mySketch', 5); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A circle drawn in the middle of a gray square. The circle changes color from black to white, then repeats.'); + } + + function draw() { + background(200); + + // Style the circle. + let c = frameCount % 255; + fill(c); + + // Display the circle. + circle(50, 50, 25); + } + + // Save a 5-second gif when the user presses the 's' key. + // Wait 1 second after the key press before recording. + function keyPressed() { + if (key === 's') { + saveGif('mySketch', 5, { delay: 1 }); + } + } + +
+class: p5 +params: + - name: filename + description: | +

file name of gif.

+ type: String + - name: duration + description: | +

duration in seconds to capture from the sketch.

+ type: Number + - name: options + description: | +

an object that can contain five more properties: + delay, a Number specifying how much time to wait before recording; + units, a String that can be either 'seconds' or 'frames'. By default it's 'seconds’; + silent, a Boolean that defines presence of progress notifications. By default it’s false; + notificationDuration, a Number that defines how long in seconds the final notification + will live. By default it's 0, meaning the notification will never be removed; + notificationID, a String that specifies the id of the notification's DOM element. By default it’s 'progressBar’.

+ type: Object + optional: true +chainable: false +--- + + +# saveGif diff --git a/src/content/reference/en/p5 copy/saveJSON.mdx b/src/content/reference/en/p5 copy/saveJSON.mdx new file mode 100644 index 0000000000..d5e664d0b2 --- /dev/null +++ b/src/content/reference/en/p5 copy/saveJSON.mdx @@ -0,0 +1,170 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1979 +title: saveJSON +module: IO +submodule: Output +file: src/io/files.js +description: > +

Saves an Object or Array to a JSON file.

+ +

JavaScript Object Notation + + (JSON) + + is a standard format for sending data between applications. The format is + + based on JavaScript objects which have keys and values. JSON files store + + data in an object with strings as keys. Values can be strings, numbers, + + Booleans, arrays, null, or other objects.

+ +

The first parameter, json, is the data to save. The data can + be an array, + + as in [1, 2, 3], or an object, as in + + { x: 50, y: 50, color: 'deeppink' }.

+ +

The second parameter, filename, is a string that sets the + file's name. + + For example, calling saveJSON([1, 2, 3], 'data.json') saves the + array + + [1, 2, 3] to a file called data.json on the user's + computer.

+ +

The third parameter, optimize, is optional. If + true is passed, as in + + saveJSON([1, 2, 3], 'data.json', true), then all unneeded + whitespace will + + be removed to reduce the file size.

+ +

Note: The browser will either save the file immediately or prompt the user + + with a dialogue window.

+line: 1979 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(12); + + // Display instructions. + text('Double-click to save', 5, 50, 90); + + describe('The text "Double-click to save" written in black on a gray background.'); + } + + // Save the file when the user double-clicks. + function doubleClicked() { + if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { + // Create an array. + let data = [1, 2, 3]; + + // Save the JSON file. + saveJSON(data, 'numbers.json'); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(12); + + // Display instructions. + text('Double-click to save', 5, 50, 90); + + describe('The text "Double-click to save" written in black on a gray background.'); + } + + // Save the file when the user double-clicks. + function doubleClicked() { + if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { + // Create an object. + let data = { x: mouseX, y: mouseY }; + + // Save the JSON file. + saveJSON(data, 'state.json'); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(12); + + // Display instructions. + text('Double-click to save', 5, 50, 90); + + describe('The text "Double-click to save" written in black on a gray background.'); + } + + // Save the file when the user double-clicks. + function doubleClicked() { + if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { + // Create an object. + let data = { x: mouseX, y: mouseY }; + + // Save the JSON file and reduce its size. + saveJSON(data, 'state.json', true); + } + } + +
+class: p5 +params: + - name: json + description: | +

data to save.

+ type: Array|Object + - name: filename + description: | +

name of the file to be saved.

+ type: String + - name: optimize + description: | +

whether to trim unneeded whitespace. Defaults + to true.

+ type: Boolean + optional: true +chainable: false +--- + + +# saveJSON diff --git a/src/content/reference/en/p5 copy/saveSound.mdx b/src/content/reference/en/p5 copy/saveSound.mdx new file mode 100644 index 0000000000..3e8e7d0667 --- /dev/null +++ b/src/content/reference/en/p5 copy/saveSound.mdx @@ -0,0 +1,35 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L1145 +title: saveSound +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: > +

Save a p5.SoundFile as a .wav file. The browser will prompt the user + + to download the file to their device. + + For uploading audio to a server, use + + p5.SoundFile.saveBlob.

+line: 1145 +isConstructor: false +itemtype: method +class: p5 +params: + - name: soundFile + description: | +

p5.SoundFile that you wish to save

+ type: p5.SoundFile + - name: fileName + description: | +

name of the resulting .wav file.

+ type: String +chainable: false +--- + + +# saveSound diff --git a/src/content/reference/en/p5 copy/saveStrings.mdx b/src/content/reference/en/p5 copy/saveStrings.mdx new file mode 100644 index 0000000000..36c6c448a2 --- /dev/null +++ b/src/content/reference/en/p5 copy/saveStrings.mdx @@ -0,0 +1,185 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L2118 +title: saveStrings +module: IO +submodule: Output +file: src/io/files.js +description: > +

Saves an Array of Strings to a file, one per + line.

+ +

The first parameter, list, is an array with the strings to + save.

+ +

The second parameter, filename, is a string that sets the + file's name. + + For example, calling saveStrings(['0', '01', '011'], 'data.txt') + saves + + the array ['0', '01', '011'] to a file called + data.txt on the user's + + computer.

+ +

The third parameter, extension, is optional. If a string is + passed, as in + + saveStrings(['0', '01', '01'], 'data', 'txt')`, the second + parameter will + + be interpreted as the file name and the third parameter as the extension.

+ +

The fourth parameter, isCRLF, is also optional, If + true is passed, as + + in saveStrings(['0', '01', '011'], 'data', 'txt', true), then two + + characters, \r\n , will be added to the end of each string to + create new + + lines in the saved file. \r is a carriage return (CR) and + \n is a line + + feed (LF). By default, only \n (line feed) is added to each + string in + + order to create new lines.

+ +

Note: The browser will either save the file immediately or prompt the user + + with a dialogue window.

+line: 2118 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(12); + + // Display instructions. + text('Double-click to save', 5, 50, 90); + + describe('The text "Double-click to save" written in black on a gray background.'); + } + + // Save the file when the user double-clicks. + function doubleClicked() { + if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { + // Create an array. + let data = ['0', '01', '011']; + + // Save the text file. + saveStrings(data, 'data.txt'); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(12); + + // Display instructions. + text('Double-click to save', 5, 50, 90); + + describe('The text "Double-click to save" written in black on a gray background.'); + } + + // Save the file when the user double-clicks. + function doubleClicked() { + if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { + // Create an array. + // ASCII art courtesy Wikipedia: + // https://en.wikipedia.org/wiki/ASCII_art + let data = [' (\\_/) ', "(='.'=)", '(")_(")']; + + // Save the text file. + saveStrings(data, 'cat', 'txt'); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textAlign(LEFT, CENTER); + textFont('Courier New'); + textSize(12); + + // Display instructions. + text('Double-click to save', 5, 50, 90); + + describe('The text "Double-click to save" written in black on a gray background.'); + } + + // Save the file when the user double-clicks. + function doubleClicked() { + if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { + // Create an array. + // +--+ + // / /| + // +--+ + + // | |/ + // +--+ + let data = [' +--+', ' / /|', '+--+ +', '| |/', '+--+']; + + // Save the text file. + // Use CRLF for line endings. + saveStrings(data, 'box', 'txt', true); + } + } + +
+class: p5 +params: + - name: list + description: | +

data to save.

+ type: 'String[]' + - name: filename + description: | +

name of file to be saved.

+ type: String + - name: extension + description: | +

format to use for the file.

+ type: String + optional: true + - name: isCRLF + description: | +

whether to add \r\n to the end of each + string. Defaults to false.

+ type: Boolean + optional: true +chainable: false +--- + + +# saveStrings diff --git a/src/content/reference/en/p5 copy/saveTable.mdx b/src/content/reference/en/p5 copy/saveTable.mdx new file mode 100644 index 0000000000..dd6e64ea4d --- /dev/null +++ b/src/content/reference/en/p5 copy/saveTable.mdx @@ -0,0 +1,70 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L2275 +title: saveTable +module: IO +submodule: Output +file: src/io/files.js +description: > +

Writes the contents of a Table object + to a file. Defaults to a + + text file with comma-separated-values ('csv') but can also + + use tab separation ('tsv'), or generate an HTML table ('html'). + + The file saving process and location of the saved file will + + vary between web browsers.

+line: 2275 +isConstructor: false +itemtype: method +example: + - |- + +
+ let table; + + function setup() { + table = new p5.Table(); + + table.addColumn('id'); + table.addColumn('species'); + table.addColumn('name'); + + let newRow = table.addRow(); + newRow.setNum('id', table.getRowCount() - 1); + newRow.setString('species', 'Panthera leo'); + newRow.setString('name', 'Lion'); + + // 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 +
+class: p5 +params: + - name: Table + description: | +

the Table object to save to a file

+ type: p5.Table + - name: filename + description: | +

the filename to which the Table should be saved

+ type: String + - name: options + description: | +

can be one of "tsv", "csv", or "html"

+ type: String + optional: true +chainable: false +--- + + +# saveTable diff --git a/src/content/reference/en/p5 copy/scale.mdx b/src/content/reference/en/p5 copy/scale.mdx new file mode 100644 index 0000000000..a459477d80 --- /dev/null +++ b/src/content/reference/en/p5 copy/scale.mdx @@ -0,0 +1,231 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L878 +title: scale +module: Transform +submodule: Transform +file: src/core/transform.js +description: > +

Scales the coordinate system.

+ +

By default, shapes are drawn at their original scale. A rectangle that's 50 + + pixels wide appears to take up half the width of a 100 pixel-wide canvas. + + The scale() function can shrink or stretch the coordinate system + so that + + shapes appear at different sizes. There are two ways to call + scale() with + + parameters that set the scale factor(s).

+ +

The first way to call scale() uses numbers to set the amount + of scaling. + + The first parameter, s, sets the amount to scale each axis. For + example, + + calling scale(2) stretches the x-, y-, and z-axes by a factor of + 2. The + + next two parameters, y and z, are optional. They set + the amount to + + scale the y- and z-axes. For example, calling scale(2, 0.5, 1) + stretches + + the x-axis by a factor of 2, shrinks the y-axis by a factor of 0.5, and + + leaves the z-axis unchanged.

+ +

The second way to call scale() uses a p5.Vector + + object to set the scale factors. For example, calling + scale(myVector) + + uses the x-, y-, and z-components of myVector to set the amount + of + + scaling along the x-, y-, and z-axes. Doing so is the same as calling + + scale(myVector.x, myVector.y, myVector.z).

+ +

By default, transformations accumulate. For example, calling + scale(1) + + twice has the same effect as calling scale(2) once. The + + push() and pop() functions + + can be used to isolate transformations within distinct drawing groups.

+ +

Note: Transformations are reset at the beginning of the draw loop. Calling + + scale(2) inside the draw() + function won't cause + + shapes to grow continuously.

+line: 878 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'Two white squares on a gray background. The larger square appears at the top-center. The smaller square appears at the top-left.' + ); + } + + function draw() { + background(200); + + // Draw a square at (30, 20). + square(30, 20, 40); + + // Scale the coordinate system by a factor of 0.5. + scale(0.5); + + // Draw a square at (30, 20). + // It appears at (15, 10) after scaling. + square(30, 20, 40); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A rectangle and a square drawn in white on a gray background.'); + } + + function draw() { + background(200); + + // Draw a square at (30, 20). + square(30, 20, 40); + + // Scale the coordinate system by factors of + // 0.5 along the x-axis and + // 1.3 along the y-axis. + scale(0.5, 1.3); + + // Draw a square at (30, 20). + // It appears as a rectangle at (15, 26) after scaling. + square(30, 20, 40); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A rectangle and a square drawn in white on a gray background.'); + } + + function draw() { + background(200); + + // Draw a square at (30, 20). + square(30, 20, 40); + + // Create a p5.Vector object. + let v = createVector(0.5, 1.3); + + // Scale the coordinate system by factors of + // 0.5 along the x-axis and + // 1.3 along the y-axis. + scale(v); + + // Draw a square at (30, 20). + // It appears as a rectangle at (15, 26) after scaling. + square(30, 20, 40); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'A red box and a blue box drawn on a gray background. The red box appears embedded in the blue box.' + ); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Style the spheres. + noStroke(); + + // Draw the red sphere. + fill('red'); + box(); + + // Scale the coordinate system by factors of + // 0.5 along the x-axis and + // 1.3 along the y-axis and + // 2 along the z-axis. + scale(0.5, 1.3, 2); + + // Draw the blue sphere. + fill('blue'); + box(); + } + +
+class: p5 +overloads: + - line: 878 + params: + - name: s + description: | +

amount to scale along the positive x-axis.

+ type: 'Number|p5.Vector|Number[]' + - name: 'y' + description: > +

amount to scale along the positive y-axis. Defaults to + s.

+ type: Number + optional: true + - name: z + description: > +

amount to scale along the positive z-axis. Defaults to + y.

+ type: Number + optional: true + chainable: 1 + - line: 1039 + params: + - name: scales + description: | +

vector whose components should be used to scale.

+ type: 'p5.Vector|Number[]' + chainable: 1 +chainable: true +--- + + +# scale diff --git a/src/content/reference/en/p5 copy/second.mdx b/src/content/reference/en/p5 copy/second.mdx new file mode 100644 index 0000000000..e29042801c --- /dev/null +++ b/src/content/reference/en/p5 copy/second.mdx @@ -0,0 +1,47 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L277 +title: second +module: IO +submodule: Time & Date +file: src/utilities/time_date.js +description: | +

Returns the current second as a number from 0–59.

+line: 277 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Get the current second. + let s = second(); + + // Style the text. + textAlign(LEFT, CENTER); + textSize(12); + textFont('Courier New'); + + // Display the second. + text(`Current second: ${s}`, 10, 50, 80); + + describe(`The text 'Current second: ${s}' written in black on a gray background.`); + } + +
+class: p5 +return: + description: current second between 0 and 59. + type: Integer +chainable: false +--- + + +# second diff --git a/src/content/reference/en/p5 copy/select.mdx b/src/content/reference/en/p5 copy/select.mdx new file mode 100644 index 0000000000..0ace11ab0d --- /dev/null +++ b/src/content/reference/en/p5 copy/select.mdx @@ -0,0 +1,113 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L21 +title: select +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Searches the page for the first element that matches the given + + CSS selector string.

+ +

The selector string can be an ID, class, tag name, or a combination. + + select() returns a p5.Element object if it + + finds a match and null if not.

+ +

The second parameter, container, is optional. It specifies a + container to + + search within. container can be CSS selector string, a + + p5.Element object, or an + + HTMLElement object.

+line: 21 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + background(200); + + // Select the canvas by its tag. + let cnv = select('canvas'); + cnv.style('border', '5px deeppink dashed'); + + describe('A gray square with a dashed pink border.'); + } + +
+ +
+ + function setup() { + let cnv = createCanvas(100, 100); + + // Add a class attribute to the canvas. + cnv.class('pinkborder'); + + background(200); + + // Select the canvas by its class. + cnv = select('.pinkborder'); + + // Style its border. + cnv.style('border', '5px deeppink dashed'); + + describe('A gray square with a dashed pink border.'); + } + +
+ +
+ + function setup() { + let cnv = createCanvas(100, 100); + + // Set the canvas' ID. + cnv.id('mycanvas'); + + background(200); + + // Select the canvas by its ID. + cnv = select('#mycanvas'); + + // Style its border. + cnv.style('border', '5px deeppink dashed'); + + describe('A gray square with a dashed pink border.'); + } + +
+class: p5 +params: + - name: selectors + description: | +

CSS selector string of element to search for.

+ type: String + - name: container + description: | +

CSS selector string, p5.Element, or + HTMLElement to search within.

+ type: String|p5.Element|HTMLElement + optional: true +return: + description: p5.Element containing the element. + type: p5.Element|null +chainable: false +--- + + +# select diff --git a/src/content/reference/en/p5 copy/selectAll.mdx b/src/content/reference/en/p5 copy/selectAll.mdx new file mode 100644 index 0000000000..ccd1f3329f --- /dev/null +++ b/src/content/reference/en/p5 copy/selectAll.mdx @@ -0,0 +1,121 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L109 +title: selectAll +module: DOM +submodule: DOM +file: src/dom/dom.js +description: > +

Searches the page for all elements that matches the given + + CSS selector string.

+ +

The selector string can be an ID, class, tag name, or a combination. + + selectAll() returns an array of p5.Element + + objects if it finds any matches and an empty array if none are found.

+ +

The second parameter, container, is optional. It specifies a + container to + + search within. container can be CSS selector string, a + + p5.Element object, or an + + HTMLElement object.

+line: 109 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Create three buttons. + createButton('1'); + createButton('2'); + createButton('3'); + + // Select the buttons by their tag. + let buttons = selectAll('button'); + + // Position the buttons. + for (let i = 0; i < 3; i += 1) { + buttons[i].position(0, i * 30); + } + + describe('Three buttons stacked vertically. The buttons are labeled, "1", "2", and "3".'); + } + +
+ +
+ + function setup() { + // Create three buttons and position them. + let b1 = createButton('1'); + b1.position(0, 0); + let b2 = createButton('2'); + b2.position(0, 30); + let b3 = createButton('3'); + b3.position(0, 60); + + // Add a class attribute to each button. + b1.class('btn'); + b2.class('btn btn-pink'); + b3.class('btn'); + + // Select the buttons by their class. + let buttons = selectAll('.btn'); + let pinkButtons = selectAll('.btn-pink'); + + // Style the selected buttons. + buttons.forEach(setFont); + pinkButtons.forEach(setColor); + + describe('Three buttons stacked vertically. The buttons are labeled, "1", "2", and "3". Buttons "1" and "3" are gray. Button "2" is pink.'); + } + + // Set a button's font to Comic Sans MS. + function setFont(btn) { + btn.style('font-family', 'Comic Sans MS'); + } + + // Set a button's background and font color. + function setColor(btn) { + btn.style('background', 'deeppink'); + btn.style('color', 'white'); + } + +
+class: p5 +params: + - name: selectors + description: | +

CSS selector string of element to search for.

+ type: String + - name: container + description: | +

CSS selector string, p5.Element, or + HTMLElement to search within.

+ type: String|p5.Element|HTMLElement + optional: true +return: + description: >- + array of p5.Elements containing any elements + found. + type: 'p5.Element[]' +chainable: false +--- + + +# selectAll diff --git a/src/content/reference/en/p5 copy/set.mdx b/src/content/reference/en/p5 copy/set.mdx new file mode 100644 index 0000000000..caa9e75a66 --- /dev/null +++ b/src/content/reference/en/p5 copy/set.mdx @@ -0,0 +1,157 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L997 +title: set +module: Image +submodule: Pixels +file: src/image/pixels.js +description: > +

Sets the color of a pixel or draws an image to the canvas.

+ +

set() is easy to use but it's not as fast as + + pixels. Use pixels + + to set many pixel values.

+ +

set() interprets the first two parameters as x- and + y-coordinates. It + + interprets the last parameter as a grayscale value, a [R, G, B, + A] pixel + + array, a p5.Color object, or a + + p5.Image object. If an image is passed, + the first + + two parameters set the coordinates for the image's upper-left corner, + + regardless of the current imageMode().

+ +

updatePixels() must be called + after using + + set() for changes to appear.

+line: 997 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Set four pixels to black. + set(30, 20, 0); + set(85, 20, 0); + set(85, 75, 0); + set(30, 75, 0); + + // Update the canvas. + updatePixels(); + + describe('Four black dots arranged in a square drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a p5.Color object. + let black = color(0); + + // Set four pixels to black. + set(30, 20, black); + set(85, 20, black); + set(85, 75, black); + set(30, 75, black); + + // Update the canvas. + updatePixels(); + + describe('Four black dots arranged in a square drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(255); + + // Draw a horizontal color gradient. + for (let x = 0; x < 100; x += 1) { + for (let y = 0; y < 100; y += 1) { + // Calculate the grayscale value. + let c = map(x, 0, 100, 0, 255); + + // Set the pixel using the grayscale value. + set(x, y, c); + } + } + + // Update the canvas. + updatePixels(); + + describe('A horizontal color gradient from black to white.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/rockies.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Use the image to set all pixels. + set(0, 0, img); + + // Update the canvas. + updatePixels(); + + describe('An image of a mountain landscape.'); + } + +
+class: p5 +params: + - name: x + description: | +

x-coordinate of the pixel.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the pixel.

+ type: Number + - name: c + description: | +

grayscale value | pixel array | + p5.Color object | p5.Image to copy.

+ type: 'Number|Number[]|Object' +chainable: false +--- + + +# set diff --git a/src/content/reference/en/p5 copy/setAttributes.mdx b/src/content/reference/en/p5 copy/setAttributes.mdx new file mode 100644 index 0000000000..368bc49c6c --- /dev/null +++ b/src/content/reference/en/p5 copy/setAttributes.mdx @@ -0,0 +1,163 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.RendererGL.js#L118 +title: setAttributes +module: Rendering +submodule: Rendering +file: src/webgl/p5.RendererGL.js +description: | +

Set attributes for the WebGL Drawing context. + This is a way of adjusting how the WebGL + renderer works to fine-tune the display and performance.

+

Note that this will reinitialize the drawing context + if called after the WebGL canvas is made.

+

If an object is passed as the parameter, all attributes + not declared in the object will be set to defaults.

+

The available attributes are: +
+ alpha - indicates if the canvas contains an alpha buffer + default is true

+

depth - indicates whether the drawing buffer has a depth buffer + of at least 16 bits - default is true

+

stencil - indicates whether the drawing buffer has a stencil buffer + of at least 8 bits

+

antialias - indicates whether or not to perform anti-aliasing + default is false (true in Safari)

+

premultipliedAlpha - indicates that the page compositor will assume + the drawing buffer contains colors with pre-multiplied alpha + default is true

+

preserveDrawingBuffer - if true the buffers will not be cleared and + and will preserve their values until cleared or overwritten by author + (note that p5 clears automatically on draw loop) + default is true

+

perPixelLighting - if true, per-pixel lighting will be used in the + lighting shader otherwise per-vertex lighting is used. + default is true.

+

version - either 1 or 2, to specify which WebGL version to ask for. By + default, WebGL 2 will be requested. If WebGL2 is not available, it will + fall back to WebGL 1. You can check what version is used with by looking at + the global webglVersion property.

+line: 118 +isConstructor: false +itemtype: method +alt: a rotating cube with smoother edges +example: + - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + } + + function draw() { + background(255); + push(); + rotateZ(frameCount * 0.02); + rotateX(frameCount * 0.02); + rotateY(frameCount * 0.02); + fill(0, 0, 0); + box(50); + pop(); + } + +
+
+ Now with the antialias attribute set to true. +
+
+ + function setup() { + setAttributes('antialias', true); + createCanvas(100, 100, WEBGL); + } + + function draw() { + background(255); + push(); + rotateZ(frameCount * 0.02); + rotateX(frameCount * 0.02); + rotateY(frameCount * 0.02); + fill(0, 0, 0); + box(50); + pop(); + } + +
+ +
+ + // press the mouse button to disable perPixelLighting + function setup() { + createCanvas(100, 100, WEBGL); + noStroke(); + fill(255); + } + + let lights = [ + { c: '#f00', t: 1.12, p: 1.91, r: 0.2 }, + { c: '#0f0', t: 1.21, p: 1.31, r: 0.2 }, + { c: '#00f', t: 1.37, p: 1.57, r: 0.2 }, + { c: '#ff0', t: 1.12, p: 1.91, r: 0.7 }, + { c: '#0ff', t: 1.21, p: 1.31, r: 0.7 }, + { c: '#f0f', t: 1.37, p: 1.57, r: 0.7 } + ]; + + function draw() { + let t = millis() / 1000 + 1000; + background(0); + directionalLight(color('#222'), 1, 1, 1); + + for (let i = 0; i < lights.length; i++) { + let light = lights[i]; + pointLight( + color(light.c), + p5.Vector.fromAngles(t * light.t, t * light.p, width * light.r) + ); + } + + specularMaterial(255); + sphere(width * 0.1); + + rotateX(t * 0.77); + rotateY(t * 0.83); + rotateZ(t * 0.91); + torus(width * 0.3, width * 0.07, 24, 10); + } + + function mousePressed() { + setAttributes('perPixelLighting', false); + noStroke(); + fill(255); + } + function mouseReleased() { + setAttributes('perPixelLighting', true); + noStroke(); + fill(255); + } + +
+class: p5 +overloads: + - line: 118 + params: + - name: key + description: | +

Name of attribute

+ type: String + - name: value + description: | +

New value of named attribute

+ type: Boolean + - line: 262 + params: + - name: obj + description: | +

object with key-value pairs

+ type: Object +chainable: false +--- + + +# setAttributes diff --git a/src/content/reference/en/p5 copy/setBPM.mdx b/src/content/reference/en/p5 copy/setBPM.mdx new file mode 100644 index 0000000000..d2e94a6c5d --- /dev/null +++ b/src/content/reference/en/p5 copy/setBPM.mdx @@ -0,0 +1,29 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L9084 +title: setBPM +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: | +

Set the global tempo, in beats per minute, for all + p5.Parts. This method will impact all active p5.Parts.

+line: 9084 +isConstructor: false +itemtype: method +class: p5 +params: + - name: BPM + description: | +

Beats Per Minute

+ type: Number + - name: rampTime + description: | +

Seconds from now

+ type: Number +chainable: false +--- + + +# setBPM diff --git a/src/content/reference/en/p5 copy/setCamera.mdx b/src/content/reference/en/p5 copy/setCamera.mdx new file mode 100644 index 0000000000..bd4727d474 --- /dev/null +++ b/src/content/reference/en/p5 copy/setCamera.mdx @@ -0,0 +1,81 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L3897 +title: setCamera +module: 3D +submodule: Camera +file: src/webgl/p5.Camera.js +description: > +

Sets the current (active) camera of a 3D sketch.

+ +

setCamera() allows for switching between multiple cameras + created with + + createCamera().

+ +

Note: setCamera() can only be used in WebGL mode.

+line: 3897 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Double-click to toggle between cameras. + + let cam1; + let cam2; + let usingCam1 = true; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create the first camera. + // Keep its default settings. + cam1 = createCamera(); + + // Create the second camera. + // Place it at the top-left. + // Point it at the origin. + cam2 = createCamera(); + cam2.setPosition(400, -400, 800); + cam2.lookAt(0, 0, 0); + + // Set the current camera to cam1. + setCamera(cam1); + + describe('A white cube on a gray background. The camera toggles between frontal and aerial views when the user double-clicks.'); + } + + function draw() { + background(200); + + // Draw the box. + box(); + } + + // Toggle the current camera when the user double-clicks. + function doubleClicked() { + if (usingCam1 === true) { + setCamera(cam2); + usingCam1 = false; + } else { + setCamera(cam1); + usingCam1 = true; + } + } + +
+class: p5 +params: + - name: cam + description: | +

camera that should be made active.

+ type: p5.Camera +chainable: false +--- + + +# setCamera diff --git a/src/content/reference/en/p5 copy/setMoveThreshold.mdx b/src/content/reference/en/p5 copy/setMoveThreshold.mdx new file mode 100644 index 0000000000..3b90fb5f4d --- /dev/null +++ b/src/content/reference/en/p5 copy/setMoveThreshold.mdx @@ -0,0 +1,59 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L417 +title: setMoveThreshold +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

The setMoveThreshold() + function is used to set the movement threshold for + + the deviceMoved() function. The + default threshold is set to 0.5.

+line: 417 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Run this example on a mobile device + // You will need to move the device incrementally further + // the closer the square's color gets to white in order to change the value. + + let value = 0; + let threshold = 0.5; + function setup() { + setMoveThreshold(threshold); + } + 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; + threshold = threshold + 0.1; + if (value > 255) { + value = 0; + threshold = 30; + } + setMoveThreshold(threshold); + } + +
+class: p5 +params: + - name: value + description: | +

The threshold value

+ type: Number +chainable: false +--- + + +# setMoveThreshold diff --git a/src/content/reference/en/p5 copy/setShakeThreshold.mdx b/src/content/reference/en/p5 copy/setShakeThreshold.mdx new file mode 100644 index 0000000000..30af9eadb0 --- /dev/null +++ b/src/content/reference/en/p5 copy/setShakeThreshold.mdx @@ -0,0 +1,59 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L459 +title: setShakeThreshold +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

The setShakeThreshold() + function is used to set the movement threshold for + + the deviceShaken() function. The + default threshold is set to 30.

+line: 459 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Run this example on a mobile device + // You will need to shake the device more firmly + // the closer the box's fill gets to white in order to change the value. + + let value = 0; + let threshold = 30; + function setup() { + setShakeThreshold(threshold); + } + 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; + threshold = threshold + 5; + if (value > 255) { + value = 0; + threshold = 30; + } + setShakeThreshold(threshold); + } + +
+class: p5 +params: + - name: value + description: | +

The threshold value

+ type: Number +chainable: false +--- + + +# setShakeThreshold diff --git a/src/content/reference/en/p5 copy/setup.mdx b/src/content/reference/en/p5 copy/setup.mdx new file mode 100644 index 0000000000..6a71ea6a0f --- /dev/null +++ b/src/content/reference/en/p5 copy/setup.mdx @@ -0,0 +1,111 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L87 +title: setup +module: Structure +submodule: Structure +file: src/core/main.js +description: > +

A function that's called once when the sketch begins running.

+ +

Declaring the function setup() sets a code block to run once + + automatically when the sketch starts running. It's used to perform + + setup tasks such as creating the canvas and initializing variables:

+ +
function setup() {
+    // Code to run once at the start of the sketch.
+  }
+
+  
+ +

Code placed in setup() will run once before code placed in + + draw() begins looping. If the + + preload() is declared, then + setup() will + + run immediately after preload() finishes + + loading assets.

+ +

Note: setup() doesn’t have to be declared, but it’s common + practice to do so.

+line: 87 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw the circle. + circle(50, 50, 40); + + describe('A white circle on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Paint the background once. + background(200); + + describe( + 'A white circle on a gray background. The circle follows the mouse as the user moves, leaving a trail.' + ); + } + + function draw() { + // Draw circles repeatedly. + circle(mouseX, mouseY, 40); + } + +
+ +
+ + let img; + + function preload() { + img = loadImage('/assets/bricks.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Draw the image. + image(img, 0, 0); + + describe( + 'A white circle on a brick wall. The circle follows the mouse as the user moves, leaving a trail.' + ); + } + + function draw() { + // Style the circle. + noStroke(); + + // Draw the circle. + circle(mouseX, mouseY, 10); + } + +
+class: p5 +chainable: false +--- + + +# setup diff --git a/src/content/reference/en/p5 copy/shader.mdx b/src/content/reference/en/p5 copy/shader.mdx new file mode 100644 index 0000000000..c8213d9261 --- /dev/null +++ b/src/content/reference/en/p5 copy/shader.mdx @@ -0,0 +1,244 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L682 +title: shader +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Sets the p5.Shader object to apply + while drawing.

+ +

Shaders are programs that run on the graphics processing unit (GPU). They + + can process many pixels or vertices at the same time, making them fast for + + many graphics tasks. They’re written in a language called + + GLSL + + and run along with the rest of the code in a sketch. + + p5.Shader objects can be created using + the + + createShader() and + + loadShader() functions.

+ +

The parameter, s, is the p5.Shader object to + + apply. For example, calling shader(myShader) applies + myShader to + + process each pixel on the canvas. The shader will be used for:

+ +
    + +
  • Fills when a texture is enabled if it includes a uniform + sampler2D.
  • + +
  • Fills when lights are enabled if it includes the attribute + aNormal, or if it has any of the following uniforms: + uUseLighting, uAmbientLightCount, + uDirectionalLightCount, uPointLightCount, + uAmbientColor, uDirectionalDiffuseColors, + uDirectionalSpecularColors, uPointLightLocation, + uPointLightDiffuseColors, uPointLightSpecularColors, + uLightingDirection, or uSpecular.
  • + +
  • Fills whenever there are no lights or textures.
  • + +
  • Strokes if it includes the uniform uStrokeWeight.
  • + +
+ +

The source code from a p5.Shader + object's + + fragment and vertex shaders will be compiled the first time it's passed to + + shader(). See + + MDN + + for more information about compiling shaders.

+ +

Calling resetShader() restores a + sketch’s + + default shaders.

+ +

Note: Shaders can only be used in WebGL mode.

+line: 682 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Note: A "uniform" is a global variable within a shader program. + + // Create a string with the vertex shader program. + // The vertex shader is called for each vertex. + let vertSrc = ` + precision highp float; + uniform mat4 uModelViewMatrix; + uniform mat4 uProjectionMatrix; + + attribute vec3 aPosition; + attribute vec2 aTexCoord; + varying vec2 vTexCoord; + + void main() { + vTexCoord = aTexCoord; + vec4 positionVec4 = vec4(aPosition, 1.0); + gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; + } + `; + + // Create a string with the fragment shader program. + // The fragment shader is called for each pixel. + let fragSrc = ` + precision highp float; + + void main() { + // Set each pixel's RGBA value to yellow. + gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); + } + `; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Shader object. + let shaderProgram = createShader(vertSrc, fragSrc); + + // Apply the p5.Shader object. + shader(shaderProgram); + + // Style the drawing surface. + noStroke(); + + // Add a plane as a drawing surface. + plane(100, 100); + + describe('A yellow square.'); + } + +
+ +
+ + // Note: A "uniform" is a global variable within a shader program. + + let mandelbrot; + + // Load the shader and create a p5.Shader object. + function preload() { + mandelbrot = loadShader('/assets/shader.vert', '/assets/shader.frag'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + // Use the p5.Shader object. + shader(mandelbrot); + + // Set the shader uniform p to an array. + mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); + + describe('A fractal image zooms in and out of focus.'); + } + + function draw() { + // Set the shader uniform r to a value that oscillates between 0 and 2. + mandelbrot.setUniform('r', sin(frameCount * 0.01) + 1); + + // Add a quad as a display surface for the shader. + quad(-1, -1, 1, -1, 1, 1, -1, 1); + } + +
+ +
+ + // Note: A "uniform" is a global variable within a shader program. + + let redGreen; + let orangeBlue; + let showRedGreen = false; + + // Load the shader and create two separate p5.Shader objects. + function preload() { + redGreen = loadShader('/assets/shader.vert', '/assets/shader-gradient.frag'); + orangeBlue = loadShader('/assets/shader.vert', '/assets/shader-gradient.frag'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + // Initialize the redGreen shader. + shader(redGreen); + + // Set the redGreen shader's center and background color. + redGreen.setUniform('colorCenter', [1.0, 0.0, 0.0]); + redGreen.setUniform('colorBackground', [0.0, 1.0, 0.0]); + + // Initialize the orangeBlue shader. + shader(orangeBlue); + + // Set the orangeBlue shader's center and background color. + orangeBlue.setUniform('colorCenter', [1.0, 0.5, 0.0]); + orangeBlue.setUniform('colorBackground', [0.226, 0.0, 0.615]); + + describe( + 'The scene toggles between two circular gradients when the user double-clicks. An orange and blue gradient vertically, and red and green gradient moves horizontally.' + ); + } + + function draw() { + // Update the offset values for each shader. + // Move orangeBlue vertically. + // Move redGreen horizontally. + orangeBlue.setUniform('offset', [0, sin(frameCount * 0.01) + 1]); + redGreen.setUniform('offset', [sin(frameCount * 0.01), 1]); + + if (showRedGreen === true) { + shader(redGreen); + } else { + shader(orangeBlue); + } + + // Style the drawing surface. + noStroke(); + + // Add a quad as a drawing surface. + quad(-1, -1, 1, -1, 1, 1, -1, 1); + } + + // Toggle between shaders when the user double-clicks. + function doubleClicked() { + showRedGreen = !showRedGreen; + } + +
+class: p5 +params: + - name: s + description: | +

p5.Shader object + to apply.

+ type: p5.Shader +chainable: true +--- + + +# shader diff --git a/src/content/reference/en/p5 copy/shearX.mdx b/src/content/reference/en/p5 copy/shearX.mdx new file mode 100644 index 0000000000..244fea83e2 --- /dev/null +++ b/src/content/reference/en/p5 copy/shearX.mdx @@ -0,0 +1,105 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L1069 +title: shearX +module: Transform +submodule: Transform +file: src/core/transform.js +description: > +

Shears the x-axis so that shapes appear skewed.

+ +

By default, the x- and y-axes are perpendicular. The shearX() + function + + transforms the coordinate system so that x-coordinates are translated while + + y-coordinates are fixed.

+ +

The first parameter, angle, is the amount to shear. For + example, calling + + shearX(1) transforms all x-coordinates using the formula + + x = x + y * tan(angle). shearX() interprets angle + values using the + + current angleMode().

+ +

By default, transformations accumulate. For example, calling + + shearX(1) twice has the same effect as calling + shearX(2) once. The + + push() and + + pop() functions can be used to isolate + + transformations within distinct drawing groups.

+ +

Note: Transformations are reset at the beginning of the draw loop. Calling + + shearX(1) inside the draw() + function won't + + cause shapes to shear continuously.

+line: 1069 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A white quadrilateral on a gray background.'); + } + + function draw() { + background(200); + + // Shear the coordinate system along the x-axis. + shearX(QUARTER_PI); + + // Draw the square. + square(0, 0, 50); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Use degrees. + angleMode(DEGREES); + + describe('A white quadrilateral on a gray background.'); + } + + function draw() { + background(200); + + // Shear the coordinate system along the x-axis. + shearX(45); + + // Draw the square. + square(0, 0, 50); + } + +
+class: p5 +params: + - name: angle + description: > +

angle to shear by in the current angleMode().

+ type: Number +chainable: true +--- + + +# shearX diff --git a/src/content/reference/en/p5 copy/shearY.mdx b/src/content/reference/en/p5 copy/shearY.mdx new file mode 100644 index 0000000000..007a8b4bfa --- /dev/null +++ b/src/content/reference/en/p5 copy/shearY.mdx @@ -0,0 +1,105 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L1146 +title: shearY +module: Transform +submodule: Transform +file: src/core/transform.js +description: > +

Shears the y-axis so that shapes appear skewed.

+ +

By default, the x- and y-axes are perpendicular. The shearY() + function + + transforms the coordinate system so that y-coordinates are translated while + + x-coordinates are fixed.

+ +

The first parameter, angle, is the amount to shear. For + example, calling + + shearY(1) transforms all y-coordinates using the formula + + y = y + x * tan(angle). shearY() interprets angle + values using the + + current angleMode().

+ +

By default, transformations accumulate. For example, calling + + shearY(1) twice has the same effect as calling + shearY(2) once. The + + push() and + + pop() functions can be used to isolate + + transformations within distinct drawing groups.

+ +

Note: Transformations are reset at the beginning of the draw loop. Calling + + shearY(1) inside the draw() + function won't + + cause shapes to shear continuously.

+line: 1146 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A white quadrilateral on a gray background.'); + } + + function draw() { + background(200); + + // Shear the coordinate system along the y-axis. + shearY(QUARTER_PI); + + // Draw the square. + square(0, 0, 50); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Use degrees. + angleMode(DEGREES); + + describe('A white quadrilateral on a gray background.'); + } + + function draw() { + background(200); + + // Shear the coordinate system along the y-axis. + shearY(45); + + // Draw the square. + square(0, 0, 50); + } + +
+class: p5 +params: + - name: angle + description: > +

angle to shear by in the current angleMode().

+ type: Number +chainable: true +--- + + +# shearY diff --git a/src/content/reference/en/p5 copy/shininess.mdx b/src/content/reference/en/p5 copy/shininess.mdx new file mode 100644 index 0000000000..a093e246c8 --- /dev/null +++ b/src/content/reference/en/p5 copy/shininess.mdx @@ -0,0 +1,86 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2998 +title: shininess +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Sets the amount of gloss ("shininess") of a + + specularMaterial().

+ +

Shiny materials focus reflected light more than dull materials. + + shininess() affects the way materials reflect light sources + including + + directionalLight(), + + pointLight(), + + and spotLight().

+ +

The parameter, shine, is a number that sets the amount of + shininess. + + shine must be greater than 1, which is its default value.

+line: 2998 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'Two red spheres drawn on a gray background. White light reflects from their surfaces as the mouse moves. The right sphere is shinier than the left sphere.' + ); + } + + function draw() { + background(200); + + // Turn on a red ambient light. + ambientLight(255, 0, 0); + + // Get the mouse's coordinates. + let mx = mouseX - 50; + let my = mouseY - 50; + + // Turn on a white point light that follows the mouse. + pointLight(255, 255, 255, mx, my, 50); + + // Style the sphere. + noStroke(); + + // Add a specular material with a grayscale value. + specularMaterial(255); + + // Draw the left sphere with low shininess. + translate(-25, 0, 0); + shininess(10); + sphere(20); + + // Draw the right sphere with high shininess. + translate(50, 0, 0); + shininess(100); + sphere(20); + } + +
+class: p5 +params: + - name: shine + description: | +

amount of shine.

+ type: Number +chainable: true +--- + + +# shininess diff --git a/src/content/reference/en/p5 copy/shorten.mdx b/src/content/reference/en/p5 copy/shorten.mdx new file mode 100644 index 0000000000..a1018f7fb8 --- /dev/null +++ b/src/content/reference/en/p5 copy/shorten.mdx @@ -0,0 +1,44 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L161 +title: shorten +module: Data +submodule: Array Functions +file: src/utilities/array_functions.js +description: | +

Decreases an array by one element and returns the shortened array, + maps to Array.pop().

+line: 161 +deprecated: >- + Use array.pop() + instead. +isConstructor: false +itemtype: method +example: + - |- + +
+ function setup() { + let myArray = ['A', 'B', 'C']; + print(myArray); // ['A', 'B', 'C'] + let newArray = shorten(myArray); + print(myArray); // ['A','B','C'] + print(newArray); // ['A','B'] + } +
+class: p5 +params: + - name: list + description: | +

Array to shorten

+ type: Array +return: + description: shortened Array + type: Array +chainable: false +--- + + +# shorten diff --git a/src/content/reference/en/p5 copy/shuffle.mdx b/src/content/reference/en/p5 copy/shuffle.mdx new file mode 100644 index 0000000000..a4ead252ef --- /dev/null +++ b/src/content/reference/en/p5 copy/shuffle.mdx @@ -0,0 +1,132 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L185 +title: shuffle +module: Data +submodule: Array Functions +file: src/utilities/array_functions.js +description: > +

Shuffles the elements of an array.

+ +

The first parameter, array, is the array to be shuffled. For + example, + + calling shuffle(myArray) will shuffle the elements of + myArray. By + + default, the original array won’t be modified. Instead, a copy will be + + created, shuffled, and returned.

+ +

The second parameter, modify, is optional. If + true is passed, as in + + shuffle(myArray, true), then the array will be shuffled in place + without + + making a copy.

+line: 185 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of colors. + let colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']; + + // Create a shuffled copy of the array. + let shuffledColors = shuffle(colors); + + // Draw a row of circles using the original array. + for (let i = 0; i < colors.length; i += 1) { + // Calculate the x-coordinate. + let x = (i + 1) * 12.5; + + // Style the circle. + let c = colors[i]; + fill(c); + + // Draw the circle. + circle(x, 33, 10); + } + + // Draw a row of circles using the original array. + for (let i = 0; i < shuffledColors.length; i += 1) { + // Calculate the x-coordinate. + let x = (i + 1) * 12.5; + + // Style the circle. + let c = shuffledColors[i]; + fill(c); + + // Draw the circle. + circle(x, 67, 10); + } + + describe( + 'Two rows of circles on a gray background. The top row follows the color sequence ROYGBIV. The bottom row has all the same colors but they are shuffled.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of colors. + let colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']; + + // Shuffle the array. + shuffle(colors, true); + + // Draw a row of circles using the original array. + for (let i = 0; i < colors.length; i += 1) { + // Calculate the x-coordinate. + let x = (i + 1) * 12.5; + + // Style the circle. + let c = colors[i]; + fill(c); + + // Draw the circle. + circle(x, 50, 10); + } + + describe( + 'A row of colorful circles on a gray background. Their sequence changes each time the sketch runs.' + ); + } + +
+class: p5 +params: + - name: array + description: | +

array to shuffle.

+ type: Array + - name: bool + description: > +

if true, shuffle the original array in place. Defaults to + false.

+ type: Boolean + optional: true +return: + description: shuffled array. + type: Array +chainable: false +--- + + +# shuffle diff --git a/src/content/reference/en/p5 copy/sin.mdx b/src/content/reference/en/p5 copy/sin.mdx new file mode 100644 index 0000000000..7f0cba972d --- /dev/null +++ b/src/content/reference/en/p5 copy/sin.mdx @@ -0,0 +1,107 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L363 +title: sin +module: Math +submodule: Trigonometry +file: src/math/trigonometry.js +description: > +

Calculates the sine of an angle.

+ +

sin() is useful for many geometric tasks in creative coding. + The values + + returned oscillate between -1 and 1 as the input angle increases. + sin() + + calculates the sine of an angle, using radians by default, or according to + + if angleMode() setting (RADIANS or + DEGREES).

+line: 363 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A white ball on a string oscillates up and down.'); + } + + function draw() { + background(200); + + // Calculate the coordinates. + let x = 50; + let y = 30 * sin(frameCount * 0.05) + 50; + + // Draw the oscillator. + line(50, y, x, y); + circle(x, y, 20); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + describe('A series of black dots form a wave pattern.'); + } + + function draw() { + // Calculate the coordinates. + let x = frameCount; + let y = 30 * sin(x * 0.1) + 50; + + // Draw the point. + point(x, y); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + describe('A series of black dots form an infinity symbol.'); + } + + function draw() { + // Calculate the coordinates. + let x = 30 * cos(frameCount * 0.1) + 50; + let y = 10 * sin(frameCount * 0.2) + 50; + + // Draw the point. + point(x, y); + } + +
+class: p5 +params: + - name: angle + description: > +

the angle, in radians by default, or according to + + if angleMode() setting (RADIANS or + DEGREES).

+ type: Number +return: + description: sine of the angle. + type: Number +chainable: false +--- + + +# sin diff --git a/src/content/reference/en/p5 copy/smooth.mdx b/src/content/reference/en/p5 copy/smooth.mdx new file mode 100644 index 0000000000..2c42bda62c --- /dev/null +++ b/src/content/reference/en/p5 copy/smooth.mdx @@ -0,0 +1,94 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L303 +title: smooth +module: Shape +submodule: Attributes +file: src/core/shape/attributes.js +description: > +

Draws certain features with smooth (antialiased) edges.

+ +

smooth() is active by default. In 2D mode, + + noSmooth() is helpful for scaling up + images + + without blurring. The functions don't affect shapes or fonts.

+ +

In WebGL mode, noSmooth() causes all + shapes to + + be drawn with jagged (aliased) edges. The functions don't affect images or + + fonts.

+line: 303 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let heart; + + // Load a pixelated heart image from an image data string. + function preload() { + heart = loadImage('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAAXNSR0IArs4c6QAAAEZJREFUGFd9jcsNACAIQ9tB2MeR3YdBMBBq8CIXPi2vBICIiOwkOedatllqWO6Y8yOWoyuNf1GZwgmf+RRG2YXr+xVFmA8HZ9Mx/KGPMtcAAAAASUVORK5CYII='); + } + + function setup() { + createCanvas(100, 100); + + background(50); + + // Antialiased hearts. + image(heart, 10, 10); + image(heart, 20, 10, 16, 16); + image(heart, 40, 10, 32, 32); + + // Aliased hearts. + noSmooth(); + image(heart, 10, 60); + image(heart, 20, 60, 16, 16); + image(heart, 40, 60, 32, 32); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + circle(0, 0, 80); + + describe('A white circle on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + // Disable smoothing. + noSmooth(); + + background(200); + + circle(0, 0, 80); + + describe('A pixelated white circle on a gray background.'); + } + +
+class: p5 +chainable: true +--- + + +# smooth diff --git a/src/content/reference/en/p5 copy/sort.mdx b/src/content/reference/en/p5 copy/sort.mdx new file mode 100644 index 0000000000..c2249d926a --- /dev/null +++ b/src/content/reference/en/p5 copy/sort.mdx @@ -0,0 +1,63 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L300 +title: sort +module: Data +submodule: Array Functions +file: src/utilities/array_functions.js +description: | +

Sorts an array of numbers from smallest to largest, or puts an array of + words in alphabetical order. The original array is not modified; a + re-ordered array is returned. The count parameter states the number of + elements to sort. For example, if there are 12 elements in an array and + count is set to 5, only the first 5 elements in the array will be sorted.

+line: 300 +deprecated: >- + Use array.sort() + instead. +isConstructor: false +itemtype: method +example: + - |- + +
+ function setup() { + let words = ['banana', 'apple', 'pear', 'lime']; + print(words); // ['banana', 'apple', 'pear', 'lime'] + let count = 4; // length of array + + words = sort(words, count); + print(words); // ['apple', 'banana', 'lime', 'pear'] + } +
+
+ function setup() { + let numbers = [2, 6, 1, 5, 14, 9, 8, 12]; + print(numbers); // [2, 6, 1, 5, 14, 9, 8, 12] + let count = 5; // Less than the length of the array + + numbers = sort(numbers, count); + print(numbers); // [1,2,5,6,14,9,8,12] + } +
+class: p5 +params: + - name: list + description: | +

Array to sort

+ type: Array + - name: count + description: | +

number of elements to sort, starting from 0

+ type: Integer + optional: true +return: + description: the sorted list + type: Array +chainable: false +--- + + +# sort diff --git a/src/content/reference/en/p5 copy/soundFormats.mdx b/src/content/reference/en/p5 copy/soundFormats.mdx new file mode 100644 index 0000000000..6bc28fe726 --- /dev/null +++ b/src/content/reference/en/p5 copy/soundFormats.mdx @@ -0,0 +1,51 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L925 +title: soundFormats +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: | +

List the SoundFile formats that you will include. LoadSound + will search your directory for these extensions, and will pick + a format that is compatable with the client's web browser. + Here is a free online file + converter.

+line: 925 +isConstructor: false +itemtype: method +example: + - |- + +
+ function preload() { + // set the global sound formats + soundFormats('mp3', 'ogg'); + + // load either beatbox.mp3, or .ogg, depending on browser + mySound = loadSound('/assets/beatbox.mp3'); + } + + function setup() { + let cnv = createCanvas(100, 100); + background(220); + text('sound loaded! tap to play', 10, 20, width - 20); + cnv.mousePressed(function() { + mySound.play(); + }); + } +
+class: p5 +params: + - name: formats + description: | +

i.e. 'mp3', 'wav', 'ogg'

+ type: String + optional: true + multiple: true +chainable: false +--- + + +# soundFormats diff --git a/src/content/reference/en/p5 copy/soundOut.mdx b/src/content/reference/en/p5 copy/soundOut.mdx new file mode 100644 index 0000000000..2f418a829c --- /dev/null +++ b/src/content/reference/en/p5 copy/soundOut.mdx @@ -0,0 +1,26 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L782 +title: soundOut +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: > +

p5.soundOut is the p5.sound final output bus. It sends output + to + + the destination of this window's web audio context. It contains + + Web Audio API nodes including a dyanmicsCompressor (.limiter), + + and Gain Nodes for .input and .output.

+line: 782 +isConstructor: false +itemtype: property +class: p5 +type: Object +--- + + +# soundOut diff --git a/src/content/reference/en/p5 copy/specularColor.mdx b/src/content/reference/en/p5 copy/specularColor.mdx new file mode 100644 index 0000000000..b23e834ca7 --- /dev/null +++ b/src/content/reference/en/p5 copy/specularColor.mdx @@ -0,0 +1,308 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L205 +title: specularColor +module: 3D +submodule: Lights +file: src/webgl/light.js +description: > +

Sets the specular color for lights.

+ +

specularColor() affects lights that bounce off a surface in a + preferred + + direction. These lights include + + directionalLight(), + + pointLight(), and + + spotLight(). The function helps to + create + + highlights on p5.Geometry objects that + are + + styled with specularMaterial(). + If a + + geometry does not use + + specularMaterial(), then + + specularColor() will have no effect.

+ +

Note: specularColor() doesn’t affect lights that bounce in all + + directions, including ambientLight() + and + + imageLight().

+ +

There are three ways to call specularColor() with optional + parameters to + + set the specular highlight color.

+ +

The first way to call specularColor() has two optional + parameters, gray + + and alpha. Grayscale and alpha values between 0 and 255, as in + + specularColor(50) or specularColor(50, 80), can be + passed to set the + + specular highlight color.

+ +

The second way to call specularColor() has one optional + parameter, + + color. A p5.Color object, an + array of color + + values, or a CSS color string can be passed to set the specular highlight + + color.

+ +

The third way to call specularColor() has four optional + parameters, v1, + + v2, v3, and alpha. RGBA, HSBA, or HSLA + values, as in + + specularColor(255, 0, 0, 80), can be passed to set the specular + highlight + + color. Color values will be interpreted using the current + + colorMode().

+line: 205 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white sphere drawn on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // No specular color. + // Draw the sphere. + sphere(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click the canvas to add a point light. + + let isLit = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A sphere drawn on a gray background. A spotlight starts shining when the user double-clicks.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Style the sphere. + noStroke(); + specularColor(100); + specularMaterial(255, 255, 255); + + // Control the light. + if (isLit === true) { + // Add a white point light from the top-right. + pointLight(255, 255, 255, 30, -20, 40); + } + + // Draw the sphere. + sphere(30); + } + + // Turn on the point light when the user double-clicks. + function doubleClicked() { + isLit = true; + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A black sphere drawn on a gray background. An area on the surface of the sphere is highlighted in blue.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Add a specular highlight. + // Use a p5.Color object. + let c = color('dodgerblue'); + specularColor(c); + + // Add a white point light from the top-right. + pointLight(255, 255, 255, 30, -20, 40); + + // Style the sphere. + noStroke(); + + // Add a white specular material. + specularMaterial(255, 255, 255); + + // Draw the sphere. + sphere(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A black sphere drawn on a gray background. An area on the surface of the sphere is highlighted in blue.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Add a specular highlight. + // Use a CSS color string. + specularColor('#1E90FF'); + + // Add a white point light from the top-right. + pointLight(255, 255, 255, 30, -20, 40); + + // Style the sphere. + noStroke(); + + // Add a white specular material. + specularMaterial(255, 255, 255); + + // Draw the sphere. + sphere(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A black sphere drawn on a gray background. An area on the surface of the sphere is highlighted in blue.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Add a specular highlight. + // Use RGB values. + specularColor(30, 144, 255); + + // Add a white point light from the top-right. + pointLight(255, 255, 255, 30, -20, 40); + + // Style the sphere. + noStroke(); + + // Add a white specular material. + specularMaterial(255, 255, 255); + + // Draw the sphere. + sphere(30); + } + +
+class: p5 +overloads: + - line: 205 + params: + - name: v1 + description: | +

red or hue value in the current + colorMode().

+ type: Number + - name: v2 + description: | +

green or saturation value in the current + colorMode().

+ type: Number + - name: v3 + description: | +

blue, brightness, or lightness value in the current + colorMode().

+ type: Number + chainable: 1 + - line: 423 + params: + - name: gray + description: | +

grayscale value between 0 and 255.

+ type: Number + chainable: 1 + - line: 429 + params: + - name: value + description: | +

color as a CSS string.

+ type: String + chainable: 1 + - line: 435 + params: + - name: values + description: | +

color as an array of RGBA, HSBA, or HSLA + values.

+ type: 'Number[]' + chainable: 1 + - line: 442 + params: + - name: color + description: | +

color as a p5.Color object.

+ type: p5.Color + chainable: 1 +chainable: true +--- + + +# specularColor diff --git a/src/content/reference/en/p5 copy/specularMaterial.mdx b/src/content/reference/en/p5 copy/specularMaterial.mdx new file mode 100644 index 0000000000..57e8977cf5 --- /dev/null +++ b/src/content/reference/en/p5 copy/specularMaterial.mdx @@ -0,0 +1,311 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2743 +title: specularMaterial +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Sets the specular color of shapes’ surface material.

+ +

The specularMaterial() color sets the components of light + color that + + glossy coats on shapes will reflect. For example, calling + + specularMaterial(255, 255, 0) would cause a shape to reflect red + and + + green light, but not blue light.

+ +

Unlike ambientMaterial(), + + specularMaterial() will reflect the full color of light sources + including + + directionalLight(), + + pointLight(), + + and spotLight(). This is what gives it + shapes + + their "shiny" appearance. The material’s shininess can be controlled by the + + shininess() function.

+ +

specularMaterial() can be called three ways with different + parameters to + + set the material’s color.

+ +

The first way to call specularMaterial() has one parameter, + gray. + + Grayscale values between 0 and 255, as in specularMaterial(50), + can be + + passed to set the material’s color. Higher grayscale values make shapes + + appear brighter.

+ +

The second way to call specularMaterial() has one parameter, + color. A + + p5.Color> object, an array of color values, + or a CSS + + color string, as in specularMaterial('magenta'), can be passed to + set the + + material’s color.

+ +

The third way to call specularMaterial() has four parameters, + v1, v2, + + v3, and alpha. alpha is optional. RGBA, + HSBA, or HSLA values can be + + passed to set the material’s colors, as in specularMaterial(255, 0, + 0) or + + specularMaterial(255, 0, 0, 30). Color values will be interpreted + using + + the current colorMode().

+line: 2743 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click the canvas to apply a specular material. + + let isGlossy = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A red torus drawn on a gray background. It becomes glossy when the user double-clicks.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on a white point light at the top-right. + pointLight(255, 255, 255, 30, -40, 30); + + // Add a glossy coat if the user has double-clicked. + if (isGlossy === true) { + specularMaterial(255); + shininess(50); + } + + // Style the torus. + noStroke(); + fill(255, 0, 0); + + // Draw the torus. + torus(30); + } + + // Make the torus glossy when the user double-clicks. + function doubleClicked() { + isGlossy = true; + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click the canvas to apply a specular material. + + let isGlossy = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'A red torus drawn on a gray background. It becomes glossy and reflects green light when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on a white point light at the top-right. + pointLight(255, 255, 255, 30, -40, 30); + + // Add a glossy green coat if the user has double-clicked. + if (isGlossy === true) { + specularMaterial(0, 255, 0); + shininess(50); + } + + // Style the torus. + noStroke(); + fill(255, 0, 0); + + // Draw the torus. + torus(30); + } + + // Make the torus glossy when the user double-clicks. + function doubleClicked() { + isGlossy = true; + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click the canvas to apply a specular material. + + let isGlossy = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'A red torus drawn on a gray background. It becomes glossy and reflects green light when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on a white point light at the top-right. + pointLight(255, 255, 255, 30, -40, 30); + + // Add a glossy green coat if the user has double-clicked. + if (isGlossy === true) { + // Create a p5.Color object. + let c = color('green'); + specularMaterial(c); + shininess(50); + } + + // Style the torus. + noStroke(); + fill(255, 0, 0); + + // Draw the torus. + torus(30); + } + + // Make the torus glossy when the user double-clicks. + function doubleClicked() { + isGlossy = true; + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click the canvas to apply a specular material. + + let isGlossy = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'A red torus drawn on a gray background. It becomes glossy and reflects green light when the user double-clicks.' + ); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on a white point light at the top-right. + pointLight(255, 255, 255, 30, -40, 30); + + // Add a glossy green coat if the user has double-clicked. + if (isGlossy === true) { + specularMaterial('#00FF00'); + shininess(50); + } + + // Style the torus. + noStroke(); + fill(255, 0, 0); + + // Draw the torus. + torus(30); + } + + // Make the torus glossy when the user double-clicks. + function doubleClicked() { + isGlossy = true; + } + +
+class: p5 +overloads: + - line: 2743 + params: + - name: gray + description: | +

grayscale value between 0 (black) and 255 (white).

+ type: Number + - name: alpha + description: | +

alpha value in the current current + colorMode().

+ type: Number + optional: true + chainable: 1 + - line: 2966 + params: + - name: v1 + description: | +

red or hue value in + the current colorMode().

+ type: Number + - name: v2 + description: | +

green or saturation value + in the current colorMode().

+ type: Number + - name: v3 + description: | +

blue, brightness, or lightness value + in the current colorMode().

+ type: Number + - name: alpha + description: '' + type: Number + optional: true + chainable: 1 + - line: 2978 + params: + - name: color + description: | +

color as a p5.Color object, + an array of color values, or a CSS string.

+ type: 'p5.Color|Number[]|String' + chainable: 1 +chainable: true +--- + + +# specularMaterial diff --git a/src/content/reference/en/p5 copy/sphere.mdx b/src/content/reference/en/p5 copy/sphere.mdx new file mode 100644 index 0000000000..c2ceca44ad --- /dev/null +++ b/src/content/reference/en/p5 copy/sphere.mdx @@ -0,0 +1,165 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L1227 +title: sphere +module: Shape +submodule: 3D Primitives +file: src/webgl/3d_primitives.js +description: > +

Draws a sphere.

+ +

A sphere is a 3D shape with triangular faces that connect to form a round + + surface. Spheres with few faces look like crystals. Spheres with many faces + + have smooth surfaces and look like balls.

+ +

The first parameter, radius, is optional. If a + Number is passed, as in + + sphere(20), it sets the radius of the sphere. By default, + radius is 50.

+ +

The second parameter, detailX, is also optional. If a + Number is passed, + + as in sphere(20, 5), it sets the number of triangle subdivisions + to use + + along the x-axis. All 3D shapes are made by connecting triangles to form + + their surfaces. By default, detailX is 24.

+ +

The third parameter, detailY, is also optional. If a + Number is passed, + + as in sphere(20, 5, 2), it sets the number of triangle + subdivisions to + + use along the y-axis. All 3D shapes are made by connecting triangles to + + form their surfaces. By default, detailY is 16.

+ +

Note: sphere() can only be used in WebGL mode.

+line: 1227 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white sphere on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the sphere. + sphere(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white sphere on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the sphere. + // Set its radius to 30. + sphere(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white sphere on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the sphere. + // Set its radius to 30. + // Set its detailX to 6. + sphere(30, 6); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white sphere on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the sphere. + // Set its radius to 30. + // Set its detailX to 24. + // Set its detailY to 4. + sphere(30, 24, 4); + } + +
+class: p5 +params: + - name: radius + description: | +

radius of the sphere. Defaults to 50.

+ type: Number + optional: true + - name: detailX + description: | +

number of triangle subdivisions along the x-axis. Defaults to 24.

+ type: Integer + optional: true + - name: detailY + description: | +

number of triangle subdivisions along the y-axis. Defaults to 16.

+ type: Integer + optional: true +chainable: true +--- + + +# sphere diff --git a/src/content/reference/en/p5 copy/splice.mdx b/src/content/reference/en/p5 copy/splice.mdx new file mode 100644 index 0000000000..866bc4ddef --- /dev/null +++ b/src/content/reference/en/p5 copy/splice.mdx @@ -0,0 +1,58 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L346 +title: splice +module: Data +submodule: Array Functions +file: src/utilities/array_functions.js +description: | +

Inserts a value or an array of values into an existing array. The first + parameter specifies the initial array to be modified, and the second + parameter defines the data to be inserted. The third parameter is an index + value which specifies the array position from which to insert data. + (Remember that array index numbering starts at zero, so the first position + is 0, the second position is 1, and so on.)

+line: 346 +deprecated: >- + Use array.splice() + instead. +isConstructor: false +itemtype: method +example: + - |- + +
+ function setup() { + let myArray = [0, 1, 2, 3, 4]; + let insArray = ['A', 'B', 'C']; + print(myArray); // [0, 1, 2, 3, 4] + print(insArray); // ['A','B','C'] + + splice(myArray, insArray, 3); + print(myArray); // [0,1,2,'A','B','C',3,4] + } +
+class: p5 +params: + - name: list + description: | +

Array to splice into

+ type: Array + - name: value + description: | +

value to be spliced in

+ type: Any + - name: position + description: | +

in the array from which to insert data

+ type: Integer +return: + description: the list + type: Array +chainable: false +--- + + +# splice diff --git a/src/content/reference/en/p5 copy/split.mdx b/src/content/reference/en/p5 copy/split.mdx new file mode 100644 index 0000000000..60b7944313 --- /dev/null +++ b/src/content/reference/en/p5 copy/split.mdx @@ -0,0 +1,87 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L690 +title: split +module: Data +submodule: String Functions +file: src/utilities/string_functions.js +description: > +

Splits a String into pieces and returns an array containing + the pieces.

+ +

The first parameter, value, is the string to split.

+ +

The second parameter, delim, is the character(s) that should + be used to + + split the string. For example, calling + + split('rock...paper...scissors', '...') would return the array + + ['rock', 'paper', 'scissors'] because there are three periods + ... + + between each word.

+line: 690 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let string = 'rock...paper...scissors'; + + // Split the string at each ... + let words = split(string, '...'); + + // Print the array to the console: + // ["rock", "paper", "scissors"] + print(words); + + // Style the text. + textAlign(CENTER, CENTER); + textFont('Courier New'); + textSize(16); + + // Iterate over the words array. + for (let i = 0; i < words.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 25; + + // Display the word. + text(words[i], 50, y); + } + + describe( + 'The words "rock", "paper", and "scissors" written on separate lines. The text is black on a gray background.' + ); + } + +
+class: p5 +params: + - name: value + description: | +

the String to be split

+ type: String + - name: delim + description: | +

the String used to separate the data

+ type: String +return: + description: Array of Strings + type: 'String[]' +chainable: false +--- + + +# split diff --git a/src/content/reference/en/p5 copy/splitTokens.mdx b/src/content/reference/en/p5 copy/splitTokens.mdx new file mode 100644 index 0000000000..95d6ef4f8e --- /dev/null +++ b/src/content/reference/en/p5 copy/splitTokens.mdx @@ -0,0 +1,180 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L751 +title: splitTokens +module: Data +submodule: String Functions +file: src/utilities/string_functions.js +description: > +

Splits a String into pieces and returns an array containing + the pieces.

+ +

splitTokens() is an enhanced version of + + split(). It can split a string when any + characters + + from a list are detected.

+ +

The first parameter, value, is the string to split.

+ +

The second parameter, delim, is optional. It sets the + character(s) that + + should be used to split the string. delim can be a single string, + as in + + splitTokens('rock...paper...scissors...shoot', '...'), or an + array of + + strings, as in + + splitTokens('rock;paper,scissors...shoot, [';', ',', '...']). By + default, + + if no delim characters are specified, then any whitespace + character is + + used to split. Whitespace characters include tab (\t), line feed + (\n), + + carriage return (\r), form feed (\f), and space.

+line: 751 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let string = 'rock paper scissors shoot'; + + // Split the string at each space. + let words = splitTokens(string); + + // Print the array to the console. + print(words); + + // Style the text. + textAlign(CENTER, CENTER); + textFont('Courier New'); + textSize(12); + + // Iterate over the words array. + for (let i = 0; i < words.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 20; + + // Display the word. + text(words[i], 50, y); + } + + describe( + 'The words "rock", "paper", "scissors", and "shoot" written on separate lines. The text is black on a gray background.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let string = 'rock...paper...scissors...shoot'; + + // Split the string at each ... + let words = splitTokens(string, '...'); + + // Print the array to the console. + print(words); + + // Style the text. + textAlign(CENTER, CENTER); + textFont('Courier New'); + textSize(12); + + // Iterate over the words array. + for (let i = 0; i < words.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 20; + + // Display the word. + text(words[i], 50, y); + } + + describe( + 'The words "rock", "paper", "scissors", and "shoot" written on separate lines. The text is black on a gray background.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let string = 'rock;paper,scissors...shoot'; + + // Split the string at each semicolon, comma, or ... + let words = splitTokens(string, [';', ',', '...']); + + // Print the array to the console. + print(words); + + // Style the text. + textAlign(CENTER, CENTER); + textFont('Courier New'); + textSize(12); + + // Iterate over the words array. + for (let i = 0; i < words.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 20; + + // Display the word. + text(words[i], 50, y); + } + + describe( + 'The words "rock", "paper", "scissors", and "shoot" written on separate lines. The text is black on a gray background.' + ); + } + +
+class: p5 +params: + - name: value + description: | +

string to split.

+ type: String + - name: delim + description: | +

character(s) to use for splitting the string.

+ type: String + optional: true +return: + description: separated strings. + type: 'String[]' +chainable: false +--- + + +# splitTokens diff --git a/src/content/reference/en/p5 copy/spotLight.mdx b/src/content/reference/en/p5 copy/spotLight.mdx new file mode 100644 index 0000000000..3d221dc8f4 --- /dev/null +++ b/src/content/reference/en/p5 copy/spotLight.mdx @@ -0,0 +1,398 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L1272 +title: spotLight +module: 3D +submodule: Lights +file: src/webgl/light.js +description: > +

Creates a light that shines from a point in one direction.

+ +

Spot lights are like flashlights that shine in one direction creating a + + cone of light. The shape of the cone can be controlled using the angle and + + concentration parameters. A maximum of 5 spot lights can be active at + once.

+ +

There are eight ways to call spotLight() with parameters to + set the + + light’s color, position, direction. For example, + + spotLight(255, 0, 0, 0, 0, 0, 1, 0, 0) creates a red (255, + 0, 0) light + + at the origin (0, 0, 0) that points to the right (1, 0, + 0).

+ +

The angle parameter is optional. It sets the radius of the + light cone. + + For example, spotLight(255, 0, 0, 0, 0, 0, 1, 0, 0, PI / 16) + creates a + + red (255, 0, 0) light at the origin (0, 0, 0) that + points to the right + + (1, 0, 0) with an angle of PI / 16 radians. By + default, angle is + + PI / 3 radians.

+ +

The concentration parameter is also optional. It focuses the + light + + towards the center of the light cone. For example, + + spotLight(255, 0, 0, 0, 0, 0, 1, 0, 0, PI / 16, 50) creates a red + + (255, 0, 0) light at the origin (0, 0, 0) that + points to the right + + (1, 0, 0) with an angle of PI / 16 radians at + concentration of 50. By + + default, concentration is 100.

+line: 1272 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click to adjust the spotlight. + + let isLit = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white sphere drawn on a gray background. A red spotlight starts shining when the user double-clicks.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Control the spotlight. + if (isLit === true) { + // Add a red spot light that shines into the screen. + // Set its angle to PI / 32 radians. + spotLight(255, 0, 0, 0, 0, 100, 0, 0, -1, PI / 32); + } + + // Draw the sphere. + sphere(30); + } + + // Turn on the spotlight when the user double-clicks. + function doubleClicked() { + isLit = true; + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + // Double-click to adjust the spotlight. + + let isLit = false; + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white sphere drawn on a gray background. A red spotlight starts shining when the user double-clicks.'); + } + + function draw() { + background(50); + + // Enable orbiting with the mouse. + orbitControl(); + + // Turn on the lights. + lights(); + + // Control the spotlight. + if (isLit === true) { + // Add a red spot light that shines into the screen. + // Set its angle to PI / 3 radians (default). + // Set its concentration to 1000. + let c = color(255, 0, 0); + let position = createVector(0, 0, 100); + let direction = createVector(0, 0, -1); + spotLight(c, position, direction, PI / 3, 1000); + } + + // Draw the sphere. + sphere(30); + } + + // Turn on the spotlight when the user double-clicks. + function doubleClicked() { + isLit = true; + } + +
+class: p5 +overloads: + - line: 1272 + params: + - name: v1 + description: | +

red or hue value in the current + colorMode().

+ type: Number + - name: v2 + description: | +

green or saturation value in the current + colorMode().

+ type: Number + - name: v3 + description: | +

blue, brightness, or lightness value in the current + colorMode().

+ type: Number + - name: x + description: | +

x-coordinate of the light.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the light.

+ type: Number + - name: z + description: | +

z-coordinate of the light.

+ type: Number + - name: rx + description: | +

x-component of light direction between -1 and 1.

+ type: Number + - name: ry + description: | +

y-component of light direction between -1 and 1.

+ type: Number + - name: rz + description: | +

z-component of light direction between -1 and 1.

+ type: Number + - name: angle + description: | +

angle of the light cone. Defaults to PI / 3.

+ type: Number + optional: true + - name: concentration + description: | +

concentration of the light. Defaults to 100.

+ type: Number + optional: true + chainable: 1 + - line: 1399 + params: + - name: color + description: | +

color as a p5.Color object, + an array of color values, or a CSS string.

+ type: 'p5.Color|Number[]|String' + - name: position + description: > +

position of the light as a p5.Vector + object.

+ type: p5.Vector + - name: direction + description: > +

direction of light as a p5.Vector + object.

+ type: p5.Vector + - name: angle + description: '' + type: Number + optional: true + - name: concentration + description: '' + type: Number + optional: true + - line: 1408 + params: + - name: v1 + description: '' + type: Number + - name: v2 + description: '' + type: Number + - name: v3 + description: '' + type: Number + - name: position + description: '' + type: p5.Vector + - name: direction + description: '' + type: p5.Vector + - name: angle + description: '' + type: Number + optional: true + - name: concentration + description: '' + type: Number + optional: true + - line: 1418 + params: + - name: color + description: '' + type: 'p5.Color|Number[]|String' + - name: x + description: '' + type: Number + - name: 'y' + description: '' + type: Number + - name: z + description: '' + type: Number + - name: direction + description: '' + type: p5.Vector + - name: angle + description: '' + type: Number + optional: true + - name: concentration + description: '' + type: Number + optional: true + - line: 1428 + params: + - name: color + description: '' + type: 'p5.Color|Number[]|String' + - name: position + description: '' + type: p5.Vector + - name: rx + description: '' + type: Number + - name: ry + description: '' + type: Number + - name: rz + description: '' + type: Number + - name: angle + description: '' + type: Number + optional: true + - name: concentration + description: '' + type: Number + optional: true + - line: 1438 + params: + - name: v1 + description: '' + type: Number + - name: v2 + description: '' + type: Number + - name: v3 + description: '' + type: Number + - name: x + description: '' + type: Number + - name: 'y' + description: '' + type: Number + - name: z + description: '' + type: Number + - name: direction + description: '' + type: p5.Vector + - name: angle + description: '' + type: Number + optional: true + - name: concentration + description: '' + type: Number + optional: true + - line: 1450 + params: + - name: v1 + description: '' + type: Number + - name: v2 + description: '' + type: Number + - name: v3 + description: '' + type: Number + - name: position + description: '' + type: p5.Vector + - name: rx + description: '' + type: Number + - name: ry + description: '' + type: Number + - name: rz + description: '' + type: Number + - name: angle + description: '' + type: Number + optional: true + - name: concentration + description: '' + type: Number + optional: true + - line: 1462 + params: + - name: color + description: '' + type: 'p5.Color|Number[]|String' + - name: x + description: '' + type: Number + - name: 'y' + description: '' + type: Number + - name: z + description: '' + type: Number + - name: rx + description: '' + type: Number + - name: ry + description: '' + type: Number + - name: rz + description: '' + type: Number + - name: angle + description: '' + type: Number + optional: true + - name: concentration + description: '' + type: Number + optional: true +chainable: true +--- + + +# spotLight diff --git a/src/content/reference/en/p5 copy/sq.mdx b/src/content/reference/en/p5 copy/sq.mdx new file mode 100644 index 0000000000..da0f2c4024 --- /dev/null +++ b/src/content/reference/en/p5 copy/sq.mdx @@ -0,0 +1,83 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L928 +title: sq +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Calculates the square of a number.

+ +

Squaring a number means multiplying the number by itself. For example, + + sq(3) evaluates 3 × 3 which is 9. sq(-3) evaluates + -3 × -3 + + which is also 9. Multiplying two negative numbers produces a positive + + number. The value returned by sq() is always positive.

+line: 928 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Top-left. + let d = sq(3); + circle(33, 33, d); + + // Bottom-right. + d = sq(6); + circle(67, 67, d); + + describe('Two white circles. The circle at the top-left is small. The circle at the bottom-right is four times larger.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + describe('A series of black dots that get higher quickly from left to right.'); + } + + function draw() { + // Invert the y-axis. + scale(1, -1); + translate(0, -100); + + // Calculate the coordinates. + let x = frameCount; + let y = 0.01 * sq(x); + + // Draw the point. + point(x, y); + } + +
+class: p5 +params: + - name: 'n' + description: | +

number to square.

+ type: Number +return: + description: squared number. + type: Number +chainable: false +--- + + +# sq diff --git a/src/content/reference/en/p5 copy/sqrt.mdx b/src/content/reference/en/p5 copy/sqrt.mdx new file mode 100644 index 0000000000..5e239f6fe4 --- /dev/null +++ b/src/content/reference/en/p5 copy/sqrt.mdx @@ -0,0 +1,84 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L988 +title: sqrt +module: Math +submodule: Calculation +file: src/math/calculation.js +description: > +

Calculates the square root of a number.

+ +

A number's square root can be multiplied by itself to produce the original + + number. For example, sqrt(9) returns 3 because 3 × 3 = 9. + sqrt() + + always returns a positive value. sqrt() doesn't work with + negative arguments + + such as sqrt(-9).

+line: 988 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Top-left. + let d = sqrt(16); + circle(33, 33, d); + + // Bottom-right. + d = sqrt(1600); + circle(67, 67, d); + + describe('Two white circles. The circle at the top-left is small. The circle at the bottom-right is ten times larger.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + describe('A series of black dots that get higher slowly from left to right.'); + } + + function draw() { + // Invert the y-axis. + scale(1, -1); + translate(0, -100); + + // Calculate the coordinates. + let x = frameCount; + let y = 5 * sqrt(x); + + // Draw the point. + point(x, y); + } + +
+class: p5 +params: + - name: 'n' + description: | +

non-negative number to square root.

+ type: Number +return: + description: square root of number. + type: Number +chainable: false +--- + + +# sqrt diff --git a/src/content/reference/en/p5 copy/square.mdx b/src/content/reference/en/p5 copy/square.mdx new file mode 100644 index 0000000000..1e94a0087d --- /dev/null +++ b/src/content/reference/en/p5 copy/square.mdx @@ -0,0 +1,163 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L1229 +title: square +module: Shape +submodule: 2D Primitives +file: src/core/shape/2d_primitives.js +description: > +

Draws a square.

+ +

A square is a four-sided shape defined by the x, + y, and s + + parameters. x and y set the location of its top-left + corner. s sets + + its width and height. Every angle in the square measures 90˚ and all its + + sides are the same length. See rectMode() for + + other ways to define squares.

+ +

The version of square() with four parameters creates a rounded + square. + + The fourth parameter sets the radius for all four corners.

+ +

The version of square() with seven parameters also creates a + rounded + + square. Each of the last four parameters set the radius of a corner. The + + radii start with the top-left corner and move clockwise around the + + square. If any of these parameters are omitted, they are set to the + + value of the last radius that was set.

+line: 1229 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + square(30, 20, 55); + + describe('A white square with a black outline in on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Give all corners a radius of 20. + square(30, 20, 55, 20); + + describe( + 'A white square with a black outline and round edges on a gray canvas.' + ); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Give each corner a unique radius. + square(30, 20, 55, 20, 15, 10, 5); + + describe('A white square with a black outline and round edges of different radii.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + square(-20, -30, 55); + + describe('A white square with a black outline in on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white square spins around on gray canvas.'); + } + + function draw() { + background(200); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Draw the square. + square(-20, -30, 55); + } + +
+class: p5 +params: + - name: x + description: | +

x-coordinate of the square.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the square.

+ type: Number + - name: s + description: | +

side size of the square.

+ type: Number + - name: tl + description: | +

optional radius of top-left corner.

+ type: Number + optional: true + - name: tr + description: | +

optional radius of top-right corner.

+ type: Number + optional: true + - name: br + description: | +

optional radius of bottom-right corner.

+ type: Number + optional: true + - name: bl + description: | +

optional radius of bottom-left corner.

+ type: Number + optional: true +chainable: true +--- + + +# square diff --git a/src/content/reference/en/p5 copy/storeItem.mdx b/src/content/reference/en/p5 copy/storeItem.mdx new file mode 100644 index 0000000000..8552634c5a --- /dev/null +++ b/src/content/reference/en/p5 copy/storeItem.mdx @@ -0,0 +1,149 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/data/local_storage.js#L10 +title: storeItem +module: Data +submodule: LocalStorage +file: src/data/local_storage.js +description: > +

Stores a value in the web browser's local storage.

+ +

Web browsers can save small amounts of data using the built-in + + localStorage object. + + Data stored in localStorage can be retrieved at any point, even + after + + refreshing a page or restarting the browser. Data are stored as key-value + + pairs.

+ +

storeItem() makes it easy to store values in + localStorage and + + getItem() makes it easy to retrieve + them.

+ +

The first parameter, key, is the name of the value to be + stored as a + + string.

+ +

The second parameter, value, is the value to be stored. Values + can have + + any type.

+ +

Note: Sensitive data such as passwords or personal information shouldn't be + + stored in localStorage.

+line: 10 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + // Store the player's name. + storeItem('name', 'Feist'); + + // Store the player's score. + storeItem('score', 1234); + + describe('The text "Feist: 1234" written in black on a gray background.'); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(14); + + // Retrieve the name. + let name = getItem('name'); + + // Retrieve the score. + let score = getItem('score'); + + // Display the score. + text(`${name}: ${score}`, 50, 50); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Create an object. + let p = { x: 50, y: 50 }; + + // Store the object. + storeItem('position', p); + + describe('A white circle on a gray background.'); + } + + function draw() { + background(200); + + // Retrieve the object. + let p = getItem('position'); + + // Draw the circle. + circle(p.x, p.y, 30); + } + +
+ + function setup() { + createCanvas(100, 100); + + // Create a p5.Color object. + let c = color('deeppink'); + + // Store the object. + storeItem('color', c); + + describe('A pink circle on a gray background.'); + } + + function draw() { + background(200); + + // Retrieve the object. + let c = getItem('color'); + + // Style the circle. + fill(c); + + // Draw the circle. + circle(50, 50, 30); + } + + +class: p5 +params: + - name: key + description: | +

name of the value.

+ type: String + - name: value + description: | +

value to be stored.

+ type: String|Number|Boolean|Object|Array +chainable: false +--- + + +# storeItem diff --git a/src/content/reference/en/p5 copy/str.mdx b/src/content/reference/en/p5 copy/str.mdx new file mode 100644 index 0000000000..c487979761 --- /dev/null +++ b/src/content/reference/en/p5 copy/str.mdx @@ -0,0 +1,135 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L232 +title: str +module: Data +submodule: Conversion +file: src/utilities/conversion.js +description: > +

Converts a Boolean or Number to + String.

+ +

str() converts values to strings. See the + + String reference page for guidance on + using + + template literals instead.

+ +

The parameter, n, is the value to convert. If n + is a Boolean, as in + + str(false) or str(true), then the value will be + returned as a string, + + as in 'false' or 'true'. If n is a + number, as in str(123), then its + + value will be returned as a string, as in '123'. If an array is + passed, + + as in str([12.34, 56.78]), then an array of strings will be + returned.

+line: 232 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a Boolean variable. + let original = false; + + // Convert the Boolean to a string. + let converted = str(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the original and converted values. + text(`${original} : ${converted}`, 50, 50); + + describe('The text "false : false" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a number variable. + let original = 123; + + // Convert the number to a string. + let converted = str(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the original and converted values. + text(`${original} = ${converted}`, 50, 50); + + describe('The text "123 = 123" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of numbers. + let original = [12, 34, 56]; + + // Convert the numbers to strings. + let strings = str(original); + + // Create an empty string variable. + let final = ''; + + // Concatenate all the strings. + for (let s of strings) { + final += s; + } + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the concatenated string. + text(final, 50, 50); + + describe('The text "123456" written in black on a gray background.'); + } + +
+class: p5 +params: + - name: 'n' + description: | +

value to convert.

+ type: String|Boolean|Number +return: + description: converted string. + type: String +chainable: false +--- + + +# str diff --git a/src/content/reference/en/p5 copy/stroke.mdx b/src/content/reference/en/p5 copy/stroke.mdx new file mode 100644 index 0000000000..bf086f9b66 --- /dev/null +++ b/src/content/reference/en/p5 copy/stroke.mdx @@ -0,0 +1,311 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1373 +title: stroke +module: Color +submodule: Setting +file: src/color/setting.js +description: > +

Sets the color used to draw points, lines, and the outlines of shapes.

+ +

Calling stroke(255, 165, 0) or stroke('orange') + means all shapes drawn + + after calling stroke() will be outlined with the color orange. + The way + + these parameters are interpreted may be changed with the + + colorMode() function.

+ +

The version of stroke() with one parameter interprets the + value one of + + three ways. If the parameter is a Number, it's interpreted as a + grayscale + + value. If the parameter is a String, it's interpreted as a CSS + color + + string. A p5.Color object can also be + provided to + + set the stroke color.

+ +

The version of stroke() with two parameters interprets the + first one as a + + grayscale value. The second parameter sets the alpha (transparency) value.

+ +

The version of stroke() with three parameters interprets them + as RGB, HSB, + + or HSL colors, depending on the current colorMode().

+ +

The version of stroke() with four parameters interprets them + as RGBA, HSBA, + + or HSLA colors, depending on the current colorMode(). The last + parameter + + sets the alpha (transparency) value.

+line: 1373 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // A grayscale value. + strokeWeight(4); + stroke(51); + square(20, 20, 60); + + describe('A white square with a dark charcoal gray outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // R, G & B values. + stroke(255, 204, 0); + strokeWeight(4); + square(20, 20, 60); + + describe('A white square with a yellow outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Use HSB color. + colorMode(HSB); + + // H, S & B values. + strokeWeight(4); + stroke(255, 204, 100); + square(20, 20, 60); + + describe('A white square with a royal blue outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // A CSS named color. + stroke('red'); + strokeWeight(4); + square(20, 20, 60); + + describe('A white square with a red outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Three-digit hex RGB notation. + stroke('#fae'); + strokeWeight(4); + square(20, 20, 60); + + describe('A white square with a pink outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Six-digit hex RGB notation. + stroke('#222222'); + strokeWeight(4); + square(20, 20, 60); + + describe('A white square with a black outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Integer RGB notation. + stroke('rgb(0, 255, 0)'); + strokeWeight(4); + square(20, 20, 60); + + describe('A whiite square with a bright green outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Integer RGBA notation. + stroke('rgba(0, 255, 0, 0.25)'); + strokeWeight(4); + square(20, 20, 60); + + describe('A white square with a soft green outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Percentage RGB notation. + stroke('rgb(100%, 0%, 10%)'); + strokeWeight(4); + square(20, 20, 60); + + describe('A white square with a red outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Percentage RGBA notation. + stroke('rgba(100%, 0%, 100%, 0.5)'); + strokeWeight(4); + square(20, 20, 60); + + describe('A white square with a dark fuchsia outline.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // A p5.Color object. + stroke(color(0, 0, 255)); + strokeWeight(4); + square(20, 20, 60); + + describe('A white square with a blue outline.'); + } + +
+class: p5 +overloads: + - line: 1373 + params: + - name: v1 + description: > +

red value if color mode is RGB or hue value if color mode is + HSB.

+ type: Number + - name: v2 + description: > +

green value if color mode is RGB or saturation value if color mode + is HSB.

+ type: Number + - name: v3 + description: > +

blue value if color mode is RGB or brightness value if color mode + is HSB.

+ type: Number + - name: alpha + description: > +

alpha value, controls transparency (0 - transparent, 255 - + opaque).

+ type: Number + optional: true + chainable: 1 + - line: 1596 + params: + - name: value + description: | +

a color string.

+ type: String + chainable: 1 + - line: 1602 + params: + - name: gray + description: | +

a grayscale value.

+ type: Number + - name: alpha + description: '' + type: Number + optional: true + chainable: 1 + - line: 1609 + params: + - name: values + description: | +

an array containing the red, green, blue, + and alpha components of the color.

+ type: 'Number[]' + chainable: 1 + - line: 1616 + params: + - name: color + description: | +

the stroke color.

+ type: p5.Color + chainable: 1 +chainable: true +--- + + +# stroke diff --git a/src/content/reference/en/p5 copy/strokeCap.mdx b/src/content/reference/en/p5 copy/strokeCap.mdx new file mode 100644 index 0000000000..80965419ab --- /dev/null +++ b/src/content/reference/en/p5 copy/strokeCap.mdx @@ -0,0 +1,67 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L388 +title: strokeCap +module: Shape +submodule: Attributes +file: src/core/shape/attributes.js +description: > +

Sets the style for rendering the ends of lines.

+ +

The caps for line endings are either rounded (ROUND), squared + + (SQUARE), or extended (PROJECT). The default cap is + ROUND.

+ +

The argument passed to strokeCap() must be written in ALL CAPS + because + + the constants ROUND, SQUARE, and + PROJECT are defined this way. + + JavaScript is a case-sensitive language.

+line: 388 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + strokeWeight(12); + + // Top. + strokeCap(ROUND); + line(20, 30, 80, 30); + + // Middle. + strokeCap(SQUARE); + line(20, 50, 80, 50); + + // Bottom. + strokeCap(PROJECT); + line(20, 70, 80, 70); + + describe( + 'Three horizontal lines. The top line has rounded ends, the middle line has squared ends, and the bottom line has longer, squared ends.' + ); + } + +
+class: p5 +params: + - name: cap + description: | +

either ROUND, SQUARE, or PROJECT

+ type: Constant +chainable: true +--- + + +# strokeCap diff --git a/src/content/reference/en/p5 copy/strokeJoin.mdx b/src/content/reference/en/p5 copy/strokeJoin.mdx new file mode 100644 index 0000000000..46a8a9206f --- /dev/null +++ b/src/content/reference/en/p5 copy/strokeJoin.mdx @@ -0,0 +1,114 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L442 +title: strokeJoin +module: Shape +submodule: Attributes +file: src/core/shape/attributes.js +description: > +

Sets the style of the joints that connect line segments.

+ +

Joints are either mitered (MITER), beveled + (BEVEL), or rounded + + (ROUND). The default joint is MITER in 2D mode and + ROUND in WebGL + + mode.

+ +

The argument passed to strokeJoin() must be written in ALL + CAPS because + + the constants MITER, BEVEL, and ROUND + are defined this way. + + JavaScript is a case-sensitive language.

+line: 442 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the line. + noFill(); + strokeWeight(10); + strokeJoin(MITER); + + // Draw the line. + beginShape(); + vertex(35, 20); + vertex(65, 50); + vertex(35, 80); + endShape(); + + describe('A right-facing arrowhead shape with a pointed tip in center of canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the line. + noFill(); + strokeWeight(10); + strokeJoin(BEVEL); + + // Draw the line. + beginShape(); + vertex(35, 20); + vertex(65, 50); + vertex(35, 80); + endShape(); + + describe('A right-facing arrowhead shape with a flat tip in center of canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the line. + noFill(); + strokeWeight(10); + strokeJoin(ROUND); + + // Draw the line. + beginShape(); + vertex(35, 20); + vertex(65, 50); + vertex(35, 80); + endShape(); + + describe('A right-facing arrowhead shape with a rounded tip in center of canvas.'); + } + +
+class: p5 +params: + - name: join + description: | +

either MITER, BEVEL, or ROUND

+ type: Constant +chainable: true +--- + + +# strokeJoin diff --git a/src/content/reference/en/p5 copy/strokeWeight.mdx b/src/content/reference/en/p5 copy/strokeWeight.mdx new file mode 100644 index 0000000000..82ebfc13d5 --- /dev/null +++ b/src/content/reference/en/p5 copy/strokeWeight.mdx @@ -0,0 +1,77 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L541 +title: strokeWeight +module: Shape +submodule: Attributes +file: src/core/shape/attributes.js +description: > +

Sets the width of the stroke used for points, lines, and the outlines of + + shapes.

+ +

Note: strokeWeight() is affected by transformations, + especially calls to + + scale().

+line: 541 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Top. + line(20, 20, 80, 20); + + // Middle. + strokeWeight(4); + line(20, 40, 80, 40); + + // Bottom. + strokeWeight(10); + line(20, 70, 80, 70); + + describe('Three horizontal black lines. The top line is thin, the middle is medium, and the bottom is thick.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Top. + line(20, 20, 80, 20); + + // Scale by a factor of 5. + scale(5); + + // Bottom. Coordinates are adjusted for scaling. + line(4, 8, 16, 8); + + describe('Two horizontal black lines. The top line is thin and the bottom is five times thicker than the top.'); + } + +
+class: p5 +params: + - name: weight + description: | +

the weight of the stroke (in pixels).

+ type: Number +chainable: true +--- + + +# strokeWeight diff --git a/src/content/reference/en/p5 copy/subset.mdx b/src/content/reference/en/p5 copy/subset.mdx new file mode 100644 index 0000000000..1cf7cb7f4e --- /dev/null +++ b/src/content/reference/en/p5 copy/subset.mdx @@ -0,0 +1,59 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L381 +title: subset +module: Data +submodule: Array Functions +file: src/utilities/array_functions.js +description: | +

Extracts an array of elements from an existing array. The list parameter + defines the array from which the elements will be copied, and the start + and count parameters specify which elements to extract. If no count is + given, elements will be extracted from the start to the end of the array. + When specifying the start, remember that the first array element is 0. + This function does not change the source array.

+line: 381 +deprecated: >- + Use array.slice() + instead. +isConstructor: false +itemtype: method +example: + - |- + +
+ function setup() { + let myArray = [1, 2, 3, 4, 5]; + print(myArray); // [1, 2, 3, 4, 5] + + let sub1 = subset(myArray, 0, 3); + let sub2 = subset(myArray, 2, 2); + print(sub1); // [1,2,3] + print(sub2); // [3,4] + } +
+class: p5 +params: + - name: list + description: | +

Array to extract from

+ type: Array + - name: start + description: | +

position to begin

+ type: Integer + - name: count + description: | +

number of values to extract

+ type: Integer + optional: true +return: + description: Array of extracted elements + type: Array +chainable: false +--- + + +# subset diff --git a/src/content/reference/en/p5 copy/tan.mdx b/src/content/reference/en/p5 copy/tan.mdx new file mode 100644 index 0000000000..376d093f33 --- /dev/null +++ b/src/content/reference/en/p5 copy/tan.mdx @@ -0,0 +1,66 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L445 +title: tan +module: Math +submodule: Trigonometry +file: src/math/trigonometry.js +description: > +

Calculates the tangent of an angle.

+ +

tan() is useful for many geometric tasks in creative coding. + The values + + returned range from -Infinity to Infinity and repeat periodically as the + + input angle increases. tan() calculates the tan of an angle, + using radians + + by default, or according to + + if angleMode() setting (RADIANS or + DEGREES).

+line: 445 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + describe('A series of identical curves drawn with black dots. Each curve starts from the top of the canvas, continues down at a slight angle, flattens out at the middle of the canvas, then continues to the bottom.'); + } + + function draw() { + // Calculate the coordinates. + let x = frameCount; + let y = 5 * tan(x * 0.1) + 50; + + // Draw the point. + point(x, y); + } + +
+class: p5 +params: + - name: angle + description: > +

the angle, in radians by default, or according to + + if angleMode() setting (RADIANS or + DEGREES).

+ type: Number +return: + description: tangent of the angle. + type: Number +chainable: false +--- + + +# tan diff --git a/src/content/reference/en/p5 copy/text.mdx b/src/content/reference/en/p5 copy/text.mdx new file mode 100644 index 0000000000..eea293bfd8 --- /dev/null +++ b/src/content/reference/en/p5 copy/text.mdx @@ -0,0 +1,96 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/loading_displaying.js#L182 +title: text +module: Typography +submodule: Loading & Displaying +file: src/typography/loading_displaying.js +description: > +

Draws text to the canvas.

+ +

The first parameter, str, is the text to be drawn. The second + and third + + parameters, x and y, set the coordinates of the + text's bottom-left + + corner. See textAlign() for other ways + to + + align text.

+ +

The fourth and fifth parameters, maxWidth and + maxHeight, are optional. + + They set the dimensions of the invisible rectangle containing the text. By + + default, they set its maximum width and height. See + + rectMode() for other ways to define the + + rectangular text box. Text will wrap to fit within the text box. Text + + outside of the box won't be drawn.

+ +

Text can be styled a few ways. Call the fill() + + function to set the text's fill color. Call + + stroke() and + + strokeWeight() to set the text's + outline. + + Call textSize() and + + textFont() to set the text's size and + font, + + respectively.

+ +

Note: WEBGL mode only supports fonts loaded with + + loadFont(). Calling + + stroke() has no effect in + WEBGL mode.

+line: 182 +isConstructor: false +itemtype: method +example: + - "\n
\n\nfunction setup() {\n background(200);\n text('hi', 50, 50);\n\n describe('The text \"hi\" written in black in the middle of a gray square.');\n}\n\n
\n\n
\n\nfunction setup() {\n background('skyblue');\n textSize(100);\n text('\U0001F308', 0, 100);\n\n describe('A rainbow in a blue sky.');\n}\n\n
\n\n
\n\nfunction setup() {\n textSize(32);\n fill(255);\n stroke(0);\n strokeWeight(4);\n text('hi', 50, 50);\n\n describe('The text \"hi\" written in white with a black outline.');\n}\n\n
\n\n
\n\nfunction setup() {\n background('black');\n textSize(22);\n fill('yellow');\n text('rainbows', 6, 20);\n fill('cornflowerblue');\n text('rainbows', 6, 45);\n fill('tomato');\n text('rainbows', 6, 70);\n fill('limegreen');\n text('rainbows', 6, 95);\n\n describe('The text \"rainbows\" written on several lines, each in a different color.');\n}\n\n
\n\n
\n\nfunction setup() {\n background(200);\n let s = 'The quick brown fox jumps over the lazy dog.';\n text(s, 10, 10, 70, 80);\n\n describe('The sample text \"The quick brown fox...\" written in black across several lines.');\n}\n\n
\n\n
\n\nfunction setup() {\n background(200);\n rectMode(CENTER);\n let s = 'The quick brown fox jumps over the lazy dog.';\n text(s, 50, 50, 70, 80);\n\n describe('The sample text \"The quick brown fox...\" written in black across several lines.');\n}\n\n
\n\n
\n\nlet font;\n\nfunction preload() {\n font = loadFont('/assets/inconsolata.otf');\n}\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n textFont(font);\n textSize(32);\n textAlign(CENTER, CENTER);\n}\n\nfunction draw() {\n background(0);\n rotateY(frameCount / 30);\n text('p5*js', 0, 0);\n\n describe('The text \"p5*js\" written in white and spinning in 3D.');\n}\n\n
" +class: p5 +params: + - name: str + description: | +

text to be displayed.

+ type: String|Object|Array|Number|Boolean + - name: x + description: | +

x-coordinate of the text box.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the text box.

+ type: Number + - name: maxWidth + description: | +

maximum width of the text box. See + rectMode() for + other options.

+ type: Number + optional: true + - name: maxHeight + description: | +

maximum height of the text box. See + rectMode() for + other options.

+ type: Number + optional: true +chainable: true +--- + + +# text diff --git a/src/content/reference/en/p5 copy/textAlign.mdx b/src/content/reference/en/p5 copy/textAlign.mdx new file mode 100644 index 0000000000..3899f22842 --- /dev/null +++ b/src/content/reference/en/p5 copy/textAlign.mdx @@ -0,0 +1,135 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L11 +title: textAlign +module: Typography +submodule: Attributes +file: src/typography/attributes.js +description: > +

Sets the way text is aligned when text() + is called.

+ +

By default, calling text('hi', 10, 20) places the bottom-left + corner of + + the text's bounding box at (10, 20).

+ +

The first parameter, horizAlign, changes the way + + text() interprets x-coordinates. By default, + the + + x-coordinate sets the left edge of the bounding box. textAlign() + accepts + + the following values for horizAlign: LEFT, + CENTER, or RIGHT.

+ +

The second parameter, vertAlign, is optional. It changes the + way + + text() interprets y-coordinates. By default, + the + + y-coordinate sets the bottom edge of the bounding box. + textAlign() + + accepts the following values for vertAlign: TOP, + BOTTOM, CENTER, + + or BASELINE.

+line: 11 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw a vertical line. + strokeWeight(0.5); + line(50, 0, 50, 100); + + // Top line. + textSize(16); + textAlign(RIGHT); + text('ABCD', 50, 30); + + // Middle line. + textAlign(CENTER); + text('EFGH', 50, 50); + + // Bottom line. + textAlign(LEFT); + text('IJKL', 50, 70); + + describe('The letters ABCD displayed at top-left, EFGH at center, and IJKL at bottom-right. A vertical line divides the canvas in half.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + strokeWeight(0.5); + + // First line. + line(0, 12, width, 12); + textAlign(CENTER, TOP); + text('TOP', 50, 12); + + // Second line. + line(0, 37, width, 37); + textAlign(CENTER, CENTER); + text('CENTER', 50, 37); + + // Third line. + line(0, 62, width, 62); + textAlign(CENTER, BASELINE); + text('BASELINE', 50, 62); + + // Fourth line. + line(0, 97, width, 97); + textAlign(CENTER, BOTTOM); + text('BOTTOM', 50, 97); + + describe('The words "TOP", "CENTER", "BASELINE", and "BOTTOM" each drawn relative to a horizontal line. Their positions demonstrate different vertical alignments.'); + } + +
+class: p5 +overloads: + - line: 11 + params: + - name: horizAlign + description: | +

horizontal alignment, either LEFT, + CENTER, or RIGHT.

+ type: Constant + - name: vertAlign + description: | +

vertical alignment, either TOP, + BOTTOM, CENTER, or BASELINE.

+ type: Constant + optional: true + chainable: 1 + - line: 98 + params: [] + return: + description: '' + type: Object +chainable: true +--- + + +# textAlign diff --git a/src/content/reference/en/p5 copy/textAscent.mdx b/src/content/reference/en/p5 copy/textAscent.mdx new file mode 100644 index 0000000000..b81a657de6 --- /dev/null +++ b/src/content/reference/en/p5 copy/textAscent.mdx @@ -0,0 +1,71 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L337 +title: textAscent +module: Typography +submodule: Attributes +file: src/typography/attributes.js +description: | +

Calculates the ascent of the current font at its current size.

+

The ascent represents the distance, in pixels, of the tallest character + above the baseline.

+line: 337 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let font; + + function preload() { + font = loadFont('/assets/inconsolata.otf'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textFont(font); + + // Different for each font. + let fontScale = 0.8; + + let baseY = 75; + strokeWeight(0.5); + + // Draw small text. + textSize(24); + text('dp', 0, baseY); + + // Draw baseline and ascent. + let a = textAscent() * fontScale; + line(0, baseY, 23, baseY); + line(23, baseY - a, 23, baseY); + + // Draw large text. + textSize(48); + text('dp', 45, baseY); + + // Draw baseline and ascent. + a = textAscent() * fontScale; + line(45, baseY, 91, baseY); + line(91, baseY - a, 91, baseY); + + describe('The letters "dp" written twice in different sizes. Each version has a horizontal baseline. A vertical line extends upward from each baseline to the top of the "d".'); + } + +
+class: p5 +return: + description: ascent measured in units of pixels. + type: Number +chainable: false +--- + + +# textAscent diff --git a/src/content/reference/en/p5 copy/textDescent.mdx b/src/content/reference/en/p5 copy/textDescent.mdx new file mode 100644 index 0000000000..15837acff3 --- /dev/null +++ b/src/content/reference/en/p5 copy/textDescent.mdx @@ -0,0 +1,71 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L396 +title: textDescent +module: Typography +submodule: Attributes +file: src/typography/attributes.js +description: | +

Calculates the descent of the current font at its current size.

+

The descent represents the distance, in pixels, of the character with the + longest descender below the baseline.

+line: 396 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let font; + + function preload() { + font = loadFont('/assets/inconsolata.otf'); + } + + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the font. + textFont(font); + + // Different for each font. + let fontScale = 0.9; + + let baseY = 75; + strokeWeight(0.5); + + // Draw small text. + textSize(24); + text('dp', 0, baseY); + + // Draw baseline and descent. + let d = textDescent() * fontScale; + line(0, baseY, 23, baseY); + line(23, baseY, 23, baseY + d); + + // Draw large text. + textSize(48); + text('dp', 45, baseY); + + // Draw baseline and descent. + d = textDescent() * fontScale; + line(45, baseY, 91, baseY); + line(91, baseY, 91, baseY + d); + + describe('The letters "dp" written twice in different sizes. Each version has a horizontal baseline. A vertical line extends downward from each baseline to the bottom of the "p".'); + } + +
+class: p5 +return: + description: descent measured in units of pixels. + type: Number +chainable: false +--- + + +# textDescent diff --git a/src/content/reference/en/p5 copy/textFont.mdx b/src/content/reference/en/p5 copy/textFont.mdx new file mode 100644 index 0000000000..e5e9fa8da1 --- /dev/null +++ b/src/content/reference/en/p5 copy/textFont.mdx @@ -0,0 +1,127 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/loading_displaying.js#L335 +title: textFont +module: Typography +submodule: Loading & Displaying +file: src/typography/loading_displaying.js +description: > +

Sets the font used by the text() + function.

+ +

The first parameter, font, sets the font. + textFont() recognizes either + + a p5.Font object or a string with the name + of a + + system font. For example, 'Courier New'.

+ +

The second parameter, size, is optional. It sets the font size + in pixels. + + This has the same effect as calling textSize().

+ +

Note: WEBGL mode only supports fonts loaded with + + loadFont().

+line: 335 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + background(200); + textFont('Courier New'); + textSize(24); + text('hi', 35, 55); + + describe('The text "hi" written in a black, monospace font on a gray background.'); + } + +
+ +
+ + function setup() { + background('black'); + fill('palegreen'); + textFont('Courier New', 10); + text('You turn to the left and see a door. Do you enter?', 5, 5, 90, 90); + text('>', 5, 70); + + describe('A text prompt from a game is written in a green, monospace font on a black background.'); + } + +
+ +
+ + function setup() { + background(200); + textFont('Verdana'); + let currentFont = textFont(); + text(currentFont, 25, 50); + + describe('The text "Verdana" written in a black, sans-serif font on a gray background.'); + } + +
+ +
+ + let fontRegular; + let fontItalic; + let fontBold; + + function preload() { + fontRegular = loadFont('/assets/Regular.otf'); + fontItalic = loadFont('/assets/Italic.ttf'); + fontBold = loadFont('/assets/Bold.ttf'); + } + + function setup() { + background(200); + textFont(fontRegular); + text('I am Normal', 10, 30); + textFont(fontItalic); + text('I am Italic', 10, 50); + textFont(fontBold); + text('I am Bold', 10, 70); + + describe('The statements "I am Normal", "I am Italic", and "I am Bold" written in black on separate lines. The statements have normal, italic, and bold fonts, respectively.'); + } + +
+class: p5 +return: + description: current font or p5 Object. + type: Object +overloads: + - line: 335 + params: [] + return: + description: current font or p5 Object. + type: Object + - line: 418 + params: + - name: font + description: | +

font as a p5.Font object or a string.

+ type: Object|String + - name: size + description: | +

font size in pixels.

+ type: Number + optional: true + chainable: 1 +chainable: false +--- + + +# textFont diff --git a/src/content/reference/en/p5 copy/textLeading.mdx b/src/content/reference/en/p5 copy/textLeading.mdx new file mode 100644 index 0000000000..3b5a22d9a2 --- /dev/null +++ b/src/content/reference/en/p5 copy/textLeading.mdx @@ -0,0 +1,63 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L107 +title: textLeading +module: Typography +submodule: Attributes +file: src/typography/attributes.js +description: > +

Sets the spacing between lines of text when + + text() is called.

+ +

Note: Spacing is measured in pixels.

+ +

Calling textLeading() without an argument returns the current + spacing.

+line: 107 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // "\n" starts a new line of text. + let lines = 'one\ntwo'; + + // Left. + text(lines, 10, 25); + + // Right. + textLeading(30); + text(lines, 70, 25); + + describe('The words "one" and "two" written on separate lines twice. The words on the left have less vertical spacing than the words on the right.'); + } + +
+class: p5 +overloads: + - line: 107 + params: + - name: leading + description: | +

spacing between lines of text in units of pixels.

+ type: Number + chainable: 1 + - line: 142 + params: [] + return: + description: '' + type: Number +chainable: true +--- + + +# textLeading diff --git a/src/content/reference/en/p5 copy/textOutput.mdx b/src/content/reference/en/p5 copy/textOutput.mdx new file mode 100644 index 0000000000..62ea4cb4b5 --- /dev/null +++ b/src/content/reference/en/p5 copy/textOutput.mdx @@ -0,0 +1,186 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/accessibility/outputs.js#L10 +title: textOutput +module: Environment +submodule: Environment +file: src/accessibility/outputs.js +description: > +

Creates a screen reader-accessible description of shapes on the canvas.

+ +

textOutput() adds a general description, list of shapes, and + + table of shapes to the web page. The general description includes the + + canvas size, canvas color, and number of shapes. For example, + + Your output is a, 100 by 100 pixels, gray canvas containing the + following 2 shapes:.

+ +

A list of shapes follows the general description. The list describes the + + color, location, and area of each shape. For example, + + a red circle at middle covering 3% of the canvas. Each shape can + be + + selected to get more details.

+ +

textOutput() uses its table of shapes as a list. The table + describes the + + shape, color, location, coordinates and area. For example, + + red circle location = middle area = 3%. This is different from + + gridOutput(), which uses its table as + a grid.

+ +

The display parameter is optional. It determines how the + description is + + displayed. If LABEL is passed, as in + textOutput(LABEL), the description + + will be visible in a div element next to the canvas. Using LABEL + creates + + unhelpful duplicates for screen readers. Only use LABEL during + + development. If FALLBACK is passed, as in + textOutput(FALLBACK), the + + description will only be visible to screen readers. This is the default + + mode.

+ +

Read + + Writing + accessible canvas descriptions + + to learn more about making sketches accessible.

+ +

textOutput() generates descriptions in English only. Text + drawn with + + text() is not described. Shapes created with + + beginShape() are not described. WEBGL + mode + + and 3D shapes are not supported.

+ +

Use describe() and + + describeElement() for more + control + + over canvas descriptions.

+line: 10 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + // Add the text description. + textOutput(); + + // Draw a couple of shapes. + background(200); + fill(255, 0, 0); + circle(20, 20, 20); + fill(0, 0, 255); + square(50, 50, 50); + + // Add a general description of the canvas. + describe('A red circle and a blue square on a gray background.'); + } + +
+ +
+ + function setup() { + // Add the text description and + // display it for debugging. + textOutput(LABEL); + + // Draw a couple of shapes. + background(200); + fill(255, 0, 0); + circle(20, 20, 20); + fill(0, 0, 255); + square(50, 50, 50); + + // Add a general description of the canvas. + describe('A red circle and a blue square on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + } + + function draw() { + // Add the text description. + textOutput(); + + // Draw a moving circle. + background(200); + let x = frameCount * 0.1; + fill(255, 0, 0); + circle(x, 20, 20); + fill(0, 0, 255); + square(50, 50, 50); + + // Add a general description of the canvas. + describe('A red circle moves from left to right above a blue square.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + } + + function draw() { + // Add the text description and + // display it for debugging. + textOutput(LABEL); + + // Draw a moving circle. + background(200); + let x = frameCount * 0.1; + fill(255, 0, 0); + circle(x, 20, 20); + fill(0, 0, 255); + square(50, 50, 50); + + // Add a general description of the canvas. + describe('A red circle moves from left to right above a blue square.'); + } + +
+class: p5 +params: + - name: display + description: | +

either FALLBACK or LABEL.

+ type: Constant + optional: true +chainable: false +--- + + +# textOutput diff --git a/src/content/reference/en/p5 copy/textSize.mdx b/src/content/reference/en/p5 copy/textSize.mdx new file mode 100644 index 0000000000..df77510315 --- /dev/null +++ b/src/content/reference/en/p5 copy/textSize.mdx @@ -0,0 +1,65 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L151 +title: textSize +module: Typography +submodule: Attributes +file: src/typography/attributes.js +description: > +

Sets the font size when + + text() is called.

+ +

Note: Font size is measured in pixels.

+ +

Calling textSize() without an argument returns the current + size.

+line: 151 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Top. + textSize(12); + text('Font Size 12', 10, 30); + + // Middle. + textSize(14); + text('Font Size 14', 10, 60); + + // Bottom. + textSize(16); + text('Font Size 16', 10, 90); + + describe('The text "Font Size 12" drawn small, "Font Size 14" drawn medium, and "Font Size 16" drawn large.'); + } + +
+class: p5 +overloads: + - line: 151 + params: + - name: size + description: | +

size of the letters in units of pixels.

+ type: Number + chainable: 1 + - line: 188 + params: [] + return: + description: '' + type: Number +chainable: true +--- + + +# textSize diff --git a/src/content/reference/en/p5 copy/textStyle.mdx b/src/content/reference/en/p5 copy/textStyle.mdx new file mode 100644 index 0000000000..572ca0454c --- /dev/null +++ b/src/content/reference/en/p5 copy/textStyle.mdx @@ -0,0 +1,79 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L197 +title: textStyle +module: Typography +submodule: Attributes +file: src/typography/attributes.js +description: > +

Sets the style for system fonts when + + text() is called.

+ +

The parameter, style, can be either NORMAL, + ITALIC, BOLD, or + + BOLDITALIC.

+ +

textStyle() may be overridden by CSS styling. This function + doesn't + + affect fonts loaded with loadFont().

+line: 197 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textSize(12); + textAlign(CENTER); + + // First row. + textStyle(NORMAL); + text('Normal', 50, 15); + + // Second row. + textStyle(ITALIC); + text('Italic', 50, 40); + + // Third row. + textStyle(BOLD); + text('Bold', 50, 65); + + // Fourth row. + textStyle(BOLDITALIC); + text('Bold Italic', 50, 90); + + describe('The words "Normal" displayed normally, "Italic" in italic, "Bold" in bold, and "Bold Italic" in bold italics.'); + } + +
+class: p5 +overloads: + - line: 197 + params: + - name: style + description: | +

styling for text, either NORMAL, + ITALIC, BOLD or BOLDITALIC.

+ type: Constant + chainable: 1 + - line: 244 + params: [] + return: + description: '' + type: String +chainable: true +--- + + +# textStyle diff --git a/src/content/reference/en/p5 copy/textWidth.mdx b/src/content/reference/en/p5 copy/textWidth.mdx new file mode 100644 index 0000000000..00721b0fee --- /dev/null +++ b/src/content/reference/en/p5 copy/textWidth.mdx @@ -0,0 +1,83 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L253 +title: textWidth +module: Typography +submodule: Attributes +file: src/typography/attributes.js +description: | +

Calculates the maximum width of a string of text drawn when + text() is called.

+line: 253 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textSize(28); + strokeWeight(0.5); + + // Calculate the text width. + let s = 'yoyo'; + let w = textWidth(s); + + // Display the text. + text(s, 22, 55); + + // Underline the text. + line(22, 55, 22 + w, 55); + + describe('The word "yoyo" underlined.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textSize(28); + strokeWeight(0.5); + + // Calculate the text width. + // "\n" starts a new line. + let s = 'yo\nyo'; + let w = textWidth(s); + + // Display the text. + text(s, 22, 55); + + // Underline the text. + line(22, 55, 22 + w, 55); + + describe('The word "yo" written twice, one copy beneath the other. The words are divided by a horizontal line.'); + } + +
+class: p5 +params: + - name: str + description: | +

string of text to measure.

+ type: String +return: + description: width measured in units of pixels. + type: Number +chainable: false +--- + + +# textWidth diff --git a/src/content/reference/en/p5 copy/textWrap.mdx b/src/content/reference/en/p5 copy/textWrap.mdx new file mode 100644 index 0000000000..0ba2b556a7 --- /dev/null +++ b/src/content/reference/en/p5 copy/textWrap.mdx @@ -0,0 +1,111 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L462 +title: textWrap +module: Typography +submodule: Attributes +file: src/typography/attributes.js +description: > +

Sets the style for wrapping text when + + text() is called.

+ +

The parameter, style, can be one of the following values:

+ +

WORD starts new lines of text at spaces. If a string of text + doesn't + + have spaces, it may overflow the text box and the canvas. This is the + + default style.

+ +

CHAR starts new lines as needed to stay within the text + box.

+ +

textWrap() only works when the maximum width is set for a text + box. For + + example, calling text('Have a wonderful day', 0, 10, 100) sets + the + + maximum width to 100 pixels.

+ +

Calling textWrap() without an argument returns the current + style.

+line: 462 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textSize(20); + textWrap(WORD); + + // Display the text. + text('Have a wonderful day', 0, 10, 100); + + describe('The text "Have a wonderful day" written across three lines.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textSize(20); + textWrap(CHAR); + + // Display the text. + text('Have a wonderful day', 0, 10, 100); + + describe('The text "Have a wonderful day" written across two lines.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the text. + textSize(20); + textWrap(CHAR); + + // Display the text. + text('祝你有美好的一天', 0, 10, 100); + + describe('The text "祝你有美好的一天" written across two lines.'); + } + +
+class: p5 +params: + - name: style + description: | +

text wrapping style, either WORD or CHAR.

+ type: Constant +return: + description: style + type: String +chainable: false +--- + + +# textWrap diff --git a/src/content/reference/en/p5 copy/texture.mdx b/src/content/reference/en/p5 copy/texture.mdx new file mode 100644 index 0000000000..7258f53ace --- /dev/null +++ b/src/content/reference/en/p5 copy/texture.mdx @@ -0,0 +1,207 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1716 +title: texture +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Sets the texture that will be used on shapes.

+ +

A texture is like a skin that wraps around a shape. texture() + works with + + built-in shapes, such as square() and + + sphere(), and custom shapes created with + + functions such as buildGeometry(). + To + + texture a geometry created with beginShape(), + + uv coordinates must be passed to each + + vertex() call.

+ +

The parameter, tex, is the texture to apply. + texture() can use a range + + of sources including images, videos, and offscreen renderers such as + + p5.Graphics and + + p5.Framebuffer objects.

+ +

To texture a geometry created with beginShape(), + + you will need to specify uv coordinates in vertex().

+ +

Note: texture() can only be used in WebGL mode.

+line: 1716 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load an image and create a p5.Image object. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A spinning cube with an image of a ceiling on each face.'); + } + + function draw() { + background(0); + + // Rotate around the x-, y-, and z-axes. + rotateZ(frameCount * 0.01); + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + + // Apply the image as a texture. + texture(img); + + // Draw the box. + box(50); + } + +
+ +
+ + let pg; + + function setup() { + createCanvas(100, 100, WEBGL); + + // Create a p5.Graphics object. + pg = createGraphics(100, 100); + + // Draw a circle to the p5.Graphics object. + pg.background(200); + pg.circle(50, 50, 30); + + describe('A spinning cube with circle at the center of each face.'); + } + + function draw() { + background(0); + + // Rotate around the x-, y-, and z-axes. + rotateZ(frameCount * 0.01); + rotateX(frameCount * 0.01); + rotateY(frameCount * 0.01); + + // Apply the p5.Graphics object as a texture. + texture(pg); + + // Draw the box. + box(50); + } + +
+ +
+ + let vid; + + // Load a video and create a p5.MediaElement object. + function preload() { + vid = createVideo('/assets/fingers.mov'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + // Hide the video. + vid.hide(); + + // Set the video to loop. + vid.loop(); + + describe('A rectangle with video as texture'); + } + + function draw() { + background(0); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Apply the video as a texture. + texture(vid); + + // Draw the rectangle. + rect(-40, -40, 80, 80); + } + +
+ +
+ + let vid; + + // Load a video and create a p5.MediaElement object. + function preload() { + vid = createVideo('/assets/fingers.mov'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + // Hide the video. + vid.hide(); + + // Set the video to loop. + vid.loop(); + + describe('A rectangle with video as texture'); + } + + function draw() { + background(0); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Set the texture mode. + textureMode(NORMAL); + + // Apply the video as a texture. + texture(vid); + + // Draw a custom shape using uv coordinates. + beginShape(); + vertex(-40, -40, 0, 0); + vertex(40, -40, 1, 0); + vertex(40, 40, 1, 1); + vertex(-40, 40, 0, 1); + endShape(); + } + +
+class: p5 +params: + - name: tex + description: | +

media to use as the texture.

+ type: >- + p5.Image|p5.MediaElement|p5.Graphics|p5.Texture|p5.Framebuffer|p5.FramebufferTexture +chainable: true +--- + + +# texture diff --git a/src/content/reference/en/p5 copy/textureMode.mdx b/src/content/reference/en/p5 copy/textureMode.mdx new file mode 100644 index 0000000000..397d1856b9 --- /dev/null +++ b/src/content/reference/en/p5 copy/textureMode.mdx @@ -0,0 +1,254 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1903 +title: textureMode +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Changes the coordinate system used for textures when they’re applied to + + custom shapes.

+ +

In order for texture() to work, a + shape needs a + + way to map the points on its surface to the pixels in an image. Built-in + + shapes such as rect() and + + box() already have these texture mappings + based on + + their vertices. Custom shapes created with + + vertex() require texture mappings to be + passed as + + uv coordinates.

+ +

Each call to vertex() must include 5 + arguments, + + as in vertex(x, y, z, u, v), to map the vertex at coordinates + (x, y, z) + + to the pixel at coordinates (u, v) within an image. For example, + the + + corners of a rectangular image are mapped to the corners of a rectangle by + default:

+ +
// Apply the image as a texture.
+
+  texture(img);
+
+
+  // Draw the rectangle.
+
+  rect(0, 0, 30, 50);
+
+  
+ +

If the image in the code snippet above has dimensions of 300 x 500 pixels, + + the same result could be achieved as follows:

+ +
// Apply the image as a texture.
+
+  texture(img);
+
+
+  // Draw the rectangle.
+
+  beginShape();
+
+
+  // Top-left.
+
+  // u: 0, v: 0
+
+  vertex(0, 0, 0, 0, 0);
+
+
+  // Top-right.
+
+  // u: 300, v: 0
+
+  vertex(30, 0, 0, 300, 0);
+
+
+  // Bottom-right.
+
+  // u: 300, v: 500
+
+  vertex(30, 50, 0, 300, 500);
+
+
+  // Bottom-left.
+
+  // u: 0, v: 500
+
+  vertex(0, 50, 0, 0, 500);
+
+
+  endShape();
+
+  
+ +

textureMode() changes the coordinate system for uv + coordinates.

+ +

The parameter, mode, accepts two possible constants. If + NORMAL is + + passed, as in textureMode(NORMAL), then the texture’s uv + coordinates can + + be provided in the range 0 to 1 instead of the image’s dimensions. This can + + be helpful for using the same code for multiple images of different sizes. + + For example, the code snippet above could be rewritten as follows:

+ +
// Set the texture mode to use normalized
+  coordinates.
+
+  textureMode(NORMAL);
+
+
+  // Apply the image as a texture.
+
+  texture(img);
+
+
+  // Draw the rectangle.
+
+  beginShape();
+
+
+  // Top-left.
+
+  // u: 0, v: 0
+
+  vertex(0, 0, 0, 0, 0);
+
+
+  // Top-right.
+
+  // u: 1, v: 0
+
+  vertex(30, 0, 0, 1, 0);
+
+
+  // Bottom-right.
+
+  // u: 1, v: 1
+
+  vertex(30, 50, 0, 1, 1);
+
+
+  // Bottom-left.
+
+  // u: 0, v: 1
+
+  vertex(0, 50, 0, 0, 1);
+
+
+  endShape();
+
+  
+ +

By default, mode is IMAGE, which scales uv + coordinates to the + + dimensions of the image. Calling textureMode(IMAGE) applies the + default.

+ +

Note: textureMode() can only be used in WebGL mode.

+line: 1903 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load an image and create a p5.Image object. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('An image of a ceiling against a black background.'); + } + + function draw() { + background(0); + + // Apply the image as a texture. + texture(img); + + // Draw the custom shape. + // Use the image's width and height as uv coordinates. + beginShape(); + vertex(-30, -30, 0, 0); + vertex(30, -30, img.width, 0); + vertex(30, 30, img.width, img.height); + vertex(-30, 30, 0, img.height); + endShape(); + } + +
+ +
+ + let img; + + // Load an image and create a p5.Image object. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('An image of a ceiling against a black background.'); + } + + function draw() { + background(0); + + // Set the texture mode. + textureMode(NORMAL); + + // Apply the image as a texture. + texture(img); + + // Draw the custom shape. + // Use normalized uv coordinates. + beginShape(); + vertex(-30, -30, 0, 0); + vertex(30, -30, 1, 0); + vertex(30, 30, 1, 1); + vertex(-30, 30, 0, 1); + endShape(); + } + +
+class: p5 +params: + - name: mode + description: | +

either IMAGE or NORMAL.

+ type: Constant +chainable: false +--- + + +# textureMode diff --git a/src/content/reference/en/p5 copy/textureWrap.mdx b/src/content/reference/en/p5 copy/textureWrap.mdx new file mode 100644 index 0000000000..6734a5325b --- /dev/null +++ b/src/content/reference/en/p5 copy/textureWrap.mdx @@ -0,0 +1,370 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2082 +title: textureWrap +module: 3D +submodule: Material +file: src/webgl/material.js +description: > +

Changes the way textures behave when a shape’s uv coordinates go beyond the + + texture.

+ +

In order for texture() to work, a + shape needs a + + way to map the points on its surface to the pixels in an image. Built-in + + shapes such as rect() and + + box() already have these texture mappings + based on + + their vertices. Custom shapes created with + + vertex() require texture mappings to be + passed as + + uv coordinates.

+ +

Each call to vertex() must include 5 + arguments, + + as in vertex(x, y, z, u, v), to map the vertex at coordinates + (x, y, z) + + to the pixel at coordinates (u, v) within an image. For example, + the + + corners of a rectangular image are mapped to the corners of a rectangle by + default:

+ +
// Apply the image as a texture.
+
+  texture(img);
+
+
+  // Draw the rectangle.
+
+  rect(0, 0, 30, 50);
+
+  
+ +

If the image in the code snippet above has dimensions of 300 x 500 pixels, + + the same result could be achieved as follows:

+ +
// Apply the image as a texture.
+
+  texture(img);
+
+
+  // Draw the rectangle.
+
+  beginShape();
+
+
+  // Top-left.
+
+  // u: 0, v: 0
+
+  vertex(0, 0, 0, 0, 0);
+
+
+  // Top-right.
+
+  // u: 300, v: 0
+
+  vertex(30, 0, 0, 300, 0);
+
+
+  // Bottom-right.
+
+  // u: 300, v: 500
+
+  vertex(30, 50, 0, 300, 500);
+
+
+  // Bottom-left.
+
+  // u: 0, v: 500
+
+  vertex(0, 50, 0, 0, 500);
+
+
+  endShape();
+
+  
+ +

textureWrap() controls how textures behave when their uv's go + beyond the + + texture. Doing so can produce interesting visual effects such as tiling. + + For example, the custom shape above could have u-coordinates are greater + + than the image’s width:

+ +
// Apply the image as a texture.
+
+  texture(img);
+
+
+  // Draw the rectangle.
+
+  beginShape();
+
+  vertex(0, 0, 0, 0, 0);
+
+
+  // Top-right.
+
+  // u: 600
+
+  vertex(30, 0, 0, 600, 0);
+
+
+  // Bottom-right.
+
+  // u: 600
+
+  vertex(30, 50, 0, 600, 500);
+
+
+  vertex(0, 50, 0, 0, 500);
+
+  endShape();
+
+  
+ +

The u-coordinates of 600 are greater than the texture image’s width of 300. + + This creates interesting possibilities.

+ +

The first parameter, wrapX, accepts three possible constants. + If CLAMP + + is passed, as in textureWrap(CLAMP), the pixels at the edge of + the + + texture will extend to the shape’s edges. If REPEAT is passed, as + in + + textureWrap(REPEAT), the texture will tile repeatedly until + reaching the + + shape’s edges. If MIRROR is passed, as in + textureWrap(MIRROR), the + + texture will tile repeatedly until reaching the shape’s edges, flipping + + its orientation between tiles. By default, textures CLAMP.

+ +

The second parameter, wrapY, is optional. It accepts the same + three + + constants, CLAMP, REPEAT, and MIRROR. + If one of these constants is + + passed, as in textureWRAP(MIRROR, REPEAT), then the texture will + MIRROR + + horizontally and REPEAT vertically. By default, + wrapY will be set to + + the same value as wrapX.

+ +

Note: textureWrap() can only be used in WebGL mode.

+line: 2082 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + function preload() { + img = loadImage('/assets/rockies128.jpg'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'An image of a landscape occupies the top-left corner of a square. Its edge colors smear to cover the other thre quarters of the square.' + ); + } + + function draw() { + background(0); + + // Set the texture mode. + textureMode(NORMAL); + + // Set the texture wrapping. + // Note: CLAMP is the default mode. + textureWrap(CLAMP); + + // Apply the image as a texture. + texture(img); + + // Style the shape. + noStroke(); + + // Draw the shape. + // Use uv coordinates > 1. + beginShape(); + vertex(-30, -30, 0, 0, 0); + vertex(30, -30, 0, 2, 0); + vertex(30, 30, 0, 2, 2); + vertex(-30, 30, 0, 0, 2); + endShape(); + } + +
+ +
+ + let img; + + function preload() { + img = loadImage('/assets/rockies128.jpg'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('Four identical images of a landscape arranged in a grid.'); + } + + function draw() { + background(0); + + // Set the texture mode. + textureMode(NORMAL); + + // Set the texture wrapping. + textureWrap(REPEAT); + + // Apply the image as a texture. + texture(img); + + // Style the shape. + noStroke(); + + // Draw the shape. + // Use uv coordinates > 1. + beginShape(); + vertex(-30, -30, 0, 0, 0); + vertex(30, -30, 0, 2, 0); + vertex(30, 30, 0, 2, 2); + vertex(-30, 30, 0, 0, 2); + endShape(); + } + +
+ +
+ + let img; + + function preload() { + img = loadImage('/assets/rockies128.jpg'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'Four identical images of a landscape arranged in a grid. The images are reflected horizontally and vertically, creating a kaleidoscope effect.' + ); + } + + function draw() { + background(0); + + // Set the texture mode. + textureMode(NORMAL); + + // Set the texture wrapping. + textureWrap(MIRROR); + + // Apply the image as a texture. + texture(img); + + // Style the shape. + noStroke(); + + // Draw the shape. + // Use uv coordinates > 1. + beginShape(); + vertex(-30, -30, 0, 0, 0); + vertex(30, -30, 0, 2, 0); + vertex(30, 30, 0, 2, 2); + vertex(-30, 30, 0, 0, 2); + endShape(); + } + +
+ +
+ + let img; + + function preload() { + img = loadImage('/assets/rockies128.jpg'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'Four identical images of a landscape arranged in a grid. The top row and bottom row are reflections of each other.' + ); + } + + function draw() { + background(0); + + // Set the texture mode. + textureMode(NORMAL); + + // Set the texture wrapping. + textureWrap(REPEAT, MIRROR); + + // Apply the image as a texture. + texture(img); + + // Style the shape. + noStroke(); + + // Draw the shape. + // Use uv coordinates > 1. + beginShape(); + vertex(-30, -30, 0, 0, 0); + vertex(30, -30, 0, 2, 0); + vertex(30, 30, 0, 2, 2); + vertex(-30, 30, 0, 0, 2); + endShape(); + } + +
+class: p5 +params: + - name: wrapX + description: | +

either CLAMP, REPEAT, or MIRROR

+ type: Constant + - name: wrapY + description: | +

either CLAMP, REPEAT, or MIRROR

+ type: Constant + optional: true +chainable: false +--- + + +# textureWrap diff --git a/src/content/reference/en/p5 copy/tint.mdx b/src/content/reference/en/p5 copy/tint.mdx new file mode 100644 index 0000000000..e99dee4431 --- /dev/null +++ b/src/content/reference/en/p5 copy/tint.mdx @@ -0,0 +1,201 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L1192 +title: tint +module: Image +submodule: Loading & Displaying +file: src/image/loading_displaying.js +description: > +

Tints images using a color.

+ +

The version of tint() with one parameter interprets it one of + four ways. + + If the parameter is a number, it's interpreted as a grayscale value. If the + + parameter is a string, it's interpreted as a CSS color string. An array of + + [R, G, B, A] values or a p5.Color object can + + also be used to set the tint color.

+ +

The version of tint() with two parameters uses the first one + as a + + grayscale value and the second as an alpha value. For example, calling + + tint(255, 128) will make an image 50% transparent.

+ +

The version of tint() with three parameters interprets them as + RGB or + + HSB values, depending on the current + + colorMode(). The optional fourth + parameter + + sets the alpha value. For example, tint(255, 0, 0, 100) will give + images + + a red tint and make them transparent.

+line: 1192 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Left image. + image(img, 0, 0); + + // Right image. + // Tint with a CSS color string. + tint('red'); + image(img, 50, 0); + + describe('Two images of an umbrella and a ceiling side-by-side. The image on the right has a red tint.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Left image. + image(img, 0, 0); + + // Right image. + // Tint with RGB values. + tint(255, 0, 0); + image(img, 50, 0); + + describe('Two images of an umbrella and a ceiling side-by-side. The image on the right has a red tint.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Left. + image(img, 0, 0); + + // Right. + // Tint with RGBA values. + tint(255, 0, 0, 100); + image(img, 50, 0); + + describe('Two images of an umbrella and a ceiling side-by-side. The image on the right has a transparent red tint.'); + } + +
+ +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Left. + image(img, 0, 0); + + // Right. + // Tint with grayscale and alpha values. + tint(255, 180); + image(img, 50, 0); + + describe('Two images of an umbrella and a ceiling side-by-side. The image on the right is transparent.'); + } + +
+class: p5 +overloads: + - line: 1192 + params: + - name: v1 + description: | +

red or hue value.

+ type: Number + - name: v2 + description: | +

green or saturation value.

+ type: Number + - name: v3 + description: | +

blue or brightness.

+ type: Number + - name: alpha + description: '' + type: Number + optional: true + - line: 1318 + params: + - name: value + description: | +

CSS color string.

+ type: String + - line: 1323 + params: + - name: gray + description: | +

grayscale value.

+ type: Number + - name: alpha + description: '' + type: Number + optional: true + - line: 1329 + params: + - name: values + description: | +

array containing the red, green, blue & + alpha components of the color.

+ type: 'Number[]' + - line: 1335 + params: + - name: color + description: | +

the tint color

+ type: p5.Color +chainable: false +--- + + +# tint diff --git a/src/content/reference/en/p5 copy/torus.mdx b/src/content/reference/en/p5 copy/torus.mdx new file mode 100644 index 0000000000..f0e2740d59 --- /dev/null +++ b/src/content/reference/en/p5 copy/torus.mdx @@ -0,0 +1,200 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L2183 +title: torus +module: Shape +submodule: 3D Primitives +file: src/webgl/3d_primitives.js +description: > +

Draws a torus.

+ +

A torus is a 3D shape with triangular faces that connect to form a ring. + + Toruses with few faces look flattened. Toruses with many faces have smooth + + surfaces.

+ +

The first parameter, radius, is optional. If a + Number is passed, as in + + torus(30), it sets the radius of the ring. By default, + radius is 50.

+ +

The second parameter, tubeRadius, is also optional. If a + Number is + + passed, as in torus(30, 15), it sets the radius of the tube. By + default, + + tubeRadius is 10.

+ +

The third parameter, detailX, is also optional. If a + Number is passed, + + as in torus(30, 15, 5), it sets the number of edges used to draw + the hole + + of the torus. Using more edges makes the hole look more like a circle. By + + default, detailX is 24.

+ +

The fourth parameter, detailY, is also optional. If a + Number is passed, + + as in torus(30, 15, 5, 7), it sets the number of triangle + subdivisions to + + use while filling in the torus’ height. By default, detailY is + 16.

+ +

Note: torus() can only be used in WebGL mode.

+line: 2183 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white torus on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the torus. + torus(); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white torus on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the torus. + // Set its radius to 30. + torus(30); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white torus on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the torus. + // Set its radius to 30 and tubeRadius to 15. + torus(30, 15); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white torus on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the torus. + // Set its radius to 30 and tubeRadius to 15. + // Set its detailX to 5. + torus(30, 15, 5); + } + +
+ +
+ + // Click and drag the mouse to view the scene from different angles. + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white torus on a gray background.'); + } + + function draw() { + background(200); + + // Enable orbiting with the mouse. + orbitControl(); + + // Draw the torus. + // Set its radius to 30 and tubeRadius to 15. + // Set its detailX to 5. + // Set its detailY to 3. + torus(30, 15, 5, 3); + } + +
+class: p5 +params: + - name: radius + description: | +

radius of the torus. Defaults to 50.

+ type: Number + optional: true + - name: tubeRadius + description: | +

radius of the tube. Defaults to 10.

+ type: Number + optional: true + - name: detailX + description: | +

number of edges that form the hole. Defaults to 24.

+ type: Integer + optional: true + - name: detailY + description: | +

number of triangle subdivisions along the y-axis. Defaults to 16.

+ type: Integer + optional: true +chainable: true +--- + + +# torus diff --git a/src/content/reference/en/p5 copy/touchEnded.mdx b/src/content/reference/en/p5 copy/touchEnded.mdx new file mode 100644 index 0000000000..aebb308dc1 --- /dev/null +++ b/src/content/reference/en/p5 copy/touchEnded.mdx @@ -0,0 +1,196 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/touch.js#L468 +title: touchEnded +module: Events +submodule: Touch +file: src/events/touch.js +description: > +

A function that's called once each time a screen touch ends.

+ +

Declaring the function touchEnded() sets a code block to run + + automatically when the user stops touching a touchscreen device:

+ +
function touchEnded() {
+    // Code to run.
+  }
+
+  
+ +

The touches array will be updated with + the most + + recent touch points when touchEnded() is called by p5.js:

+ +
function touchEnded() {
+    // Paint over the background.
+    background(200);
+
+    // Mark each remaining touch point when the user stops
+    // a touch.
+    for (let touch of touches) {
+      circle(touch.x, touch.y, 40);
+    }
+  }
+
+  
+ +

The parameter, event, is optional. touchEnded() will be passed + a + + TouchEvent + + object with properties that describe the touch event:

+ +
function touchEnded(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

On touchscreen devices, mouseReleased() will + + run when the user’s touch ends if touchEnded() isn’t declared. If + + touchEnded() is declared, then touchEnded() will run + when a user’s + + touch ends and mouseReleased() + won’t.

+ +

Note: touchStarted(), + + touchEnded(), and touchMoved() are all + + related. touchStarted() runs as soon + as the + + user touches a touchscreen device. touchEnded() runs as soon as + the user + + ends a touch. touchMoved() runs + repeatedly as + + the user moves any touch points.

+line: 468 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // On a touchscreen device, touch the canvas using one or more fingers + // at the same time. + + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square switches color between black and white each time the user stops touching the screen.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Toggle colors when a touch ends. + function touchEnded() { + if (value === 0) { + value = 255; + } else { + value = 0; + } + } + +
+ +
+ + // On a touchscreen device, touch the canvas using one or more fingers + // at the same time. + + let bgColor = 50; + let fillColor = 255; + let borderWidth = 0.5; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with the number 0 at the top-center. The number tracks the number of places the user is touching the screen. Circles appear at each touch point and change style in response to events.' + ); + } + + function draw() { + background(bgColor); + + // Style the text. + textAlign(CENTER); + textSize(16); + fill(0); + noStroke(); + + // Display the number of touch points. + text(touches.length, 50, 20); + + // Style the touch points. + fill(fillColor); + stroke(0); + strokeWeight(borderWidth); + + // Display the touch points as circles. + for (let touch of touches) { + circle(touch.x, touch.y, 40); + } + } + + // Set the background color to a random grayscale value. + function touchStarted() { + bgColor = random(80, 255); + } + + // Set the fill color to a random grayscale value. + function touchEnded() { + fillColor = random(0, 255); + } + + // Set the stroke weight. + function touchMoved() { + // Increment the border width. + borderWidth += 0.1; + + // Reset the border width once it's too thick. + if (borderWidth > 20) { + borderWidth = 0.5; + } + } + +
+class: p5 +params: + - name: event + description: | +

optional TouchEvent argument.

+ type: TouchEvent + optional: true +chainable: false +--- + + +# touchEnded diff --git a/src/content/reference/en/p5 copy/touchMoved.mdx b/src/content/reference/en/p5 copy/touchMoved.mdx new file mode 100644 index 0000000000..80c23b81f8 --- /dev/null +++ b/src/content/reference/en/p5 copy/touchMoved.mdx @@ -0,0 +1,198 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/touch.js#L295 +title: touchMoved +module: Events +submodule: Touch +file: src/events/touch.js +description: > +

A function that's called when the user touches the screen and moves.

+ +

Declaring the function touchMoved() sets a code block to run + + automatically when the user touches a touchscreen device and moves:

+ +
function touchMoved() {
+    // Code to run.
+  }
+
+  
+ +

The touches array will be updated with + the most + + recent touch points when touchMoved() is called by p5.js:

+ +
function touchMoved() {
+    // Paint over the background.
+    background(200);
+
+    // Mark each touch point while the user moves.
+    for (let touch of touches) {
+      circle(touch.x, touch.y, 40);
+    }
+  }
+
+  
+ +

The parameter, event, is optional. touchMoved() will be passed + a + + TouchEvent + + object with properties that describe the touch event:

+ +
function touchMoved(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

On touchscreen devices, mouseDragged() will + + run when the user’s touch points move if touchMoved() isn’t + declared. If + + touchMoved() is declared, then touchMoved() will run + when a user’s + + touch points move and mouseDragged() + won’t.

+ +

Note: touchStarted(), + + touchEnded(), and + + touchMoved() are all related. + + touchStarted() runs as soon as the + user + + touches a touchscreen device. touchEnded() + + runs as soon as the user ends a touch. touchMoved() runs + repeatedly as + + the user moves any touch points.

+line: 295 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // On a touchscreen device, touch the canvas using one or more fingers + // at the same time. + + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square becomes lighter when the user touches the screen and moves.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + function touchMoved() { + // Update the grayscale value. + value += 5; + + // Reset the grayscale value. + if (value > 255) { + value = 0; + } + } + +
+ +
+ + // On a touchscreen device, touch the canvas using one or more fingers + // at the same time. + + let bgColor = 50; + let fillColor = 255; + let borderWidth = 0.5; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with the number 0 at the top-center. The number tracks the number of places the user is touching the screen. Circles appear at each touch point and change style in response to events.' + ); + } + + function draw() { + background(bgColor); + + // Style the text. + textAlign(CENTER); + textSize(16); + fill(0); + noStroke(); + + // Display the number of touch points. + text(touches.length, 50, 20); + + // Style the touch points. + fill(fillColor); + stroke(0); + strokeWeight(borderWidth); + + // Display the touch points as circles. + for (let touch of touches) { + circle(touch.x, touch.y, 40); + } + } + + // Set the background color to a random grayscale value. + function touchStarted() { + bgColor = random(80, 255); + } + + // Set the fill color to a random grayscale value. + function touchEnded() { + fillColor = random(0, 255); + } + + // Set the stroke weight. + function touchMoved() { + // Increment the border width. + borderWidth += 0.1; + + // Reset the border width once it's too thick. + if (borderWidth > 20) { + borderWidth = 0.5; + } + } + +
+class: p5 +params: + - name: event + description: | +

optional TouchEvent argument.

+ type: TouchEvent + optional: true +chainable: false +--- + + +# touchMoved diff --git a/src/content/reference/en/p5 copy/touchStarted.mdx b/src/content/reference/en/p5 copy/touchStarted.mdx new file mode 100644 index 0000000000..fc33b1f1c5 --- /dev/null +++ b/src/content/reference/en/p5 copy/touchStarted.mdx @@ -0,0 +1,197 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/touch.js#L125 +title: touchStarted +module: Events +submodule: Touch +file: src/events/touch.js +description: > +

A function that's called once each time the user touches the screen.

+ +

Declaring a function called touchStarted() sets a code block + to run + + automatically each time the user begins touching a touchscreen device:

+ +
function touchStarted() {
+    // Code to run.
+  }
+
+  
+ +

The touches array will be updated with + the most + + recent touch points when touchStarted() is called by p5.js:

+ +
function touchStarted() {
+    // Paint over the background.
+    background(200);
+
+    // Mark each touch point once with a circle.
+    for (let touch of touches) {
+      circle(touch.x, touch.y, 40);
+    }
+  }
+
+  
+ +

The parameter, event, is optional. touchStarted() will be + passed a + + TouchEvent + + object with properties that describe the touch event:

+ +
function touchStarted(event) {
+    // Code to run that uses the event.
+    console.log(event);
+  }
+
+  
+ +

On touchscreen devices, mousePressed() will + + run when a user’s touch starts if touchStarted() isn’t declared. + If + + touchStarted() is declared, then touchStarted() will + run when a user’s + + touch starts and mousePressed() + won’t.

+ +

Note: touchStarted(), touchEnded(), and + + touchMoved() are all related. + + touchStarted() runs as soon as the user touches a touchscreen + device. + + touchEnded() runs as soon as the user + ends a + + touch. touchMoved() runs repeatedly as + the + + user moves any touch points.

+line: 125 +isConstructor: false +itemtype: method +example: + - |- + +
+ + // On a touchscreen device, touch the canvas using one or more fingers + // at the same time. + + let value = 0; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with a black square at its center. The inner square switches color between black and white each time the user touches the screen.' + ); + } + + function draw() { + background(200); + + // Style the square. + fill(value); + + // Draw the square. + square(25, 25, 50); + } + + // Toggle colors with each touch. + function touchStarted() { + if (value === 0) { + value = 255; + } else { + value = 0; + } + } + +
+ +
+ + // On a touchscreen device, touch the canvas using one or more fingers + // at the same time. + + let bgColor = 50; + let fillColor = 255; + let borderWidth = 0.5; + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square with the number 0 at the top-center. The number tracks the number of places the user is touching the screen. Circles appear at each touch point and change style in response to events.' + ); + } + + function draw() { + background(bgColor); + + // Style the text. + textAlign(CENTER); + textSize(16); + fill(0); + noStroke(); + + // Display the number of touch points. + text(touches.length, 50, 20); + + // Style the touch points. + fill(fillColor); + stroke(0); + strokeWeight(borderWidth); + + // Display the touch points as circles. + for (let touch of touches) { + circle(touch.x, touch.y, 40); + } + } + + // Set the background color to a random grayscale value. + function touchStarted() { + bgColor = random(80, 255); + } + + // Set the fill color to a random grayscale value. + function touchEnded() { + fillColor = random(0, 255); + } + + // Set the stroke weight. + function touchMoved() { + // Increment the border width. + borderWidth += 0.1; + + // Reset the border width once it's too thick. + if (borderWidth > 20) { + borderWidth = 0.5; + } + } + +
+class: p5 +params: + - name: event + description: | +

optional TouchEvent argument.

+ type: TouchEvent + optional: true +chainable: false +--- + + +# touchStarted diff --git a/src/content/reference/en/p5 copy/touches.mdx b/src/content/reference/en/p5 copy/touches.mdx new file mode 100644 index 0000000000..7ad03e1610 --- /dev/null +++ b/src/content/reference/en/p5 copy/touches.mdx @@ -0,0 +1,102 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/touch.js#L10 +title: touches +module: Events +submodule: Touch +file: src/events/touch.js +description: > +

An Array of all the current touch points on a touchscreen + device.

+ +

The touches array is empty by default. When the user touches + their + + screen, a new touch point is tracked and added to the array. Touch points + + are Objects with the following properties:

+ +
// Iterate over the touches array.
+
+  for (let touch of touches) {
+    // x-coordinate relative to the top-left
+    // corner of the canvas.
+    console.log(touch.x);
+
+    // y-coordinate relative to the top-left
+    // corner of the canvas.
+    console.log(touch.y);
+
+    // x-coordinate relative to the top-left
+    // corner of the browser.
+    console.log(touch.winX);
+
+    // y-coordinate relative to the top-left
+    // corner of the browser.
+    console.log(touch.winY);
+
+    // ID number
+    console.log(touch.id);
+  }
+
+  
+line: 10 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // On a touchscreen device, touch the canvas using one or more fingers + // at the same time. + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square. White circles appear where the user touches the square.' + ); + } + + function draw() { + background(200); + + // Draw a circle at each touch point. + for (let touch of touches) { + circle(touch.x, touch.y, 40); + } + } + +
+ +
+ + // On a touchscreen device, touch the canvas using one or more fingers + // at the same time. + + function setup() { + createCanvas(100, 100); + + describe( + 'A gray square. Labels appear where the user touches the square, displaying the coordinates.' + ); + } + + function draw() { + background(200); + + // Draw a label above each touch point. + for (let touch of touches) { + text(`${touch.x}, ${touch.y}`, touch.x, touch.y - 40); + } + } + +
+class: p5 +type: 'Object[]' +--- + + +# touches diff --git a/src/content/reference/en/p5 copy/translate.mdx b/src/content/reference/en/p5 copy/translate.mdx new file mode 100644 index 0000000000..dd725eb199 --- /dev/null +++ b/src/content/reference/en/p5 copy/translate.mdx @@ -0,0 +1,241 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L1223 +title: translate +module: Transform +submodule: Transform +file: src/core/transform.js +description: > +

Translates the coordinate system.

+ +

By default, the origin (0, 0) is at the sketch's top-left + corner in 2D + + mode and center in WebGL mode. The translate() function shifts + the origin + + to a different position. Everything drawn after translate() is + called + + will appear to be shifted. There are two ways to call translate() + with + + parameters that set the origin's position.

+ +

The first way to call translate() uses numbers to set the + amount of + + translation. The first two parameters, x and y, set + the amount to + + translate along the positive x- and y-axes. For example, calling + + translate(20, 30) translates the origin 20 pixels along the + x-axis and 30 + + pixels along the y-axis. The third parameter, z, is optional. It + sets the + + amount to translate along the positive z-axis. For example, calling + + translate(20, 30, 40) translates the origin 20 pixels along the + x-axis, + + 30 pixels along the y-axis, and 40 pixels along the z-axis.

+ +

The second way to call translate() uses a + + p5.Vector object to set the amount of + + translation. For example, calling translate(myVector) uses the + x-, y-, + + and z-components of myVector to set the amount to translate along + the x-, + + y-, and z-axes. Doing so is the same as calling + + translate(myVector.x, myVector.y, myVector.z).

+ +

By default, transformations accumulate. For example, calling + + translate(10, 0) twice has the same effect as calling + + translate(20, 0) once. The push() and + + pop() functions can be used to isolate + + transformations within distinct drawing groups.

+ +

Note: Transformations are reset at the beginning of the draw loop. Calling + + translate(10, 0) inside the draw() function won't + + cause shapes to move continuously.

+line: 1223 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A white circle on a gray background.'); + } + + function draw() { + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Draw a circle at coordinates (0, 0). + circle(0, 0, 40); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe( + 'Two circles drawn on a gray background. The blue circle on the right overlaps the red circle at the center.' + ); + } + + function draw() { + background(200); + + // Translate the origin to the center. + translate(50, 50); + + // Draw the red circle. + fill('red'); + circle(0, 0, 40); + + // Translate the origin to the right. + translate(25, 0); + + // Draw the blue circle. + fill('blue'); + circle(0, 0, 40); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A white circle moves slowly from left to right on a gray background.'); + } + + function draw() { + background(200); + + // Calculate the x-coordinate. + let x = frameCount * 0.2; + + // Translate the origin. + translate(x, 50); + + // Draw a circle at coordinates (0, 0). + circle(0, 0, 40); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A white circle on a gray background.'); + } + + function draw() { + background(200); + + // Create a p5.Vector object. + let v = createVector(50, 50); + + // Translate the origin by the vector. + translate(v); + + // Draw a circle at coordinates (0, 0). + circle(0, 0, 40); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe( + 'Two spheres sitting side-by-side on gray background. The sphere at the center is red. The sphere on the right is blue.' + ); + } + + function draw() { + background(200); + + // Turn on the lights. + lights(); + + // Style the spheres. + noStroke(); + + // Draw the red sphere. + fill('red'); + sphere(10); + + // Translate the origin to the right. + translate(30, 0, 0); + + // Draw the blue sphere. + fill('blue'); + sphere(10); + } + +
+class: p5 +overloads: + - line: 1223 + params: + - name: x + description: | +

amount to translate along the positive x-axis.

+ type: Number + - name: 'y' + description: | +

amount to translate along the positive y-axis.

+ type: Number + - name: z + description: | +

amount to translate along the positive z-axis.

+ type: Number + optional: true + chainable: 1 + - line: 1394 + params: + - name: vector + description: | +

vector by which to translate.

+ type: p5.Vector + chainable: 1 +chainable: true +--- + + +# translate diff --git a/src/content/reference/en/p5 copy/triangle.mdx b/src/content/reference/en/p5 copy/triangle.mdx new file mode 100644 index 0000000000..08f1afb223 --- /dev/null +++ b/src/content/reference/en/p5 copy/triangle.mdx @@ -0,0 +1,104 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L1385 +title: triangle +module: Shape +submodule: 2D Primitives +file: src/core/shape/2d_primitives.js +description: > +

Draws a triangle.

+ +

A triangle is a three-sided shape defined by three points. The + + first two parameters specify the triangle's first point (x1, y1). + The + + middle two parameters specify its second point (x2, y2). And the + last two + + parameters specify its third point (x3, y3).

+line: 1385 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + triangle(30, 75, 58, 20, 86, 75); + + describe('A white triangle with a black outline on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + triangle(-20, 25, 8, -30, 36, 25); + + describe('A white triangle with a black outline on a gray canvas.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white triangle spins around on a gray canvas.'); + } + + function draw() { + background(200); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Draw the triangle. + triangle(-20, 25, 8, -30, 36, 25); + } + +
+class: p5 +params: + - name: x1 + description: | +

x-coordinate of the first point.

+ type: Number + - name: y1 + description: | +

y-coordinate of the first point.

+ type: Number + - name: x2 + description: | +

x-coordinate of the second point.

+ type: Number + - name: y2 + description: | +

y-coordinate of the second point.

+ type: Number + - name: x3 + description: | +

x-coordinate of the third point.

+ type: Number + - name: y3 + description: | +

y-coordinate of the third point.

+ type: Number +chainable: true +--- + + +# triangle diff --git a/src/content/reference/en/p5 copy/trim.mdx b/src/content/reference/en/p5 copy/trim.mdx new file mode 100644 index 0000000000..a782306725 --- /dev/null +++ b/src/content/reference/en/p5 copy/trim.mdx @@ -0,0 +1,113 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L916 +title: trim +module: Data +submodule: String Functions +file: src/utilities/string_functions.js +description: > +

Removes whitespace from the start and end of a String without + changing the middle.

+ +

trim() trims + + whitespace characters + + such as spaces, carriage returns, tabs, Unicode "nbsp" character.

+ +

The parameter, str, is the string to trim. If a single string + is passed, + + as in trim(' pad '), a single string is returned. If an array + of + + strings is passed, as in trim([' pad ', '\n space \n']), an + array of + + strings is returned.

+line: 916 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let string = ' p5*js '; + + // Trim the whitespace. + let trimmed = trim(string); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the text. + text(`Hello, ${trimmed}!`, 50, 50); + + describe('The text "Hello, p5*js!" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of strings. + let strings = [' wide ', '\n open ', '\n spaces ']; + + // Trim the whitespace. + let trimmed = trim(strings); + + // Style the text. + textAlign(CENTER, CENTER); + textFont('Courier New'); + textSize(10); + + // Display the text. + text(`${trimmed[0]} ${trimmed[1]} ${trimmed[2]}`, 50, 50); + + describe('The text "wide open spaces" written in black on a gray background.'); + } + +
+class: p5 +return: + description: trimmed string. + type: String +overloads: + - line: 916 + params: + - name: str + description: | +

string to trim.

+ type: String + return: + description: trimmed string. + type: String + - line: 984 + params: + - name: strs + description: | +

strings to trim.

+ type: 'String[]' + return: + description: trimmed strings. + type: 'String[]' +chainable: false +--- + + +# trim diff --git a/src/content/reference/en/p5 copy/turnAxis.mdx b/src/content/reference/en/p5 copy/turnAxis.mdx new file mode 100644 index 0000000000..e8dc93e115 --- /dev/null +++ b/src/content/reference/en/p5 copy/turnAxis.mdx @@ -0,0 +1,54 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L378 +title: turnAxis +module: Events +submodule: Acceleration +file: src/events/acceleration.js +description: > +

When a device is rotated, the axis that triggers the deviceTurned() + + method is stored in the turnAxis variable. The turnAxis variable is only + defined within + + the scope of deviceTurned().

+line: 378 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // Run this example on a mobile device + // Rotate the device by 90 degrees in the + // X-axis to change the value. + + let value = 0; + 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') { + if (value === 0) { + value = 255; + } else if (value === 255) { + value = 0; + } + } + } + +
+class: p5 +type: String +--- + + +# turnAxis diff --git a/src/content/reference/en/p5 copy/types/Array.mdx b/src/content/reference/en/p5 copy/types/Array.mdx new file mode 100644 index 0000000000..17fe1c2ed3 --- /dev/null +++ b/src/content/reference/en/p5 copy/types/Array.mdx @@ -0,0 +1,269 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L1140 +title: Array +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: > +

A list that keeps several pieces of data in order.

+ +

Arrays are helpful for storing related data. They can contain data of any + + type. For example, an array could contain a list of someone's favorite + + colors as strings. Arrays are created as follows:

+ +
let myArray = ['deeppink', 'darkorchid',
+  'magenta'];
+
+  
+ +

Each piece of data in an array is called an element. Each element has an + + address, or index, within its array. The variable myArray refers + to an + + array with three String elements, + 'deeppink', + + 'darkorchid', and 'magenta'. Arrays are + zero-indexed, which means + + that 'deeppink' is at index 0, 'darkorchid' is at + index 1, and + + 'magenta' is at index 2. Array elements can be accessed using + their + + indices as follows:

+ +
let zeroth = myArray[0]; // 'deeppink'
+
+  let first = myArray[1]; // 'darkorchid'
+
+  let second = myArray[2]; // 'magenta'
+
+  
+ +

Elements can be added to the end of an array by calling the + + push() + + method as follows:

+ +
myArray.push('lavender');
+
+
+  let third = myArray[3]; // 'lavender'
+
+  
+ +

See MDN + + for more information about arrays.

+line: 1140 +isConstructor: false +itemtype: property +example: + - >- + +
+ + + + // Declare the variable xCoordinates and assign it an array + + // with three numeric elements. + + let xCoordinates = [25, 50, 75]; + + + function setup() { + createCanvas(100, 100); + + describe( + 'Three white circles drawn in a horizontal line on a gray background.' + ); + } + + + function draw() { + background(200); + + // Access the element at index 0, which is 25. + circle(xCoordinates[0], 50, 20); + + // Access the element at index 1, which is 50. + circle(xCoordinates[1], 50, 20); + + // Access the element at index 2, which is 75. + circle(xCoordinates[2], 50, 20); + } + + + +
+ + +
+ + + + // Declare the variable xCoordinates and assign it an array with three + numeric elements. + + let xCoordinates = [20, 40, 60]; + + + // Add another element to the end of the array. + + xCoordinates.push(80); + + + function setup() { + createCanvas(100, 100); + + describe('Four white circles drawn in a horizontal line on a gray background.'); + } + + + function draw() { + background(200); + + // Access the element at index 0, which is 20. + circle(xCoordinates[0], 50, 20); + + // Access the element at index 1, which is 40. + circle(xCoordinates[1], 50, 20); + + // Access the element at index 2, which is 60. + circle(xCoordinates[2], 50, 20); + + // Access the element at index 3, which is 80. + circle(xCoordinates[3], 50, 20); + } + + + +
+ + +
+ + + + // Declare the variable xCoordinates and assign it an empty array. + + let xCoordinates = []; + + + function setup() { + createCanvas(100, 100); + + // Add elements to the array using a loop. + for (let x = 20; x < 100; x += 20) { + xCoordinates.push(x); + } + + describe('Four white circles drawn in a horizontal line on a gray background.'); + } + + + function draw() { + background(200); + + // Access the element at index i and use it to draw a circle. + for (let i = 0; i < xCoordinates.length; i += 1) { + circle(xCoordinates[i], 50, 20); + } + } + + + +
+ + +
+ + + + // Declare the variable xCoordinates and assign it an empty array. + + let xCoordinates = []; + + + function setup() { + createCanvas(100, 100); + + // Add elements to the array using a loop. + for (let x = 20; x < 100; x += 20) { + xCoordinates.push(x); + } + + describe('Four white circles drawn in a horizontal line on a gray background.'); + } + + + function draw() { + background(200); + + // Access each element of the array and use it to draw a circle. + for (let x of xCoordinates) { + circle(x, 50, 20); + } + } + + + +
+ + +
+ + + + // Declare the variable xCoordinates and assign it an empty array. + + let xCoordinates = []; + + + function setup() { + createCanvas(100, 100); + + // Add elements to the array using a loop. + for (let x = 20; x < 100; x += 20) { + xCoordinates.push(x); + } + + describe( + 'Four white circles in a horizontal line on a gray background. The circles move randomly.' + ); + } + + + function draw() { + background(200); + + for (let i = 0; i < xCoordinates.length; i += 1) { + // Update the element at index i. + xCoordinates[i] += random(-1, 1); + + // Use the element at index i to draw a circle. + circle(xCoordinates[i], 50, 20); + } + } + + + +
+class: p5 +--- + + +# Array diff --git a/src/content/reference/en/p5 copy/types/Boolean.mdx b/src/content/reference/en/p5 copy/types/Boolean.mdx new file mode 100644 index 0000000000..01d02c8de2 --- /dev/null +++ b/src/content/reference/en/p5 copy/types/Boolean.mdx @@ -0,0 +1,273 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L502 +title: Boolean +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: > +

A value that's either true or false.

+ +

Boolean values help to make decisions in code. They appear any + time a + + logical condition is checked. For example, the condition + + "Is a mouse button being pressed?" must be either true or + + false:

+ +
// If the user presses the mouse, draw a circle
+  at
+
+  // the mouse's location.
+
+  if (mouseIsPressed === true) {
+    circle(mouseX, mouseY, 20);
+  }
+
+  
+ +

The if statement checks whether + + mouseIsPressed is + true and draws a + + circle if it is. Boolean expressions such as mouseIsPressed + === true + + evaluate to one of the two possible Boolean values: + true or false.

+ +

The === operator (EQUAL) checks whether two values are equal. + If they + + are, the expression evaluates to true. Otherwise, it evaluates to + + false.

+ +

Note: There's also a == operator with two = + instead of three. Don't use + + it.

+ +

The mouseIsPressed system + variable is + + always true or false, so the code snippet above + could also be written + + as follows:

+ +
if (mouseIsPressed) {
+    circle(mouseX, mouseY, 20);
+  }
+
+  
+ +

The !== operator (NOT EQUAL) checks whether two values are not + equal, as + + in the following example:

+ +
if (2 + 2 !== 4) {
+    text('War is peace.', 50, 50);
+  }
+
+  
+ +

Starting from the left, the arithmetic expression 2 + 2 + produces the + + value 4. The Boolean expression 4 !== 4 + evaluates to false because + + 4 is equal to itself. As a result, the if + statement's body is skipped.

+ +

Note: There's also a != operator with one = + instead of two. Don't use + + it.

+ +

The Boolean operator && (AND) checks whether two + expressions are both + + true:

+ +
if (keyIsPressed === true && key === 'p') {
+    text('You pressed the "p" key!', 50, 50);
+  }
+
+  
+ +

If the user is pressing a key AND that key is 'p', then a + message will + + display.

+ +

The Boolean operator || (OR) checks whether at + least one of two + + expressions is true:

+ +
if (keyIsPressed === true || mouseIsPressed ===
+  true) {
+    text('You did something!', 50, 50);
+  }
+
+  
+ +

If the user presses a key, or presses a mouse button, or both, then a + + message will display.

+ +

The following truth table summarizes a few common scenarios with + && and + + ||:

+ +
true && true  // true
+
+  true && false // false
+
+  false && false // false
+
+  true || true  // true
+
+  true || false // true
+
+  false || false // false
+
+  
+ +

The relational operators >, << code="">, + >=, and <=< code=""> also produce Boolean + + values:

+ +
2 > 1 // true
+
+  2 < 1 // false
+
+  2 >= 2 // true
+
+  2 <= 2="" true="" <="" code=""/>
+ +

See if for more information about + if statements and + + Number for more information about + Numbers.

+line: 502 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('A gray square. When the user presses the mouse, a circle appears at that location.'); + } + + function draw() { + background(200); + + // If the user presses the mouse, draw a circle at that location. + if (mouseIsPressed) { + circle(mouseX, mouseY, 20); + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A gray square. When the user presses the mouse, a circle appears at that location.'); + } + + function draw() { + background(200); + + // If the user presses the mouse, draw a circle at that location. + if (mouseIsPressed === true) { + circle(mouseX, mouseY, 20); + } + } + +
+ +
+ + // Click on the canvas to begin detecting key presses. + + function setup() { + createCanvas(100, 100); + + describe('A gray square that turns pink when the user presses the mouse or a key.'); + } + + function draw() { + background(200); + + // If the user presses the mouse, change the background color. + if (mouseIsPressed === true || keyIsPressed === true) { + background('deeppink'); + } + } + +
+ +
+ + // Click the canvas to begin detecting key presses. + + // Create a Boolean variable. + let isPlaying = false; + + function setup() { + createCanvas(100, 100); + + describe( + 'The message "Begin?\nY or N" written in green on a black background. The message "Good luck!" appears when they press the "y" key.' + ); + } + + function draw() { + background(0); + + // Style the text. + textAlign(CENTER, CENTER); + textFont('Courier New'); + textSize(16); + fill(0, 255, 0); + + // Display a different message when the user begins playing. + if (isPlaying === false) { + text('Begin?', 50, 40); + text('Y or N', 50, 60); + } else { + text('Good luck!', 50, 50); + } + } + + // Start playing when the user presses the 'y' key. + function keyPressed() { + if (key === 'y') { + isPlaying = true; + } + } + +
+class: p5 +--- + + +# Boolean diff --git a/src/content/reference/en/p5 copy/types/Number.mdx b/src/content/reference/en/p5 copy/types/Number.mdx new file mode 100644 index 0000000000..3dfa850720 --- /dev/null +++ b/src/content/reference/en/p5 copy/types/Number.mdx @@ -0,0 +1,201 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L853 +title: Number +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: > +

A number that can be positive, negative, or zero.

+ +

The Number data type is useful for describing values such as + position, + + size, and color. A number can be an integer such as 20 or a decimal number + + such as 12.34. For example, a circle's position and size can be described + + by three numbers:

+ +
circle(50, 50, 20);
+
+  
+ +
circle(50, 50, 12.34);
+
+  
+ +

Numbers support basic arithmetic and follow the standard order of + + operations: Parentheses, Exponents, Multiplication, Division, Addition, + + and Subtraction (PEMDAS). For example, it's common to use arithmetic + + operators with p5.js' system variables that are numbers:

+ +
// Draw a circle at the center.
+
+  circle(width / 2, height / 2, 20);
+
+  
+ +
// Draw a circle that moves from left to right.
+
+  circle(frameCount * 0.01, 50, 20);
+
+  
+ +

Here's a quick overview of the arithmetic operators:

+ +
1 + 2 // Add
+
+  1 - 2 // Subtract
+
+  1 * 2 // Multiply
+
+  1 / 2 // Divide
+
+  1 % 2 // Remainder
+
+  1 ** 2 // Exponentiate
+
+  
+ +

It's common to update a number variable using arithmetic. For example, an + + object's location can be updated like so:

+ +
x = x + 1;
+
+  
+ +

The statement above adds 1 to a variable x using the + + operator. The + + addition assignment operator += expresses the same idea:

+ +
x += 1;
+
+  
+ +

Here's a quick overview of the assignment operators:

+ +
x += 2 // Addition assignment
+
+  x -= 2 // Subtraction assignment
+
+  x *= 2 // Multiplication assignment
+
+  x /= 2 // Division assignment
+
+  x %= 2 // Remainder assignment
+
+  
+ +

Numbers can be compared using the + + relational operators + + >, << code="">, >=, <=< code="">, + ===, and !==. For example, a sketch's + + frameCount can be used as a + timer:

+ +
if (frameCount > 1000) {
+    text('Game over!', 50, 50);
+  }
+
+  
+ +

An expression such as frameCount > 1000 evaluates to a + Boolean value + + that's either true or false. The relational + operators all produce + + Boolean values:

+ +
2 > 1 // true
+
+  2 < 1 // false
+
+  2 >= 2 // true
+
+  2 <= 2="" true="" !="=" false="" <="" code=""/>
+ +

See Boolean for more information about + comparisons and conditions.

+ +

Note: There are also == and != operators with one + fewer =. Don't use them.

+ +

Expressions with numbers can also produce special values when something + + goes wrong:

+ +
sqrt(-1) // NaN
+
+  1 / 0 // Infinity
+
+  
+ +

The value NaN stands for + + Not-A-Number. + + NaN appears when calculations or conversions don't work. + Infinity is a + + value that's larger than any number. It appears during certain + + calculations.

+line: 853 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Draw a circle at the center. + circle(50, 50, 70); + + // Draw a smaller circle at the center. + circle(width / 2, height / 2, 30); + + describe('Two concentric, white circles drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + describe('A white circle travels from left to right on a gray background.'); + } + + function draw() { + background(200); + + circle(frameCount * 0.05, 50, 20); + } + +
+class: p5 +--- + + +# Number diff --git a/src/content/reference/en/p5 copy/types/Object.mdx b/src/content/reference/en/p5 copy/types/Object.mdx new file mode 100644 index 0000000000..c5c9adf8bb --- /dev/null +++ b/src/content/reference/en/p5 copy/types/Object.mdx @@ -0,0 +1,91 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L999 +title: Object +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: "

A container for data that's stored as key-value pairs.

\n

Objects help to organize related data of any type, including other objects.\nA value stored in an object can be accessed by name, called its key. Each\nkey-value pair is called a \"property.\" Objects are similar to dictionaries\nin Python and maps in Java and Ruby.

\n

For example, an object could contain the location, size, and appearance of\na dog:

\n
// Declare the dog variable and assign it an object.\nlet dog = { x: 50, y: 50, size: 20, emoji: '\U0001F436' };\n\n// Style the text.\ntextAlign(CENTER, CENTER);\ntextSize(dog.size);\n\n// Draw the dog.\ntext(dog.emoji, dog.x, dog.y);\n
\n

The variable dog is assigned an object with four properties. Objects\nare declared with curly braces {}. Values can be accessed using the dot\noperator, as in dog.size. In the example above, the key size\ncorresponds to the value 20. Objects can also be empty to start:

\n
// Declare a cat variable and assign it an empty object.\nlet cat = {};\n\n// Add properties to the object.\ncat.x = 50;\ncat.y = 50;\ncat.size = 20;\ncat.emoji = '\U0001F431';\n\n// Style the text.\ntextAlign(CENTER, CENTER);\ntextSize(cat.size);\n\n// Draw the cat.\ntext(cat.emoji, cat.x, cat.y);\n
\n

An object's data can be updated while a sketch runs. For example, the cat\ncould run away from the dog by updating its location:

\n
// Run to the right.\ncat.x += 5;\n
\n

If needed, an object's values can be accessed using square brackets []\nand strings instead of dot notation:

\n
// Run to the right.\ncat[\"x\"] += 5;\n
\n

This syntax can be helpful when the key's name has spaces, as in\ncat['height (m)'].

\n" +line: 999 +isConstructor: false +itemtype: property +example: + - |- + +
+ + // Declare the variable data and assign it an object with three properties. + let data = { x: 50, y: 50, d: 20 }; + + function setup() { + createCanvas(100, 100); + + describe('A white circle on a gray background.'); + } + + function draw() { + background(200); + + // Access the object's values using the . operator. + circle(data.x, data.y, data.d); + } + +
+ +
+ + // Declare the variable data and assign it an object with three properties. + let data = { x: 50, y: 50, d: 20 }; + + // Add another property for color. + data.color = 'deeppink'; + + function setup() { + createCanvas(100, 100); + + describe('A pink circle on a gray background.'); + } + + function draw() { + background(200); + + // Access the object's values using the . operator. + fill(data.color); + circle(data.x, data.y, data.d); + } + +
+ +
+ + // Declare the variable data and assign it an object with three properties. + let data = { x: 50, y: 50, d: 20 }; + + // Add another property for color. + data.color = 'deeppink'; + + function setup() { + createCanvas(100, 100); + + describe('A white circle on a gray background.'); + } + + function draw() { + background(200); + + // Access the object's values using the . operator. + fill(data.color); + circle(data.x, data.y, data.d); + + // Update the object's x and y properties. + data.x += random(-1, 1); + data.y += random(-1, 1); + } + +
+class: p5 +--- + + +# Object diff --git a/src/content/reference/en/p5 copy/types/String.mdx b/src/content/reference/en/p5 copy/types/String.mdx new file mode 100644 index 0000000000..e62a9a8b9c --- /dev/null +++ b/src/content/reference/en/p5 copy/types/String.mdx @@ -0,0 +1,153 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L710 +title: String +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: > +

A sequence of text characters.

+ +

The String data type is helpful for working with text. For + example, a + + string could contain a welcome message:

+ +
// Use a string literal.
+
+  text('Hello!', 10, 10);
+
+  
+ +
// Create a string variable.
+
+  let message = 'Hello!';
+
+
+  // Use the string variable.
+
+  text(message, 10, 10);
+
+  
+ +

The most common way to create strings is to use some form of quotations as + + follows:

+ +
text("hi", 50, 50);
+
+  
+ +
text('hi', 50, 50);
+
+  
+ +
text(`hi`, 50, 50);
+
+  
+ +

"hi", 'hi', and hi are all string + literals. A "literal" means a + + value was actually written, as in text('hi', 50, 50). By + contrast, + + text(message, 50, 50) uses the variable message, so + it isn't a string + + literal.

+ +

Single quotes '' and double quotes "" mean the + same thing. It's nice to + + have the option for cases when a string contains one type of quote:

+ +
text("What's up?", 50, 50);
+
+  
+ +
text('Air quotes make you look "cool."', 50,
+  50);
+
+  
+ +

Backticks `` create template literals. Template literals have + many uses. + + For example, they can contain both single and double quotes as needed:

+ +
text(`"Don't you forget about me"`,  10, 10);
+
+  
+ +

Template literals are helpful when strings are created from variables like + + so:

+ +
let size = random(10, 20);
+
+  circle(50, 50, size);
+
+
+  text(`The circle's diameter is ${size} pixels.`,  10, 10);
+
+  
+ +

The size variable's value will replace ${size} + when the string is + + created. ${} is a placeholder for any value. That means an + expression can + + be used, as in ${round(PI, 3)}. All of the following are valid + template + + literals:

+ +
text(`π is about ${round(PI, 2)} pixels.`,  10,
+  10);
+
+  text(`It's ${mouseX < width / 2} that I'm on the left half of the canvas.`, 
+  10, 30);
+
+  
+ +

Template literals can include several variables:

+ +
let x = random(0, 100);
+
+  let y = random(0, 100);
+
+  let size = random(10, 20);
+
+  circle(x, y, size);
+
+
+  text(`The circle at (${x}, ${y}) has a diameter of ${size} pixels.`,  10, 10);
+
+  
+ +

Template literals are also helpful for creating multi-line text like + so:

+ +
let poem = `My sketch doesn't run;
+
+  it waits for me patiently
+
+  while bugs point the way.`;
+
+
+  text(poem, 10, 10);
+
+  
+line: 710 +isConstructor: false +itemtype: property +example: + - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Style the text.\n textAlign(CENTER, CENTER);\n textSize(20);\n\n // Display a welcome message.\n text('Hello!', 50, 50);\n\n describe('The text \"Hello!\" written on a gray background.');\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Style the text.\n textAlign(CENTER, CENTER);\n textSize(20);\n\n // Create a string variable.\n let world = '\U0001F30D';\n\n // Display a welcome message using a template string.\n text(`Hello, ${world}!`, 50, 50);\n\n describe('The text \"Hello, \U0001F30D!\" written on a gray background.');\n}\n\n
" +class: p5 +--- + + +# String diff --git a/src/content/reference/en/p5 copy/unchar.mdx b/src/content/reference/en/p5 copy/unchar.mdx new file mode 100644 index 0000000000..8ef044b393 --- /dev/null +++ b/src/content/reference/en/p5 copy/unchar.mdx @@ -0,0 +1,114 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L731 +title: unchar +module: Data +submodule: Conversion +file: src/utilities/conversion.js +description: > +

Converts a single-character String to a + Number.

+ +

unchar() converts single-character strings to their + corresponding + + integer (whole number).

+ +

The parameter, n, is the character to convert. For example, + + unchar('A'), returns the number 65. If an array is passed, as in + + unchar(['A', 'B', 'C']), an array of integers is returned.

+line: 731 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a string variable. + let original = 'A'; + + // Convert the string to a number. + let converted = unchar(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the original and converted values. + text(`${original} : ${converted}`, 50, 50); + + describe('The text "A : 65" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of characters. + let original = ['A', 'B', 'C']; + + // Convert the string to a number. + let converted = unchar(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Iterate over elements of the converted array. + for (let i = 0; i < converted.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 25; + + // Display the original and converted values. + text(`${original[i]} : ${converted[i]}`, 50, y); + } + + describe( + 'The text "A : 65", "B : 66", and "C :67" written on three separate lines. The text is in black on a gray background.' + ); + } + +
+class: p5 +return: + description: converted number. + type: Number +overloads: + - line: 731 + params: + - name: 'n' + description: | +

value to convert.

+ type: String + return: + description: converted number. + type: Number + - line: 805 + params: + - name: ns + description: | +

values to convert.

+ type: 'String[]' + return: + description: converted numbers. + type: 'Number[]' +chainable: false +--- + + +# unchar diff --git a/src/content/reference/en/p5 copy/unhex.mdx b/src/content/reference/en/p5 copy/unhex.mdx new file mode 100644 index 0000000000..5c507abc4c --- /dev/null +++ b/src/content/reference/en/p5 copy/unhex.mdx @@ -0,0 +1,121 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L956 +title: unhex +module: Data +submodule: Conversion +file: src/utilities/conversion.js +description: > +

Converts a String with a hexadecimal value to a + Number.

+ +

unhex() converts a string with its hexadecimal number value to + a number. + + Hexadecimal (hex) numbers are base-16, which means there are 16 unique + + digits. Hex extends the numbers 0–9 with the letters A–F. For example, the + + number 11 (eleven) in base-10 is written as the letter + B in hex.

+ +

The first parameter, n, is the hex string to convert. For + example, + + unhex('FF'), returns the number 255. If an array is passed, as in + + unhex(['00', '80', 'FF']), an array of numbers is returned.

+line: 956 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create a a hex string variable + let original = 'FF'; + + // Convert the hex string to a number. + let converted = unhex(original); + + // Style the text. + textAlign(CENTER, CENTER); + textSize(16); + + // Display the original and converted values. + text(`${original} = ${converted}`, 50, 50); + + describe('The text "FF = 255" written in black on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Create an array of numbers. + let original = ['00', '80', 'FF']; + + // Convert the numbers to hex strings. + // Only use two hex digits. + let converted = unhex(original, 2); + + // Style the text. + textAlign(RIGHT, CENTER); + textSize(16); + + // Iterate over the converted values. + for (let i = 0; i < converted.length; i += 1) { + + // Calculate the y-coordinate. + let y = (i + 1) * 25; + + // Display the original and converted values. + text(`${ original[i]} = ${converted[i]}`, 80, y); + } + + describe( + 'The text "00 = 0", "80 = 128", and "FF = 255" written on three separate lines. The text is in black on a gray background.' + ); + } + +
+class: p5 +return: + description: converted number. + type: Number +overloads: + - line: 956 + params: + - name: 'n' + description: | +

value to convert.

+ type: String + return: + description: converted number. + type: Number + - line: 1033 + params: + - name: ns + description: | +

values to convert.

+ type: 'String[]' + return: + description: converted numbers. + type: 'Number[]' +chainable: false +--- + + +# unhex diff --git a/src/content/reference/en/p5 copy/updatePixels.mdx b/src/content/reference/en/p5 copy/updatePixels.mdx new file mode 100644 index 0000000000..5de892374b --- /dev/null +++ b/src/content/reference/en/p5 copy/updatePixels.mdx @@ -0,0 +1,94 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L1118 +title: updatePixels +module: Image +submodule: Pixels +file: src/image/pixels.js +description: > +

Updates the canvas with the RGBA values in the + + pixels array.

+ +

updatePixels() only needs to be called after changing values + in the + + pixels array. Such changes can be made + directly + + after calling loadPixels() or by + calling + + set().

+line: 1118 +isConstructor: false +itemtype: method +example: + - |- + +
+ + let img; + + // Load the image. + function preload() { + img = loadImage('/assets/rockies.jpg'); + } + + function setup() { + createCanvas(100, 100); + + // Display the image. + image(img, 0, 0, 100, 100); + + // Get the pixel density. + let d = pixelDensity(); + + // Calculate the halfway index in the pixels array. + let halfImage = 4 * (d * width) * (d * height / 2); + + // Load the pixels array. + loadPixels(); + + // Copy the top half of the canvas to the bottom. + for (let i = 0; i < halfImage; i += 1) { + pixels[i + halfImage] = pixels[i]; + } + + // Update the canvas. + updatePixels(); + + describe('Two identical images of mountain landscapes, one on top of the other.'); + } + +
+class: p5 +params: + - name: x + description: | +

x-coordinate of the upper-left corner of region + to update.

+ type: Number + optional: true + - name: 'y' + description: | +

y-coordinate of the upper-left corner of region + to update.

+ type: Number + optional: true + - name: w + description: | +

width of region to update.

+ type: Number + optional: true + - name: h + description: | +

height of region to update.

+ type: Number + optional: true +chainable: false +--- + + +# updatePixels diff --git a/src/content/reference/en/p5 copy/userStartAudio.mdx b/src/content/reference/en/p5 copy/userStartAudio.mdx new file mode 100644 index 0000000000..076d8537c5 --- /dev/null +++ b/src/content/reference/en/p5 copy/userStartAudio.mdx @@ -0,0 +1,99 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L198 +title: userStartAudio +module: p5.sound +submodule: p5.sound +file: lib/addons/p5.sound.js +description: >- +

It is not only a good practice to give users control over starting + + audio. This policy is enforced by many web browsers, including iOS and + + Google Chrome, which create the Web Audio API's + + Audio Context + + in a suspended state.

+ + +

In these browser-specific policies, sound will not play until a user + + interaction event (i.e. mousePressed()) explicitly resumes + + the AudioContext, or starts an audio node. This can be accomplished by + + calling start() on a p5.Oscillator, + + play() on a p5.SoundFile, or simply + + userStartAudio().

+ + +

userStartAudio() starts the AudioContext on a user + + gesture. The default behavior will enable audio on any + + mouseUp or touchEnd event. It can also be placed in a specific + + interaction function, such as mousePressed() as in the + + example below. This method utilizes + + StartAudioContext + + , a library by Yotam Mann (MIT Licence, 2016).

+line: 198 +isConstructor: false +itemtype: method +example: + - |- + +
+ function setup() { + // mimics the autoplay policy + getAudioContext().suspend(); + + let mySynth = new p5.MonoSynth(); + + // This won't play until the context has resumed + mySynth.play('A6'); + } + function draw() { + background(220); + textAlign(CENTER, CENTER); + text(getAudioContext().state, width/2, height/2); + } + function mousePressed() { + userStartAudio(); + } +
+class: p5 +params: + - name: elements + description: | +

This argument can be an Element, + Selector String, NodeList, p5.Element, + jQuery Element, or an Array of any of those.

+ type: Element|Array + optional: true + - name: callback + description: | +

Callback to invoke when the AudioContext + has started

+ type: Function + optional: true +return: + description: |- + Returns a Promise that resolves when + the AudioContext state is 'running' + type: Promise +chainable: false +--- + + +# userStartAudio diff --git a/src/content/reference/en/p5 copy/vertex.mdx b/src/content/reference/en/p5 copy/vertex.mdx new file mode 100644 index 0000000000..92d5bb9138 --- /dev/null +++ b/src/content/reference/en/p5 copy/vertex.mdx @@ -0,0 +1,242 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L1881 +title: vertex +module: Shape +submodule: Vertex +file: src/core/shape/vertex.js +description: > +

Adds a vertex to a custom shape.

+ +

vertex() sets the coordinates of vertices drawn between the + + beginShape() and + + endShape() functions.

+ +

The first two parameters, x and y, set the x- and + y-coordinates of the + + vertex.

+ +

The third parameter, z, is optional. It sets the z-coordinate + of the + + vertex in WebGL mode. By default, z is 0.

+ +

The fourth and fifth parameters, u and v, are + also optional. They set + + the u- and v-coordinates for the vertex’s texture when used with + + endShape(). By default, u + and v are both 0.

+line: 1881 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Style the shape. + strokeWeight(3); + + // Start drawing the shape. + // Only draw the vertices. + beginShape(POINTS); + + // Add the vertices. + vertex(30, 20); + vertex(85, 20); + vertex(85, 75); + vertex(30, 75); + + // Stop drawing the shape. + endShape(); + + describe('Four black dots that form a square are drawn on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Start drawing the shape. + beginShape(); + + // Add vertices. + vertex(30, 20); + vertex(85, 20); + vertex(85, 75); + vertex(30, 75); + + // Stop drawing the shape. + endShape(CLOSE); + + describe('A white square on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + background(200); + + // Start drawing the shape. + beginShape(); + + // Add vertices. + vertex(-20, -30, 0); + vertex(35, -30, 0); + vertex(35, 25, 0); + vertex(-20, 25, 0); + + // Stop drawing the shape. + endShape(CLOSE); + + describe('A white square on a gray background.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A white square spins around slowly on a gray background.'); + } + + function draw() { + background(200); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Start drawing the shape. + beginShape(); + + // Add vertices. + vertex(-20, -30, 0); + vertex(35, -30, 0); + vertex(35, 25, 0); + vertex(-20, 25, 0); + + // Stop drawing the shape. + endShape(CLOSE); + } + +
+ +
+ + let img; + + // Load an image to apply as a texture. + function preload() { + img = loadImage('/assets/laDefense.jpg'); + } + + function setup() { + createCanvas(100, 100, WEBGL); + + describe('A photograph of a ceiling rotates slowly against a gray background.'); + } + + function draw() { + background(200); + + // Rotate around the y-axis. + rotateY(frameCount * 0.01); + + // Style the shape. + noStroke(); + + // Apply the texture. + texture(img); + textureMode(NORMAL); + + // Start drawing the shape + beginShape(); + + // Add vertices. + vertex(-20, -30, 0, 0, 0); + vertex(35, -30, 0, 1, 0); + vertex(35, 25, 0, 1, 1); + vertex(-20, 25, 0, 0, 1); + + // Stop drawing the shape. + endShape(); + } + +
+class: p5 +overloads: + - line: 1881 + params: + - name: x + description: | +

x-coordinate of the vertex.

+ type: Number + - name: 'y' + description: | +

y-coordinate of the vertex.

+ type: Number + chainable: 1 + - line: 2052 + params: + - name: x + description: '' + type: Number + - name: 'y' + description: '' + type: Number + - name: z + description: | +

z-coordinate of the vertex. Defaults to 0.

+ type: Number + optional: true + chainable: 1 + - line: 2059 + params: + - name: x + description: '' + type: Number + - name: 'y' + description: '' + type: Number + - name: z + description: '' + type: Number + optional: true + - name: u + description: | +

u-coordinate of the vertex's texture. Defaults to 0.

+ type: Number + optional: true + - name: v + description: | +

v-coordinate of the vertex's texture. Defaults to 0.

+ type: Number + optional: true + chainable: 1 +chainable: true +--- + + +# vertex diff --git a/src/content/reference/en/p5 copy/webglVersion.mdx b/src/content/reference/en/p5 copy/webglVersion.mdx new file mode 100644 index 0000000000..1909f94a86 --- /dev/null +++ b/src/content/reference/en/p5 copy/webglVersion.mdx @@ -0,0 +1,105 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L508 +title: webglVersion +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

A String variable with the WebGL version in use.

+ +

webglVersion's value equals one of the following string + constants:

+ +
    + +
  • WEBGL2 whose value is 'webgl2',
  • + +
  • WEBGL whose value is 'webgl', or
  • + +
  • P2D whose value is 'p2d'. This is the default + for 2D sketches.
  • + +
+ +

See setAttributes() for ways to + set the + + WebGL version.

+line: 508 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + background(200); + + // Display the current WebGL version. + text(webglVersion, 42, 54); + + describe('The text "p2d" written in black on a gray background.'); + } + +
+ +
+ + let font; + + function preload() { + // Load a font to use. + font = loadFont('/assets/inconsolata.otf'); + } + + function setup() { + // Create a canvas using WEBGL mode. + createCanvas(100, 50, WEBGL); + background(200); + + // Display the current WebGL version. + fill(0); + textFont(font); + text(webglVersion, -15, 5); + + describe('The text "webgl2" written in black on a gray background.'); + } + +
+ +
+ + let font; + + function preload() { + // Load a font to use. + font = loadFont('/assets/inconsolata.otf'); + } + + function setup() { + // Create a canvas using WEBGL mode. + createCanvas(100, 50, WEBGL); + + // Set WebGL to version 1. + setAttributes({ version: 1 }); + + background(200); + + // Display the current WebGL version. + fill(0); + textFont(font); + text(webglVersion, -14, 5); + + describe('The text "webgl" written in black on a gray background.'); + } + +
+class: p5 +type: String +--- + + +# webglVersion diff --git a/src/content/reference/en/p5 copy/while.mdx b/src/content/reference/en/p5 copy/while.mdx new file mode 100644 index 0000000000..5fdcb2985a --- /dev/null +++ b/src/content/reference/en/p5 copy/while.mdx @@ -0,0 +1,161 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L1872 +title: while +module: Foundation +submodule: Foundation +file: src/core/reference.js +description: > +

A way to repeat a block of code.

+ +

while loops are helpful for repeating statements while a + condition is + + true. They're like if statements that repeat. For + example, a while + + loop makes it easy to express the idea "draw several lines" like so:

+ +
// Declare a variable to keep track of
+  iteration.
+
+  let x = 10;
+
+
+  // Repeat as long as x < 100
+
+  while (x < 100) {
+    line(x, 25, x, 75);
+
+    // Increment by 20.
+    x += 20;
+  }
+
+  
+ +

The loop's header begins with the keyword while. Loops + generally count up + + or count down as they repeat, or iterate. The statement in parentheses + + x < 100 is a condition the loop checks each time it iterates. If + the + + condition is true, the loop runs the code between the curly + braces {}, + + The code between the curly braces is called the loop's body. If the + + condition is false, the body is skipped and the loop is + stopped.

+ +

It's common to create infinite loops accidentally. For example, the + + following loop never stops iterating because it doesn't count up:

+ +
// Declare a variable to keep track of
+  iteration.
+
+  let x = 10;
+
+
+  // Repeat as long as x < 100
+
+  while (x < 100) {
+    line(x, 25, x, 75);
+  }
+
+
+  // This should be in the loop's body!
+
+  x += 20;
+
+  
+ +

The statement x += 20 appears after the loop's body. That + means the + + variable x is stuck at 10, which is always less + than 100.

+ +

while loops are useful when the number of iterations isn't + known in + + advance. For example, concentric circles could be drawn at random + + increments:

+ +
let d = 100;
+
+  let minSize = 5;
+
+
+  while (d > minSize) {
+    circle(50, 50, d);
+    d -= random(10);
+  }
+
+  
+line: 1872 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe('Five black vertical lines on a gray background.'); + } + + function draw() { + background(200); + + // Declare a variable to keep track of iteration. + let x = 10; + + // Repeat as long as x < 100 + while (x < 100) { + line(x, 25, x, 75); + + // Increment by 20. + x += 20; + } + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + // Slow the frame rate. + frameRate(5); + + describe( + "A gray square with several concentric circles at the center. The circles' sizes decrease at random increments." + ); + } + + function draw() { + background(200); + + let d = 100; + let minSize = 5; + + while (d > minSize) { + circle(50, 50, d); + d -= random(5, 15); + } + } + +
+class: p5 +--- + + +# while diff --git a/src/content/reference/en/p5 copy/width.mdx b/src/content/reference/en/p5 copy/width.mdx new file mode 100644 index 0000000000..0eb6ad07bb --- /dev/null +++ b/src/content/reference/en/p5 copy/width.mdx @@ -0,0 +1,87 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L812 +title: width +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

A Number variable that stores the width of the canvas in + pixels.

+ +

width's default value is 100. Calling + + createCanvas() or + + resizeCanvas() changes the value of + + width. Calling noCanvas() + sets its value to + + 0.

+line: 812 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + background(200); + + // Display the canvas' width. + text(width, 42, 54); + + describe('The number 100 written in black on a gray square.'); + } + +
+ +
+ + function setup() { + createCanvas(50, 100); + + background(200); + + // Display the canvas' width. + text(width, 21, 54); + + describe('The number 50 written in black on a gray rectangle.'); + } + +
+ +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Display the canvas' width. + text(width, 42, 54); + + describe('The number 100 written in black on a gray square. When the mouse is pressed, the square becomes a rectangle and the number becomes 50.'); + } + + // If the mouse is pressed, reisze + // the canvas and display its new + // width. + function mousePressed() { + if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) { + resizeCanvas(50, 100); + background(200); + text(width, 21, 54); + } + } + +
+class: p5 +type: Number +--- + + +# width diff --git a/src/content/reference/en/p5 copy/winMouseX.mdx b/src/content/reference/en/p5 copy/winMouseX.mdx new file mode 100644 index 0000000000..ae7dbc3fac --- /dev/null +++ b/src/content/reference/en/p5 copy/winMouseX.mdx @@ -0,0 +1,61 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L463 +title: winMouseX +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A Number variable that tracks the mouse's horizontal position + within the + + browser.

+ +

winMouseX keeps track of the mouse's position relative to the + top-left + + corner of the browser window. For example, if the mouse is 50 pixels from + + the left edge of the browser, then winMouseX will be 50.

+ +

On a touchscreen device, winMouseX will hold the x-coordinate + of the most + + recent touch point.

+ +

Note: Use mouseX to track the mouse’s + + x-coordinate within the canvas.

+line: 463 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe("A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse."); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the mouse's coordinates within the browser window. + text(`x: ${winMouseX} y: ${winMouseY}`, 50, 50); + } + +
+class: p5 +type: Number +--- + + +# winMouseX diff --git a/src/content/reference/en/p5 copy/winMouseY.mdx b/src/content/reference/en/p5 copy/winMouseY.mdx new file mode 100644 index 0000000000..32c59cba4c --- /dev/null +++ b/src/content/reference/en/p5 copy/winMouseY.mdx @@ -0,0 +1,61 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L504 +title: winMouseY +module: Events +submodule: Mouse +file: src/events/mouse.js +description: > +

A Number variable that tracks the mouse's vertical position + within the + + browser.

+ +

winMouseY keeps track of the mouse's position relative to the + top-left + + corner of the browser window. For example, if the mouse is 50 pixels from + + the top edge of the browser, then winMouseY will be 50.

+ +

On a touchscreen device, winMouseY will hold the y-coordinate + of the most + + recent touch point.

+ +

Note: Use mouseY to track the mouse’s + + y-coordinate within the canvas.

+line: 504 +isConstructor: false +itemtype: property +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + describe("A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse."); + } + + function draw() { + background(200); + + // Style the text. + textAlign(CENTER); + textSize(16); + + // Display the mouse's coordinates within the browser window. + text(`x: ${winMouseX} y: ${winMouseY}`, 50, 50); + } + +
+class: p5 +type: Number +--- + + +# winMouseY diff --git a/src/content/reference/en/p5 copy/windowHeight.mdx b/src/content/reference/en/p5 copy/windowHeight.mdx new file mode 100644 index 0000000000..829ac3d76b --- /dev/null +++ b/src/content/reference/en/p5 copy/windowHeight.mdx @@ -0,0 +1,43 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L680 +title: windowHeight +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

A Number variable that stores the height of the browser's + viewport.

+ +

The layout viewport + + is the area within the browser that's available for drawing.

+line: 680 +isConstructor: false +itemtype: property +alt: This example does not render anything. +example: + - |- + +
+ + function setup() { + // Set the canvas' width and height + // using the browser's dimensions. + createCanvas(windowWidth, windowHeight); + + background(200); + + describe('A gray canvas that takes up the entire browser window.'); + } + +
+class: p5 +type: Number +--- + + +# windowHeight diff --git a/src/content/reference/en/p5 copy/windowResized.mdx b/src/content/reference/en/p5 copy/windowResized.mdx new file mode 100644 index 0000000000..aed52e6b4b --- /dev/null +++ b/src/content/reference/en/p5 copy/windowResized.mdx @@ -0,0 +1,64 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L708 +title: windowResized +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

A function that's called when the browser window is resized.

+ +

Code placed in the body of windowResized() will run when the + + browser window's size changes. It's a good place to call + + resizeCanvas() or make other + + adjustments to accommodate the new window size.

+ +

The event parameter is optional. If added to the function + declaration, it + + can be used for debugging or other purposes.

+line: 708 +isConstructor: false +itemtype: method +alt: This example does not render anything. +example: + - |- + +
+ + function setup() { + createCanvas(windowWidth, windowHeight); + + describe('A gray canvas with a white circle at its center. The canvas takes up the entire browser window. It changes size to match the browser window.'); + } + + function draw() { + background(200); + + // Draw a circle at the center. + circle(width / 2, height / 2, 50); + } + + // Resize the canvas when the + // browser's size changes. + function windowResized() { + resizeCanvas(windowWidth, windowHeight); + } + +
+class: p5 +params: + - name: event + description: | +

optional resize Event.

+ type: Event + optional: true +chainable: false +--- + + +# windowResized diff --git a/src/content/reference/en/p5 copy/windowWidth.mdx b/src/content/reference/en/p5 copy/windowWidth.mdx new file mode 100644 index 0000000000..26ec5fc2a9 --- /dev/null +++ b/src/content/reference/en/p5 copy/windowWidth.mdx @@ -0,0 +1,43 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L652 +title: windowWidth +module: Environment +submodule: Environment +file: src/core/environment.js +description: > +

A Number variable that stores the width of the browser's + viewport.

+ +

The layout viewport + + is the area within the browser that's available for drawing.

+line: 652 +isConstructor: false +itemtype: property +alt: This example does not render anything. +example: + - |- + +
+ + function setup() { + // Set the canvas' width and height + // using the browser's dimensions. + createCanvas(windowWidth, windowHeight); + + background(200); + + describe('A gray canvas that takes up the entire browser window.'); + } + +
+class: p5 +type: Number +--- + + +# windowWidth diff --git a/src/content/reference/en/p5 copy/year.mdx b/src/content/reference/en/p5 copy/year.mdx new file mode 100644 index 0000000000..04efa83189 --- /dev/null +++ b/src/content/reference/en/p5 copy/year.mdx @@ -0,0 +1,47 @@ +--- +# This file was auto-generated. Please do not edit it manually! +# To make changes, edit the comments in the corresponding source file: +# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L311 +title: year +module: IO +submodule: Time & Date +file: src/utilities/time_date.js +description: | +

Returns the current year as a number such as 1999.

+line: 311 +isConstructor: false +itemtype: method +example: + - |- + +
+ + function setup() { + createCanvas(100, 100); + + background(200); + + // Get the current year. + let y = year(); + + // Style the text. + textAlign(LEFT, CENTER); + textSize(12); + textFont('Courier New'); + + // Display the year. + text(`Current year: ${y}`, 10, 50, 80); + + describe(`The text 'Current year: ${y}' written in black on a gray background.`); + } + +
+class: p5 +return: + description: current year. + type: Integer +chainable: false +--- + + +# year From 3b6ecb11f84898303bb19b34d803c30a20365993 Mon Sep 17 00:00:00 2001 From: Aashish Panthi Date: Mon, 29 Jun 2026 23:53:10 +0545 Subject: [PATCH 16/16] Remove test files and update readme --- .github/actions/translation-tracker/README.md | 4 +- src/content/reference/en/p5 copy/abs.mdx | 61 -- .../reference/en/p5 copy/accelerationX.mdx | 37 - .../reference/en/p5 copy/accelerationY.mdx | 37 - .../reference/en/p5 copy/accelerationZ.mdx | 37 - src/content/reference/en/p5 copy/acos.mdx | 86 -- src/content/reference/en/p5 copy/alpha.mdx | 120 --- .../reference/en/p5 copy/ambientLight.mdx | 241 ------ .../reference/en/p5 copy/ambientMaterial.mdx | 269 ------ .../reference/en/p5 copy/angleMode.mdx | 219 ----- src/content/reference/en/p5 copy/append.mdx | 48 -- .../reference/en/p5 copy/applyMatrix.mdx | 347 -------- src/content/reference/en/p5 copy/arc.mdx | 274 ------ .../reference/en/p5 copy/arrayCopy.mdx | 95 --- src/content/reference/en/p5 copy/asin.mdx | 86 -- src/content/reference/en/p5 copy/atan.mdx | 86 -- src/content/reference/en/p5 copy/atan2.mdx | 106 --- .../reference/en/p5 copy/background.mdx | 336 -------- .../reference/en/p5 copy/baseColorShader.mdx | 178 ---- .../en/p5 copy/baseMaterialShader.mdx | 418 --------- .../reference/en/p5 copy/baseNormalShader.mdx | 211 ----- .../reference/en/p5 copy/baseStrokeShader.mdx | 356 -------- .../reference/en/p5 copy/beginClip.mdx | 208 ----- .../reference/en/p5 copy/beginContour.mdx | 134 --- .../reference/en/p5 copy/beginGeometry.mdx | 281 ------- .../reference/en/p5 copy/beginShape.mdx | 449 ---------- src/content/reference/en/p5 copy/bezier.mdx | 273 ------ .../reference/en/p5 copy/bezierDetail.mdx | 121 --- .../reference/en/p5 copy/bezierPoint.mdx | 162 ---- .../reference/en/p5 copy/bezierTangent.mdx | 155 ---- .../reference/en/p5 copy/bezierVertex.mdx | 337 -------- src/content/reference/en/p5 copy/blend.mdx | 214 ----- .../reference/en/p5 copy/blendMode.mdx | 541 ------------ src/content/reference/en/p5 copy/blue.mdx | 158 ---- src/content/reference/en/p5 copy/boolean.mdx | 157 ---- src/content/reference/en/p5 copy/box.mdx | 186 ---- .../reference/en/p5 copy/brightness.mdx | 168 ---- .../reference/en/p5 copy/buildGeometry.mdx | 263 ------ src/content/reference/en/p5 copy/byte.mdx | 180 ---- src/content/reference/en/p5 copy/camera.mdx | 200 ----- src/content/reference/en/p5 copy/ceil.mdx | 65 -- src/content/reference/en/p5 copy/changed.mdx | 87 -- src/content/reference/en/p5 copy/char.mdx | 152 ---- src/content/reference/en/p5 copy/circle.mdx | 77 -- src/content/reference/en/p5 copy/class.mdx | 19 - src/content/reference/en/p5 copy/clear.mdx | 108 --- .../reference/en/p5 copy/clearDepth.mdx | 113 --- .../reference/en/p5 copy/clearStorage.mdx | 81 -- src/content/reference/en/p5 copy/clip.mdx | 225 ----- src/content/reference/en/p5 copy/color.mdx | 349 -------- .../reference/en/p5 copy/colorMode.mdx | 271 ------ src/content/reference/en/p5 copy/concat.mdx | 54 -- src/content/reference/en/p5 copy/cone.mdx | 265 ------ src/content/reference/en/p5 copy/console.mdx | 99 --- .../reference/en/p5 copy/constants/ADD.mdx | 18 - .../reference/en/p5 copy/constants/ALT.mdx | 18 - .../reference/en/p5 copy/constants/ARROW.mdx | 18 - .../reference/en/p5 copy/constants/AUTO.mdx | 25 - .../reference/en/p5 copy/constants/AXES.mdx | 18 - .../en/p5 copy/constants/BACKSPACE.mdx | 18 - .../en/p5 copy/constants/BASELINE.mdx | 18 - .../reference/en/p5 copy/constants/BEVEL.mdx | 18 - .../reference/en/p5 copy/constants/BEZIER.mdx | 18 - .../reference/en/p5 copy/constants/BLEND.mdx | 18 - .../reference/en/p5 copy/constants/BLUR.mdx | 18 - .../reference/en/p5 copy/constants/BOLD.mdx | 18 - .../en/p5 copy/constants/BOLDITALIC.mdx | 18 - .../reference/en/p5 copy/constants/BOTTOM.mdx | 18 - .../reference/en/p5 copy/constants/BURN.mdx | 18 - .../reference/en/p5 copy/constants/CENTER.mdx | 18 - .../reference/en/p5 copy/constants/CHAR.mdx | 18 - .../reference/en/p5 copy/constants/CHORD.mdx | 18 - .../reference/en/p5 copy/constants/CLAMP.mdx | 18 - .../reference/en/p5 copy/constants/CLOSE.mdx | 18 - .../en/p5 copy/constants/CONTAIN.mdx | 18 - .../en/p5 copy/constants/CONTROL.mdx | 18 - .../reference/en/p5 copy/constants/CORNER.mdx | 18 - .../en/p5 copy/constants/CORNERS.mdx | 18 - .../reference/en/p5 copy/constants/COVER.mdx | 18 - .../reference/en/p5 copy/constants/CROSS.mdx | 18 - .../reference/en/p5 copy/constants/CURVE.mdx | 18 - .../en/p5 copy/constants/DARKEST.mdx | 18 - .../en/p5 copy/constants/DEGREES.mdx | 59 -- .../reference/en/p5 copy/constants/DELETE.mdx | 18 - .../en/p5 copy/constants/DIFFERENCE.mdx | 18 - .../reference/en/p5 copy/constants/DILATE.mdx | 18 - .../reference/en/p5 copy/constants/DODGE.mdx | 18 - .../en/p5 copy/constants/DOWN_ARROW.mdx | 18 - .../reference/en/p5 copy/constants/ENTER.mdx | 18 - .../reference/en/p5 copy/constants/ERODE.mdx | 18 - .../reference/en/p5 copy/constants/ESCAPE.mdx | 18 - .../en/p5 copy/constants/EXCLUSION.mdx | 18 - .../en/p5 copy/constants/FALLBACK.mdx | 18 - .../reference/en/p5 copy/constants/FILL.mdx | 18 - .../reference/en/p5 copy/constants/FLAT.mdx | 18 - .../reference/en/p5 copy/constants/FLOAT.mdx | 18 - .../reference/en/p5 copy/constants/GRAY.mdx | 18 - .../reference/en/p5 copy/constants/GRID.mdx | 18 - .../en/p5 copy/constants/HALF_FLOAT.mdx | 18 - .../en/p5 copy/constants/HALF_PI.mdx | 109 --- .../reference/en/p5 copy/constants/HAND.mdx | 18 - .../en/p5 copy/constants/HARD_LIGHT.mdx | 18 - .../reference/en/p5 copy/constants/HSB.mdx | 24 - .../reference/en/p5 copy/constants/HSL.mdx | 18 - .../reference/en/p5 copy/constants/IMAGE.mdx | 18 - .../en/p5 copy/constants/IMMEDIATE.mdx | 18 - .../reference/en/p5 copy/constants/INVERT.mdx | 18 - .../reference/en/p5 copy/constants/ITALIC.mdx | 18 - .../reference/en/p5 copy/constants/LABEL.mdx | 18 - .../en/p5 copy/constants/LANDSCAPE.mdx | 18 - .../reference/en/p5 copy/constants/LEFT.mdx | 18 - .../en/p5 copy/constants/LEFT_ARROW.mdx | 18 - .../en/p5 copy/constants/LIGHTEST.mdx | 18 - .../reference/en/p5 copy/constants/LINEAR.mdx | 18 - .../reference/en/p5 copy/constants/LINES.mdx | 18 - .../en/p5 copy/constants/LINE_LOOP.mdx | 18 - .../en/p5 copy/constants/LINE_STRIP.mdx | 18 - .../reference/en/p5 copy/constants/MIRROR.mdx | 18 - .../reference/en/p5 copy/constants/MITER.mdx | 18 - .../reference/en/p5 copy/constants/MOVE.mdx | 18 - .../en/p5 copy/constants/MULTIPLY.mdx | 18 - .../en/p5 copy/constants/NEAREST.mdx | 18 - .../reference/en/p5 copy/constants/NORMAL.mdx | 18 - .../reference/en/p5 copy/constants/OPAQUE.mdx | 18 - .../reference/en/p5 copy/constants/OPEN.mdx | 18 - .../reference/en/p5 copy/constants/OPTION.mdx | 18 - .../en/p5 copy/constants/OVERLAY.mdx | 18 - .../reference/en/p5 copy/constants/P2D.mdx | 19 - .../reference/en/p5 copy/constants/PI.mdx | 108 --- .../reference/en/p5 copy/constants/PIE.mdx | 18 - .../reference/en/p5 copy/constants/POINTS.mdx | 18 - .../en/p5 copy/constants/PORTRAIT.mdx | 18 - .../en/p5 copy/constants/POSTERIZE.mdx | 18 - .../en/p5 copy/constants/PROJECT.mdx | 18 - .../en/p5 copy/constants/QUADRATIC.mdx | 18 - .../reference/en/p5 copy/constants/QUADS.mdx | 18 - .../en/p5 copy/constants/QUAD_STRIP.mdx | 18 - .../en/p5 copy/constants/QUARTER_PI.mdx | 109 --- .../en/p5 copy/constants/RADIANS.mdx | 66 -- .../reference/en/p5 copy/constants/RADIUS.mdx | 18 - .../reference/en/p5 copy/constants/REMOVE.mdx | 18 - .../reference/en/p5 copy/constants/REPEAT.mdx | 18 - .../en/p5 copy/constants/REPLACE.mdx | 18 - .../reference/en/p5 copy/constants/RETURN.mdx | 18 - .../reference/en/p5 copy/constants/RGB.mdx | 18 - .../reference/en/p5 copy/constants/RGBA.mdx | 18 - .../reference/en/p5 copy/constants/RIGHT.mdx | 18 - .../en/p5 copy/constants/RIGHT_ARROW.mdx | 18 - .../reference/en/p5 copy/constants/ROUND.mdx | 18 - .../reference/en/p5 copy/constants/SCREEN.mdx | 18 - .../reference/en/p5 copy/constants/SHIFT.mdx | 18 - .../reference/en/p5 copy/constants/SMOOTH.mdx | 18 - .../en/p5 copy/constants/SOFT_LIGHT.mdx | 18 - .../reference/en/p5 copy/constants/SQUARE.mdx | 18 - .../reference/en/p5 copy/constants/STROKE.mdx | 18 - .../en/p5 copy/constants/SUBTRACT.mdx | 18 - .../reference/en/p5 copy/constants/TAB.mdx | 18 - .../reference/en/p5 copy/constants/TAU.mdx | 114 --- .../reference/en/p5 copy/constants/TESS.mdx | 18 - .../reference/en/p5 copy/constants/TEXT.mdx | 18 - .../en/p5 copy/constants/TEXTURE.mdx | 18 - .../en/p5 copy/constants/THRESHOLD.mdx | 18 - .../reference/en/p5 copy/constants/TOP.mdx | 18 - .../en/p5 copy/constants/TRIANGLES.mdx | 18 - .../en/p5 copy/constants/TRIANGLE_FAN.mdx | 18 - .../en/p5 copy/constants/TRIANGLE_STRIP.mdx | 18 - .../reference/en/p5 copy/constants/TWO_PI.mdx | 114 --- .../en/p5 copy/constants/UNSIGNED_BYTE.mdx | 18 - .../en/p5 copy/constants/UNSIGNED_INT.mdx | 18 - .../en/p5 copy/constants/UP_ARROW.mdx | 18 - .../en/p5 copy/constants/VERSION.mdx | 19 - .../reference/en/p5 copy/constants/WAIT.mdx | 18 - .../reference/en/p5 copy/constants/WEBGL.mdx | 91 -- .../reference/en/p5 copy/constants/WEBGL2.mdx | 21 - .../reference/en/p5 copy/constants/WORD.mdx | 18 - .../reference/en/p5 copy/constrain.mdx | 86 -- src/content/reference/en/p5 copy/copy.mdx | 144 ---- src/content/reference/en/p5 copy/cos.mdx | 107 --- src/content/reference/en/p5 copy/createA.mdx | 93 -- .../reference/en/p5 copy/createAudio.mdx | 83 -- .../reference/en/p5 copy/createButton.mdx | 109 --- .../reference/en/p5 copy/createCamera.mdx | 99 --- .../reference/en/p5 copy/createCanvas.mdx | 191 ----- .../reference/en/p5 copy/createCapture.mdx | 189 ----- .../reference/en/p5 copy/createCheckbox.mdx | 131 --- .../en/p5 copy/createColorPicker.mdx | 101 --- .../reference/en/p5 copy/createConvolver.mdx | 78 -- .../reference/en/p5 copy/createDiv.mdx | 72 -- .../reference/en/p5 copy/createElement.mdx | 78 -- .../reference/en/p5 copy/createFileInput.mdx | 138 --- .../en/p5 copy/createFilterShader.mdx | 148 ---- .../en/p5 copy/createFramebuffer.mdx | 208 ----- .../reference/en/p5 copy/createGraphics.mdx | 191 ----- .../reference/en/p5 copy/createImage.mdx | 172 ---- .../reference/en/p5 copy/createImg.mdx | 115 --- .../reference/en/p5 copy/createInput.mdx | 118 --- .../reference/en/p5 copy/createModel.mdx | 193 ----- .../reference/en/p5 copy/createNumberDict.mdx | 57 -- src/content/reference/en/p5 copy/createP.mdx | 54 -- .../reference/en/p5 copy/createRadio.mdx | 223 ----- .../reference/en/p5 copy/createSelect.mdx | 235 ------ .../reference/en/p5 copy/createShader.mdx | 438 ---------- .../reference/en/p5 copy/createSlider.mdx | 162 ---- .../reference/en/p5 copy/createSpan.mdx | 93 -- .../reference/en/p5 copy/createStringDict.mdx | 56 -- .../reference/en/p5 copy/createVector.mdx | 133 --- .../reference/en/p5 copy/createVideo.mdx | 135 --- .../reference/en/p5 copy/createWriter.mdx | 146 ---- src/content/reference/en/p5 copy/cursor.mdx | 139 --- src/content/reference/en/p5 copy/curve.mdx | 272 ------ .../reference/en/p5 copy/curveDetail.mdx | 117 --- .../reference/en/p5 copy/curvePoint.mdx | 160 ---- .../reference/en/p5 copy/curveTangent.mdx | 153 ---- .../reference/en/p5 copy/curveTightness.mdx | 77 -- .../reference/en/p5 copy/curveVertex.mdx | 407 --------- src/content/reference/en/p5 copy/cylinder.mdx | 282 ------- src/content/reference/en/p5 copy/day.mdx | 47 -- .../reference/en/p5 copy/debugMode.mdx | 362 -------- src/content/reference/en/p5 copy/degrees.mdx | 53 -- .../reference/en/p5 copy/deltaTime.mdx | 68 -- src/content/reference/en/p5 copy/describe.mdx | 137 --- .../reference/en/p5 copy/describeElement.mdx | 127 --- .../reference/en/p5 copy/deviceMoved.mdx | 49 -- .../en/p5 copy/deviceOrientation.mdx | 22 - .../reference/en/p5 copy/deviceShaken.mdx | 50 -- .../reference/en/p5 copy/deviceTurned.mdx | 80 -- .../reference/en/p5 copy/directionalLight.mdx | 277 ------ .../en/p5 copy/disableFriendlyErrors.mdx | 55 -- .../reference/en/p5 copy/displayDensity.mdx | 55 -- .../reference/en/p5 copy/displayHeight.mdx | 47 -- .../reference/en/p5 copy/displayWidth.mdx | 47 -- src/content/reference/en/p5 copy/dist.mdx | 121 --- .../reference/en/p5 copy/doubleClicked.mdx | 157 ---- src/content/reference/en/p5 copy/draw.mdx | 129 --- .../reference/en/p5 copy/drawingContext.mdx | 78 -- src/content/reference/en/p5 copy/ellipse.mdx | 164 ---- .../reference/en/p5 copy/ellipseMode.mdx | 113 --- .../reference/en/p5 copy/ellipsoid.mdx | 233 ----- .../reference/en/p5 copy/emissiveMaterial.mdx | 140 ---- src/content/reference/en/p5 copy/endClip.mdx | 43 - .../reference/en/p5 copy/endContour.mdx | 133 --- .../reference/en/p5 copy/endGeometry.mdx | 285 ------- src/content/reference/en/p5 copy/endShape.mdx | 256 ------ src/content/reference/en/p5 copy/erase.mdx | 123 --- .../reference/en/p5 copy/exitPointerLock.mdx | 82 -- src/content/reference/en/p5 copy/exp.mdx | 83 -- src/content/reference/en/p5 copy/fill.mdx | 312 ------- src/content/reference/en/p5 copy/filter.mdx | 330 -------- src/content/reference/en/p5 copy/float.mdx | 116 --- src/content/reference/en/p5 copy/floor.mdx | 57 -- src/content/reference/en/p5 copy/focused.mdx | 50 -- src/content/reference/en/p5 copy/for.mdx | 290 ------- src/content/reference/en/p5 copy/fract.mdx | 55 -- .../reference/en/p5 copy/frameCount.mdx | 73 -- .../reference/en/p5 copy/frameRate.mdx | 107 --- .../reference/en/p5 copy/freeGeometry.mdx | 152 ---- .../reference/en/p5 copy/freqToMidi.mdx | 29 - src/content/reference/en/p5 copy/frustum.mdx | 175 ---- .../reference/en/p5 copy/fullscreen.mdx | 63 -- src/content/reference/en/p5 copy/function.mdx | 19 - src/content/reference/en/p5 copy/get.mdx | 178 ---- .../reference/en/p5 copy/getAudioContext.mdx | 56 -- src/content/reference/en/p5 copy/getItem.mdx | 151 ---- .../reference/en/p5 copy/getOutputVolume.mdx | 25 - .../en/p5 copy/getTargetFrameRate.mdx | 48 -- src/content/reference/en/p5 copy/getURL.mdx | 46 - .../reference/en/p5 copy/getURLParams.mdx | 59 -- .../reference/en/p5 copy/getURLPath.mdx | 58 -- src/content/reference/en/p5 copy/green.mdx | 159 ---- .../reference/en/p5 copy/gridOutput.mdx | 189 ----- src/content/reference/en/p5 copy/height.mdx | 87 -- src/content/reference/en/p5 copy/hex.mdx | 166 ---- src/content/reference/en/p5 copy/hour.mdx | 47 -- src/content/reference/en/p5 copy/httpDo.mdx | 150 ---- src/content/reference/en/p5 copy/httpGet.mdx | 140 ---- src/content/reference/en/p5 copy/httpPost.mdx | 165 ---- src/content/reference/en/p5 copy/hue.mdx | 145 ---- src/content/reference/en/p5 copy/if.mdx | 268 ------ src/content/reference/en/p5 copy/image.mdx | 327 -------- .../reference/en/p5 copy/imageLight.mdx | 86 -- .../reference/en/p5 copy/imageMode.mdx | 129 --- src/content/reference/en/p5 copy/input.mdx | 88 -- src/content/reference/en/p5 copy/int.mdx | 169 ---- .../reference/en/p5 copy/isLooping.mdx | 65 -- src/content/reference/en/p5 copy/join.mdx | 70 -- src/content/reference/en/p5 copy/key.mdx | 106 --- src/content/reference/en/p5 copy/keyCode.mdx | 128 --- .../reference/en/p5 copy/keyIsDown.mdx | 142 ---- .../reference/en/p5 copy/keyIsPressed.mdx | 105 --- .../reference/en/p5 copy/keyPressed.mdx | 192 ----- .../reference/en/p5 copy/keyReleased.mdx | 188 ----- src/content/reference/en/p5 copy/keyTyped.mdx | 170 ---- src/content/reference/en/p5 copy/lerp.mdx | 122 --- .../reference/en/p5 copy/lerpColor.mdx | 96 --- src/content/reference/en/p5 copy/let.mdx | 91 -- .../reference/en/p5 copy/lightFalloff.mdx | 100 --- .../reference/en/p5 copy/lightness.mdx | 168 ---- src/content/reference/en/p5 copy/lights.mdx | 88 -- src/content/reference/en/p5 copy/line.mdx | 194 ----- .../reference/en/p5 copy/linePerspective.mdx | 164 ---- .../reference/en/p5 copy/loadBytes.mdx | 56 -- src/content/reference/en/p5 copy/loadFont.mdx | 171 ---- .../reference/en/p5 copy/loadImage.mdx | 137 --- src/content/reference/en/p5 copy/loadJSON.mdx | 288 ------- .../reference/en/p5 copy/loadModel.mdx | 469 ----------- .../reference/en/p5 copy/loadPixels.mdx | 61 -- .../reference/en/p5 copy/loadShader.mdx | 172 ---- .../reference/en/p5 copy/loadSound.mdx | 78 -- .../reference/en/p5 copy/loadStrings.mdx | 188 ----- .../reference/en/p5 copy/loadTable.mdx | 124 --- src/content/reference/en/p5 copy/loadXML.mdx | 220 ----- src/content/reference/en/p5 copy/log.mdx | 79 -- src/content/reference/en/p5 copy/loop.mdx | 111 --- src/content/reference/en/p5 copy/mag.mdx | 84 -- src/content/reference/en/p5 copy/map.mdx | 119 --- src/content/reference/en/p5 copy/match.mdx | 91 -- src/content/reference/en/p5 copy/matchAll.mdx | 107 --- src/content/reference/en/p5 copy/max.mdx | 104 --- .../reference/en/p5 copy/metalness.mdx | 142 ---- .../reference/en/p5 copy/midiToFreq.mdx | 66 -- src/content/reference/en/p5 copy/millis.mdx | 147 ---- src/content/reference/en/p5 copy/min.mdx | 104 --- src/content/reference/en/p5 copy/minute.mdx | 47 -- src/content/reference/en/p5 copy/model.mdx | 155 ---- src/content/reference/en/p5 copy/month.mdx | 47 -- .../reference/en/p5 copy/mouseButton.mdx | 87 -- .../reference/en/p5 copy/mouseClicked.mdx | 196 ----- .../reference/en/p5 copy/mouseDragged.mdx | 130 --- .../reference/en/p5 copy/mouseIsPressed.mdx | 73 -- .../reference/en/p5 copy/mouseMoved.mdx | 118 --- .../reference/en/p5 copy/mousePressed.mdx | 193 ----- .../reference/en/p5 copy/mouseReleased.mdx | 195 ----- .../reference/en/p5 copy/mouseWheel.mdx | 162 ---- src/content/reference/en/p5 copy/mouseX.mdx | 124 --- src/content/reference/en/p5 copy/mouseY.mdx | 124 --- src/content/reference/en/p5 copy/movedX.mdx | 78 -- src/content/reference/en/p5 copy/movedY.mdx | 78 -- src/content/reference/en/p5 copy/nf.mdx | 159 ---- src/content/reference/en/p5 copy/nfc.mdx | 153 ---- src/content/reference/en/p5 copy/nfp.mdx | 188 ----- src/content/reference/en/p5 copy/nfs.mdx | 176 ---- src/content/reference/en/p5 copy/noCanvas.mdx | 36 - src/content/reference/en/p5 copy/noCursor.mdx | 38 - .../reference/en/p5 copy/noDebugMode.mdx | 54 -- src/content/reference/en/p5 copy/noErase.mdx | 55 -- src/content/reference/en/p5 copy/noFill.mdx | 73 -- src/content/reference/en/p5 copy/noLights.mdx | 79 -- src/content/reference/en/p5 copy/noLoop.mdx | 139 --- src/content/reference/en/p5 copy/noSmooth.mdx | 92 -- src/content/reference/en/p5 copy/noStroke.mdx | 71 -- src/content/reference/en/p5 copy/noTint.mdx | 51 -- src/content/reference/en/p5 copy/noise.mdx | 282 ------- .../reference/en/p5 copy/noiseDetail.mdx | 100 --- .../reference/en/p5 copy/noiseSeed.mdx | 68 -- src/content/reference/en/p5 copy/norm.mdx | 69 -- src/content/reference/en/p5 copy/normal.mdx | 250 ------ .../reference/en/p5 copy/normalMaterial.mdx | 55 -- .../reference/en/p5 copy/orbitControl.mdx | 203 ----- src/content/reference/en/p5 copy/ortho.mdx | 168 ---- .../reference/en/p5 copy/outputVolume.mdx | 51 -- .../reference/en/p5 copy/p5.Camera.mdx | 659 --------------- src/content/reference/en/p5 copy/p5.Color.mdx | 116 --- .../reference/en/p5 copy/p5.Element.mdx | 545 ------------ src/content/reference/en/p5 copy/p5.File.mdx | 153 ---- src/content/reference/en/p5 copy/p5.Font.mdx | 146 ---- .../reference/en/p5 copy/p5.Framebuffer.mdx | 443 ---------- .../reference/en/p5 copy/p5.Geometry.mdx | 793 ------------------ .../reference/en/p5 copy/p5.Graphics.mdx | 261 ------ src/content/reference/en/p5 copy/p5.Image.mdx | 519 ------------ .../reference/en/p5 copy/p5.MediaElement.mdx | 258 ------ .../reference/en/p5 copy/p5.NumberDict.mdx | 63 -- .../reference/en/p5 copy/p5.PrintWriter.mdx | 35 - .../reference/en/p5 copy/p5.Renderer.mdx | 34 - .../reference/en/p5 copy/p5.Shader.mdx | 433 ---------- .../reference/en/p5 copy/p5.StringDict.mdx | 15 - src/content/reference/en/p5 copy/p5.Table.mdx | 213 ----- .../reference/en/p5 copy/p5.TableRow.mdx | 66 -- .../reference/en/p5 copy/p5.TypedDict.mdx | 66 -- .../reference/en/p5 copy/p5.Vector.mdx | 673 --------------- src/content/reference/en/p5 copy/p5.XML.mdx | 321 ------- src/content/reference/en/p5 copy/p5.mdx | 51 -- .../reference/en/p5 copy/pAccelerationX.mdx | 21 - .../reference/en/p5 copy/pAccelerationY.mdx | 21 - .../reference/en/p5 copy/pAccelerationZ.mdx | 21 - .../reference/en/p5 copy/pRotationX.mdx | 63 -- .../reference/en/p5 copy/pRotationY.mdx | 62 -- .../reference/en/p5 copy/pRotationZ.mdx | 58 -- .../reference/en/p5 copy/paletteLerp.mdx | 66 -- src/content/reference/en/p5 copy/panorama.mdx | 76 -- .../reference/en/p5 copy/perspective.mdx | 194 ----- .../reference/en/p5 copy/pixelDensity.mdx | 90 -- src/content/reference/en/p5 copy/pixels.mdx | 173 ---- src/content/reference/en/p5 copy/plane.mdx | 152 ---- src/content/reference/en/p5 copy/pmouseX.mdx | 88 -- src/content/reference/en/p5 copy/pmouseY.mdx | 88 -- src/content/reference/en/p5 copy/point.mdx | 229 ----- .../reference/en/p5 copy/pointLight.mdx | 329 -------- src/content/reference/en/p5 copy/pop.mdx | 20 - src/content/reference/en/p5 copy/pow.mdx | 67 -- src/content/reference/en/p5 copy/preload.mdx | 70 -- src/content/reference/en/p5 copy/print.mdx | 55 -- src/content/reference/en/p5 copy/push.mdx | 20 - .../reference/en/p5 copy/pwinMouseX.mdx | 99 --- .../reference/en/p5 copy/pwinMouseY.mdx | 99 --- src/content/reference/en/p5 copy/quad.mdx | 233 ----- .../reference/en/p5 copy/quadraticVertex.mdx | 303 ------- src/content/reference/en/p5 copy/radians.mdx | 53 -- src/content/reference/en/p5 copy/random.mdx | 48 -- .../reference/en/p5 copy/randomGaussian.mdx | 104 --- .../reference/en/p5 copy/randomSeed.mdx | 71 -- src/content/reference/en/p5 copy/rect.mdx | 209 ----- src/content/reference/en/p5 copy/rectMode.mdx | 142 ---- src/content/reference/en/p5 copy/red.mdx | 158 ---- src/content/reference/en/p5 copy/redraw.mdx | 117 --- src/content/reference/en/p5 copy/remove.mdx | 57 -- .../reference/en/p5 copy/removeElements.mdx | 85 -- .../reference/en/p5 copy/removeItem.mdx | 97 --- .../en/p5 copy/requestPointerLock.mdx | 85 -- .../reference/en/p5 copy/resetMatrix.mdx | 52 -- .../reference/en/p5 copy/resetShader.mdx | 95 --- .../reference/en/p5 copy/resizeCanvas.mdx | 133 --- src/content/reference/en/p5 copy/reverse.mdx | 43 - src/content/reference/en/p5 copy/rotate.mdx | 226 ----- src/content/reference/en/p5 copy/rotateX.mdx | 161 ---- src/content/reference/en/p5 copy/rotateY.mdx | 161 ---- src/content/reference/en/p5 copy/rotateZ.mdx | 161 ---- .../reference/en/p5 copy/rotationX.mdx | 45 - .../reference/en/p5 copy/rotationY.mdx | 45 - .../reference/en/p5 copy/rotationZ.mdx | 47 -- src/content/reference/en/p5 copy/round.mdx | 88 -- .../reference/en/p5 copy/sampleRate.mdx | 26 - .../reference/en/p5 copy/saturation.mdx | 201 ----- src/content/reference/en/p5 copy/save.mdx | 140 ---- .../reference/en/p5 copy/saveCanvas.mdx | 166 ---- .../reference/en/p5 copy/saveFrames.mdx | 175 ---- src/content/reference/en/p5 copy/saveGif.mdx | 119 --- src/content/reference/en/p5 copy/saveJSON.mdx | 170 ---- .../reference/en/p5 copy/saveSound.mdx | 35 - .../reference/en/p5 copy/saveStrings.mdx | 185 ---- .../reference/en/p5 copy/saveTable.mdx | 70 -- src/content/reference/en/p5 copy/scale.mdx | 231 ----- src/content/reference/en/p5 copy/second.mdx | 47 -- src/content/reference/en/p5 copy/select.mdx | 113 --- .../reference/en/p5 copy/selectAll.mdx | 121 --- src/content/reference/en/p5 copy/set.mdx | 157 ---- .../reference/en/p5 copy/setAttributes.mdx | 163 ---- src/content/reference/en/p5 copy/setBPM.mdx | 29 - .../reference/en/p5 copy/setCamera.mdx | 81 -- .../reference/en/p5 copy/setMoveThreshold.mdx | 59 -- .../en/p5 copy/setShakeThreshold.mdx | 59 -- src/content/reference/en/p5 copy/setup.mdx | 111 --- src/content/reference/en/p5 copy/shader.mdx | 244 ------ src/content/reference/en/p5 copy/shearX.mdx | 105 --- src/content/reference/en/p5 copy/shearY.mdx | 105 --- .../reference/en/p5 copy/shininess.mdx | 86 -- src/content/reference/en/p5 copy/shorten.mdx | 44 - src/content/reference/en/p5 copy/shuffle.mdx | 132 --- src/content/reference/en/p5 copy/sin.mdx | 107 --- src/content/reference/en/p5 copy/smooth.mdx | 94 --- src/content/reference/en/p5 copy/sort.mdx | 63 -- .../reference/en/p5 copy/soundFormats.mdx | 51 -- src/content/reference/en/p5 copy/soundOut.mdx | 26 - .../reference/en/p5 copy/specularColor.mdx | 308 ------- .../reference/en/p5 copy/specularMaterial.mdx | 311 ------- src/content/reference/en/p5 copy/sphere.mdx | 165 ---- src/content/reference/en/p5 copy/splice.mdx | 58 -- src/content/reference/en/p5 copy/split.mdx | 87 -- .../reference/en/p5 copy/splitTokens.mdx | 180 ---- .../reference/en/p5 copy/spotLight.mdx | 398 --------- src/content/reference/en/p5 copy/sq.mdx | 83 -- src/content/reference/en/p5 copy/sqrt.mdx | 84 -- src/content/reference/en/p5 copy/square.mdx | 163 ---- .../reference/en/p5 copy/storeItem.mdx | 149 ---- src/content/reference/en/p5 copy/str.mdx | 135 --- src/content/reference/en/p5 copy/stroke.mdx | 311 ------- .../reference/en/p5 copy/strokeCap.mdx | 67 -- .../reference/en/p5 copy/strokeJoin.mdx | 114 --- .../reference/en/p5 copy/strokeWeight.mdx | 77 -- src/content/reference/en/p5 copy/subset.mdx | 59 -- src/content/reference/en/p5 copy/tan.mdx | 66 -- src/content/reference/en/p5 copy/text.mdx | 96 --- .../reference/en/p5 copy/textAlign.mdx | 135 --- .../reference/en/p5 copy/textAscent.mdx | 71 -- .../reference/en/p5 copy/textDescent.mdx | 71 -- src/content/reference/en/p5 copy/textFont.mdx | 127 --- .../reference/en/p5 copy/textLeading.mdx | 63 -- .../reference/en/p5 copy/textOutput.mdx | 186 ---- src/content/reference/en/p5 copy/textSize.mdx | 65 -- .../reference/en/p5 copy/textStyle.mdx | 79 -- .../reference/en/p5 copy/textWidth.mdx | 83 -- src/content/reference/en/p5 copy/textWrap.mdx | 111 --- src/content/reference/en/p5 copy/texture.mdx | 207 ----- .../reference/en/p5 copy/textureMode.mdx | 254 ------ .../reference/en/p5 copy/textureWrap.mdx | 370 -------- src/content/reference/en/p5 copy/tint.mdx | 201 ----- src/content/reference/en/p5 copy/torus.mdx | 200 ----- .../reference/en/p5 copy/touchEnded.mdx | 196 ----- .../reference/en/p5 copy/touchMoved.mdx | 198 ----- .../reference/en/p5 copy/touchStarted.mdx | 197 ----- src/content/reference/en/p5 copy/touches.mdx | 102 --- .../reference/en/p5 copy/translate.mdx | 241 ------ src/content/reference/en/p5 copy/triangle.mdx | 104 --- src/content/reference/en/p5 copy/trim.mdx | 113 --- src/content/reference/en/p5 copy/turnAxis.mdx | 54 -- .../reference/en/p5 copy/types/Array.mdx | 269 ------ .../reference/en/p5 copy/types/Boolean.mdx | 273 ------ .../reference/en/p5 copy/types/Number.mdx | 201 ----- .../reference/en/p5 copy/types/Object.mdx | 91 -- .../reference/en/p5 copy/types/String.mdx | 153 ---- src/content/reference/en/p5 copy/unchar.mdx | 114 --- src/content/reference/en/p5 copy/unhex.mdx | 121 --- .../reference/en/p5 copy/updatePixels.mdx | 94 --- .../reference/en/p5 copy/userStartAudio.mdx | 99 --- src/content/reference/en/p5 copy/vertex.mdx | 242 ------ .../reference/en/p5 copy/webglVersion.mdx | 105 --- src/content/reference/en/p5 copy/while.mdx | 161 ---- src/content/reference/en/p5 copy/width.mdx | 87 -- .../reference/en/p5 copy/winMouseX.mdx | 61 -- .../reference/en/p5 copy/winMouseY.mdx | 61 -- .../reference/en/p5 copy/windowHeight.mdx | 43 - .../reference/en/p5 copy/windowResized.mdx | 64 -- .../reference/en/p5 copy/windowWidth.mdx | 43 - src/content/reference/en/p5 copy/year.mdx | 47 -- 523 files changed, 2 insertions(+), 60137 deletions(-) delete mode 100644 src/content/reference/en/p5 copy/abs.mdx delete mode 100644 src/content/reference/en/p5 copy/accelerationX.mdx delete mode 100644 src/content/reference/en/p5 copy/accelerationY.mdx delete mode 100644 src/content/reference/en/p5 copy/accelerationZ.mdx delete mode 100644 src/content/reference/en/p5 copy/acos.mdx delete mode 100644 src/content/reference/en/p5 copy/alpha.mdx delete mode 100644 src/content/reference/en/p5 copy/ambientLight.mdx delete mode 100644 src/content/reference/en/p5 copy/ambientMaterial.mdx delete mode 100644 src/content/reference/en/p5 copy/angleMode.mdx delete mode 100644 src/content/reference/en/p5 copy/append.mdx delete mode 100644 src/content/reference/en/p5 copy/applyMatrix.mdx delete mode 100644 src/content/reference/en/p5 copy/arc.mdx delete mode 100644 src/content/reference/en/p5 copy/arrayCopy.mdx delete mode 100644 src/content/reference/en/p5 copy/asin.mdx delete mode 100644 src/content/reference/en/p5 copy/atan.mdx delete mode 100644 src/content/reference/en/p5 copy/atan2.mdx delete mode 100644 src/content/reference/en/p5 copy/background.mdx delete mode 100644 src/content/reference/en/p5 copy/baseColorShader.mdx delete mode 100644 src/content/reference/en/p5 copy/baseMaterialShader.mdx delete mode 100644 src/content/reference/en/p5 copy/baseNormalShader.mdx delete mode 100644 src/content/reference/en/p5 copy/baseStrokeShader.mdx delete mode 100644 src/content/reference/en/p5 copy/beginClip.mdx delete mode 100644 src/content/reference/en/p5 copy/beginContour.mdx delete mode 100644 src/content/reference/en/p5 copy/beginGeometry.mdx delete mode 100644 src/content/reference/en/p5 copy/beginShape.mdx delete mode 100644 src/content/reference/en/p5 copy/bezier.mdx delete mode 100644 src/content/reference/en/p5 copy/bezierDetail.mdx delete mode 100644 src/content/reference/en/p5 copy/bezierPoint.mdx delete mode 100644 src/content/reference/en/p5 copy/bezierTangent.mdx delete mode 100644 src/content/reference/en/p5 copy/bezierVertex.mdx delete mode 100644 src/content/reference/en/p5 copy/blend.mdx delete mode 100644 src/content/reference/en/p5 copy/blendMode.mdx delete mode 100644 src/content/reference/en/p5 copy/blue.mdx delete mode 100644 src/content/reference/en/p5 copy/boolean.mdx delete mode 100644 src/content/reference/en/p5 copy/box.mdx delete mode 100644 src/content/reference/en/p5 copy/brightness.mdx delete mode 100644 src/content/reference/en/p5 copy/buildGeometry.mdx delete mode 100644 src/content/reference/en/p5 copy/byte.mdx delete mode 100644 src/content/reference/en/p5 copy/camera.mdx delete mode 100644 src/content/reference/en/p5 copy/ceil.mdx delete mode 100644 src/content/reference/en/p5 copy/changed.mdx delete mode 100644 src/content/reference/en/p5 copy/char.mdx delete mode 100644 src/content/reference/en/p5 copy/circle.mdx delete mode 100644 src/content/reference/en/p5 copy/class.mdx delete mode 100644 src/content/reference/en/p5 copy/clear.mdx delete mode 100644 src/content/reference/en/p5 copy/clearDepth.mdx delete mode 100644 src/content/reference/en/p5 copy/clearStorage.mdx delete mode 100644 src/content/reference/en/p5 copy/clip.mdx delete mode 100644 src/content/reference/en/p5 copy/color.mdx delete mode 100644 src/content/reference/en/p5 copy/colorMode.mdx delete mode 100644 src/content/reference/en/p5 copy/concat.mdx delete mode 100644 src/content/reference/en/p5 copy/cone.mdx delete mode 100644 src/content/reference/en/p5 copy/console.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/ADD.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/ALT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/ARROW.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/AUTO.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/AXES.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/BACKSPACE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/BASELINE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/BEVEL.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/BEZIER.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/BLEND.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/BLUR.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/BOLD.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/BOLDITALIC.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/BOTTOM.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/BURN.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/CENTER.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/CHAR.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/CHORD.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/CLAMP.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/CLOSE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/CONTAIN.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/CONTROL.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/CORNER.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/CORNERS.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/COVER.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/CROSS.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/CURVE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/DARKEST.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/DEGREES.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/DELETE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/DIFFERENCE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/DILATE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/DODGE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/DOWN_ARROW.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/ENTER.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/ERODE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/ESCAPE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/EXCLUSION.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/FALLBACK.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/FILL.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/FLAT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/FLOAT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/GRAY.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/GRID.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/HALF_FLOAT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/HALF_PI.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/HAND.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/HARD_LIGHT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/HSB.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/HSL.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/IMAGE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/IMMEDIATE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/INVERT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/ITALIC.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/LABEL.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/LANDSCAPE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/LEFT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/LEFT_ARROW.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/LIGHTEST.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/LINEAR.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/LINES.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/LINE_LOOP.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/LINE_STRIP.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/MIRROR.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/MITER.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/MOVE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/MULTIPLY.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/NEAREST.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/NORMAL.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/OPAQUE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/OPEN.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/OPTION.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/OVERLAY.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/P2D.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/PI.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/PIE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/POINTS.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/PORTRAIT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/POSTERIZE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/PROJECT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/QUADRATIC.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/QUADS.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/QUAD_STRIP.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/QUARTER_PI.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/RADIANS.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/RADIUS.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/REMOVE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/REPEAT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/REPLACE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/RETURN.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/RGB.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/RGBA.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/RIGHT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/RIGHT_ARROW.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/ROUND.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/SCREEN.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/SHIFT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/SMOOTH.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/SOFT_LIGHT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/SQUARE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/STROKE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/SUBTRACT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/TAB.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/TAU.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/TESS.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/TEXT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/TEXTURE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/THRESHOLD.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/TOP.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/TRIANGLES.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/TRIANGLE_FAN.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/TRIANGLE_STRIP.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/TWO_PI.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/UNSIGNED_BYTE.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/UNSIGNED_INT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/UP_ARROW.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/VERSION.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/WAIT.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/WEBGL.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/WEBGL2.mdx delete mode 100644 src/content/reference/en/p5 copy/constants/WORD.mdx delete mode 100644 src/content/reference/en/p5 copy/constrain.mdx delete mode 100644 src/content/reference/en/p5 copy/copy.mdx delete mode 100644 src/content/reference/en/p5 copy/cos.mdx delete mode 100644 src/content/reference/en/p5 copy/createA.mdx delete mode 100644 src/content/reference/en/p5 copy/createAudio.mdx delete mode 100644 src/content/reference/en/p5 copy/createButton.mdx delete mode 100644 src/content/reference/en/p5 copy/createCamera.mdx delete mode 100644 src/content/reference/en/p5 copy/createCanvas.mdx delete mode 100644 src/content/reference/en/p5 copy/createCapture.mdx delete mode 100644 src/content/reference/en/p5 copy/createCheckbox.mdx delete mode 100644 src/content/reference/en/p5 copy/createColorPicker.mdx delete mode 100644 src/content/reference/en/p5 copy/createConvolver.mdx delete mode 100644 src/content/reference/en/p5 copy/createDiv.mdx delete mode 100644 src/content/reference/en/p5 copy/createElement.mdx delete mode 100644 src/content/reference/en/p5 copy/createFileInput.mdx delete mode 100644 src/content/reference/en/p5 copy/createFilterShader.mdx delete mode 100644 src/content/reference/en/p5 copy/createFramebuffer.mdx delete mode 100644 src/content/reference/en/p5 copy/createGraphics.mdx delete mode 100644 src/content/reference/en/p5 copy/createImage.mdx delete mode 100644 src/content/reference/en/p5 copy/createImg.mdx delete mode 100644 src/content/reference/en/p5 copy/createInput.mdx delete mode 100644 src/content/reference/en/p5 copy/createModel.mdx delete mode 100644 src/content/reference/en/p5 copy/createNumberDict.mdx delete mode 100644 src/content/reference/en/p5 copy/createP.mdx delete mode 100644 src/content/reference/en/p5 copy/createRadio.mdx delete mode 100644 src/content/reference/en/p5 copy/createSelect.mdx delete mode 100644 src/content/reference/en/p5 copy/createShader.mdx delete mode 100644 src/content/reference/en/p5 copy/createSlider.mdx delete mode 100644 src/content/reference/en/p5 copy/createSpan.mdx delete mode 100644 src/content/reference/en/p5 copy/createStringDict.mdx delete mode 100644 src/content/reference/en/p5 copy/createVector.mdx delete mode 100644 src/content/reference/en/p5 copy/createVideo.mdx delete mode 100644 src/content/reference/en/p5 copy/createWriter.mdx delete mode 100644 src/content/reference/en/p5 copy/cursor.mdx delete mode 100644 src/content/reference/en/p5 copy/curve.mdx delete mode 100644 src/content/reference/en/p5 copy/curveDetail.mdx delete mode 100644 src/content/reference/en/p5 copy/curvePoint.mdx delete mode 100644 src/content/reference/en/p5 copy/curveTangent.mdx delete mode 100644 src/content/reference/en/p5 copy/curveTightness.mdx delete mode 100644 src/content/reference/en/p5 copy/curveVertex.mdx delete mode 100644 src/content/reference/en/p5 copy/cylinder.mdx delete mode 100644 src/content/reference/en/p5 copy/day.mdx delete mode 100644 src/content/reference/en/p5 copy/debugMode.mdx delete mode 100644 src/content/reference/en/p5 copy/degrees.mdx delete mode 100644 src/content/reference/en/p5 copy/deltaTime.mdx delete mode 100644 src/content/reference/en/p5 copy/describe.mdx delete mode 100644 src/content/reference/en/p5 copy/describeElement.mdx delete mode 100644 src/content/reference/en/p5 copy/deviceMoved.mdx delete mode 100644 src/content/reference/en/p5 copy/deviceOrientation.mdx delete mode 100644 src/content/reference/en/p5 copy/deviceShaken.mdx delete mode 100644 src/content/reference/en/p5 copy/deviceTurned.mdx delete mode 100644 src/content/reference/en/p5 copy/directionalLight.mdx delete mode 100644 src/content/reference/en/p5 copy/disableFriendlyErrors.mdx delete mode 100644 src/content/reference/en/p5 copy/displayDensity.mdx delete mode 100644 src/content/reference/en/p5 copy/displayHeight.mdx delete mode 100644 src/content/reference/en/p5 copy/displayWidth.mdx delete mode 100644 src/content/reference/en/p5 copy/dist.mdx delete mode 100644 src/content/reference/en/p5 copy/doubleClicked.mdx delete mode 100644 src/content/reference/en/p5 copy/draw.mdx delete mode 100644 src/content/reference/en/p5 copy/drawingContext.mdx delete mode 100644 src/content/reference/en/p5 copy/ellipse.mdx delete mode 100644 src/content/reference/en/p5 copy/ellipseMode.mdx delete mode 100644 src/content/reference/en/p5 copy/ellipsoid.mdx delete mode 100644 src/content/reference/en/p5 copy/emissiveMaterial.mdx delete mode 100644 src/content/reference/en/p5 copy/endClip.mdx delete mode 100644 src/content/reference/en/p5 copy/endContour.mdx delete mode 100644 src/content/reference/en/p5 copy/endGeometry.mdx delete mode 100644 src/content/reference/en/p5 copy/endShape.mdx delete mode 100644 src/content/reference/en/p5 copy/erase.mdx delete mode 100644 src/content/reference/en/p5 copy/exitPointerLock.mdx delete mode 100644 src/content/reference/en/p5 copy/exp.mdx delete mode 100644 src/content/reference/en/p5 copy/fill.mdx delete mode 100644 src/content/reference/en/p5 copy/filter.mdx delete mode 100644 src/content/reference/en/p5 copy/float.mdx delete mode 100644 src/content/reference/en/p5 copy/floor.mdx delete mode 100644 src/content/reference/en/p5 copy/focused.mdx delete mode 100644 src/content/reference/en/p5 copy/for.mdx delete mode 100644 src/content/reference/en/p5 copy/fract.mdx delete mode 100644 src/content/reference/en/p5 copy/frameCount.mdx delete mode 100644 src/content/reference/en/p5 copy/frameRate.mdx delete mode 100644 src/content/reference/en/p5 copy/freeGeometry.mdx delete mode 100644 src/content/reference/en/p5 copy/freqToMidi.mdx delete mode 100644 src/content/reference/en/p5 copy/frustum.mdx delete mode 100644 src/content/reference/en/p5 copy/fullscreen.mdx delete mode 100644 src/content/reference/en/p5 copy/function.mdx delete mode 100644 src/content/reference/en/p5 copy/get.mdx delete mode 100644 src/content/reference/en/p5 copy/getAudioContext.mdx delete mode 100644 src/content/reference/en/p5 copy/getItem.mdx delete mode 100644 src/content/reference/en/p5 copy/getOutputVolume.mdx delete mode 100644 src/content/reference/en/p5 copy/getTargetFrameRate.mdx delete mode 100644 src/content/reference/en/p5 copy/getURL.mdx delete mode 100644 src/content/reference/en/p5 copy/getURLParams.mdx delete mode 100644 src/content/reference/en/p5 copy/getURLPath.mdx delete mode 100644 src/content/reference/en/p5 copy/green.mdx delete mode 100644 src/content/reference/en/p5 copy/gridOutput.mdx delete mode 100644 src/content/reference/en/p5 copy/height.mdx delete mode 100644 src/content/reference/en/p5 copy/hex.mdx delete mode 100644 src/content/reference/en/p5 copy/hour.mdx delete mode 100644 src/content/reference/en/p5 copy/httpDo.mdx delete mode 100644 src/content/reference/en/p5 copy/httpGet.mdx delete mode 100644 src/content/reference/en/p5 copy/httpPost.mdx delete mode 100644 src/content/reference/en/p5 copy/hue.mdx delete mode 100644 src/content/reference/en/p5 copy/if.mdx delete mode 100644 src/content/reference/en/p5 copy/image.mdx delete mode 100644 src/content/reference/en/p5 copy/imageLight.mdx delete mode 100644 src/content/reference/en/p5 copy/imageMode.mdx delete mode 100644 src/content/reference/en/p5 copy/input.mdx delete mode 100644 src/content/reference/en/p5 copy/int.mdx delete mode 100644 src/content/reference/en/p5 copy/isLooping.mdx delete mode 100644 src/content/reference/en/p5 copy/join.mdx delete mode 100644 src/content/reference/en/p5 copy/key.mdx delete mode 100644 src/content/reference/en/p5 copy/keyCode.mdx delete mode 100644 src/content/reference/en/p5 copy/keyIsDown.mdx delete mode 100644 src/content/reference/en/p5 copy/keyIsPressed.mdx delete mode 100644 src/content/reference/en/p5 copy/keyPressed.mdx delete mode 100644 src/content/reference/en/p5 copy/keyReleased.mdx delete mode 100644 src/content/reference/en/p5 copy/keyTyped.mdx delete mode 100644 src/content/reference/en/p5 copy/lerp.mdx delete mode 100644 src/content/reference/en/p5 copy/lerpColor.mdx delete mode 100644 src/content/reference/en/p5 copy/let.mdx delete mode 100644 src/content/reference/en/p5 copy/lightFalloff.mdx delete mode 100644 src/content/reference/en/p5 copy/lightness.mdx delete mode 100644 src/content/reference/en/p5 copy/lights.mdx delete mode 100644 src/content/reference/en/p5 copy/line.mdx delete mode 100644 src/content/reference/en/p5 copy/linePerspective.mdx delete mode 100644 src/content/reference/en/p5 copy/loadBytes.mdx delete mode 100644 src/content/reference/en/p5 copy/loadFont.mdx delete mode 100644 src/content/reference/en/p5 copy/loadImage.mdx delete mode 100644 src/content/reference/en/p5 copy/loadJSON.mdx delete mode 100644 src/content/reference/en/p5 copy/loadModel.mdx delete mode 100644 src/content/reference/en/p5 copy/loadPixels.mdx delete mode 100644 src/content/reference/en/p5 copy/loadShader.mdx delete mode 100644 src/content/reference/en/p5 copy/loadSound.mdx delete mode 100644 src/content/reference/en/p5 copy/loadStrings.mdx delete mode 100644 src/content/reference/en/p5 copy/loadTable.mdx delete mode 100644 src/content/reference/en/p5 copy/loadXML.mdx delete mode 100644 src/content/reference/en/p5 copy/log.mdx delete mode 100644 src/content/reference/en/p5 copy/loop.mdx delete mode 100644 src/content/reference/en/p5 copy/mag.mdx delete mode 100644 src/content/reference/en/p5 copy/map.mdx delete mode 100644 src/content/reference/en/p5 copy/match.mdx delete mode 100644 src/content/reference/en/p5 copy/matchAll.mdx delete mode 100644 src/content/reference/en/p5 copy/max.mdx delete mode 100644 src/content/reference/en/p5 copy/metalness.mdx delete mode 100644 src/content/reference/en/p5 copy/midiToFreq.mdx delete mode 100644 src/content/reference/en/p5 copy/millis.mdx delete mode 100644 src/content/reference/en/p5 copy/min.mdx delete mode 100644 src/content/reference/en/p5 copy/minute.mdx delete mode 100644 src/content/reference/en/p5 copy/model.mdx delete mode 100644 src/content/reference/en/p5 copy/month.mdx delete mode 100644 src/content/reference/en/p5 copy/mouseButton.mdx delete mode 100644 src/content/reference/en/p5 copy/mouseClicked.mdx delete mode 100644 src/content/reference/en/p5 copy/mouseDragged.mdx delete mode 100644 src/content/reference/en/p5 copy/mouseIsPressed.mdx delete mode 100644 src/content/reference/en/p5 copy/mouseMoved.mdx delete mode 100644 src/content/reference/en/p5 copy/mousePressed.mdx delete mode 100644 src/content/reference/en/p5 copy/mouseReleased.mdx delete mode 100644 src/content/reference/en/p5 copy/mouseWheel.mdx delete mode 100644 src/content/reference/en/p5 copy/mouseX.mdx delete mode 100644 src/content/reference/en/p5 copy/mouseY.mdx delete mode 100644 src/content/reference/en/p5 copy/movedX.mdx delete mode 100644 src/content/reference/en/p5 copy/movedY.mdx delete mode 100644 src/content/reference/en/p5 copy/nf.mdx delete mode 100644 src/content/reference/en/p5 copy/nfc.mdx delete mode 100644 src/content/reference/en/p5 copy/nfp.mdx delete mode 100644 src/content/reference/en/p5 copy/nfs.mdx delete mode 100644 src/content/reference/en/p5 copy/noCanvas.mdx delete mode 100644 src/content/reference/en/p5 copy/noCursor.mdx delete mode 100644 src/content/reference/en/p5 copy/noDebugMode.mdx delete mode 100644 src/content/reference/en/p5 copy/noErase.mdx delete mode 100644 src/content/reference/en/p5 copy/noFill.mdx delete mode 100644 src/content/reference/en/p5 copy/noLights.mdx delete mode 100644 src/content/reference/en/p5 copy/noLoop.mdx delete mode 100644 src/content/reference/en/p5 copy/noSmooth.mdx delete mode 100644 src/content/reference/en/p5 copy/noStroke.mdx delete mode 100644 src/content/reference/en/p5 copy/noTint.mdx delete mode 100644 src/content/reference/en/p5 copy/noise.mdx delete mode 100644 src/content/reference/en/p5 copy/noiseDetail.mdx delete mode 100644 src/content/reference/en/p5 copy/noiseSeed.mdx delete mode 100644 src/content/reference/en/p5 copy/norm.mdx delete mode 100644 src/content/reference/en/p5 copy/normal.mdx delete mode 100644 src/content/reference/en/p5 copy/normalMaterial.mdx delete mode 100644 src/content/reference/en/p5 copy/orbitControl.mdx delete mode 100644 src/content/reference/en/p5 copy/ortho.mdx delete mode 100644 src/content/reference/en/p5 copy/outputVolume.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Camera.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Color.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Element.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.File.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Font.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Framebuffer.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Geometry.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Graphics.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Image.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.MediaElement.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.NumberDict.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.PrintWriter.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Renderer.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Shader.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.StringDict.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Table.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.TableRow.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.TypedDict.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.Vector.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.XML.mdx delete mode 100644 src/content/reference/en/p5 copy/p5.mdx delete mode 100644 src/content/reference/en/p5 copy/pAccelerationX.mdx delete mode 100644 src/content/reference/en/p5 copy/pAccelerationY.mdx delete mode 100644 src/content/reference/en/p5 copy/pAccelerationZ.mdx delete mode 100644 src/content/reference/en/p5 copy/pRotationX.mdx delete mode 100644 src/content/reference/en/p5 copy/pRotationY.mdx delete mode 100644 src/content/reference/en/p5 copy/pRotationZ.mdx delete mode 100644 src/content/reference/en/p5 copy/paletteLerp.mdx delete mode 100644 src/content/reference/en/p5 copy/panorama.mdx delete mode 100644 src/content/reference/en/p5 copy/perspective.mdx delete mode 100644 src/content/reference/en/p5 copy/pixelDensity.mdx delete mode 100644 src/content/reference/en/p5 copy/pixels.mdx delete mode 100644 src/content/reference/en/p5 copy/plane.mdx delete mode 100644 src/content/reference/en/p5 copy/pmouseX.mdx delete mode 100644 src/content/reference/en/p5 copy/pmouseY.mdx delete mode 100644 src/content/reference/en/p5 copy/point.mdx delete mode 100644 src/content/reference/en/p5 copy/pointLight.mdx delete mode 100644 src/content/reference/en/p5 copy/pop.mdx delete mode 100644 src/content/reference/en/p5 copy/pow.mdx delete mode 100644 src/content/reference/en/p5 copy/preload.mdx delete mode 100644 src/content/reference/en/p5 copy/print.mdx delete mode 100644 src/content/reference/en/p5 copy/push.mdx delete mode 100644 src/content/reference/en/p5 copy/pwinMouseX.mdx delete mode 100644 src/content/reference/en/p5 copy/pwinMouseY.mdx delete mode 100644 src/content/reference/en/p5 copy/quad.mdx delete mode 100644 src/content/reference/en/p5 copy/quadraticVertex.mdx delete mode 100644 src/content/reference/en/p5 copy/radians.mdx delete mode 100644 src/content/reference/en/p5 copy/random.mdx delete mode 100644 src/content/reference/en/p5 copy/randomGaussian.mdx delete mode 100644 src/content/reference/en/p5 copy/randomSeed.mdx delete mode 100644 src/content/reference/en/p5 copy/rect.mdx delete mode 100644 src/content/reference/en/p5 copy/rectMode.mdx delete mode 100644 src/content/reference/en/p5 copy/red.mdx delete mode 100644 src/content/reference/en/p5 copy/redraw.mdx delete mode 100644 src/content/reference/en/p5 copy/remove.mdx delete mode 100644 src/content/reference/en/p5 copy/removeElements.mdx delete mode 100644 src/content/reference/en/p5 copy/removeItem.mdx delete mode 100644 src/content/reference/en/p5 copy/requestPointerLock.mdx delete mode 100644 src/content/reference/en/p5 copy/resetMatrix.mdx delete mode 100644 src/content/reference/en/p5 copy/resetShader.mdx delete mode 100644 src/content/reference/en/p5 copy/resizeCanvas.mdx delete mode 100644 src/content/reference/en/p5 copy/reverse.mdx delete mode 100644 src/content/reference/en/p5 copy/rotate.mdx delete mode 100644 src/content/reference/en/p5 copy/rotateX.mdx delete mode 100644 src/content/reference/en/p5 copy/rotateY.mdx delete mode 100644 src/content/reference/en/p5 copy/rotateZ.mdx delete mode 100644 src/content/reference/en/p5 copy/rotationX.mdx delete mode 100644 src/content/reference/en/p5 copy/rotationY.mdx delete mode 100644 src/content/reference/en/p5 copy/rotationZ.mdx delete mode 100644 src/content/reference/en/p5 copy/round.mdx delete mode 100644 src/content/reference/en/p5 copy/sampleRate.mdx delete mode 100644 src/content/reference/en/p5 copy/saturation.mdx delete mode 100644 src/content/reference/en/p5 copy/save.mdx delete mode 100644 src/content/reference/en/p5 copy/saveCanvas.mdx delete mode 100644 src/content/reference/en/p5 copy/saveFrames.mdx delete mode 100644 src/content/reference/en/p5 copy/saveGif.mdx delete mode 100644 src/content/reference/en/p5 copy/saveJSON.mdx delete mode 100644 src/content/reference/en/p5 copy/saveSound.mdx delete mode 100644 src/content/reference/en/p5 copy/saveStrings.mdx delete mode 100644 src/content/reference/en/p5 copy/saveTable.mdx delete mode 100644 src/content/reference/en/p5 copy/scale.mdx delete mode 100644 src/content/reference/en/p5 copy/second.mdx delete mode 100644 src/content/reference/en/p5 copy/select.mdx delete mode 100644 src/content/reference/en/p5 copy/selectAll.mdx delete mode 100644 src/content/reference/en/p5 copy/set.mdx delete mode 100644 src/content/reference/en/p5 copy/setAttributes.mdx delete mode 100644 src/content/reference/en/p5 copy/setBPM.mdx delete mode 100644 src/content/reference/en/p5 copy/setCamera.mdx delete mode 100644 src/content/reference/en/p5 copy/setMoveThreshold.mdx delete mode 100644 src/content/reference/en/p5 copy/setShakeThreshold.mdx delete mode 100644 src/content/reference/en/p5 copy/setup.mdx delete mode 100644 src/content/reference/en/p5 copy/shader.mdx delete mode 100644 src/content/reference/en/p5 copy/shearX.mdx delete mode 100644 src/content/reference/en/p5 copy/shearY.mdx delete mode 100644 src/content/reference/en/p5 copy/shininess.mdx delete mode 100644 src/content/reference/en/p5 copy/shorten.mdx delete mode 100644 src/content/reference/en/p5 copy/shuffle.mdx delete mode 100644 src/content/reference/en/p5 copy/sin.mdx delete mode 100644 src/content/reference/en/p5 copy/smooth.mdx delete mode 100644 src/content/reference/en/p5 copy/sort.mdx delete mode 100644 src/content/reference/en/p5 copy/soundFormats.mdx delete mode 100644 src/content/reference/en/p5 copy/soundOut.mdx delete mode 100644 src/content/reference/en/p5 copy/specularColor.mdx delete mode 100644 src/content/reference/en/p5 copy/specularMaterial.mdx delete mode 100644 src/content/reference/en/p5 copy/sphere.mdx delete mode 100644 src/content/reference/en/p5 copy/splice.mdx delete mode 100644 src/content/reference/en/p5 copy/split.mdx delete mode 100644 src/content/reference/en/p5 copy/splitTokens.mdx delete mode 100644 src/content/reference/en/p5 copy/spotLight.mdx delete mode 100644 src/content/reference/en/p5 copy/sq.mdx delete mode 100644 src/content/reference/en/p5 copy/sqrt.mdx delete mode 100644 src/content/reference/en/p5 copy/square.mdx delete mode 100644 src/content/reference/en/p5 copy/storeItem.mdx delete mode 100644 src/content/reference/en/p5 copy/str.mdx delete mode 100644 src/content/reference/en/p5 copy/stroke.mdx delete mode 100644 src/content/reference/en/p5 copy/strokeCap.mdx delete mode 100644 src/content/reference/en/p5 copy/strokeJoin.mdx delete mode 100644 src/content/reference/en/p5 copy/strokeWeight.mdx delete mode 100644 src/content/reference/en/p5 copy/subset.mdx delete mode 100644 src/content/reference/en/p5 copy/tan.mdx delete mode 100644 src/content/reference/en/p5 copy/text.mdx delete mode 100644 src/content/reference/en/p5 copy/textAlign.mdx delete mode 100644 src/content/reference/en/p5 copy/textAscent.mdx delete mode 100644 src/content/reference/en/p5 copy/textDescent.mdx delete mode 100644 src/content/reference/en/p5 copy/textFont.mdx delete mode 100644 src/content/reference/en/p5 copy/textLeading.mdx delete mode 100644 src/content/reference/en/p5 copy/textOutput.mdx delete mode 100644 src/content/reference/en/p5 copy/textSize.mdx delete mode 100644 src/content/reference/en/p5 copy/textStyle.mdx delete mode 100644 src/content/reference/en/p5 copy/textWidth.mdx delete mode 100644 src/content/reference/en/p5 copy/textWrap.mdx delete mode 100644 src/content/reference/en/p5 copy/texture.mdx delete mode 100644 src/content/reference/en/p5 copy/textureMode.mdx delete mode 100644 src/content/reference/en/p5 copy/textureWrap.mdx delete mode 100644 src/content/reference/en/p5 copy/tint.mdx delete mode 100644 src/content/reference/en/p5 copy/torus.mdx delete mode 100644 src/content/reference/en/p5 copy/touchEnded.mdx delete mode 100644 src/content/reference/en/p5 copy/touchMoved.mdx delete mode 100644 src/content/reference/en/p5 copy/touchStarted.mdx delete mode 100644 src/content/reference/en/p5 copy/touches.mdx delete mode 100644 src/content/reference/en/p5 copy/translate.mdx delete mode 100644 src/content/reference/en/p5 copy/triangle.mdx delete mode 100644 src/content/reference/en/p5 copy/trim.mdx delete mode 100644 src/content/reference/en/p5 copy/turnAxis.mdx delete mode 100644 src/content/reference/en/p5 copy/types/Array.mdx delete mode 100644 src/content/reference/en/p5 copy/types/Boolean.mdx delete mode 100644 src/content/reference/en/p5 copy/types/Number.mdx delete mode 100644 src/content/reference/en/p5 copy/types/Object.mdx delete mode 100644 src/content/reference/en/p5 copy/types/String.mdx delete mode 100644 src/content/reference/en/p5 copy/unchar.mdx delete mode 100644 src/content/reference/en/p5 copy/unhex.mdx delete mode 100644 src/content/reference/en/p5 copy/updatePixels.mdx delete mode 100644 src/content/reference/en/p5 copy/userStartAudio.mdx delete mode 100644 src/content/reference/en/p5 copy/vertex.mdx delete mode 100644 src/content/reference/en/p5 copy/webglVersion.mdx delete mode 100644 src/content/reference/en/p5 copy/while.mdx delete mode 100644 src/content/reference/en/p5 copy/width.mdx delete mode 100644 src/content/reference/en/p5 copy/winMouseX.mdx delete mode 100644 src/content/reference/en/p5 copy/winMouseY.mdx delete mode 100644 src/content/reference/en/p5 copy/windowHeight.mdx delete mode 100644 src/content/reference/en/p5 copy/windowResized.mdx delete mode 100644 src/content/reference/en/p5 copy/windowWidth.mdx delete mode 100644 src/content/reference/en/p5 copy/year.mdx diff --git a/.github/actions/translation-tracker/README.md b/.github/actions/translation-tracker/README.md index 0c9a7e698e..1b5f2e041e 100644 --- a/.github/actions/translation-tracker/README.md +++ b/.github/actions/translation-tracker/README.md @@ -50,12 +50,12 @@ Preview path example: ```bash # From repository root — missing files from latest commit only (all languages by default) -GENERATE_STUBS=true \ + GENERATE_STUBS=true \ GITHUB_TOKEN=your_token GITHUB_REPOSITORY=youruser/p5.js-website \ node .github/actions/translation-tracker/index.js # Single language or full scan (STUB_MAX_FILES applies per language) -GENERATE_STUBS=true STUB_FULL_SCAN=true STUB_MAX_FILES=10 STUB_LANGUAGES=es,hi \ + GENERATE_STUBS=true STUB_FULL_SCAN=true STUB_MAX_FILES=10 STUB_LANGUAGES=es,hi \ GITHUB_TOKEN=your_token GITHUB_REPOSITORY=youruser/p5.js-website \ node .github/actions/translation-tracker/index.js ``` diff --git a/src/content/reference/en/p5 copy/abs.mdx b/src/content/reference/en/p5 copy/abs.mdx deleted file mode 100644 index 1bdb6895ff..0000000000 --- a/src/content/reference/en/p5 copy/abs.mdx +++ /dev/null @@ -1,61 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L10 -title: abs -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Calculates the absolute value of a number.

- -

A number's absolute value is its distance from zero on the number line. - - -5 and 5 are both five units away from zero, so calling abs(-5) - and - - abs(5) both return 5. The absolute value of a number is always - positive.

-line: 10 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A gray square with a vertical black line that divides it in half. A white rectangle gets taller when the user moves the mouse away from the line.'); - } - - function draw() { - background(200); - - // Divide the canvas. - line(50, 0, 50, 100); - - // Calculate the mouse's distance from the middle. - let h = abs(mouseX - 50); - - // Draw a rectangle based on the mouse's distance - // from the middle. - rect(0, 100 - h, 100, h); - } - -
-class: p5 -params: - - name: 'n' - description: | -

number to compute.

- type: Number -return: - description: absolute value of given number. - type: Number -chainable: false ---- - - -# abs diff --git a/src/content/reference/en/p5 copy/accelerationX.mdx b/src/content/reference/en/p5 copy/accelerationX.mdx deleted file mode 100644 index 6a47fc46ce..0000000000 --- a/src/content/reference/en/p5 copy/accelerationX.mdx +++ /dev/null @@ -1,37 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L23 -title: accelerationX -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

The system variable accelerationX always contains the acceleration of the - - device along the x axis. Value is represented as meters per second - squared.

-line: 23 -isConstructor: false -itemtype: property -example: - - |- - -
- - // Move a touchscreen device to register - // acceleration changes. - function draw() { - background(220, 50); - fill('magenta'); - ellipse(width / 2, height / 2, accelerationX); - describe('Magnitude of device acceleration is displayed as ellipse size.'); - } - -
-class: p5 -type: Number ---- - - -# accelerationX diff --git a/src/content/reference/en/p5 copy/accelerationY.mdx b/src/content/reference/en/p5 copy/accelerationY.mdx deleted file mode 100644 index bf5f54e39b..0000000000 --- a/src/content/reference/en/p5 copy/accelerationY.mdx +++ /dev/null @@ -1,37 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L45 -title: accelerationY -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

The system variable accelerationY always contains the acceleration of the - - device along the y axis. Value is represented as meters per second - squared.

-line: 45 -isConstructor: false -itemtype: property -example: - - |- - -
- - // Move a touchscreen device to register - // acceleration changes. - function draw() { - background(220, 50); - fill('magenta'); - ellipse(width / 2, height / 2, accelerationY); - describe('Magnitude of device acceleration is displayed as ellipse size'); - } - -
-class: p5 -type: Number ---- - - -# accelerationY diff --git a/src/content/reference/en/p5 copy/accelerationZ.mdx b/src/content/reference/en/p5 copy/accelerationZ.mdx deleted file mode 100644 index 11e5cbb53e..0000000000 --- a/src/content/reference/en/p5 copy/accelerationZ.mdx +++ /dev/null @@ -1,37 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L67 -title: accelerationZ -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

The system variable accelerationZ always contains the acceleration of the - - device along the z axis. Value is represented as meters per second - squared.

-line: 67 -isConstructor: false -itemtype: property -example: - - |- - -
- - // Move a touchscreen device to register - // acceleration changes. - function draw() { - background(220, 50); - fill('magenta'); - ellipse(width / 2, height / 2, accelerationZ); - describe('Magnitude of device acceleration is displayed as ellipse size'); - } - -
-class: p5 -type: Number ---- - - -# accelerationZ diff --git a/src/content/reference/en/p5 copy/acos.mdx b/src/content/reference/en/p5 copy/acos.mdx deleted file mode 100644 index c9ed943f5e..0000000000 --- a/src/content/reference/en/p5 copy/acos.mdx +++ /dev/null @@ -1,86 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L18 -title: acos -module: Math -submodule: Trigonometry -file: src/math/trigonometry.js -description: > -

Calculates the arc cosine of a number.

- -

acos() is the inverse of cos(). It expects - - arguments in the range -1 to 1. By default, acos() returns values - in the - - range 0 to π (about 3.14). If the - - angleMode() is DEGREES, - then values are - - returned in the range 0 to 180.

-line: 18 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Calculate cos() and acos() values. - let a = PI; - let c = cos(a); - let ac = acos(c); - - // Display the values. - text(`${round(a, 3)}`, 35, 25); - text(`${round(c, 3)}`, 35, 50); - text(`${round(ac, 3)}`, 35, 75); - - describe('The numbers 3.142, -1, and 3.142 written on separate rows.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Calculate cos() and acos() values. - let a = PI + QUARTER_PI; - let c = cos(a); - let ac = acos(c); - - // Display the values. - text(`${round(a, 3)}`, 35, 25); - text(`${round(c, 3)}`, 35, 50); - text(`${round(ac, 3)}`, 35, 75); - - describe('The numbers 3.927, -0.707, and 2.356 written on separate rows.'); - } - -
-class: p5 -params: - - name: value - description: | -

value whose arc cosine is to be returned.

- type: Number -return: - description: arc cosine of the given value. - type: Number -chainable: false ---- - - -# acos diff --git a/src/content/reference/en/p5 copy/alpha.mdx b/src/content/reference/en/p5 copy/alpha.mdx deleted file mode 100644 index c1a87aa78d..0000000000 --- a/src/content/reference/en/p5 copy/alpha.mdx +++ /dev/null @@ -1,120 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L16 -title: alpha -module: Color -submodule: Creating & Reading -file: src/color/creating_reading.js -description: > -

Gets the alpha (transparency) value of a color.

- -

alpha() extracts the alpha value from a - - p5.Color object, an array of color - components, or - - a CSS color string.

-line: 16 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object. - let c = color(0, 126, 255, 102); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'alphaValue' to 102. - let alphaValue = alpha(c); - - // Draw the right rectangle. - fill(alphaValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light blue and the right one is charcoal gray.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a color array. - let c = [0, 126, 255, 102]; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'alphaValue' to 102. - let alphaValue = alpha(c); - - // Draw the left rectangle. - fill(alphaValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light blue and the right one is charcoal gray.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a CSS color string. - let c = 'rgba(0, 126, 255, 0.4)'; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'alphaValue' to 102. - let alphaValue = alpha(c); - - // Draw the right rectangle. - fill(alphaValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light blue and the right one is charcoal gray.'); - } - -
-class: p5 -params: - - name: color - description: | -

p5.Color object, array of - color components, or CSS color string.

- type: 'p5.Color|Number[]|String' -return: - description: the alpha value. - type: Number -chainable: false ---- - - -# alpha diff --git a/src/content/reference/en/p5 copy/ambientLight.mdx b/src/content/reference/en/p5 copy/ambientLight.mdx deleted file mode 100644 index 09f9159592..0000000000 --- a/src/content/reference/en/p5 copy/ambientLight.mdx +++ /dev/null @@ -1,241 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L10 -title: ambientLight -module: 3D -submodule: Lights -file: src/webgl/light.js -description: > -

Creates a light that shines from all directions.

- -

Ambient light does not come from one direction. Instead, 3D shapes are - - lit evenly from all sides. Ambient lights are almost always used in - - combination with other types of lights.

- -

There are three ways to call ambientLight() with optional - parameters to - - set the light’s color.

- -

The first way to call ambientLight() has two parameters, - gray and - - alpha. alpha is optional. Grayscale and alpha values - between 0 and 255 - - can be passed to set the ambient light’s color, as in - ambientLight(50) or - - ambientLight(50, 30).

- -

The second way to call ambientLight() has one parameter, - color. A - - p5.Color object, an array of color - values, or a - - CSS color string, as in ambientLight('magenta'), can be passed to - set the - - ambient light’s color.

- -

The third way to call ambientLight() has four parameters, - v1, v2, - - v3, and alpha. alpha is optional. RGBA, - HSBA, or HSLA values can be - - passed to set the ambient light’s colors, as in ambientLight(255, 0, - 0) - - or ambientLight(255, 0, 0, 30). Color values will be interpreted - using - - the current colorMode().

-line: 10 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click the canvas to turn on the light. - - let isLit = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A sphere drawn against a gray background. The sphere appears to change color when the user double-clicks.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Control the light. - if (isLit === true) { - // Use a grayscale value of 80. - ambientLight(80); - } - - // Draw the sphere. - sphere(30); - } - - // Turn on the ambient light when the user double-clicks. - function doubleClicked() { - isLit = true; - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A faded magenta sphere drawn against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - // Use a p5.Color object. - let c = color('orchid'); - ambientLight(c); - - // Draw the sphere. - sphere(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A faded magenta sphere drawn against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - // Use a CSS color string. - ambientLight('#DA70D6'); - - // Draw the sphere. - sphere(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A faded magenta sphere drawn against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - // Use RGB values - ambientLight(218, 112, 214); - - // Draw the sphere. - sphere(30); - } - -
-class: p5 -overloads: - - line: 10 - params: - - name: v1 - description: | -

red or hue value in the current - colorMode().

- type: Number - - name: v2 - description: | -

green or saturation value in the current - colorMode().

- type: Number - - name: v3 - description: | -

blue, brightness, or lightness value in the current - colorMode().

- type: Number - - name: alpha - description: | -

alpha (transparency) value in the current - colorMode().

- type: Number - optional: true - chainable: 1 - - line: 164 - params: - - name: gray - description: | -

grayscale value between 0 and 255.

- type: Number - - name: alpha - description: '' - type: Number - optional: true - chainable: 1 - - line: 171 - params: - - name: value - description: | -

color as a CSS string.

- type: String - chainable: 1 - - line: 177 - params: - - name: values - description: | -

color as an array of RGBA, HSBA, or HSLA - values.

- type: 'Number[]' - chainable: 1 - - line: 184 - params: - - name: color - description: | -

color as a p5.Color object.

- type: p5.Color - chainable: 1 -chainable: true ---- - - -# ambientLight diff --git a/src/content/reference/en/p5 copy/ambientMaterial.mdx b/src/content/reference/en/p5 copy/ambientMaterial.mdx deleted file mode 100644 index 8b96f24260..0000000000 --- a/src/content/reference/en/p5 copy/ambientMaterial.mdx +++ /dev/null @@ -1,269 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2416 -title: ambientMaterial -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Sets the ambient color of shapes’ surface material.

- -

The ambientMaterial() color sets the components of the - - ambientLight() color that shapes - will - - reflect. For example, calling ambientMaterial(255, 255, 0) would - cause a - - shape to reflect red and green light, but not blue light.

- -

ambientMaterial() can be called three ways with different - parameters to - - set the material’s color.

- -

The first way to call ambientMaterial() has one parameter, - gray. - - Grayscale values between 0 and 255, as in ambientMaterial(50), - can be - - passed to set the material’s color. Higher grayscale values make shapes - - appear brighter.

- -

The second way to call ambientMaterial() has one parameter, - color. A - - p5.Color object, an array of color - values, or a - - CSS color string, as in ambientMaterial('magenta'), can be passed - to set - - the material’s color.

- -

The third way to call ambientMaterial() has three parameters, - v1, v2, - - and v3. RGB, HSB, or HSL values, as in ambientMaterial(255, - 0, 0), can - - be passed to set the material’s colors. Color values will be interpreted - - using the current colorMode().

- -

Note: ambientMaterial() can only be used in WebGL mode.

-line: 2416 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A magenta cube drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on a magenta ambient light. - ambientLight(255, 0, 255); - - // Draw the box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A purple cube drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on a magenta ambient light. - ambientLight(255, 0, 255); - - // Add a dark gray ambient material. - ambientMaterial(150); - - // Draw the box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A red cube drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on a magenta ambient light. - ambientLight(255, 0, 255); - - // Add a yellow ambient material using RGB values. - ambientMaterial(255, 255, 0); - - // Draw the box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A red cube drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on a magenta ambient light. - ambientLight(255, 0, 255); - - // Add a yellow ambient material using a p5.Color object. - let c = color(255, 255, 0); - ambientMaterial(c); - - // Draw the box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A red cube drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on a magenta ambient light. - ambientLight(255, 0, 255); - - // Add a yellow ambient material using a color string. - ambientMaterial('yellow'); - - // Draw the box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A yellow cube drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on a white ambient light. - ambientLight(255, 255, 255); - - // Add a yellow ambient material using a color string. - ambientMaterial('yellow'); - - // Draw the box. - box(); - } - -
-class: p5 -overloads: - - line: 2416 - params: - - name: v1 - description: | -

red or hue value in the current - colorMode().

- type: Number - - name: v2 - description: | -

green or saturation value in the - current colorMode().

- type: Number - - name: v3 - description: | -

blue, brightness, or lightness value in the - current colorMode().

- type: Number - chainable: 1 - - line: 2621 - params: - - name: gray - description: | -

grayscale value between 0 (black) and 255 (white).

- type: Number - chainable: 1 - - line: 2627 - params: - - name: color - description: | -

color as a p5.Color object, - an array of color values, or a CSS string.

- type: 'p5.Color|Number[]|String' - chainable: 1 -chainable: true ---- - - -# ambientMaterial diff --git a/src/content/reference/en/p5 copy/angleMode.mdx b/src/content/reference/en/p5 copy/angleMode.mdx deleted file mode 100644 index 3401a563cd..0000000000 --- a/src/content/reference/en/p5 copy/angleMode.mdx +++ /dev/null @@ -1,219 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L557 -title: angleMode -module: Math -submodule: Trigonometry -file: src/math/trigonometry.js -description: > -

Changes the unit system used to measure angles.

- -

Degrees and radians are both units for measuring angles. There are 360˚ in - - one full rotation. A full rotation is 2 × π (about 6.28) radians.

- -

Functions such as rotate() and - - sin() expect angles measured radians by - default. - - Calling angleMode(DEGREES) switches to degrees. Calling - - angleMode(RADIANS) switches back to radians.

- -

Calling angleMode() with no arguments returns current angle - mode, which - - is either RADIANS or DEGREES.

-line: 557 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Rotate 1/8 turn. - rotate(QUARTER_PI); - - // Draw a line. - line(0, 0, 80, 0); - - describe('A diagonal line radiating from the top-left corner of a square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use degrees. - angleMode(DEGREES); - - // Rotate 1/8 turn. - rotate(45); - - // Draw a line. - line(0, 0, 80, 0); - - describe('A diagonal line radiating from the top-left corner of a square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(50); - - // Calculate the angle to rotate. - let angle = TWO_PI / 7; - - // Move the origin to the center. - translate(50, 50); - - // Style the flower. - noStroke(); - fill(255, 50); - - // Draw the flower. - for (let i = 0; i < 7; i += 1) { - ellipse(0, 0, 80, 20); - rotate(angle); - } - - describe('A translucent white flower on a dark background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(50); - - // Use degrees. - angleMode(DEGREES); - - // Calculate the angle to rotate. - let angle = 360 / 7; - - // Move the origin to the center. - translate(50, 50); - - // Style the flower. - noStroke(); - fill(255, 50); - - // Draw the flower. - for (let i = 0; i < 7; i += 1) { - ellipse(0, 0, 80, 20); - rotate(angle); - } - - describe('A translucent white flower on a dark background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A white ball on a string oscillates left and right.'); - } - - function draw() { - background(200); - - // Calculate the coordinates. - let x = 30 * cos(frameCount * 0.05) + 50; - let y = 50; - - // Draw the oscillator. - line(50, y, x, y); - circle(x, y, 20); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Use degrees. - angleMode(DEGREES); - - describe('A white ball on a string oscillates left and right.'); - } - - function draw() { - background(200); - - // Calculate the coordinates. - let x = 30 * cos(frameCount * 2.86) + 50; - let y = 50; - - // Draw the oscillator. - line(50, y, x, y); - circle(x, y, 20); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw the upper line. - rotate(PI / 6); - line(0, 0, 80, 0); - - // Use degrees. - angleMode(DEGREES); - - // Draw the lower line. - rotate(30); - line(0, 0, 80, 0); - - describe('Two diagonal lines radiating from the top-left corner of a square. The lines are oriented 30 degrees from the edges of the square and 30 degrees apart from each other.'); - } - -
-class: p5 -overloads: - - line: 557 - params: - - name: mode - description: | -

either RADIANS or DEGREES.

- type: Constant - - line: 743 - params: [] - return: - description: mode either RADIANS or DEGREES - type: Constant -chainable: false ---- - - -# angleMode diff --git a/src/content/reference/en/p5 copy/append.mdx b/src/content/reference/en/p5 copy/append.mdx deleted file mode 100644 index 4e0bbeb5eb..0000000000 --- a/src/content/reference/en/p5 copy/append.mdx +++ /dev/null @@ -1,48 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L10 -title: append -module: Data -submodule: Array Functions -file: src/utilities/array_functions.js -description: | -

Adds a value to the end of an array. Extends the length of - the array by one. Maps to Array.push().

-line: 10 -deprecated: >- - Use array.push(value) - instead. -isConstructor: false -itemtype: method -example: - - |- - -
- function setup() { - let myArray = ['Mango', 'Apple', 'Papaya']; - print(myArray); // ['Mango', 'Apple', 'Papaya'] - - append(myArray, 'Peach'); - print(myArray); // ['Mango', 'Apple', 'Papaya', 'Peach'] - } -
-class: p5 -params: - - name: array - description: | -

Array to append

- type: Array - - name: value - description: | -

to be added to the Array

- type: Any -return: - description: the array that was appended to - type: Array -chainable: false ---- - - -# append diff --git a/src/content/reference/en/p5 copy/applyMatrix.mdx b/src/content/reference/en/p5 copy/applyMatrix.mdx deleted file mode 100644 index b105ed75da..0000000000 --- a/src/content/reference/en/p5 copy/applyMatrix.mdx +++ /dev/null @@ -1,347 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L11 -title: applyMatrix -module: Transform -submodule: Transform -file: src/core/transform.js -description: > -

Applies a transformation matrix to the coordinate system.

- -

Transformations such as - - translate(), - - rotate(), and - - scale() - - use matrix-vector multiplication behind the scenes. A table of numbers, - - called a matrix, encodes each transformation. The values in the matrix - - then multiply each point on the canvas, which is represented by a vector.

- -

applyMatrix() allows for many transformations to be applied at - once. See - - Wikipedia - - and MDN - - for more details about transformations.

- -

There are two ways to call applyMatrix() in two and three - dimensions.

- -

In 2D mode, the parameters a, b, c, - d, e, and f, correspond to - - elements in the following transformation matrix:

- -
- -

The transformation matrix used when applyMatrix is called in 2D
-  mode.

- -
- -

The numbers can be passed individually, as in - - applyMatrix(2, 0, 0, 0, 2, 0). They can also be passed in an - array, as in - - applyMatrix([2, 0, 0, 0, 2, 0]).

- -

In 3D mode, the parameters a, b, c, - d, e, f, g, - h, i, - - j, k, l, m, - n, o, and p correspond to elements in - the - - following transformation matrix:

- -

The transformation matrix used when applyMatrix is called in 3D
-  mode.

- -

The numbers can be passed individually, as in - - applyMatrix(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1). They - can - - also be passed in an array, as in - - applyMatrix([2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, - 1]).

- -

By default, transformations accumulate. The - - push() and pop() functions - - can be used to isolate transformations within distinct drawing groups.

- -

Note: Transformations are reset at the beginning of the draw loop. Calling - - applyMatrix() inside the draw() - function won't - - cause shapes to transform continuously.

-line: 11 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A white circle on a gray background.'); - } - - function draw() { - background(200); - - // Translate the origin to the center. - applyMatrix(1, 0, 0, 1, 50, 50); - - // Draw the circle at coordinates (0, 0). - circle(0, 0, 40); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A white circle on a gray background.'); - } - - function draw() { - background(200); - - // Translate the origin to the center. - let m = [1, 0, 0, 1, 50, 50]; - applyMatrix(m); - - // Draw the circle at coordinates (0, 0). - circle(0, 0, 40); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe("A white rectangle on a gray background. The rectangle's long axis runs from top-left to bottom-right."); - } - - function draw() { - background(200); - - // Rotate the coordinate system 1/8 turn. - let angle = QUARTER_PI; - let ca = cos(angle); - let sa = sin(angle); - applyMatrix(ca, sa, -sa, ca, 0, 0); - - // Draw a rectangle at coordinates (50, 0). - rect(50, 0, 40, 20); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - 'Two white squares on a gray background. The larger square appears at the top-center. The smaller square appears at the top-left.' - ); - } - - function draw() { - background(200); - - // Draw a square at (30, 20). - square(30, 20, 40); - - // Scale the coordinate system by a factor of 0.5. - applyMatrix(0.5, 0, 0, 0.5, 0, 0); - - // Draw a square at (30, 20). - // It appears at (15, 10) after scaling. - square(30, 20, 40); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A white quadrilateral on a gray background.'); - } - - function draw() { - background(200); - - // Calculate the shear factor. - let angle = QUARTER_PI; - let shearFactor = 1 / tan(HALF_PI - angle); - - // Shear the coordinate system along the x-axis. - applyMatrix(1, 0, shearFactor, 1, 0, 0); - - // Draw the square. - square(0, 0, 50); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube rotates slowly against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system a little more each frame. - let angle = frameCount * 0.01; - let ca = cos(angle); - let sa = sin(angle); - applyMatrix(ca, 0, sa, 0, 0, 1, 0, 0, -sa, 0, ca, 0, 0, 0, 0, 1); - - // Draw a box. - box(); - } - -
-class: p5 -overloads: - - line: 11 - params: - - name: arr - description: > -

an array containing the elements of the transformation matrix. Its - length should be either 6 (2D) or 16 (3D).

- type: Array - chainable: 1 - - line: 206 - params: - - name: a - description: | -

an element of the transformation matrix.

- type: Number - - name: b - description: | -

an element of the transformation matrix.

- type: Number - - name: c - description: | -

an element of the transformation matrix.

- type: Number - - name: d - description: | -

an element of the transformation matrix.

- type: Number - - name: e - description: | -

an element of the transformation matrix.

- type: Number - - name: f - description: | -

an element of the transformation matrix.

- type: Number - chainable: 1 - - line: 216 - params: - - name: a - description: '' - type: Number - - name: b - description: '' - type: Number - - name: c - description: '' - type: Number - - name: d - description: '' - type: Number - - name: e - description: '' - type: Number - - name: f - description: '' - type: Number - - name: g - description: | -

an element of the transformation matrix.

- type: Number - - name: h - description: | -

an element of the transformation matrix.

- type: Number - - name: i - description: | -

an element of the transformation matrix.

- type: Number - - name: j - description: | -

an element of the transformation matrix.

- type: Number - - name: k - description: | -

an element of the transformation matrix.

- type: Number - - name: l - description: | -

an element of the transformation matrix.

- type: Number - - name: m - description: | -

an element of the transformation matrix.

- type: Number - - name: 'n' - description: | -

an element of the transformation matrix.

- type: Number - - name: o - description: | -

an element of the transformation matrix.

- type: Number - - name: p - description: | -

an element of the transformation matrix.

- type: Number - chainable: 1 -chainable: true ---- - - -# applyMatrix diff --git a/src/content/reference/en/p5 copy/arc.mdx b/src/content/reference/en/p5 copy/arc.mdx deleted file mode 100644 index ee50708815..0000000000 --- a/src/content/reference/en/p5 copy/arc.mdx +++ /dev/null @@ -1,274 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L102 -title: arc -module: Shape -submodule: 2D Primitives -file: src/core/shape/2d_primitives.js -description: > -

Draws an arc.

- -

An arc is a section of an ellipse defined by the x, - y, w, and - - h parameters. x and y set the location - of the arc's center. w and - - h set the arc's width and height. See - - ellipse() and - - ellipseMode() for more details.

- -

The fifth and sixth parameters, start and stop, - set the angles - - between which to draw the arc. Arcs are always drawn clockwise from - - start to stop. The fifth and sixth parameters, start - and stop, set the - - angles between which to draw the arc. By default, angles are given in radians, - but if angleMode - - (DEGREES) is set, the function interprets the values in degrees.

- -

The seventh parameter, mode, is optional. It determines the - arc's fill - - style. The fill modes are a semi-circle (OPEN), a closed - semi-circle - - (CHORD), or a closed pie segment (PIE).

- -

The eighth parameter, detail, is also optional. It determines - how many - - vertices are used to draw the arc in WebGL mode. The default value is 25.

-line: 102 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - arc(50, 50, 80, 80, 0, PI + HALF_PI); - - describe('A white circle on a gray canvas. The top-right quarter of the circle is missing.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - arc(50, 50, 80, 40, 0, PI + HALF_PI); - - describe('A white ellipse on a gray canvas. The top-right quarter of the ellipse is missing.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Bottom-right. - arc(50, 55, 50, 50, 0, HALF_PI); - - noFill(); - - // Bottom-left. - arc(50, 55, 60, 60, HALF_PI, PI); - - // Top-left. - arc(50, 55, 70, 70, PI, PI + QUARTER_PI); - - // Top-right. - arc(50, 55, 80, 80, PI + QUARTER_PI, TWO_PI); - - describe( - 'A shattered outline of an circle with a quarter of a white circle at the bottom-right.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Default fill mode. - arc(50, 50, 80, 80, 0, PI + QUARTER_PI); - - describe('A white circle with the top-right third missing. The bottom is outlined in black.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // OPEN fill mode. - arc(50, 50, 80, 80, 0, PI + QUARTER_PI, OPEN); - - describe( - 'A white circle missing a section from the top-right. The bottom is outlined in black.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // CHORD fill mode. - arc(50, 50, 80, 80, 0, PI + QUARTER_PI, CHORD); - - describe('A white circle with a black outline missing a section from the top-right.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // PIE fill mode. - arc(50, 50, 80, 80, 0, PI + QUARTER_PI, PIE); - - describe('A white circle with a black outline. The top-right third is missing.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - // PIE fill mode. - arc(0, 0, 80, 80, 0, PI + QUARTER_PI, PIE); - - describe('A white circle with a black outline. The top-right third is missing.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - // PIE fill mode with 5 vertices. - arc(0, 0, 80, 80, 0, PI + QUARTER_PI, PIE, 5); - - describe('A white circle with a black outline. The top-right third is missing.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A yellow circle on a black background. The circle opens and closes its mouth.'); - } - - function draw() { - background(0); - - // Style the arc. - noStroke(); - fill(255, 255, 0); - - // Update start and stop angles. - let biteSize = PI / 16; - let startAngle = biteSize * sin(frameCount * 0.1) + biteSize; - let endAngle = TWO_PI - startAngle; - - // Draw the arc. - arc(50, 50, 80, 80, startAngle, endAngle, PIE); - } - -
-class: p5 -params: - - name: x - description: | -

x-coordinate of the arc's ellipse.

- type: Number - - name: 'y' - description: | -

y-coordinate of the arc's ellipse.

- type: Number - - name: w - description: | -

width of the arc's ellipse by default.

- type: Number - - name: h - description: | -

height of the arc's ellipse by default.

- type: Number - - name: start - description: | -

angle to start the arc, specified in radians.

- type: Number - - name: stop - description: | -

angle to stop the arc, specified in radians.

- type: Number - - name: mode - description: | -

optional parameter to determine the way of drawing - the arc. either CHORD, PIE, or OPEN.

- type: Constant - optional: true - - name: detail - description: | -

optional parameter for WebGL mode only. This is to - specify the number of vertices that makes up the - perimeter of the arc. Default value is 25. Won't - draw a stroke for a detail of more than 50.

- type: Integer - optional: true -chainable: true ---- - - -# arc diff --git a/src/content/reference/en/p5 copy/arrayCopy.mdx b/src/content/reference/en/p5 copy/arrayCopy.mdx deleted file mode 100644 index 2d149d1ed3..0000000000 --- a/src/content/reference/en/p5 copy/arrayCopy.mdx +++ /dev/null @@ -1,95 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L35 -title: arrayCopy -module: Data -submodule: Array Functions -file: src/utilities/array_functions.js -description: > -

Copies an array (or part of an array) to another array. The src array is - - copied to the dst array, beginning at the position specified by - - srcPosition and into the position specified by dstPosition. The number of - - elements to copy is determined by length. Note that copying values - - overwrites existing values in the destination array. To append values - - instead of overwriting them, use concat().

- -

The simplified version with only two arguments, arrayCopy(src, dst), - - copies an entire array to another of the same size. It is equivalent to - - arrayCopy(src, 0, dst, 0, src.length).

- -

Using this function is far more efficient for copying array data than - - iterating through a for() loop and copying each element individually.

-line: 35 -deprecated: >- - Use arr1.copyWithin(arr2) - instead. -isConstructor: false -itemtype: method -example: - - |- - -
- let src = ['A', 'B', 'C']; - let dst = [1, 2, 3]; - let srcPosition = 1; - let dstPosition = 0; - let length = 2; - - print(src); // ['A', 'B', 'C'] - print(dst); // [ 1 , 2 , 3 ] - - arrayCopy(src, srcPosition, dst, dstPosition, length); - print(dst); // ['B', 'C', 3] -
-class: p5 -overloads: - - line: 35 - params: - - name: src - description: | -

the source Array

- type: Array - - name: srcPosition - description: | -

starting position in the source Array

- type: Integer - - name: dst - description: | -

the destination Array

- type: Array - - name: dstPosition - description: | -

starting position in the destination Array

- type: Integer - - name: length - description: | -

number of Array elements to be copied

- type: Integer - - line: 73 - params: - - name: src - description: '' - type: Array - - name: dst - description: '' - type: Array - - name: length - description: '' - type: Integer - optional: true -chainable: false ---- - - -# arrayCopy diff --git a/src/content/reference/en/p5 copy/asin.mdx b/src/content/reference/en/p5 copy/asin.mdx deleted file mode 100644 index 78518c0050..0000000000 --- a/src/content/reference/en/p5 copy/asin.mdx +++ /dev/null @@ -1,86 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L80 -title: asin -module: Math -submodule: Trigonometry -file: src/math/trigonometry.js -description: > -

Calculates the arc sine of a number.

- -

asin() is the inverse of sin(). It expects input - - values in the range of -1 to 1. By default, asin() returns values - in the - - range -π ÷ 2 (about -1.57) to π ÷ 2 (about 1.57). If - - the angleMode() is DEGREES - then values are - - returned in the range -90 to 90.

-line: 80 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Calculate sin() and asin() values. - let a = PI / 3; - let s = sin(a); - let as = asin(s); - - // Display the values. - text(`${round(a, 3)}`, 35, 25); - text(`${round(s, 3)}`, 35, 50); - text(`${round(as, 3)}`, 35, 75); - - describe('The numbers 1.047, 0.866, and 1.047 written on separate rows.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Calculate sin() and asin() values. - let a = PI + PI / 3; - let s = sin(a); - let as = asin(s); - - // Display the values. - text(`${round(a, 3)}`, 35, 25); - text(`${round(s, 3)}`, 35, 50); - text(`${round(as, 3)}`, 35, 75); - - describe('The numbers 4.189, -0.866, and -1.047 written on separate rows.'); - } - -
-class: p5 -params: - - name: value - description: | -

value whose arc sine is to be returned.

- type: Number -return: - description: arc sine of the given value. - type: Number -chainable: false ---- - - -# asin diff --git a/src/content/reference/en/p5 copy/atan.mdx b/src/content/reference/en/p5 copy/atan.mdx deleted file mode 100644 index 86b3874bb0..0000000000 --- a/src/content/reference/en/p5 copy/atan.mdx +++ /dev/null @@ -1,86 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L142 -title: atan -module: Math -submodule: Trigonometry -file: src/math/trigonometry.js -description: > -

Calculates the arc tangent of a number.

- -

atan() is the inverse of tan(). It expects input - - values in the range of -Infinity to Infinity. By default, atan() - returns - - values in the range -π ÷ 2 (about -1.57) to π ÷ 2 - - (about 1.57). If the angleMode() is - DEGREES - - then values are returned in the range -90 to 90.

-line: 142 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Calculate tan() and atan() values. - let a = PI / 3; - let t = tan(a); - let at = atan(t); - - // Display the values. - text(`${round(a, 3)}`, 35, 25); - text(`${round(t, 3)}`, 35, 50); - text(`${round(at, 3)}`, 35, 75); - - describe('The numbers 1.047, 1.732, and 1.047 written on separate rows.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Calculate tan() and atan() values. - let a = PI + PI / 3; - let t = tan(a); - let at = atan(t); - - // Display the values. - text(`${round(a, 3)}`, 35, 25); - text(`${round(t, 3)}`, 35, 50); - text(`${round(at, 3)}`, 35, 75); - - describe('The numbers 4.189, 1.732, and 1.047 written on separate rows.'); - } - -
-class: p5 -params: - - name: value - description: | -

value whose arc tangent is to be returned.

- type: Number -return: - description: arc tangent of the given value. - type: Number -chainable: false ---- - - -# atan diff --git a/src/content/reference/en/p5 copy/atan2.mdx b/src/content/reference/en/p5 copy/atan2.mdx deleted file mode 100644 index 200b49516b..0000000000 --- a/src/content/reference/en/p5 copy/atan2.mdx +++ /dev/null @@ -1,106 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L204 -title: atan2 -module: Math -submodule: Trigonometry -file: src/math/trigonometry.js -description: > -

Calculates the angle formed by a point, the origin, and the positive - - x-axis.

- -

atan2() is most often used for orienting geometry to the - mouse's - - position, as in atan2(mouseY, mouseX). The first parameter is the - point's - - y-coordinate and the second parameter is its x-coordinate.

- -

By default, atan2() returns values in the range - - -π (about -3.14) to π (3.14). If the - - angleMode() is DEGREES, - then values are - - returned in the range -180 to 180.

-line: 204 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A rectangle at the top-left of the canvas rotates with mouse movements.'); - } - - function draw() { - background(200); - - // Calculate the angle between the mouse - // and the origin. - let a = atan2(mouseY, mouseX); - - // Rotate. - rotate(a); - - // Draw the shape. - rect(0, 0, 60, 10); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A rectangle at the center of the canvas rotates with mouse movements.'); - } - - function draw() { - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Get the mouse's coordinates relative to the origin. - let x = mouseX - 50; - let y = mouseY - 50; - - // Calculate the angle between the mouse and the origin. - let a = atan2(y, x); - - // Rotate. - rotate(a); - - // Draw the shape. - rect(-30, -5, 60, 10); - } - -
-class: p5 -params: - - name: 'y' - description: | -

y-coordinate of the point.

- type: Number - - name: x - description: | -

x-coordinate of the point.

- type: Number -return: - description: arc tangent of the given point. - type: Number -chainable: false ---- - - -# atan2 diff --git a/src/content/reference/en/p5 copy/background.mdx b/src/content/reference/en/p5 copy/background.mdx deleted file mode 100644 index 6250c60339..0000000000 --- a/src/content/reference/en/p5 copy/background.mdx +++ /dev/null @@ -1,336 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L414 -title: background -module: Color -submodule: Setting -file: src/color/setting.js -description: > -

Sets the color used for the background of the canvas.

- -

By default, the background is transparent. background() is - typically used - - within draw() to clear the display window at - the - - beginning of each frame. It can also be used inside - - setup() to set the background on the first - frame - - of animation.

- -

The version of background() with one parameter interprets the - value one - - of four ways. If the parameter is a Number, it's interpreted as a - grayscale - - value. If the parameter is a String, it's interpreted as a CSS - color string. - - RGB, RGBA, HSL, HSLA, hex, and named color strings are supported. If the - - parameter is a p5.Color object, it will - be used as - - the background color. If the parameter is a - - p5.Image object, it will be used as the - background - - image.

- -

The version of background() with two parameters interprets the - first one - - as a grayscale value. The second parameter sets the alpha (transparency) - - value.

- -

The version of background() with three parameters interprets - them as RGB, - - HSB, or HSL colors, depending on the current - - colorMode(). By default, colors are - specified - - in RGB values. Calling background(255, 204, 0) sets the - background a bright - - yellow color.

- -

The version of background() with four parameters interprets - them as RGBA, - - HSBA, or HSLA colors, depending on the current - - colorMode(). The last parameter sets - the alpha - - (transparency) value.

-line: 414 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // A grayscale value. - background(51); - - describe('A canvas with a dark charcoal gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // A grayscale value and an alpha value. - background(51, 0.4); - describe('A canvas with a transparent gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // R, G & B values. - background(255, 204, 0); - - describe('A canvas with a yellow background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // R, G, B, and Alpha values. - background(255, 0, 0, 128); - - describe('A canvas with a semi-transparent red background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Use HSB color. - colorMode(HSB); - - // H, S & B values. - background(255, 204, 100); - - describe('A canvas with a royal blue background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // A CSS named color. - background('red'); - - describe('A canvas with a red background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Three-digit hex RGB notation. - background('#fae'); - - describe('A canvas with a pink background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Six-digit hex RGB notation. - background('#222222'); - - describe('A canvas with a black background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Integer RGB notation. - background('rgb(0, 255, 0)'); - - describe('A canvas with a bright green background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Integer RGBA notation. - background('rgba(0, 255, 0, 0.25)'); - - describe('A canvas with a transparent green background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Percentage RGB notation. - background('rgb(100%, 0%, 10%)'); - - describe('A canvas with a red background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Percentage RGBA notation. - background('rgba(100%, 0%, 100%, 0.5)'); - - describe('A canvas with a transparent purple background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // A p5.Color object. - let c = color(0, 0, 255); - background(c); - - describe('A canvas with a blue background.'); - } - -
-class: p5 -overloads: - - line: 414 - params: - - name: color - description: > -

any value created by the color() - function

- type: p5.Color - chainable: 1 - - line: 626 - params: - - name: colorstring - description: | -

color string, possible formats include: integer - rgb() or rgba(), percentage rgb() or rgba(), - 3-digit hex, 6-digit hex.

- type: String - - name: a - description: | -

opacity of the background relative to current - color range (default is 0-255).

- type: Number - optional: true - chainable: 1 - - line: 636 - params: - - name: gray - description: | -

specifies a value between white and black.

- type: Number - - name: a - description: '' - type: Number - optional: true - chainable: 1 - - line: 643 - params: - - name: v1 - description: > -

red value if color mode is RGB, or hue value if color mode is - HSB.

- type: Number - - name: v2 - description: > -

green value if color mode is RGB, or saturation value if color mode - is HSB.

- type: Number - - name: v3 - description: > -

blue value if color mode is RGB, or brightness value if color mode - is HSB.

- type: Number - - name: a - description: '' - type: Number - optional: true - chainable: 1 - - line: 652 - params: - - name: values - description: | -

an array containing the red, green, blue - and alpha components of the color.

- type: 'Number[]' - chainable: 1 - - line: 659 - params: - - name: image - description: | -

image created with loadImage() - or createImage(), - to set as background. - (must be same size as the sketch window).

- type: p5.Image - - name: a - description: '' - type: Number - optional: true - chainable: 1 -chainable: true ---- - - -# background diff --git a/src/content/reference/en/p5 copy/baseColorShader.mdx b/src/content/reference/en/p5 copy/baseColorShader.mdx deleted file mode 100644 index a608e4d5ce..0000000000 --- a/src/content/reference/en/p5 copy/baseColorShader.mdx +++ /dev/null @@ -1,178 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1292 -title: baseColorShader -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Get the shader used when no lights or materials are applied.

- -

You can call baseColorShader().modify() - - and change any of the following hooks:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HookDescription
void beforeVertexCalled at the start of the vertex shader.
vec3 getLocalPositionUpdate the position of vertices before transforms are applied. It takes in - vec3 position and must return a modified version.
vec3 getWorldPositionUpdate the position of vertices after transforms are applied. It takes in - vec3 position and pust return a modified version.
vec3 getLocalNormalUpdate the normal before transforms are applied. It takes in vec3 - normal and must return a modified version.
vec3 getWorldNormalUpdate the normal after transforms are applied. It takes in vec3 - normal and must return a modified version.
vec2 getUVUpdate the texture coordinates. It takes in vec2 uv and must - return a modified version.
vec4 getVertexColorUpdate the color of each vertex. It takes in a vec4 color and - must return a modified version.
void afterVertexCalled at the end of the vertex shader.
void beforeFragmentCalled at the start of the fragment shader.
vec4 getFinalColorUpdate the final color after mixing. It takes in a vec4 color - and must return a modified version.
void afterFragmentCalled at the end of the fragment shader.
- -

Most of the time, you will need to write your hooks in GLSL ES version 300. - If you - - are using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.

- -

Call baseColorShader().inspectHooks() to see all the possible - hooks and - - their default implementations.

-line: 1292 -isConstructor: false -itemtype: method -example: - - |- - -
- - let myShader; - - function setup() { - createCanvas(200, 200, WEBGL); - myShader = baseColorShader().modify({ - uniforms: { - 'float time': () => millis() - }, - 'vec3 getWorldPosition': `(vec3 pos) { - pos.y += 20. * sin(time * 0.001 + pos.x * 0.05); - return pos; - }` - }); - } - - function draw() { - background(255); - shader(myShader); - noStroke(); - fill('red'); - circle(0, 0, 50); - } - -
-class: p5 -return: - description: The color shader - type: p5.Shader -chainable: false -beta: true ---- - - -# baseColorShader diff --git a/src/content/reference/en/p5 copy/baseMaterialShader.mdx b/src/content/reference/en/p5 copy/baseMaterialShader.mdx deleted file mode 100644 index d41248d1aa..0000000000 --- a/src/content/reference/en/p5 copy/baseMaterialShader.mdx +++ /dev/null @@ -1,418 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L886 -title: baseMaterialShader -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Get the default shader used with lights, materials, - - and textures.

- -

You can call baseMaterialShader().modify() - - and change any of the following hooks:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HookDescription
- - -

void beforeVertex

- -
- - -

Called at the start of the vertex shader.

- -
- - -

vec3 getLocalPosition

- -
- - -

Update the position of vertices before transforms are applied. It takes in - vec3 position and must return a modified version.

- -
- - -

vec3 getWorldPosition

- -
- - -

Update the position of vertices after transforms are applied. It takes in - vec3 position and pust return a modified version.

- -
- - -

vec3 getLocalNormal

- -
- - -

Update the normal before transforms are applied. It takes in vec3 - normal and must return a modified version.

- -
- - -

vec3 getWorldNormal

- -
- - -

Update the normal after transforms are applied. It takes in vec3 - normal and must return a modified version.

- -
- - -

vec2 getUV

- -
- - -

Update the texture coordinates. It takes in vec2 uv and must - return a modified version.

- -
- - -

vec4 getVertexColor

- -
- - -

Update the color of each vertex. It takes in a vec4 color and - must return a modified version.

- -
- - -

void afterVertex

- -
- - -

Called at the end of the vertex shader.

- -
- - -

void beforeFragment

- -
- - -

Called at the start of the fragment shader.

- -
- - -

Inputs getPixelInputs

- -
- - -

Update the per-pixel inputs of the material. It takes in an - Inputs struct, which includes:

- -
    - -
  • vec3 normal, the direction pointing out of the surface
  • - -
  • vec2 texCoord, a vector where x and - y are between 0 and 1 describing the spot on a texture the pixel - is mapped to, as a fraction of the texture size
  • - -
  • vec3 ambientLight, the ambient light color on the vertex
  • - -
  • vec4 color, the base material color of the pixel
  • - -
  • vec3 ambientMaterial, the color of the pixel when affected by - ambient light
  • - -
  • vec3 specularMaterial, the color of the pixel when reflecting - specular highlights
  • - -
  • vec3 emissiveMaterial, the light color emitted by the - pixel
  • - -
  • float shininess, a number representing how sharp specular - reflections should be, from 1 to infinity
  • - -
  • float metalness, a number representing how mirrorlike the - material should be, between 0 and 1 - - The struct can be modified and returned.
- - -

vec4 combineColors

- -
- - -

Take in a ColorComponents struct containing all the different - components of light, and combining them into - - a single final color. The struct contains:

- -
    - -
  • vec3 baseColor, the base color of the pixel
  • - -
  • float opacity, the opacity between 0 and 1 that it should be - drawn at
  • - -
  • vec3 ambientColor, the color of the pixel when affected by - ambient light
  • - -
  • vec3 specularColor, the color of the pixel when affected by - specular reflections
  • - -
  • vec3 diffuse, the amount of diffused light hitting the - pixel
  • - -
  • vec3 ambient, the amount of ambient light hitting the - pixel
  • - -
  • vec3 specular, the amount of specular reflection hitting the - pixel
  • - -
  • vec3 emissive, the amount of light emitted by the pixel
  • - -
- -
- - -

vec4 getFinalColor

- -
- - -

Update the final color after mixing. It takes in a vec4 color - and must return a modified version.

- -
- - -

void afterFragment

- -
- - -

Called at the end of the fragment shader.

- -
- - -

Most of the time, you will need to write your hooks in GLSL ES version 300. - If you - - are using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.

- -

Call baseMaterialShader().inspectHooks() to see all the - possible hooks and - - their default implementations.

-line: 886 -isConstructor: false -itemtype: method -example: - - |- - -
- - let myShader; - - function setup() { - createCanvas(200, 200, WEBGL); - myShader = baseMaterialShader().modify({ - uniforms: { - 'float time': () => millis() - }, - 'vec3 getWorldPosition': `(vec3 pos) { - pos.y += 20.0 * sin(time * 0.001 + pos.x * 0.05); - return pos; - }` - }); - } - - function draw() { - background(255); - shader(myShader); - lights(); - noStroke(); - fill('red'); - sphere(50); - } - -
- - |- - -
- - let myShader; - - function setup() { - createCanvas(200, 200, WEBGL); - myShader = baseMaterialShader().modify({ - declarations: 'vec3 myNormal;', - 'Inputs getPixelInputs': `(Inputs inputs) { - myNormal = inputs.normal; - return inputs; - }`, - 'vec4 getFinalColor': `(vec4 color) { - return mix( - vec4(1.0, 1.0, 1.0, 1.0), - color, - abs(dot(myNormal, vec3(0.0, 0.0, 1.0))) - ); - }` - }); - } - - function draw() { - background(255); - rotateY(millis() * 0.001); - shader(myShader); - lights(); - noStroke(); - fill('red'); - torus(30); - } - -
- - |- - -
- - let myShader; - let environment; - - function preload() { - environment = loadImage('/assets/outdoor_spheremap.jpg'); - } - - function setup() { - createCanvas(200, 200, WEBGL); - myShader = baseMaterialShader().modify({ - 'Inputs getPixelInputs': `(Inputs inputs) { - float factor = - sin( - inputs.texCoord.x * ${TWO_PI} + - inputs.texCoord.y * ${TWO_PI} - ) * 0.4 + 0.5; - inputs.shininess = mix(1., 100., factor); - inputs.metalness = factor; - return inputs; - }` - }); - } - - function draw() { - panorama(environment); - ambientLight(100); - imageLight(environment); - rotateY(millis() * 0.001); - shader(myShader); - noStroke(); - fill(255); - specularMaterial(150); - sphere(50); - } - -
- - |- - -
- - let myShader; - - function setup() { - createCanvas(200, 200, WEBGL); - myShader = baseMaterialShader().modify({ - 'Inputs getPixelInputs': `(Inputs inputs) { - vec3 newNormal = inputs.normal; - // Simple bump mapping: adjust the normal based on position - newNormal.x += 0.2 * sin( - sin( - inputs.texCoord.y * ${TWO_PI} * 10.0 + - inputs.texCoord.x * ${TWO_PI} * 25.0 - ) - ); - newNormal.y += 0.2 * sin( - sin( - inputs.texCoord.x * ${TWO_PI} * 10.0 + - inputs.texCoord.y * ${TWO_PI} * 25.0 - ) - ); - inputs.normal = normalize(newNormal); - return inputs; - }` - }); - } - - function draw() { - background(255); - shader(myShader); - ambientLight(150); - pointLight( - 255, 255, 255, - 100*cos(frameCount*0.04), -50, 100*sin(frameCount*0.04) - ); - noStroke(); - fill('red'); - shininess(200); - specularMaterial(255); - sphere(50); - } - -
-class: p5 -return: - description: The material shader - type: p5.Shader -chainable: false -beta: true ---- - - -# baseMaterialShader diff --git a/src/content/reference/en/p5 copy/baseNormalShader.mdx b/src/content/reference/en/p5 copy/baseNormalShader.mdx deleted file mode 100644 index 4eac6e9109..0000000000 --- a/src/content/reference/en/p5 copy/baseNormalShader.mdx +++ /dev/null @@ -1,211 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1197 -title: baseNormalShader -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Get the shader used by normalMaterial().

- -

You can call baseNormalShader().modify() - - and change any of the following hooks:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HookDescription
void beforeVertexCalled at the start of the vertex shader.
vec3 getLocalPositionUpdate the position of vertices before transforms are applied. It takes in - vec3 position and must return a modified version.
vec3 getWorldPositionUpdate the position of vertices after transforms are applied. It takes in - vec3 position and pust return a modified version.
vec3 getLocalNormalUpdate the normal before transforms are applied. It takes in vec3 - normal and must return a modified version.
vec3 getWorldNormalUpdate the normal after transforms are applied. It takes in vec3 - normal and must return a modified version.
vec2 getUVUpdate the texture coordinates. It takes in vec2 uv and must - return a modified version.
vec4 getVertexColorUpdate the color of each vertex. It takes in a vec4 color and - must return a modified version.
void afterVertexCalled at the end of the vertex shader.
void beforeFragmentCalled at the start of the fragment shader.
vec4 getFinalColorUpdate the final color after mixing. It takes in a vec4 color - and must return a modified version.
void afterFragmentCalled at the end of the fragment shader.
- -

Most of the time, you will need to write your hooks in GLSL ES version 300. - If you - - are using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.

- -

Call baseNormalShader().inspectHooks() to see all the possible - hooks and - - their default implementations.

-line: 1197 -isConstructor: false -itemtype: method -example: - - |- - -
- - let myShader; - - function setup() { - createCanvas(200, 200, WEBGL); - myShader = baseNormalShader().modify({ - uniforms: { - 'float time': () => millis() - }, - 'vec3 getWorldPosition': `(vec3 pos) { - pos.y += 20. * sin(time * 0.001 + pos.x * 0.05); - return pos; - }` - }); - } - - function draw() { - background(255); - shader(myShader); - noStroke(); - sphere(50); - } - -
- - |- - -
- - let myShader; - - function setup() { - createCanvas(200, 200, WEBGL); - myShader = baseNormalShader().modify({ - 'vec3 getWorldNormal': '(vec3 normal) { return abs(normal); }', - 'vec4 getFinalColor': `(vec4 color) { - // Map the r, g, and b values of the old normal to new colors - // instead of just red, green, and blue: - vec3 newColor = - color.r * vec3(89.0, 240.0, 232.0) / 255.0 + - color.g * vec3(240.0, 237.0, 89.0) / 255.0 + - color.b * vec3(205.0, 55.0, 222.0) / 255.0; - newColor = newColor / (color.r + color.g + color.b); - return vec4(newColor, 1.0) * color.a; - }` - }); - } - - function draw() { - background(255); - shader(myShader); - noStroke(); - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.015); - box(100); - } - -
-class: p5 -return: - description: The `normalMaterial` shader - type: p5.Shader -chainable: false -beta: true ---- - - -# baseNormalShader diff --git a/src/content/reference/en/p5 copy/baseStrokeShader.mdx b/src/content/reference/en/p5 copy/baseStrokeShader.mdx deleted file mode 100644 index f2bfb42be5..0000000000 --- a/src/content/reference/en/p5 copy/baseStrokeShader.mdx +++ /dev/null @@ -1,356 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1355 -title: baseStrokeShader -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Get the shader used when drawing the strokes of shapes.

- -

You can call baseStrokeShader().modify() - - and change any of the following hooks:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HookDescription
- - -

void beforeVertex

- -
- - -

Called at the start of the vertex shader.

- -
- - -

vec3 getLocalPosition

- -
- - -

Update the position of vertices before transforms are applied. It takes in - vec3 position and must return a modified version.

- -
- - -

vec3 getWorldPosition

- -
- - -

Update the position of vertices after transforms are applied. It takes in - vec3 position and pust return a modified version.

- -
- - -

float getStrokeWeight

- -
- - -

Update the stroke weight. It takes in float weight and pust - return a modified version.

- -
- - -

vec2 getLineCenter

- -
- - -

Update the center of the line. It takes in vec2 center and - must return a modified version.

- -
- - -

vec2 getLinePosition

- -
- - -

Update the position of each vertex on the edge of the line. It takes in - vec2 position and must return a modified version.

- -
- - -

vec4 getVertexColor

- -
- - -

Update the color of each vertex. It takes in a vec4 color and - must return a modified version.

- -
- - -

void afterVertex

- -
- - -

Called at the end of the vertex shader.

- -
- - -

void beforeFragment

- -
- - -

Called at the start of the fragment shader.

- -
- - -

Inputs getPixelInputs

- -
- - -

Update the inputs to the shader. It takes in a struct Inputs - inputs, which includes:

- -
    - -
  • vec4 color, the color of the stroke
  • - -
  • vec2 tangent, the direction of the stroke in screen - space
  • - -
  • vec2 center, the coordinate of the center of the stroke in - screen space p5.js pixels
  • - -
  • vec2 position, the coordinate of the current pixel in screen - space p5.js pixels
  • - -
  • float strokeWeight, the thickness of the stroke in p5.js - pixels
  • - -
- -
- - -

bool shouldDiscard

- -
- - -

Caps and joins are made by discarded pixels in the fragment shader to carve - away unwanted areas. Use this to change this logic. It takes in a bool - willDiscard and must return a modified version.

- -
- - -

vec4 getFinalColor

- -
- - -

Update the final color after mixing. It takes in a vec4 color - and must return a modified version.

- -
- - -

void afterFragment

- -
- - -

Called at the end of the fragment shader.

- -
- - -

Most of the time, you will need to write your hooks in GLSL ES version 300. - If you - - are using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.

- -

Call baseStrokeShader().inspectHooks() to see all the possible - hooks and - - their default implementations.

-line: 1355 -isConstructor: false -itemtype: method -example: - - |- - -
- - let myShader; - - function setup() { - createCanvas(200, 200, WEBGL); - myShader = baseStrokeShader().modify({ - 'Inputs getPixelInputs': `(Inputs inputs) { - float opacity = 1.0 - smoothstep( - 0.0, - 15.0, - length(inputs.position - inputs.center) - ); - inputs.color *= opacity; - return inputs; - }` - }); - } - - function draw() { - background(255); - shader(myShader); - strokeWeight(30); - line( - -width/3, - sin(millis()*0.001) * height/4, - width/3, - sin(millis()*0.001 + 1) * height/4 - ); - } - -
- - |- - -
- - let myShader; - - function setup() { - createCanvas(200, 200, WEBGL); - myShader = baseStrokeShader().modify({ - uniforms: { - 'float time': () => millis() - }, - declarations: 'vec3 myPosition;', - 'vec3 getWorldPosition': `(vec3 pos) { - myPosition = pos; - return pos; - }`, - 'float getStrokeWeight': `(float w) { - // Add a somewhat random offset to the weight - // that varies based on position and time - float scale = 0.8 + 0.2*sin(10.0 * sin( - floor(time/250.) + - myPosition.x*0.01 + - myPosition.y*0.01 - )); - return w * scale; - }` - }); - } - - function draw() { - background(255); - shader(myShader); - myShader.setUniform('time', millis()); - strokeWeight(10); - beginShape(); - for (let i = 0; i <= 50; i++) { - let r = map(i, 0, 50, 0, width/3); - let x = r*cos(i*0.2); - let y = r*sin(i*0.2); - vertex(x, y); - } - endShape(); - } - -
- - |- - -
- - let myShader; - - function setup() { - createCanvas(200, 200, WEBGL); - myShader = baseStrokeShader().modify({ - 'float random': `(vec2 p) { - vec3 p3 = fract(vec3(p.xyx) * .1031); - p3 += dot(p3, p3.yzx + 33.33); - return fract((p3.x + p3.y) * p3.z); - }`, - 'Inputs getPixelInputs': `(Inputs inputs) { - // Replace alpha in the color with dithering by - // randomly setting pixel colors to 0 based on opacity - float a = inputs.color.a; - inputs.color.a = 1.0; - inputs.color *= random(inputs.position.xy) > a ? 0.0 : 1.0; - return inputs; - }` - }); - } - - function draw() { - background(255); - shader(myShader); - strokeWeight(10); - beginShape(); - for (let i = 0; i <= 50; i++) { - stroke( - 0, - 255 - * map(i, 0, 20, 0, 1, true) - * map(i, 30, 50, 1, 0, true) - ); - vertex( - map(i, 0, 50, -1, 1) * width/3, - 50 * sin(i/10 + frameCount/100) - ); - } - endShape(); - } - -
-class: p5 -return: - description: The stroke shader - type: p5.Shader -chainable: false -beta: true ---- - - -# baseStrokeShader diff --git a/src/content/reference/en/p5 copy/beginClip.mdx b/src/content/reference/en/p5 copy/beginClip.mdx deleted file mode 100644 index ebad022a68..0000000000 --- a/src/content/reference/en/p5 copy/beginClip.mdx +++ /dev/null @@ -1,208 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L13 -title: beginClip -module: Color -submodule: Setting -file: src/color/setting.js -description: > -

Starts defining a shape that will mask any shapes drawn afterward.

- -

Any shapes drawn between beginClip() and - - endClip() will add to the mask shape. The - mask - - will apply to anything drawn after endClip().

- -

The parameter, options, is optional. If an object with an - invert - - property is passed, as in beginClip({ invert: true }), it will be - used to - - set the masking mode. { invert: true } inverts the mask, creating - holes - - in shapes that are masked. invert is false by - default.

- -

Masks can be contained between the - - push() and pop() functions. - - Doing so allows unmasked shapes to be drawn after masked shapes.

- -

Masks can also be defined in a callback function that's passed to - - clip().

-line: 13 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a mask. - beginClip(); - triangle(15, 37, 30, 13, 43, 37); - circle(45, 45, 7); - endClip(); - - // Draw a backing shape. - square(5, 5, 45); - - describe('A white triangle and circle on a gray background.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an inverted mask. - beginClip({ invert: true }); - triangle(15, 37, 30, 13, 43, 37); - circle(45, 45, 7); - endClip(); - - // Draw a backing shape. - square(5, 5, 45); - - describe('A white square at the top-left corner of a gray square. The white square has a triangle and a circle cut out of it.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - noStroke(); - - // Draw a masked shape. - push(); - // Create a mask. - beginClip(); - triangle(15, 37, 30, 13, 43, 37); - circle(45, 45, 7); - endClip(); - - // Draw a backing shape. - square(5, 5, 45); - pop(); - - // Translate the origin to the center. - translate(50, 50); - - // Draw an inverted masked shape. - push(); - // Create an inverted mask. - beginClip({ invert: true }); - triangle(15, 37, 30, 13, 43, 37); - circle(45, 45, 7); - endClip(); - - // Draw a backing shape. - square(5, 5, 45); - pop(); - - describe('In the top left, a white triangle and circle. In the bottom right, a white square with a triangle and circle cut out of it.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A silhouette of a rotating torus colored fuchsia.'); - } - - function draw() { - background(200); - - // Create a mask. - beginClip(); - push(); - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - scale(0.5); - torus(30, 15); - pop(); - endClip(); - - // Draw a backing shape. - noStroke(); - fill('fuchsia'); - plane(100); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A silhouette of a rotating torus colored with a gradient from cyan to purple.'); - } - - function draw() { - background(200); - - // Create a mask. - beginClip(); - push(); - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - scale(0.5); - torus(30, 15); - pop(); - endClip(); - - // Draw a backing shape. - noStroke(); - beginShape(QUAD_STRIP); - fill(0, 255, 255); - vertex(-width / 2, -height / 2); - vertex(width / 2, -height / 2); - fill(100, 0, 100); - vertex(-width / 2, height / 2); - vertex(width / 2, height / 2); - endShape(); - } - -
-class: p5 -params: - - name: options - description: | -

an object containing clip settings.

- type: Object - optional: true -chainable: false ---- - - -# beginClip diff --git a/src/content/reference/en/p5 copy/beginContour.mdx b/src/content/reference/en/p5 copy/beginContour.mdx deleted file mode 100644 index 5ecd6d1437..0000000000 --- a/src/content/reference/en/p5 copy/beginContour.mdx +++ /dev/null @@ -1,134 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L20 -title: beginContour -module: Shape -submodule: Vertex -file: src/core/shape/vertex.js -description: > -

Begins creating a hole within a flat shape.

- -

The beginContour() and endContour() - - functions allow for creating negative space within custom shapes that are - - flat. beginContour() begins adding vertices to a negative space - and - - endContour() stops adding them. - - beginContour() and endContour() must be - - called between beginShape() and - - endShape().

- -

Transformations such as translate(), - - rotate(), and scale() - - don't work between beginContour() and - - endContour(). It's also not possible - to use - - other shapes, such as ellipse() or - - rect(), between beginContour() - and - - endContour().

- -

Note: The vertices that define a negative space must "wind" in the opposite - - direction from the outer shape. First, draw vertices for the outer shape - - clockwise order. Then, draw vertices for the negative space in - - counter-clockwise order.

-line: 20 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - beginShape(); - - // Exterior vertices, clockwise winding. - vertex(10, 10); - vertex(90, 10); - vertex(90, 90); - vertex(10, 90); - - // Interior vertices, counter-clockwise winding. - beginContour(); - vertex(30, 30); - vertex(30, 70); - vertex(70, 70); - vertex(70, 30); - endContour(); - - // Stop drawing the shape. - endShape(CLOSE); - - describe('A white square with a square hole in its center drawn on a gray background.'); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white square with a square hole in its center drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Start drawing the shape. - beginShape(); - - // Exterior vertices, clockwise winding. - vertex(-40, -40); - vertex(40, -40); - vertex(40, 40); - vertex(-40, 40); - - // Interior vertices, counter-clockwise winding. - beginContour(); - vertex(-20, -20); - vertex(-20, 20); - vertex(20, 20); - vertex(20, -20); - endContour(); - - // Stop drawing the shape. - endShape(CLOSE); - } - -
-class: p5 -chainable: true ---- - - -# beginContour diff --git a/src/content/reference/en/p5 copy/beginGeometry.mdx b/src/content/reference/en/p5 copy/beginGeometry.mdx deleted file mode 100644 index 3fdf211bd3..0000000000 --- a/src/content/reference/en/p5 copy/beginGeometry.mdx +++ /dev/null @@ -1,281 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L13 -title: beginGeometry -module: Shape -submodule: 3D Primitives -file: src/webgl/3d_primitives.js -description: > -

Begins adding shapes to a new - - p5.Geometry object.

- -

The beginGeometry() and endGeometry() - - functions help with creating complex 3D shapes from simpler ones such as - - sphere(). beginGeometry() - begins adding shapes - - to a custom p5.Geometry object and - - endGeometry() stops adding them.

- -

beginGeometry() and endGeometry() can help - - to make sketches more performant. For example, if a complex 3D shape - - doesn’t change while a sketch runs, then it can be created with - - beginGeometry() and endGeometry(). - - Creating a p5.Geometry object once and - then - - drawing it will run faster than repeatedly drawing the individual pieces.

- -

See buildGeometry() for another - way to - - build 3D shapes.

- -

Note: beginGeometry() can only be used in WebGL mode.

-line: 13 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Start building the p5.Geometry object. - beginGeometry(); - - // Add a cone. - cone(); - - // Stop building the p5.Geometry object. - shape = endGeometry(); - - describe('A white cone drawn on a gray background.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the p5.Geometry object. - noStroke(); - - // Draw the p5.Geometry object. - model(shape); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the p5.Geometry object. - createArrow(); - - describe('A white arrow drawn on a gray background.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the p5.Geometry object. - noStroke(); - - // Draw the p5.Geometry object. - model(shape); - } - - function createArrow() { - // Start building the p5.Geometry object. - beginGeometry(); - - // Add shapes. - push(); - rotateX(PI); - cone(10); - translate(0, -10, 0); - cylinder(3, 20); - pop(); - - // Stop building the p5.Geometry object. - shape = endGeometry(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let blueArrow; - let redArrow; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the arrows. - redArrow = createArrow('red'); - blueArrow = createArrow('blue'); - - describe('A red arrow and a blue arrow drawn on a gray background. The blue arrow rotates slowly.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the arrows. - noStroke(); - - // Draw the red arrow. - model(redArrow); - - // Translate and rotate the coordinate system. - translate(30, 0, 0); - rotateZ(frameCount * 0.01); - - // Draw the blue arrow. - model(blueArrow); - } - - function createArrow(fillColor) { - // Start building the p5.Geometry object. - beginGeometry(); - - fill(fillColor); - - // Add shapes to the p5.Geometry object. - push(); - rotateX(PI); - cone(10); - translate(0, -10, 0); - cylinder(3, 20); - pop(); - - // Stop building the p5.Geometry object. - let shape = endGeometry(); - - return shape; - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let button; - let particles; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a button to reset the particle system. - button = createButton('Reset'); - - // Call resetModel() when the user presses the button. - button.mousePressed(resetModel); - - // Add the original set of particles. - resetModel(); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the particles. - noStroke(); - - // Draw the particles. - model(particles); - } - - function resetModel() { - // If the p5.Geometry object has already been created, - // free those resources. - if (particles) { - freeGeometry(particles); - } - - // Create a new p5.Geometry object with random spheres. - particles = createParticles(); - } - - function createParticles() { - // Start building the p5.Geometry object. - beginGeometry(); - - // Add shapes. - for (let i = 0; i < 60; i += 1) { - // Calculate random coordinates. - let x = randomGaussian(0, 20); - let y = randomGaussian(0, 20); - let z = randomGaussian(0, 20); - - push(); - // Translate to the particle's coordinates. - translate(x, y, z); - // Draw the particle. - sphere(5); - pop(); - } - - // Stop building the p5.Geometry object. - let shape = endGeometry(); - - return shape; - } - -
-class: p5 -chainable: false ---- - - -# beginGeometry diff --git a/src/content/reference/en/p5 copy/beginShape.mdx b/src/content/reference/en/p5 copy/beginShape.mdx deleted file mode 100644 index d8642333db..0000000000 --- a/src/content/reference/en/p5 copy/beginShape.mdx +++ /dev/null @@ -1,449 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L129 -title: beginShape -module: Shape -submodule: Vertex -file: src/core/shape/vertex.js -description: > -

Begins adding vertices to a custom shape.

- -

The beginShape() and endShape() functions - - allow for creating custom shapes in 2D or 3D. beginShape() begins - adding - - vertices to a custom shape and endShape() stops - - adding them.

- -

The parameter, kind, sets the kind of shape to make. By - default, any - - irregular polygon can be drawn. The available modes for kind are:

- -
    - -
  • POINTS to draw a series of points.
  • - -
  • LINES to draw a series of unconnected line segments.
  • - -
  • TRIANGLES to draw a series of separate triangles.
  • - -
  • TRIANGLE_FAN to draw a series of connected triangles sharing - the first vertex in a fan-like fashion.
  • - -
  • TRIANGLE_STRIP to draw a series of connected triangles in - strip fashion.
  • - -
  • QUADS to draw a series of separate quadrilaterals - (quads).
  • - -
  • QUAD_STRIP to draw quad strip using adjacent edges to form - the next quad.
  • - -
  • TESS to create a filling curve by explicit tessellation - (WebGL only).
  • - -
- -

After calling beginShape(), shapes can be built by calling - - vertex(), - - bezierVertex(), - - quadraticVertex(), and/or - - curveVertex(). Calling - - endShape() will stop adding vertices to - the - - shape. Each shape will be outlined with the current stroke color and filled - - with the current fill color.

- -

Transformations such as translate(), - - rotate(), and - - scale() don't work between - beginShape() and - - endShape(). It's also not possible to - use - - other shapes, such as ellipse() or - - rect(), between beginShape() - and - - endShape().

-line: 129 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - beginShape(); - - // Add vertices. - vertex(30, 20); - vertex(85, 20); - vertex(85, 75); - vertex(30, 75); - - // Stop drawing the shape. - endShape(CLOSE); - - describe('A white square on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - // Only draw the vertices (points). - beginShape(POINTS); - - // Add vertices. - vertex(30, 20); - vertex(85, 20); - vertex(85, 75); - vertex(30, 75); - - // Stop drawing the shape. - endShape(); - - describe('Four black dots that form a square are drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - // Only draw lines between alternating pairs of vertices. - beginShape(LINES); - - // Add vertices. - vertex(30, 20); - vertex(85, 20); - vertex(85, 75); - vertex(30, 75); - - // Stop drawing the shape. - endShape(); - - describe('Two horizontal black lines on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the shape. - noFill(); - - // Start drawing the shape. - beginShape(); - - // Add vertices. - vertex(30, 20); - vertex(85, 20); - vertex(85, 75); - vertex(30, 75); - - // Stop drawing the shape. - endShape(); - - describe('Three black lines form a sideways U shape on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the shape. - noFill(); - - // Start drawing the shape. - beginShape(); - - // Add vertices. - vertex(30, 20); - vertex(85, 20); - vertex(85, 75); - vertex(30, 75); - - // Stop drawing the shape. - // Connect the first and last vertices. - endShape(CLOSE); - - describe('A black outline of a square drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - // Draw a series of triangles. - beginShape(TRIANGLES); - - // Left triangle. - vertex(30, 75); - vertex(40, 20); - vertex(50, 75); - - // Right triangle. - vertex(60, 20); - vertex(70, 75); - vertex(80, 20); - - // Stop drawing the shape. - endShape(); - - describe('Two white triangles drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - // Draw a series of triangles. - beginShape(TRIANGLE_STRIP); - - // Add vertices. - vertex(30, 75); - vertex(40, 20); - vertex(50, 75); - vertex(60, 20); - vertex(70, 75); - vertex(80, 20); - vertex(90, 75); - - // Stop drawing the shape. - endShape(); - - describe('Five white triangles that are interleaved drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - // Draw a series of triangles that share their first vertex. - beginShape(TRIANGLE_FAN); - - // Add vertices. - vertex(57.5, 50); - vertex(57.5, 15); - vertex(92, 50); - vertex(57.5, 85); - vertex(22, 50); - vertex(57.5, 15); - - // Stop drawing the shape. - endShape(); - - describe('Four white triangles form a square are drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - // Draw a series of quadrilaterals. - beginShape(QUADS); - - // Left rectangle. - vertex(30, 20); - vertex(30, 75); - vertex(50, 75); - vertex(50, 20); - - // Right rectangle. - vertex(65, 20); - vertex(65, 75); - vertex(85, 75); - vertex(85, 20); - - // Stop drawing the shape. - endShape(); - - describe('Two white rectangles drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - // Draw a series of quadrilaterals. - beginShape(QUAD_STRIP); - - // Add vertices. - vertex(30, 20); - vertex(30, 75); - vertex(50, 20); - vertex(50, 75); - vertex(65, 20); - vertex(65, 75); - vertex(85, 20); - vertex(85, 75); - - // Stop drawing the shape. - endShape(); - - describe('Three white rectangles that share edges are drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - // Start drawing the shape. - // Draw a series of quadrilaterals. - beginShape(TESS); - - // Add the vertices. - vertex(-30, -30, 0); - vertex(30, -30, 0); - vertex(30, -10, 0); - vertex(-10, -10, 0); - vertex(-10, 10, 0); - vertex(30, 10, 0); - vertex(30, 30, 0); - vertex(-30, 30, 0); - - // Stop drawing the shape. - // Connect the first and last vertices. - endShape(CLOSE); - - describe('A blocky C shape drawn in white on a gray background.'); - } - -
- -
- - // Click and drag with the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A blocky C shape drawn in red, blue, and green on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Start drawing the shape. - // Draw a series of quadrilaterals. - beginShape(TESS); - - // Add the vertices. - fill('red'); - stroke('red'); - vertex(-30, -30, 0); - vertex(30, -30, 0); - vertex(30, -10, 0); - fill('green'); - stroke('green'); - vertex(-10, -10, 0); - vertex(-10, 10, 0); - vertex(30, 10, 0); - fill('blue'); - stroke('blue'); - vertex(30, 30, 0); - vertex(-30, 30, 0); - - // Stop drawing the shape. - // Connect the first and last vertices. - endShape(CLOSE); - } - -
-class: p5 -params: - - name: kind - description: | -

either POINTS, LINES, TRIANGLES, TRIANGLE_FAN - TRIANGLE_STRIP, QUADS, QUAD_STRIP or TESS.

- type: Constant - optional: true -chainable: true ---- - - -# beginShape diff --git a/src/content/reference/en/p5 copy/bezier.mdx b/src/content/reference/en/p5 copy/bezier.mdx deleted file mode 100644 index 50c15330b7..0000000000 --- a/src/content/reference/en/p5 copy/bezier.mdx +++ /dev/null @@ -1,273 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L13 -title: bezier -module: Shape -submodule: Curves -file: src/core/shape/curves.js -description: > -

Draws a Bézier curve.

- -

Bézier curves can form shapes and curves that slope gently. They're defined - - by two anchor points and two control points. Bézier curves provide more - - control than the spline curves created with the - - curve() function.

- -

The first two parameters, x1 and y1, set the - first anchor point. The - - first anchor point is where the curve starts.

- -

The next four parameters, x2, y2, - x3, and y3, set the two control - - points. The control points "pull" the curve towards them.

- -

The seventh and eighth parameters, x4 and y4, set - the last anchor - - point. The last anchor point is where the curve ends.

- -

Bézier curves can also be drawn in 3D using WebGL mode. The 3D version of - - bezier() has twelve arguments because each point has x-, y-, - - and z-coordinates.

-line: 13 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw the anchor points in black. - stroke(0); - strokeWeight(5); - point(85, 20); - point(15, 80); - - // Draw the control points in red. - stroke(255, 0, 0); - point(10, 10); - point(90, 90); - - // Draw a black bezier curve. - noFill(); - stroke(0); - strokeWeight(1); - bezier(85, 20, 10, 10, 90, 90, 15, 80); - - // Draw red lines from the anchor points to the control points. - stroke(255, 0, 0); - line(85, 20, 10, 10); - line(15, 80, 90, 90); - - describe( - 'A gray square with three curves. A black s-curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' - ); - } - -
- -
- - // Click the mouse near the red dot in the top-left corner - // and drag to change the curve's shape. - - let x2 = 10; - let y2 = 10; - let isChanging = false; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with three curves. A black s-curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' - ); - } - - function draw() { - background(200); - - // Draw the anchor points in black. - stroke(0); - strokeWeight(5); - point(85, 20); - point(15, 80); - - // Draw the control points in red. - stroke(255, 0, 0); - point(x2, y2); - point(90, 90); - - // Draw a black bezier curve. - noFill(); - stroke(0); - strokeWeight(1); - bezier(85, 20, x2, y2, 90, 90, 15, 80); - - // Draw red lines from the anchor points to the control points. - stroke(255, 0, 0); - line(85, 20, x2, y2); - line(15, 80, 90, 90); - } - - // Start changing the first control point if the user clicks near it. - function mousePressed() { - if (dist(mouseX, mouseY, x2, y2) < 20) { - isChanging = true; - } - } - - // Stop changing the first control point when the user releases the mouse. - function mouseReleased() { - isChanging = false; - } - - // Update the first control point while the user drags the mouse. - function mouseDragged() { - if (isChanging === true) { - x2 = mouseX; - y2 = mouseY; - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background('skyblue'); - - // Draw the red balloon. - fill('red'); - bezier(50, 60, 5, 15, 95, 15, 50, 60); - - // Draw the balloon string. - line(50, 60, 50, 80); - - describe('A red balloon in a blue sky.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A red balloon in a blue sky. The balloon rotates slowly, revealing that it is flat.'); - } - - function draw() { - background('skyblue'); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Draw the red balloon. - fill('red'); - bezier(0, 0, 0, -45, -45, 0, 45, -45, 0, 0, 0, 0); - - // Draw the balloon string. - line(0, 0, 0, 0, 20, 0); - } - -
-class: p5 -overloads: - - line: 13 - params: - - name: x1 - description: | -

x-coordinate of the first anchor point.

- type: Number - - name: y1 - description: | -

y-coordinate of the first anchor point.

- type: Number - - name: x2 - description: | -

x-coordinate of the first control point.

- type: Number - - name: y2 - description: | -

y-coordinate of the first control point.

- type: Number - - name: x3 - description: | -

x-coordinate of the second control point.

- type: Number - - name: y3 - description: | -

y-coordinate of the second control point.

- type: Number - - name: x4 - description: | -

x-coordinate of the second anchor point.

- type: Number - - name: y4 - description: | -

y-coordinate of the second anchor point.

- type: Number - chainable: 1 - - line: 191 - params: - - name: x1 - description: '' - type: Number - - name: y1 - description: '' - type: Number - - name: z1 - description: | -

z-coordinate of the first anchor point.

- type: Number - - name: x2 - description: '' - type: Number - - name: y2 - description: '' - type: Number - - name: z2 - description: | -

z-coordinate of the first control point.

- type: Number - - name: x3 - description: '' - type: Number - - name: y3 - description: '' - type: Number - - name: z3 - description: | -

z-coordinate of the second control point.

- type: Number - - name: x4 - description: '' - type: Number - - name: y4 - description: '' - type: Number - - name: z4 - description: | -

z-coordinate of the second anchor point.

- type: Number - chainable: 1 -chainable: true ---- - - -# bezier diff --git a/src/content/reference/en/p5 copy/bezierDetail.mdx b/src/content/reference/en/p5 copy/bezierDetail.mdx deleted file mode 100644 index b4f895a3fc..0000000000 --- a/src/content/reference/en/p5 copy/bezierDetail.mdx +++ /dev/null @@ -1,121 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L221 -title: bezierDetail -module: Shape -submodule: Curves -file: src/core/shape/curves.js -description: > -

Sets the number of segments used to draw Bézier curves in WebGL mode.

- -

In WebGL mode, smooth shapes are drawn using many flat segments. Adding - - more flat segments makes shapes appear smoother.

- -

The parameter, detail, is the number of segments to use while - drawing a - - Bézier curve. For example, calling bezierDetail(5) will use 5 - segments to - - draw curves with the bezier() function. By - - default,detail is 20.

- -

Note: bezierDetail() has no effect in 2D mode.

-line: 221 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Draw the original curve. - - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw the anchor points in black. - stroke(0); - strokeWeight(5); - point(85, 20); - point(15, 80); - - // Draw the control points in red. - stroke(255, 0, 0); - point(10, 10); - point(90, 90); - - // Draw a black bezier curve. - noFill(); - stroke(0); - strokeWeight(1); - bezier(85, 20, 10, 10, 90, 90, 15, 80); - - // Draw red lines from the anchor points to the control points. - stroke(255, 0, 0); - line(85, 20, 10, 10); - line(15, 80, 90, 90); - - describe( - 'A gray square with three curves. A black s-curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' - ); - } - -
- -
- - // Draw the curve with less detail. - - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - // Set the curveDetail() to 5. - bezierDetail(5); - - // Draw the anchor points in black. - stroke(0); - strokeWeight(5); - point(35, -30, 0); - point(-35, 30, 0); - - // Draw the control points in red. - stroke(255, 0, 0); - point(-40, -40, 0); - point(40, 40, 0); - - // Draw a black bezier curve. - noFill(); - stroke(0); - strokeWeight(1); - bezier(35, -30, 0, -40, -40, 0, 40, 40, 0, -35, 30, 0); - - // Draw red lines from the anchor points to the control points. - stroke(255, 0, 0); - line(35, -30, -40, -40); - line(-35, 30, 40, 40); - - describe( - 'A gray square with three curves. A black s-curve is drawn with jagged segments. Two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' - ); - } - -
-class: p5 -params: - - name: detail - description: | -

number of segments to use. Defaults to 20.

- type: Number -chainable: true ---- - - -# bezierDetail diff --git a/src/content/reference/en/p5 copy/bezierPoint.mdx b/src/content/reference/en/p5 copy/bezierPoint.mdx deleted file mode 100644 index a42c171121..0000000000 --- a/src/content/reference/en/p5 copy/bezierPoint.mdx +++ /dev/null @@ -1,162 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L324 -title: bezierPoint -module: Shape -submodule: Curves -file: src/core/shape/curves.js -description: > -

Calculates coordinates along a Bézier curve using interpolation.

- -

bezierPoint() calculates coordinates along a Bézier curve - using the - - anchor and control points. It expects points in the same order as the - - bezier() function. - bezierPoint() works one axis - - at a time. Passing the anchor and control points' x-coordinates will - - calculate the x-coordinate of a point on the curve. Passing the anchor and - - control points' y-coordinates will calculate the y-coordinate of a point on - - the curve.

- -

The first parameter, a, is the coordinate of the first anchor - point.

- -

The second and third parameters, b and c, are the - coordinates of the - - control points.

- -

The fourth parameter, d, is the coordinate of the last anchor - point.

- -

The fifth parameter, t, is the amount to interpolate along the - curve. 0 - - is the first anchor point, 1 is the second anchor point, and 0.5 is halfway - - between them.

-line: 324 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Set the coordinates for the curve's anchor and control points. - let x1 = 85; - let x2 = 10; - let x3 = 90; - let x4 = 15; - let y1 = 20; - let y2 = 10; - let y3 = 90; - let y4 = 80; - - // Style the curve. - noFill(); - - // Draw the curve. - bezier(x1, y1, x2, y2, x3, y3, x4, y4); - - // Draw circles along the curve's path. - fill(255); - - // Top-right. - let x = bezierPoint(x1, x2, x3, x4, 0); - let y = bezierPoint(y1, y2, y3, y4, 0); - circle(x, y, 5); - - // Center. - x = bezierPoint(x1, x2, x3, x4, 0.5); - y = bezierPoint(y1, y2, y3, y4, 0.5); - circle(x, y, 5); - - // Bottom-left. - x = bezierPoint(x1, x2, x3, x4, 1); - y = bezierPoint(y1, y2, y3, y4, 1); - circle(x, y, 5); - - describe('A black s-curve on a gray square. The endpoints and center of the curve are marked with white circles.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A black s-curve on a gray square. A white circle moves back and forth along the curve.'); - } - - function draw() { - background(200); - - // Set the coordinates for the curve's anchor and control points. - let x1 = 85; - let x2 = 10; - let x3 = 90; - let x4 = 15; - let y1 = 20; - let y2 = 10; - let y3 = 90; - let y4 = 80; - - // Draw the curve. - noFill(); - bezier(x1, y1, x2, y2, x3, y3, x4, y4); - - // Calculate the circle's coordinates. - let t = 0.5 * sin(frameCount * 0.01) + 0.5; - let x = bezierPoint(x1, x2, x3, x4, t); - let y = bezierPoint(y1, y2, y3, y4, t); - - // Draw the circle. - fill(255); - circle(x, y, 5); - } - -
-class: p5 -params: - - name: a - description: | -

coordinate of first anchor point.

- type: Number - - name: b - description: | -

coordinate of first control point.

- type: Number - - name: c - description: | -

coordinate of second control point.

- type: Number - - name: d - description: | -

coordinate of second anchor point.

- type: Number - - name: t - description: | -

amount to interpolate between 0 and 1.

- type: Number -return: - description: coordinate of the point on the curve. - type: Number -chainable: false ---- - - -# bezierPoint diff --git a/src/content/reference/en/p5 copy/bezierTangent.mdx b/src/content/reference/en/p5 copy/bezierTangent.mdx deleted file mode 100644 index 8fb0edfaa8..0000000000 --- a/src/content/reference/en/p5 copy/bezierTangent.mdx +++ /dev/null @@ -1,155 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L450 -title: bezierTangent -module: Shape -submodule: Curves -file: src/core/shape/curves.js -description: > -

Calculates coordinates along a line that's tangent to a Bézier curve.

- -

Tangent lines skim the surface of a curve. A tangent line's slope equals - - the curve's slope at the point where it intersects.

- -

bezierTangent() calculates coordinates along a tangent line - using the - - Bézier curve's anchor and control points. It expects points in the same - - order as the bezier() function. - bezierTangent() - - works one axis at a time. Passing the anchor and control points' - - x-coordinates will calculate the x-coordinate of a point on the tangent - - line. Passing the anchor and control points' y-coordinates will calculate - - the y-coordinate of a point on the tangent line.

- -

The first parameter, a, is the coordinate of the first anchor - point.

- -

The second and third parameters, b and c, are the - coordinates of the - - control points.

- -

The fourth parameter, d, is the coordinate of the last anchor - point.

- -

The fifth parameter, t, is the amount to interpolate along the - curve. 0 - - is the first anchor point, 1 is the second anchor point, and 0.5 is halfway - - between them.

-line: 450 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Set the coordinates for the curve's anchor and control points. - let x1 = 85; - let x2 = 10; - let x3 = 90; - let x4 = 15; - let y1 = 20; - let y2 = 10; - let y3 = 90; - let y4 = 80; - - // Style the curve. - noFill(); - - // Draw the curve. - bezier(x1, y1, x2, y2, x3, y3, x4, y4); - - // Draw tangents along the curve's path. - fill(255); - - // Top-right circle. - stroke(0); - let x = bezierPoint(x1, x2, x3, x4, 0); - let y = bezierPoint(y1, y2, y3, y4, 0); - circle(x, y, 5); - - // Top-right tangent line. - // Scale the tangent point to draw a shorter line. - stroke(255, 0, 0); - let tx = 0.1 * bezierTangent(x1, x2, x3, x4, 0); - let ty = 0.1 * bezierTangent(y1, y2, y3, y4, 0); - line(x + tx, y + ty, x - tx, y - ty); - - // Center circle. - stroke(0); - x = bezierPoint(x1, x2, x3, x4, 0.5); - y = bezierPoint(y1, y2, y3, y4, 0.5); - circle(x, y, 5); - - // Center tangent line. - // Scale the tangent point to draw a shorter line. - stroke(255, 0, 0); - tx = 0.1 * bezierTangent(x1, x2, x3, x4, 0.5); - ty = 0.1 * bezierTangent(y1, y2, y3, y4, 0.5); - line(x + tx, y + ty, x - tx, y - ty); - - // Bottom-left circle. - stroke(0); - x = bezierPoint(x1, x2, x3, x4, 1); - y = bezierPoint(y1, y2, y3, y4, 1); - circle(x, y, 5); - - // Bottom-left tangent. - // Scale the tangent point to draw a shorter line. - stroke(255, 0, 0); - tx = 0.1 * bezierTangent(x1, x2, x3, x4, 1); - ty = 0.1 * bezierTangent(y1, y2, y3, y4, 1); - line(x + tx, y + ty, x - tx, y - ty); - - describe( - 'A black s-curve on a gray square. The endpoints and center of the curve are marked with white circles. Red tangent lines extend from the white circles.' - ); - } - -
-class: p5 -params: - - name: a - description: | -

coordinate of first anchor point.

- type: Number - - name: b - description: | -

coordinate of first control point.

- type: Number - - name: c - description: | -

coordinate of second control point.

- type: Number - - name: d - description: | -

coordinate of second anchor point.

- type: Number - - name: t - description: | -

amount to interpolate between 0 and 1.

- type: Number -return: - description: coordinate of a point on the tangent line. - type: Number -chainable: false ---- - - -# bezierTangent diff --git a/src/content/reference/en/p5 copy/bezierVertex.mdx b/src/content/reference/en/p5 copy/bezierVertex.mdx deleted file mode 100644 index f4b5fb57cb..0000000000 --- a/src/content/reference/en/p5 copy/bezierVertex.mdx +++ /dev/null @@ -1,337 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L543 -title: bezierVertex -module: Shape -submodule: Vertex -file: src/core/shape/vertex.js -description: > -

Adds a Bézier curve segment to a custom shape.

- -

bezierVertex() adds a curved segment to custom shapes. The - Bézier curves - - it creates are defined like those made by the - - bezier() function. - bezierVertex() must be - - called between the - - beginShape() and - - endShape() functions. The curved segment - uses - - the previous vertex as the first anchor point, so there must be at least - - one call to vertex() before - bezierVertex() can - - be used.

- -

The first four parameters, x2, y2, - x3, and y3, set the curve’s two - - control points. The control points "pull" the curve towards them.

- -

The fifth and sixth parameters, x4, and y4, set - the last anchor point. - - The last anchor point is where the curve ends.

- -

Bézier curves can also be drawn in 3D using WebGL mode. The 3D version of - - bezierVertex() has eight arguments because each point has x-, y-, - and - - z-coordinates.

- -

Note: bezierVertex() won’t work when an argument is passed to - - beginShape().

-line: 543 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the shape. - noFill(); - - // Start drawing the shape. - beginShape(); - - // Add the first anchor point. - vertex(30, 20); - - // Add the Bézier vertex. - bezierVertex(80, 0, 80, 75, 30, 75); - - // Stop drawing the shape. - endShape(); - - describe('A black C curve on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw the anchor points in black. - stroke(0); - strokeWeight(5); - point(30, 20); - point(30, 75); - - // Draw the control points in red. - stroke(255, 0, 0); - point(80, 0); - point(80, 75); - - // Style the shape. - noFill(); - stroke(0); - strokeWeight(1); - - // Start drawing the shape. - beginShape(); - - // Add the first anchor point. - vertex(30, 20); - - // Add the Bézier vertex. - bezierVertex(80, 0, 80, 75, 30, 75); - - // Stop drawing the shape. - endShape(); - - // Draw red lines from the anchor points to the control points. - stroke(255, 0, 0); - line(30, 20, 80, 0); - line(30, 75, 80, 75); - - describe( - 'A gray square with three curves. A black curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' - ); - } - -
- -
- - // Click the mouse near the red dot in the top-right corner - // and drag to change the curve's shape. - - let x2 = 80; - let y2 = 0; - let isChanging = false; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with three curves. A black curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.' - ); - } - - function draw() { - background(200); - - // Draw the anchor points in black. - stroke(0); - strokeWeight(5); - point(30, 20); - point(30, 75); - - // Draw the control points in red. - stroke(255, 0, 0); - point(x2, y2); - point(80, 75); - - // Style the shape. - noFill(); - stroke(0); - strokeWeight(1); - - // Start drawing the shape. - beginShape(); - - // Add the first anchor point. - vertex(30, 20); - - // Add the Bézier vertex. - bezierVertex(x2, y2, 80, 75, 30, 75); - - // Stop drawing the shape. - endShape(); - - // Draw red lines from the anchor points to the control points. - stroke(255, 0, 0); - line(30, 20, x2, y2); - line(30, 75, 80, 75); - } - - // Start changing the first control point if the user clicks near it. - function mousePressed() { - if (dist(mouseX, mouseY, x2, y2) < 20) { - isChanging = true; - } - } - - // Stop changing the first control point when the user releases the mouse. - function mouseReleased() { - isChanging = false; - } - - // Update the first control point while the user drags the mouse. - function mouseDragged() { - if (isChanging === true) { - x2 = mouseX; - y2 = mouseY; - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - beginShape(); - - // Add the first anchor point. - vertex(30, 20); - - // Add the Bézier vertices. - bezierVertex(80, 0, 80, 75, 30, 75); - bezierVertex(50, 80, 60, 25, 30, 20); - - // Stop drawing the shape. - endShape(); - - describe('A crescent moon shape drawn in white on a gray background.'); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A crescent moon shape drawn in white on a blue background. When the user drags the mouse, the scene rotates and a second moon is revealed.'); - } - - function draw() { - background('midnightblue'); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the moons. - noStroke(); - fill('lemonchiffon'); - - // Draw the first moon. - beginShape(); - vertex(-20, -30, 0); - bezierVertex(30, -50, 0, 30, 25, 0, -20, 25, 0); - bezierVertex(0, 30, 0, 10, -25, 0, -20, -30, 0); - endShape(); - - // Draw the second moon. - beginShape(); - vertex(-20, -30, -20); - bezierVertex(30, -50, -20, 30, 25, -20, -20, 25, -20); - bezierVertex(0, 30, -20, 10, -25, -20, -20, -30, -20); - endShape(); - } - -
-class: p5 -overloads: - - line: 543 - params: - - name: x2 - description: | -

x-coordinate of the first control point.

- type: Number - - name: y2 - description: | -

y-coordinate of the first control point.

- type: Number - - name: x3 - description: | -

x-coordinate of the second control point.

- type: Number - - name: y3 - description: | -

y-coordinate of the second control point.

- type: Number - - name: x4 - description: | -

x-coordinate of the anchor point.

- type: Number - - name: y4 - description: | -

y-coordinate of the anchor point.

- type: Number - chainable: 1 - - line: 792 - params: - - name: x2 - description: '' - type: Number - - name: y2 - description: '' - type: Number - - name: z2 - description: | -

z-coordinate of the first control point.

- type: Number - - name: x3 - description: '' - type: Number - - name: y3 - description: '' - type: Number - - name: z3 - description: | -

z-coordinate of the second control point.

- type: Number - - name: x4 - description: '' - type: Number - - name: y4 - description: '' - type: Number - - name: z4 - description: | -

z-coordinate of the anchor point.

- type: Number - chainable: 1 -chainable: true ---- - - -# bezierVertex diff --git a/src/content/reference/en/p5 copy/blend.mdx b/src/content/reference/en/p5 copy/blend.mdx deleted file mode 100644 index 53e9a94dc9..0000000000 --- a/src/content/reference/en/p5 copy/blend.mdx +++ /dev/null @@ -1,214 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L148 -title: blend -module: Image -submodule: Pixels -file: src/image/pixels.js -description: > -

Copies a region of pixels from one image to another.

- -

The first parameter, srcImage, is the - - p5.Image object to blend.

- -

The next four parameters, sx, sy, - sw, and sh determine the region - - to blend from the source image. (sx, sy) is the top-left corner - of the - - region. sw and sh are the regions width and - height.

- -

The next four parameters, dx, dy, - dw, and dh determine the region - - of the canvas to blend into. (dx, dy) is the top-left corner of - the - - region. dw and dh are the regions width and - height.

- -

The tenth parameter, blendMode, sets the effect used to blend - the images' - - colors. The options are BLEND, DARKEST, - LIGHTEST, DIFFERENCE, - - MULTIPLY, EXCLUSION, SCREEN, - REPLACE, OVERLAY, HARD_LIGHT, - - SOFT_LIGHT, DODGE, BURN, - ADD, or NORMAL

-line: 148 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img0; - let img1; - - // Load the images. - function preload() { - img0 = loadImage('/assets/rockies.jpg'); - img1 = loadImage('/assets/bricks_third.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Use the mountains as the background. - background(img0); - - // Display the bricks. - image(img1, 0, 0); - - // Display the bricks faded into the landscape. - blend(img1, 0, 0, 33, 100, 67, 0, 33, 100, LIGHTEST); - - describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears faded on the right of the image.'); - } - -
- -
- - let img0; - let img1; - - // Load the images. - function preload() { - img0 = loadImage('/assets/rockies.jpg'); - img1 = loadImage('/assets/bricks_third.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Use the mountains as the background. - background(img0); - - // Display the bricks. - image(img1, 0, 0); - - // Display the bricks partially transparent. - blend(img1, 0, 0, 33, 100, 67, 0, 33, 100, DARKEST); - - describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears transparent on the right of the image.'); - } - -
- -
- - let img0; - let img1; - - // Load the images. - function preload() { - img0 = loadImage('/assets/rockies.jpg'); - img1 = loadImage('/assets/bricks_third.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Use the mountains as the background. - background(img0); - - // Display the bricks. - image(img1, 0, 0); - - // Display the bricks washed out into the landscape. - blend(img1, 0, 0, 33, 100, 67, 0, 33, 100, ADD); - - describe('A wall of bricks in front of a mountain landscape. The same wall of bricks appears washed out on the right of the image.'); - } - -
-class: p5 -overloads: - - line: 148 - params: - - name: srcImage - description: | -

source image.

- type: p5.Image - - name: sx - description: | -

x-coordinate of the source's upper-left corner.

- type: Integer - - name: sy - description: | -

y-coordinate of the source's upper-left corner.

- type: Integer - - name: sw - description: | -

source image width.

- type: Integer - - name: sh - description: | -

source image height.

- type: Integer - - name: dx - description: | -

x-coordinate of the destination's upper-left corner.

- type: Integer - - name: dy - description: | -

y-coordinate of the destination's upper-left corner.

- type: Integer - - name: dw - description: | -

destination image width.

- type: Integer - - name: dh - description: | -

destination image height.

- type: Integer - - name: blendMode - description: | -

the blend mode. either - BLEND, DARKEST, LIGHTEST, DIFFERENCE, - MULTIPLY, EXCLUSION, SCREEN, REPLACE, OVERLAY, HARD_LIGHT, - SOFT_LIGHT, DODGE, BURN, ADD or NORMAL.

- type: Constant - - line: 267 - params: - - name: sx - description: '' - type: Integer - - name: sy - description: '' - type: Integer - - name: sw - description: '' - type: Integer - - name: sh - description: '' - type: Integer - - name: dx - description: '' - type: Integer - - name: dy - description: '' - type: Integer - - name: dw - description: '' - type: Integer - - name: dh - description: '' - type: Integer - - name: blendMode - description: '' - type: Constant -chainable: false ---- - - -# blend diff --git a/src/content/reference/en/p5 copy/blendMode.mdx b/src/content/reference/en/p5 copy/blendMode.mdx deleted file mode 100644 index 8f6365b78d..0000000000 --- a/src/content/reference/en/p5 copy/blendMode.mdx +++ /dev/null @@ -1,541 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L720 -title: blendMode -module: Rendering -submodule: Rendering -file: src/core/rendering.js -description: > -

Sets the way colors blend when added to the canvas.

- -

By default, drawing with a solid color paints over the current pixel values - - on the canvas. blendMode() offers many options for blending - colors.

- -

Shapes, images, and text can be used as sources for drawing to the canvas. - - A source pixel changes the color of the canvas pixel where it's drawn. The - - final color results from blending the source pixel's color with the canvas - - pixel's color. RGB color values from the source and canvas pixels are - - compared, added, subtracted, multiplied, and divided to create different - - effects. Red values with red values, greens with greens, and blues with - - blues.

- -

The parameter, mode, sets the blend mode. For example, calling - - blendMode(ADD) sets the blend mode to ADD. The - following blend modes - - are available in both 2D and WebGL mode:

- -
    - -
  • BLEND: color values from the source overwrite the canvas. - This is the default mode.
  • - -
  • ADD: color values from the source are added to values from - the canvas.
  • - -
  • DARKEST: keeps the darkest color value.
  • - -
  • LIGHTEST: keeps the lightest color value.
  • - -
  • EXCLUSION: similar to DIFFERENCE but with less - contrast.
  • - -
  • MULTIPLY: color values from the source are multiplied with - values from the canvas. The result is always darker.
  • - -
  • SCREEN: all color values are inverted, then multiplied, then - inverted again. The result is always lighter. (Opposite of - MULTIPLY)
  • - -
  • REPLACE: the last source drawn completely replaces the rest - of the canvas.
  • - -
  • REMOVE: overlapping pixels are removed by making them - completely transparent.
  • - -
- -

The following blend modes are only available in 2D mode:

- -
    - -
  • DIFFERENCE: color values from the source are subtracted from - the values from the canvas. If the difference is a negative number, it's made - positive.
  • - -
  • OVERLAY: combines MULTIPLY and - SCREEN. Dark values in the canvas get darker and light values get - lighter.
  • - -
  • HARD_LIGHT: combines MULTIPLY and - SCREEN. Dark values in the source get darker and light values get - lighter.
  • - -
  • SOFT_LIGHT: a softer version of HARD_LIGHT.
  • - -
  • DODGE: lightens light tones and increases contrast. Divides - the canvas color values by the inverted color values from the source.
  • - -
  • BURN: darkens dark tones and increases contrast. Divides the - source color values by the inverted color values from the canvas, then inverts - the result.
  • - -
- -

The following blend modes are only available in WebGL mode:

- -
    - -
  • SUBTRACT: RGB values from the source are subtracted from the - values from the canvas. If the difference is a negative number, it's made - positive. Alpha (transparency) values from the source and canvas are - added.
  • - -
-line: 720 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Use the default blend mode. - blendMode(BLEND); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('A Sky Blue line and a Deep Rose line form an X on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(HARD_LIGHT); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('An ocean blue line and a hot pink line form an X on a gray background. The area where they overlap is Magenta purple.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(ADD); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('An icy blue line and a light lavender line form an X on a gray background. The area where they overlap is white.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(DARKEST); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('A steel blue line and a cranberry line form an X on a gray background. The area where they overlap is deep purple.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(BURN); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('A cobalt blue line and a burgundy line form an X on a gray background. The area where they overlap is black.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(LIGHTEST); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('A pale lavender line and a soft beige line form an X on a gray background. The area where they overlap is pale lilac.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(EXCLUSION); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('An earthy brown line and a muted sage line form an X on a gray background. The area where they overlap is sage green.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(MULTIPLY); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('A slate blue line and a plum line form an X on a gray background. The area where they overlap is dark Indigo.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(SCREEN); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('A baby blue line and a peach pink line form an X on a gray background. The area where they overlap is misty lilac.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(REPLACE); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('A diagonal deep rose line.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(REMOVE); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('The silhouette of an X is missing from a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(DIFFERENCE); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('A light burgundy line and a forest green line form an X on a gray background. The area where they overlap is dark cocoa.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(OVERLAY); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('A cornflower blue line and a light rose line form an X on a gray background. The area where they overlap is violet.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(SOFT_LIGHT); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('A pale sky line and a rose blush line form an X on a gray background. The area where they overlap is lavender.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Set the blend mode. - blendMode(DODGE); - - // Style the lines. - strokeWeight(30); - - // Draw the first line. - stroke('#1a85ff'); - line(25, 25, 75, 75); - - // Draw the second line. - stroke('#d41159'); - line(75, 25, 25, 75); - - describe('An aqua blue line and a light pink line form an X on a gray background. The area where they overlap is white.'); - } - -
- -
- - function setup() { - // Create a canvas with WEBGL mode. - createCanvas(100, 100, WEBGL); - - // Set the background color. - background(180); - - // Set the blend mode to SUBTRACT. - blendMode(SUBTRACT); - - // Style the lines. - strokeWeight(30); - - // Draw the blue line. - stroke('#1a85ff'); - line(-25, -25, 25, 25); - - // Draw the red line. - stroke('#d41159'); - line(25, -25, -25, 25); - - describe('A burnt orange and a sea green line form an X on a gray background. The area where they overlap is forest green.'); - } - -
-class: p5 -params: - - name: mode - description: | -

blend mode to set. - either BLEND, DARKEST, LIGHTEST, DIFFERENCE, MULTIPLY, - EXCLUSION, SCREEN, REPLACE, OVERLAY, HARD_LIGHT, - SOFT_LIGHT, DODGE, BURN, ADD, REMOVE or SUBTRACT

- type: Constant -chainable: false ---- - - -# blendMode diff --git a/src/content/reference/en/p5 copy/blue.mdx b/src/content/reference/en/p5 copy/blue.mdx deleted file mode 100644 index d3e05aae37..0000000000 --- a/src/content/reference/en/p5 copy/blue.mdx +++ /dev/null @@ -1,158 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L117 -title: blue -module: Color -submodule: Creating & Reading -file: src/color/creating_reading.js -description: > -

Gets the blue value of a color.

- -

blue() extracts the blue value from a - - p5.Color object, an array of color - components, or - - a CSS color string.

- -

By default, blue() returns a color's blue value in the range 0 - - to 255. If the colorMode() is set to - RGB, it - - returns the blue value in the given range.

-line: 117 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object using RGB values. - let c = color(175, 100, 220); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'blueValue' to 220. - let blueValue = blue(c); - - // Draw the right rectangle. - fill(0, 0, blueValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is royal blue.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a color array. - let c = [175, 100, 220]; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'blueValue' to 220. - let blueValue = blue(c); - - // Draw the right rectangle. - fill(0, 0, blueValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is royal blue.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a CSS color string. - let c = 'rgb(175, 100, 220)'; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'blueValue' to 220. - let blueValue = blue(c); - - // Draw the right rectangle. - fill(0, 0, blueValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is royal blue.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use RGB color with values in the range 0-100. - colorMode(RGB, 100); - - // Create a p5.Color object using RGB values. - let c = color(69, 39, 86); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'blueValue' to 86. - let blueValue = blue(c); - - // Draw the right rectangle. - fill(0, 0, blueValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is royal blue.'); - } - -
-class: p5 -params: - - name: color - description: | -

p5.Color object, array of - color components, or CSS color string.

- type: 'p5.Color|Number[]|String' -return: - description: the blue value. - type: Number -chainable: false ---- - - -# blue diff --git a/src/content/reference/en/p5 copy/boolean.mdx b/src/content/reference/en/p5 copy/boolean.mdx deleted file mode 100644 index 8eab48af5f..0000000000 --- a/src/content/reference/en/p5 copy/boolean.mdx +++ /dev/null @@ -1,157 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L341 -title: boolean -module: Data -submodule: Conversion -file: src/utilities/conversion.js -description: > -

Converts a String or Number to a - Boolean.

- -

boolean() converts values to true or - false.

- -

The parameter, n, is the value to convert. If n - is a string, then - - boolean('true') will return true and every other - string value will - - return false. If n is a number, then - boolean(0) will return false - - and every other numeric value will return true. If an array is - passed, as - - in boolean([0, 1, 'true', 'blue']), then an array of Boolean - values will - - be returned.

-line: 341 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a number variable. - let original = 0; - - // Convert the number to a Boolean value. - let converted = boolean(original); - - // Style the circle based on the converted value. - if (converted === true) { - fill('blue'); - } else { - fill('red'); - } - - // Draw the circle. - circle(50, 50, 40); - - describe('A red circle on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let original = 'true'; - - // Convert the string to a Boolean value. - let converted = boolean(original); - - // Style the circle based on the converted value. - if (converted === true) { - fill('blue'); - } else { - fill('red'); - } - - // Draw the circle. - circle(50, 50, 40); - - describe('A blue circle on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of values. - let original = [0, 'hi', 123, 'true']; - - // Convert the array to a Boolean values. - let converted = boolean(original); - - // Iterate over the array of converted Boolean values. - for (let i = 0; i < converted.length; i += 1) { - - // Style the circle based on the converted value. - if (converted[i] === true) { - fill('blue'); - } else { - fill('red'); - } - - // Calculate the x-coordinate. - let x = (i + 1) * 20; - - // Draw the circle. - circle(x, 50, 15); - } - - describe( - 'A row of circles on a gray background. The two circles on the left are red and the two on the right are blue.' - ); - } - -
-class: p5 -return: - description: converted Boolean value. - type: Boolean -overloads: - - line: 341 - params: - - name: 'n' - description: | -

value to convert.

- type: String|Boolean|Number - return: - description: converted Boolean value. - type: Boolean - - line: 451 - params: - - name: ns - description: | -

values to convert.

- type: Array - return: - description: converted Boolean values. - type: 'Boolean[]' -chainable: false ---- - - -# boolean diff --git a/src/content/reference/en/p5 copy/box.mdx b/src/content/reference/en/p5 copy/box.mdx deleted file mode 100644 index a4f5282947..0000000000 --- a/src/content/reference/en/p5 copy/box.mdx +++ /dev/null @@ -1,186 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L1009 -title: box -module: Shape -submodule: 3D Primitives -file: src/webgl/3d_primitives.js -description: > -

Draws a box (rectangular prism).

- -

A box is a 3D shape with six faces. Each face makes a 90˚ with four - - neighboring faces.

- -

The first parameter, width, is optional. If a - Number is passed, as in - - box(20), it sets the box’s width and height. By default, - width is 50.

- -

The second parameter, height, is also optional. If a - Number is passed, - - as in box(20, 30), it sets the box’s height. By default, - height is set - - to the box’s width.

- -

The third parameter, depth, is also optional. If a - Number is passed, as - - in box(20, 30, 40), it sets the box’s depth. By default, - depth is set - - to the box’s height.

- -

The fourth parameter, detailX, is also optional. If a - Number is passed, - - as in box(20, 30, 40, 5), it sets the number of triangle - subdivisions to - - use along the x-axis. All 3D shapes are made by connecting triangles to - - form their surfaces. By default, detailX is 1.

- -

The fifth parameter, detailY, is also optional. If a number is - passed, as - - in box(20, 30, 40, 5, 7), it sets the number of triangle - subdivisions to - - use along the y-axis. All 3D shapes are made by connecting triangles to - - form their surfaces. By default, detailY is 1.

- -

Note: box() can only be used in WebGL mode.

-line: 1009 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white box on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white box on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the box. - // Set its width and height to 30. - box(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white box on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the box. - // Set its width to 30 and height to 50. - box(30, 50); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white box on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the box. - // Set its width to 30, height to 50, and depth to 10. - box(30, 50, 10); - } - -
-class: p5 -params: - - name: width - description: | -

width of the box.

- type: Number - optional: true - - name: height - description: | -

height of the box.

- type: Number - optional: true - - name: depth - description: | -

depth of the box.

- type: Number - optional: true - - name: detailX - description: | -

number of triangle subdivisions along the x-axis.

- type: Integer - optional: true - - name: detailY - description: | -

number of triangle subdivisions along the y-axis.

- type: Integer - optional: true -chainable: true ---- - - -# box diff --git a/src/content/reference/en/p5 copy/brightness.mdx b/src/content/reference/en/p5 copy/brightness.mdx deleted file mode 100644 index 2860cbf226..0000000000 --- a/src/content/reference/en/p5 copy/brightness.mdx +++ /dev/null @@ -1,168 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L253 -title: brightness -module: Color -submodule: Creating & Reading -file: src/color/creating_reading.js -description: > -

Gets the brightness value of a color.

- -

brightness() extracts the HSB brightness value from a - - p5.Color object, an array of color - components, or - - a CSS color string.

- -

By default, brightness() returns a color's HSB brightness in - the range 0 - - to 100. If the colorMode() is set to - HSB, it - - returns the brightness value in the given range.

-line: 253 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use HSB color. - colorMode(HSB); - - // Create a p5.Color object. - let c = color(0, 50, 100); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'brightValue' to 100. - let brightValue = brightness(c); - - // Draw the right rectangle. - fill(brightValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is white.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use HSB color. - colorMode(HSB); - - // Create a color array. - let c = [0, 50, 100]; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'brightValue' to 100. - let brightValue = brightness(c); - - // Draw the right rectangle. - fill(brightValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is white.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use HSB color. - colorMode(HSB); - - // Create a CSS color string. - let c = 'rgb(255, 128, 128)'; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'brightValue' to 100. - let brightValue = brightness(c); - - // Draw the right rectangle. - fill(brightValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is white.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use HSB color with values in the range 0-255. - colorMode(HSB, 255); - - // Create a p5.Color object. - let c = color(0, 127, 255); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'brightValue' to 255. - let brightValue = brightness(c); - - // Draw the right rectangle. - fill(brightValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is white.'); - } - -
-class: p5 -params: - - name: color - description: | -

p5.Color object, array of - color components, or CSS color string.

- type: 'p5.Color|Number[]|String' -return: - description: the brightness value. - type: Number -chainable: false ---- - - -# brightness diff --git a/src/content/reference/en/p5 copy/buildGeometry.mdx b/src/content/reference/en/p5 copy/buildGeometry.mdx deleted file mode 100644 index ef58d7b650..0000000000 --- a/src/content/reference/en/p5 copy/buildGeometry.mdx +++ /dev/null @@ -1,263 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L520 -title: buildGeometry -module: Shape -submodule: 3D Primitives -file: src/webgl/3d_primitives.js -description: > -

Creates a custom p5.Geometry object - from - - simpler 3D shapes.

- -

buildGeometry() helps with creating complex 3D shapes from - simpler ones - - such as sphere(). It can help to make - sketches - - more performant. For example, if a complex 3D shape doesn’t change while a - - sketch runs, then it can be created with buildGeometry(). - Creating a - - p5.Geometry object once and then - drawing it - - will run faster than repeatedly drawing the individual pieces.

- -

The parameter, callback, is a function with the drawing - instructions for - - the new p5.Geometry object. It will be - called - - once to create the new 3D shape.

- -

See beginGeometry() and - - endGeometry() for another way to - build 3D - - shapes.

- -

Note: buildGeometry() can only be used in WebGL mode.

-line: 520 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the p5.Geometry object. - shape = buildGeometry(createShape); - - describe('A white cone drawn on a gray background.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the p5.Geometry object. - noStroke(); - - // Draw the p5.Geometry object. - model(shape); - } - - // Create p5.Geometry object from a single cone. - function createShape() { - cone(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the arrow. - shape = buildGeometry(createArrow); - - describe('A white arrow drawn on a gray background.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the arrow. - noStroke(); - - // Draw the arrow. - model(shape); - } - - function createArrow() { - // Add shapes to the p5.Geometry object. - push(); - rotateX(PI); - cone(10); - translate(0, -10, 0); - cylinder(3, 20); - pop(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the p5.Geometry object. - shape = buildGeometry(createArrow); - - describe('Two white arrows drawn on a gray background. The arrow on the right rotates slowly.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the arrows. - noStroke(); - - // Draw the p5.Geometry object. - model(shape); - - // Translate and rotate the coordinate system. - translate(30, 0, 0); - rotateZ(frameCount * 0.01); - - // Draw the p5.Geometry object again. - model(shape); - } - - function createArrow() { - // Add shapes to the p5.Geometry object. - push(); - rotateX(PI); - cone(10); - translate(0, -10, 0); - cylinder(3, 20); - pop(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let button; - let particles; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a button to reset the particle system. - button = createButton('Reset'); - - // Call resetModel() when the user presses the button. - button.mousePressed(resetModel); - - // Add the original set of particles. - resetModel(); - - describe('A set of white spheres on a gray background. The spheres are positioned randomly. Their positions reset when the user presses the Reset button.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the particles. - noStroke(); - - // Draw the particles. - model(particles); - } - - function resetModel() { - // If the p5.Geometry object has already been created, - // free those resources. - if (particles) { - freeGeometry(particles); - } - - // Create a new p5.Geometry object with random spheres. - particles = buildGeometry(createParticles); - } - - function createParticles() { - for (let i = 0; i < 60; i += 1) { - // Calculate random coordinates. - let x = randomGaussian(0, 20); - let y = randomGaussian(0, 20); - let z = randomGaussian(0, 20); - - push(); - // Translate to the particle's coordinates. - translate(x, y, z); - // Draw the particle. - sphere(5); - pop(); - } - } - -
-class: p5 -params: - - name: callback - description: | -

function that draws the shape.

- type: Function -return: - description: new 3D shape. - type: p5.Geometry -chainable: false ---- - - -# buildGeometry diff --git a/src/content/reference/en/p5 copy/byte.mdx b/src/content/reference/en/p5 copy/byte.mdx deleted file mode 100644 index 0a6f3234a4..0000000000 --- a/src/content/reference/en/p5 copy/byte.mdx +++ /dev/null @@ -1,180 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L468 -title: byte -module: Data -submodule: Conversion -file: src/utilities/conversion.js -description: > -

Converts a Boolean, String, or - Number to its byte value.

- -

byte() converts a value to an integer (whole number) between - -128 and - - 127. Values greater than 127 wrap around while negative values are - - unchanged. For example, 128 becomes -128 and -129 remains the same.

- -

The parameter, n, is the value to convert. If n - is a Boolean, as in - - byte(false) or byte(true), the number 0 - (false) or 1 (true) will be - - returned. If n is a string or number, as in - byte('256') or byte(256), - - then the byte value will be returned. Decimal values are ignored. If an - - array is passed, as in byte([true, 123, '456']), then an array of - byte - - values will be returned.

- -

Note: If a value can't be converted to a number, as in - byte('giraffe'), - - then the value NaN (not a number) will be returned.

-line: 468 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a Boolean variable. - let original = true; - - // Convert the Boolean to its byte value. - let converted = byte(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the original and converted values. - text(`${original} : ${converted}`, 50, 50); - - describe('The text "true : 1" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let original = '256'; - - // Convert the string to its byte value. - let converted = byte(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the original and converted values. - text(`${original} : ${converted}`, 50, 50); - - describe('The text "256 : 0" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a number variable. - let original = 256; - - // Convert the number to its byte value. - let converted = byte(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the original and converted values. - text(`${original} : ${converted}`, 50, 50); - - describe('The text "256 : 0" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of values. - let original = [false, '64', 383]; - - // Convert the array elements to their byte values. - let converted = byte(original); - - // Iterate over the converted array elements. - for (let i = 0; i < converted.length; i += 1) { - - // Style the circle. - fill(converted[i]); - - // Calculate the x-coordinate. - let x = (i + 1) * 25; - - // Draw the circle. - circle(x, 50, 20); - } - - describe( - 'Three gray circles on a gray background. The circles get lighter from left to right.' - ); - } - -
-class: p5 -return: - description: converted byte value. - type: Number -overloads: - - line: 468 - params: - - name: 'n' - description: | -

value to convert.

- type: String|Boolean|Number - return: - description: converted byte value. - type: Number - - line: 598 - params: - - name: ns - description: | -

values to convert.

- type: Array - return: - description: converted byte values. - type: 'Number[]' -chainable: false ---- - - -# byte diff --git a/src/content/reference/en/p5 copy/camera.mdx b/src/content/reference/en/p5 copy/camera.mdx deleted file mode 100644 index 55f983385e..0000000000 --- a/src/content/reference/en/p5 copy/camera.mdx +++ /dev/null @@ -1,200 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L13 -title: camera -module: 3D -submodule: Camera -file: src/webgl/p5.Camera.js -description: > -

Sets the position and orientation of the current camera in a 3D sketch.

- -

camera() allows objects to be viewed from different angles. It - has nine - - parameters that are all optional.

- -

The first three parameters, x, y, and - z, are the coordinates of the - - camera’s position. For example, calling camera(0, 0, 0) places - the camera - - at the origin (0, 0, 0). By default, the camera is placed at - - (0, 0, 800).

- -

The next three parameters, centerX, centerY, and - centerZ are the - - coordinates of the point where the camera faces. For example, calling - - camera(0, 0, 0, 10, 20, 30) places the camera at the origin - (0, 0, 0) - - and points it at (10, 20, 30). By default, the camera points at - the - - origin (0, 0, 0).

- -

The last three parameters, upX, upY, and - upZ are the components of - - the "up" vector. The "up" vector orients the camera’s y-axis. For example, - - calling camera(0, 0, 0, 10, 20, 30, 0, -1, 0) places the camera - at the - - origin (0, 0, 0), points it at (10, 20, 30), and - sets the "up" vector - - to (0, -1, 0) which is like holding it upside-down. By default, - the "up" - - vector is (0, 1, 0).

- -

Note: camera() can only be used in WebGL mode.

-line: 13 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Move the camera to the top-right. - camera(200, -400, 800); - - // Draw the box. - box(); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube apperas to sway left and right on a gray background.'); - } - - function draw() { - background(200); - - // Calculate the camera's x-coordinate. - let x = 400 * cos(frameCount * 0.01); - - // Orbit the camera around the box. - camera(x, -400, 800); - - // Draw the box. - box(); - } - -
- -
- - // Adjust the range sliders to change the camera's position. - - let xSlider; - let ySlider; - let zSlider; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create slider objects to set the camera's coordinates. - xSlider = createSlider(-400, 400, 400); - xSlider.position(0, 100); - xSlider.size(100); - ySlider = createSlider(-400, 400, -200); - ySlider.position(0, 120); - ySlider.size(100); - zSlider = createSlider(0, 1600, 800); - zSlider.position(0, 140); - zSlider.size(100); - - describe( - 'A white cube drawn against a gray background. Three range sliders appear beneath the image. The camera position changes when the user moves the sliders.' - ); - } - - function draw() { - background(200); - - // Get the camera's coordinates from the sliders. - let x = xSlider.value(); - let y = ySlider.value(); - let z = zSlider.value(); - - // Move the camera. - camera(x, y, z); - - // Draw the box. - box(); - } - -
-class: p5 -params: - - name: x - description: | -

x-coordinate of the camera. Defaults to 0.

- type: Number - optional: true - - name: 'y' - description: | -

y-coordinate of the camera. Defaults to 0.

- type: Number - optional: true - - name: z - description: | -

z-coordinate of the camera. Defaults to 800.

- type: Number - optional: true - - name: centerX - description: | -

x-coordinate of the point the camera faces. Defaults to 0.

- type: Number - optional: true - - name: centerY - description: | -

y-coordinate of the point the camera faces. Defaults to 0.

- type: Number - optional: true - - name: centerZ - description: | -

z-coordinate of the point the camera faces. Defaults to 0.

- type: Number - optional: true - - name: upX - description: | -

x-component of the camera’s "up" vector. Defaults to 0.

- type: Number - optional: true - - name: upY - description: | -

y-component of the camera’s "up" vector. Defaults to 1.

- type: Number - optional: true - - name: upZ - description: | -

z-component of the camera’s "up" vector. Defaults to 0.

- type: Number - optional: true -chainable: true ---- - - -# camera diff --git a/src/content/reference/en/p5 copy/ceil.mdx b/src/content/reference/en/p5 copy/ceil.mdx deleted file mode 100644 index 45c17468bf..0000000000 --- a/src/content/reference/en/p5 copy/ceil.mdx +++ /dev/null @@ -1,65 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L48 -title: ceil -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Calculates the closest integer value that is greater than or equal to a - - number.

- -

For example, calling ceil(9.03) and ceil(9.97) - both return the value - - 10.

-line: 48 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use RGB color with values from 0 to 1. - colorMode(RGB, 1); - - noStroke(); - - // Draw the left rectangle. - let r = 0.3; - fill(r, 0, 0); - rect(0, 0, 50, 100); - - // Round r up to 1. - r = ceil(r); - - // Draw the right rectangle. - fill(r, 0, 0); - rect(50, 0, 50, 100); - - describe('Two rectangles. The one on the left is dark red and the one on the right is bright red.'); - } - -
-class: p5 -params: - - name: 'n' - description: | -

number to round up.

- type: Number -return: - description: rounded up number. - type: Integer -chainable: false ---- - - -# ceil diff --git a/src/content/reference/en/p5 copy/changed.mdx b/src/content/reference/en/p5 copy/changed.mdx deleted file mode 100644 index 45289630e9..0000000000 --- a/src/content/reference/en/p5 copy/changed.mdx +++ /dev/null @@ -1,87 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L330 -title: changed -module: DOM -submodule: DOM -file: src/dom/dom.js -description: | -

Calls a function when the element changes.

-

Calling myElement.changed(false) disables the function.

-line: 330 -isConstructor: false -itemtype: method -example: - - |- - -
- - let dropdown; - - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a dropdown menu and add a few color options. - dropdown = createSelect(); - dropdown.position(0, 0); - dropdown.option('red'); - dropdown.option('green'); - dropdown.option('blue'); - - // Call paintBackground() when the color option changes. - dropdown.changed(paintBackground); - - describe('A gray square with a dropdown menu at the top. The square changes color when an option is selected.'); - } - - // Paint the background with the selected color. - function paintBackground() { - let c = dropdown.value(); - background(c); - } - -
- -
- - let checkbox; - - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a checkbox and place it beneath the canvas. - checkbox = createCheckbox(' circle'); - checkbox.position(0, 100); - - // Call repaint() when the checkbox changes. - checkbox.changed(repaint); - - describe('A gray square with a checkbox underneath it that says "circle". A white circle appears when the box is checked and disappears otherwise.'); - } - - // Paint the background gray and determine whether to draw a circle. - function repaint() { - background(200); - if (checkbox.checked() === true) { - circle(50, 50, 30); - } - } - -
-class: p5 -params: - - name: fxn - description: | -

function to call when the element changes. - false disables the function.

- type: Function|Boolean -chainable: true ---- - - -# changed diff --git a/src/content/reference/en/p5 copy/char.mdx b/src/content/reference/en/p5 copy/char.mdx deleted file mode 100644 index e01e22a9f7..0000000000 --- a/src/content/reference/en/p5 copy/char.mdx +++ /dev/null @@ -1,152 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L612 -title: char -module: Data -submodule: Conversion -file: src/utilities/conversion.js -description: > -

Converts a Number or String to a single-character - String.

- -

char() converts numbers to their single-character string - representations.

- -

The parameter, n, is the value to convert. If a number is - passed, as in - - char(65), the corresponding single-character string is returned. - If a - - string is passed, as in char('65'), the string is converted to an - integer - - (whole number) and the corresponding single-character string is returned. - - If an array is passed, as in char([65, 66, 67]), an array of - - single-character strings is returned.

- -

See MDN - - for more information about conversions.

-line: 612 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a number variable. - let original = 65; - - // Convert the number to a char. - let converted = char(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the original and converted values. - text(`${original} : ${converted}`, 50, 50); - - describe('The text "65 : A" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let original = '65'; - - // Convert the string to a char. - let converted = char(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the original and converted values. - text(`${original} : ${converted}`, 50, 50); - - describe('The text "65 : A" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of numbers. - let original = ['65', 66, '67']; - - // Convert the string to a char. - let converted = char(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Iterate over elements of the converted array. - for (let i = 0; i < converted.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 25; - - // Display the original and converted values. - text(`${original[i]} : ${converted[i]}`, 50, y); - } - - describe( - 'The text "65 : A", "66 : B", and "67 : C" written on three separate lines. The text is in black on a gray background.' - ); - } - -
-class: p5 -return: - description: converted single-character string. - type: String -overloads: - - line: 612 - params: - - name: 'n' - description: | -

value to convert.

- type: String|Number - return: - description: converted single-character string. - type: String - - line: 716 - params: - - name: ns - description: | -

values to convert.

- type: Array - return: - description: converted single-character strings. - type: 'String[]' -chainable: false ---- - - -# char diff --git a/src/content/reference/en/p5 copy/circle.mdx b/src/content/reference/en/p5 copy/circle.mdx deleted file mode 100644 index 46069bea74..0000000000 --- a/src/content/reference/en/p5 copy/circle.mdx +++ /dev/null @@ -1,77 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L488 -title: circle -module: Shape -submodule: 2D Primitives -file: src/core/shape/2d_primitives.js -description: > -

Draws a circle.

- -

A circle is a round shape defined by the x, y, - and d parameters. - - x and y set the location of its center. - d sets its width and height (diameter). - - Every point on the circle's edge is the same distance, 0.5 * d, - from its center. - - 0.5 * d (half the diameter) is the circle's radius. - - See ellipseMode() for other ways to - set its position.

-line: 488 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - circle(50, 50, 25); - - describe('A white circle with black outline in the middle of a gray canvas.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - circle(0, 0, 25); - - describe('A white circle with black outline in the middle of a gray canvas.'); - } - -
-class: p5 -params: - - name: x - description: | -

x-coordinate of the center of the circle.

- type: Number - - name: 'y' - description: | -

y-coordinate of the center of the circle.

- type: Number - - name: d - description: | -

diameter of the circle.

- type: Number -chainable: true ---- - - -# circle diff --git a/src/content/reference/en/p5 copy/class.mdx b/src/content/reference/en/p5 copy/class.mdx deleted file mode 100644 index 94b64b75c2..0000000000 --- a/src/content/reference/en/p5 copy/class.mdx +++ /dev/null @@ -1,19 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L1329 -title: class -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: "

A template for creating objects of a particular type.

\n

Classes can make it easier to program with objects. For example, a Frog\nclass could create objects that behave like frogs. Each object created\nusing a class is called an instance of that class. All instances of a class\nare the same type. Here's an example of creating an instance of a Frog\nclass:

\n
let fifi = new Frog(50, 50, 20);\n
\n

The variable fifi refers to an instance of the Frog class. The keyword\nnew is used to call the Frog class' constructor in the statement\nnew Frog(). Altogether, a new Frog object was created and assigned to\nthe variable fifi. Classes are templates, so they can be used to create\nmore than one instance:

\n
// First Frog instance.\nlet frog1 = new Frog(25, 50, 10);\n\n// Second Frog instance.\nlet frog2 = new Frog(75, 50, 10);\n
\n

A simple Frog class could be declared as follows:

\n
class Frog {\n  constructor(x, y, size) {\n    // This code runs once when an instance is created.\n    this.x = x;\n    this.y = y;\n    this.size = size;\n  }\n\n  show() {\n    // This code runs once when myFrog.show() is called.\n    textAlign(CENTER, CENTER);\n    textSize(this.size);\n    text('\U0001F438', this.x, this.y);\n  }\n\n  hop() {\n    // This code runs once when myFrog.hop() is called.\n    this.x += random(-10, 10);\n    this.y += random(-10, 10);\n  }\n}\n
\n

Class declarations begin with the keyword class followed by the class\nname, such as Frog, and curly braces {}. Class names should use\nPascalCase and can't have spaces in their names. For example, naming a\nclass Kermit The Frog with spaces between each word would throw a\nSyntaxError. The code between the curly braces {} defines the class.

\n

Functions that belong to a class are called methods. constructor(),\nshow(), and hop() are methods in the Frog class. Methods define an\nobject's behavior. Methods can accept parameters and return values, just\nlike functions. Note that methods don't use the function keyword.

\n

constructor() is a special method that's called once when an instance of\nthe class is created. The statement new Frog() calls the Frog class'\nconstructor() method.

\n

A class definition is a template for instances. The keyword this refers\nto an instance's data and methods. For example, each Frog instance has\nunique coordinates stored in this.x and this.y. The show() method\nuses those coordinates to draw the frog. The hop() method updates those\ncoordinates when called. Once a Frog instance is created, its data and\nmethods can be accessed using the dot operator . as follows:

\n
// Draw a lily pad.\nfill('green');\nstroke('green');\ncircle(fifi.x, fifi.y, 2 * fifi.size);\n\n// Show the Frog.\nfifi.show();\n\n// Hop.\nfifi.hop();\n
\n" -line: 1329 -isConstructor: false -itemtype: property -example: - - "\n
\n\n// Declare a frog variable.\nlet fifi;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variable a new Frog object.\n fifi = new Frog(50, 50, 20);\n\n describe('A frog face drawn on a blue background.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frog.\n fifi.show();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n}\n\n
\n\n
\n\n// Declare two frog variables.\nlet frog1;\nlet frog2;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variables a new Frog object.\n frog1 = new Frog(25, 50, 10);\n frog2 = new Frog(75, 50, 20);\n\n describe('Two frog faces drawn next to each other on a blue background.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frogs.\n frog1.show();\n frog2.show();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n}\n\n
\n\n
\n\n// Declare two frog variables.\nlet frog1;\nlet frog2;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variables a new Frog object.\n frog1 = new Frog(25, 50, 10);\n frog2 = new Frog(75, 50, 20);\n\n // Slow the frame rate.\n frameRate(1);\n\n describe('Two frog faces on a blue background. The frogs hop around randomly.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frogs.\n frog1.show();\n frog2.show();\n\n // Move the frogs.\n frog1.hop();\n frog2.hop();\n\n // Wrap around if they've hopped off the edge.\n frog1.checkEdges();\n frog2.checkEdges();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n\n hop() {\n this.x += random(-10, 10);\n this.y += random(-10, 10);\n }\n\n checkEdges() {\n if (this.x > width) {\n this.x = this.x - width;\n } else if (this.x < 0) {\n this.x = width - this.x;\n }\n\n if (this.y > height) {\n this.y = this.y - height;\n } else if (this.y < 0) {\n this.y = height - this.y;\n }\n }\n}\n\n
\n\n
\n\n// Create an array that will hold frogs.\nlet frogs = [];\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Add Frog objects to the array.\n for (let i = 0; i < 5; i += 1) {\n // Calculate random coordinates and size.\n let x = random(0, 100);\n let y = random(0, 100);\n let s = random(2, 20);\n\n // Create a new Frog object.\n let frog = new Frog(x, y, s);\n\n // Add the Frog to the array.\n frogs.push(frog);\n }\n\n // Slow the frame rate.\n frameRate(1);\n\n describe(\n 'Five frog faces on a blue background. The frogs hop around randomly.'\n );\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n for (let frog of frogs) {\n // Show the frog.\n frog.show();\n\n // Move the frog.\n frog.hop();\n\n // Wrap around if they've hopped off the edge.\n frog.checkEdges();\n }\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n\n hop() {\n this.x += random(-10, 10);\n this.y += random(-10, 10);\n }\n\n checkEdges() {\n if (this.x > width) {\n this.x = this.x - width;\n } else if (this.x < 0) {\n this.x = width - this.x;\n }\n\n if (this.y > height) {\n this.y = this.y - height;\n } else if (this.y < 0) {\n this.y = height - this.y;\n }\n }\n}\n\n
" -class: p5 ---- - - -# class diff --git a/src/content/reference/en/p5 copy/clear.mdx b/src/content/reference/en/p5 copy/clear.mdx deleted file mode 100644 index a096184afc..0000000000 --- a/src/content/reference/en/p5 copy/clear.mdx +++ /dev/null @@ -1,108 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L673 -title: clear -module: Color -submodule: Setting -file: src/color/setting.js -description: > -

Clears the pixels on the canvas.

- -

clear() makes every pixel 100% transparent. Calling - clear() doesn't - - clear objects created by createX() functions such as - - createGraphics(), - - createVideo(), and - - createImg(). These objects will remain - - unchanged after calling clear() and can be redrawn.

- -

In WebGL mode, this function can clear the screen to a specific color. It - - interprets four numeric parameters as normalized RGBA color values. It also - - clears the depth buffer. If you are not using the WebGL renderer, these - - parameters will have no effect.

-line: 673 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - describe('A gray square. White circles are drawn as the user moves the mouse. The circles disappear when the user presses the mouse.'); - } - - function draw() { - circle(mouseX, mouseY, 20); - } - - function mousePressed() { - clear(); - background(200); - } - -
- -
- - let pg; - - function setup() { - createCanvas(100, 100); - background(200); - - pg = createGraphics(60, 60); - pg.background(200); - pg.noStroke(); - pg.circle(pg.width / 2, pg.height / 2, 15); - image(pg, 20, 20); - - describe('A white circle drawn on a gray square. The square gets smaller when the mouse is pressed.'); - } - - function mousePressed() { - clear(); - image(pg, 20, 20); - } - -
-class: p5 -params: - - name: r - description: | -

normalized red value.

- type: Number - optional: true - - name: g - description: | -

normalized green value.

- type: Number - optional: true - - name: b - description: | -

normalized blue value.

- type: Number - optional: true - - name: a - description: | -

normalized alpha value.

- type: Number - optional: true -chainable: true ---- - - -# clear diff --git a/src/content/reference/en/p5 copy/clearDepth.mdx b/src/content/reference/en/p5 copy/clearDepth.mdx deleted file mode 100644 index 25425d1920..0000000000 --- a/src/content/reference/en/p5 copy/clearDepth.mdx +++ /dev/null @@ -1,113 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L635 -title: clearDepth -module: Rendering -submodule: Rendering -file: src/core/rendering.js -description: > -

Clears the depth buffer in WebGL mode.

- -

clearDepth() clears information about how far objects are from - the camera - - in 3D space. This information is stored in an object called the - - depth buffer. Clearing the depth buffer ensures new objects aren't - drawn - - behind old ones. Doing so can be useful for feedback effects in which the - - previous frame serves as the background for the current frame.

- -

The parameter, depth, is optional. If a number is passed, as - in - - clearDepth(0.5), it determines the range of objects to clear from - the - - depth buffer. 0 doesn't clear any depth information, 0.5 clears depth - - information halfway between the near and far clipping planes, and 1 clears - - depth information all the way to the far clipping plane. By default, - - depth is 1.

- -

Note: clearDepth() can only be used in WebGL mode.

-line: 635 -isConstructor: false -itemtype: method -example: - - |- - -
- - let previous; - let current; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the p5.Framebuffer objects. - previous = createFramebuffer({ format: FLOAT }); - current = createFramebuffer({ format: FLOAT }); - - describe( - 'A multicolor box drifts from side to side on a white background. It leaves a trail that fades over time.' - ); - } - - function draw() { - // Swap the previous p5.Framebuffer and the - // current one so it can be used as a texture. - [previous, current] = [current, previous]; - - // Start drawing to the current p5.Framebuffer. - current.begin(); - - // Paint the background. - background(255); - - // Draw the previous p5.Framebuffer. - // Clear the depth buffer so the previous - // frame doesn't block the current one. - push(); - tint(255, 250); - image(previous, -50, -50); - clearDepth(); - pop(); - - // Draw the box on top of the previous frame. - push(); - let x = 25 * sin(frameCount * 0.01); - let y = 25 * sin(frameCount * 0.02); - translate(x, y, 0); - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - normalMaterial(); - box(12); - pop(); - - // Stop drawing to the current p5.Framebuffer. - current.end(); - - // Display the current p5.Framebuffer. - image(current, -50, -50); - } - -
-class: p5 -params: - - name: depth - description: | -

amount of the depth buffer to clear between 0 - (none) and 1 (far clipping plane). Defaults to 1.

- type: Number - optional: true -chainable: false ---- - - -# clearDepth diff --git a/src/content/reference/en/p5 copy/clearStorage.mdx b/src/content/reference/en/p5 copy/clearStorage.mdx deleted file mode 100644 index d2c89e63bf..0000000000 --- a/src/content/reference/en/p5 copy/clearStorage.mdx +++ /dev/null @@ -1,81 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/data/local_storage.js#L313 -title: clearStorage -module: Data -submodule: LocalStorage -file: src/data/local_storage.js -description: > -

Removes all items in the web browser's local storage.

- -

Web browsers can save small amounts of data using the built-in - - localStorage object. - - Data stored in localStorage can be retrieved at any point, even - after - - refreshing a page or restarting the browser. Data are stored as key-value - - pairs. Calling clearStorage() removes all data from - localStorage.

- -

Note: Sensitive data such as passwords or personal information shouldn't be - - stored in localStorage.

-line: 313 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Double-click to clear localStorage. - - function setup() { - createCanvas(100, 100); - - // Store the player's name. - storeItem('name', 'Feist'); - - // Store the player's score. - storeItem('score', 1234); - - describe( - 'The text "Feist: 1234" written in black on a gray background. The text "null: null" appears when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(14); - - // Retrieve the name. - let name = getItem('name'); - - // Retrieve the score. - let score = getItem('score'); - - // Display the score. - text(`${name}: ${score}`, 50, 50); - } - - // Clear localStorage when the user double-clicks. - function doubleClicked() { - clearStorage(); - } - -
-class: p5 -chainable: false ---- - - -# clearStorage diff --git a/src/content/reference/en/p5 copy/clip.mdx b/src/content/reference/en/p5 copy/clip.mdx deleted file mode 100644 index ae72687f03..0000000000 --- a/src/content/reference/en/p5 copy/clip.mdx +++ /dev/null @@ -1,225 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L222 -title: clip -module: Color -submodule: Setting -file: src/color/setting.js -description: > -

Defines a shape that will mask any shapes drawn afterward.

- -

The first parameter, callback, is a function that defines the - mask. - - Any shapes drawn in callback will add to the mask shape. The - mask - - will apply to anything drawn after clip() is called.

- -

The second parameter, options, is optional. If an object with - an invert - - property is passed, as in beginClip({ invert: true }), it will be - used to - - set the masking mode. { invert: true } inverts the mask, creating - holes - - in shapes that are masked. invert is false by - default.

- -

Masks can be contained between the - - push() and pop() functions. - - Doing so allows unmasked shapes to be drawn after masked shapes.

- -

Masks can also be defined with beginClip() - - and endClip().

-line: 222 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a mask. - clip(mask); - - // Draw a backing shape. - square(5, 5, 45); - - describe('A white triangle and circle on a gray background.'); - } - - // Declare a function that defines the mask. - function mask() { - triangle(15, 37, 30, 13, 43, 37); - circle(45, 45, 7); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an inverted mask. - clip(mask, { invert: true }); - - // Draw a backing shape. - square(5, 5, 45); - - describe('A white square at the top-left corner of a gray square. The white square has a triangle and a circle cut out of it.'); - } - - // Declare a function that defines the mask. - function mask() { - triangle(15, 37, 30, 13, 43, 37); - circle(45, 45, 7); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - noStroke(); - - // Draw a masked shape. - push(); - // Create a mask. - clip(mask); - - // Draw a backing shape. - square(5, 5, 45); - pop(); - - // Translate the origin to the center. - translate(50, 50); - - // Draw an inverted masked shape. - push(); - // Create an inverted mask. - clip(mask, { invert: true }); - - // Draw a backing shape. - square(5, 5, 45); - pop(); - - describe('In the top left, a white triangle and circle. In the bottom right, a white square with a triangle and circle cut out of it.'); - } - - // Declare a function that defines the mask. - function mask() { - triangle(15, 37, 30, 13, 43, 37); - circle(45, 45, 7); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A silhouette of a rotating torus colored fuchsia.'); - } - - function draw() { - background(200); - - // Create a mask. - clip(mask); - - // Draw a backing shape. - noStroke(); - fill('fuchsia'); - plane(100); - } - - // Declare a function that defines the mask. - function mask() { - push(); - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - scale(0.5); - torus(30, 15); - pop(); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A silhouette of a rotating torus colored with a gradient from cyan to purple.'); - } - - function draw() { - background(200); - - // Create a mask. - clip(mask); - - // Draw a backing shape. - noStroke(); - beginShape(QUAD_STRIP); - fill(0, 255, 255); - vertex(-width / 2, -height / 2); - vertex(width / 2, -height / 2); - fill(100, 0, 100); - vertex(-width / 2, height / 2); - vertex(width / 2, height / 2); - endShape(); - } - - // Declare a function that defines the mask. - function mask() { - push(); - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - scale(0.5); - torus(30, 15); - pop(); - } - -
-class: p5 -params: - - name: callback - description: | -

a function that draws the mask shape.

- type: Function - - name: options - description: | -

an object containing clip settings.

- type: Object - optional: true -chainable: false ---- - - -# clip diff --git a/src/content/reference/en/p5 copy/color.mdx b/src/content/reference/en/p5 copy/color.mdx deleted file mode 100644 index ad2bdbd8da..0000000000 --- a/src/content/reference/en/p5 copy/color.mdx +++ /dev/null @@ -1,349 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L398 -title: color -module: Color -submodule: Creating & Reading -file: src/color/creating_reading.js -description: > -

Creates a p5.Color object.

- -

By default, the parameters are interpreted as RGB values. Calling - - color(255, 204, 0) will return a bright yellow color. The way - these - - parameters are interpreted may be changed with the - - colorMode() function.

- -

The version of color() with one parameter interprets the value - one of two - - ways. If the parameter is a number, it's interpreted as a grayscale value. - - If the parameter is a string, it's interpreted as a CSS color string.

- -

The version of color() with two parameters interprets the - first one as a - - grayscale value. The second parameter sets the alpha (transparency) value.

- -

The version of color() with three parameters interprets them - as RGB, HSB, - - or HSL colors, depending on the current colorMode().

- -

The version of color() with four parameters interprets them as - RGBA, HSBA, - - or HSLA colors, depending on the current colorMode(). The last - parameter - - sets the alpha (transparency) value.

-line: 398 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object using RGB values. - let c = color(255, 204, 0); - - // Draw the square. - fill(c); - noStroke(); - square(30, 20, 55); - - describe('A yellow square on a gray canvas.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object using RGB values. - let c1 = color(255, 204, 0); - - // Draw the left circle. - fill(c1); - noStroke(); - circle(25, 25, 80); - - // Create a p5.Color object using a grayscale value. - let c2 = color(65); - - // Draw the right circle. - fill(c2); - circle(75, 75, 80); - - describe( - 'Two circles on a gray canvas. The circle in the top-left corner is yellow and the one at the bottom-right is gray.' - ); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object using a named color. - let c = color('magenta'); - - // Draw the square. - fill(c); - noStroke(); - square(20, 20, 60); - - describe('A magenta square on a gray canvas.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object using a hex color code. - let c1 = color('#0f0'); - - // Draw the left rectangle. - fill(c1); - noStroke(); - rect(0, 10, 45, 80); - - // Create a p5.Color object using a hex color code. - let c2 = color('#00ff00'); - - // Draw the right rectangle. - fill(c2); - rect(55, 10, 45, 80); - - describe('Two bright green rectangles on a gray canvas.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object using a RGB color string. - let c1 = color('rgb(0, 0, 255)'); - - // Draw the top-left square. - fill(c1); - square(10, 10, 35); - - // Create a p5.Color object using a RGB color string. - let c2 = color('rgb(0%, 0%, 100%)'); - - // Draw the top-right square. - fill(c2); - square(55, 10, 35); - - // Create a p5.Color object using a RGBA color string. - let c3 = color('rgba(0, 0, 255, 1)'); - - // Draw the bottom-left square. - fill(c3); - square(10, 55, 35); - - // Create a p5.Color object using a RGBA color string. - let c4 = color('rgba(0%, 0%, 100%, 1)'); - - // Draw the bottom-right square. - fill(c4); - square(55, 55, 35); - - describe('Four blue squares in the corners of a gray canvas.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object using a HSL color string. - let c1 = color('hsl(160, 100%, 50%)'); - - // Draw the left rectangle. - noStroke(); - fill(c1); - rect(0, 10, 45, 80); - - // Create a p5.Color object using a HSLA color string. - let c2 = color('hsla(160, 100%, 50%, 0.5)'); - - // Draw the right rectangle. - fill(c2); - rect(55, 10, 45, 80); - - describe('Two sea green rectangles. A darker rectangle on the left and a brighter one on the right.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object using a HSB color string. - let c1 = color('hsb(160, 100%, 50%)'); - - // Draw the left rectangle. - noStroke(); - fill(c1); - rect(0, 10, 45, 80); - - // Create a p5.Color object using a HSBA color string. - let c2 = color('hsba(160, 100%, 50%, 0.5)'); - - // Draw the right rectangle. - fill(c2); - rect(55, 10, 45, 80); - - describe('Two green rectangles. A darker rectangle on the left and a brighter one on the right.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object using RGB values. - let c1 = color(50, 55, 100); - - // Draw the left rectangle. - fill(c1); - rect(0, 10, 45, 80); - - // Switch the color mode to HSB. - colorMode(HSB, 100); - - // Create a p5.Color object using HSB values. - let c2 = color(50, 55, 100); - - // Draw the right rectangle. - fill(c2); - rect(55, 10, 45, 80); - - describe('Two blue rectangles. A darker rectangle on the left and a brighter one on the right.'); - } - -
-class: p5 -return: - description: resulting color. - type: p5.Color -overloads: - - line: 398 - params: - - name: gray - description: | -

number specifying value between white and black.

- type: Number - - name: alpha - description: | -

alpha value relative to current color range - (default is 0-255).

- type: Number - optional: true - return: - description: resulting color. - type: p5.Color - - line: 652 - params: - - name: v1 - description: | -

red or hue value relative to - the current color range.

- type: Number - - name: v2 - description: | -

green or saturation value - relative to the current color range.

- type: Number - - name: v3 - description: | -

blue or brightness value - relative to the current color range.

- type: Number - - name: alpha - description: '' - type: Number - optional: true - return: - description: '' - type: p5.Color - - line: 664 - params: - - name: value - description: | -

a color string.

- type: String - return: - description: '' - type: p5.Color - - line: 670 - params: - - name: values - description: | -

an array containing the red, green, blue, - and alpha components of the color.

- type: 'Number[]' - return: - description: '' - type: p5.Color - - line: 677 - params: - - name: color - description: '' - type: p5.Color - return: - description: '' - type: p5.Color -chainable: false ---- - - -# color diff --git a/src/content/reference/en/p5 copy/colorMode.mdx b/src/content/reference/en/p5 copy/colorMode.mdx deleted file mode 100644 index b4aca3c9ce..0000000000 --- a/src/content/reference/en/p5 copy/colorMode.mdx +++ /dev/null @@ -1,271 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L751 -title: colorMode -module: Color -submodule: Setting -file: src/color/setting.js -description: > -

Changes the way color values are interpreted.

- -

By default, the Number parameters for fill(), - - stroke(), - - background(), and - - color() are defined by values between 0 and - 255 - - using the RGB color model. This is equivalent to calling - - colorMode(RGB, 255). Pure red is color(255, 0, 0) in - this model.

- -

Calling colorMode(RGB, 100) sets colors to use RGB color - values - - between 0 and 100. Pure red is color(100, 0, 0) in this - model.

- -

Calling colorMode(HSB) or colorMode(HSL) changes - to HSB or HSL system - - instead of RGB. Pure red is color(0, 100, 100) in HSB and - - color(0, 100, 50) in HSL.

- -

p5.Color objects remember the mode - that they were - - created in. Changing modes doesn't affect their appearance.

-line: 751 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Fill with pure red. - fill(255, 0, 0); - - circle(50, 50, 25); - - describe('A gray square with a red circle at its center.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use RGB color with values in the range 0-100. - colorMode(RGB, 100); - - // Fill with pure red. - fill(100, 0, 0); - - circle(50, 50, 25); - - describe('A gray square with a red circle at its center.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use HSB color. - colorMode(HSB); - - // Fill with pure red. - fill(0, 100, 100); - - circle(50, 50, 25); - - describe('A gray square with a red circle at its center.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use HSL color. - colorMode(HSL); - - // Fill with pure red. - fill(0, 100, 50); - - circle(50, 50, 25); - - describe('A gray square with a red circle at its center.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - // Use RGB color with values in the range 0-100. - colorMode(RGB, 100); - - for (let x = 0; x < 100; x += 1) { - for (let y = 0; y < 100; y += 1) { - stroke(x, y, 0); - point(x, y); - } - } - - describe( - 'A diagonal green to red gradient from bottom-left to top-right with shading transitioning to black at top-left corner.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Use HSB color with values in the range 0-100. - colorMode(HSB, 100); - - for (let x = 0; x < 100; x += 1) { - for (let y = 0; y < 100; y += 1) { - stroke(x, y, 100); - point(x, y); - } - } - - describe('A rainbow gradient from left-to-right. Brightness transitions to white at the top.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Create a p5.Color object. - let myColor = color(180, 175, 230); - background(myColor); - - // Use RGB color with values in the range 0-1. - colorMode(RGB, 1); - - // Get the red, green, and blue color components. - let redValue = red(myColor); - let greenValue = green(myColor); - let blueValue = blue(myColor); - - // Round the color components for display. - redValue = round(redValue, 2); - greenValue = round(greenValue, 2); - blueValue = round(blueValue, 2); - - // Display the color components. - text(`Red: ${redValue}`, 10, 10, 80, 80); - text(`Green: ${greenValue}`, 10, 40, 80, 80); - text(`Blue: ${blueValue}`, 10, 70, 80, 80); - - describe('A purple canvas with the red, green, and blue decimal values of the color written on it.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(255); - - // Use RGB color with alpha values in the range 0-1. - colorMode(RGB, 255, 255, 255, 1); - - noFill(); - strokeWeight(4); - stroke(255, 0, 10, 0.3); - circle(40, 40, 50); - circle(50, 60, 50); - - describe('Two overlapping translucent pink circle outlines.'); - } - -
-class: p5 -overloads: - - line: 751 - params: - - name: mode - description: | -

either RGB, HSB or HSL, corresponding to - Red/Green/Blue and Hue/Saturation/Brightness - (or Lightness).

- type: Constant - - name: max - description: | -

range for all values.

- type: Number - optional: true - chainable: 1 - - line: 956 - params: - - name: mode - description: '' - type: Constant - - name: max1 - description: | -

range for the red or hue depending on the - current color mode.

- type: Number - - name: max2 - description: | -

range for the green or saturation depending - on the current color mode.

- type: Number - - name: max3 - description: | -

range for the blue or brightness/lightness - depending on the current color mode.

- type: Number - - name: maxA - description: | -

range for the alpha.

- type: Number - optional: true - chainable: 1 -chainable: true ---- - - -# colorMode diff --git a/src/content/reference/en/p5 copy/concat.mdx b/src/content/reference/en/p5 copy/concat.mdx deleted file mode 100644 index 1e83bf84c0..0000000000 --- a/src/content/reference/en/p5 copy/concat.mdx +++ /dev/null @@ -1,54 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L112 -title: concat -module: Data -submodule: Array Functions -file: src/utilities/array_functions.js -description: | -

Concatenates two arrays, maps to Array.concat(). Does not modify the - input arrays.

-line: 112 -deprecated: >- - Use arr1.concat(arr2) - instead. -isConstructor: false -itemtype: method -example: - - |- - -
- function setup() { - let arr1 = ['A', 'B', 'C']; - let arr2 = [1, 2, 3]; - - print(arr1); // ['A','B','C'] - print(arr2); // [1,2,3] - - let arr3 = concat(arr1, arr2); - - print(arr1); // ['A','B','C'] - print(arr2); // [1, 2, 3] - print(arr3); // ['A','B','C', 1, 2, 3] - } -
-class: p5 -params: - - name: a - description: | -

first Array to concatenate

- type: Array - - name: b - description: | -

second Array to concatenate

- type: Array -return: - description: concatenated array - type: Array -chainable: false ---- - - -# concat diff --git a/src/content/reference/en/p5 copy/cone.mdx b/src/content/reference/en/p5 copy/cone.mdx deleted file mode 100644 index ff0756d0a5..0000000000 --- a/src/content/reference/en/p5 copy/cone.mdx +++ /dev/null @@ -1,265 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L1730 -title: cone -module: Shape -submodule: 3D Primitives -file: src/webgl/3d_primitives.js -description: > -

Draws a cone.

- -

A cone is a 3D shape with triangular faces that connect a flat bottom to a - - single point. Cones with few faces look like pyramids. Cones with many - - faces have smooth surfaces.

- -

The first parameter, radius, is optional. If a - Number is passed, as in - - cone(20), it sets the radius of the cone’s base. By default, - radius is - - 50.

- -

The second parameter, height, is also optional. If a - Number is passed, - - as in cone(20, 30), it sets the cone’s height. By default, - height is - - set to the cone’s radius.

- -

The third parameter, detailX, is also optional. If a - Number is passed, - - as in cone(20, 30, 5), it sets the number of edges used to form - the - - cone's base. Using more edges makes the base look more like a circle. By - - default, detailX is 24.

- -

The fourth parameter, detailY, is also optional. If a - Number is passed, - - as in cone(20, 30, 5, 7), it sets the number of triangle - subdivisions to - - use along the y-axis connecting the base to the tip. All 3D shapes are made - - by connecting triangles to form their surfaces. By default, - detailY is 1.

- -

The fifth parameter, cap, is also optional. If a - false is passed, as - - in cone(20, 30, 5, 7, false) the cone’s base won’t be drawn. By - default, - - cap is true.

- -

Note: cone() can only be used in WebGL mode.

-line: 1730 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cone on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cone. - cone(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cone on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cone. - // Set its radius and height to 30. - cone(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cone on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cone. - // Set its radius to 30 and height to 50. - cone(30, 50); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cone on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cone. - // Set its radius to 30 and height to 50. - // Set its detailX to 5. - cone(30, 50, 5); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white pyramid on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cone. - // Set its radius to 30 and height to 50. - // Set its detailX to 5. - cone(30, 50, 5); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cone on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cone. - // Set its radius to 30 and height to 50. - // Set its detailX to 24 and detailY to 2. - cone(30, 50, 24, 2); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cone on a gray background. Its base is missing.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cone. - // Set its radius to 30 and height to 50. - // Set its detailX to 24 and detailY to 1. - // Don't draw its base. - cone(30, 50, 24, 1, false); - } - -
-class: p5 -params: - - name: radius - description: | -

radius of the cone's base. Defaults to 50.

- type: Number - optional: true - - name: height - description: | -

height of the cone. Defaults to the value of radius.

- type: Number - optional: true - - name: detailX - description: | -

number of edges used to draw the base. Defaults to 24.

- type: Integer - optional: true - - name: detailY - description: | -

number of triangle subdivisions along the y-axis. Defaults to 1.

- type: Integer - optional: true - - name: cap - description: | -

whether to draw the cone's base. Defaults to true.

- type: Boolean - optional: true -chainable: true ---- - - -# cone diff --git a/src/content/reference/en/p5 copy/console.mdx b/src/content/reference/en/p5 copy/console.mdx deleted file mode 100644 index 411b08357e..0000000000 --- a/src/content/reference/en/p5 copy/console.mdx +++ /dev/null @@ -1,99 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L1988 -title: console -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: > -

Prints a message to the web browser's console.

- -

The console - - object is helpful for printing messages while debugging. For example, it's - - common to add a console.log() statement while studying how a - section of - - code works:

- -
if (isPlaying === true) {
-    // Add a console.log() statement to make sure this block of code runs.
-    console.log('Got here!');
-
-    // Game logic.
-  }
-
-  
- -

console.error() is helpful for tracking errors because it - prints - - formatted messages. For example, it's common to encounter errors when - - loading media assets:

- -
// Logs an error message with special
-  formatting.
-
-  function handleFailure(error) {
-    console.error('Oops!', error);
-  }
-
-
-  // Try to load an image and call handleError() if it fails.
-
-  loadImage('https://example.com/cat.jpg', handleImage, handleError);
-
-  
-line: 1988 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - noCanvas(); - - // Prints "Hello!" to the console. - console.log('Hello!'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Try to load an image from a fake URL. - // Call handleError() if the image fails to load. - loadImage('https://example.com/cat.jpg', handleImage, handleError); - } - - // Displays the image. - function handleImage(img) { - image(img, 0, 0); - - describe('A cat on a gray background.'); - } - - // Prints the error. - function handleError(error) { - console.error('Oops!', error); - - describe('A gray square.'); - } - -
-class: p5 ---- - - -# console diff --git a/src/content/reference/en/p5 copy/constants/ADD.mdx b/src/content/reference/en/p5 copy/constants/ADD.mdx deleted file mode 100644 index 9148f688e9..0000000000 --- a/src/content/reference/en/p5 copy/constants/ADD.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L905 -title: ADD -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 905 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# ADD diff --git a/src/content/reference/en/p5 copy/constants/ALT.mdx b/src/content/reference/en/p5 copy/constants/ALT.mdx deleted file mode 100644 index a039e3919b..0000000000 --- a/src/content/reference/en/p5 copy/constants/ALT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L820 -title: ALT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 820 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# ALT diff --git a/src/content/reference/en/p5 copy/constants/ARROW.mdx b/src/content/reference/en/p5 copy/constants/ARROW.mdx deleted file mode 100644 index d2a0e065a1..0000000000 --- a/src/content/reference/en/p5 copy/constants/ARROW.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L55 -title: ARROW -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 55 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# ARROW diff --git a/src/content/reference/en/p5 copy/constants/AUTO.mdx b/src/content/reference/en/p5 copy/constants/AUTO.mdx deleted file mode 100644 index 185fb15902..0000000000 --- a/src/content/reference/en/p5 copy/constants/AUTO.mdx +++ /dev/null @@ -1,25 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L810 -title: AUTO -module: Constants -submodule: Constants -file: src/core/constants.js -description: > -

AUTO allows us to automatically set the width or height of an element (but - not both), - - based on the current height and width of the element. Only one parameter can - - be passed to the size function as - AUTO, at a time.

-line: 810 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# AUTO diff --git a/src/content/reference/en/p5 copy/constants/AXES.mdx b/src/content/reference/en/p5 copy/constants/AXES.mdx deleted file mode 100644 index c6f60b6b89..0000000000 --- a/src/content/reference/en/p5 copy/constants/AXES.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1171 -title: AXES -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1171 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# AXES diff --git a/src/content/reference/en/p5 copy/constants/BACKSPACE.mdx b/src/content/reference/en/p5 copy/constants/BACKSPACE.mdx deleted file mode 100644 index ee299ffcff..0000000000 --- a/src/content/reference/en/p5 copy/constants/BACKSPACE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L826 -title: BACKSPACE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 826 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# BACKSPACE diff --git a/src/content/reference/en/p5 copy/constants/BASELINE.mdx b/src/content/reference/en/p5 copy/constants/BASELINE.mdx deleted file mode 100644 index 200aa201ec..0000000000 --- a/src/content/reference/en/p5 copy/constants/BASELINE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L675 -title: BASELINE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 675 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# BASELINE diff --git a/src/content/reference/en/p5 copy/constants/BEVEL.mdx b/src/content/reference/en/p5 copy/constants/BEVEL.mdx deleted file mode 100644 index a4af3693f7..0000000000 --- a/src/content/reference/en/p5 copy/constants/BEVEL.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L777 -title: BEVEL -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 777 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# BEVEL diff --git a/src/content/reference/en/p5 copy/constants/BEZIER.mdx b/src/content/reference/en/p5 copy/constants/BEZIER.mdx deleted file mode 100644 index b2993b2c33..0000000000 --- a/src/content/reference/en/p5 copy/constants/BEZIER.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1073 -title: BEZIER -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1073 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# BEZIER diff --git a/src/content/reference/en/p5 copy/constants/BLEND.mdx b/src/content/reference/en/p5 copy/constants/BLEND.mdx deleted file mode 100644 index bf367f05eb..0000000000 --- a/src/content/reference/en/p5 copy/constants/BLEND.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L893 -title: BLEND -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 893 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# BLEND diff --git a/src/content/reference/en/p5 copy/constants/BLUR.mdx b/src/content/reference/en/p5 copy/constants/BLUR.mdx deleted file mode 100644 index 5580994e74..0000000000 --- a/src/content/reference/en/p5 copy/constants/BLUR.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1019 -title: BLUR -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1019 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# BLUR diff --git a/src/content/reference/en/p5 copy/constants/BOLD.mdx b/src/content/reference/en/p5 copy/constants/BOLD.mdx deleted file mode 100644 index 6069c955e8..0000000000 --- a/src/content/reference/en/p5 copy/constants/BOLD.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1036 -title: BOLD -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1036 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# BOLD diff --git a/src/content/reference/en/p5 copy/constants/BOLDITALIC.mdx b/src/content/reference/en/p5 copy/constants/BOLDITALIC.mdx deleted file mode 100644 index 2967579a9c..0000000000 --- a/src/content/reference/en/p5 copy/constants/BOLDITALIC.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1041 -title: BOLDITALIC -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1041 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# BOLDITALIC diff --git a/src/content/reference/en/p5 copy/constants/BOTTOM.mdx b/src/content/reference/en/p5 copy/constants/BOTTOM.mdx deleted file mode 100644 index b01ded11ea..0000000000 --- a/src/content/reference/en/p5 copy/constants/BOTTOM.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L670 -title: BOTTOM -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 670 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# BOTTOM diff --git a/src/content/reference/en/p5 copy/constants/BURN.mdx b/src/content/reference/en/p5 copy/constants/BURN.mdx deleted file mode 100644 index 7ba3764dac..0000000000 --- a/src/content/reference/en/p5 copy/constants/BURN.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L976 -title: BURN -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 976 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# BURN diff --git a/src/content/reference/en/p5 copy/constants/CENTER.mdx b/src/content/reference/en/p5 copy/constants/CENTER.mdx deleted file mode 100644 index cab0205cef..0000000000 --- a/src/content/reference/en/p5 copy/constants/CENTER.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L660 -title: CENTER -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 660 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# CENTER diff --git a/src/content/reference/en/p5 copy/constants/CHAR.mdx b/src/content/reference/en/p5 copy/constants/CHAR.mdx deleted file mode 100644 index 564855787a..0000000000 --- a/src/content/reference/en/p5 copy/constants/CHAR.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1046 -title: CHAR -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1046 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# CHAR diff --git a/src/content/reference/en/p5 copy/constants/CHORD.mdx b/src/content/reference/en/p5 copy/constants/CHORD.mdx deleted file mode 100644 index 40896bb3a1..0000000000 --- a/src/content/reference/en/p5 copy/constants/CHORD.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L750 -title: CHORD -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 750 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# CHORD diff --git a/src/content/reference/en/p5 copy/constants/CLAMP.mdx b/src/content/reference/en/p5 copy/constants/CLAMP.mdx deleted file mode 100644 index 977b02599d..0000000000 --- a/src/content/reference/en/p5 copy/constants/CLAMP.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1126 -title: CLAMP -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1126 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# CLAMP diff --git a/src/content/reference/en/p5 copy/constants/CLOSE.mdx b/src/content/reference/en/p5 copy/constants/CLOSE.mdx deleted file mode 100644 index 34bc946fe5..0000000000 --- a/src/content/reference/en/p5 copy/constants/CLOSE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L740 -title: CLOSE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 740 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# CLOSE diff --git a/src/content/reference/en/p5 copy/constants/CONTAIN.mdx b/src/content/reference/en/p5 copy/constants/CONTAIN.mdx deleted file mode 100644 index 59d56be350..0000000000 --- a/src/content/reference/en/p5 copy/constants/CONTAIN.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1188 -title: CONTAIN -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1188 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# CONTAIN diff --git a/src/content/reference/en/p5 copy/constants/CONTROL.mdx b/src/content/reference/en/p5 copy/constants/CONTROL.mdx deleted file mode 100644 index d620bb502d..0000000000 --- a/src/content/reference/en/p5 copy/constants/CONTROL.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L831 -title: CONTROL -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 831 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# CONTROL diff --git a/src/content/reference/en/p5 copy/constants/CORNER.mdx b/src/content/reference/en/p5 copy/constants/CORNER.mdx deleted file mode 100644 index e8b5eced3e..0000000000 --- a/src/content/reference/en/p5 copy/constants/CORNER.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L635 -title: CORNER -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 635 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# CORNER diff --git a/src/content/reference/en/p5 copy/constants/CORNERS.mdx b/src/content/reference/en/p5 copy/constants/CORNERS.mdx deleted file mode 100644 index 85e4226b1e..0000000000 --- a/src/content/reference/en/p5 copy/constants/CORNERS.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L640 -title: CORNERS -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 640 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# CORNERS diff --git a/src/content/reference/en/p5 copy/constants/COVER.mdx b/src/content/reference/en/p5 copy/constants/COVER.mdx deleted file mode 100644 index 3714b4bec3..0000000000 --- a/src/content/reference/en/p5 copy/constants/COVER.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1194 -title: COVER -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1194 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# COVER diff --git a/src/content/reference/en/p5 copy/constants/CROSS.mdx b/src/content/reference/en/p5 copy/constants/CROSS.mdx deleted file mode 100644 index eba1238e34..0000000000 --- a/src/content/reference/en/p5 copy/constants/CROSS.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L60 -title: CROSS -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 60 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# CROSS diff --git a/src/content/reference/en/p5 copy/constants/CURVE.mdx b/src/content/reference/en/p5 copy/constants/CURVE.mdx deleted file mode 100644 index 3e46bf2151..0000000000 --- a/src/content/reference/en/p5 copy/constants/CURVE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1078 -title: CURVE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1078 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# CURVE diff --git a/src/content/reference/en/p5 copy/constants/DARKEST.mdx b/src/content/reference/en/p5 copy/constants/DARKEST.mdx deleted file mode 100644 index b86d06dec4..0000000000 --- a/src/content/reference/en/p5 copy/constants/DARKEST.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L913 -title: DARKEST -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 913 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# DARKEST diff --git a/src/content/reference/en/p5 copy/constants/DEGREES.mdx b/src/content/reference/en/p5 copy/constants/DEGREES.mdx deleted file mode 100644 index c259f456ad..0000000000 --- a/src/content/reference/en/p5 copy/constants/DEGREES.mdx +++ /dev/null @@ -1,59 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L547 -title: DEGREES -module: Constants -submodule: Constants -file: src/core/constants.js -description: > -

A String constant that's used to set the - - angleMode().

- -

By default, functions such as rotate() - and - - sin() expect angles measured in units of - radians. - - Calling angleMode(DEGREES) ensures that angles are measured in - units of - - degrees.

- -

Note: TWO_PI radians equals 360˚.

-line: 547 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw a red arc from 0 to HALF_PI radians. - fill(255, 0, 0); - arc(50, 50, 80, 80, 0, HALF_PI); - - // Use degrees. - angleMode(DEGREES); - - // Draw a blue arc from 90˚ to 180˚. - fill(0, 0, 255); - arc(50, 50, 80, 80, 90, 180); - - describe('The bottom half of a circle drawn on a gray background. The bottom-right quarter is red. The bottom-left quarter is blue.'); - } - -
-class: p5 -type: String ---- - - -# DEGREES diff --git a/src/content/reference/en/p5 copy/constants/DELETE.mdx b/src/content/reference/en/p5 copy/constants/DELETE.mdx deleted file mode 100644 index 3bef8a3983..0000000000 --- a/src/content/reference/en/p5 copy/constants/DELETE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L836 -title: DELETE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 836 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# DELETE diff --git a/src/content/reference/en/p5 copy/constants/DIFFERENCE.mdx b/src/content/reference/en/p5 copy/constants/DIFFERENCE.mdx deleted file mode 100644 index 27d7e0880c..0000000000 --- a/src/content/reference/en/p5 copy/constants/DIFFERENCE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L924 -title: DIFFERENCE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 924 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# DIFFERENCE diff --git a/src/content/reference/en/p5 copy/constants/DILATE.mdx b/src/content/reference/en/p5 copy/constants/DILATE.mdx deleted file mode 100644 index 5eca5b06dd..0000000000 --- a/src/content/reference/en/p5 copy/constants/DILATE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1009 -title: DILATE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1009 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# DILATE diff --git a/src/content/reference/en/p5 copy/constants/DODGE.mdx b/src/content/reference/en/p5 copy/constants/DODGE.mdx deleted file mode 100644 index ba1594bfe4..0000000000 --- a/src/content/reference/en/p5 copy/constants/DODGE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L970 -title: DODGE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 970 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# DODGE diff --git a/src/content/reference/en/p5 copy/constants/DOWN_ARROW.mdx b/src/content/reference/en/p5 copy/constants/DOWN_ARROW.mdx deleted file mode 100644 index c1d80ae679..0000000000 --- a/src/content/reference/en/p5 copy/constants/DOWN_ARROW.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L841 -title: DOWN_ARROW -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 841 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# DOWN\_ARROW diff --git a/src/content/reference/en/p5 copy/constants/ENTER.mdx b/src/content/reference/en/p5 copy/constants/ENTER.mdx deleted file mode 100644 index 0ded2aec7f..0000000000 --- a/src/content/reference/en/p5 copy/constants/ENTER.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L846 -title: ENTER -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 846 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# ENTER diff --git a/src/content/reference/en/p5 copy/constants/ERODE.mdx b/src/content/reference/en/p5 copy/constants/ERODE.mdx deleted file mode 100644 index 9dba021043..0000000000 --- a/src/content/reference/en/p5 copy/constants/ERODE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1014 -title: ERODE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1014 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# ERODE diff --git a/src/content/reference/en/p5 copy/constants/ESCAPE.mdx b/src/content/reference/en/p5 copy/constants/ESCAPE.mdx deleted file mode 100644 index 53256ed7ce..0000000000 --- a/src/content/reference/en/p5 copy/constants/ESCAPE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L851 -title: ESCAPE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 851 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# ESCAPE diff --git a/src/content/reference/en/p5 copy/constants/EXCLUSION.mdx b/src/content/reference/en/p5 copy/constants/EXCLUSION.mdx deleted file mode 100644 index 61c3572125..0000000000 --- a/src/content/reference/en/p5 copy/constants/EXCLUSION.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L934 -title: EXCLUSION -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 934 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# EXCLUSION diff --git a/src/content/reference/en/p5 copy/constants/FALLBACK.mdx b/src/content/reference/en/p5 copy/constants/FALLBACK.mdx deleted file mode 100644 index 6c9f4ec37c..0000000000 --- a/src/content/reference/en/p5 copy/constants/FALLBACK.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1182 -title: FALLBACK -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1182 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# FALLBACK diff --git a/src/content/reference/en/p5 copy/constants/FILL.mdx b/src/content/reference/en/p5 copy/constants/FILL.mdx deleted file mode 100644 index 9e2ca1ce96..0000000000 --- a/src/content/reference/en/p5 copy/constants/FILL.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1090 -title: FILL -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1090 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# FILL diff --git a/src/content/reference/en/p5 copy/constants/FLAT.mdx b/src/content/reference/en/p5 copy/constants/FLAT.mdx deleted file mode 100644 index 50d8b95b1e..0000000000 --- a/src/content/reference/en/p5 copy/constants/FLAT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1138 -title: FLAT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1138 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# FLAT diff --git a/src/content/reference/en/p5 copy/constants/FLOAT.mdx b/src/content/reference/en/p5 copy/constants/FLOAT.mdx deleted file mode 100644 index b063ffc631..0000000000 --- a/src/content/reference/en/p5 copy/constants/FLOAT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1212 -title: FLOAT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1212 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# FLOAT diff --git a/src/content/reference/en/p5 copy/constants/GRAY.mdx b/src/content/reference/en/p5 copy/constants/GRAY.mdx deleted file mode 100644 index ca8a56d090..0000000000 --- a/src/content/reference/en/p5 copy/constants/GRAY.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L989 -title: GRAY -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 989 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# GRAY diff --git a/src/content/reference/en/p5 copy/constants/GRID.mdx b/src/content/reference/en/p5 copy/constants/GRID.mdx deleted file mode 100644 index 683bbf43f9..0000000000 --- a/src/content/reference/en/p5 copy/constants/GRID.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1165 -title: GRID -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1165 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# GRID diff --git a/src/content/reference/en/p5 copy/constants/HALF_FLOAT.mdx b/src/content/reference/en/p5 copy/constants/HALF_FLOAT.mdx deleted file mode 100644 index a70c409626..0000000000 --- a/src/content/reference/en/p5 copy/constants/HALF_FLOAT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1218 -title: HALF_FLOAT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1218 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# HALF\_FLOAT diff --git a/src/content/reference/en/p5 copy/constants/HALF_PI.mdx b/src/content/reference/en/p5 copy/constants/HALF_PI.mdx deleted file mode 100644 index 212458ee9e..0000000000 --- a/src/content/reference/en/p5 copy/constants/HALF_PI.mdx +++ /dev/null @@ -1,109 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L88 -title: HALF_PI -module: Constants -submodule: Constants -file: src/core/constants.js -description: > -

A Number constant that's approximately 1.5708.

- -

HALF_PI is half the value of the mathematical constant π. It's - useful for - - many tasks that involve rotation and oscillation. For example, calling - - rotate(HALF_PI) rotates the coordinate system - HALF_PI radians, which is - - a quarter turn (90˚).

- -

Note: TWO_PI radians equals 360˚, PI radians - equals 180˚, HALF_PI - - radians equals 90˚, and QUARTER_PI radians equals 45˚.

-line: 88 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw an arc from 0 to HALF_PI. - arc(50, 50, 80, 80, 0, HALF_PI); - - describe('The bottom-right quarter of a circle drawn in white on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Draw a line. - line(0, 0, 40, 0); - - // Rotate a quarter turn. - rotate(HALF_PI); - - // Draw the same line, rotated. - line(0, 0, 40, 0); - - describe('Two black lines on a gray background. One line extends from the center to the right. The other line extends from the center to the bottom.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A red circle and a blue circle oscillate from left to right on a gray background. The red circle appears to chase the blue circle.' - ); - } - - function draw() { - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Calculate the x-coordinates. - let x1 = 40 * sin(frameCount * 0.05); - let x2 = 40 * sin(frameCount * 0.05 + HALF_PI); - - // Style the oscillators. - noStroke(); - - // Draw the red oscillator. - fill(255, 0, 0); - circle(x1, 0, 20); - - // Draw the blue oscillator. - fill(0, 0, 255); - circle(x2, 0, 20); - } - -
-class: p5 -type: Number ---- - - -# HALF\_PI diff --git a/src/content/reference/en/p5 copy/constants/HAND.mdx b/src/content/reference/en/p5 copy/constants/HAND.mdx deleted file mode 100644 index 0bd864fb59..0000000000 --- a/src/content/reference/en/p5 copy/constants/HAND.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L65 -title: HAND -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 65 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# HAND diff --git a/src/content/reference/en/p5 copy/constants/HARD_LIGHT.mdx b/src/content/reference/en/p5 copy/constants/HARD_LIGHT.mdx deleted file mode 100644 index 9f3f9742fc..0000000000 --- a/src/content/reference/en/p5 copy/constants/HARD_LIGHT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L960 -title: HARD_LIGHT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 960 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# HARD\_LIGHT diff --git a/src/content/reference/en/p5 copy/constants/HSB.mdx b/src/content/reference/en/p5 copy/constants/HSB.mdx deleted file mode 100644 index d921d5405e..0000000000 --- a/src/content/reference/en/p5 copy/constants/HSB.mdx +++ /dev/null @@ -1,24 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L794 -title: HSB -module: Constants -submodule: Constants -file: src/core/constants.js -description: > -

HSB (hue, saturation, brightness) is a type of color model. - - You can learn more about it at - - HSB.

-line: 794 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# HSB diff --git a/src/content/reference/en/p5 copy/constants/HSL.mdx b/src/content/reference/en/p5 copy/constants/HSL.mdx deleted file mode 100644 index aa660c2da5..0000000000 --- a/src/content/reference/en/p5 copy/constants/HSL.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L803 -title: HSL -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 803 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# HSL diff --git a/src/content/reference/en/p5 copy/constants/IMAGE.mdx b/src/content/reference/en/p5 copy/constants/IMAGE.mdx deleted file mode 100644 index 479af890bb..0000000000 --- a/src/content/reference/en/p5 copy/constants/IMAGE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1108 -title: IMAGE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1108 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# IMAGE diff --git a/src/content/reference/en/p5 copy/constants/IMMEDIATE.mdx b/src/content/reference/en/p5 copy/constants/IMMEDIATE.mdx deleted file mode 100644 index 52b38ee8b5..0000000000 --- a/src/content/reference/en/p5 copy/constants/IMMEDIATE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1100 -title: IMMEDIATE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1100 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# IMMEDIATE diff --git a/src/content/reference/en/p5 copy/constants/INVERT.mdx b/src/content/reference/en/p5 copy/constants/INVERT.mdx deleted file mode 100644 index 9c383dd4d1..0000000000 --- a/src/content/reference/en/p5 copy/constants/INVERT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L999 -title: INVERT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 999 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# INVERT diff --git a/src/content/reference/en/p5 copy/constants/ITALIC.mdx b/src/content/reference/en/p5 copy/constants/ITALIC.mdx deleted file mode 100644 index d0a9a1f2e5..0000000000 --- a/src/content/reference/en/p5 copy/constants/ITALIC.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1031 -title: ITALIC -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1031 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# ITALIC diff --git a/src/content/reference/en/p5 copy/constants/LABEL.mdx b/src/content/reference/en/p5 copy/constants/LABEL.mdx deleted file mode 100644 index 92786b3feb..0000000000 --- a/src/content/reference/en/p5 copy/constants/LABEL.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1177 -title: LABEL -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1177 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# LABEL diff --git a/src/content/reference/en/p5 copy/constants/LANDSCAPE.mdx b/src/content/reference/en/p5 copy/constants/LANDSCAPE.mdx deleted file mode 100644 index c1709051cd..0000000000 --- a/src/content/reference/en/p5 copy/constants/LANDSCAPE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1150 -title: LANDSCAPE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1150 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# LANDSCAPE diff --git a/src/content/reference/en/p5 copy/constants/LEFT.mdx b/src/content/reference/en/p5 copy/constants/LEFT.mdx deleted file mode 100644 index 6e48fe2d99..0000000000 --- a/src/content/reference/en/p5 copy/constants/LEFT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L655 -title: LEFT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 655 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# LEFT diff --git a/src/content/reference/en/p5 copy/constants/LEFT_ARROW.mdx b/src/content/reference/en/p5 copy/constants/LEFT_ARROW.mdx deleted file mode 100644 index 8628e56688..0000000000 --- a/src/content/reference/en/p5 copy/constants/LEFT_ARROW.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L856 -title: LEFT_ARROW -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 856 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# LEFT\_ARROW diff --git a/src/content/reference/en/p5 copy/constants/LIGHTEST.mdx b/src/content/reference/en/p5 copy/constants/LIGHTEST.mdx deleted file mode 100644 index bd15662468..0000000000 --- a/src/content/reference/en/p5 copy/constants/LIGHTEST.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L918 -title: LIGHTEST -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 918 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# LIGHTEST diff --git a/src/content/reference/en/p5 copy/constants/LINEAR.mdx b/src/content/reference/en/p5 copy/constants/LINEAR.mdx deleted file mode 100644 index e56c663585..0000000000 --- a/src/content/reference/en/p5 copy/constants/LINEAR.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1063 -title: LINEAR -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1063 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# LINEAR diff --git a/src/content/reference/en/p5 copy/constants/LINES.mdx b/src/content/reference/en/p5 copy/constants/LINES.mdx deleted file mode 100644 index 9d7d5d2abc..0000000000 --- a/src/content/reference/en/p5 copy/constants/LINES.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L687 -title: LINES -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 687 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# LINES diff --git a/src/content/reference/en/p5 copy/constants/LINE_LOOP.mdx b/src/content/reference/en/p5 copy/constants/LINE_LOOP.mdx deleted file mode 100644 index 2a566fa4c7..0000000000 --- a/src/content/reference/en/p5 copy/constants/LINE_LOOP.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L699 -title: LINE_LOOP -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 699 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# LINE\_LOOP diff --git a/src/content/reference/en/p5 copy/constants/LINE_STRIP.mdx b/src/content/reference/en/p5 copy/constants/LINE_STRIP.mdx deleted file mode 100644 index 816e857d01..0000000000 --- a/src/content/reference/en/p5 copy/constants/LINE_STRIP.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L693 -title: LINE_STRIP -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 693 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# LINE\_STRIP diff --git a/src/content/reference/en/p5 copy/constants/MIRROR.mdx b/src/content/reference/en/p5 copy/constants/MIRROR.mdx deleted file mode 100644 index 9b2bcd7146..0000000000 --- a/src/content/reference/en/p5 copy/constants/MIRROR.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1131 -title: MIRROR -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1131 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# MIRROR diff --git a/src/content/reference/en/p5 copy/constants/MITER.mdx b/src/content/reference/en/p5 copy/constants/MITER.mdx deleted file mode 100644 index 533039ecc8..0000000000 --- a/src/content/reference/en/p5 copy/constants/MITER.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L782 -title: MITER -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 782 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# MITER diff --git a/src/content/reference/en/p5 copy/constants/MOVE.mdx b/src/content/reference/en/p5 copy/constants/MOVE.mdx deleted file mode 100644 index aea9bf8a71..0000000000 --- a/src/content/reference/en/p5 copy/constants/MOVE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L70 -title: MOVE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 70 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# MOVE diff --git a/src/content/reference/en/p5 copy/constants/MULTIPLY.mdx b/src/content/reference/en/p5 copy/constants/MULTIPLY.mdx deleted file mode 100644 index ce343b4bf2..0000000000 --- a/src/content/reference/en/p5 copy/constants/MULTIPLY.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L939 -title: MULTIPLY -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 939 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# MULTIPLY diff --git a/src/content/reference/en/p5 copy/constants/NEAREST.mdx b/src/content/reference/en/p5 copy/constants/NEAREST.mdx deleted file mode 100644 index 9fba7e46cf..0000000000 --- a/src/content/reference/en/p5 copy/constants/NEAREST.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1116 -title: NEAREST -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1116 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# NEAREST diff --git a/src/content/reference/en/p5 copy/constants/NORMAL.mdx b/src/content/reference/en/p5 copy/constants/NORMAL.mdx deleted file mode 100644 index 2c49e02fbf..0000000000 --- a/src/content/reference/en/p5 copy/constants/NORMAL.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1026 -title: NORMAL -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1026 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# NORMAL diff --git a/src/content/reference/en/p5 copy/constants/OPAQUE.mdx b/src/content/reference/en/p5 copy/constants/OPAQUE.mdx deleted file mode 100644 index 9ddf599dd1..0000000000 --- a/src/content/reference/en/p5 copy/constants/OPAQUE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L994 -title: OPAQUE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 994 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# OPAQUE diff --git a/src/content/reference/en/p5 copy/constants/OPEN.mdx b/src/content/reference/en/p5 copy/constants/OPEN.mdx deleted file mode 100644 index 29011d1e69..0000000000 --- a/src/content/reference/en/p5 copy/constants/OPEN.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L745 -title: OPEN -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 745 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# OPEN diff --git a/src/content/reference/en/p5 copy/constants/OPTION.mdx b/src/content/reference/en/p5 copy/constants/OPTION.mdx deleted file mode 100644 index 8ea0e625db..0000000000 --- a/src/content/reference/en/p5 copy/constants/OPTION.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L861 -title: OPTION -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 861 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# OPTION diff --git a/src/content/reference/en/p5 copy/constants/OVERLAY.mdx b/src/content/reference/en/p5 copy/constants/OVERLAY.mdx deleted file mode 100644 index ccb03411bb..0000000000 --- a/src/content/reference/en/p5 copy/constants/OVERLAY.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L955 -title: OVERLAY -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 955 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# OVERLAY diff --git a/src/content/reference/en/p5 copy/constants/P2D.mdx b/src/content/reference/en/p5 copy/constants/P2D.mdx deleted file mode 100644 index 83f09b1d9c..0000000000 --- a/src/content/reference/en/p5 copy/constants/P2D.mdx +++ /dev/null @@ -1,19 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L18 -title: P2D -module: Constants -submodule: Constants -file: src/core/constants.js -description: | -

The default, two-dimensional renderer.

-line: 18 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# P2D diff --git a/src/content/reference/en/p5 copy/constants/PI.mdx b/src/content/reference/en/p5 copy/constants/PI.mdx deleted file mode 100644 index bddf509592..0000000000 --- a/src/content/reference/en/p5 copy/constants/PI.mdx +++ /dev/null @@ -1,108 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L178 -title: PI -module: Constants -submodule: Constants -file: src/core/constants.js -description: > -

A Number constant that's approximately 3.1416.

- -

PI is the mathematical constant π. It's useful for many tasks - that - - involve rotation and oscillation. For example, calling rotate(PI) - rotates - - the coordinate system PI radians, which is a half turn - (180˚).

- -

Note: TWO_PI radians equals 360˚, PI radians - equals 180˚, HALF_PI - - radians equals 90˚, and QUARTER_PI radians equals 45˚.

-line: 178 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw an arc from 0 to PI. - arc(50, 50, 80, 80, 0, PI); - - describe('The bottom half of a circle drawn in white on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Draw a line. - line(0, 0, 40, 0); - - // Rotate a half turn. - rotate(PI); - - // Draw the same line, rotated. - line(0, 0, 40, 0); - - describe('A horizontal black line on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A red circle and a blue circle oscillate from left to right on a gray background. The circles drift apart, then meet in the middle, over and over again.' - ); - } - - function draw() { - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Calculate the x-coordinates. - let x1 = 40 * sin(frameCount * 0.05); - let x2 = 40 * sin(frameCount * 0.05 + PI); - - // Style the oscillators. - noStroke(); - - // Draw the red oscillator. - fill(255, 0, 0); - circle(x1, 0, 20); - - // Draw the blue oscillator. - fill(0, 0, 255); - circle(x2, 0, 20); - } - -
-class: p5 -type: Number ---- - - -# PI diff --git a/src/content/reference/en/p5 copy/constants/PIE.mdx b/src/content/reference/en/p5 copy/constants/PIE.mdx deleted file mode 100644 index 7be0810e6e..0000000000 --- a/src/content/reference/en/p5 copy/constants/PIE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L755 -title: PIE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 755 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# PIE diff --git a/src/content/reference/en/p5 copy/constants/POINTS.mdx b/src/content/reference/en/p5 copy/constants/POINTS.mdx deleted file mode 100644 index 8dea326a14..0000000000 --- a/src/content/reference/en/p5 copy/constants/POINTS.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L681 -title: POINTS -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 681 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# POINTS diff --git a/src/content/reference/en/p5 copy/constants/PORTRAIT.mdx b/src/content/reference/en/p5 copy/constants/PORTRAIT.mdx deleted file mode 100644 index 492546578c..0000000000 --- a/src/content/reference/en/p5 copy/constants/PORTRAIT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1155 -title: PORTRAIT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1155 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# PORTRAIT diff --git a/src/content/reference/en/p5 copy/constants/POSTERIZE.mdx b/src/content/reference/en/p5 copy/constants/POSTERIZE.mdx deleted file mode 100644 index 198c365591..0000000000 --- a/src/content/reference/en/p5 copy/constants/POSTERIZE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1004 -title: POSTERIZE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1004 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# POSTERIZE diff --git a/src/content/reference/en/p5 copy/constants/PROJECT.mdx b/src/content/reference/en/p5 copy/constants/PROJECT.mdx deleted file mode 100644 index ce6f7dbaac..0000000000 --- a/src/content/reference/en/p5 copy/constants/PROJECT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L760 -title: PROJECT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 760 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# PROJECT diff --git a/src/content/reference/en/p5 copy/constants/QUADRATIC.mdx b/src/content/reference/en/p5 copy/constants/QUADRATIC.mdx deleted file mode 100644 index 49e8d2cc19..0000000000 --- a/src/content/reference/en/p5 copy/constants/QUADRATIC.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1068 -title: QUADRATIC -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1068 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# QUADRATIC diff --git a/src/content/reference/en/p5 copy/constants/QUADS.mdx b/src/content/reference/en/p5 copy/constants/QUADS.mdx deleted file mode 100644 index c67a193a4f..0000000000 --- a/src/content/reference/en/p5 copy/constants/QUADS.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L723 -title: QUADS -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 723 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# QUADS diff --git a/src/content/reference/en/p5 copy/constants/QUAD_STRIP.mdx b/src/content/reference/en/p5 copy/constants/QUAD_STRIP.mdx deleted file mode 100644 index c1ce9d4291..0000000000 --- a/src/content/reference/en/p5 copy/constants/QUAD_STRIP.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L728 -title: QUAD_STRIP -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 728 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# QUAD\_STRIP diff --git a/src/content/reference/en/p5 copy/constants/QUARTER_PI.mdx b/src/content/reference/en/p5 copy/constants/QUARTER_PI.mdx deleted file mode 100644 index 5f4cc24bc1..0000000000 --- a/src/content/reference/en/p5 copy/constants/QUARTER_PI.mdx +++ /dev/null @@ -1,109 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L267 -title: QUARTER_PI -module: Constants -submodule: Constants -file: src/core/constants.js -description: > -

A Number constant that's approximately 0.7854.

- -

QUARTER_PI is one-fourth the value of the mathematical - constant π. It's - - useful for many tasks that involve rotation and oscillation. For example, - - calling rotate(QUARTER_PI) rotates the coordinate system - QUARTER_PI - - radians, which is an eighth of a turn (45˚).

- -

Note: TWO_PI radians equals 360˚, PI radians - equals 180˚, HALF_PI - - radians equals 90˚, and QUARTER_PI radians equals 45˚.

-line: 267 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw an arc from 0 to QUARTER_PI. - arc(50, 50, 80, 80, 0, QUARTER_PI); - - describe('A one-eighth slice of a circle drawn in white on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Draw a line. - line(0, 0, 40, 0); - - // Rotate an eighth turn. - rotate(QUARTER_PI); - - // Draw the same line, rotated. - line(0, 0, 40, 0); - - describe('Two black lines that form a "V" opening towards the bottom-right corner of a gray square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A red circle and a blue circle oscillate from left to right on a gray background. The red circle appears to chase the blue circle.' - ); - } - - function draw() { - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Calculate the x-coordinates. - let x1 = 40 * sin(frameCount * 0.05); - let x2 = 40 * sin(frameCount * 0.05 + QUARTER_PI); - - // Style the oscillators. - noStroke(); - - // Draw the red oscillator. - fill(255, 0, 0); - circle(x1, 0, 20); - - // Draw the blue oscillator. - fill(0, 0, 255); - circle(x2, 0, 20); - } - -
-class: p5 -type: Number ---- - - -# QUARTER\_PI diff --git a/src/content/reference/en/p5 copy/constants/RADIANS.mdx b/src/content/reference/en/p5 copy/constants/RADIANS.mdx deleted file mode 100644 index 856db37b9f..0000000000 --- a/src/content/reference/en/p5 copy/constants/RADIANS.mdx +++ /dev/null @@ -1,66 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L587 -title: RADIANS -module: Constants -submodule: Constants -file: src/core/constants.js -description: > -

A String constant that's used to set the - - angleMode().

- -

By default, functions such as rotate() - and - - sin() expect angles measured in units of - radians. - - Calling angleMode(RADIANS) ensures that angles are measured in - units of - - radians. Doing so can be useful if the - - angleMode() has been set to - - DEGREES.

- -

Note: TWO_PI radians equals 360˚.

-line: 587 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use degrees. - angleMode(DEGREES); - - // Draw a red arc from 0˚ to 90˚. - fill(255, 0, 0); - arc(50, 50, 80, 80, 0, 90); - - // Use radians. - angleMode(RADIANS); - - // Draw a blue arc from HALF_PI to PI. - fill(0, 0, 255); - arc(50, 50, 80, 80, HALF_PI, PI); - - describe('The bottom half of a circle drawn on a gray background. The bottom-right quarter is red. The bottom-left quarter is blue.'); - } - -
-class: p5 -type: String ---- - - -# RADIANS diff --git a/src/content/reference/en/p5 copy/constants/RADIUS.mdx b/src/content/reference/en/p5 copy/constants/RADIUS.mdx deleted file mode 100644 index 95f1dcdeef..0000000000 --- a/src/content/reference/en/p5 copy/constants/RADIUS.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L645 -title: RADIUS -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 645 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# RADIUS diff --git a/src/content/reference/en/p5 copy/constants/REMOVE.mdx b/src/content/reference/en/p5 copy/constants/REMOVE.mdx deleted file mode 100644 index c2daffc564..0000000000 --- a/src/content/reference/en/p5 copy/constants/REMOVE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L899 -title: REMOVE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 899 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# REMOVE diff --git a/src/content/reference/en/p5 copy/constants/REPEAT.mdx b/src/content/reference/en/p5 copy/constants/REPEAT.mdx deleted file mode 100644 index c9e75c8bec..0000000000 --- a/src/content/reference/en/p5 copy/constants/REPEAT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1121 -title: REPEAT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1121 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# REPEAT diff --git a/src/content/reference/en/p5 copy/constants/REPLACE.mdx b/src/content/reference/en/p5 copy/constants/REPLACE.mdx deleted file mode 100644 index 8a04f06130..0000000000 --- a/src/content/reference/en/p5 copy/constants/REPLACE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L949 -title: REPLACE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 949 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# REPLACE diff --git a/src/content/reference/en/p5 copy/constants/RETURN.mdx b/src/content/reference/en/p5 copy/constants/RETURN.mdx deleted file mode 100644 index 3069efc256..0000000000 --- a/src/content/reference/en/p5 copy/constants/RETURN.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L866 -title: RETURN -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 866 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# RETURN diff --git a/src/content/reference/en/p5 copy/constants/RGB.mdx b/src/content/reference/en/p5 copy/constants/RGB.mdx deleted file mode 100644 index b0ae826064..0000000000 --- a/src/content/reference/en/p5 copy/constants/RGB.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L789 -title: RGB -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 789 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# RGB diff --git a/src/content/reference/en/p5 copy/constants/RGBA.mdx b/src/content/reference/en/p5 copy/constants/RGBA.mdx deleted file mode 100644 index 256949cfd1..0000000000 --- a/src/content/reference/en/p5 copy/constants/RGBA.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1224 -title: RGBA -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1224 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# RGBA diff --git a/src/content/reference/en/p5 copy/constants/RIGHT.mdx b/src/content/reference/en/p5 copy/constants/RIGHT.mdx deleted file mode 100644 index e9f69e8a80..0000000000 --- a/src/content/reference/en/p5 copy/constants/RIGHT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L650 -title: RIGHT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 650 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# RIGHT diff --git a/src/content/reference/en/p5 copy/constants/RIGHT_ARROW.mdx b/src/content/reference/en/p5 copy/constants/RIGHT_ARROW.mdx deleted file mode 100644 index 731ab29fb5..0000000000 --- a/src/content/reference/en/p5 copy/constants/RIGHT_ARROW.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L871 -title: RIGHT_ARROW -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 871 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# RIGHT\_ARROW diff --git a/src/content/reference/en/p5 copy/constants/ROUND.mdx b/src/content/reference/en/p5 copy/constants/ROUND.mdx deleted file mode 100644 index 50426d2636..0000000000 --- a/src/content/reference/en/p5 copy/constants/ROUND.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L772 -title: ROUND -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 772 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# ROUND diff --git a/src/content/reference/en/p5 copy/constants/SCREEN.mdx b/src/content/reference/en/p5 copy/constants/SCREEN.mdx deleted file mode 100644 index 65f2e6192d..0000000000 --- a/src/content/reference/en/p5 copy/constants/SCREEN.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L944 -title: SCREEN -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 944 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# SCREEN diff --git a/src/content/reference/en/p5 copy/constants/SHIFT.mdx b/src/content/reference/en/p5 copy/constants/SHIFT.mdx deleted file mode 100644 index e48b091ab3..0000000000 --- a/src/content/reference/en/p5 copy/constants/SHIFT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L876 -title: SHIFT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 876 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# SHIFT diff --git a/src/content/reference/en/p5 copy/constants/SMOOTH.mdx b/src/content/reference/en/p5 copy/constants/SMOOTH.mdx deleted file mode 100644 index 816be1029b..0000000000 --- a/src/content/reference/en/p5 copy/constants/SMOOTH.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1143 -title: SMOOTH -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1143 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# SMOOTH diff --git a/src/content/reference/en/p5 copy/constants/SOFT_LIGHT.mdx b/src/content/reference/en/p5 copy/constants/SOFT_LIGHT.mdx deleted file mode 100644 index 846e6fe72b..0000000000 --- a/src/content/reference/en/p5 copy/constants/SOFT_LIGHT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L965 -title: SOFT_LIGHT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 965 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# SOFT\_LIGHT diff --git a/src/content/reference/en/p5 copy/constants/SQUARE.mdx b/src/content/reference/en/p5 copy/constants/SQUARE.mdx deleted file mode 100644 index 7b5da139d7..0000000000 --- a/src/content/reference/en/p5 copy/constants/SQUARE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L766 -title: SQUARE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 766 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# SQUARE diff --git a/src/content/reference/en/p5 copy/constants/STROKE.mdx b/src/content/reference/en/p5 copy/constants/STROKE.mdx deleted file mode 100644 index 16cfa32e5e..0000000000 --- a/src/content/reference/en/p5 copy/constants/STROKE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1085 -title: STROKE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1085 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# STROKE diff --git a/src/content/reference/en/p5 copy/constants/SUBTRACT.mdx b/src/content/reference/en/p5 copy/constants/SUBTRACT.mdx deleted file mode 100644 index 2bd6d94fe9..0000000000 --- a/src/content/reference/en/p5 copy/constants/SUBTRACT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L929 -title: SUBTRACT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 929 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# SUBTRACT diff --git a/src/content/reference/en/p5 copy/constants/TAB.mdx b/src/content/reference/en/p5 copy/constants/TAB.mdx deleted file mode 100644 index cf89117ae4..0000000000 --- a/src/content/reference/en/p5 copy/constants/TAB.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L881 -title: TAB -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 881 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# TAB diff --git a/src/content/reference/en/p5 copy/constants/TAU.mdx b/src/content/reference/en/p5 copy/constants/TAU.mdx deleted file mode 100644 index a553339913..0000000000 --- a/src/content/reference/en/p5 copy/constants/TAU.mdx +++ /dev/null @@ -1,114 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L357 -title: TAU -module: Constants -submodule: Constants -file: src/core/constants.js -description: > -

A Number constant that's approximately 6.2382.

- -

TAU is twice the value of the mathematical constant π. It's - useful for - - many tasks that involve rotation and oscillation. For example, calling - - rotate(TAU) rotates the coordinate system TAU - radians, which is one - - full turn (360˚). TAU and TWO_PI are equal.

- -

Note: TAU radians equals 360˚, PI radians equals - 180˚, HALF_PI - - radians equals 90˚, and QUARTER_PI radians equals 45˚.

-line: 357 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw an arc from 0 to TAU. - arc(50, 50, 80, 80, 0, TAU); - - describe('A white circle drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Draw a line. - line(0, 0, 40, 0); - - // Rotate a full turn. - rotate(TAU); - - // Style the second line. - strokeWeight(5); - - // Draw the same line, shorter and rotated. - line(0, 0, 20, 0); - - describe( - 'Two horizontal black lines on a gray background. A thick line extends from the center toward the right. A thin line extends from the end of the thick line.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A red circle with a blue center oscillates from left to right on a gray background.' - ); - } - - function draw() { - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Calculate the x-coordinates. - let x1 = 40 * sin(frameCount * 0.05); - let x2 = 40 * sin(frameCount * 0.05 + TAU); - - // Style the oscillators. - noStroke(); - - // Draw the red oscillator. - fill(255, 0, 0); - circle(x1, 0, 20); - - // Draw the blue oscillator, smaller. - fill(0, 0, 255); - circle(x2, 0, 10); - } - -
-class: p5 -type: Number ---- - - -# TAU diff --git a/src/content/reference/en/p5 copy/constants/TESS.mdx b/src/content/reference/en/p5 copy/constants/TESS.mdx deleted file mode 100644 index e6f853e8ab..0000000000 --- a/src/content/reference/en/p5 copy/constants/TESS.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L734 -title: TESS -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 734 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# TESS diff --git a/src/content/reference/en/p5 copy/constants/TEXT.mdx b/src/content/reference/en/p5 copy/constants/TEXT.mdx deleted file mode 100644 index 157a90001a..0000000000 --- a/src/content/reference/en/p5 copy/constants/TEXT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L75 -title: TEXT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 75 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# TEXT diff --git a/src/content/reference/en/p5 copy/constants/TEXTURE.mdx b/src/content/reference/en/p5 copy/constants/TEXTURE.mdx deleted file mode 100644 index 8ada92f376..0000000000 --- a/src/content/reference/en/p5 copy/constants/TEXTURE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1095 -title: TEXTURE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1095 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# TEXTURE diff --git a/src/content/reference/en/p5 copy/constants/THRESHOLD.mdx b/src/content/reference/en/p5 copy/constants/THRESHOLD.mdx deleted file mode 100644 index f12e6ea336..0000000000 --- a/src/content/reference/en/p5 copy/constants/THRESHOLD.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L984 -title: THRESHOLD -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 984 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# THRESHOLD diff --git a/src/content/reference/en/p5 copy/constants/TOP.mdx b/src/content/reference/en/p5 copy/constants/TOP.mdx deleted file mode 100644 index a91b5f4824..0000000000 --- a/src/content/reference/en/p5 copy/constants/TOP.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L665 -title: TOP -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 665 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# TOP diff --git a/src/content/reference/en/p5 copy/constants/TRIANGLES.mdx b/src/content/reference/en/p5 copy/constants/TRIANGLES.mdx deleted file mode 100644 index ec281d033e..0000000000 --- a/src/content/reference/en/p5 copy/constants/TRIANGLES.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L705 -title: TRIANGLES -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 705 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# TRIANGLES diff --git a/src/content/reference/en/p5 copy/constants/TRIANGLE_FAN.mdx b/src/content/reference/en/p5 copy/constants/TRIANGLE_FAN.mdx deleted file mode 100644 index bcd5d5f5a1..0000000000 --- a/src/content/reference/en/p5 copy/constants/TRIANGLE_FAN.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L711 -title: TRIANGLE_FAN -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 711 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# TRIANGLE\_FAN diff --git a/src/content/reference/en/p5 copy/constants/TRIANGLE_STRIP.mdx b/src/content/reference/en/p5 copy/constants/TRIANGLE_STRIP.mdx deleted file mode 100644 index fefe226e17..0000000000 --- a/src/content/reference/en/p5 copy/constants/TRIANGLE_STRIP.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L717 -title: TRIANGLE_STRIP -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 717 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# TRIANGLE\_STRIP diff --git a/src/content/reference/en/p5 copy/constants/TWO_PI.mdx b/src/content/reference/en/p5 copy/constants/TWO_PI.mdx deleted file mode 100644 index ed62a10b0f..0000000000 --- a/src/content/reference/en/p5 copy/constants/TWO_PI.mdx +++ /dev/null @@ -1,114 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L452 -title: TWO_PI -module: Constants -submodule: Constants -file: src/core/constants.js -description: > -

A Number constant that's approximately 6.2382.

- -

TWO_PI is twice the value of the mathematical constant π. It's - useful for - - many tasks that involve rotation and oscillation. For example, calling - - rotate(TWO_PI) rotates the coordinate system TWO_PI - radians, which is - - one full turn (360˚). TWO_PI and TAU are equal.

- -

Note: TWO_PI radians equals 360˚, PI radians - equals 180˚, HALF_PI - - radians equals 90˚, and QUARTER_PI radians equals 45˚.

-line: 452 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw an arc from 0 to TWO_PI. - arc(50, 50, 80, 80, 0, TWO_PI); - - describe('A white circle drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Draw a line. - line(0, 0, 40, 0); - - // Rotate a full turn. - rotate(TWO_PI); - - // Style the second line. - strokeWeight(5); - - // Draw the same line, shorter and rotated. - line(0, 0, 20, 0); - - describe( - 'Two horizontal black lines on a gray background. A thick line extends from the center toward the right. A thin line extends from the end of the thick line.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A red circle with a blue center oscillates from left to right on a gray background.' - ); - } - - function draw() { - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Calculate the x-coordinates. - let x1 = 40 * sin(frameCount * 0.05); - let x2 = 40 * sin(frameCount * 0.05 + TWO_PI); - - // Style the oscillators. - noStroke(); - - // Draw the red oscillator. - fill(255, 0, 0); - circle(x1, 0, 20); - - // Draw the blue oscillator, smaller. - fill(0, 0, 255); - circle(x2, 0, 10); - } - -
-class: p5 -type: Number ---- - - -# TWO\_PI diff --git a/src/content/reference/en/p5 copy/constants/UNSIGNED_BYTE.mdx b/src/content/reference/en/p5 copy/constants/UNSIGNED_BYTE.mdx deleted file mode 100644 index 00acfe29c0..0000000000 --- a/src/content/reference/en/p5 copy/constants/UNSIGNED_BYTE.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1200 -title: UNSIGNED_BYTE -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1200 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# UNSIGNED\_BYTE diff --git a/src/content/reference/en/p5 copy/constants/UNSIGNED_INT.mdx b/src/content/reference/en/p5 copy/constants/UNSIGNED_INT.mdx deleted file mode 100644 index f060682a13..0000000000 --- a/src/content/reference/en/p5 copy/constants/UNSIGNED_INT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1206 -title: UNSIGNED_INT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1206 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# UNSIGNED\_INT diff --git a/src/content/reference/en/p5 copy/constants/UP_ARROW.mdx b/src/content/reference/en/p5 copy/constants/UP_ARROW.mdx deleted file mode 100644 index e0e0326aa6..0000000000 --- a/src/content/reference/en/p5 copy/constants/UP_ARROW.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L886 -title: UP_ARROW -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 886 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# UP\_ARROW diff --git a/src/content/reference/en/p5 copy/constants/VERSION.mdx b/src/content/reference/en/p5 copy/constants/VERSION.mdx deleted file mode 100644 index f9f62fca55..0000000000 --- a/src/content/reference/en/p5 copy/constants/VERSION.mdx +++ /dev/null @@ -1,19 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L9 -title: VERSION -module: Constants -submodule: Constants -file: src/core/constants.js -description: | -

Version of this p5.js.

-line: 9 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# VERSION diff --git a/src/content/reference/en/p5 copy/constants/WAIT.mdx b/src/content/reference/en/p5 copy/constants/WAIT.mdx deleted file mode 100644 index 833f77ee4f..0000000000 --- a/src/content/reference/en/p5 copy/constants/WAIT.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L80 -title: WAIT -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 80 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# WAIT diff --git a/src/content/reference/en/p5 copy/constants/WEBGL.mdx b/src/content/reference/en/p5 copy/constants/WEBGL.mdx deleted file mode 100644 index 2919ec489c..0000000000 --- a/src/content/reference/en/p5 copy/constants/WEBGL.mdx +++ /dev/null @@ -1,91 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L24 -title: WEBGL -module: Constants -submodule: Constants -file: src/core/constants.js -description: > -

One of the two render modes in p5.js, used for computationally intensive - tasks like 3D rendering and shaders.

- -

WEBGL differs from the default P2D renderer in the following - ways:

- - - -

To learn more about WEBGL mode, check out all the interactive WEBGL - tutorials in the "Tutorials" section of this website, or read the wiki - article "Getting - started with WebGL in p5".

-line: 24 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# WEBGL diff --git a/src/content/reference/en/p5 copy/constants/WEBGL2.mdx b/src/content/reference/en/p5 copy/constants/WEBGL2.mdx deleted file mode 100644 index 68c6ca83fa..0000000000 --- a/src/content/reference/en/p5 copy/constants/WEBGL2.mdx +++ /dev/null @@ -1,21 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L45 -title: WEBGL2 -module: Constants -submodule: Constants -file: src/core/constants.js -description: | -

One of the two possible values of a WebGL canvas (either WEBGL or WEBGL2), - which can be used to determine what capabilities the rendering environment - has.

-line: 45 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# WEBGL2 diff --git a/src/content/reference/en/p5 copy/constants/WORD.mdx b/src/content/reference/en/p5 copy/constants/WORD.mdx deleted file mode 100644 index 03f13b4874..0000000000 --- a/src/content/reference/en/p5 copy/constants/WORD.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/constants.js#L1051 -title: WORD -module: Constants -submodule: Constants -file: src/core/constants.js -description: '' -line: 1051 -isConstructor: false -itemtype: property -class: p5 -type: String ---- - - -# WORD diff --git a/src/content/reference/en/p5 copy/constrain.mdx b/src/content/reference/en/p5 copy/constrain.mdx deleted file mode 100644 index d869ce2e74..0000000000 --- a/src/content/reference/en/p5 copy/constrain.mdx +++ /dev/null @@ -1,86 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L91 -title: constrain -module: Math -submodule: Calculation -file: src/math/calculation.js -description: | -

Constrains a number between a minimum and maximum value.

-line: 91 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A black dot drawn on a gray square follows the mouse from left to right. Its movement is constrained to the middle third of the square.'); - } - - function draw() { - background(200); - - let x = constrain(mouseX, 33, 67); - let y = 50; - - strokeWeight(5); - point(x, y); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('Two vertical lines. Two circles move horizontally with the mouse. One circle stops at the vertical lines.'); - } - - function draw() { - background(200); - - // Set boundaries and draw them. - let leftWall = 25; - let rightWall = 75; - line(leftWall, 0, leftWall, 100); - line(rightWall, 0, rightWall, 100); - - // Draw a circle that follows the mouse freely. - fill(255); - circle(mouseX, 33, 9); - - // Draw a circle that's constrained. - let xc = constrain(mouseX, leftWall, rightWall); - fill(0); - circle(xc, 67, 9); - } - -
-class: p5 -params: - - name: 'n' - description: | -

number to constrain.

- type: Number - - name: low - description: | -

minimum limit.

- type: Number - - name: high - description: | -

maximum limit.

- type: Number -return: - description: constrained number. - type: Number -chainable: false ---- - - -# constrain diff --git a/src/content/reference/en/p5 copy/copy.mdx b/src/content/reference/en/p5 copy/copy.mdx deleted file mode 100644 index 059df56434..0000000000 --- a/src/content/reference/en/p5 copy/copy.mdx +++ /dev/null @@ -1,144 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L288 -title: copy -module: Image -submodule: Pixels -file: src/image/pixels.js -description: > -

Copies pixels from a source image to a region of the canvas.

- -

The first parameter, srcImage, is the - - p5.Image object to blend. The source - image can be - - the canvas itself or a - - p5.Image object. copy() will - scale pixels from - - the source region if it isn't the same size as the destination region.

- -

The next four parameters, sx, sy, - sw, and sh determine the region - - to copy from the source image. (sx, sy) is the top-left corner of - the - - region. sw and sh are the region's width and - height.

- -

The next four parameters, dx, dy, - dw, and dh determine the region - - of the canvas to copy into. (dx, dy) is the top-left corner of - the - - region. dw and dh are the region's width and - height.

-line: 288 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/rockies.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Use the mountains as the background. - background(img); - - // Copy a region of pixels to another spot. - copy(img, 7, 22, 10, 10, 35, 25, 50, 50); - - // Outline the copied region. - stroke(255); - noFill(); - square(7, 22, 10); - - describe('An image of a mountain landscape. A square region is outlined in white. A larger square contains a pixelated view of the outlined region.'); - } - -
-class: p5 -overloads: - - line: 288 - params: - - name: srcImage - description: | -

source image.

- type: p5.Image|p5.Element - - name: sx - description: | -

x-coordinate of the source's upper-left corner.

- type: Integer - - name: sy - description: | -

y-coordinate of the source's upper-left corner.

- type: Integer - - name: sw - description: | -

source image width.

- type: Integer - - name: sh - description: | -

source image height.

- type: Integer - - name: dx - description: | -

x-coordinate of the destination's upper-left corner.

- type: Integer - - name: dy - description: | -

y-coordinate of the destination's upper-left corner.

- type: Integer - - name: dw - description: | -

destination image width.

- type: Integer - - name: dh - description: | -

destination image height.

- type: Integer - - line: 345 - params: - - name: sx - description: '' - type: Integer - - name: sy - description: '' - type: Integer - - name: sw - description: '' - type: Integer - - name: sh - description: '' - type: Integer - - name: dx - description: '' - type: Integer - - name: dy - description: '' - type: Integer - - name: dw - description: '' - type: Integer - - name: dh - description: '' - type: Integer -chainable: false ---- - - -# copy diff --git a/src/content/reference/en/p5 copy/cos.mdx b/src/content/reference/en/p5 copy/cos.mdx deleted file mode 100644 index cd6468fc4f..0000000000 --- a/src/content/reference/en/p5 copy/cos.mdx +++ /dev/null @@ -1,107 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L281 -title: cos -module: Math -submodule: Trigonometry -file: src/math/trigonometry.js -description: > -

Calculates the cosine of an angle.

- -

cos() is useful for many geometric tasks in creative coding. - The values - - returned oscillate between -1 and 1 as the input angle increases. - cos() - - calculates the cosine of an angle, using radians by default, or according to - - if angleMode() setting (RADIANS or - DEGREES).

-line: 281 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A white ball on a string oscillates left and right.'); - } - - function draw() { - background(200); - - // Calculate the coordinates. - let x = 30 * cos(frameCount * 0.05) + 50; - let y = 50; - - // Draw the oscillator. - line(50, y, x, y); - circle(x, y, 20); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - describe('A series of black dots form a wave pattern.'); - } - - function draw() { - // Calculate the coordinates. - let x = frameCount; - let y = 30 * cos(x * 0.1) + 50; - - // Draw the point. - point(x, y); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - describe('A series of black dots form an infinity symbol.'); - } - - function draw() { - // Calculate the coordinates. - let x = 30 * cos(frameCount * 0.1) + 50; - let y = 10 * sin(frameCount * 0.2) + 50; - - // Draw the point. - point(x, y); - } - -
-class: p5 -params: - - name: angle - description: > -

the angle, in radians by default, or according to - - if angleMode() setting (RADIANS or - DEGREES).

- type: Number -return: - description: cosine of the angle. - type: Number -chainable: false ---- - - -# cos diff --git a/src/content/reference/en/p5 copy/createA.mdx b/src/content/reference/en/p5 copy/createA.mdx deleted file mode 100644 index 669ce45a27..0000000000 --- a/src/content/reference/en/p5 copy/createA.mdx +++ /dev/null @@ -1,93 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L724 -title: createA -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates an element that links to another web page.

- -

The first parmeter, href, is a string that sets the URL of the - linked - - page.

- -

The second parameter, html, is a string that sets the inner - HTML of the - - link. It's common to use text, images, or buttons as links.

- -

The third parameter, target, is optional. It's a string that - tells the - - web browser where to open the link. By default, links open in the current - - browser tab. Passing '_blank' will cause the link to open in a - new - - browser tab. MDN describes a few - - other options.

-line: 724 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an anchor element that links to p5js.org. - let a = createA('https://p5js.org/', 'p5*js'); - a.position(25, 35); - - describe('The text "p5*js" written at the center of a gray square.'); - } - -
- -
- - function setup() { - background(200); - - // Create an anchor tag that links to p5js.org. - // Open the link in a new tab. - let a = createA('https://p5js.org/', 'p5*js', '_blank'); - a.position(25, 35); - - describe('The text "p5*js" written at the center of a gray square.'); - } - -
-class: p5 -params: - - name: href - description: | -

URL of linked page.

- type: String - - name: html - description: | -

inner HTML of link element to display.

- type: String - - name: target - description: | -

target where the new link should open, - either '_blank', '_self', '_parent', or '_top'.

- type: String - optional: true -return: - description: new p5.Element object. - type: p5.Element -chainable: false ---- - - -# createA diff --git a/src/content/reference/en/p5 copy/createAudio.mdx b/src/content/reference/en/p5 copy/createAudio.mdx deleted file mode 100644 index 24b3bce36b..0000000000 --- a/src/content/reference/en/p5 copy/createAudio.mdx +++ /dev/null @@ -1,83 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L2213 -title: createAudio -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a hidden element for simple audio - playback.

- -

createAudio() returns a new - - p5.MediaElement object.

- -

The first parameter, src, is the path the video. If a single - string is - - passed, as in '/assets/video.mp4', a single video is loaded. An - array - - of strings can be used to load the same video in different formats. For - - example, ['/assets/video.mp4', '/assets/video.ogv', - '/assets/video.webm']. - - This is useful for ensuring that the video can play across different - - browsers with different capabilities. See - - MDN - - for more information about supported formats.

- -

The second parameter, callback, is optional. It's a function - to call once - - the audio is ready to play.

-line: 2213 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - noCanvas(); - - // Load the audio. - let beat = createAudio('/assets/beat.mp3'); - - // Show the default audio controls. - beat.showControls(); - - describe('An audio beat plays when the user double-clicks the square.'); - } - -
-class: p5 -params: - - name: src - description: | -

path to an audio file, or an array of paths - for supporting different browsers.

- type: 'String|String[]' - optional: true - - name: callback - description: | -

function to call once the audio is ready to play.

- type: Function - optional: true -return: - description: new p5.MediaElement object. - type: p5.MediaElement -chainable: false ---- - - -# createAudio diff --git a/src/content/reference/en/p5 copy/createButton.mdx b/src/content/reference/en/p5 copy/createButton.mdx deleted file mode 100644 index 9ff2d66faf..0000000000 --- a/src/content/reference/en/p5 copy/createButton.mdx +++ /dev/null @@ -1,109 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L924 -title: createButton -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a element.

- -

The first parameter, label, is a string that sets the label - displayed on - - the button.

- -

The second parameter, value, is optional. It's a string that - sets the - - button's value. See - - MDN - - for more details.

-line: 924 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a button and place it beneath the canvas. - let button = createButton('click me'); - button.position(0, 100); - - // Call repaint() when the button is pressed. - button.mousePressed(repaint); - - describe('A gray square with a button that says "click me" beneath it. The square changes color when the button is clicked.'); - } - - // Change the background color. - function repaint() { - let g = random(255); - background(g); - } - -
- -
- - let button; - - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a button and set its value to 0. - // Place the button beneath the canvas. - button = createButton('click me', 'red'); - button.position(0, 100); - - // Call randomColor() when the button is pressed. - button.mousePressed(randomColor); - - describe('A red square with a button that says "click me" beneath it. The square changes color when the button is clicked.'); - } - - function draw() { - // Use the button's value to set the background color. - let c = button.value(); - background(c); - } - - // Set the button's value to a random color. - function randomColor() { - let c = random(['red', 'green', 'blue', 'yellow']); - button.value(c); - } - -
-class: p5 -params: - - name: label - description: | -

label displayed on the button.

- type: String - - name: value - description: | -

value of the button.

- type: String - optional: true -return: - description: new p5.Element object. - type: p5.Element -chainable: false ---- - - -# createButton diff --git a/src/content/reference/en/p5 copy/createCamera.mdx b/src/content/reference/en/p5 copy/createCamera.mdx deleted file mode 100644 index 8fbb13ce5d..0000000000 --- a/src/content/reference/en/p5 copy/createCamera.mdx +++ /dev/null @@ -1,99 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L638 -title: createCamera -module: 3D -submodule: Camera -file: src/webgl/p5.Camera.js -description: > -

Creates a new p5.Camera object and - sets it - - as the current (active) camera.

- -

The new camera is initialized with a default position (0, 0, - 800) and a - - default perspective projection. Its properties can be controlled with - - p5.Camera methods such as - - myCamera.lookAt(0, 0, 0).

- -

Note: Every 3D sketch starts with a default camera initialized. - - This camera can be controlled with the functions - - camera(), - - perspective(), - - ortho(), and - - frustum() if it's the only camera in the - scene.

- -

Note: createCamera() can only be used in WebGL mode.

-line: 638 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Double-click to toggle between cameras. - - let cam1; - let cam2; - let usingCam1 = true; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the first camera. - // Keep its default settings. - cam1 = createCamera(); - - // Create the second camera. - // Place it at the top-left. - // Point it at the origin. - cam2 = createCamera(); - cam2.setPosition(400, -400, 800); - cam2.lookAt(0, 0, 0); - - // Set the current camera to cam1. - setCamera(cam1); - - describe('A white cube on a gray background. The camera toggles between frontal and aerial views when the user double-clicks.'); - } - - function draw() { - background(200); - - // Draw the box. - box(); - } - - // Toggle the current camera when the user double-clicks. - function doubleClicked() { - if (usingCam1 === true) { - setCamera(cam2); - usingCam1 = false; - } else { - setCamera(cam1); - usingCam1 = true; - } - } - -
-class: p5 -return: - description: the new camera. - type: p5.Camera -chainable: false ---- - - -# createCamera diff --git a/src/content/reference/en/p5 copy/createCanvas.mdx b/src/content/reference/en/p5 copy/createCanvas.mdx deleted file mode 100644 index 600d7e3545..0000000000 --- a/src/content/reference/en/p5 copy/createCanvas.mdx +++ /dev/null @@ -1,191 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L15 -title: createCanvas -module: Rendering -submodule: Rendering -file: src/core/rendering.js -description: > -

Creates a canvas element on the web page.

- -

createCanvas() creates the main drawing canvas for a sketch. - It should - - only be called once at the beginning of setup(). - - Calling createCanvas() more than once causes unpredictable - behavior.

- -

The first two parameters, width and height, are - optional. They set the - - dimensions of the canvas and the values of the - - width and height system - - variables. For example, calling createCanvas(900, 500) creates a - canvas - - that's 900×500 pixels. By default, width and height - are both 100.

- -

The third parameter is also optional. If either of the constants - P2D or - - WEBGL is passed, as in createCanvas(900, 500, - WEBGL), then it will set - - the sketch's rendering mode. If an existing - - HTMLCanvasElement - - is passed, as in createCanvas(900, 500, myCanvas), then it will - be used - - by the sketch.

- -

The fourth parameter is also optional. If an existing - - HTMLCanvasElement - - is passed, as in createCanvas(900, 500, WEBGL, myCanvas), then it - will be - - used by the sketch.

- -

Note: In WebGL mode, the canvas will use a WebGL2 context if it's supported - - by the browser. Check the webglVersion - - system variable to check what version is being used, or call - - setAttributes({ version: 1 }) to create a WebGL1 context.

-line: 15 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Draw a diagonal line. - line(0, 0, width, height); - - describe('A diagonal line drawn from top-left to bottom-right on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 50); - - background(180); - - // Draw a diagonal line. - line(0, 0, width, height); - - describe('A diagonal line drawn from top-left to bottom-right on a gray background.'); - } - -
- -
- - // Use WebGL mode. - - function setup() { - createCanvas(100, 100, WEBGL); - - background(180); - - // Draw a diagonal line. - line(-width / 2, -height / 2, width / 2, height / 2); - - describe('A diagonal line drawn from top-left to bottom-right on a gray background.'); - } - -
- -
- - function setup() { - // Create a p5.Renderer object. - let cnv = createCanvas(50, 50); - - // Position the canvas. - cnv.position(10, 20); - - background(180); - - // Draw a diagonal line. - line(0, 0, width, height); - - describe('A diagonal line drawn from top-left to bottom-right on a gray background.'); - } - -
-class: p5 -return: - description: new `p5.Renderer` that holds the canvas. - type: p5.Renderer -overloads: - - line: 15 - params: - - name: width - description: | -

width of the canvas. Defaults to 100.

- type: Number - optional: true - - name: height - description: | -

height of the canvas. Defaults to 100.

- type: Number - optional: true - - name: renderer - description: | -

either P2D or WEBGL. Defaults to P2D.

- type: Constant - optional: true - - name: canvas - description: | -

existing canvas element that should be used for the sketch.

- type: HTMLCanvasElement - optional: true - return: - description: new `p5.Renderer` that holds the canvas. - type: p5.Renderer - - line: 119 - params: - - name: width - description: '' - type: Number - optional: true - - name: height - description: '' - type: Number - optional: true - - name: canvas - description: '' - type: HTMLCanvasElement - optional: true - return: - description: '' - type: p5.Renderer -chainable: false ---- - - -# createCanvas diff --git a/src/content/reference/en/p5 copy/createCapture.mdx b/src/content/reference/en/p5 copy/createCapture.mdx deleted file mode 100644 index 1087d14b1a..0000000000 --- a/src/content/reference/en/p5 copy/createCapture.mdx +++ /dev/null @@ -1,189 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L2295 -title: createCapture -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a element that "captures" the audio/video - stream from - - the webcam and microphone.

- -

createCapture() returns a new - - p5.MediaElement object. Videos are - shown by - - default. They can be hidden by calling capture.hide() and drawn - to the - - canvas using image().

- -

The first parameter, type, is optional. It sets the type of - capture to - - use. By default, createCapture() captures both audio and video. - If VIDEO - - is passed, as in createCapture(VIDEO), only video will be - captured. - - If AUDIO is passed, as in createCapture(AUDIO), only - audio will be - - captured. A constraints object can also be passed to customize the stream. - - See the - - W3C documentation for possible properties. Different browsers support - different - - properties.

- -

The 'flipped' property is an optional property which can be set to - {flipped:true} - - to mirror the video output.If it is true then it means that video will be - mirrored - - or flipped and if nothing is mentioned then by default it will be - false.

- -

The second parameter,callback, is optional. It's a function to - call once - - the capture is ready for use. The callback function should have one - - parameter, stream, that's a - - MediaStream object.

- -

Note: createCapture() only works when running a sketch locally - or using HTTPS. Learn more - - here - - and here.

-line: 2295 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - noCanvas(); - - // Create the video capture. - createCapture(VIDEO); - - describe('A video stream from the webcam.'); - } - -
- -
- - let capture; - - function setup() { - createCanvas(100, 100); - - // Create the video capture and hide the element. - capture = createCapture(VIDEO); - capture.hide(); - - describe('A video stream from the webcam with inverted colors.'); - } - - function draw() { - // Draw the video capture within the canvas. - image(capture, 0, 0, width, width * capture.height / capture.width); - - // Invert the colors in the stream. - filter(INVERT); - } - -
-
- - let capture; - - function setup() { - createCanvas(100, 100); - - // Create the video capture with mirrored output. - capture = createCapture(VIDEO,{ flipped:true }); - capture.size(100,100); - - describe('A video stream from the webcam with flipped or mirrored output.'); - } - - -
- -
- - function setup() { - createCanvas(480, 120); - - // Create a constraints object. - let constraints = { - video: { - mandatory: { - minWidth: 1280, - minHeight: 720 - }, - optional: [{ maxFrameRate: 10 }] - }, - audio: false - }; - - // Create the video capture. - createCapture(constraints); - - describe('A video stream from the webcam.'); - } - -
-class: p5 -params: - - name: type - description: | -

type of capture, either AUDIO or VIDEO, - or a constraints object. Both video and audio - audio streams are captured by default.

- type: String|Constant|Object - optional: true - - name: flipped - description: > -

flip the capturing video and mirror the output with - {flipped:true}. By - default it is false.

- type: Object - optional: true - - name: callback - description: | -

function to call once the stream - has loaded.

- type: Function - optional: true -return: - description: new p5.MediaElement object. - type: p5.MediaElement -chainable: false ---- - - -# createCapture diff --git a/src/content/reference/en/p5 copy/createCheckbox.mdx b/src/content/reference/en/p5 copy/createCheckbox.mdx deleted file mode 100644 index 45335be2d4..0000000000 --- a/src/content/reference/en/p5 copy/createCheckbox.mdx +++ /dev/null @@ -1,131 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1008 -title: createCheckbox -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a checkbox element.

- -

Checkboxes extend the p5.Element - class with a - - checked() method. Calling myBox.checked() returns - true if it the box - - is checked and false if not.

- -

The first parameter, label, is optional. It's a string that - sets the label - - to display next to the checkbox.

- -

The second parameter, value, is also optional. It's a boolean - that sets the - - checkbox's value.

-line: 1008 -isConstructor: false -itemtype: method -example: - - |- - -
- - let checkbox; - - function setup() { - createCanvas(100, 100); - - // Create a checkbox and place it beneath the canvas. - checkbox = createCheckbox(); - checkbox.position(0, 100); - - describe('A black square with a checkbox beneath it. The square turns white when the box is checked.'); - } - - function draw() { - // Use the checkbox to set the background color. - if (checkbox.checked()) { - background(255); - } else { - background(0); - } - } - -
- -
- - let checkbox; - - function setup() { - createCanvas(100, 100); - - // Create a checkbox and place it beneath the canvas. - // Label the checkbox "white". - checkbox = createCheckbox(' white'); - checkbox.position(0, 100); - - describe('A black square with a checkbox labeled "white" beneath it. The square turns white when the box is checked.'); - } - - function draw() { - // Use the checkbox to set the background color. - if (checkbox.checked()) { - background(255); - } else { - background(0); - } - } - -
- -
- - let checkbox; - - function setup() { - createCanvas(100, 100); - - // Create a checkbox and place it beneath the canvas. - // Label the checkbox "white" and set its value to true. - checkbox = createCheckbox(' white', true); - checkbox.position(0, 100); - - describe('A white square with a checkbox labeled "white" beneath it. The square turns black when the box is unchecked.'); - } - - function draw() { - // Use the checkbox to set the background color. - if (checkbox.checked()) { - background(255); - } else { - background(0); - } - } - -
-class: p5 -params: - - name: label - description: | -

label displayed after the checkbox.

- type: String - optional: true - - name: value - description: > -

value of the checkbox. Checked is true and unchecked is - false.

- type: Boolean - optional: true -return: - description: new p5.Element object. - type: p5.Element -chainable: false ---- - - -# createCheckbox diff --git a/src/content/reference/en/p5 copy/createColorPicker.mdx b/src/content/reference/en/p5 copy/createColorPicker.mdx deleted file mode 100644 index 0c34a0593e..0000000000 --- a/src/content/reference/en/p5 copy/createColorPicker.mdx +++ /dev/null @@ -1,101 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1759 -title: createColorPicker -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a color picker element.

- -

The parameter, value, is optional. If a color string or - - p5.Color object is passed, it will set - the default - - color.

- -

Color pickers extend the p5.Element - class with a - - couple of helpful methods for managing colors:

- -
    - -
  • myPicker.value() returns the current color as a hex string in - the format '#rrggbb'.
  • - -
  • myPicker.color() returns the current color as a p5.Color object.
  • - -
-line: 1759 -isConstructor: false -itemtype: method -example: - - |- - -
- - let myPicker; - - function setup() { - createCanvas(100, 100); - - // Create a color picker and set its position. - myPicker = createColorPicker('deeppink'); - myPicker.position(0, 100); - - describe('A pink square with a color picker beneath it. The square changes color when the user picks a new color.'); - } - - function draw() { - // Use the color picker to paint the background. - let c = myPicker.color(); - background(c); - } - -
- -
- - let myPicker; - - function setup() { - createCanvas(100, 100); - - // Create a color picker and set its position. - myPicker = createColorPicker('deeppink'); - myPicker.position(0, 100); - - describe('A number with the format "#rrggbb" is displayed on a pink canvas. The background color and number change when the user picks a new color.'); - } - - function draw() { - // Use the color picker to paint the background. - let c = myPicker.value(); - background(c); - - // Display the current color as a hex string. - text(c, 25, 55); - } - -
-class: p5 -params: - - name: value - description: > -

default color as a CSS color string.

- type: String|p5.Color - optional: true -return: - description: new p5.Element object. - type: p5.Element -chainable: false ---- - - -# createColorPicker diff --git a/src/content/reference/en/p5 copy/createConvolver.mdx b/src/content/reference/en/p5 copy/createConvolver.mdx deleted file mode 100644 index 89fba3be4e..0000000000 --- a/src/content/reference/en/p5 copy/createConvolver.mdx +++ /dev/null @@ -1,78 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L8885 -title: createConvolver -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: | -

Create a p5.Convolver. Accepts a path to a soundfile - that will be used to generate an impulse response.

-line: 8885 -isConstructor: false -itemtype: method -example: - - |- - -
- let cVerb, sound; - function preload() { - // We have both MP3 and OGG versions of all sound assets - soundFormats('ogg', 'mp3'); - - // Try replacing 'bx-spring' with other soundfiles like - // 'concrete-tunnel' 'small-plate' 'drum' 'beatbox' - cVerb = createConvolver('/assets/bx-spring.mp3'); - - // Try replacing 'Damscray_DancingTiger' with - // 'beat', 'doorbell', lucky_dragons_-_power_melody' - sound = loadSound('/assets/Damscray_DancingTiger.mp3'); - } - - function setup() { - let cnv = createCanvas(100, 100); - cnv.mousePressed(playSound); - background(220); - text('tap to play', 20, 20); - - // disconnect from main output... - sound.disconnect(); - - // ...and process with cVerb - // so that we only hear the convolution - cVerb.process(sound); - } - - function playSound() { - sound.play(); - } -
-class: p5 -params: - - name: path - description: | -

path to a sound file

- type: String - - name: callback - description: | -

function to call if loading is successful. - The object will be passed in as the argument - to the callback function.

- type: Function - optional: true - - name: errorCallback - description: | -

function to call if loading is not successful. - A custom error will be passed in as the argument - to the callback function.

- type: Function - optional: true -return: - description: '' - type: p5.Convolver -chainable: false ---- - - -# createConvolver diff --git a/src/content/reference/en/p5 copy/createDiv.mdx b/src/content/reference/en/p5 copy/createDiv.mdx deleted file mode 100644 index 610e0a4f67..0000000000 --- a/src/content/reference/en/p5 copy/createDiv.mdx +++ /dev/null @@ -1,72 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L491 -title: createDiv -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a

element.

- -

elements are commonly used as containers for - - other elements.

- -

The parameter html is optional. It accepts a string that sets - the - - inner HTML of the new

.

-line: 491 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a div element and set its position. - let div = createDiv('p5*js'); - div.position(25, 35); - - describe('A gray square with the text "p5*js" written in its center.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an h3 element within the div. - let div = createDiv('

p5*js

'); - div.position(20, 5); - - describe('A gray square with the text "p5*js" written in its center.'); - } -
-
-class: p5 -params: - - name: html - description: > -

inner HTML for the new <div></div> - element.

- type: String - optional: true -return: - description: new p5.Element object. - type: p5.Element -chainable: false ---- - - -# createDiv diff --git a/src/content/reference/en/p5 copy/createElement.mdx b/src/content/reference/en/p5 copy/createElement.mdx deleted file mode 100644 index 5969416251..0000000000 --- a/src/content/reference/en/p5 copy/createElement.mdx +++ /dev/null @@ -1,78 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L2493 -title: createElement -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a new p5.Element object.

- -

The first parameter, tag, is a string an HTML tag such as - 'h5'.

- -

The second parameter, content, is optional. It's a string that - sets the - - HTML content to insert into the new element. New elements have no content - - by default.

-line: 2493 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an h5 element with nothing in it. - createElement('h5'); - - describe('A gray square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an h5 element with the content "p5*js". - let h5 = createElement('h5', 'p5*js'); - - // Set the element's style and position. - h5.style('color', 'deeppink'); - h5.position(30, 15); - - describe('The text "p5*js" written in pink in the middle of a gray square.'); - } - -
-class: p5 -params: - - name: tag - description: | -

tag for the new element.

- type: String - - name: content - description: | -

HTML content to insert into the element.

- type: String - optional: true -return: - description: new p5.Element object. - type: p5.Element -chainable: false ---- - - -# createElement diff --git a/src/content/reference/en/p5 copy/createFileInput.mdx b/src/content/reference/en/p5 copy/createFileInput.mdx deleted file mode 100644 index 295f2a0434..0000000000 --- a/src/content/reference/en/p5 copy/createFileInput.mdx +++ /dev/null @@ -1,138 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1942 -title: createFileInput -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates an element of type - 'file'.

- -

createFileInput() allows users to select local files for use - in a sketch. - - It returns a p5.File object.

- -

The first parameter, callback, is a function that's called - when the file - - loads. The callback function should have one parameter, file, - that's a - - p5.File object.

- -

The second parameter, multiple, is optional. It's a boolean - value that - - allows loading multiple files if set to true. If - true, callback - - will be called once per file.

-line: 1942 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Use the file input to select an image to - // load and display. - let input; - let img; - - function setup() { - createCanvas(100, 100); - - // Create a file input and place it beneath - // the canvas. - input = createFileInput(handleImage); - input.position(0, 100); - - describe('A gray square with a file input beneath it. If the user selects an image file to load, it is displayed on the square.'); - } - - function draw() { - background(200); - - // Draw the image if loaded. - if (img) { - image(img, 0, 0, width, height); - } - } - - // Create an image if the file is an image. - function handleImage(file) { - if (file.type === 'image') { - img = createImg(file.data, ''); - img.hide(); - } else { - img = null; - } - } - -
- -
- - // Use the file input to select multiple images - // to load and display. - let input; - let images = []; - - function setup() { - // Create a file input and place it beneath - // the canvas. Allow it to load multiple files. - input = createFileInput(handleImage, true); - input.position(0, 100); - } - - function draw() { - background(200); - - // Draw the images if loaded. Each image - // is drawn 20 pixels lower than the - // previous image. - for (let i = 0; i < images.length; i += 1) { - // Calculate the y-coordinate. - let y = i * 20; - - // Draw the image. - image(images[i], 0, y, 100, 100); - } - - describe('A gray square with a file input beneath it. If the user selects multiple image files to load, they are displayed on the square.'); - } - - // Create an image if the file is an image, - // then add it to the images array. - function handleImage(file) { - if (file.type === 'image') { - let img = createImg(file.data, ''); - img.hide(); - images.push(img); - } - } - -
-class: p5 -params: - - name: callback - description: | -

function to call once the file loads.

- type: Function - - name: multiple - description: | -

allow multiple files to be selected.

- type: Boolean - optional: true -return: - description: new p5.File object. - type: p5.File -chainable: false ---- - - -# createFileInput diff --git a/src/content/reference/en/p5 copy/createFilterShader.mdx b/src/content/reference/en/p5 copy/createFilterShader.mdx deleted file mode 100644 index 5c6c9a4ec5..0000000000 --- a/src/content/reference/en/p5 copy/createFilterShader.mdx +++ /dev/null @@ -1,148 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L540 -title: createFilterShader -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Creates a p5.Shader object to be used - with the - - filter() function.

- -

createFilterShader() works like - - createShader() but has a default - vertex - - shader included. createFilterShader() is intended to be used - along with - - filter() for filtering the contents of a - canvas. - - A filter shader will be applied to the whole canvas instead of just - - p5.Geometry objects.

- -

The parameter, fragSrc, sets the fragment shader. It’s a - string that - - contains the fragment shader program written in - - GLSL.

- -

The p5.Shader object that's created - has some - - uniforms that can be set:

- -
    - -
  • sampler2D tex0, which contains the canvas contents as a - texture.
  • - -
  • vec2 canvasSize, which is the width and height of the canvas, - not including pixel density.
  • - -
  • vec2 texelSize, which is the size of a physical pixel - including pixel density. This is calculated as 1.0 / (width * - density) for the pixel width and 1.0 / (height * density) - for the pixel height.
  • - -
- -

The p5.Shader that's created also - provides - - varying vec2 vTexCoord, a coordinate with values between 0 and 1. - - vTexCoord describes where on the canvas the pixel will be - drawn.

- -

For more info about filters and shaders, see Adam Ferriss' repo of shader - examples - - or the Introduction to - Shaders tutorial.

-line: 540 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - let fragSrc = `precision highp float; - void main() { - gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); - }`; - - createCanvas(100, 100, WEBGL); - let s = createFilterShader(fragSrc); - filter(s); - describe('a yellow canvas'); - } - -
- -
- - let img, s; - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - function setup() { - let fragSrc = `precision highp float; - - // x,y coordinates, given from the vertex shader - varying vec2 vTexCoord; - - // the canvas contents, given from filter() - uniform sampler2D tex0; - // other useful information from the canvas - uniform vec2 texelSize; - uniform vec2 canvasSize; - // a custom variable from this sketch - uniform float darkness; - - void main() { - // get the color at current pixel - vec4 color = texture2D(tex0, vTexCoord); - // set the output color - color.b = 1.0; - color *= darkness; - gl_FragColor = vec4(color.rgb, 1.0); - }`; - - createCanvas(100, 100, WEBGL); - s = createFilterShader(fragSrc); - } - function draw() { - image(img, -50, -50); - s.setUniform('darkness', 0.5); - filter(s); - describe('a image of bricks tinted dark blue'); - } - -
-class: p5 -params: - - name: fragSrc - description: | -

source code for the fragment shader.

- type: String -return: - description: new shader object created from the fragment shader. - type: p5.Shader -chainable: false ---- - - -# createFilterShader diff --git a/src/content/reference/en/p5 copy/createFramebuffer.mdx b/src/content/reference/en/p5 copy/createFramebuffer.mdx deleted file mode 100644 index 80d8199779..0000000000 --- a/src/content/reference/en/p5 copy/createFramebuffer.mdx +++ /dev/null @@ -1,208 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L495 -title: createFramebuffer -module: Rendering -submodule: Rendering -file: src/core/rendering.js -description: > -

Creates and a new p5.Framebuffer - object.

- -

p5.Framebuffer objects are - separate drawing - - surfaces that can be used as textures in WebGL mode. They're similar to - - p5.Graphics objects and generally run - much - - faster when used as textures.

- -

The parameter, options, is optional. An object can be passed - to configure - - the p5.Framebuffer object. The - available - - properties are:

- -
    - -
  • format: data format of the texture, either - UNSIGNED_BYTE, FLOAT, or HALF_FLOAT. - Default is UNSIGNED_BYTE.
  • - -
  • channels: whether to store RGB or - RGBA color channels. Default is to match the main canvas which is - RGBA.
  • - -
  • depth: whether to include a depth buffer. Default is - true.
  • - -
  • depthFormat: data format of depth information, either - UNSIGNED_INT or FLOAT. Default is - FLOAT.
  • - -
  • stencil: whether to include a stencil buffer for masking. - depth must be true for this feature to work. - Defaults to the value of depth which is true.
  • - -
  • antialias: whether to perform anti-aliasing. If set to - true, as in { antialias: true }, 2 samples will be - used by default. The number of samples can also be set, as in { - antialias: 4 }. Default is to match setAttributes() which is - false (true in Safari).
  • - -
  • width: width of the p5.Framebuffer object. Default is to - always match the main canvas width.
  • - -
  • height: height of the p5.Framebuffer object. Default is to - always match the main canvas height.
  • - -
  • density: pixel density of the p5.Framebuffer object. Default is to - always match the main canvas pixel density.
  • - -
  • textureFiltering: how to read values from the p5.Framebuffer object. Either - LINEAR (nearby pixels will be interpolated) or - NEAREST (no interpolation). Generally, use LINEAR - when using the texture as an image and NEAREST if reading the - texture as data. Default is LINEAR.
  • - -
- -

If the width, height, or density - attributes are set, they won't automatically match the main canvas and must be - changed manually.

- -

Note: createFramebuffer() can only be used in WebGL mode.

-line: 495 -isConstructor: false -itemtype: method -example: - - |- - -
- - let myBuffer; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Framebuffer object. - myBuffer = createFramebuffer(); - - describe('A grid of white toruses rotating against a dark gray background.'); - } - - function draw() { - background(50); - - // Start drawing to the p5.Framebuffer object. - myBuffer.begin(); - - // Clear the drawing surface. - clear(); - - // Turn on the lights. - lights(); - - // Rotate the coordinate system. - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - - // Style the torus. - noStroke(); - - // Draw the torus. - torus(20); - - // Stop drawing to the p5.Framebuffer object. - myBuffer.end(); - - // Iterate from left to right. - for (let x = -50; x < 50; x += 25) { - // Iterate from top to bottom. - for (let y = -50; y < 50; y += 25) { - // Draw the p5.Framebuffer object to the canvas. - image(myBuffer, x, y, 25, 25); - } - } - } - -
- -
- - let myBuffer; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create an options object. - let options = { width: 25, height: 25 }; - - // Create a p5.Framebuffer object. - // Use options for configuration. - myBuffer = createFramebuffer(options); - - describe('A grid of white toruses rotating against a dark gray background.'); - } - - function draw() { - background(50); - - // Start drawing to the p5.Framebuffer object. - myBuffer.begin(); - - // Clear the drawing surface. - clear(); - - // Turn on the lights. - lights(); - - // Rotate the coordinate system. - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - - // Style the torus. - noStroke(); - - // Draw the torus. - torus(5, 2.5); - - // Stop drawing to the p5.Framebuffer object. - myBuffer.end(); - - // Iterate from left to right. - for (let x = -50; x < 50; x += 25) { - // Iterate from top to bottom. - for (let y = -50; y < 50; y += 25) { - // Draw the p5.Framebuffer object to the canvas. - image(myBuffer, x, y); - } - } - } - -
-class: p5 -params: - - name: options - description: | -

configuration options.

- type: Object - optional: true -return: - description: new framebuffer. - type: p5.Framebuffer -chainable: false ---- - - -# createFramebuffer diff --git a/src/content/reference/en/p5 copy/createGraphics.mdx b/src/content/reference/en/p5 copy/createGraphics.mdx deleted file mode 100644 index 6d75f158f4..0000000000 --- a/src/content/reference/en/p5 copy/createGraphics.mdx +++ /dev/null @@ -1,191 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L370 -title: createGraphics -module: Rendering -submodule: Rendering -file: src/core/rendering.js -description: > -

Creates a p5.Graphics object.

- -

createGraphics() creates an offscreen drawing canvas (graphics - buffer) - - and returns it as a p5.Graphics - object. Drawing - - to a separate graphics buffer can be helpful for performance and for - - organizing code.

- -

The first two parameters, width and height, are - optional. They set the - - dimensions of the p5.Graphics object. - For - - example, calling createGraphics(900, 500) creates a graphics - buffer - - that's 900×500 pixels.

- -

The third parameter is also optional. If either of the constants - P2D or - - WEBGL is passed, as in createGraphics(900, 500, - WEBGL), then it will set - - the p5.Graphics object's rendering - mode. If an - - existing - - HTMLCanvasElement - - is passed, as in createGraphics(900, 500, myCanvas), then it will - be used - - by the graphics buffer.

- -

The fourth parameter is also optional. If an existing - - HTMLCanvasElement - - is passed, as in createGraphics(900, 500, WEBGL, myCanvas), then - it will be - - used by the graphics buffer.

- -

Note: In WebGL mode, the p5.Graphics object - - will use a WebGL2 context if it's supported by the browser. Check the - - webglVersion system variable to - check what - - version is being used, or call setAttributes({ version: 1 }) to - create a - - WebGL1 context.

-line: 370 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Double-click to draw the contents of the graphics buffer. - - let pg; - - function setup() { - createCanvas(100, 100); - - background(180); - - // Create the p5.Graphics object. - pg = createGraphics(50, 50); - - // Draw to the graphics buffer. - pg.background(100); - pg.circle(pg.width / 2, pg.height / 2, 20); - - describe('A gray square. A smaller, darker square with a white circle at its center appears when the user double-clicks.'); - } - - // Display the graphics buffer when the user double-clicks. - function doubleClicked() { - if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { - image(pg, 25, 25); - } - } - -
- -
- - // Double-click to draw the contents of the graphics buffer. - - let pg; - - function setup() { - createCanvas(100, 100); - - background(180); - - // Create the p5.Graphics object in WebGL mode. - pg = createGraphics(50, 50, WEBGL); - - // Draw to the graphics buffer. - pg.background(100); - pg.lights(); - pg.noStroke(); - pg.rotateX(QUARTER_PI); - pg.rotateY(QUARTER_PI); - pg.torus(15, 5); - - describe('A gray square. A smaller, darker square with a white torus at its center appears when the user double-clicks.'); - } - - // Display the graphics buffer when the user double-clicks. - function doubleClicked() { - if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { - image(pg, 25, 25); - } - } - -
-class: p5 -return: - description: new graphics buffer. - type: p5.Graphics -overloads: - - line: 370 - params: - - name: width - description: | -

width of the graphics buffer.

- type: Number - - name: height - description: | -

height of the graphics buffer.

- type: Number - - name: renderer - description: | -

either P2D or WEBGL. Defaults to P2D.

- type: Constant - optional: true - - name: canvas - description: | -

existing canvas element that should be - used for the graphics buffer..

- type: HTMLCanvasElement - optional: true - return: - description: new graphics buffer. - type: p5.Graphics - - line: 475 - params: - - name: width - description: '' - type: Number - - name: height - description: '' - type: Number - - name: canvas - description: '' - type: HTMLCanvasElement - optional: true - return: - description: '' - type: p5.Graphics -chainable: false ---- - - -# createGraphics diff --git a/src/content/reference/en/p5 copy/createImage.mdx b/src/content/reference/en/p5 copy/createImage.mdx deleted file mode 100644 index 33c151c315..0000000000 --- a/src/content/reference/en/p5 copy/createImage.mdx +++ /dev/null @@ -1,172 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/image.js#L15 -title: createImage -module: Image -submodule: Image -file: src/image/image.js -description: > -

Creates a new p5.Image object.

- -

createImage() uses the width and - height parameters to set the new - - p5.Image object's dimensions in pixels. - The new - - p5.Image can be modified by updating its - - pixels array or by calling its - - get() and - - set() methods. The - - loadPixels() method must be - called - - before reading or modifying pixel values. The - - updatePixels() method must be - called - - for updates to take effect.

- -

Note: The new p5.Image object is - transparent by - - default.

-line: 15 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Image object. - let img = createImage(66, 66); - - // Load the image's pixels into memory. - img.loadPixels(); - - // Set all the image's pixels to black. - for (let x = 0; x < img.width; x += 1) { - for (let y = 0; y < img.height; y += 1) { - img.set(x, y, 0); - } - } - - // Update the image's pixel values. - img.updatePixels(); - - // Draw the image. - image(img, 17, 17); - - describe('A black square drawn in the middle of a gray square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Image object. - let img = createImage(66, 66); - - // Load the image's pixels into memory. - img.loadPixels(); - - // Create a color gradient. - for (let x = 0; x < img.width; x += 1) { - for (let y = 0; y < img.height; y += 1) { - // Calculate the transparency. - let a = map(x, 0, img.width, 0, 255); - - // Create a p5.Color object. - let c = color(0, a); - - // Set the pixel's color. - img.set(x, y, c); - } - } - - // Update the image's pixels. - img.updatePixels(); - - // Display the image. - image(img, 17, 17); - - describe('A square with a horizontal color gradient that transitions from gray to black.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Image object. - let img = createImage(66, 66); - - // Load the pixels into memory. - img.loadPixels(); - // Get the current pixel density. - let d = pixelDensity(); - - // Calculate the pixel that is halfway through the image's pixel array. - let halfImage = 4 * (d * img.width) * (d * img.height / 2); - - // Set half of the image's pixels to black. - for (let i = 0; i < halfImage; i += 4) { - // Red. - img.pixels[i] = 0; - // Green. - img.pixels[i + 1] = 0; - // Blue. - img.pixels[i + 2] = 0; - // Alpha. - img.pixels[i + 3] = 255; - } - - // Update the image's pixels. - img.updatePixels(); - - // Display the image. - image(img, 17, 17); - - describe('A black square drawn in the middle of a gray square.'); - } - -
-class: p5 -params: - - name: width - description: | -

width in pixels.

- type: Integer - - name: height - description: | -

height in pixels.

- type: Integer -return: - description: new p5.Image object. - type: p5.Image -chainable: false ---- - - -# createImage diff --git a/src/content/reference/en/p5 copy/createImg.mdx b/src/content/reference/en/p5 copy/createImg.mdx deleted file mode 100644 index 22b71d22c4..0000000000 --- a/src/content/reference/en/p5 copy/createImg.mdx +++ /dev/null @@ -1,115 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L649 -title: createImg -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates an element that can appear outside of the - canvas.

- -

The first parameter, src, is a string with the path to the - image file. - - src should be a relative path, as in - '/assets/image.png', or a URL, as - - in 'https://example.com/image.png'.

- -

The second parameter, alt, is a string with the - - alternate text - - for the image. An empty string '' can be used for images that - aren't displayed.

- -

The third parameter, crossOrigin, is optional. It's a string - that sets the - - crossOrigin property - - of the image. Use 'anonymous' or 'use-credentials' - to fetch the image - - with cross-origin access.

- -

The fourth parameter, callback, is also optional. It sets a - function to - - call after the image loads. The new image is passed to the callback - - function as a p5.Element object.

-line: 649 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - let img = createImg( - 'https://p5js.org//assets/img/asterisk-01.png', - 'The p5.js magenta asterisk.' - ); - img.position(0, -10); - - describe('A gray square with a magenta asterisk in its center.'); - } - -
-class: p5 -return: - description: new p5.Element object. - type: p5.Element -overloads: - - line: 649 - params: - - name: src - description: | -

relative path or URL for the image.

- type: String - - name: alt - description: | -

alternate text for the image.

- type: String - return: - description: new p5.Element object. - type: p5.Element - - line: 693 - params: - - name: src - description: '' - type: String - - name: alt - description: '' - type: String - - name: crossOrigin - description: | -

crossOrigin property to use when fetching the image.

- type: String - optional: true - - name: successCallback - description: | -

function to call once the image loads. The new image will be passed - to the function as a p5.Element object.

- type: Function - optional: true - return: - description: new p5.Element object. - type: p5.Element -chainable: false ---- - - -# createImg diff --git a/src/content/reference/en/p5 copy/createInput.mdx b/src/content/reference/en/p5 copy/createInput.mdx deleted file mode 100644 index 3a790ee6b2..0000000000 --- a/src/content/reference/en/p5 copy/createInput.mdx +++ /dev/null @@ -1,118 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1859 -title: createInput -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a text element.

- -

Call myInput.size() to set the length of the text box.

- -

The first parameter, value, is optional. It's a string that - sets the - - input's default value. The input is blank by default.

- -

The second parameter, type, is also optional. It's a string - that - - specifies the type of text being input. See MDN for a full - - list of options. - - The default is 'text'.

-line: 1859 -isConstructor: false -itemtype: method -example: - - |- - -
- - let myInput; - - function setup() { - createCanvas(100, 100); - - // Create an input element and place it - // beneath the canvas. - myInput = createInput(); - myInput.position(0, 100); - - describe('A gray square with a text box beneath it. The text in the square changes when the user types something new in the input bar.'); - } - - function draw() { - background(200); - - // Use the input to display a message. - let msg = myInput.value(); - text(msg, 25, 55); - } - -
- -
- - let myInput; - - function setup() { - createCanvas(100, 100); - - // Create an input element and place it - // beneath the canvas. Set its default - // text to "hello!". - myInput = createInput('hello!'); - myInput.position(0, 100); - - describe('The text "hello!" written at the center of a gray square. A text box beneath the square also says "hello!". The text in the square changes when the user types something new in the input bar.'); - } - - function draw() { - background(200); - - // Use the input to display a message. - let msg = myInput.value(); - text(msg, 25, 55); - } - -
-class: p5 -return: - description: new p5.Element object. - type: p5.Element -overloads: - - line: 1859 - params: - - name: value - description: > -

default value of the input box. Defaults to an empty string - ''.

- type: String - optional: true - - name: type - description: | -

type of input. Defaults to 'text'.

- type: String - optional: true - return: - description: new p5.Element object. - type: p5.Element - - line: 1929 - params: - - name: value - description: '' - type: String - optional: true - return: - description: '' - type: p5.Element -chainable: false ---- - - -# createInput diff --git a/src/content/reference/en/p5 copy/createModel.mdx b/src/content/reference/en/p5 copy/createModel.mdx deleted file mode 100644 index c94e95900f..0000000000 --- a/src/content/reference/en/p5 copy/createModel.mdx +++ /dev/null @@ -1,193 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/loading.js#L1132 -title: createModel -module: Shape -submodule: 3D Models -file: src/webgl/loading.js -description: > -

Load a 3d model from an OBJ or STL string.

- -

OBJ and STL files lack a built-in sense of scale, causing models exported - from different programs to vary in size. - - If your model doesn't display correctly, consider using - loadModel() with normalize set to true - to standardize its size. - - Further adjustments can be made using the scale() function.

- -

Also, the support for colored STL files is not present. STL files with - color will be - - rendered without color properties.

- -
    - -
  • Options can include:
  • - -
- -
    - -
  • modelString: Specifies the plain text string of either an stl - or obj file to be loaded.
  • - -
  • fileType: Defines the file extension of the model.
  • - -
  • normalize: Enables standardized size scaling during loading - if set to true.
  • - -
  • successCallback: Callback for post-loading actions with the - 3D model object.
  • - -
  • failureCallback: Handles errors if model loading fails, - receiving an event error.
  • - -
  • flipU: Flips the U texture coordinates of the model.
  • - -
  • flipV: Flips the V texture coordinates of the model.
  • - -
-line: 1132 -isConstructor: false -itemtype: method -example: - - |- - -
- - const octahedron_model = ` - v 0.000000E+00 0.000000E+00 40.0000 - v 22.5000 22.5000 0.000000E+00 - v 22.5000 -22.5000 0.000000E+00 - v -22.5000 -22.5000 0.000000E+00 - v -22.5000 22.5000 0.000000E+00 - v 0.000000E+00 0.000000E+00 -40.0000 - f 1 2 3 - f 1 3 4 - f 1 4 5 - f 1 5 2 - f 6 5 4 - f 6 4 3 - f 6 3 2 - f 6 2 5 - `; - //draw a spinning octahedron - let octahedron; - - function setup() { - createCanvas(100, 100, WEBGL); - octahedron = createModel(octahedron_model, '.obj'); - describe('Vertically rotating 3D octahedron.'); - } - - function draw() { - background(200); - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - model(octahedron); - } - -
-class: p5 -return: - description: the p5.Geometry object - type: p5.Geometry -overloads: - - line: 1132 - params: - - name: modelString - description: | -

String of the object to be loaded

- type: String - - name: fileType - description: | -

The file extension of the model - (.stl, .obj).

- type: String - optional: true - - name: normalize - description: | -

If true, scale the model to a - standardized size when loading

- type: Boolean - - name: successCallback - description: | -

Function to be called - once the model is loaded. Will be passed - the 3D model object.

- type: function(p5.Geometry) - optional: true - - name: failureCallback - description: | -

called with event error if - the model fails to load.

- type: Function(Event) - optional: true - return: - description: the p5.Geometry object - type: p5.Geometry - - line: 1202 - params: - - name: modelString - description: '' - type: String - - name: fileType - description: '' - type: String - optional: true - - name: successCallback - description: '' - type: function(p5.Geometry) - optional: true - - name: failureCallback - description: '' - type: Function(Event) - optional: true - return: - description: the p5.Geometry object - type: p5.Geometry - - line: 1210 - params: - - name: modelString - description: '' - type: String - - name: fileType - description: '' - type: String - optional: true - - name: options - description: '' - type: Object - optional: true - props: - - name: successCallback - description: '' - type: function(p5.Geometry) - optional: true - - name: failureCallback - description: '' - type: Function(Event) - optional: true - - name: normalize - description: '' - type: Boolean - optional: true - - name: flipU - description: '' - type: Boolean - optional: true - - name: flipV - description: '' - type: Boolean - optional: true - return: - description: the p5.Geometry object - type: p5.Geometry -chainable: false ---- - - -# createModel diff --git a/src/content/reference/en/p5 copy/createNumberDict.mdx b/src/content/reference/en/p5 copy/createNumberDict.mdx deleted file mode 100644 index 952410a222..0000000000 --- a/src/content/reference/en/p5 copy/createNumberDict.mdx +++ /dev/null @@ -1,57 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/data/p5.TypedDict.js#L48 -title: createNumberDict -module: Data -submodule: Dictionary -file: src/data/p5.TypedDict.js -description: > -

Creates a new instance of p5.NumberDict using the key-value pair - or object you provide.

-line: 48 -isConstructor: false -itemtype: method -example: - - |2- - -
- - function setup() { - let myDictionary = createNumberDict(100, 42); - print(myDictionary.hasKey(100)); // logs true to console - let anotherDictionary = createNumberDict({ 200: 84 }); - print(anotherDictionary.hasKey(200)); // logs true to console - } -
-class: p5 -return: - description: '' - type: p5.NumberDict -overloads: - - line: 48 - params: - - name: key - description: '' - type: Number - - name: value - description: '' - type: Number - return: - description: '' - type: p5.NumberDict - - line: 71 - params: - - name: object - description: | -

object

- type: Object - return: - description: '' - type: p5.NumberDict -chainable: false ---- - - -# createNumberDict diff --git a/src/content/reference/en/p5 copy/createP.mdx b/src/content/reference/en/p5 copy/createP.mdx deleted file mode 100644 index 6d3005fc37..0000000000 --- a/src/content/reference/en/p5 copy/createP.mdx +++ /dev/null @@ -1,54 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L543 -title: createP -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a paragraph element.

- -

elements are commonly used for paragraph-length - text.

- -

The parameter html is optional. It accepts a string that sets - the - - inner HTML of the new

.

-line: 543 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a paragraph element and set its position. - let p = createP('Tell me a story.'); - p.position(5, 0); - - describe('A gray square displaying the text "Tell me a story." written in black.'); - } - -
-class: p5 -params: - - name: html - description: | -

inner HTML for the new <p></p> element.

- type: String - optional: true -return: - description: new p5.Element object. - type: p5.Element -chainable: false ---- - - -# createP diff --git a/src/content/reference/en/p5 copy/createRadio.mdx b/src/content/reference/en/p5 copy/createRadio.mdx deleted file mode 100644 index f2b8a2a81c..0000000000 --- a/src/content/reference/en/p5 copy/createRadio.mdx +++ /dev/null @@ -1,223 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1440 -title: createRadio -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a radio button element.

- -

The parameter is optional. If a string is passed, as in - - let myRadio = createSelect('food'), then each radio option will - - have "food" as its name parameter: . - - If an existing

or - - element is passed, as in let myRadio = createSelect(container), - it will - - become the radio button's parent element.

- -

Radio buttons extend the p5.Element - class with a few - - helpful methods for managing options:

- -
    - -
  • myRadio.option(value, [label]) adds an option to the menu. - The first parameter, value, is a string that sets the option's - value and label. The second parameter, label, is optional. If - provided, it sets the label displayed for the value. If an option - with value already exists, its label is changed and its value is - returned.
  • - -
  • myRadio.value() returns the currently-selected option's - value.
  • - -
  • myRadio.selected() returns the currently-selected - option.
  • - -
  • myRadio.selected(value) selects the given option and returns - it as an HTMLInputElement.
  • - -
  • myRadio.disable(shouldDisable) Disables the radio button if - true is passed, and enables it if false is - passed.
  • - -
-line: 1440 -isConstructor: false -itemtype: method -example: - - |- - -
- - let style = document.createElement('style'); - style.innerHTML = ` - .p5-radio label { - display: flex; - align-items: center; - } - .p5-radio input { - margin-right: 5px; - } - `; - document.head.appendChild(style); - - let myRadio; - - function setup() { - createCanvas(100, 100); - - // Create a radio button element and place it - // in the top-left corner. - myRadio = createRadio(); - myRadio.position(0, 0); - myRadio.class('p5-radio'); - myRadio.size(60); - - // Add a few color options. - myRadio.option('red'); - myRadio.option('yellow'); - myRadio.option('blue'); - - // Choose a default option. - myRadio.selected('yellow'); - - describe('A yellow square with three color options listed, "red", "yellow", and "blue". The square changes color when the user selects a new option.'); - } - - function draw() { - // Set the background color using the radio button. - let g = myRadio.value(); - background(g); - } - -
- -
- - let myRadio; - - function setup() { - createCanvas(100, 100); - - // Create a radio button element and place it - // in the top-left corner. - myRadio = createRadio(); - myRadio.position(0, 0); - myRadio.size(50); - - // Add a few color options. - // Color values are labeled with - // emotions they evoke. - myRadio.option('red', 'love'); - myRadio.option('yellow', 'joy'); - myRadio.option('blue', 'trust'); - - // Choose a default option. - myRadio.selected('yellow'); - - describe('A yellow square with three options listed, "love", "joy", and "trust". The square changes color when the user selects a new option.'); - } - - function draw() { - // Set the background color using the radio button. - let c = myRadio.value(); - background(c); - } - -
- -
- - let myRadio; - - function setup() { - createCanvas(100, 100); - - // Create a radio button element and place it - // in the top-left corner. - myRadio = createRadio(); - myRadio.position(0, 0); - myRadio.class('p5-radio'); - myRadio.size(50); - - // Add a few color options. - myRadio.option('red'); - myRadio.option('yellow'); - myRadio.option('blue'); - - // Choose a default option. - myRadio.selected('yellow'); - - // Create a button and place it beneath the canvas. - let btn = createButton('disable'); - btn.position(0, 100); - - // Call disableRadio() when btn is pressed. - btn.mousePressed(disableRadio); - - describe('A yellow square with three options listed, "red", "yellow", and "blue". The square changes color when the user selects a new option. A "disable" button beneath the canvas disables the color options when pressed.'); - } - - function draw() { - // Set the background color using the radio button. - let c = myRadio.value(); - background(c); - } - - // Disable myRadio. - function disableRadio() { - myRadio.disable(true); - } - -
-class: p5 -return: - description: new p5.Element object. - type: p5.Element -overloads: - - line: 1440 - params: - - name: containerElement - description: > -

container HTML Element, either a - <div></div> - - or <span></span>.

- type: Object - optional: true - return: - description: new p5.Element object. - type: p5.Element - - line: 1588 - params: - - name: name - description: > -

name parameter assigned to each option's - <input></input> element.

- type: String - optional: true - return: - description: new p5.Element object. - type: p5.Element - - line: 1593 - params: [] - return: - description: new p5.Element object. - type: p5.Element -chainable: false ---- - - -# createRadio diff --git a/src/content/reference/en/p5 copy/createSelect.mdx b/src/content/reference/en/p5 copy/createSelect.mdx deleted file mode 100644 index 496f4082e6..0000000000 --- a/src/content/reference/en/p5 copy/createSelect.mdx +++ /dev/null @@ -1,235 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L1159 -title: createSelect -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a dropdown menu element.

- -

The parameter is optional. If true is passed, as in - - let mySelect = createSelect(true), then the dropdown will support - - multiple selections. If an existing element - - is passed, as in let mySelect = createSelect(otherSelect), the - existing - - element will be wrapped in a new p5.Element - - object.

- -

Dropdowns extend the p5.Element - class with a few - - helpful methods for managing options:

- -
    - -
  • mySelect.option(name, [value]) adds an option to the menu. - The first paremeter, name, is a string that sets the option's - name and value. The second parameter, value, is optional. If - provided, it sets the value that corresponds to the key name. If - an option with name already exists, its value is changed to - value.
  • - -
  • mySelect.value() returns the currently-selected option's - value.
  • - -
  • mySelect.selected() returns the currently-selected - option.
  • - -
  • mySelect.selected(option) selects the given option by - default.
  • - -
  • mySelect.disable() marks the whole dropdown element as - disabled.
  • - -
  • mySelect.disable(option) marks a given option as - disabled.
  • - -
  • mySelect.enable() marks the whole dropdown element as - enabled.
  • - -
  • mySelect.enable(option) marks a given option as enabled.
  • - -
-line: 1159 -isConstructor: false -itemtype: method -example: - - |- - -
- - let mySelect; - - function setup() { - createCanvas(100, 100); - - // Create a dropdown and place it beneath the canvas. - mySelect = createSelect(); - mySelect.position(0, 100); - - // Add color options. - mySelect.option('red'); - mySelect.option('green'); - mySelect.option('blue'); - mySelect.option('yellow'); - - // Set the selected option to "red". - mySelect.selected('red'); - - describe('A red square with a dropdown menu beneath it. The square changes color when a new color is selected.'); - } - - function draw() { - // Use the selected value to paint the background. - let c = mySelect.selected(); - background(c); - } - -
- -
- - let mySelect; - - function setup() { - createCanvas(100, 100); - - // Create a dropdown and place it beneath the canvas. - mySelect = createSelect(); - mySelect.position(0, 100); - - // Add color options. - mySelect.option('red'); - mySelect.option('green'); - mySelect.option('blue'); - mySelect.option('yellow'); - - // Set the selected option to "red". - mySelect.selected('red'); - - // Disable the "yellow" option. - mySelect.disable('yellow'); - - describe('A red square with a dropdown menu beneath it. The square changes color when a new color is selected.'); - } - - function draw() { - // Use the selected value to paint the background. - let c = mySelect.selected(); - background(c); - } - -
- -
- - let mySelect; - - function setup() { - createCanvas(100, 100); - - // Create a dropdown and place it beneath the canvas. - mySelect = createSelect(); - mySelect.position(0, 100); - - // Add color options with names and values. - mySelect.option('one', 'red'); - mySelect.option('two', 'green'); - mySelect.option('three', 'blue'); - mySelect.option('four', 'yellow'); - - // Set the selected option to "one". - mySelect.selected('one'); - - describe('A red square with a dropdown menu beneath it. The square changes color when a new color is selected.'); - } - - function draw() { - // Use the selected value to paint the background. - let c = mySelect.selected(); - background(c); - } - -
- -
- - // Hold CTRL to select multiple options on Windows and Linux. - // Hold CMD to select multiple options on macOS. - let mySelect; - - function setup() { - createCanvas(100, 100); - - // Create a dropdown and allow multiple selections. - // Place it beneath the canvas. - mySelect = createSelect(true); - mySelect.position(0, 100); - - // Add color options. - mySelect.option('red'); - mySelect.option('green'); - mySelect.option('blue'); - mySelect.option('yellow'); - - describe('A gray square with a dropdown menu beneath it. Colorful circles appear when their color is selected.'); - } - - function draw() { - background(200); - - // Use the selected value(s) to draw circles. - let colors = mySelect.selected(); - for (let i = 0; i < colors.length; i += 1) { - // Calculate the x-coordinate. - let x = 10 + i * 20; - - // Access the color. - let c = colors[i]; - - // Draw the circle. - fill(c); - circle(x, 50, 20); - } - } - -
-class: p5 -return: - description: new p5.Element object. - type: p5.Element -overloads: - - line: 1159 - params: - - name: multiple - description: | -

support multiple selections.

- type: Boolean - optional: true - return: - description: new p5.Element object. - type: p5.Element - - line: 1324 - params: - - name: existing - description: > -

select element to wrap, either as a p5.Element or - a HTMLSelectElement.

- type: Object - return: - description: '' - type: p5.Element -chainable: false ---- - - -# createSelect diff --git a/src/content/reference/en/p5 copy/createShader.mdx b/src/content/reference/en/p5 copy/createShader.mdx deleted file mode 100644 index c595145529..0000000000 --- a/src/content/reference/en/p5 copy/createShader.mdx +++ /dev/null @@ -1,438 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L173 -title: createShader -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Creates a new p5.Shader object.

- -

Shaders are programs that run on the graphics processing unit (GPU). They - - can process many pixels at the same time, making them fast for many - - graphics tasks. They’re written in a language called - - GLSL - - and run along with the rest of the code in a sketch.

- -

Once the p5.Shader object is created, - it can be - - used with the shader() function, as in - - shader(myShader). A shader program consists of two parts, a - vertex shader - - and a fragment shader. The vertex shader affects where 3D geometry is drawn - - on the screen and the fragment shader affects color.

- -

The first parameter, vertSrc, sets the vertex shader. It’s a - string that - - contains the vertex shader program written in GLSL.

- -

The second parameter, fragSrc, sets the fragment shader. It’s - a string - - that contains the fragment shader program written in GLSL.

- -

A shader can optionally describe hooks, which are functions in - GLSL that - - users may choose to provide to customize the behavior of the shader using the - - modify() method of - p5.Shader. These are added by - - describing the hooks in a third parameter, options, and - referencing the hooks in - - your vertSrc or fragSrc. Hooks for the vertex or - fragment shader are described under - - the vertex and fragment keys of - options. Each one is an object. where each key is - - the type and name of a hook function, and each value is a string with the - - parameter list and default implementation of the hook. For example, to let - users - - optionally run code at the start of the vertex shader, the options object - could - - include:

- -
{
-    vertex: {
-      'void beforeVertex': '() {}'
-    }
-  }
-
-  
- -

Then, in your vertex shader source, you can run a hook by calling a - function - - with the same name prefixed by HOOK_. If you want to check if the - default - - hook has been replaced, maybe to avoid extra overhead, you can check if the - - same name prefixed by AUGMENTED_HOOK_ has been defined:

- -
void main() {
-    // In most cases, just calling the hook is fine:
-    HOOK_beforeVertex();
-
-    // Alternatively, for more efficiency:
-    #ifdef AUGMENTED_HOOK_beforeVertex
-    HOOK_beforeVertex();
-    #endif
-
-    // Add the rest of your shader code here!
-  }
-
-  
- -

Note: Only filter shaders can be used in 2D mode. All shaders can be used - - in WebGL mode.

-line: 173 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Note: A "uniform" is a global variable within a shader program. - - // Create a string with the vertex shader program. - // The vertex shader is called for each vertex. - let vertSrc = ` - precision highp float; - uniform mat4 uModelViewMatrix; - uniform mat4 uProjectionMatrix; - attribute vec3 aPosition; - attribute vec2 aTexCoord; - varying vec2 vTexCoord; - - void main() { - vTexCoord = aTexCoord; - vec4 positionVec4 = vec4(aPosition, 1.0); - gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; - } - `; - - // Create a string with the fragment shader program. - // The fragment shader is called for each pixel. - let fragSrc = ` - precision highp float; - - void main() { - // Set each pixel's RGBA value to yellow. - gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); - } - `; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Shader object. - let shaderProgram = createShader(vertSrc, fragSrc); - - // Compile and apply the p5.Shader object. - shader(shaderProgram); - - // Style the drawing surface. - noStroke(); - - // Add a plane as a drawing surface. - plane(100, 100); - - describe('A yellow square.'); - } - -
- -
- - // Note: A "uniform" is a global variable within a shader program. - - // Create a string with the vertex shader program. - // The vertex shader is called for each vertex. - let vertSrc = ` - precision highp float; - uniform mat4 uModelViewMatrix; - uniform mat4 uProjectionMatrix; - attribute vec3 aPosition; - attribute vec2 aTexCoord; - varying vec2 vTexCoord; - - void main() { - vTexCoord = aTexCoord; - vec4 positionVec4 = vec4(aPosition, 1.0); - gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; - } - `; - - // Create a string with the fragment shader program. - // The fragment shader is called for each pixel. - let fragSrc = ` - precision highp float; - uniform vec2 p; - uniform float r; - const int numIterations = 500; - varying vec2 vTexCoord; - - void main() { - vec2 c = p + gl_FragCoord.xy * r; - vec2 z = c; - float n = 0.0; - - for (int i = numIterations; i > 0; i--) { - if (z.x * z.x + z.y * z.y > 4.0) { - n = float(i) / float(numIterations); - break; - } - z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c; - } - - gl_FragColor = vec4( - 0.5 - cos(n * 17.0) / 2.0, - 0.5 - cos(n * 13.0) / 2.0, - 0.5 - cos(n * 23.0) / 2.0, - 1.0 - ); - } - `; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Shader object. - let mandelbrot = createShader(vertSrc, fragSrc); - - // Compile and apply the p5.Shader object. - shader(mandelbrot); - - // Set the shader uniform p to an array. - // p is the center point of the Mandelbrot image. - mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); - - // Set the shader uniform r to 0.005. - // r is the size of the image in Mandelbrot-space. - mandelbrot.setUniform('r', 0.005); - - // Style the drawing surface. - noStroke(); - - // Add a plane as a drawing surface. - plane(100, 100); - - describe('A black fractal image on a magenta background.'); - } - -
- -
- - // Note: A "uniform" is a global variable within a shader program. - - // Create a string with the vertex shader program. - // The vertex shader is called for each vertex. - let vertSrc = ` - precision highp float; - uniform mat4 uModelViewMatrix; - uniform mat4 uProjectionMatrix; - - attribute vec3 aPosition; - attribute vec2 aTexCoord; - varying vec2 vTexCoord; - - void main() { - vTexCoord = aTexCoord; - vec4 positionVec4 = vec4(aPosition, 1.0); - gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; - } - `; - - // Create a string with the fragment shader program. - // The fragment shader is called for each pixel. - let fragSrc = ` - precision highp float; - uniform vec2 p; - uniform float r; - const int numIterations = 500; - varying vec2 vTexCoord; - - void main() { - vec2 c = p + gl_FragCoord.xy * r; - vec2 z = c; - float n = 0.0; - - for (int i = numIterations; i > 0; i--) { - if (z.x * z.x + z.y * z.y > 4.0) { - n = float(i) / float(numIterations); - break; - } - - z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c; - } - - gl_FragColor = vec4( - 0.5 - cos(n * 17.0) / 2.0, - 0.5 - cos(n * 13.0) / 2.0, - 0.5 - cos(n * 23.0) / 2.0, - 1.0 - ); - } - `; - - let mandelbrot; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Shader object. - mandelbrot = createShader(vertSrc, fragSrc); - - // Apply the p5.Shader object. - shader(mandelbrot); - - // Set the shader uniform p to an array. - // p is the center point of the Mandelbrot image. - mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); - - describe('A fractal image zooms in and out of focus.'); - } - - function draw() { - // Set the shader uniform r to a value that oscillates - // between 0 and 0.005. - // r is the size of the image in Mandelbrot-space. - let radius = 0.005 * (sin(frameCount * 0.01) + 1); - mandelbrot.setUniform('r', radius); - - // Style the drawing surface. - noStroke(); - - // Add a plane as a drawing surface. - plane(100, 100); - } - -
- -
- - // A shader with hooks. - let myShader; - - // A shader with modified hooks. - let modifiedShader; - - // Create a string with the vertex shader program. - // The vertex shader is called for each vertex. - let vertSrc = ` - precision highp float; - uniform mat4 uModelViewMatrix; - uniform mat4 uProjectionMatrix; - - attribute vec3 aPosition; - attribute vec2 aTexCoord; - - void main() { - vec4 positionVec4 = vec4(aPosition, 1.0); - gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; - } - `; - - // Create a fragment shader that uses a hook. - let fragSrc = ` - precision highp float; - void main() { - // Let users override the color - gl_FragColor = HOOK_getColor(vec4(1., 0., 0., 1.)); - } - `; - - function setup() { - createCanvas(50, 50, WEBGL); - - // Create a shader with hooks - myShader = createShader(vertSrc, fragSrc, { - fragment: { - 'vec4 getColor': '(vec4 color) { return color; }' - } - }); - - // Make a version of the shader with a hook overridden - modifiedShader = myShader.modify({ - 'vec4 getColor': `(vec4 color) { - return vec4(0., 0., 1., 1.); - }` - }); - } - - function draw() { - noStroke(); - - push(); - shader(myShader); - translate(-width/3, 0); - sphere(10); - pop(); - - push(); - shader(modifiedShader); - translate(width/3, 0); - sphere(10); - pop(); - } - -
-class: p5 -params: - - name: vertSrc - description: | -

source code for the vertex shader.

- type: String - - name: fragSrc - description: | -

source code for the fragment shader.

- type: String - - name: options - description: > -

An optional object describing how this shader can - - be augmented with hooks. It can include:

- -
    - -
  • vertex: An object describing the available vertex shader - hooks.
  • - -
  • fragment: An object describing the available frament - shader hooks.
  • - -
- type: Object - optional: true -return: - description: |- - new shader object created from the - vertex and fragment shaders. - type: p5.Shader -chainable: false ---- - - -# createShader diff --git a/src/content/reference/en/p5 copy/createSlider.mdx b/src/content/reference/en/p5 copy/createSlider.mdx deleted file mode 100644 index 7bdf510078..0000000000 --- a/src/content/reference/en/p5 copy/createSlider.mdx +++ /dev/null @@ -1,162 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L789 -title: createSlider -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a slider element.

- -

Range sliders are useful for quickly selecting numbers from a given - range.

- -

The first two parameters, min and max, are - numbers that set the - - slider's minimum and maximum.

- -

The third parameter, value, is optional. It's a number that - sets the - - slider's default value.

- -

The fourth parameter, step, is also optional. It's a number - that sets the - - spacing between each value in the slider's range. Setting step to - 0 - - allows the slider to move smoothly from min to - max.

-line: 789 -isConstructor: false -itemtype: method -example: - - |- - -
- - let slider; - - function setup() { - createCanvas(100, 100); - - // Create a slider and place it at the top of the canvas. - slider = createSlider(0, 255); - slider.position(10, 10); - slider.size(80); - - describe('A dark gray square with a range slider at the top. The square changes color when the slider is moved.'); - } - - function draw() { - // Use the slider as a grayscale value. - let g = slider.value(); - background(g); - } - -
- -
- - let slider; - - function setup() { - createCanvas(100, 100); - - // Create a slider and place it at the top of the canvas. - // Set its default value to 0. - slider = createSlider(0, 255, 0); - slider.position(10, 10); - slider.size(80); - - describe('A black square with a range slider at the top. The square changes color when the slider is moved.'); - } - - function draw() { - // Use the slider as a grayscale value. - let g = slider.value(); - background(g); - } - -
- -
- - let slider; - - function setup() { - createCanvas(100, 100); - - // Create a slider and place it at the top of the canvas. - // Set its default value to 0. - // Set its step size to 50. - slider = createSlider(0, 255, 0, 50); - slider.position(10, 10); - slider.size(80); - - describe('A black square with a range slider at the top. The square changes color when the slider is moved.'); - } - - function draw() { - // Use the slider as a grayscale value. - let g = slider.value(); - background(g); - } - -
- -
- - let slider; - - function setup() { - createCanvas(100, 100); - - // Create a slider and place it at the top of the canvas. - // Set its default value to 0. - // Set its step size to 0 so that it moves smoothly. - slider = createSlider(0, 255, 0, 0); - slider.position(10, 10); - slider.size(80); - - describe('A black square with a range slider at the top. The square changes color when the slider is moved.'); - } - - function draw() { - // Use the slider as a grayscale value. - let g = slider.value(); - background(g); - } - -
-class: p5 -params: - - name: min - description: | -

minimum value of the slider.

- type: Number - - name: max - description: | -

maximum value of the slider.

- type: Number - - name: value - description: | -

default value of the slider.

- type: Number - optional: true - - name: step - description: | -

size for each step in the slider's range.

- type: Number - optional: true -return: - description: new p5.Element object. - type: p5.Element -chainable: false ---- - - -# createSlider diff --git a/src/content/reference/en/p5 copy/createSpan.mdx b/src/content/reference/en/p5 copy/createSpan.mdx deleted file mode 100644 index ed346b35dc..0000000000 --- a/src/content/reference/en/p5 copy/createSpan.mdx +++ /dev/null @@ -1,93 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L578 -title: createSpan -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a element.

- -

elements are commonly used as containers - - for inline elements. For example, a - - can hold part of a sentence that's a - - different style.

- -

The parameter html is optional. It accepts a string that sets - the - - inner HTML of the new .

-line: 578 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a span element and set its position. - let span = createSpan('p5*js'); - span.position(25, 35); - - describe('A gray square with the text "p5*js" written in its center.'); - } - -
- -
- - function setup() { - background(200); - - // Create a div element as a container. - let div = createDiv(); - - // Place the div at the center. - div.position(25, 35); - - // Create a span element. - let s1 = createSpan('p5'); - - // Create a second span element. - let s2 = createSpan('*'); - - // Set the second span's font color. - s2.style('color', 'deeppink'); - - // Create a third span element. - let s3 = createSpan('js'); - - // Add all the spans to the container div. - s1.parent(div); - s2.parent(div); - s3.parent(div); - - describe('A gray square with the text "p5*js" written in black at its center. The asterisk is pink.'); - } - -
-class: p5 -params: - - name: html - description: > -

inner HTML for the new <span></span> - element.

- type: String - optional: true -return: - description: new p5.Element object. - type: p5.Element -chainable: false ---- - - -# createSpan diff --git a/src/content/reference/en/p5 copy/createStringDict.mdx b/src/content/reference/en/p5 copy/createStringDict.mdx deleted file mode 100644 index bc080c1276..0000000000 --- a/src/content/reference/en/p5 copy/createStringDict.mdx +++ /dev/null @@ -1,56 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/data/p5.TypedDict.js#L14 -title: createStringDict -module: Data -submodule: Dictionary -file: src/data/p5.TypedDict.js -description: | -

Creates a new instance of p5.StringDict using the key-value pair - or the object you provide.

-line: 14 -isConstructor: false -itemtype: method -example: - - |2- - -
- - function setup() { - let myDictionary = createStringDict('p5', 'js'); - print(myDictionary.hasKey('p5')); // logs true to console - let anotherDictionary = createStringDict({ happy: 'coding' }); - print(anotherDictionary.hasKey('happy')); // logs true to console - } -
-class: p5 -return: - description: '' - type: p5.StringDict -overloads: - - line: 14 - params: - - name: key - description: '' - type: String - - name: value - description: '' - type: String - return: - description: '' - type: p5.StringDict - - line: 37 - params: - - name: object - description: | -

object

- type: Object - return: - description: '' - type: p5.StringDict -chainable: false ---- - - -# createStringDict diff --git a/src/content/reference/en/p5 copy/createVector.mdx b/src/content/reference/en/p5 copy/createVector.mdx deleted file mode 100644 index 07ca75ec36..0000000000 --- a/src/content/reference/en/p5 copy/createVector.mdx +++ /dev/null @@ -1,133 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/math.js#L10 -title: createVector -module: Math -submodule: Vector -file: src/math/math.js -description: > -

Creates a new p5.Vector object.

- -

A vector can be thought of in different ways. In one view, a vector is like - - an arrow pointing in space. Vectors have both magnitude (length) and - - direction. This view is helpful for programming motion.

- -

A vector's components determine its magnitude and direction. For example, - - calling createVector(3, 4) creates a new - - p5.Vector object with an x-component of - 3 and a - - y-component of 4. From the origin, this vector's tip is 3 units to the - - right and 4 units down.

- -

p5.Vector objects are often used to - program - - motion because they simplify the math. For example, a moving ball has a - - position and a velocity. Position describes where the ball is in space. The - - ball's position vector extends from the origin to the ball's center. - - Velocity describes the ball's speed and the direction it's moving. If the - - ball is moving straight up, its velocity vector points straight up. Adding - - the ball's velocity vector to its position vector moves it, as in - - pos.add(vel). Vector math relies on methods inside the - - p5.Vector class.

-line: 10 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create p5.Vector objects. - let p1 = createVector(25, 25); - let p2 = createVector(50, 50); - let p3 = createVector(75, 75); - - // Draw the dots. - strokeWeight(5); - point(p1); - point(p2); - point(p3); - - describe('Three black dots form a diagonal line from top left to bottom right.'); - } - -
- -
- - let pos; - let vel; - - function setup() { - createCanvas(100, 100); - - // Create p5.Vector objects. - pos = createVector(50, 100); - vel = createVector(0, -1); - - describe('A black dot moves from bottom to top on a gray square. The dot reappears at the bottom when it reaches the top.'); - } - - function draw() { - background(200); - - // Add velocity to position. - pos.add(vel); - - // If the dot reaches the top of the canvas, - // restart from the bottom. - if (pos.y < 0) { - pos.y = 100; - } - - // Draw the dot. - strokeWeight(5); - point(pos); - } - -
-class: p5 -params: - - name: x - description: | -

x component of the vector.

- type: Number - optional: true - - name: 'y' - description: | -

y component of the vector.

- type: Number - optional: true - - name: z - description: | -

z component of the vector.

- type: Number - optional: true -return: - description: new p5.Vector object. - type: p5.Vector -chainable: false ---- - - -# createVector diff --git a/src/content/reference/en/p5 copy/createVideo.mdx b/src/content/reference/en/p5 copy/createVideo.mdx deleted file mode 100644 index a7053f80a0..0000000000 --- a/src/content/reference/en/p5 copy/createVideo.mdx +++ /dev/null @@ -1,135 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L2115 -title: createVideo -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Creates a element for simple audio/video playback.

- -

createVideo() returns a new - - p5.MediaElement object. Videos are - shown by - - default. They can be hidden by calling video.hide() and drawn to - the - - canvas using image().

- -

The first parameter, src, is the path the video. If a single - string is - - passed, as in '/assets/topsecret.mp4', a single video is loaded. - An array - - of strings can be used to load the same video in different formats. For - - example, ['/assets/topsecret.mp4', '/assets/topsecret.ogv', - '/assets/topsecret.webm']. - - This is useful for ensuring that the video can play across different browsers - with - - different capabilities. See - - MDN - - for more information about supported formats.

- -

The second parameter, callback, is optional. It's a function - to call once - - the video is ready to play.

-line: 2115 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - noCanvas(); - - // Load a video and add it to the page. - // Note: this may not work in some browsers. - let video = createVideo('/assets/small.mp4'); - - // Show the default video controls. - video.showControls(); - - describe('A video of a toy robot with playback controls beneath it.'); - } - -
- -
- - function setup() { - noCanvas(); - - // Load a video and add it to the page. - // Provide an array options for different file formats. - let video = createVideo( - ['/assets/small.mp4', '/assets/small.ogv', '/assets/small.webm'] - ); - - // Show the default video controls. - video.showControls(); - - describe('A video of a toy robot with playback controls beneath it.'); - } - -
- -
- - let video; - - function setup() { - noCanvas(); - - // Load a video and add it to the page. - // Provide an array options for different file formats. - // Call mute() once the video loads. - video = createVideo( - ['/assets/small.mp4', '/assets/small.ogv', '/assets/small.webm'], - muteVideo - ); - - // Show the default video controls. - video.showControls(); - - describe('A video of a toy robot with playback controls beneath it.'); - } - - // Mute the video once it loads. - function muteVideo() { - video.volume(0); - } - -
-class: p5 -params: - - name: src - description: | -

path to a video file, or an array of paths for - supporting different browsers.

- type: 'String|String[]' - - name: callback - description: | -

function to call once the video is ready to play.

- type: Function - optional: true -return: - description: new p5.MediaElement object. - type: p5.MediaElement -chainable: false ---- - - -# createVideo diff --git a/src/content/reference/en/p5 copy/createWriter.mdx b/src/content/reference/en/p5 copy/createWriter.mdx deleted file mode 100644 index 18928ff461..0000000000 --- a/src/content/reference/en/p5 copy/createWriter.mdx +++ /dev/null @@ -1,146 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1444 -title: createWriter -module: IO -submodule: Output -file: src/io/files.js -description: > -

Creates a new p5.PrintWriter - object.

- -

p5.PrintWriter objects provide a - way to - - save a sequence of text data, called the print stream, to the user's - - computer. They're low-level objects that enable precise control of text - - output. Functions such as - - saveStrings() and - - saveJSON() are easier to use for simple - file - - saving.

- -

The first parameter, filename, is the name of the file to be - written. If - - a string is passed, as in createWriter('words.txt'), a new - - p5.PrintWriter object will be - created that - - writes to a file named words.txt.

- -

The second parameter, extension, is optional. If a string is - passed, as - - in createWriter('words', 'csv'), the first parameter will be - interpreted - - as the file name and the second parameter as the extension.

-line: 1444 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(12); - - // Display instructions. - text('Double-click to save', 5, 50, 90); - - describe('The text "Double-click to save" written in black on a gray background.'); - } - - // Save the file when the user double-clicks. - function doubleClicked() { - if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { - // Create a p5.PrintWriter object. - let myWriter = createWriter('xo.txt'); - - // Add some lines to the print stream. - myWriter.print('XOO'); - myWriter.print('OXO'); - myWriter.print('OOX'); - - // Save the file and close the print stream. - myWriter.close(); - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(12); - - // Display instructions. - text('Double-click to save', 5, 50, 90); - - describe('The text "Double-click to save" written in black on a gray background.'); - } - - // Save the file when the user double-clicks. - function doubleClicked() { - if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { - // Create a p5.PrintWriter object. - // Use the file format .csv. - let myWriter = createWriter('mauna_loa_co2', 'csv'); - - // Add some lines to the print stream. - myWriter.print('date,ppm_co2'); - myWriter.print('1960-01-01,316.43'); - myWriter.print('1970-01-01,325.06'); - myWriter.print('1980-01-01,337.9'); - myWriter.print('1990-01-01,353.86'); - myWriter.print('2000-01-01,369.45'); - myWriter.print('2020-01-01,413.61'); - - // Save the file and close the print stream. - myWriter.close(); - } - } - -
-class: p5 -params: - - name: name - description: | -

name of the file to create.

- type: String - - name: extension - description: | -

format to use for the file.

- type: String - optional: true -return: - description: stream for writing data. - type: p5.PrintWriter -chainable: false ---- - - -# createWriter diff --git a/src/content/reference/en/p5 copy/cursor.mdx b/src/content/reference/en/p5 copy/cursor.mdx deleted file mode 100644 index 8ada3a4379..0000000000 --- a/src/content/reference/en/p5 copy/cursor.mdx +++ /dev/null @@ -1,139 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L209 -title: cursor -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

Changes the cursor's appearance.

- -

The first parameter, type, sets the type of cursor to display. - The - - built-in options are ARROW, CROSS, - HAND, MOVE, TEXT, and - WAIT. - - cursor() also recognizes standard CSS cursor properties passed as - - strings: 'help', 'wait', 'crosshair', - 'not-allowed', 'zoom-in', - - and 'grab'. If the path to an image is passed, as in - - cursor('/assets/target.png'), then the image will be used as the - cursor. - - Images must be in .cur, .gif, .jpg, .jpeg, or .png format and should be at - most 32 by 32 pixels large.

- -

The parameters x and y are optional. If an image - is used for the - - cursor, x and y set the location pointed to within - the image. They are - - both 0 by default, so the cursor points to the image's top-left corner. - x - - and y must be less than the image's width and height, - respectively.

-line: 209 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A gray square. The cursor appears as crosshairs.'); - } - - function draw() { - background(200); - - // Set the cursor to crosshairs: + - cursor(CROSS); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A gray square divided into quadrants. The cursor image changes when the mouse moves to each quadrant.'); - } - - function draw() { - background(200); - - // Divide the canvas into quadrants. - line(50, 0, 50, 100); - line(0, 50, 100, 50); - - // Change cursor based on mouse position. - if (mouseX < 50 && mouseY < 50) { - cursor(CROSS); - } else if (mouseX > 50 && mouseY < 50) { - cursor('progress'); - } else if (mouseX > 50 && mouseY > 50) { - cursor('https://avatars0.githubusercontent.com/u/1617169?s=16'); - } else { - cursor('grab'); - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('An image of three purple curves follows the mouse. The image shifts when the mouse is pressed.'); - } - - function draw() { - background(200); - - // Change the cursor's active spot - // when the mouse is pressed. - if (mouseIsPressed === true) { - cursor('https://avatars0.githubusercontent.com/u/1617169?s=16', 8, 8); - } else { - cursor('https://avatars0.githubusercontent.com/u/1617169?s=16'); - } - } - -
-class: p5 -params: - - name: type - description: | -

Built-in: either ARROW, CROSS, HAND, MOVE, TEXT, or WAIT. - Native CSS properties: 'grab', 'progress', and so on. - Path to cursor image.

- type: String|Constant - - name: x - description: | -

horizontal active spot of the cursor.

- type: Number - optional: true - - name: 'y' - description: | -

vertical active spot of the cursor.

- type: Number - optional: true -chainable: false ---- - - -# cursor diff --git a/src/content/reference/en/p5 copy/curve.mdx b/src/content/reference/en/p5 copy/curve.mdx deleted file mode 100644 index 9631e551e8..0000000000 --- a/src/content/reference/en/p5 copy/curve.mdx +++ /dev/null @@ -1,272 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L570 -title: curve -module: Shape -submodule: Curves -file: src/core/shape/curves.js -description: > -

Draws a curve using a Catmull-Rom spline.

- -

Spline curves can form shapes and curves that slope gently. They’re like - - cables that are attached to a set of points. Splines are defined by two - - anchor points and two control points.

- -

The first two parameters, x1 and y1, set the - first control point. This - - point isn’t drawn and can be thought of as the curve’s starting point.

- -

The next four parameters, x2, y2, - x3, and y3, set the two anchor - - points. The anchor points are the start and end points of the curve’s - - visible segment.

- -

The seventh and eighth parameters, x4 and y4, set - the last control - - point. This point isn’t drawn and can be thought of as the curve’s ending - - point.

- -

Spline curves can also be drawn in 3D using WebGL mode. The 3D version of - - curve() has twelve arguments because each point has x-, y-, and - - z-coordinates.

-line: 570 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw a black spline curve. - noFill(); - strokeWeight(1); - stroke(0); - curve(5, 26, 73, 24, 73, 61, 15, 65); - - // Draw red spline curves from the anchor points to the control points. - stroke(255, 0, 0); - curve(5, 26, 5, 26, 73, 24, 73, 61); - curve(73, 24, 73, 61, 15, 65, 15, 65); - - // Draw the anchor points in black. - strokeWeight(5); - stroke(0); - point(73, 24); - point(73, 61); - - // Draw the control points in red. - stroke(255, 0, 0); - point(5, 26); - point(15, 65); - - describe( - 'A gray square with a curve drawn in three segments. The curve is a sideways U shape with red segments on top and bottom, and a black segment on the right. The endpoints of all the segments are marked with dots.' - ); - } - -
- -
- - let x1 = 5; - let y1 = 26; - let isChanging = false; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a curve drawn in three segments. The curve is a sideways U shape with red segments on top and bottom, and a black segment on the right. The endpoints of all the segments are marked with dots.' - ); - } - - function draw() { - background(200); - - // Draw a black spline curve. - noFill(); - strokeWeight(1); - stroke(0); - curve(x1, y1, 73, 24, 73, 61, 15, 65); - - // Draw red spline curves from the anchor points to the control points. - stroke(255, 0, 0); - curve(x1, y1, x1, y1, 73, 24, 73, 61); - curve(73, 24, 73, 61, 15, 65, 15, 65); - - // Draw the anchor points in black. - strokeWeight(5); - stroke(0); - point(73, 24); - point(73, 61); - - // Draw the control points in red. - stroke(255, 0, 0); - point(x1, y1); - point(15, 65); - } - - // Start changing the first control point if the user clicks near it. - function mousePressed() { - if (dist(mouseX, mouseY, x1, y1) < 20) { - isChanging = true; - } - } - - // Stop changing the first control point when the user releases the mouse. - function mouseReleased() { - isChanging = false; - } - - // Update the first control point while the user drags the mouse. - function mouseDragged() { - if (isChanging === true) { - x1 = mouseX; - y1 = mouseY; - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background('skyblue'); - - // Draw the red balloon. - fill('red'); - curve(-150, 275, 50, 60, 50, 60, 250, 275); - - // Draw the balloon string. - line(50, 60, 50, 80); - - describe('A red balloon in a blue sky.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A red balloon in a blue sky.'); - } - - function draw() { - background('skyblue'); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Draw the red balloon. - fill('red'); - curve(-200, 225, 0, 0, 10, 0, 0, 10, 0, 200, 225, 0); - - // Draw the balloon string. - line(0, 10, 0, 0, 30, 0); - } - -
-class: p5 -overloads: - - line: 570 - params: - - name: x1 - description: | -

x-coordinate of the first control point.

- type: Number - - name: y1 - description: | -

y-coordinate of the first control point.

- type: Number - - name: x2 - description: | -

x-coordinate of the first anchor point.

- type: Number - - name: y2 - description: | -

y-coordinate of the first anchor point.

- type: Number - - name: x3 - description: | -

x-coordinate of the second anchor point.

- type: Number - - name: y3 - description: | -

y-coordinate of the second anchor point.

- type: Number - - name: x4 - description: | -

x-coordinate of the second control point.

- type: Number - - name: y4 - description: | -

y-coordinate of the second control point.

- type: Number - chainable: 1 - - line: 746 - params: - - name: x1 - description: '' - type: Number - - name: y1 - description: '' - type: Number - - name: z1 - description: | -

z-coordinate of the first control point.

- type: Number - - name: x2 - description: '' - type: Number - - name: y2 - description: '' - type: Number - - name: z2 - description: | -

z-coordinate of the first anchor point.

- type: Number - - name: x3 - description: '' - type: Number - - name: y3 - description: '' - type: Number - - name: z3 - description: | -

z-coordinate of the second anchor point.

- type: Number - - name: x4 - description: '' - type: Number - - name: y4 - description: '' - type: Number - - name: z4 - description: | -

z-coordinate of the second control point.

- type: Number - chainable: 1 -chainable: true ---- - - -# curve diff --git a/src/content/reference/en/p5 copy/curveDetail.mdx b/src/content/reference/en/p5 copy/curveDetail.mdx deleted file mode 100644 index 796ca5a026..0000000000 --- a/src/content/reference/en/p5 copy/curveDetail.mdx +++ /dev/null @@ -1,117 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L772 -title: curveDetail -module: Shape -submodule: Curves -file: src/core/shape/curves.js -description: > -

Sets the number of segments used to draw spline curves in WebGL mode.

- -

In WebGL mode, smooth shapes are drawn using many flat segments. Adding - - more flat segments makes shapes appear smoother.

- -

The parameter, detail, is the number of segments to use while - drawing a - - spline curve. For example, calling curveDetail(5) will use 5 - segments to - - draw curves with the curve() function. By - - default,detail is 20.

- -

Note: curveDetail() has no effect in 2D mode.

-line: 772 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw a black spline curve. - noFill(); - strokeWeight(1); - stroke(0); - curve(5, 26, 73, 24, 73, 61, 15, 65); - - // Draw red spline curves from the anchor points to the control points. - stroke(255, 0, 0); - curve(5, 26, 5, 26, 73, 24, 73, 61); - curve(73, 24, 73, 61, 15, 65, 15, 65); - - // Draw the anchor points in black. - strokeWeight(5); - stroke(0); - point(73, 24); - point(73, 61); - - // Draw the control points in red. - stroke(255, 0, 0); - point(5, 26); - point(15, 65); - - describe( - 'A gray square with a curve drawn in three segments. The curve is a sideways U shape with red segments on top and bottom, and a black segment on the right. The endpoints of all the segments are marked with dots.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - // Set the curveDetail() to 3. - curveDetail(3); - - // Draw a black spline curve. - noFill(); - strokeWeight(1); - stroke(0); - curve(-45, -24, 0, 23, -26, 0, 23, 11, 0, -35, 15, 0); - - // Draw red spline curves from the anchor points to the control points. - stroke(255, 0, 0); - curve(-45, -24, 0, -45, -24, 0, 23, -26, 0, 23, 11, 0); - curve(23, -26, 0, 23, 11, 0, -35, 15, 0, -35, 15, 0); - - // Draw the anchor points in black. - strokeWeight(5); - stroke(0); - point(23, -26); - point(23, 11); - - // Draw the control points in red. - stroke(255, 0, 0); - point(-45, -24); - point(-35, 15); - - describe( - 'A gray square with a jagged curve drawn in three segments. The curve is a sideways U shape with red segments on top and bottom, and a black segment on the right. The endpoints of all the segments are marked with dots.' - ); - } - -
-class: p5 -params: - - name: resolution - description: | -

number of segments to use. Defaults to 20.

- type: Number -chainable: true ---- - - -# curveDetail diff --git a/src/content/reference/en/p5 copy/curvePoint.mdx b/src/content/reference/en/p5 copy/curvePoint.mdx deleted file mode 100644 index 761b468ca6..0000000000 --- a/src/content/reference/en/p5 copy/curvePoint.mdx +++ /dev/null @@ -1,160 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L930 -title: curvePoint -module: Shape -submodule: Curves -file: src/core/shape/curves.js -description: > -

Calculates coordinates along a spline curve using interpolation.

- -

curvePoint() calculates coordinates along a spline curve using - the - - anchor and control points. It expects points in the same order as the - - curve() function. curvePoint() - works one axis - - at a time. Passing the anchor and control points' x-coordinates will - - calculate the x-coordinate of a point on the curve. Passing the anchor and - - control points' y-coordinates will calculate the y-coordinate of a point on - - the curve.

- -

The first parameter, a, is the coordinate of the first control - point.

- -

The second and third parameters, b and c, are the - coordinates of the - - anchor points.

- -

The fourth parameter, d, is the coordinate of the last control - point.

- -

The fifth parameter, t, is the amount to interpolate along the - curve. 0 - - is the first anchor point, 1 is the second anchor point, and 0.5 is halfway - - between them.

-line: 930 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Set the coordinates for the curve's anchor and control points. - let x1 = 5; - let y1 = 26; - let x2 = 73; - let y2 = 24; - let x3 = 73; - let y3 = 61; - let x4 = 15; - let y4 = 65; - - // Draw the curve. - noFill(); - curve(x1, y1, x2, y2, x3, y3, x4, y4); - - // Draw circles along the curve's path. - fill(255); - - // Top. - let x = curvePoint(x1, x2, x3, x4, 0); - let y = curvePoint(y1, y2, y3, y4, 0); - circle(x, y, 5); - - // Center. - x = curvePoint(x1, x2, x3, x4, 0.5); - y = curvePoint(y1, y2, y3, y4, 0.5); - circle(x, y, 5); - - // Bottom. - x = curvePoint(x1, x2, x3, x4, 1); - y = curvePoint(y1, y2, y3, y4, 1); - circle(x, y, 5); - - describe('A black curve on a gray square. The endpoints and center of the curve are marked with white circles.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A black curve on a gray square. A white circle moves back and forth along the curve.'); - } - - function draw() { - background(200); - - // Set the coordinates for the curve's anchor and control points. - let x1 = 5; - let y1 = 26; - let x2 = 73; - let y2 = 24; - let x3 = 73; - let y3 = 61; - let x4 = 15; - let y4 = 65; - - // Draw the curve. - noFill(); - curve(x1, y1, x2, y2, x3, y3, x4, y4); - - // Calculate the circle's coordinates. - let t = 0.5 * sin(frameCount * 0.01) + 0.5; - let x = curvePoint(x1, x2, x3, x4, t); - let y = curvePoint(y1, y2, y3, y4, t); - - // Draw the circle. - fill(255); - circle(x, y, 5); - } - -
-class: p5 -params: - - name: a - description: | -

coordinate of first control point.

- type: Number - - name: b - description: | -

coordinate of first anchor point.

- type: Number - - name: c - description: | -

coordinate of second anchor point.

- type: Number - - name: d - description: | -

coordinate of second control point.

- type: Number - - name: t - description: | -

amount to interpolate between 0 and 1.

- type: Number -return: - description: coordinate of a point on the curve. - type: Number -chainable: false ---- - - -# curvePoint diff --git a/src/content/reference/en/p5 copy/curveTangent.mdx b/src/content/reference/en/p5 copy/curveTangent.mdx deleted file mode 100644 index 005ade9aab..0000000000 --- a/src/content/reference/en/p5 copy/curveTangent.mdx +++ /dev/null @@ -1,153 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L1054 -title: curveTangent -module: Shape -submodule: Curves -file: src/core/shape/curves.js -description: > -

Calculates coordinates along a line that's tangent to a spline curve.

- -

Tangent lines skim the surface of a curve. A tangent line's slope equals - - the curve's slope at the point where it intersects.

- -

curveTangent() calculates coordinates along a tangent line - using the - - spline curve's anchor and control points. It expects points in the same - - order as the curve() function. - curveTangent() - - works one axis at a time. Passing the anchor and control points' - - x-coordinates will calculate the x-coordinate of a point on the tangent - - line. Passing the anchor and control points' y-coordinates will calculate - - the y-coordinate of a point on the tangent line.

- -

The first parameter, a, is the coordinate of the first control - point.

- -

The second and third parameters, b and c, are the - coordinates of the - - anchor points.

- -

The fourth parameter, d, is the coordinate of the last control - point.

- -

The fifth parameter, t, is the amount to interpolate along the - curve. 0 - - is the first anchor point, 1 is the second anchor point, and 0.5 is halfway - - between them.

-line: 1054 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Set the coordinates for the curve's anchor and control points. - let x1 = 5; - let y1 = 26; - let x2 = 73; - let y2 = 24; - let x3 = 73; - let y3 = 61; - let x4 = 15; - let y4 = 65; - - // Draw the curve. - noFill(); - curve(x1, y1, x2, y2, x3, y3, x4, y4); - - // Draw tangents along the curve's path. - fill(255); - - // Top circle. - stroke(0); - let x = curvePoint(x1, x2, x3, x4, 0); - let y = curvePoint(y1, y2, y3, y4, 0); - circle(x, y, 5); - - // Top tangent line. - // Scale the tangent point to draw a shorter line. - stroke(255, 0, 0); - let tx = 0.2 * curveTangent(x1, x2, x3, x4, 0); - let ty = 0.2 * curveTangent(y1, y2, y3, y4, 0); - line(x + tx, y + ty, x - tx, y - ty); - - // Center circle. - stroke(0); - x = curvePoint(x1, x2, x3, x4, 0.5); - y = curvePoint(y1, y2, y3, y4, 0.5); - circle(x, y, 5); - - // Center tangent line. - // Scale the tangent point to draw a shorter line. - stroke(255, 0, 0); - tx = 0.2 * curveTangent(x1, x2, x3, x4, 0.5); - ty = 0.2 * curveTangent(y1, y2, y3, y4, 0.5); - line(x + tx, y + ty, x - tx, y - ty); - - // Bottom circle. - stroke(0); - x = curvePoint(x1, x2, x3, x4, 1); - y = curvePoint(y1, y2, y3, y4, 1); - circle(x, y, 5); - - // Bottom tangent line. - // Scale the tangent point to draw a shorter line. - stroke(255, 0, 0); - tx = 0.2 * curveTangent(x1, x2, x3, x4, 1); - ty = 0.2 * curveTangent(y1, y2, y3, y4, 1); - line(x + tx, y + ty, x - tx, y - ty); - - describe( - 'A black curve on a gray square. A white circle moves back and forth along the curve.' - ); - } - -
-class: p5 -params: - - name: a - description: | -

coordinate of first control point.

- type: Number - - name: b - description: | -

coordinate of first anchor point.

- type: Number - - name: c - description: | -

coordinate of second anchor point.

- type: Number - - name: d - description: | -

coordinate of second control point.

- type: Number - - name: t - description: | -

amount to interpolate between 0 and 1.

- type: Number -return: - description: coordinate of a point on the tangent line. - type: Number -chainable: false ---- - - -# curveTangent diff --git a/src/content/reference/en/p5 copy/curveTightness.mdx b/src/content/reference/en/p5 copy/curveTightness.mdx deleted file mode 100644 index 506066be18..0000000000 --- a/src/content/reference/en/p5 copy/curveTightness.mdx +++ /dev/null @@ -1,77 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/curves.js#L875 -title: curveTightness -module: Shape -submodule: Curves -file: src/core/shape/curves.js -description: > -

Adjusts the way curve() and - - curveVertex() draw.

- -

Spline curves are like cables that are attached to a set of points. - - curveTightness() adjusts how tightly the cable is attached to the - points.

- -

The parameter, tightness, determines how the curve fits to the - vertex - - points. By default, tightness is set to 0. Setting tightness to - 1, - - as in curveTightness(1), connects the curve's points using - straight - - lines. Values in the range from –5 to 5 deform curves while leaving them - - recognizable.

-line: 875 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Move the mouse left and right to see the curve change. - - function setup() { - createCanvas(100, 100); - - describe('A black curve forms a sideways U shape. The curve deforms as the user moves the mouse from left to right'); - } - - function draw() { - background(200); - - // Set the curve's tightness using the mouse. - let t = map(mouseX, 0, 100, -5, 5, true); - curveTightness(t); - - // Draw the curve. - noFill(); - beginShape(); - curveVertex(10, 26); - curveVertex(10, 26); - curveVertex(83, 24); - curveVertex(83, 61); - curveVertex(25, 65); - curveVertex(25, 65); - endShape(); - } - -
-class: p5 -params: - - name: amount - description: | -

amount of tightness.

- type: Number -chainable: true ---- - - -# curveTightness diff --git a/src/content/reference/en/p5 copy/curveVertex.mdx b/src/content/reference/en/p5 copy/curveVertex.mdx deleted file mode 100644 index 3d928fc0ce..0000000000 --- a/src/content/reference/en/p5 copy/curveVertex.mdx +++ /dev/null @@ -1,407 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L832 -title: curveVertex -module: Shape -submodule: Vertex -file: src/core/shape/vertex.js -description: > -

Adds a spline curve segment to a custom shape.

- -

curveVertex() adds a curved segment to custom shapes. The - spline curves - - it creates are defined like those made by the - - curve() function. - curveVertex() must be called - - between the beginShape() and - - endShape() functions.

- -

Spline curves can form shapes and curves that slope gently. They’re like - - cables that are attached to a set of points. Splines are defined by two - - anchor points and two control points. curveVertex() must be - called at - - least four times between - - beginShape() and - - endShape() in order to draw a curve:

- -
beginShape();
-
-
-  // Add the first control point.
-
-  curveVertex(84, 91);
-
-
-  // Add the anchor points to draw between.
-
-  curveVertex(68, 19);
-
-  curveVertex(21, 17);
-
-
-  // Add the second control point.
-
-  curveVertex(32, 91);
-
-
-  endShape();
-
-  
- -

The code snippet above would only draw the curve between the anchor points, - - similar to the curve() function. The - segments - - between the control and anchor points can be drawn by calling - - curveVertex() with the coordinates of the control points:

- -
beginShape();
-
-
-  // Add the first control point and draw a segment to it.
-
-  curveVertex(84, 91);
-
-  curveVertex(84, 91);
-
-
-  // Add the anchor points to draw between.
-
-  curveVertex(68, 19);
-
-  curveVertex(21, 17);
-
-
-  // Add the second control point.
-
-  curveVertex(32, 91);
-
-
-  // Uncomment the next line to draw the segment to the second control point.
-
-  // curveVertex(32, 91);
-
-
-  endShape();
-
-  
- -

The first two parameters, x and y, set the - vertex’s location. For - - example, calling curveVertex(10, 10) adds a point to the curve at - - (10, 10).

- -

Spline curves can also be drawn in 3D using WebGL mode. The 3D version of - - curveVertex() has three arguments because each point has x-, y-, - and - - z-coordinates. By default, the vertex’s z-coordinate is set to 0.

- -

Note: curveVertex() won’t work when an argument is passed to - - beginShape().

-line: 832 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the shape. - noFill(); - strokeWeight(1); - - // Start drawing the shape. - beginShape(); - - // Add the first control point. - curveVertex(32, 91); - - // Add the anchor points. - curveVertex(21, 17); - curveVertex(68, 19); - - // Add the second control point. - curveVertex(84, 91); - - // Stop drawing the shape. - endShape(); - - // Style the anchor and control points. - strokeWeight(5); - - // Draw the anchor points in black. - stroke(0); - point(21, 17); - point(68, 19); - - // Draw the control points in red. - stroke(255, 0, 0); - point(32, 91); - point(84, 91); - - describe( - 'A black curve drawn on a gray background. The curve has black dots at its ends. Two red dots appear near the bottom of the canvas.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the shape. - noFill(); - strokeWeight(1); - - // Start drawing the shape. - beginShape(); - - // Add the first control point and draw a segment to it. - curveVertex(32, 91); - curveVertex(32, 91); - - // Add the anchor points. - curveVertex(21, 17); - curveVertex(68, 19); - - // Add the second control point. - curveVertex(84, 91); - - // Stop drawing the shape. - endShape(); - - // Style the anchor and control points. - strokeWeight(5); - - // Draw the anchor points in black. - stroke(0); - point(21, 17); - point(68, 19); - - // Draw the control points in red. - stroke(255, 0, 0); - point(32, 91); - point(84, 91); - - describe( - 'A black curve drawn on a gray background. The curve passes through one red dot and two black dots. Another red dot appears near the bottom of the canvas.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the shape. - noFill(); - strokeWeight(1); - - // Start drawing the shape. - beginShape(); - - // Add the first control point and draw a segment to it. - curveVertex(32, 91); - curveVertex(32, 91); - - // Add the anchor points. - curveVertex(21, 17); - curveVertex(68, 19); - - // Add the second control point and draw a segment to it. - curveVertex(84, 91); - curveVertex(84, 91); - - // Stop drawing the shape. - endShape(); - - // Style the anchor and control points. - strokeWeight(5); - - // Draw the anchor points in black. - stroke(0); - point(21, 17); - point(68, 19); - - // Draw the control points in red. - stroke(255, 0, 0); - point(32, 91); - point(84, 91); - - describe( - 'A black U curve drawn upside down on a gray background. The curve passes from one red dot through two black dots and ends at another red dot.' - ); - } - -
- -
- - // Click the mouse near the red dot in the bottom-left corner - // and drag to change the curve's shape. - - let x1 = 32; - let y1 = 91; - let isChanging = false; - - function setup() { - createCanvas(100, 100); - - describe( - 'A black U curve drawn upside down on a gray background. The curve passes from one red dot through two black dots and ends at another red dot.' - ); - } - - function draw() { - background(200); - - // Style the shape. - noFill(); - stroke(0); - strokeWeight(1); - - // Start drawing the shape. - beginShape(); - - // Add the first control point and draw a segment to it. - curveVertex(x1, y1); - curveVertex(x1, y1); - - // Add the anchor points. - curveVertex(21, 17); - curveVertex(68, 19); - - // Add the second control point and draw a segment to it. - curveVertex(84, 91); - curveVertex(84, 91); - - // Stop drawing the shape. - endShape(); - - // Style the anchor and control points. - strokeWeight(5); - - // Draw the anchor points in black. - stroke(0); - point(21, 17); - point(68, 19); - - // Draw the control points in red. - stroke(255, 0, 0); - point(x1, y1); - point(84, 91); - } - - // Start changing the first control point if the user clicks near it. - function mousePressed() { - if (dist(mouseX, mouseY, x1, y1) < 20) { - isChanging = true; - } - } - - // Stop changing the first control point when the user releases the mouse. - function mouseReleased() { - isChanging = false; - } - - // Update the first control point while the user drags the mouse. - function mouseDragged() { - if (isChanging === true) { - x1 = mouseX; - y1 = mouseY; - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - beginShape(); - - // Add the first control point and draw a segment to it. - curveVertex(32, 91); - curveVertex(32, 91); - - // Add the anchor points. - curveVertex(21, 17); - curveVertex(68, 19); - - // Add the second control point. - curveVertex(84, 91); - curveVertex(84, 91); - - // Stop drawing the shape. - endShape(); - - describe('A ghost shape drawn in white on a gray background.'); - } - -
-class: p5 -overloads: - - line: 832 - params: - - name: x - description: | -

x-coordinate of the vertex

- type: Number - - name: 'y' - description: | -

y-coordinate of the vertex

- type: Number - chainable: 1 - - line: 1160 - params: - - name: x - description: '' - type: Number - - name: 'y' - description: '' - type: Number - - name: z - description: | -

z-coordinate of the vertex.

- type: Number - optional: true - chainable: 1 -chainable: true ---- - - -# curveVertex diff --git a/src/content/reference/en/p5 copy/cylinder.mdx b/src/content/reference/en/p5 copy/cylinder.mdx deleted file mode 100644 index dd81cd687f..0000000000 --- a/src/content/reference/en/p5 copy/cylinder.mdx +++ /dev/null @@ -1,282 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L1477 -title: cylinder -module: Shape -submodule: 3D Primitives -file: src/webgl/3d_primitives.js -description: > -

Draws a cylinder.

- -

A cylinder is a 3D shape with triangular faces that connect a flat bottom - - to a flat top. Cylinders with few faces look like boxes. Cylinders with - - many faces have smooth surfaces.

- -

The first parameter, radius, is optional. If a - Number is passed, as in - - cylinder(20), it sets the radius of the cylinder’s base. By - default, - - radius is 50.

- -

The second parameter, height, is also optional. If a - Number is passed, - - as in cylinder(20, 30), it sets the cylinder’s height. By - default, - - height is set to the cylinder’s radius.

- -

The third parameter, detailX, is also optional. If a - Number is passed, - - as in cylinder(20, 30, 5), it sets the number of edges used to - form the - - cylinder's top and bottom. Using more edges makes the top and bottom look - - more like circles. By default, detailX is 24.

- -

The fourth parameter, detailY, is also optional. If a - Number is passed, - - as in cylinder(20, 30, 5, 2), it sets the number of triangle - subdivisions - - to use along the y-axis, between cylinder's the top and bottom. All 3D - - shapes are made by connecting triangles to form their surfaces. By default, - - detailY is 1.

- -

The fifth parameter, bottomCap, is also optional. If a - false is passed, - - as in cylinder(20, 30, 5, 2, false) the cylinder’s bottom won’t - be drawn. - - By default, bottomCap is true.

- -

The sixth parameter, topCap, is also optional. If a - false is passed, as - - in cylinder(20, 30, 5, 2, false, false) the cylinder’s top won’t - be - - drawn. By default, topCap is true.

- -

Note: cylinder() can only be used in WebGL mode.

-line: 1477 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cylinder on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cylinder. - cylinder(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cylinder on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cylinder. - // Set its radius and height to 30. - cylinder(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cylinder on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cylinder. - // Set its radius to 30 and height to 50. - cylinder(30, 50); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white box on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cylinder. - // Set its radius to 30 and height to 50. - // Set its detailX to 5. - cylinder(30, 50, 5); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cylinder on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cylinder. - // Set its radius to 30 and height to 50. - // Set its detailX to 24 and detailY to 2. - cylinder(30, 50, 24, 2); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cylinder on a gray background. Its top is missing.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cylinder. - // Set its radius to 30 and height to 50. - // Set its detailX to 24 and detailY to 1. - // Don't draw its bottom. - cylinder(30, 50, 24, 1, false); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cylinder on a gray background. Its top and bottom are missing.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the cylinder. - // Set its radius to 30 and height to 50. - // Set its detailX to 24 and detailY to 1. - // Don't draw its bottom or top. - cylinder(30, 50, 24, 1, false, false); - } - -
-class: p5 -params: - - name: radius - description: | -

radius of the cylinder. Defaults to 50.

- type: Number - optional: true - - name: height - description: > -

height of the cylinder. Defaults to the value of - radius.

- type: Number - optional: true - - name: detailX - description: | -

number of edges along the top and bottom. Defaults to 24.

- type: Integer - optional: true - - name: detailY - description: | -

number of triangle subdivisions along the y-axis. Defaults to 1.

- type: Integer - optional: true - - name: bottomCap - description: > -

whether to draw the cylinder's bottom. Defaults to - true.

- type: Boolean - optional: true - - name: topCap - description: | -

whether to draw the cylinder's top. Defaults to true.

- type: Boolean - optional: true -chainable: true ---- - - -# cylinder diff --git a/src/content/reference/en/p5 copy/day.mdx b/src/content/reference/en/p5 copy/day.mdx deleted file mode 100644 index f029fcb983..0000000000 --- a/src/content/reference/en/p5 copy/day.mdx +++ /dev/null @@ -1,47 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L10 -title: day -module: IO -submodule: Time & Date -file: src/utilities/time_date.js -description: | -

Returns the current day as a number from 1–31.

-line: 10 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Get the current day. - let d = day(); - - // Style the text. - textAlign(LEFT, CENTER); - textSize(12); - textFont('Courier New'); - - // Display the day. - text(`Current day: ${d}`, 20, 50, 60); - - describe(`The text 'Current day: ${d}' written in black on a gray background.`); - } - -
-class: p5 -return: - description: current day between 1 and 31. - type: Integer -chainable: false ---- - - -# day diff --git a/src/content/reference/en/p5 copy/debugMode.mdx b/src/content/reference/en/p5 copy/debugMode.mdx deleted file mode 100644 index 19ccdfb63f..0000000000 --- a/src/content/reference/en/p5 copy/debugMode.mdx +++ /dev/null @@ -1,362 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/interaction.js#L471 -title: debugMode -module: 3D -submodule: Interaction -file: src/webgl/interaction.js -description: > -

Adds a grid and an axes icon to clarify orientation in 3D sketches.

- -

debugMode() adds a grid that shows where the “ground” is in a - sketch. By - - default, the grid will run through the origin (0, 0, 0) of the - sketch - - along the XZ plane. debugMode() also adds an axes icon that - points along - - the positive x-, y-, and z-axes. Calling debugMode() displays the - grid - - and axes icon with their default size and position.

- -

There are four ways to call debugMode() with optional - parameters to - - customize the debugging environment.

- -

The first way to call debugMode() has one parameter, - mode. If the - - system constant GRID is passed, as in - debugMode(GRID), then the grid - - will be displayed and the axes icon will be hidden. If the constant - AXES - - is passed, as in debugMode(AXES), then the axes icon will be - displayed - - and the grid will be hidden.

- -

The second way to call debugMode() has six parameters. The - first - - parameter, mode, selects either GRID or - AXES to be displayed. The - - next five parameters, gridSize, gridDivisions, - xOff, yOff, and - - zOff are optional. They’re numbers that set the appearance of the - grid - - (gridSize and gridDivisions) and the placement of - the axes icon - - (xOff, yOff, and zOff). For example, - calling - - debugMode(20, 5, 10, 10, 10) sets the gridSize to 20 - pixels, the number - - of gridDivisions to 5, and offsets the axes icon by 10 pixels - along the - - x-, y-, and z-axes.

- -

The third way to call debugMode() has five parameters. The - first - - parameter, mode, selects either GRID or - AXES to be displayed. The - - next four parameters, axesSize, xOff, - yOff, and zOff are optional. - - They’re numbers that set the appearance of the size of the axes icon - - (axesSize) and its placement (xOff, - yOff, and zOff).

- -

The fourth way to call debugMode() has nine optional - parameters. The - - first five parameters, gridSize, gridDivisions, - gridXOff, gridYOff, - - and gridZOff are numbers that set the appearance of the grid. For - - example, calling debugMode(100, 5, 0, 0, 0) sets the - gridSize to 100, - - the number of gridDivisions to 5, and sets all the offsets to 0 - so that - - the grid is centered at the origin. The next four parameters, - axesSize, - - xOff, yOff, and zOff are numbers that - set the appearance of the size - - of the axes icon (axesSize) and its placement - (axesXOff, axesYOff, - - and axesZOff). For example, calling - - debugMode(100, 5, 0, 0, 0, 50, 10, 10, 10) sets the - gridSize to 100, - - the number of gridDivisions to 5, and sets all the offsets to 0 - so that - - the grid is centered at the origin. It then sets the axesSize to - 50 and - - offsets the icon 10 pixels along each axis.

-line: 471 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - // Enable debug mode. - debugMode(); - - describe('A multicolor box on a gray background. A grid and axes icon are displayed near the box.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the box. - normalMaterial(); - - // Draw the box. - box(20, 40); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - // Enable debug mode. - // Only display the axes icon. - debugMode(AXES); - - describe('A multicolor box on a gray background. A grid and axes icon are displayed near the box.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the box. - normalMaterial(); - - // Draw the box. - box(20, 40); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - // Enable debug mode. - // Only display the grid and customize it: - // - size: 50 - // - divisions: 10 - // - offsets: 0, 20, 0 - debugMode(GRID, 50, 10, 0, 20, 0); - - describe('A multicolor box on a gray background. A grid is displayed below the box.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the box. - normalMaterial(); - - // Draw the box. - box(20, 40); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - // Enable debug mode. - // Display the grid and axes icon and customize them: - // Grid - // ---- - // - size: 50 - // - divisions: 10 - // - offsets: 0, 20, 0 - // Axes - // ---- - // - size: 50 - // - offsets: 0, 0, 0 - debugMode(50, 10, 0, 20, 0, 50, 0, 0, 0); - - describe('A multicolor box on a gray background. A grid is displayed below the box. An axes icon is displayed at the center of the box.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the box. - normalMaterial(); - - // Draw the box. - box(20, 40); - } - -
-class: p5 -overloads: - - line: 471 - params: [] - - line: 650 - params: - - name: mode - description: | -

either GRID or AXES

- type: Constant - - line: 655 - params: - - name: mode - description: '' - type: Constant - - name: gridSize - description: | -

side length of the grid.

- type: Number - optional: true - - name: gridDivisions - description: | -

number of divisions in the grid.

- type: Number - optional: true - - name: xOff - description: | -

offset from origin along the x-axis.

- type: Number - optional: true - - name: yOff - description: | -

offset from origin along the y-axis.

- type: Number - optional: true - - name: zOff - description: | -

offset from origin along the z-axis.

- type: Number - optional: true - - line: 665 - params: - - name: mode - description: '' - type: Constant - - name: axesSize - description: | -

length of axes icon markers.

- type: Number - optional: true - - name: xOff - description: '' - type: Number - optional: true - - name: yOff - description: '' - type: Number - optional: true - - name: zOff - description: '' - type: Number - optional: true - - line: 674 - params: - - name: gridSize - description: '' - type: Number - optional: true - - name: gridDivisions - description: '' - type: Number - optional: true - - name: gridXOff - description: | -

grid offset from the origin along the x-axis.

- type: Number - optional: true - - name: gridYOff - description: | -

grid offset from the origin along the y-axis.

- type: Number - optional: true - - name: gridZOff - description: | -

grid offset from the origin along the z-axis.

- type: Number - optional: true - - name: axesSize - description: '' - type: Number - optional: true - - name: axesXOff - description: | -

axes icon offset from the origin along the x-axis.

- type: Number - optional: true - - name: axesYOff - description: | -

axes icon offset from the origin along the y-axis.

- type: Number - optional: true - - name: axesZOff - description: | -

axes icon offset from the origin along the z-axis.

- type: Number - optional: true -chainable: false ---- - - -# debugMode diff --git a/src/content/reference/en/p5 copy/degrees.mdx b/src/content/reference/en/p5 copy/degrees.mdx deleted file mode 100644 index 730b361384..0000000000 --- a/src/content/reference/en/p5 copy/degrees.mdx +++ /dev/null @@ -1,53 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L485 -title: degrees -module: Math -submodule: Trigonometry -file: src/math/trigonometry.js -description: | -

Converts an angle measured in radians to its value in degrees.

-

Degrees and radians are both units for measuring angles. There are 360˚ in - one full rotation. A full rotation is 2 × π (about 6.28) radians.

-

The same angle can be expressed in with either unit. For example, 90° is a - quarter of a full rotation. The same angle is 2 × π ÷ 4 - (about 1.57) radians.

-line: 485 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Calculate the angle conversion. - let rad = QUARTER_PI; - let deg = degrees(rad); - - // Display the conversion. - text(`${round(rad, 2)} rad = ${deg}˚`, 10, 50); - - describe('The text "0.79 rad = 45˚".'); - } - -
-class: p5 -params: - - name: radians - description: | -

radians value to convert to degrees.

- type: Number -return: - description: converted angle. - type: Number -chainable: false ---- - - -# degrees diff --git a/src/content/reference/en/p5 copy/deltaTime.mdx b/src/content/reference/en/p5 copy/deltaTime.mdx deleted file mode 100644 index 0915a014c2..0000000000 --- a/src/content/reference/en/p5 copy/deltaTime.mdx +++ /dev/null @@ -1,68 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L124 -title: deltaTime -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

A Number variable that tracks the number of milliseconds it - took to draw - - the last frame.

- -

deltaTime contains the amount of time it took - - draw() to execute during the previous frame. - It's - - useful for simulating physics.

-line: 124 -isConstructor: false -itemtype: property -example: - - |- - -
- - let x = 0; - let speed = 0.05; - - function setup() { - createCanvas(100, 100); - - // Set the frameRate to 30. - frameRate(30); - - describe('A white circle moves from left to right on a gray background. It reappears on the left side when it reaches the right side.'); - } - - function draw() { - background(200); - - // Use deltaTime to calculate - // a change in position. - let deltaX = speed * deltaTime; - - // Update the x variable. - x += deltaX; - - // Reset x to 0 if it's - // greater than 100. - if (x > 100) { - x = 0; - } - - // Use x to set the circle's - // position. - circle(x, 50, 20); - } - -
-class: p5 -type: Integer ---- - - -# deltaTime diff --git a/src/content/reference/en/p5 copy/describe.mdx b/src/content/reference/en/p5 copy/describe.mdx deleted file mode 100644 index dee815b9f1..0000000000 --- a/src/content/reference/en/p5 copy/describe.mdx +++ /dev/null @@ -1,137 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/accessibility/describe.js#L18 -title: describe -module: Environment -submodule: Environment -file: src/accessibility/describe.js -description: > -

Creates a screen reader-accessible description of the canvas.

- -

The first parameter, text, is the description of the - canvas.

- -

The second parameter, display, is optional. It determines how - the - - description is displayed. If LABEL is passed, as in - - describe('A description.', LABEL), the description will be - visible in - - a div element next to the canvas. If FALLBACK is passed, as in - - describe('A description.', FALLBACK), the description will only - be - - visible to screen readers. This is the default mode.

- -

Read - - Writing - accessible canvas descriptions - - to learn more about making sketches accessible.

-line: 18 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - background('pink'); - - // Draw a heart. - fill('red'); - noStroke(); - circle(67, 67, 20); - circle(83, 67, 20); - triangle(91, 73, 75, 95, 59, 73); - - // Add a general description of the canvas. - describe('A pink square with a red heart in the bottom-right corner.'); - } - -
- -
- - function setup() { - background('pink'); - - // Draw a heart. - fill('red'); - noStroke(); - circle(67, 67, 20); - circle(83, 67, 20); - triangle(91, 73, 75, 95, 59, 73); - - // Add a general description of the canvas - // and display it for debugging. - describe('A pink square with a red heart in the bottom-right corner.', LABEL); - } - -
- -
- - function draw() { - background(200); - - // The expression - // frameCount % 100 - // causes x to increase from 0 - // to 99, then restart from 0. - let x = frameCount % 100; - - // Draw the circle. - fill(0, 255, 0); - circle(x, 50, 40); - - // Add a general description of the canvas. - describe(`A green circle at (${x}, 50) moves from left to right on a gray square.`); - } - -
- -
- - function draw() { - background(200); - - // The expression - // frameCount % 100 - // causes x to increase from 0 - // to 99, then restart from 0. - let x = frameCount % 100; - - // Draw the circle. - fill(0, 255, 0); - circle(x, 50, 40); - - // Add a general description of the canvas - // and display it for debugging. - describe(`A green circle at (${x}, 50) moves from left to right on a gray square.`, LABEL); - } - -
-class: p5 -params: - - name: text - description: | -

description of the canvas.

- type: String - - name: display - description: | -

either LABEL or FALLBACK.

- type: Constant - optional: true -chainable: false ---- - - -# describe diff --git a/src/content/reference/en/p5 copy/describeElement.mdx b/src/content/reference/en/p5 copy/describeElement.mdx deleted file mode 100644 index 0b7bc8b330..0000000000 --- a/src/content/reference/en/p5 copy/describeElement.mdx +++ /dev/null @@ -1,127 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/accessibility/describe.js#L162 -title: describeElement -module: Environment -submodule: Environment -file: src/accessibility/describe.js -description: > -

Creates a screen reader-accessible description of elements in the - canvas.

- -

Elements are shapes or groups of shapes that create meaning together. For - - example, a few overlapping circles could make an "eye" element.

- -

The first parameter, name, is the name of the element.

- -

The second parameter, text, is the description of the - element.

- -

The third parameter, display, is optional. It determines how - the - - description is displayed. If LABEL is passed, as in - - describe('A description.', LABEL), the description will be - visible in - - a div element next to the canvas. Using LABEL creates unhelpful - - duplicates for screen readers. Only use LABEL during development. - If - - FALLBACK is passed, as in describe('A description.', - FALLBACK), the - - description will only be visible to screen readers. This is the default - - mode.

- -

Read - - Writing - accessible canvas descriptions - - to learn more about making sketches accessible.

-line: 162 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - background('pink'); - - // Describe the first element - // and draw it. - describeElement('Circle', 'A yellow circle in the top-left corner.'); - noStroke(); - fill('yellow'); - circle(25, 25, 40); - - // Describe the second element - // and draw it. - describeElement('Heart', 'A red heart in the bottom-right corner.'); - fill('red'); - circle(66.6, 66.6, 20); - circle(83.2, 66.6, 20); - triangle(91.2, 72.6, 75, 95, 58.6, 72.6); - - // Add a general description of the canvas. - describe('A red heart and yellow circle over a pink background.'); - } - -
- -
- - function setup() { - background('pink'); - - // Describe the first element - // and draw it. Display the - // description for debugging. - describeElement('Circle', 'A yellow circle in the top-left corner.', LABEL); - noStroke(); - fill('yellow'); - circle(25, 25, 40); - - // Describe the second element - // and draw it. Display the - // description for debugging. - describeElement('Heart', 'A red heart in the bottom-right corner.', LABEL); - fill('red'); - circle(66.6, 66.6, 20); - circle(83.2, 66.6, 20); - triangle(91.2, 72.6, 75, 95, 58.6, 72.6); - - // Add a general description of the canvas. - describe('A red heart and yellow circle over a pink background.'); - } - -
-class: p5 -params: - - name: name - description: | -

name of the element.

- type: String - - name: text - description: | -

description of the element.

- type: String - - name: display - description: | -

either LABEL or FALLBACK.

- type: Constant - optional: true -chainable: false ---- - - -# describeElement diff --git a/src/content/reference/en/p5 copy/deviceMoved.mdx b/src/content/reference/en/p5 copy/deviceMoved.mdx deleted file mode 100644 index 90e9ce91fb..0000000000 --- a/src/content/reference/en/p5 copy/deviceMoved.mdx +++ /dev/null @@ -1,49 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L501 -title: deviceMoved -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

The deviceMoved() function is - called when the device is moved by more than - - the threshold value along X, Y or Z axis. The default threshold is set to 0.5. - - The threshold value can be changed using setMoveThreshold().

-line: 501 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Run this example on a mobile device - // Move the device around - // to change the value. - - let value = 0; - 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; - if (value > 255) { - value = 0; - } - } - -
-class: p5 -chainable: false ---- - - -# deviceMoved diff --git a/src/content/reference/en/p5 copy/deviceOrientation.mdx b/src/content/reference/en/p5 copy/deviceOrientation.mdx deleted file mode 100644 index a18763fc87..0000000000 --- a/src/content/reference/en/p5 copy/deviceOrientation.mdx +++ /dev/null @@ -1,22 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L11 -title: deviceOrientation -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: | -

The system variable deviceOrientation always contains the orientation of - the device. The value of this variable will either be set 'landscape' - or 'portrait'. If no data is available it will be set to 'undefined'. - either LANDSCAPE or PORTRAIT.

-line: 11 -isConstructor: false -itemtype: property -class: p5 -type: Constant ---- - - -# deviceOrientation diff --git a/src/content/reference/en/p5 copy/deviceShaken.mdx b/src/content/reference/en/p5 copy/deviceShaken.mdx deleted file mode 100644 index 0c1cce17f8..0000000000 --- a/src/content/reference/en/p5 copy/deviceShaken.mdx +++ /dev/null @@ -1,50 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L589 -title: deviceShaken -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

The deviceShaken() function is - called when the device total acceleration - - changes of accelerationX and accelerationY values is more than - - the threshold value. The default threshold is set to 30. - - The threshold value can be changed using setShakeThreshold().

-line: 589 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Run this example on a mobile device - // Shake the device to change the value. - - let value = 0; - 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; - if (value > 255) { - value = 0; - } - } - -
-class: p5 -chainable: false ---- - - -# deviceShaken diff --git a/src/content/reference/en/p5 copy/deviceTurned.mdx b/src/content/reference/en/p5 copy/deviceTurned.mdx deleted file mode 100644 index 28f760eb6f..0000000000 --- a/src/content/reference/en/p5 copy/deviceTurned.mdx +++ /dev/null @@ -1,80 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L531 -title: deviceTurned -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

The deviceTurned() function is - called when the device rotates by - - more than 90 degrees continuously.

- -

The axis that triggers the deviceTurned() method is stored in the - turnAxis - - variable. The deviceTurned() method - can be locked to trigger on any axis: - - X, Y or Z by comparing the turnAxis variable to 'X', 'Y' or 'Z'.

-line: 531 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Run this example on a mobile device - // Rotate the device by 90 degrees - // to change the value. - - let value = 0; - 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) { - value = 255; - } else if (value === 255) { - value = 0; - } - } - -
-
- - // Run this example on a mobile device - // Rotate the device by 90 degrees in the - // X-axis to change the value. - - let value = 0; - 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') { - if (value === 0) { - value = 255; - } else if (value === 255) { - value = 0; - } - } - } - -
-class: p5 -chainable: false ---- - - -# deviceTurned diff --git a/src/content/reference/en/p5 copy/directionalLight.mdx b/src/content/reference/en/p5 copy/directionalLight.mdx deleted file mode 100644 index b2b3e011a3..0000000000 --- a/src/content/reference/en/p5 copy/directionalLight.mdx +++ /dev/null @@ -1,277 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L461 -title: directionalLight -module: 3D -submodule: Lights -file: src/webgl/light.js -description: > -

Creates a light that shines in one direction.

- -

Directional lights don’t shine from a specific point. They’re like a sun - - that shines from somewhere offscreen. The light’s direction is set using - - three (x, y, z) values between -1 and 1. For example, setting a - light’s - - direction as (1, 0, 0) will light p5.Geometry - - objects from the left since the light faces directly to the right. A - - maximum of 5 directional lights can be active at once.

- -

There are four ways to call directionalLight() with parameters - to set the - - light’s color and direction.

- -

The first way to call directionalLight() has six parameters. - The first - - three parameters, v1, v2, and v3, set - the light’s color using the - - current colorMode(). The last three - - parameters, x, y, and z, set the - light’s direction. For example, - - directionalLight(255, 0, 0, 1, 0, 0) creates a red (255, 0, - 0) light - - that shines to the right (1, 0, 0).

- -

The second way to call directionalLight() has four parameters. - The first - - three parameters, v1, v2, and v3, set - the light’s color using the - - current colorMode(). The last - parameter, - - direction sets the light’s direction using a - p5.Vector object. For example, - directionalLight(255, 0, 0, lightDir) creates a red (255, - 0, 0) light - - that shines in the direction the lightDir vector points.

- -

The third way to call directionalLight() has four parameters. - The first - - parameter, color, sets the light’s color using a - - p5.Color object or an array of color - values. The - - last three parameters, x, y, and z, set - the light’s direction. For - - example, directionalLight(myColor, 1, 0, 0) creates a light that - shines - - to the right (1, 0, 0) with the color value of - myColor.

- -

The fourth way to call directionalLight() has two parameters. - The first - - parameter, color, sets the light’s color using a - - p5.Color object or an array of color - values. The - - second parameter, direction, sets the light’s direction using a - - p5.Color object. For example, - - directionalLight(myColor, lightDir) creates a light that shines - in the - - direction the lightDir vector points with the color value of - myColor.

-line: 461 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click to turn on the directional light. - - let isLit = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A sphere drawn on a gray background. A red light starts shining from above when the user double-clicks.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Control the light. - if (isLit === true) { - // Add a red directional light from above. - // Use RGB values and XYZ directions. - directionalLight(255, 0, 0, 0, 1, 0); - } - - // Style the sphere. - noStroke(); - - // Draw the sphere. - sphere(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Add a red directional light from above. - // Use a p5.Color object and XYZ directions. - let c = color(255, 0, 0); - directionalLight(c, 0, 1, 0); - - // Style the sphere. - noStroke(); - - // Draw the sphere. - sphere(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Add a red directional light from above. - // Use a p5.Color object and a p5.Vector object. - let c = color(255, 0, 0); - let lightDir = createVector(0, 1, 0); - directionalLight(c, lightDir); - - // Style the sphere. - noStroke(); - - // Draw the sphere. - sphere(30); - } - -
-class: p5 -overloads: - - line: 461 - params: - - name: v1 - description: | -

red or hue value in the current - colorMode().

- type: Number - - name: v2 - description: | -

green or saturation value in the current - colorMode().

- type: Number - - name: v3 - description: | -

blue, brightness, or lightness value in the current - colorMode().

- type: Number - - name: x - description: | -

x-component of the light's direction between -1 and 1.

- type: Number - - name: 'y' - description: | -

y-component of the light's direction between -1 and 1.

- type: Number - - name: z - description: | -

z-component of the light's direction between -1 and 1.

- type: Number - chainable: 1 - - line: 614 - params: - - name: v1 - description: '' - type: Number - - name: v2 - description: '' - type: Number - - name: v3 - description: '' - type: Number - - name: direction - description: | -

direction of the light as a - p5.Vector object.

- type: p5.Vector - chainable: 1 - - line: 624 - params: - - name: color - description: | -

color as a p5.Color object, - an array of color values, or as a CSS string.

- type: 'p5.Color|Number[]|String' - - name: x - description: '' - type: Number - - name: 'y' - description: '' - type: Number - - name: z - description: '' - type: Number - chainable: 1 - - line: 634 - params: - - name: color - description: '' - type: 'p5.Color|Number[]|String' - - name: direction - description: '' - type: p5.Vector - chainable: 1 -chainable: true ---- - - -# directionalLight diff --git a/src/content/reference/en/p5 copy/disableFriendlyErrors.mdx b/src/content/reference/en/p5 copy/disableFriendlyErrors.mdx deleted file mode 100644 index a72ec28678..0000000000 --- a/src/content/reference/en/p5 copy/disableFriendlyErrors.mdx +++ /dev/null @@ -1,55 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L872 -title: disableFriendlyErrors -module: Structure -submodule: Structure -file: src/core/main.js -description: > -

Turns off the parts of the Friendly Error System (FES) that impact - performance.

- -

The FES - - can cause sketches to draw slowly because it does extra work behind the - - scenes. For example, the FES checks the arguments passed to functions, - - which takes time to process. Disabling the FES can significantly improve - - performance by turning off these checks.

-line: 872 -isConstructor: false -itemtype: property -example: - - |- - -
- - // Disable the FES. - p5.disableFriendlyErrors = true; - - function setup() { - createCanvas(100, 100); - - background(200); - - // The circle() function requires three arguments. The - // next line would normally display a friendly error that - // points this out. Instead, nothing happens and it fails - // silently. - circle(50, 50); - - describe('A gray square.'); - } - -
-class: p5 -type: Boolean ---- - - -# disableFriendlyErrors diff --git a/src/content/reference/en/p5 copy/displayDensity.mdx b/src/content/reference/en/p5 copy/displayDensity.mdx deleted file mode 100644 index e52be83ec2..0000000000 --- a/src/content/reference/en/p5 copy/displayDensity.mdx +++ /dev/null @@ -1,55 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L1078 -title: displayDensity -module: Environment -submodule: Environment -file: src/core/environment.js -description: | -

Returns the display's current pixel density.

-line: 1078 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - // Set the pixel density to 1. - pixelDensity(1); - - // Create a canvas and draw - // a circle. - createCanvas(100, 100); - background(200); - circle(50, 50, 70); - - describe('A fuzzy white circle drawn on a gray background. The circle becomes sharper when the mouse is pressed.'); - } - - function mousePressed() { - // Get the current display density. - let d = displayDensity(); - - // Use the display density to set - // the sketch's pixel density. - pixelDensity(d); - - // Paint the background and - // draw a circle. - background(200); - circle(50, 50, 70); - } - -
-class: p5 -return: - description: current pixel density of the display. - type: Number -chainable: false ---- - - -# displayDensity diff --git a/src/content/reference/en/p5 copy/displayHeight.mdx b/src/content/reference/en/p5 copy/displayHeight.mdx deleted file mode 100644 index d392419e70..0000000000 --- a/src/content/reference/en/p5 copy/displayHeight.mdx +++ /dev/null @@ -1,47 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L621 -title: displayHeight -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

A Number variable that stores the height of the screen - display.

- -

displayHeight is useful for running full-screen programs. Its - value - - depends on the current pixelDensity().

- -

Note: The actual screen height can be computed as - - displayHeight * pixelDensity().

-line: 621 -isConstructor: false -itemtype: property -alt: This example does not render anything. -example: - - |- - -
- - function setup() { - // Set the canvas' width and height - // using the display's dimensions. - createCanvas(displayWidth, displayHeight); - - background(200); - - describe('A gray canvas that is the same size as the display.'); - } - -
-class: p5 -type: Number ---- - - -# displayHeight diff --git a/src/content/reference/en/p5 copy/displayWidth.mdx b/src/content/reference/en/p5 copy/displayWidth.mdx deleted file mode 100644 index 9ab79a09db..0000000000 --- a/src/content/reference/en/p5 copy/displayWidth.mdx +++ /dev/null @@ -1,47 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L590 -title: displayWidth -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

A Number variable that stores the width of the screen - display.

- -

displayWidth is useful for running full-screen programs. Its - value - - depends on the current pixelDensity().

- -

Note: The actual screen width can be computed as - - displayWidth * pixelDensity().

-line: 590 -isConstructor: false -itemtype: property -alt: This example does not render anything. -example: - - |- - -
- - function setup() { - // Set the canvas' width and height - // using the display's dimensions. - createCanvas(displayWidth, displayHeight); - - background(200); - - describe('A gray canvas that is the same size as the display.'); - } - -
-class: p5 -type: Number ---- - - -# displayWidth diff --git a/src/content/reference/en/p5 copy/dist.mdx b/src/content/reference/en/p5 copy/dist.mdx deleted file mode 100644 index 60b7155b9b..0000000000 --- a/src/content/reference/en/p5 copy/dist.mdx +++ /dev/null @@ -1,121 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L155 -title: dist -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Calculates the distance between two points.

- -

The version of dist() with four parameters calculates distance - in two - - dimensions.

- -

The version of dist() with six parameters calculates distance - in three - - dimensions.

- -

Use p5.Vector.dist() to calculate - the - - distance between two p5.Vector - objects.

-line: 155 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Set the coordinates. - let x1 = 10; - let y1 = 50; - let x2 = 90; - let y2 = 50; - - // Draw the points and a line connecting them. - line(x1, y1, x2, y2); - strokeWeight(5); - point(x1, y1); - point(x2, y2); - - // Calculate the distance. - let d = dist(x1, y1, x2, y2); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the distance. - text(d, 43, 40); - - describe('Two dots connected by a horizontal line. The number 80 is written above the center of the line.'); - } - -
-class: p5 -return: - description: distance between the two points. - type: Number -overloads: - - line: 155 - params: - - name: x1 - description: | -

x-coordinate of the first point.

- type: Number - - name: y1 - description: | -

y-coordinate of the first point.

- type: Number - - name: x2 - description: | -

x-coordinate of the second point.

- type: Number - - name: y2 - description: | -

y-coordinate of the second point.

- type: Number - return: - description: distance between the two points. - type: Number - - line: 209 - params: - - name: x1 - description: '' - type: Number - - name: y1 - description: '' - type: Number - - name: z1 - description: | -

z-coordinate of the first point.

- type: Number - - name: x2 - description: '' - type: Number - - name: y2 - description: '' - type: Number - - name: z2 - description: | -

z-coordinate of the second point.

- type: Number - return: - description: distance between the two points. - type: Number -chainable: false ---- - - -# dist diff --git a/src/content/reference/en/p5 copy/doubleClicked.mdx b/src/content/reference/en/p5 copy/doubleClicked.mdx deleted file mode 100644 index 3e148c677f..0000000000 --- a/src/content/reference/en/p5 copy/doubleClicked.mdx +++ /dev/null @@ -1,157 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1599 -title: doubleClicked -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A function that's called once when a mouse button is clicked twice - quickly.

- -

Declaring the function doubleClicked() sets a code block to - run - - automatically when the user presses and releases the mouse button twice - - quickly:

- -
function doubleClicked() {
-    // Code to run.
-  }
-
-  
- -

The mouse system variables, such as mouseX and - - mouseY, will be updated with their most - recent - - value when doubleClicked() is called by p5.js:

- -
function doubleClicked() {
-    if (mouseX < 50) {
-      // Code to run if the mouse is on the left.
-    }
-
-    if (mouseY > 50) {
-      // Code to run if the mouse is near the bottom.
-    }
-  }
-
-  
- -

The parameter, event, is optional. - doubleClicked() is always passed a - - MouseEvent - - object with properties that describe the double-click event:

- -
function doubleClicked(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

On touchscreen devices, code placed in doubleClicked() will - run after two - - touches that occur within a short time.

- -

Browsers may have default behaviors attached to various mouse events. For - - example, some browsers highlight text when the user moves the mouse while - - pressing a mouse button. To prevent any default behavior for this event, - - add return false; to the end of the function.

-line: 1599 -isConstructor: false -itemtype: method -example: - - |- - -
- - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square changes color when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Toggle the square's color when the user double-clicks. - function doubleClicked() { - if (value === 0) { - value = 255; - } else { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
- -
- - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black circle at its center. When the user double-clicks on the circle, it changes color to white.' - ); - } - - function draw() { - background(200); - - // Style the circle. - fill(value); - - // Draw the circle. - circle(50, 50, 80); - } - - // Reassign value to 255 when the user double-clicks on the circle. - function doubleClicked() { - if (dist(50, 50, mouseX, mouseY) < 40) { - value = 255; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
-class: p5 -params: - - name: event - description: | -

optional MouseEvent argument.

- type: MouseEvent - optional: true -chainable: false ---- - - -# doubleClicked diff --git a/src/content/reference/en/p5 copy/draw.mdx b/src/content/reference/en/p5 copy/draw.mdx deleted file mode 100644 index dba2e2b44a..0000000000 --- a/src/content/reference/en/p5 copy/draw.mdx +++ /dev/null @@ -1,129 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L176 -title: draw -module: Structure -submodule: Structure -file: src/core/main.js -description: > -

A function that's called repeatedly while the sketch runs.

- -

Declaring the function draw() sets a code block to run - repeatedly - - once the sketch starts. It’s used to create animations and respond to - - user inputs:

- -
function draw() {
-    // Code to run repeatedly.
-  }
-
-  
- -

This is often called the "draw loop" because p5.js calls the code in - - draw() in a loop behind the scenes. By default, - draw() tries to run - - 60 times per second. The actual rate depends on many factors. The - - drawing rate, called the "frame rate", can be controlled by calling - - frameRate(). The number of times - draw() - - has run is stored in the system variable - - frameCount().

- -

Code placed within draw() begins looping after - - setup() runs. draw() will run - until the user - - closes the sketch. draw() can be stopped by calling the - - noLoop() function. draw() can - be resumed by - - calling the loop() function.

-line: 176 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Paint the background once. - background(200); - - describe( - 'A white circle on a gray background. The circle follows the mouse as the user moves, leaving a trail.' - ); - } - - function draw() { - // Draw circles repeatedly. - circle(mouseX, mouseY, 40); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A white circle on a gray background. The circle follows the mouse as the user moves.' - ); - } - - function draw() { - // Paint the background repeatedly. - background(200); - - // Draw circles repeatedly. - circle(mouseX, mouseY, 40); - } - -
- -
- - // Double-click the canvas to change the circle's color. - - function setup() { - createCanvas(100, 100); - - describe( - 'A white circle on a gray background. The circle follows the mouse as the user moves. The circle changes color to pink when the user double-clicks.' - ); - } - - function draw() { - // Paint the background repeatedly. - background(200); - - // Draw circles repeatedly. - circle(mouseX, mouseY, 40); - } - - // Change the fill color when the user double-clicks. - function doubleClicked() { - fill('deeppink'); - } - -
-class: p5 -chainable: false ---- - - -# draw diff --git a/src/content/reference/en/p5 copy/drawingContext.mdx b/src/content/reference/en/p5 copy/drawingContext.mdx deleted file mode 100644 index 3cf1335733..0000000000 --- a/src/content/reference/en/p5 copy/drawingContext.mdx +++ /dev/null @@ -1,78 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L1198 -title: drawingContext -module: Rendering -submodule: Rendering -file: src/core/rendering.js -description: > -

A system variable that provides direct access to the sketch's - - element.

- -

The element provides many specialized features that - aren't - - included in the p5.js library. The drawingContext system variable - - provides access to these features by exposing the sketch's - - CanvasRenderingContext2D - - object.

-line: 1198 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(180); - - // Style the circle using shadows. - drawingContext.shadowOffsetX = 5; - drawingContext.shadowOffsetY = -5; - drawingContext.shadowBlur = 10; - drawingContext.shadowColor = 'black'; - - // Draw the circle. - circle(50, 50, 40); - - describe("A white circle on a gray background. The circle's edges are shadowy."); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background('skyblue'); - - // Style the circle using a color gradient. - let myGradient = drawingContext.createRadialGradient(50, 50, 3, 50, 50, 40); - myGradient.addColorStop(0, 'yellow'); - myGradient.addColorStop(0.6, 'orangered'); - myGradient.addColorStop(1, 'yellow'); - drawingContext.fillStyle = myGradient; - drawingContext.strokeStyle = 'rgba(0, 0, 0, 0)'; - - // Draw the circle. - circle(50, 50, 40); - - describe('A fiery sun drawn on a light blue background.'); - } - -
-class: p5 ---- - - -# drawingContext diff --git a/src/content/reference/en/p5 copy/ellipse.mdx b/src/content/reference/en/p5 copy/ellipse.mdx deleted file mode 100644 index 6c07765230..0000000000 --- a/src/content/reference/en/p5 copy/ellipse.mdx +++ /dev/null @@ -1,164 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L371 -title: ellipse -module: Shape -submodule: 2D Primitives -file: src/core/shape/2d_primitives.js -description: > -

Draws an ellipse (oval).

- -

An ellipse is a round shape defined by the x, y, - w, and - - h parameters. x and y set the location - of its center. w and - - h set its width and height. See - - ellipseMode() for other ways to set - - its position.

- -

If no height is set, the value of width is used for both the width and - - height. If a negative height or width is specified, the absolute value is - - taken.

- -

The fifth parameter, detail, is also optional. It determines - how many - - vertices are used to draw the ellipse in WebGL mode. The default value is - - 25.

-line: 371 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - ellipse(50, 50, 80, 80); - - describe('A white circle on a gray canvas.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - ellipse(50, 50, 80); - - describe('A white circle on a gray canvas.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - ellipse(50, 50, 80, 40); - - describe('A white ellipse on a gray canvas.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - ellipse(0, 0, 80, 40); - - describe('A white ellipse on a gray canvas.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - // Use 6 vertices. - ellipse(0, 0, 80, 40, 6); - - describe('A white hexagon on a gray canvas.'); - } - -
-class: p5 -overloads: - - line: 371 - params: - - name: x - description: | -

x-coordinate of the center of the ellipse.

- type: Number - - name: 'y' - description: | -

y-coordinate of the center of the ellipse.

- type: Number - - name: w - description: | -

width of the ellipse.

- type: Number - - name: h - description: | -

height of the ellipse.

- type: Number - optional: true - chainable: 1 - - line: 472 - params: - - name: x - description: '' - type: Number - - name: 'y' - description: '' - type: Number - - name: w - description: '' - type: Number - - name: h - description: '' - type: Number - - name: detail - description: | -

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.

- type: Integer - optional: true -chainable: true ---- - - -# ellipse diff --git a/src/content/reference/en/p5 copy/ellipseMode.mdx b/src/content/reference/en/p5 copy/ellipseMode.mdx deleted file mode 100644 index 0826de63f4..0000000000 --- a/src/content/reference/en/p5 copy/ellipseMode.mdx +++ /dev/null @@ -1,113 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L12 -title: ellipseMode -module: Shape -submodule: Attributes -file: src/core/shape/attributes.js -description: > -

Changes where ellipses, circles, and arcs are drawn.

- -

By default, the first two parameters of - - ellipse(), circle(), - - and arc() - - are the x- and y-coordinates of the shape's center. The next parameters set - - the shape's width and height. This is the same as calling - - ellipseMode(CENTER).

- -

ellipseMode(RADIUS) also uses the first two parameters to set - the x- and - - y-coordinates of the shape's center. The next parameters are half of the - - shapes's width and height. Calling ellipse(0, 0, 10, 15) draws a - shape - - with a width of 20 and height of 30.

- -

ellipseMode(CORNER) uses the first two parameters as the - upper-left - - corner of the shape. The next parameters are its width and height.

- -

ellipseMode(CORNERS) uses the first two parameters as the - location of one - - corner of the ellipse's bounding box. The next parameters are the location - - of the opposite corner.

- -

The argument passed to ellipseMode() must be written in ALL - CAPS because - - the constants CENTER, RADIUS, CORNER, - and CORNERS are defined this - - way. JavaScript is a case-sensitive language.

-line: 12 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // White ellipse. - ellipseMode(RADIUS); - fill(255); - ellipse(50, 50, 30, 30); - - // Gray ellipse. - ellipseMode(CENTER); - fill(100); - ellipse(50, 50, 30, 30); - - describe('A white circle with a gray circle at its center. Both circles have black outlines.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // White ellipse. - ellipseMode(CORNER); - fill(255); - ellipse(25, 25, 50, 50); - - // Gray ellipse. - ellipseMode(CORNERS); - fill(100); - ellipse(25, 25, 50, 50); - - describe('A white circle with a gray circle at its top-left corner. Both circles have black outlines.'); - } - -
-class: p5 -params: - - name: mode - description: | -

either CENTER, RADIUS, CORNER, or CORNERS

- type: Constant -chainable: true ---- - - -# ellipseMode diff --git a/src/content/reference/en/p5 copy/ellipsoid.mdx b/src/content/reference/en/p5 copy/ellipsoid.mdx deleted file mode 100644 index 56d86709b7..0000000000 --- a/src/content/reference/en/p5 copy/ellipsoid.mdx +++ /dev/null @@ -1,233 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L1965 -title: ellipsoid -module: Shape -submodule: 3D Primitives -file: src/webgl/3d_primitives.js -description: > -

Draws an ellipsoid.

- -

An ellipsoid is a 3D shape with triangular faces that connect to form a - - round surface. Ellipsoids with few faces look like crystals. Ellipsoids - - with many faces have smooth surfaces and look like eggs. - ellipsoid() - - defines a shape by its radii. This is different from - - ellipse() which uses diameters - - (width and height).

- -

The first parameter, radiusX, is optional. If a - Number is passed, as in - - ellipsoid(20), it sets the radius of the ellipsoid along the - x-axis. By - - default, radiusX is 50.

- -

The second parameter, radiusY, is also optional. If a - Number is passed, - - as in ellipsoid(20, 30), it sets the ellipsoid’s radius along the - y-axis. - - By default, radiusY is set to the ellipsoid’s - radiusX.

- -

The third parameter, radiusZ, is also optional. If a - Number is passed, - - as in ellipsoid(20, 30, 40), it sets the ellipsoid’s radius along - the - - z-axis. By default, radiusZ is set to the ellipsoid’s - radiusY.

- -

The fourth parameter, detailX, is also optional. If a - Number is passed, - - as in ellipsoid(20, 30, 40, 5), it sets the number of triangle - - subdivisions to use along the x-axis. All 3D shapes are made by connecting - - triangles to form their surfaces. By default, detailX is 24.

- -

The fifth parameter, detailY, is also optional. If a - Number is passed, - - as in ellipsoid(20, 30, 40, 5, 7), it sets the number of triangle - - subdivisions to use along the y-axis. All 3D shapes are made by connecting - - triangles to form their surfaces. By default, detailY is 16.

- -

Note: ellipsoid() can only be used in WebGL mode.

-line: 1965 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white sphere on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the ellipsoid. - // Set its radiusX to 30. - ellipsoid(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white ellipsoid on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the ellipsoid. - // Set its radiusX to 30. - // Set its radiusY to 40. - ellipsoid(30, 40); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white ellipsoid on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the ellipsoid. - // Set its radiusX to 30. - // Set its radiusY to 40. - // Set its radiusZ to 50. - ellipsoid(30, 40, 50); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white ellipsoid on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the ellipsoid. - // Set its radiusX to 30. - // Set its radiusY to 40. - // Set its radiusZ to 50. - // Set its detailX to 4. - ellipsoid(30, 40, 50, 4); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white ellipsoid on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the ellipsoid. - // Set its radiusX to 30. - // Set its radiusY to 40. - // Set its radiusZ to 50. - // Set its detailX to 4. - // Set its detailY to 3. - ellipsoid(30, 40, 50, 4, 3); - } - -
-class: p5 -params: - - name: radiusX - description: | -

radius of the ellipsoid along the x-axis. Defaults to 50.

- type: Number - optional: true - - name: radiusY - description: > -

radius of the ellipsoid along the y-axis. Defaults to - radiusX.

- type: Number - optional: true - - name: radiusZ - description: > -

radius of the ellipsoid along the z-axis. Defaults to - radiusY.

- type: Number - optional: true - - name: detailX - description: | -

number of triangle subdivisions along the x-axis. Defaults to 24.

- type: Integer - optional: true - - name: detailY - description: | -

number of triangle subdivisions along the y-axis. Defaults to 16.

- type: Integer - optional: true -chainable: true ---- - - -# ellipsoid diff --git a/src/content/reference/en/p5 copy/emissiveMaterial.mdx b/src/content/reference/en/p5 copy/emissiveMaterial.mdx deleted file mode 100644 index 10037c3c86..0000000000 --- a/src/content/reference/en/p5 copy/emissiveMaterial.mdx +++ /dev/null @@ -1,140 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2647 -title: emissiveMaterial -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Sets the emissive color of shapes’ surface material.

- -

The emissiveMaterial() color sets a color shapes display at - full - - strength, regardless of lighting. This can give the appearance that a shape - - is glowing. However, emissive materials don’t actually emit light that - - can affect surrounding objects.

- -

emissiveMaterial() can be called three ways with different - parameters to - - set the material’s color.

- -

The first way to call emissiveMaterial() has one parameter, - gray. - - Grayscale values between 0 and 255, as in emissiveMaterial(50), - can be - - passed to set the material’s color. Higher grayscale values make shapes - - appear brighter.

- -

The second way to call emissiveMaterial() has one parameter, - color. A - - p5.Color object, an array of color - values, or a - - CSS color string, as in emissiveMaterial('magenta'), can be - passed to set - - the material’s color.

- -

The third way to call emissiveMaterial() has four parameters, - v1, v2, - - v3, and alpha. alpha is optional. RGBA, - HSBA, or HSLA values can be - - passed to set the material’s colors, as in emissiveMaterial(255, 0, - 0) or - - emissiveMaterial(255, 0, 0, 30). Color values will be interpreted - using - - the current colorMode().

- -

Note: emissiveMaterial() can only be used in WebGL mode.

-line: 2647 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A red cube drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on a white ambient light. - ambientLight(255, 255, 255); - - // Add a red emissive material using RGB values. - emissiveMaterial(255, 0, 0); - - // Draw the box. - box(); - } - -
-class: p5 -overloads: - - line: 2647 - params: - - name: v1 - description: | -

red or hue value in the current - colorMode().

- type: Number - - name: v2 - description: | -

green or saturation value in the - current colorMode().

- type: Number - - name: v3 - description: | -

blue, brightness, or lightness value in the - current colorMode().

- type: Number - - name: alpha - description: | -

alpha value in the current - colorMode().

- type: Number - optional: true - chainable: 1 - - line: 2717 - params: - - name: gray - description: | -

grayscale value between 0 (black) and 255 (white).

- type: Number - chainable: 1 - - line: 2723 - params: - - name: color - description: | -

color as a p5.Color object, - an array of color values, or a CSS string.

- type: 'p5.Color|Number[]|String' - chainable: 1 -chainable: true ---- - - -# emissiveMaterial diff --git a/src/content/reference/en/p5 copy/endClip.mdx b/src/content/reference/en/p5 copy/endClip.mdx deleted file mode 100644 index 69bf243858..0000000000 --- a/src/content/reference/en/p5 copy/endClip.mdx +++ /dev/null @@ -1,43 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L190 -title: endClip -module: Color -submodule: Setting -file: src/color/setting.js -description: | -

Ends defining a mask that was started with - beginClip().

-line: 190 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a mask. - beginClip(); - triangle(15, 37, 30, 13, 43, 37); - circle(45, 45, 7); - endClip(); - - // Draw a backing shape. - square(5, 5, 45); - - describe('A white triangle and circle on a gray background.'); - } - -
-class: p5 -chainable: false ---- - - -# endClip diff --git a/src/content/reference/en/p5 copy/endContour.mdx b/src/content/reference/en/p5 copy/endContour.mdx deleted file mode 100644 index 5965b72db8..0000000000 --- a/src/content/reference/en/p5 copy/endContour.mdx +++ /dev/null @@ -1,133 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L1224 -title: endContour -module: Shape -submodule: Vertex -file: src/core/shape/vertex.js -description: > -

Stops creating a hole within a flat shape.

- -

The beginContour() and - endContour() - - functions allow for creating negative space within custom shapes that are - - flat. beginContour() begins adding - vertices - - to a negative space and endContour() stops adding them. - - beginContour() and - endContour() must be - - called between beginShape() and - - endShape().

- -

Transformations such as translate(), - - rotate(), and scale() - - don't work between beginContour() - and - - endContour(). It's also not possible to use other shapes, such as - - ellipse() or rect(), - - between beginContour() and - endContour().

- -

Note: The vertices that define a negative space must "wind" in the opposite - - direction from the outer shape. First, draw vertices for the outer shape - - clockwise order. Then, draw vertices for the negative space in - - counter-clockwise order.

-line: 1224 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - beginShape(); - - // Exterior vertices, clockwise winding. - vertex(10, 10); - vertex(90, 10); - vertex(90, 90); - vertex(10, 90); - - // Interior vertices, counter-clockwise winding. - beginContour(); - vertex(30, 30); - vertex(30, 70); - vertex(70, 70); - vertex(70, 30); - endContour(); - - // Stop drawing the shape. - endShape(CLOSE); - - describe('A white square with a square hole in its center drawn on a gray background.'); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white square with a square hole in its center drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Start drawing the shape. - beginShape(); - - // Exterior vertices, clockwise winding. - vertex(-40, -40); - vertex(40, -40); - vertex(40, 40); - vertex(-40, 40); - - // Interior vertices, counter-clockwise winding. - beginContour(); - vertex(-20, -20); - vertex(-20, 20); - vertex(20, 20); - vertex(20, -20); - endContour(); - - // Stop drawing the shape. - endShape(CLOSE); - } - -
-class: p5 -chainable: true ---- - - -# endContour diff --git a/src/content/reference/en/p5 copy/endGeometry.mdx b/src/content/reference/en/p5 copy/endGeometry.mdx deleted file mode 100644 index bfbeb81c7b..0000000000 --- a/src/content/reference/en/p5 copy/endGeometry.mdx +++ /dev/null @@ -1,285 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L266 -title: endGeometry -module: Shape -submodule: 3D Primitives -file: src/webgl/3d_primitives.js -description: > -

Stops adding shapes to a new - - p5.Geometry object and returns the - object.

- -

The beginGeometry() and endGeometry() - - functions help with creating complex 3D shapes from simpler ones such as - - sphere(). beginGeometry() - begins adding shapes - - to a custom p5.Geometry object and - - endGeometry() stops adding them.

- -

beginGeometry() and endGeometry() can help - - to make sketches more performant. For example, if a complex 3D shape - - doesn’t change while a sketch runs, then it can be created with - - beginGeometry() and endGeometry(). - - Creating a p5.Geometry object once and - then - - drawing it will run faster than repeatedly drawing the individual pieces.

- -

See buildGeometry() for another - way to - - build 3D shapes.

- -

Note: endGeometry() can only be used in WebGL mode.

-line: 266 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Start building the p5.Geometry object. - beginGeometry(); - - // Add a cone. - cone(); - - // Stop building the p5.Geometry object. - shape = endGeometry(); - - describe('A white cone drawn on a gray background.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the p5.Geometry object. - noStroke(); - - // Draw the p5.Geometry object. - model(shape); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the p5.Geometry object. - createArrow(); - - describe('A white arrow drawn on a gray background.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the p5.Geometry object. - noStroke(); - - // Draw the p5.Geometry object. - model(shape); - } - - function createArrow() { - // Start building the p5.Geometry object. - beginGeometry(); - - // Add shapes. - push(); - rotateX(PI); - cone(10); - translate(0, -10, 0); - cylinder(3, 20); - pop(); - - // Stop building the p5.Geometry object. - shape = endGeometry(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let blueArrow; - let redArrow; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the arrows. - redArrow = createArrow('red'); - blueArrow = createArrow('blue'); - - describe('A red arrow and a blue arrow drawn on a gray background. The blue arrow rotates slowly.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the arrows. - noStroke(); - - // Draw the red arrow. - model(redArrow); - - // Translate and rotate the coordinate system. - translate(30, 0, 0); - rotateZ(frameCount * 0.01); - - // Draw the blue arrow. - model(blueArrow); - } - - function createArrow(fillColor) { - // Start building the p5.Geometry object. - beginGeometry(); - - fill(fillColor); - - // Add shapes to the p5.Geometry object. - push(); - rotateX(PI); - cone(10); - translate(0, -10, 0); - cylinder(3, 20); - pop(); - - // Stop building the p5.Geometry object. - let shape = endGeometry(); - - return shape; - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let button; - let particles; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a button to reset the particle system. - button = createButton('Reset'); - - // Call resetModel() when the user presses the button. - button.mousePressed(resetModel); - - // Add the original set of particles. - resetModel(); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the particles. - noStroke(); - - // Draw the particles. - model(particles); - } - - function resetModel() { - // If the p5.Geometry object has already been created, - // free those resources. - if (particles) { - freeGeometry(particles); - } - - // Create a new p5.Geometry object with random spheres. - particles = createParticles(); - } - - function createParticles() { - // Start building the p5.Geometry object. - beginGeometry(); - - // Add shapes. - for (let i = 0; i < 60; i += 1) { - // Calculate random coordinates. - let x = randomGaussian(0, 20); - let y = randomGaussian(0, 20); - let z = randomGaussian(0, 20); - - push(); - // Translate to the particle's coordinates. - translate(x, y, z); - // Draw the particle. - sphere(5); - pop(); - } - - // Stop building the p5.Geometry object. - let shape = endGeometry(); - - return shape; - } - -
-class: p5 -return: - description: new 3D shape. - type: p5.Geometry -chainable: false ---- - - -# endGeometry diff --git a/src/content/reference/en/p5 copy/endShape.mdx b/src/content/reference/en/p5 copy/endShape.mdx deleted file mode 100644 index 198b6d7497..0000000000 --- a/src/content/reference/en/p5 copy/endShape.mdx +++ /dev/null @@ -1,256 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L1344 -title: endShape -module: Shape -submodule: Vertex -file: src/core/shape/vertex.js -description: > -

Stops adding vertices to a custom shape.

- -

The beginShape() and - endShape() functions - - allow for creating custom shapes in 2D or 3D. - - beginShape() begins adding vertices to - a - - custom shape and endShape() stops adding them.

- -

The first parameter, mode, is optional. By default, the first - and last - - vertices of a shape aren't connected. If the constant CLOSE is - passed, as - - in endShape(CLOSE), then the first and last vertices will be - connected.

- -

The second parameter, count, is also optional. In WebGL mode, - it’s more - - efficient to draw many copies of the same shape using a technique called - - instancing. - - The count parameter tells WebGL mode how many copies to draw. For - - example, calling endShape(CLOSE, 400) after drawing a custom - shape will - - make it efficient to draw 400 copies. This feature requires - - writing - a custom shader.

- -

After calling beginShape(), shapes - can be - - built by calling vertex(), - - bezierVertex(), - - quadraticVertex(), and/or - - curveVertex(). Calling - - endShape() will stop adding vertices to the - - shape. Each shape will be outlined with the current stroke color and filled - - with the current fill color.

- -

Transformations such as translate(), - - rotate(), and - - scale() don't work between - - beginShape() and - endShape(). It's also not - - possible to use other shapes, such as ellipse() or - - rect(), between - - beginShape() and - endShape().

-line: 1344 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the shapes. - noFill(); - - // Left triangle. - beginShape(); - vertex(20, 20); - vertex(45, 20); - vertex(45, 80); - endShape(CLOSE); - - // Right triangle. - beginShape(); - vertex(50, 20); - vertex(75, 20); - vertex(75, 80); - endShape(); - - describe( - 'Two sets of black lines drawn on a gray background. The three lines on the left form a right triangle. The two lines on the right form a right angle.' - ); - } - -
- -
- - function setup() { - createCanvas(200, 100); - - background(240); - - noFill(); - stroke(0); - - // Open shape (left) - beginShape(); - vertex(20, 20); - vertex(80, 20); - vertex(80, 80); - endShape(); // Not closed - - // Closed shape (right) - beginShape(); - vertex(120, 20); - vertex(180, 20); - vertex(180, 80); - endShape(CLOSE); // Closed - - describe( - 'Two right-angled shapes on a light gray background. The left shape is open with three lines. The right shape is closed, forming a triangle.' - ); - } - -
- -
- - // Note: A "uniform" is a global variable within a shader program. - - // Create a string with the vertex shader program. - // The vertex shader is called for each vertex. - let vertSrc = `#version 300 es - - precision mediump float; - - in vec3 aPosition; - flat out int instanceID; - - uniform mat4 uModelViewMatrix; - uniform mat4 uProjectionMatrix; - - void main() { - - // Copy the instance ID to the fragment shader. - instanceID = gl_InstanceID; - vec4 positionVec4 = vec4(aPosition, 1.0); - - // gl_InstanceID represents a numeric value for each instance. - // Using gl_InstanceID allows us to move each instance separately. - // Here we move each instance horizontally by ID * 23. - float xOffset = float(gl_InstanceID) * 23.0; - - // Apply the offset to the final position. - gl_Position = uProjectionMatrix * uModelViewMatrix * (positionVec4 - - vec4(xOffset, 0.0, 0.0, 0.0)); - } - `; - - // Create a string with the fragment shader program. - // The fragment shader is called for each pixel. - let fragSrc = `#version 300 es - - precision mediump float; - - out vec4 outColor; - flat in int instanceID; - uniform float numInstances; - - void main() { - vec4 red = vec4(1.0, 0.0, 0.0, 1.0); - vec4 blue = vec4(0.0, 0.0, 1.0, 1.0); - - // Normalize the instance ID. - float normId = float(instanceID) / numInstances; - - // Mix between two colors using the normalized instance ID. - outColor = mix(red, blue, normId); - } - `; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Shader object. - let myShader = createShader(vertSrc, fragSrc); - - background(220); - - // Compile and apply the p5.Shader. - shader(myShader); - - // Set the numInstances uniform. - myShader.setUniform('numInstances', 4); - - // Translate the origin to help align the drawing. - translate(25, -10); - - // Style the shapes. - noStroke(); - - // Draw the shapes. - beginShape(); - vertex(0, 0); - vertex(0, 20); - vertex(20, 20); - vertex(20, 0); - vertex(0, 0); - endShape(CLOSE, 4); - - describe('A row of four squares. Their colors transition from purple on the left to red on the right'); - } - -
-class: p5 -params: - - name: mode - description: | -

use CLOSE to close the shape

- type: Constant - optional: true - - name: count - description: > -

number of times you want to draw/instance the shape (for WebGL - mode).

- type: Integer - optional: true -chainable: true ---- - - -# endShape diff --git a/src/content/reference/en/p5 copy/erase.mdx b/src/content/reference/en/p5 copy/erase.mdx deleted file mode 100644 index 24f1397e8e..0000000000 --- a/src/content/reference/en/p5 copy/erase.mdx +++ /dev/null @@ -1,123 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1629 -title: erase -module: Color -submodule: Setting -file: src/color/setting.js -description: > -

Starts using shapes to erase parts of the canvas.

- -

All drawing that follows erase() will subtract from the - canvas, revealing - - the web page underneath. The erased areas will become transparent, allowing - - the content behind the canvas to show through. The - - fill(), stroke(), and - - blendMode() have no effect once - erase() is - - called.

- -

The erase() function has two optional parameters. The first - parameter - - sets the strength of erasing by the shape's interior. A value of 0 means - - that no erasing will occur. A value of 255 means that the shape's interior - - will fully erase the content underneath. The default value is 255 - - (full strength).

- -

The second parameter sets the strength of erasing by the shape's edge. A - - value of 0 means that no erasing will occur. A value of 255 means that the - - shape's edge will fully erase the content underneath. The default value is - - 255 (full strength).

- -

To cancel the erasing effect, use the noErase() - - function.

- -

erase() has no effect on drawing done with the - - image() and - - background() functions.

-line: 1629 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(100, 100, 250); - - // Draw a pink square. - fill(250, 100, 100); - square(20, 20, 60); - - // Erase a circular area. - erase(); - circle(25, 30, 30); - noErase(); - - describe('A purple canvas with a pink square in the middle. A circle is erased from the top-left, leaving a hole.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(100, 100, 250); - - // Draw a pink square. - fill(250, 100, 100); - square(20, 20, 60); - - // Erase a circular area. - strokeWeight(5); - erase(150, 255); - circle(25, 30, 30); - noErase(); - - describe('A purple canvas with a pink square in the middle. A circle at the top-left partially erases its interior and a fully erases its outline.'); - } - -
-class: p5 -params: - - name: strengthFill - description: | -

a number (0-255) for the strength of erasing under a shape's interior. - Defaults to 255, which is full strength.

- type: Number - optional: true - - name: strengthStroke - description: | -

a number (0-255) for the strength of erasing under a shape's edge. - Defaults to 255, which is full strength.

- type: Number - optional: true -chainable: true ---- - - -# erase diff --git a/src/content/reference/en/p5 copy/exitPointerLock.mdx b/src/content/reference/en/p5 copy/exitPointerLock.mdx deleted file mode 100644 index db8a989422..0000000000 --- a/src/content/reference/en/p5 copy/exitPointerLock.mdx +++ /dev/null @@ -1,82 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1946 -title: exitPointerLock -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

Exits a pointer lock started with - - requestPointerLock.

- -

Calling requestPointerLock() locks the values of - - mouseX, mouseY, - - pmouseX, and pmouseY. - - Calling exitPointerLock() resumes updating the mouse system - variables.

- -

Note: Most browsers require an input, such as a click, before calling - - requestPointerLock(). It’s recommended to call - requestPointerLock() in - - an event function such as doubleClicked().

-line: 1946 -isConstructor: false -itemtype: method -example: - - |- - -
- - let isLocked = false; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a word at its center. The word changes between "Unlocked" and "Locked" when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Tell the user whether the pointer is locked. - if (isLocked === true) { - text('Locked', 50, 50); - } else { - text('Unlocked', 50, 50); - } - } - - // Toggle the pointer lock when the user double-clicks. - function doubleClicked() { - if (isLocked === true) { - exitPointerLock(); - isLocked = false; - } else { - requestPointerLock(); - isLocked = true; - } - } - -
-class: p5 -chainable: false ---- - - -# exitPointerLock diff --git a/src/content/reference/en/p5 copy/exp.mdx b/src/content/reference/en/p5 copy/exp.mdx deleted file mode 100644 index e75a420dab..0000000000 --- a/src/content/reference/en/p5 copy/exp.mdx +++ /dev/null @@ -1,83 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L230 -title: exp -module: Math -submodule: Calculation -file: src/math/calculation.js -description: | -

Calculates the value of Euler's number e (2.71828...) raised to the power - of a number.

-line: 230 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Top-left. - let d = exp(1); - circle(10, 10, d); - - // Left-center. - d = exp(2); - circle(20, 20, d); - - // Right-center. - d = exp(3); - circle(40, 40, d); - - // Bottom-right. - d = exp(4); - circle(80, 80, d); - - describe('A series of circles that grow exponentially from top left to bottom right.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - describe('A series of black dots that grow exponentially from left to right.'); - } - - function draw() { - // Invert the y-axis. - scale(1, -1); - translate(0, -100); - - // Calculate the coordinates. - let x = frameCount; - let y = 0.005 * exp(x * 0.1); - - // Draw a point. - point(x, y); - } - -
-class: p5 -params: - - name: 'n' - description: | -

exponent to raise.

- type: Number -return: - description: e^n - type: Number -chainable: false ---- - - -# exp diff --git a/src/content/reference/en/p5 copy/fill.mdx b/src/content/reference/en/p5 copy/fill.mdx deleted file mode 100644 index 84f074abd4..0000000000 --- a/src/content/reference/en/p5 copy/fill.mdx +++ /dev/null @@ -1,312 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1000 -title: fill -module: Color -submodule: Setting -file: src/color/setting.js -description: > -

Sets the color used to fill shapes.

- -

Calling fill(255, 165, 0) or fill('orange') means - all shapes drawn - - after the fill command will be filled with the color orange.

- -

The version of fill() with one parameter interprets the value - one of - - three ways. If the parameter is a Number, it's interpreted as a - grayscale - - value. If the parameter is a String, it's interpreted as a CSS - color - - string. A p5.Color object can also be - provided to - - set the fill color.

- -

The version of fill() with three parameters interprets them as - RGB, HSB, - - or HSL colors, depending on the current - - colorMode(). The default color space is - RGB, - - with each value in the range from 0 to 255.

- -

The version of fill() with four parameters interprets them as - RGBA, HSBA, - - or HSLA colors, depending on the current colorMode(). The last parameter - - sets the alpha (transparency) value.

-line: 1000 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // A grayscale value. - fill(51); - square(20, 20, 60); - - describe('A dark charcoal gray square with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // R, G & B values. - fill(255, 204, 0); - square(20, 20, 60); - - describe('A yellow square with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // R, G, B, and Alpha values. - fill(255, 0, 0, 128); - square(20, 20, 60); - - describe('A semi-transparent red square with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(100); - - // Use HSB color. - colorMode(HSB); - - // H, S & B values. - fill(255, 204, 100); - square(20, 20, 60); - - describe('A royal blue square with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // A CSS named color. - fill('red'); - square(20, 20, 60); - - describe('A red square with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Three-digit hex RGB notation. - fill('#fae'); - square(20, 20, 60); - - describe('A pink square with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Six-digit hex RGB notation. - fill('#A251FA'); - square(20, 20, 60); - - describe('A purple square with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Integer RGB notation. - fill('rgb(0, 255, 0)'); - square(20, 20, 60); - - describe('A bright green square with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Integer RGBA notation. - fill('rgba(0, 255, 0, 0.25)'); - square(20, 20, 60); - - describe('A soft green rectange with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Percentage RGB notation. - fill('rgb(100%, 0%, 10%)'); - square(20, 20, 60); - - describe('A red square with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Percentage RGBA notation. - fill('rgba(100%, 0%, 100%, 0.5)'); - square(20, 20, 60); - - describe('A dark fuchsia square with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // A p5.Color object. - let c = color(0, 0, 255); - fill(c); - square(20, 20, 60); - - describe('A blue square with a black outline.'); - } - -
-class: p5 -overloads: - - line: 1000 - params: - - name: v1 - description: > -

red value if color mode is RGB or hue value if color mode is - HSB.

- type: Number - - name: v2 - description: > -

green value if color mode is RGB or saturation value if color mode - is HSB.

- type: Number - - name: v3 - description: > -

blue value if color mode is RGB or brightness value if color mode - is HSB.

- type: Number - - name: alpha - description: > -

alpha value, controls transparency (0 - transparent, 255 - - opaque).

- type: Number - optional: true - chainable: 1 - - line: 1225 - params: - - name: value - description: | -

a color string.

- type: String - chainable: 1 - - line: 1231 - params: - - name: gray - description: | -

a grayscale value.

- type: Number - - name: alpha - description: '' - type: Number - optional: true - chainable: 1 - - line: 1238 - params: - - name: values - description: | -

an array containing the red, green, blue & - and alpha components of the color.

- type: 'Number[]' - chainable: 1 - - line: 1245 - params: - - name: color - description: | -

the fill color.

- type: p5.Color - chainable: 1 -chainable: true ---- - - -# fill diff --git a/src/content/reference/en/p5 copy/filter.mdx b/src/content/reference/en/p5 copy/filter.mdx deleted file mode 100644 index 5496568d48..0000000000 --- a/src/content/reference/en/p5 copy/filter.mdx +++ /dev/null @@ -1,330 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L442 -title: filter -module: Image -submodule: Pixels -file: src/image/pixels.js -description: > -

Applies an image filter to the canvas.

- -

The preset options are:

- -

INVERT - - Inverts the colors in the image. No parameter is used.

- -

GRAY - - Converts the image to grayscale. No parameter is used.

- -

THRESHOLD - - Converts the image to black and white. Pixels with a grayscale value - - above a given threshold are converted to white. The rest are converted to - - black. The threshold must be between 0.0 (black) and 1.0 (white). If no - - value is specified, 0.5 is used.

- -

OPAQUE - - Sets the alpha channel to entirely opaque. No parameter is used.

- -

POSTERIZE - - Limits the number of colors in the image. Each color channel is limited to - - the number of colors specified. Values between 2 and 255 are valid, but - - results are most noticeable with lower values. The default value is 4.

- -

BLUR - - Blurs the image. The level of blurring is specified by a blur radius. Larger - - values increase the blur. The default value is 4. A gaussian blur is used - - in P2D mode. A box blur is used in WEBGL mode.

- -

ERODE - - Reduces the light areas. No parameter is used.

- -

DILATE - - Increases the light areas. No parameter is used.

- -

filter() uses WebGL in the background by default because it's - faster. - - This can be disabled in P2D mode by adding a false - argument, as in - - filter(BLUR, false). This may be useful to keep computation off - the GPU - - or to work around a lack of WebGL support.

- -

In WebgL mode, filter() can also use custom shaders. See - - createFilterShader() for more - - information.

-line: 442 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Apply the INVERT filter. - filter(INVERT); - - describe('A blue brick wall.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Apply the GRAY filter. - filter(GRAY); - - describe('A brick wall drawn in grayscale.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Apply the THRESHOLD filter. - filter(THRESHOLD); - - describe('A brick wall drawn in black and white.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Apply the OPAQUE filter. - filter(OPAQUE); - - describe('A red brick wall.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Apply the POSTERIZE filter. - filter(POSTERIZE, 3); - - describe('An image of a red brick wall drawn with limited color palette.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Apply the BLUR filter. - filter(BLUR, 3); - - describe('A blurry image of a red brick wall.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Apply the DILATE filter. - filter(DILATE); - - describe('A red brick wall with bright lines between each brick.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Apply the ERODE filter. - filter(ERODE); - - describe('A red brick wall with faint lines between each brick.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Apply the BLUR filter. - // Don't use WebGL. - filter(BLUR, 3, false); - - describe('A blurry image of a red brick wall.'); - } - -
-class: p5 -overloads: - - line: 442 - params: - - name: filterType - description: | -

either THRESHOLD, GRAY, OPAQUE, INVERT, - POSTERIZE, BLUR, ERODE, DILATE or BLUR.

- type: Constant - - name: filterParam - description: | -

parameter unique to each filter.

- type: Number - optional: true - - name: useWebGL - description: | -

flag to control whether to use fast - WebGL filters (GPU) or original image - filters (CPU); defaults to true.

- type: Boolean - optional: true - - line: 715 - params: - - name: filterType - description: '' - type: Constant - - name: useWebGL - description: '' - type: Boolean - optional: true - - line: 720 - params: - - name: shaderFilter - description: | -

shader that's been loaded, with the - frag shader using a tex0 uniform.

- type: p5.Shader -chainable: false ---- - - -# filter diff --git a/src/content/reference/en/p5 copy/float.mdx b/src/content/reference/en/p5 copy/float.mdx deleted file mode 100644 index fffd6bfc1b..0000000000 --- a/src/content/reference/en/p5 copy/float.mdx +++ /dev/null @@ -1,116 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L10 -title: float -module: Data -submodule: Conversion -file: src/utilities/conversion.js -description: > -

Converts a String to a floating point (decimal) - Number.

- -

float() converts strings that resemble numbers, such as - '12.34', into - - numbers.

- -

The parameter, str, is the string value to convert. For - example, calling - - float('12.34') returns the number 12.34. If an - array of strings is - - passed, as in float(['12.34', '56.78']), then an array of numbers - will be - - returned.

- -

Note: If a string can't be converted to a number, as in - float('giraffe'), - - then the value NaN (not a number) will be returned.

-line: 10 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let original = '12.3'; - - // Convert the string to a number. - let converted = float(original); - - // Double the converted value. - let twice = converted * 2; - - // Style the text. - textAlign(CENTER, CENTER); - textSize(12); - - // Display the original and converted values. - text(`${original} × 2 = ${twice}`, 50, 50); - - describe('The text "12.3 × 2 = 24.6" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of strings. - let original = ['60', '30', '15']; - - // Convert the strings to numbers. - let diameters = float(original); - - for (let d of diameters) { - // Draw a circle. - circle(50, 50, d); - } - - describe('Three white, concentric circles on a gray background.'); - } - -
-class: p5 -return: - description: converted number. - type: Number -overloads: - - line: 10 - params: - - name: str - description: | -

string to convert.

- type: String - return: - description: converted number. - type: Number - - line: 80 - params: - - name: ns - description: | -

array of strings to convert.

- type: 'String[]' - return: - description: converted numbers. - type: 'Number[]' -chainable: false ---- - - -# float diff --git a/src/content/reference/en/p5 copy/floor.mdx b/src/content/reference/en/p5 copy/floor.mdx deleted file mode 100644 index a9e97965a3..0000000000 --- a/src/content/reference/en/p5 copy/floor.mdx +++ /dev/null @@ -1,57 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L294 -title: floor -module: Math -submodule: Calculation -file: src/math/calculation.js -description: | -

Calculates the closest integer value that is less than or equal to the - value of a number.

-line: 294 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Use RGB color with values from 0 to 1. - colorMode(RGB, 1); - - noStroke(); - - // Draw the left rectangle. - let r = 0.8; - fill(r, 0, 0); - rect(0, 0, 50, 100); - - // Round r down to 0. - r = floor(r); - - // Draw the right rectangle. - fill(r, 0, 0); - rect(50, 0, 50, 100); - - describe('Two rectangles. The one on the left is bright red and the one on the right is black.'); - } - -
-class: p5 -params: - - name: 'n' - description: | -

number to round down.

- type: Number -return: - description: rounded down number. - type: Integer -chainable: false ---- - - -# floor diff --git a/src/content/reference/en/p5 copy/focused.mdx b/src/content/reference/en/p5 copy/focused.mdx deleted file mode 100644 index 1e95f25927..0000000000 --- a/src/content/reference/en/p5 copy/focused.mdx +++ /dev/null @@ -1,50 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L174 -title: focused -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

A Boolean variable that's true if the browser is - focused and false if - - not.

- -

Note: The browser window can only receive input if it's focused.

-line: 174 -isConstructor: false -itemtype: property -example: - - |- - -
- - // Open this example in two separate browser - // windows placed side-by-side to demonstrate. - - function setup() { - createCanvas(100, 100); - - describe('A square changes color from green to red when the browser window is out of focus.'); - } - - function draw() { - // Change the background color - // when the browser window - // goes in/out of focus. - if (focused === true) { - background(0, 255, 0); - } else { - background(255, 0, 0); - } - } - -
-class: p5 -type: Boolean ---- - - -# focused diff --git a/src/content/reference/en/p5 copy/for.mdx b/src/content/reference/en/p5 copy/for.mdx deleted file mode 100644 index dc71d1c2ca..0000000000 --- a/src/content/reference/en/p5 copy/for.mdx +++ /dev/null @@ -1,290 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L1648 -title: for -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: > -

A way to repeat a block of code when the number of iterations is known.

- -

for loops are helpful for repeating statements a certain - number of times. - - For example, a for loop makes it easy to express the idea - - "draw five lines" like so:

- -
for (let x = 10; x < 100; x += 20) {
-    line(x, 25, x, 75);
-  }
-
-  
- -

The loop's header begins with the keyword for. Loops generally - count up - - or count down as they repeat, or iterate. The statements in parentheses - - let x = 10; x < 100; x += 20 tell the loop how it should - repeat:

- -
    - -
  • let x = 10 tells the loop to start counting at - 10 and keep track of iterations using the variable - x.
  • - -
  • x < 100 tells the loop to count up to, but not including, - 100.
  • - -
  • x += 20 tells the loop to count up by 20 at the - end of each iteration.
  • - -
- -

The code between the curly braces {} is the loop's body. - Statements in the - - loop body are repeated during each iteration of the loop.

- -

It's common to create infinite loops accidentally. When this happens, - - sketches may become unresponsive and the web browser may display a warning. - - For example, the following loop never stops iterating because it doesn't - - count up:

- -
for (let x = 10; x < 100; x = 20) {
-    line(x, 25, x, 75);
-  }
-
-  
- -

The statement x = 20 keeps the variable x stuck - at 20, which is - - always less than 100.

- -

for loops can also count down:

- -
for (let d = 100; d > 0; d -= 10) {
-    circle(50, 50, d);
-  }
-
-  
- -

for loops can also contain other loops. The following nested - loop draws a - - grid of points:

- -
// Loop from left to right.
-
-  for (let x = 10; x < 100; x += 10) {
-
-    // Loop from top to bottom.
-    for (let y = 10; y < 100; y += 10) {
-      point(x, y);
-    }
-
-  }
-
-  
- -

for loops are also helpful for iterating through the elements - of an - - array. For example, it's common to iterate through an array that contains - - information about where or what to draw:

- -
// Create an array of x-coordinates.
-
-  let xCoordinates = [20, 40, 60];
-
-
-  for (let i = 0; i < xCoordinates.length; i += 1) {
-    // Update the element.
-    xCoordinates[i] += random(-1, 1);
-
-    // Draw a circle.
-    circle(xCoordinates[i], 50, 20);
-  }
-
-  
- -

If the array's values aren't modified, the for...of statement - can - - simplify the code. They're similar to for loops in Python and - for-each - - loops in C++ and Java. The following loops have the same effect:

- -
// Draw circles with a for loop.
-
-  let xCoordinates = [20, 40, 60];
-
-
-  for (let i = 0; i < xCoordinates.length; i += 1) {
-    circle(xCoordinates[i], 50, 20);
-  }
-
-  
- -
// Draw circles with a for...of statement.
-
-  let xCoordinates = [20, 40, 60];
-
-
-  for (let x of xCoordinates) {
-    circle(x, 50, 20);
-  }
-
-  
- -

In the code snippets above, the variables i and x - have different roles.

- -

In the first snippet, i counts from 0 up to - 2, which is one less than - - xCoordinates.length. i is used to access the element - in xCoordinates - - at index i.

- -

In the second code snippet, x isn't keeping track of the - loop's progress - - or an index. During each iteration, x contains the next element - of - - xCoordinates. x starts from the beginning of - xCoordinates (20) and - - updates its value to 40 and then 60 during the next - iterations.

-line: 1648 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('Five black vertical lines on a gray background.'); - } - - function draw() { - background(200); - - // Draw vertical lines using a loop. - for (let x = 10; x < 100; x += 20) { - line(x, 25, x, 75); - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('Five white concentric circles drawn on a gray background.'); - } - - function draw() { - background(200); - - // Draw concentric circles using a loop. - for (let d = 100; d > 0; d -= 20) { - circle(50, 50, d); - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A grid of black dots on a gray background.'); - } - - function draw() { - background(200); - - // Set the spacing for points on the grid. - let space = 10; - - // Increase the stroke weight. - strokeWeight(3); - - // Loop from the left to the right. - for (let x = space; x < 100; x += space) { - // Loop from the top to the bottom. - for (let y = space; y < 100; y += space) { - point(x, y); - } - } - } - -
- -
- - // Declare the variable xCoordinates and assign it an array of numbers. - let xCoordinates = [20, 40, 60, 80]; - - function setup() { - createCanvas(100, 100); - - describe('Four white circles drawn in a horizontal line on a gray background.'); - } - - function draw() { - background(200); - - // Access the element at index i and use it to draw a circle. - for (let i = 0; i < xCoordinates.length; i += 1) { - circle(xCoordinates[i], 50, 20); - } - } - -
- -
- - // Declare the variable xCoordinates and assign it an array of numbers. - let xCoordinates = [20, 40, 60, 80]; - - function setup() { - createCanvas(100, 100); - - describe('Four white circles drawn in a horizontal line on a gray background.'); - } - - function draw() { - background(200); - - // Access each element of the array and use it to draw a circle. - for (let x of xCoordinates) { - circle(x, 50, 20); - } - } - -
-class: p5 ---- - - -# for diff --git a/src/content/reference/en/p5 copy/fract.mdx b/src/content/reference/en/p5 copy/fract.mdx deleted file mode 100644 index 399f144c09..0000000000 --- a/src/content/reference/en/p5 copy/fract.mdx +++ /dev/null @@ -1,55 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L1048 -title: fract -module: Math -submodule: Calculation -file: src/math/calculation.js -description: | -

Calculates the fractional part of a number.

-

A number's fractional part includes its decimal values. For example, - fract(12.34) returns 0.34.

-line: 1048 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Original number. - let n = 56.78; - text(n, 50, 33); - - // Fractional part. - let f = fract(n); - text(f, 50, 67); - - describe('The number 56.78 written above the number 0.78.'); - } - -
-class: p5 -params: - - name: 'n' - description: | -

number whose fractional part will be found.

- type: Number -return: - description: fractional part of n. - type: Number -chainable: false ---- - - -# fract diff --git a/src/content/reference/en/p5 copy/frameCount.mdx b/src/content/reference/en/p5 copy/frameCount.mdx deleted file mode 100644 index f2d02603a0..0000000000 --- a/src/content/reference/en/p5 copy/frameCount.mdx +++ /dev/null @@ -1,73 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L69 -title: frameCount -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

A Number variable that tracks the number of frames drawn since - the sketch - - started.

- -

frameCount's value is 0 inside setup(). It - - increments by 1 each time the code in draw() - - finishes executing.

-line: 69 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Display the value of - // frameCount. - textSize(30); - textAlign(CENTER, CENTER); - text(frameCount, 50, 50); - - describe('The number 0 written in black in the middle of a gray square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Set the frameRate to 30. - frameRate(30); - - textSize(30); - textAlign(CENTER, CENTER); - - describe('A number written in black in the middle of a gray square. Its value increases rapidly.'); - } - - function draw() { - background(200); - - // Display the value of - // frameCount. - text(frameCount, 50, 50); - } - -
-class: p5 -type: Integer ---- - - -# frameCount diff --git a/src/content/reference/en/p5 copy/frameRate.mdx b/src/content/reference/en/p5 copy/frameRate.mdx deleted file mode 100644 index 38ccddd0d6..0000000000 --- a/src/content/reference/en/p5 copy/frameRate.mdx +++ /dev/null @@ -1,107 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L330 -title: frameRate -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

Sets the number of frames to draw per second.

- -

Calling frameRate() with one numeric argument, as in - frameRate(30), - - attempts to draw 30 frames per second (FPS). The target frame rate may not - - be achieved depending on the sketch's processing needs. Most computers - - default to a frame rate of 60 FPS. Frame rates of 24 FPS and above are - - fast enough for smooth animations.

- -

Calling frameRate() without an argument returns the current - frame rate. - - The value returned is an approximation.

-line: 330 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A white circle on a gray background. The circle moves from left to right in a loop. It slows down when the mouse is pressed.'); - } - - function draw() { - background(200); - - // Set the x variable based - // on the current frameCount. - let x = frameCount % 100; - - // If the mouse is pressed, - // decrease the frame rate. - if (mouseIsPressed === true) { - frameRate(10); - } else { - frameRate(60); - } - - // Use x to set the circle's - // position. - circle(x, 50, 20); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A number written in black on a gray background. The number decreases when the mouse is pressed.'); - } - - function draw() { - background(200); - - // If the mouse is pressed, do lots - // of math to slow down drawing. - if (mouseIsPressed === true) { - for (let i = 0; i < 1000000; i += 1) { - random(); - } - } - - // Get the current frame rate - // and display it. - let fps = frameRate(); - text(fps, 50, 50); - } - -
-class: p5 -overloads: - - line: 330 - params: - - name: fps - description: | -

number of frames to draw per second.

- type: Number - chainable: 1 - - line: 404 - params: [] - return: - description: current frame rate. - type: Number -chainable: true ---- - - -# frameRate diff --git a/src/content/reference/en/p5 copy/freeGeometry.mdx b/src/content/reference/en/p5 copy/freeGeometry.mdx deleted file mode 100644 index 7af36d8620..0000000000 --- a/src/content/reference/en/p5 copy/freeGeometry.mdx +++ /dev/null @@ -1,152 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L748 -title: freeGeometry -module: Shape -submodule: 3D Primitives -file: src/webgl/3d_primitives.js -description: > -

Clears a p5.Geometry object from - the graphics - - processing unit (GPU) memory.

- -

p5.Geometry objects can contain - lots of data - - about their vertices, surface normals, colors, and so on. Complex 3D shapes - - can use lots of memory which is a limited resource in many GPUs. Calling - - freeGeometry() can improve performance by freeing a - - p5.Geometry object’s resources from - GPU memory. - - freeGeometry() works with p5.Geometry objects - - created with beginGeometry() and - - endGeometry(), - - buildGeometry(), and - - loadModel().

- -

The parameter, geometry, is the p5.Geometry - - object to be freed.

- -

Note: A p5.Geometry object can - still be drawn - - after its resources are cleared from GPU memory. It may take longer to draw - - the first time it’s redrawn.

- -

Note: freeGeometry() can only be used in WebGL mode.

-line: 748 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - // Create a p5.Geometry object. - beginGeometry(); - cone(); - let shape = endGeometry(); - - // Draw the shape. - model(shape); - - // Free the shape's resources. - freeGeometry(shape); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let button; - let particles; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a button to reset the particle system. - button = createButton('Reset'); - - // Call resetModel() when the user presses the button. - button.mousePressed(resetModel); - - // Add the original set of particles. - resetModel(); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the particles. - noStroke(); - - // Draw the particles. - model(particles); - } - - function resetModel() { - // If the p5.Geometry object has already been created, - // free those resources. - if (particles) { - freeGeometry(particles); - } - - // Create a new p5.Geometry object with random spheres. - particles = buildGeometry(createParticles); - } - - function createParticles() { - for (let i = 0; i < 60; i += 1) { - // Calculate random coordinates. - let x = randomGaussian(0, 20); - let y = randomGaussian(0, 20); - let z = randomGaussian(0, 20); - - push(); - // Translate to the particle's coordinates. - translate(x, y, z); - // Draw the particle. - sphere(5); - pop(); - } - } - -
-class: p5 -params: - - name: geometry - description: | -

3D shape whose resources should be freed.

- type: p5.Geometry -chainable: false ---- - - -# freeGeometry diff --git a/src/content/reference/en/p5 copy/freqToMidi.mdx b/src/content/reference/en/p5 copy/freqToMidi.mdx deleted file mode 100644 index 12c6e1eff9..0000000000 --- a/src/content/reference/en/p5 copy/freqToMidi.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L825 -title: freqToMidi -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: | -

Returns the closest MIDI note value for - a given frequency.

-line: 825 -isConstructor: false -itemtype: method -class: p5 -params: - - name: frequency - description: | -

A freqeuncy, for example, the "A" - above Middle C is 440Hz

- type: Number -return: - description: MIDI note value - type: Number -chainable: false ---- - - -# freqToMidi diff --git a/src/content/reference/en/p5 copy/frustum.mdx b/src/content/reference/en/p5 copy/frustum.mdx deleted file mode 100644 index 01ffd87883..0000000000 --- a/src/content/reference/en/p5 copy/frustum.mdx +++ /dev/null @@ -1,175 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L522 -title: frustum -module: 3D -submodule: Camera -file: src/webgl/p5.Camera.js -description: > -

Sets the frustum of the current camera in a 3D sketch.

- -

In a frustum projection, shapes that are further from the camera appear - - smaller than shapes that are near the camera. This technique, called - - foreshortening, creates realistic 3D scenes.

- -

frustum() changes the default camera’s perspective by changing - its - - viewing frustum. The frustum is the volume of space that’s visible to the - - camera. The frustum’s shape is a pyramid with its top cut off. The camera - - is placed where the top of the pyramid should be and points towards the - - base of the pyramid. It views everything within the frustum.

- -

The first four parameters, left, right, - bottom, and top, set the - - coordinates of the frustum’s sides, bottom, and top. For example, calling - - frustum(-100, 100, 200, -200) creates a frustum that’s 200 pixels - wide - - and 400 pixels tall. By default, these coordinates are set based on the - - sketch’s width and height, as in - - ortho(-width / 20, width / 20, height / 20, -height / 20).

- -

The last two parameters, near and far, set the - distance of the - - frustum’s near and far plane from the camera. For example, calling - - ortho(-100, 100, 200, -200, 50, 1000) creates a frustum that’s - 200 pixels - - wide, 400 pixels tall, starts 50 pixels from the camera, and ends 1,000 - - pixels from the camera. By default, near is set to 0.1 * 800, - which is - - 1/10th the default distance between the camera and the origin. - far is set - - to 10 * 800, which is 10 times the default distance between the - camera - - and the origin.

- -

Note: frustum() can only be used in WebGL mode.

-line: 522 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A row of white cubes on a gray background.'); - } - - function draw() { - background(200); - - // Apply the default frustum projection. - frustum(); - - // Translate the origin toward the camera. - translate(-10, 10, 600); - - // Rotate the coordinate system. - rotateY(-0.1); - rotateX(-0.1); - - // Draw the row of boxes. - for (let i = 0; i < 6; i += 1) { - translate(0, 0, -40); - box(10); - } - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Adjust the frustum. - // Center it. - // Set its width and height to 20 pixels. - // Place its near plane 300 pixels from the camera. - // Place its far plane 350 pixels from the camera. - frustum(-10, 10, -10, 10, 300, 350); - - // Translate the origin toward the camera. - translate(-10, 10, 600); - - // Rotate the coordinate system. - rotateY(-0.1); - rotateX(-0.1); - - // Draw the row of boxes. - for (let i = 0; i < 6; i += 1) { - translate(0, 0, -40); - box(10); - } - } - -
-class: p5 -params: - - name: left - description: > -

x-coordinate of the frustum’s left plane. Defaults to -width / - 20.

- type: Number - optional: true - - name: right - description: > -

x-coordinate of the frustum’s right plane. Defaults to width / - 20.

- type: Number - optional: true - - name: bottom - description: > -

y-coordinate of the frustum’s bottom plane. Defaults to height / - 20.

- type: Number - optional: true - - name: top - description: > -

y-coordinate of the frustum’s top plane. Defaults to -height / - 20.

- type: Number - optional: true - - name: near - description: > -

z-coordinate of the frustum’s near plane. Defaults to 0.1 * - 800.

- type: Number - optional: true - - name: far - description: > -

z-coordinate of the frustum’s far plane. Defaults to 10 * - 800.

- type: Number - optional: true -chainable: true ---- - - -# frustum diff --git a/src/content/reference/en/p5 copy/fullscreen.mdx b/src/content/reference/en/p5 copy/fullscreen.mdx deleted file mode 100644 index 1c6b2eb7fe..0000000000 --- a/src/content/reference/en/p5 copy/fullscreen.mdx +++ /dev/null @@ -1,63 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L950 -title: fullscreen -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

Toggles full-screen mode or returns the current mode.

- -

Calling fullscreen(true) makes the sketch full-screen. Calling - - fullscreen(false) makes the sketch its original size.

- -

Calling fullscreen() without an argument returns - true if the sketch - - is in full-screen mode and false if not.

- -

Note: Due to browser restrictions, fullscreen() can only be - called with - - user input such as a mouse press.

-line: 950 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - background(200); - - describe('A gray canvas that switches between default and full-screen display when clicked.'); - } - - // If the mouse is pressed, - // toggle full-screen mode. - function mousePressed() { - if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) { - let fs = fullscreen(); - fullscreen(!fs); - } - } - -
-class: p5 -params: - - name: val - description: | -

whether the sketch should be in fullscreen mode.

- type: Boolean - optional: true -return: - description: current fullscreen state. - type: Boolean -chainable: false ---- - - -# fullscreen diff --git a/src/content/reference/en/p5 copy/function.mdx b/src/content/reference/en/p5 copy/function.mdx deleted file mode 100644 index e213633c86..0000000000 --- a/src/content/reference/en/p5 copy/function.mdx +++ /dev/null @@ -1,19 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L317 -title: function -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: "

A named group of statements.

\n

Functions\nhelp with organizing and reusing code. For example, functions make it easy\nto express the idea \"Draw a flower.\":

\n
function drawFlower() {\n  // Style the text.\n  textAlign(CENTER, CENTER);\n  textSize(20);\n\n  // Draw a flower emoji.\n  text('\U0001F338', 50, 50);\n}\n
\n

The function header begins with the keyword function. The function's\nname, drawFlower, is followed by parentheses () and curly braces {}.\nThe code between the curly braces is called the function's body. The\nfunction's body runs when the function is called like so:

\n
drawFlower();\n
\n

Functions can accept inputs by adding parameters to their headers.\nParameters are placeholders for values that will be provided when the\nfunction is called. For example, the drawFlower() function could include\na parameter for the flower's size:

\n
function drawFlower(size) {\n  // Style the text.\n  textAlign(CENTER, CENTER);\n\n  // Use the size parameter.\n  textSize(size);\n\n  // Draw a flower emoji.\n  text('\U0001F338', 50, 50);\n}\n
\n

Parameters are part of the function's declaration. Arguments are provided\nby the code that calls a function. When a function is called, arguments are\nassigned to parameters:

\n
// The argument 20 is assigned to the parameter size.\ndrawFlower(20);\n
\n

Functions can have multiple parameters separated by commas. Parameters\ncan have any type. For example, the drawFlower() function could accept\nNumber parameters for the flower's x- and y-coordinates along with its\nsize:

\n
function drawFlower(x, y, size) {\n  // Style the text.\n  textAlign(CENTER, CENTER);\n\n  // Use the size parameter.\n  textSize(size);\n\n  // Draw a flower emoji.\n  // Use the x and y parameters.\n  text('\U0001F338', x, y);\n}\n
\n

Functions can also produce outputs by adding a return statement:

\n
function double(x) {\n  let answer = 2 * x;\n  return answer;\n}\n
\n

The expression following return can produce an output that's used\nelsewhere. For example, the output of the double() function can be\nassigned to a variable:

\n
let six = double(3);\ntext(`3 x 2 = ${six}`, 50, 50);\n
\n" -line: 317 -isConstructor: false -itemtype: property -example: - - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n describe('A pink flower on a gray background.');\n}\n\nfunction draw() {\n background(200);\n\n // Call the drawFlower() function.\n drawFlower();\n}\n\n// Declare a function that draws a flower at the\n// center of the canvas.\nfunction drawFlower() {\n // Style the text.\n textAlign(CENTER, CENTER);\n textSize(20);\n\n // Draw a flower emoji.\n text('\U0001F338', 50, 50);\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n describe('A pink flower on a gray background.');\n}\n\nfunction draw() {\n background(200);\n\n // Call the drawFlower() function and pass values for\n // its position and size.\n drawFlower(50, 50, 20);\n}\n\n// Declare a function that draws a flower at the\n// center of the canvas.\nfunction drawFlower(x, y, size) {\n // Style the text.\n textAlign(CENTER, CENTER);\n\n // Use the size parameter.\n textSize(size);\n\n // Draw a flower emoji.\n // Use the x and y parameters.\n text('\U0001F338', x, y);\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n describe('The message \"Hello, \U0001F30D!\" written on a gray background.');\n}\n\nfunction draw() {\n background(200);\n\n // Create a greeting.\n let greeting = createGreeting('\U0001F30D');\n\n // Style the text.\n textAlign(CENTER, CENTER);\n textSize(16);\n\n // Display the greeting.\n text(greeting, 50, 50);\n}\n\n// Return a string with a personalized greeting.\nfunction createGreeting(name) {\n let message = `Hello, ${name}!`;\n return message;\n}\n\n
" -class: p5 ---- - - -# function diff --git a/src/content/reference/en/p5 copy/get.mdx b/src/content/reference/en/p5 copy/get.mdx deleted file mode 100644 index 42cbb8e7f8..0000000000 --- a/src/content/reference/en/p5 copy/get.mdx +++ /dev/null @@ -1,178 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L820 -title: get -module: Image -submodule: Pixels -file: src/image/pixels.js -description: > -

Gets a pixel or a region of pixels from the canvas.

- -

get() is easy to use but it's not as fast as - - pixels. Use pixels - - to read many pixel values.

- -

The version of get() with no parameters returns the entire - canvas.

- -

The version of get() with two parameters interprets them as - - coordinates. It returns an array with the [R, G, B, A] values of - the - - pixel at the given point.

- -

The version of get() with four parameters interprets them as - coordinates - - and dimensions. It returns a subsection of the canvas as a - - p5.Image object. The first two parameters - are the - - coordinates for the upper-left corner of the subsection. The last two - - parameters are the width and height of the subsection.

- -

Use p5.Image.get() to work directly - with - - p5.Image objects.

-line: 820 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/rockies.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Get the entire canvas. - let c = get(); - - // Display half the canvas. - image(c, 50, 0); - - describe('Two identical mountain landscapes shown side-by-side.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/rockies.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Get the color of a pixel. - let c = get(50, 90); - - // Style the square with the pixel's color. - fill(c); - noStroke(); - - // Display the square. - square(25, 25, 50); - - describe('A mountain landscape with an olive green square in its center.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/rockies.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - // Get a region of the image. - let c = get(0, 0, 50, 50); - - // Display the region. - image(c, 50, 50); - - describe('A mountain landscape drawn on top of another mountain landscape.'); - } - -
-class: p5 -return: - description: subsection as a p5.Image object. - type: p5.Image -overloads: - - line: 820 - params: - - name: x - description: | -

x-coordinate of the pixel.

- type: Number - - name: 'y' - description: | -

y-coordinate of the pixel.

- type: Number - - name: w - description: | -

width of the subsection to be returned.

- type: Number - - name: h - description: | -

height of the subsection to be returned.

- type: Number - return: - description: subsection as a p5.Image object. - type: p5.Image - - line: 931 - params: [] - return: - description: whole canvas as a p5.Image. - type: p5.Image - - line: 935 - params: - - name: x - description: '' - type: Number - - name: 'y' - description: '' - type: Number - return: - description: 'color of the pixel at (x, y) in array format `[R, G, B, A]`.' - type: 'Number[]' -chainable: false ---- - - -# get diff --git a/src/content/reference/en/p5 copy/getAudioContext.mdx b/src/content/reference/en/p5 copy/getAudioContext.mdx deleted file mode 100644 index c7291c5cdf..0000000000 --- a/src/content/reference/en/p5 copy/getAudioContext.mdx +++ /dev/null @@ -1,56 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L159 -title: getAudioContext -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: >- -

Returns the Audio Context for this sketch. Useful for users - - who would like to dig deeper into the Web Audio API - - .

- - -

Some browsers require users to startAudioContext - - with a user gesture, such as touchStarted in the example below.

-line: 159 -isConstructor: false -itemtype: method -example: - - |- - -
- function draw() { - background(255); - textAlign(CENTER); - - if (getAudioContext().state !== 'running') { - text('click to start audio', width/2, height/2); - } else { - text('audio is enabled', width/2, height/2); - } - } - - function touchStarted() { - if (getAudioContext().state !== 'running') { - getAudioContext().resume(); - } - var synth = new p5.MonoSynth(); - synth.play('A4', 0.5, 0, 0.2); - } - -
-class: p5 -return: - description: AudioContext for this sketch - type: Object -chainable: false ---- - - -# getAudioContext diff --git a/src/content/reference/en/p5 copy/getItem.mdx b/src/content/reference/en/p5 copy/getItem.mdx deleted file mode 100644 index 5747f67366..0000000000 --- a/src/content/reference/en/p5 copy/getItem.mdx +++ /dev/null @@ -1,151 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/data/local_storage.js#L164 -title: getItem -module: Data -submodule: LocalStorage -file: src/data/local_storage.js -description: > -

Returns a value in the web browser's local storage.

- -

Web browsers can save small amounts of data using the built-in - - localStorage object. - - Data stored in localStorage can be retrieved at any point, even - after - - refreshing a page or restarting the browser. Data are stored as key-value - - pairs.

- -

storeItem() makes it easy to store - values in - - localStorage and getItem() makes it easy to retrieve - them.

- -

The first parameter, key, is the name of the value to be - stored as a - - string.

- -

The second parameter, value, is the value to be retrieved a - string. For - - example, calling getItem('size') retrieves the value with the key - size.

- -

Note: Sensitive data such as passwords or personal information shouldn't be - - stored in localStorage.

-line: 164 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Store the player's name. - storeItem('name', 'Feist'); - - // Store the player's score. - storeItem('score', 1234); - - describe('The text "Feist: 1234" written in black on a gray background.'); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(14); - - // Retrieve the name. - let name = getItem('name'); - - // Retrieve the score. - let score = getItem('score'); - - // Display the score. - text(`${name}: ${score}`, 50, 50); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Create an object. - let p = { x: 50, y: 50 }; - - // Store the object. - storeItem('position', p); - - describe('A white circle on a gray background.'); - } - - function draw() { - background(200); - - // Retrieve the object. - let p = getItem('position'); - - // Draw the circle. - circle(p.x, p.y, 30); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Create a p5.Color object. - let c = color('deeppink'); - - // Store the object. - storeItem('color', c); - - describe('A pink circle on a gray background.'); - } - - function draw() { - background(200); - - // Retrieve the object. - let c = getItem('color'); - - // Style the circle. - fill(c); - - // Draw the circle. - circle(50, 50, 30); - } - -
-class: p5 -params: - - name: key - description: | -

name of the value.

- type: String -return: - description: stored item. - type: String|Number|Boolean|Object|Array -chainable: false ---- - - -# getItem diff --git a/src/content/reference/en/p5 copy/getOutputVolume.mdx b/src/content/reference/en/p5 copy/getOutputVolume.mdx deleted file mode 100644 index 6542c5edb6..0000000000 --- a/src/content/reference/en/p5 copy/getOutputVolume.mdx +++ /dev/null @@ -1,25 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L726 -title: getOutputVolume -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: | -

Returns a number representing the output volume for sound - in this sketch.

-line: 726 -isConstructor: false -itemtype: method -class: p5 -return: - description: |- - Output volume for sound in this sketch. - Should be between 0.0 (silence) and 1.0. - type: Number -chainable: false ---- - - -# getOutputVolume diff --git a/src/content/reference/en/p5 copy/getTargetFrameRate.mdx b/src/content/reference/en/p5 copy/getTargetFrameRate.mdx deleted file mode 100644 index 10e3c74a4b..0000000000 --- a/src/content/reference/en/p5 copy/getTargetFrameRate.mdx +++ /dev/null @@ -1,48 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L447 -title: getTargetFrameRate -module: Environment -submodule: Environment -file: src/core/environment.js -description: | -

Returns the target frame rate.

-

The value is either the system frame rate or the last value passed to - frameRate().

-line: 447 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('The number 20 written in black on a gray background.'); - } - - function draw() { - background(200); - - // Set the frame rate to 20. - frameRate(20); - - // Get the target frame rate and - // display it. - let fps = getTargetFrameRate(); - text(fps, 43, 54); - } - -
-class: p5 -return: - description: _targetFrameRate - type: Number -chainable: false ---- - - -# getTargetFrameRate diff --git a/src/content/reference/en/p5 copy/getURL.mdx b/src/content/reference/en/p5 copy/getURL.mdx deleted file mode 100644 index 01ccdc8e11..0000000000 --- a/src/content/reference/en/p5 copy/getURL.mdx +++ /dev/null @@ -1,46 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L1149 -title: getURL -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

Returns the sketch's current - - URL - - as a String.

-line: 1149 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - background(200); - - // Get the sketch's URL - // and display it. - let url = getURL(); - textWrap(CHAR); - text(url, 0, 40, 100); - - describe('The URL "https://p5js.org/reference/p5/getURL" written in black on a gray background.'); - } - -
-class: p5 -return: - description: url - type: String -chainable: false ---- - - -# getURL diff --git a/src/content/reference/en/p5 copy/getURLParams.mdx b/src/content/reference/en/p5 copy/getURLParams.mdx deleted file mode 100644 index c08c77f23f..0000000000 --- a/src/content/reference/en/p5 copy/getURLParams.mdx +++ /dev/null @@ -1,59 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L1208 -title: getURLParams -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

Returns the current - - URL parameters - - in an Object.

- -

For example, calling getURLParams() in a sketch hosted at the - URL - - https://p5js.org?year=2014&month=May&day=15 returns - - { year: 2014, month: 'May', day: 15 }.

-line: 1208 -isConstructor: false -itemtype: method -alt: This example does not render anything. -example: - - |- - -
- - // Imagine this sketch is hosted at the following URL: - // https://p5js.org?year=2014&month=May&day=15 - - function setup() { - background(200); - - // Get the sketch's URL - // parameters and display - // them. - let params = getURLParams(); - text(params.day, 10, 20); - text(params.month, 10, 40); - text(params.year, 10, 60); - - describe('The text "15", "May", and "2014" written in black on separate lines.'); - } - -
-class: p5 -return: - description: URL params - type: Object -chainable: false ---- - - -# getURLParams diff --git a/src/content/reference/en/p5 copy/getURLPath.mdx b/src/content/reference/en/p5 copy/getURLPath.mdx deleted file mode 100644 index e71b7746ad..0000000000 --- a/src/content/reference/en/p5 copy/getURLPath.mdx +++ /dev/null @@ -1,58 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L1175 -title: getURLPath -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

Returns the current - - URL - - path as an Array of Strings.

- -

For example, consider a sketch hosted at the URL - - https://example.com/sketchbook. Calling getURLPath() - returns - - ['sketchbook']. For a sketch hosted at the URL - - https://example.com/sketchbook/monday, getURLPath() - returns - - ['sketchbook', 'monday'].

-line: 1175 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - background(200); - - // Get the sketch's URL path - // and display the first - // part. - let path = getURLPath(); - text(path[0], 25, 54); - - describe('The word "reference" written in black on a gray background.'); - } - -
-class: p5 -return: - description: path components. - type: 'String[]' -chainable: false ---- - - -# getURLPath diff --git a/src/content/reference/en/p5 copy/green.mdx b/src/content/reference/en/p5 copy/green.mdx deleted file mode 100644 index 72634492fb..0000000000 --- a/src/content/reference/en/p5 copy/green.mdx +++ /dev/null @@ -1,159 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L692 -title: green -module: Color -submodule: Creating & Reading -file: src/color/creating_reading.js -description: > -

Gets the green value of a color.

- -

green() extracts the green value from a - - p5.Color object, an array of color - components, or - - a CSS color string.

- -

By default, green() returns a color's green value in the range - 0 - - to 255. If the colorMode() is set to - RGB, it - - returns the green value in the given range.

-line: 692 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object. - let c = color(175, 100, 220); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'greenValue' to 100. - let greenValue = green(c); - - // Draw the right rectangle. - fill(0, greenValue, 0); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is dark green.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a color array. - let c = [175, 100, 220]; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'greenValue' to 100. - let greenValue = green(c); - - // Draw the right rectangle. - fill(0, greenValue, 0); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is dark green.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a CSS color string. - let c = 'rgb(175, 100, 220)'; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'greenValue' to 100. - let greenValue = green(c); - - // Draw the right rectangle. - fill(0, greenValue, 0); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is dark green.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use RGB color with values in the range 0-100. - colorMode(RGB, 100); - - // Create a p5.Color object using RGB values. - let c = color(69, 39, 86); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'greenValue' to 39. - let greenValue = green(c); - - // Draw the right rectangle. - fill(0, greenValue, 0); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is dark green.'); - } - -
-class: p5 -params: - - name: color - description: | -

p5.Color object, array of - color components, or CSS color string.

- type: 'p5.Color|Number[]|String' -return: - description: the green value. - type: Number -chainable: false ---- - - -# green diff --git a/src/content/reference/en/p5 copy/gridOutput.mdx b/src/content/reference/en/p5 copy/gridOutput.mdx deleted file mode 100644 index c80c3efaf2..0000000000 --- a/src/content/reference/en/p5 copy/gridOutput.mdx +++ /dev/null @@ -1,189 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/accessibility/outputs.js#L161 -title: gridOutput -module: Environment -submodule: Environment -file: src/accessibility/outputs.js -description: > -

Creates a screen reader-accessible description of shapes on the canvas.

- -

gridOutput() adds a general description, table of shapes, and - list of - - shapes to the web page. The general description includes the canvas size, - - canvas color, and number of shapes. For example, - - gray canvas, 100 by 100 pixels, contains 2 shapes: 1 circle 1 - square.

- -

gridOutput() uses its table of shapes as a grid. Each shape in - the grid - - is placed in a cell whose row and column correspond to the shape's location - - on the canvas. The grid cells describe the color and type of shape at that - - location. For example, red circle. These descriptions can be - selected - - individually to get more details. This is different from - - textOutput(), which uses its table as - a list.

- -

A list of shapes follows the table. The list describes the color, type, - - location, and area of each shape. For example, - - red circle, location = middle, area = 3 %.

- -

The display parameter is optional. It determines how the - description is - - displayed. If LABEL is passed, as in - gridOutput(LABEL), the description - - will be visible in a div element next to the canvas. Using LABEL - creates - - unhelpful duplicates for screen readers. Only use LABEL during - - development. If FALLBACK is passed, as in - gridOutput(FALLBACK), the - - description will only be visible to screen readers. This is the default - - mode.

- -

Read - - Writing - accessible canvas descriptions - - to learn more about making sketches accessible.

- -

gridOutput() generates descriptions in English only. Text - drawn with - - text() is not described. Shapes created with - - beginShape() are not described. WEBGL - mode - - and 3D shapes are not supported.

- -

Use describe() and - - describeElement() for more - control - - over canvas descriptions.

-line: 161 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - // Add the grid description. - gridOutput(); - - // Draw a couple of shapes. - background(200); - fill(255, 0, 0); - circle(20, 20, 20); - fill(0, 0, 255); - square(50, 50, 50); - - // Add a general description of the canvas. - describe('A red circle and a blue square on a gray background.'); - } - -
- -
- - function setup() { - // Add the grid description and - // display it for debugging. - gridOutput(LABEL); - - // Draw a couple of shapes. - background(200); - fill(255, 0, 0); - circle(20, 20, 20); - fill(0, 0, 255); - square(50, 50, 50); - - // Add a general description of the canvas. - describe('A red circle and a blue square on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - } - - function draw() { - // Add the grid description. - gridOutput(); - - // Draw a moving circle. - background(200); - let x = frameCount * 0.1; - fill(255, 0, 0); - circle(x, 20, 20); - fill(0, 0, 255); - square(50, 50, 50); - - // Add a general description of the canvas. - describe('A red circle moves from left to right above a blue square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - } - - function draw() { - // Add the grid description and - // display it for debugging. - gridOutput(LABEL); - - // Draw a moving circle. - background(200); - let x = frameCount * 0.1; - fill(255, 0, 0); - circle(x, 20, 20); - fill(0, 0, 255); - square(50, 50, 50); - - // Add a general description of the canvas. - describe('A red circle moves from left to right above a blue square.'); - } - -
-class: p5 -params: - - name: display - description: | -

either FALLBACK or LABEL.

- type: Constant - optional: true -chainable: false ---- - - -# gridOutput diff --git a/src/content/reference/en/p5 copy/height.mdx b/src/content/reference/en/p5 copy/height.mdx deleted file mode 100644 index f6321218df..0000000000 --- a/src/content/reference/en/p5 copy/height.mdx +++ /dev/null @@ -1,87 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L881 -title: height -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

A Number variable that stores the height of the canvas in - pixels.

- -

height's default value is 100. Calling - - createCanvas() or - - resizeCanvas() changes the value of - - height. Calling noCanvas() - sets its value to - - 0.

-line: 881 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - background(200); - - // Display the canvas' height. - text(height, 42, 54); - - describe('The number 100 written in black on a gray square.'); - } - -
- -
- - function setup() { - createCanvas(100, 50); - - background(200); - - // Display the canvas' height. - text(height, 42, 27); - - describe('The number 50 written in black on a gray rectangle.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Display the canvas' height. - text(height, 42, 54); - - describe('The number 100 written in black on a gray square. When the mouse is pressed, the square becomes a rectangle and the number becomes 50.'); - } - - // If the mouse is pressed, reisze - // the canvas and display its new - // height. - function mousePressed() { - if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) { - resizeCanvas(100, 50); - background(200); - text(height, 42, 27); - } - } - -
-class: p5 -type: Number ---- - - -# height diff --git a/src/content/reference/en/p5 copy/hex.mdx b/src/content/reference/en/p5 copy/hex.mdx deleted file mode 100644 index 5475af324a..0000000000 --- a/src/content/reference/en/p5 copy/hex.mdx +++ /dev/null @@ -1,166 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L818 -title: hex -module: Data -submodule: Conversion -file: src/utilities/conversion.js -description: > -

Converts a Number to a String with its - hexadecimal value.

- -

hex() converts a number to a string with its hexadecimal - number value. - - Hexadecimal (hex) numbers are base-16, which means there are 16 unique - - digits. Hex extends the numbers 0–9 with the letters A–F. For example, the - - number 11 (eleven) in base-10 is written as the letter - B in hex.

- -

The first parameter, n, is the number to convert. For example, - hex(20), - - returns the string '00000014'. If an array is passed, as in - - hex([1, 10, 100]), an array of hexadecimal strings is - returned.

- -

The second parameter, digits, is optional. If a number is - passed, as in - - hex(20, 2), it sets the number of hexadecimal digits to display. - For - - example, calling hex(20, 2) returns the string - '14'.

-line: 818 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a number variable. - let original = 20; - - // Convert the number to a hex string. - let converted = hex(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(14); - - // Display the original and converted values. - text(`${original} = ${converted}`, 50, 50); - - describe('The text "20 = 00000014" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a number variable. - let original = 20; - - // Convert the number to a hex string. - // Only display two hex digits. - let converted = hex(original, 2); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the original and converted values. - text(`${original} = ${converted}`, 50, 50); - - describe('The text "20 = 14" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of numbers. - let original = [1, 10, 100]; - - // Convert the numbers to hex strings. - // Only use two hex digits. - let converted = hex(original, 2); - - // Style the text. - textAlign(RIGHT, CENTER); - textSize(16); - - // Iterate over the converted values. - for (let i = 0; i < converted.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 25; - - // Display the original and converted values. - text(`${ original[i]} = ${converted[i]}`, 75, y); - } - - describe( - 'The text "1 = 01", "10 = 0A", and "100 = 64" written on three separate lines. The text is in black on a gray background.' - ); - } - -
-class: p5 -return: - description: converted hexadecimal value. - type: String -overloads: - - line: 818 - params: - - name: 'n' - description: | -

value to convert.

- type: Number - - name: digits - description: | -

number of digits to include.

- type: Number - optional: true - return: - description: converted hexadecimal value. - type: String - - line: 926 - params: - - name: ns - description: | -

values to convert.

- type: 'Number[]' - - name: digits - description: '' - type: Number - optional: true - return: - description: converted hexadecimal values. - type: 'String[]' -chainable: false ---- - - -# hex diff --git a/src/content/reference/en/p5 copy/hour.mdx b/src/content/reference/en/p5 copy/hour.mdx deleted file mode 100644 index 802a809d72..0000000000 --- a/src/content/reference/en/p5 copy/hour.mdx +++ /dev/null @@ -1,47 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L44 -title: hour -module: IO -submodule: Time & Date -file: src/utilities/time_date.js -description: | -

Returns the current hour as a number from 0–23.

-line: 44 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Get the current hour. - let h = hour(); - - // Style the text. - textAlign(LEFT, CENTER); - textSize(12); - textFont('Courier New'); - - // Display the hour. - text(`Current hour: ${h}`, 20, 50, 60); - - describe(`The text 'Current hour: ${h}' written in black on a gray background.`); - } - -
-class: p5 -return: - description: current hour between 0 and 23. - type: Integer -chainable: false ---- - - -# hour diff --git a/src/content/reference/en/p5 copy/httpDo.mdx b/src/content/reference/en/p5 copy/httpDo.mdx deleted file mode 100644 index 52d6553248..0000000000 --- a/src/content/reference/en/p5 copy/httpDo.mdx +++ /dev/null @@ -1,150 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1208 -title: httpDo -module: IO -submodule: Input -file: src/io/files.js -description: > -

Method for executing an HTTP request. If data type is not specified, - - p5 will try to guess based on the URL, defaulting to text.

- - For more advanced use, you may also pass in the path as the first argument - - and a object as the second argument, the signature follows the one specified - - in the Fetch API specification. - - This method is suitable for fetching files up to size of 64MB when "GET" is - used.

-line: 1208 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Examples use USGS Earthquake API: - // https://earthquake.usgs.gov/fdsnws/event/1/#methods - - // displays an animation of all USGS earthquakes - let earthquakes; - let eqFeatureIndex = 0; - - function preload() { - let url = 'https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson'; - httpDo( - url, - { - method: 'GET', - // Other Request options, like special headers for apis - headers: { authorization: 'Bearer secretKey' } - }, - function(res) { - earthquakes = res; - } - ); - } - - function draw() { - // wait until the data is loaded - if (!earthquakes || !earthquakes.features[eqFeatureIndex]) { - return; - } - clear(); - - let feature = earthquakes.features[eqFeatureIndex]; - let mag = feature.properties.mag; - let rad = mag / 11 * ((width + height) / 2); - fill(255, 0, 0, 100); - ellipse(width / 2 + random(-2, 2), height / 2 + random(-2, 2), rad, rad); - - if (eqFeatureIndex >= earthquakes.features.length) { - eqFeatureIndex = 0; - } else { - eqFeatureIndex += 1; - } - } - -
-class: p5 -return: - description: |- - A promise that resolves with the data when the operation - completes successfully or rejects with the error after - one occurs. - type: Promise -overloads: - - line: 1208 - params: - - name: path - description: | -

name of the file or url to load

- type: String - - name: method - description: | -

either "GET", "POST", or "PUT", - defaults to "GET"

- type: String - optional: true - - name: datatype - description: | -

"json", "jsonp", "xml", or "text"

- type: String - optional: true - - name: data - description: | -

param data passed sent with request

- type: Object - optional: true - - name: callback - description: | -

function to be executed after - httpGet() completes, data is passed in - as first argument

- type: Function - optional: true - - name: errorCallback - description: | -

function to be executed if - there is an error, response is passed - in as first argument

- type: Function - optional: true - return: - description: |- - A promise that resolves with the data when the operation - completes successfully or rejects with the error after - one occurs. - type: Promise - - line: 1279 - params: - - name: path - description: '' - type: String - - name: options - description: > -

Request object options as documented in the - "fetch" API - reference

- type: Object - - name: callback - description: '' - type: Function - optional: true - - name: errorCallback - description: '' - type: Function - optional: true - return: - description: '' - type: Promise -chainable: false ---- - - -# httpDo diff --git a/src/content/reference/en/p5 copy/httpGet.mdx b/src/content/reference/en/p5 copy/httpGet.mdx deleted file mode 100644 index 9e8591e059..0000000000 --- a/src/content/reference/en/p5 copy/httpGet.mdx +++ /dev/null @@ -1,140 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1043 -title: httpGet -module: IO -submodule: Input -file: src/io/files.js -description: > -

Method for executing an HTTP GET request. If data type is not specified, - - p5 will try to guess based on the URL, defaulting to text. This is equivalent - to - - calling httpDo(path, 'GET'). The 'binary' datatype will return - - a Blob object, and the 'arrayBuffer' datatype will return an ArrayBuffer - - which can be used to initialize typed arrays (such as Uint8Array).

-line: 1043 -isConstructor: false -itemtype: method -example: - - |- - -
- // Examples use USGS Earthquake API: - // https://earthquake.usgs.gov/fdsnws/event/1/#methods - let earthquakes; - function preload() { - // Get the most recent earthquake in the database - let url = - 'https://earthquake.usgs.gov/fdsnws/event/1/query?' + - 'format=geojson&limit=1&orderby=time'; - httpGet(url, 'jsonp', false, function(response) { - // when the HTTP request completes, populate the variable that holds the - // earthquake data used in the visualization. - earthquakes = response; - }); - } - - function draw() { - if (!earthquakes) { - // Wait until the earthquake data has loaded before drawing. - return; - } - background(200); - // Get the magnitude and name of the earthquake out of the loaded JSON - let earthquakeMag = earthquakes.features[0].properties.mag; - let earthquakeName = earthquakes.features[0].properties.place; - ellipse(width / 2, height / 2, earthquakeMag * 10, earthquakeMag * 10); - textAlign(CENTER); - text(earthquakeName, 0, height - 30, width, 30); - noLoop(); - } -
-class: p5 -return: - description: |- - A promise that resolves with the data when the operation - completes successfully or rejects with the error after - one occurs. - type: Promise -overloads: - - line: 1043 - params: - - name: path - description: | -

name of the file or url to load

- type: String - - name: datatype - description: | -

"json", "jsonp", "binary", "arrayBuffer", - "xml", or "text"

- type: String - optional: true - - name: data - description: | -

param data passed sent with request

- type: Object|Boolean - optional: true - - name: callback - description: | -

function to be executed after - httpGet() completes, data is passed in - as first argument

- type: Function - optional: true - - name: errorCallback - description: | -

function to be executed if - there is an error, response is passed - in as first argument

- type: Function - optional: true - return: - description: |- - A promise that resolves with the data when the operation - completes successfully or rejects with the error after - one occurs. - type: Promise - - line: 1097 - params: - - name: path - description: '' - type: String - - name: data - description: '' - type: Object|Boolean - - name: callback - description: '' - type: Function - optional: true - - name: errorCallback - description: '' - type: Function - optional: true - return: - description: '' - type: Promise - - line: 1105 - params: - - name: path - description: '' - type: String - - name: callback - description: '' - type: Function - - name: errorCallback - description: '' - type: Function - optional: true - return: - description: '' - type: Promise -chainable: false ---- - - -# httpGet diff --git a/src/content/reference/en/p5 copy/httpPost.mdx b/src/content/reference/en/p5 copy/httpPost.mdx deleted file mode 100644 index 39f4fc75a0..0000000000 --- a/src/content/reference/en/p5 copy/httpPost.mdx +++ /dev/null @@ -1,165 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1119 -title: httpPost -module: IO -submodule: Input -file: src/io/files.js -description: > -

Method for executing an HTTP POST request. If data type is not specified, - - p5 will try to guess based on the URL, defaulting to text. This is equivalent - to - - calling httpDo(path, 'POST').

-line: 1119 -isConstructor: false -itemtype: method -example: - - >- - -
- - - - // Examples use jsonplaceholder.typicode.com for a Mock Data API - - - let url = 'https://jsonplaceholder.typicode.com/posts'; - - let postData = { userId: 1, title: 'p5 Clicked!', body: 'p5.js is very - cool.' }; - - - function setup() { - createCanvas(100, 100); - background(200); - } - - - function mousePressed() { - httpPost(url, 'json', postData, function(result) { - strokeWeight(2); - text(result.body, mouseX, mouseY); - }); - } - - - -
- - -
- - let url = 'ttps://invalidURL'; // A bad URL that will cause errors - - let postData = { title: 'p5 Clicked!', body: 'p5.js is very cool.' }; - - - function setup() { - createCanvas(100, 100); - background(200); - } - - - function mousePressed() { - httpPost( - url, - 'json', - postData, - function(result) { - // ... won't be called - }, - function(error) { - strokeWeight(2); - text(error.toString(), mouseX, mouseY); - } - ); - } - -
-class: p5 -return: - description: |- - A promise that resolves with the data when the operation - completes successfully or rejects with the error after - one occurs. - type: Promise -overloads: - - line: 1119 - params: - - name: path - description: | -

name of the file or url to load

- type: String - - name: datatype - description: | -

"json", "jsonp", "xml", or "text". - If omitted, httpPost() will guess.

- type: String - optional: true - - name: data - description: | -

param data passed sent with request

- type: Object|Boolean - optional: true - - name: callback - description: | -

function to be executed after - httpPost() completes, data is passed in - as first argument

- type: Function - optional: true - - name: errorCallback - description: | -

function to be executed if - there is an error, response is passed - in as first argument

- type: Function - optional: true - return: - description: |- - A promise that resolves with the data when the operation - completes successfully or rejects with the error after - one occurs. - type: Promise - - line: 1186 - params: - - name: path - description: '' - type: String - - name: data - description: '' - type: Object|Boolean - - name: callback - description: '' - type: Function - optional: true - - name: errorCallback - description: '' - type: Function - optional: true - return: - description: '' - type: Promise - - line: 1194 - params: - - name: path - description: '' - type: String - - name: callback - description: '' - type: Function - - name: errorCallback - description: '' - type: Function - optional: true - return: - description: '' - type: Promise -chainable: false ---- - - -# httpPost diff --git a/src/content/reference/en/p5 copy/hue.mdx b/src/content/reference/en/p5 copy/hue.mdx deleted file mode 100644 index 6baca2b9ce..0000000000 --- a/src/content/reference/en/p5 copy/hue.mdx +++ /dev/null @@ -1,145 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L828 -title: hue -module: Color -submodule: Creating & Reading -file: src/color/creating_reading.js -description: > -

Gets the hue value of a color.

- -

hue() extracts the hue value from a - - p5.Color object, an array of color - components, or - - a CSS color string.

- -

Hue describes a color's position on the color wheel. By default, - hue() - - returns a color's HSL hue in the range 0 to 360. If the - - colorMode() is set to HSB or HSL, it - returns the hue - - value in the given mode.

-line: 828 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use HSL color. - colorMode(HSL); - - // Create a p5.Color object. - let c = color(0, 50, 100); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 20, 35, 60); - - // Set 'hueValue' to 0. - let hueValue = hue(c); - - // Draw the right rectangle. - fill(hueValue); - rect(50, 20, 35, 60); - - describe( - 'Two rectangles. The rectangle on the left is salmon pink and the one on the right is black.' - ); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use HSL color. - colorMode(HSL); - - // Create a color array. - let c = [0, 50, 100]; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 20, 35, 60); - - // Set 'hueValue' to 0. - let hueValue = hue(c); - - // Draw the right rectangle. - fill(hueValue); - rect(50, 20, 35, 60); - - describe( - 'Two rectangles. The rectangle on the left is salmon pink and the one on the right is black.' - ); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use HSL color. - colorMode(HSL); - - // Create a CSS color string. - let c = 'rgb(255, 128, 128)'; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 20, 35, 60); - - // Set 'hueValue' to 0. - let hueValue = hue(c); - - // Draw the right rectangle. - fill(hueValue); - rect(50, 20, 35, 60); - - describe( - 'Two rectangles. The rectangle on the left is salmon pink and the one on the right is black.' - ); - } - -
-class: p5 -params: - - name: color - description: | -

p5.Color object, array of - color components, or CSS color string.

- type: 'p5.Color|Number[]|String' -return: - description: the hue value. - type: Number -chainable: false ---- - - -# hue diff --git a/src/content/reference/en/p5 copy/if.mdx b/src/content/reference/en/p5 copy/if.mdx deleted file mode 100644 index 88228b3ed0..0000000000 --- a/src/content/reference/en/p5 copy/if.mdx +++ /dev/null @@ -1,268 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L110 -title: if -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: > -

A way to choose whether to run a block of code.

- -

if statements are helpful for running a block of code based on - a - - condition. For example, an if statement makes it easy to express - the - - idea "Draw a circle if the mouse is pressed.":

- -
if (mouseIsPressed === true) {
-    circle(mouseX, mouseY, 20);
-  }
-
-  
- -

The statement header begins with the keyword if. The - expression in - - parentheses mouseIsPressed === true is a Boolean - expression that's - - either true or false. The code between the curly - braces {} is the if - - statement's body. The body only runs if the Boolean expression is - true.

- -

The mouseIsPressed system - variable is - - always true or false, so the code snippet above - could also be written - - as follows:

- -
if (mouseIsPressed) {
-    circle(mouseX, mouseY, 20);
-  }
-
-  
- -

An if-else statement adds a block of code that - runs if the Boolean - - expression is false. For example, here's an - if-else statement that - - expresses the idea "Draw a circle if the mouse is pressed. Otherwise, - - display a message.":

- -
if (mouseIsPressed === true) {
-    // When true.
-    circle(mouseX, mouseY, 20);
-  } else {
-    // When false.
-    text('Click me!', 50, 50);
-  }
-
-  
- -

There are two possible paths, or branches, in this code snippet. The - - program must follow one branch or the other.

- -

An else-if statement makes it possible to add - more branches. - - else-if statements run different blocks of code - under different - - conditions. For example, an else-if statement makes - it easy to express - - the idea "If the mouse is on the left, paint the canvas white. If the mouse - - is in the middle, paint the canvas gray. Otherwise, paint the canvas - - black.":

- -
if (mouseX < 33) {
-    background(255);
-  } else if (mouseX < 67) {
-    background(200);
-  } else {
-    background(0);
-  }
-
-  
- -

if statements can add as many - else-if statements as needed. However, - - there can only be one else statement and it must be last.

- -

if statements can also check for multiple conditions at once. - For - - example, the Boolean operator && (AND) checks - whether two expressions - - are both true:

- -
if (keyIsPressed === true && key === 'p') {
-    text('You pressed the "p" key!', 50, 50);
-  }
-
-  
- -

If the user is pressing a key AND that key is 'p', then a - message will - - display.

- -

The Boolean operator || (OR) checks whether at - least one of two - - expressions is true:

- -
if (keyIsPressed === true || mouseIsPressed ===
-  true) {
-    text('You did something!', 50, 50);
-  }
-
-  
- -

If the user presses a key, or presses a mouse button, or both, then a - - message will display.

- -

The body of an if statement can contain another - if statement. This is - - called a "nested if statement." For example, nested - if statements make - - it easy to express the idea "If a key is pressed, then check if the key is - - 'r'. If it is, then set the fill to red.":

- -
if (keyIsPressed === true) {
-    if (key === 'r') {
-      fill('red');
-    }
-  }
-
-  
- -

See Boolean and Number - - to learn more about these data types and the operations they support.

-line: 110 -isConstructor: false -itemtype: property -example: - - |- - -
- - // Click the mouse to show the circle. - - function setup() { - createCanvas(100, 100); - - describe( - 'A white circle on a gray background. The circle follows the mouse user clicks on the canvas.' - ); - } - - function draw() { - background(200); - - if (mouseIsPressed === true) { - circle(mouseX, mouseY, 20); - } - } - -
- -
- - // Click the mouse to show different shapes. - - function setup() { - createCanvas(100, 100); - - describe( - 'A white ellipse on a gray background. The ellipse becomes a circle when the user presses the mouse.' - ); - } - - function draw() { - background(200); - - if (mouseIsPressed === true) { - circle(50, 50, 20); - } else { - ellipse(50, 50, 20, 50); - } - } - -
- -
- - // Move the mouse to change the background color. - - function setup() { - createCanvas(100, 100); - - describe( - 'A square changes color from white to black as the user moves the mouse from left to right.' - ); - } - - function draw() { - if (mouseX < 33) { - background(255); - } else if (mouseX < 67) { - background(200); - } else { - background(0); - } - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - function setup() { - createCanvas(100, 100); - - describe( - 'A white circle drawn on a gray background. The circle changes color to red when the user presses the "r" key.' - ); - } - - function draw() { - background(200); - - if (keyIsPressed === true) { - if (key === 'r') { - fill('red'); - } - } - - circle(50, 50, 40); - } - -
-class: p5 ---- - - -# if diff --git a/src/content/reference/en/p5 copy/image.mdx b/src/content/reference/en/p5 copy/image.mdx deleted file mode 100644 index 9dbd36fd22..0000000000 --- a/src/content/reference/en/p5 copy/image.mdx +++ /dev/null @@ -1,327 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L888 -title: image -module: Image -submodule: Loading & Displaying -file: src/image/loading_displaying.js -description: > -

Draws an image to the canvas.

- -

The first parameter, img, is the source image to be drawn. - img can be - - any of the following objects:

- - - -

The second and third parameters, dx and dy, set - the coordinates of the - - destination image's top left corner. See - - imageMode() for other ways to position - images.

- -

Here's a diagram that explains how optional parameters work in - image():

- -

- -

The fourth and fifth parameters, dw and dh, are - optional. They set the - - the width and height to draw the destination image. By default, - image() - - draws the full source image at its original size.

- -

The sixth and seventh parameters, sx and sy, are - also optional. - - These coordinates define the top left corner of a subsection to draw from - - the source image.

- -

The eighth and ninth parameters, sw and sh, are - also optional. - - They define the width and height of a subsection to draw from the source - - image. By default, image() draws the full subsection that begins - at - - (sx, sy) and extends to the edges of the source image.

- -

The ninth parameter, fit, is also optional. It enables a - subsection of - - the source image to be drawn without affecting its aspect ratio. If - - CONTAIN is passed, the full subsection will appear within the - destination - - rectangle. If COVER is passed, the subsection will completely - cover the - - destination rectangle. This may have the effect of zooming into the - - subsection.

- -

The tenth and eleventh parameters, xAlign and - yAlign, are also - - optional. They determine how to align the fitted subsection. - xAlign can - - be set to either LEFT, RIGHT, or - CENTER. yAlign can be set to - - either TOP, BOTTOM, or CENTER. By - default, both xAlign and yAlign - - are set to CENTER.

-line: 888 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100); - - background(50); - - // Draw the image. - image(img, 0, 0); - - describe('An image of the underside of a white umbrella with a gridded ceiling above.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100); - - background(50); - - // Draw the image. - image(img, 10, 10); - - describe('An image of the underside of a white umbrella with a gridded ceiling above. The image has dark gray borders on its left and top.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100); - - background(50); - - // Draw the image 50x50. - image(img, 0, 0, 50, 50); - - describe('An image of the underside of a white umbrella with a gridded ceiling above. The image is drawn in the top left corner of a dark gray square.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100); - - background(50); - - // Draw the center of the image. - image(img, 25, 25, 50, 50, 25, 25, 50, 50); - - describe('An image of a gridded ceiling drawn in the center of a dark gray square.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/moonwalk.jpg'); - } - - function setup() { - createCanvas(100, 100); - - background(50); - - // Draw the image and scale it to fit within the canvas. - image(img, 0, 0, width, height, 0, 0, img.width, img.height, CONTAIN); - - describe('An image of an astronaut on the moon. The top and bottom borders of the image are dark gray.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - // Image is 50 x 50 pixels. - img = loadImage('/assets/laDefense50.png'); - } - - function setup() { - createCanvas(100, 100); - - background(50); - - // Draw the image and scale it to cover the canvas. - image(img, 0, 0, width, height, 0, 0, img.width, img.height, COVER); - - describe('A pixelated image of the underside of a white umbrella with a gridded ceiling above.'); - } - -
-class: p5 -overloads: - - line: 888 - params: - - name: img - description: | -

image to display.

- type: p5.Image|p5.Element|p5.Texture|p5.Framebuffer|p5.FramebufferTexture - - name: x - description: | -

x-coordinate of the top-left corner of the image.

- type: Number - - name: 'y' - description: | -

y-coordinate of the top-left corner of the image.

- type: Number - - name: width - description: | -

width to draw the image.

- type: Number - optional: true - - name: height - description: | -

height to draw the image.

- type: Number - optional: true - - line: 1074 - params: - - name: img - description: '' - type: p5.Image|p5.Element|p5.Texture|p5.Framebuffer|p5.FramebufferTexture - - name: dx - description: | -

the x-coordinate of the destination - rectangle in which to draw the source image

- type: Number - - name: dy - description: | -

the y-coordinate of the destination - rectangle in which to draw the source image

- type: Number - - name: dWidth - description: | -

the width of the destination rectangle

- type: Number - - name: dHeight - description: | -

the height of the destination rectangle

- type: Number - - name: sx - description: | -

the x-coordinate of the subsection of the source - image to draw into the destination rectangle

- type: Number - - name: sy - description: | -

the y-coordinate of the subsection of the source - image to draw into the destination rectangle

- type: Number - - name: sWidth - description: | -

the width of the subsection of the - source image to draw into the destination - rectangle

- type: Number - optional: true - - name: sHeight - description: | -

the height of the subsection of the - source image to draw into the destination rectangle

- type: Number - optional: true - - name: fit - description: | -

either CONTAIN or COVER

- type: Constant - optional: true - - name: xAlign - description: | -

either LEFT, RIGHT or CENTER default is CENTER

- type: Constant - optional: true - - name: yAlign - description: | -

either TOP, BOTTOM or CENTER default is CENTER

- type: Constant - optional: true -chainable: false ---- - - -# image diff --git a/src/content/reference/en/p5 copy/imageLight.mdx b/src/content/reference/en/p5 copy/imageLight.mdx deleted file mode 100644 index 70b001f3e5..0000000000 --- a/src/content/reference/en/p5 copy/imageLight.mdx +++ /dev/null @@ -1,86 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L956 -title: imageLight -module: 3D -submodule: Lights -file: src/webgl/light.js -description: > -

Creates an ambient light from an image.

- -

imageLight() simulates a light shining from all directions. - The effect is - - like placing the sketch at the center of a giant sphere that uses the image - - as its texture. The image's diffuse light will be affected by - - fill() and the specular reflections will be - - affected by specularMaterial() - and - - shininess().

- -

The parameter, img, is the p5.Image object to - - use as the light source.

-line: 956 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - let img; - - // Load an image and create a p5.Image object. - function preload() { - img = loadImage('/assets/outdoor_spheremap.jpg'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A sphere floating above a landscape. The surface of the sphere reflects the landscape.'); - } - - function draw() { - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the image as a panorama (360˚ background). - panorama(img); - - // Add a soft ambient light. - ambientLight(50); - - // Add light from the image. - imageLight(img); - - // Style the sphere. - specularMaterial(20); - shininess(100); - noStroke(); - - // Draw the sphere. - sphere(30); - } - -
-class: p5 -params: - - name: img - description: | -

image to use as the light source.

- type: p5.image -chainable: false ---- - - -# imageLight diff --git a/src/content/reference/en/p5 copy/imageMode.mdx b/src/content/reference/en/p5 copy/imageMode.mdx deleted file mode 100644 index f7d41c6d54..0000000000 --- a/src/content/reference/en/p5 copy/imageMode.mdx +++ /dev/null @@ -1,129 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L1395 -title: imageMode -module: Image -submodule: Loading & Displaying -file: src/image/loading_displaying.js -description: > -

Changes the location from which images are drawn when - - image() is called.

- -

By default, the first - - two parameters of image() are the x- and - - y-coordinates of the image's upper-left corner. The next parameters are - - its width and height. This is the same as calling - imageMode(CORNER).

- -

imageMode(CORNERS) also uses the first two parameters of - - image() as the x- and y-coordinates of the - image's - - top-left corner. The third and fourth parameters are the coordinates of its - - bottom-right corner.

- -

imageMode(CENTER) uses the first two parameters of - - image() as the x- and y-coordinates of the - image's - - center. The next parameters are its width and height.

-line: 1395 -isConstructor: false -itemtype: method -example: - - |- - - -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Use CORNER mode. - imageMode(CORNER); - - // Display the image. - image(img, 10, 10, 50, 50); - - describe('A square image of a brick wall is drawn at the top left of a gray square.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Use CORNERS mode. - imageMode(CORNERS); - - // Display the image. - image(img, 10, 10, 90, 40); - - describe('An image of a brick wall is drawn on a gray square. The image is squeezed into a small rectangular area.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Use CENTER mode. - imageMode(CENTER); - - // Display the image. - image(img, 50, 50, 80, 80); - - describe('A square image of a brick wall is drawn on a gray square.'); - } - -
-class: p5 -params: - - name: mode - description: | -

either CORNER, CORNERS, or CENTER.

- type: Constant -chainable: false ---- - - -# imageMode diff --git a/src/content/reference/en/p5 copy/input.mdx b/src/content/reference/en/p5 copy/input.mdx deleted file mode 100644 index 83f71feabc..0000000000 --- a/src/content/reference/en/p5 copy/input.mdx +++ /dev/null @@ -1,88 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L405 -title: input -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Calls a function when the element receives input.

- -

myElement.input() is often used to with text inputs and - sliders. Calling - - myElement.input(false) disables the function.

-line: 405 -isConstructor: false -itemtype: method -example: - - |- - -
- - let slider; - - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a slider and place it beneath the canvas. - slider = createSlider(0, 255, 200); - slider.position(0, 100); - - // Call repaint() when the slider changes. - slider.input(repaint); - - describe('A gray square with a range slider underneath it. The background changes shades of gray when the slider is moved.'); - } - - // Paint the background using slider's value. - function repaint() { - let g = slider.value(); - background(g); - } - -
- -
- - let input; - - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an input and place it beneath the canvas. - input = createInput(''); - input.position(0, 100); - - // Call repaint() when input is detected. - input.input(repaint); - - describe('A gray square with a text input bar beneath it. Any text written in the input appears in the middle of the square.'); - } - - // Paint the background gray and display the input's value. - function repaint() { - background(200); - let msg = input.value(); - text(msg, 5, 50); - } - -
-class: p5 -params: - - name: fxn - description: | -

function to call when input is detected within - the element. - false disables the function.

- type: Function|Boolean -chainable: true ---- - - -# input diff --git a/src/content/reference/en/p5 copy/int.mdx b/src/content/reference/en/p5 copy/int.mdx deleted file mode 100644 index 5d5fe8826a..0000000000 --- a/src/content/reference/en/p5 copy/int.mdx +++ /dev/null @@ -1,169 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L92 -title: int -module: Data -submodule: Conversion -file: src/utilities/conversion.js -description: > -

Converts a Boolean, String, or decimal - Number to an integer.

- -

int() converts values to integers. Integers are positive or - negative - - numbers without decimals. If the original value has decimals, as in -34.56, - - they're removed to produce an integer such as -34.

- -

The parameter, n, is the value to convert. If n - is a Boolean, as in - - int(false) or int(true), then the number 0 - (false) or 1 (true) will - - be returned. If n is a string or number, as in - int('45') or - - int(67.89), then an integer will be returned. If an array is - passed, as - - in int([12.34, 56.78]), then an array of integers will be - returned.

- -

Note: If a value can't be converted to a number, as in - int('giraffe'), - - then the value NaN (not a number) will be returned.

-line: 92 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a Boolean variable. - let original = false; - - // Convert the Boolean to an integer. - let converted = int(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the original and converted values. - text(`${original} : ${converted}`, 50, 50); - - describe('The text "false : 0" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let original = '12.34'; - - // Convert the string to an integer. - let converted = int(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(14); - - // Display the original and converted values. - text(`${original} ≈ ${converted}`, 50, 50); - - describe('The text "12.34 ≈ 12" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a decimal number variable. - let original = 12.34; - - // Convert the decimal number to an integer. - let converted = int(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(14); - - // Display the original and converted values. - text(`${original} ≈ ${converted}`, 50, 50); - - describe('The text "12.34 ≈ 12" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of strings. - let original = ['60', '30', '15']; - - // Convert the strings to integers. - let diameters = int(original); - - for (let d of diameters) { - // Draw a circle. - circle(50, 50, d); - } - - describe('Three white, concentric circles on a gray background.'); - } - -
-class: p5 -return: - description: converted number. - type: Number -overloads: - - line: 92 - params: - - name: 'n' - description: | -

value to convert.

- type: String|Boolean|Number - return: - description: converted number. - type: Number - - line: 211 - params: - - name: ns - description: | -

values to convert.

- type: Array - return: - description: converted numbers. - type: 'Number[]' -chainable: false ---- - - -# int diff --git a/src/content/reference/en/p5 copy/isLooping.mdx b/src/content/reference/en/p5 copy/isLooping.mdx deleted file mode 100644 index 622fd77d9b..0000000000 --- a/src/content/reference/en/p5 copy/isLooping.mdx +++ /dev/null @@ -1,65 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L224 -title: isLooping -module: Structure -submodule: Structure -file: src/core/structure.js -description: > -

Returns true if the draw loop is running and - false if not.

- -

By default, draw() tries to run 60 times - per - - second. Calling noLoop() stops - - draw() from repeating. The draw loop can be - - restarted by calling loop().

- -

The isLooping() function can be used to check whether a sketch - is - - looping, as in isLooping() === true.

-line: 224 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A white circle drawn against a gray background. When the user double-clicks, the circle stops or resumes following the mouse.'); - } - - function draw() { - background(200); - - // Draw the circle at the mouse's position. - circle(mouseX, mouseY, 20); - } - - // Toggle the draw loop when the user double-clicks. - function doubleClicked() { - if (isLooping() === true) { - noLoop(); - } else { - loop(); - } - } - -
-class: p5 -return: - description: '' - type: Boolean -chainable: false ---- - - -# isLooping diff --git a/src/content/reference/en/p5 copy/join.mdx b/src/content/reference/en/p5 copy/join.mdx deleted file mode 100644 index 23222a6db4..0000000000 --- a/src/content/reference/en/p5 copy/join.mdx +++ /dev/null @@ -1,70 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L15 -title: join -module: Data -submodule: String Functions -file: src/utilities/string_functions.js -description: > -

Combines an array of strings into one string.

- -

The first parameter, list, is the array of strings to - join.

- -

The second parameter, separator, is the character(s) that - should be used - - to separate the combined strings. For example, calling - - join(myWords, ' : ') would return a string of words each - separated by a - - colon and spaces.

-line: 15 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of strings. - let myWords = ['one', 'two', 'three']; - - // Create a combined string - let combined = join(myWords, ' : '); - - // Style the text. - textAlign(CENTER, CENTER); - - // Display the combined string. - text(combined, 50, 50); - - describe('The text "one : two : three" written in black on a gray canvas.'); - } - -
-class: p5 -params: - - name: list - description: | -

array of strings to combine.

- type: Array - - name: separator - description: | -

character(s) to place between strings when they're combined.

- type: String -return: - description: combined string. - type: String -chainable: false ---- - - -# join diff --git a/src/content/reference/en/p5 copy/key.mdx b/src/content/reference/en/p5 copy/key.mdx deleted file mode 100644 index 63fc144fa3..0000000000 --- a/src/content/reference/en/p5 copy/key.mdx +++ /dev/null @@ -1,106 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L102 -title: key -module: Events -submodule: Keyboard -file: src/events/keyboard.js -description: > -

A String system variable that contains the value of the last - key typed.

- -

The key variable is helpful for checking whether an - - ASCII - - key has been typed. For example, the expression key === "a" - evaluates to - - true if the a key was typed and false - if not. key doesn’t update - - for special keys such as LEFT_ARROW and ENTER. Use - keyCode instead for - - special keys. The keyIsDown() function - should - - be used to check for multiple different key presses at the same time.

-line: 102 -isConstructor: false -itemtype: property -example: - - |- - -
- - // Click on the canvas to begin detecting key presses. - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square. The last key pressed is displayed at the center.' - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the last key pressed. - text(key, 50, 50); - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - let x = 50; - let y = 50; - - function setup() { - createCanvas(100, 100); - - background(200); - - describe( - 'A gray square with a black circle at its center. The circle moves when the user presses the keys "w", "a", "s", or "d". It leaves a trail as it moves.' - ); - } - - function draw() { - // Update x and y if a key is pressed. - if (keyIsPressed === true) { - if (key === 'w') { - y -= 1; - } else if (key === 's') { - y += 1; - } else if (key === 'a') { - x -= 1; - } else if (key === 'd') { - x += 1; - } - } - - // Style the circle. - fill(0); - - // Draw the circle at (x, y). - circle(x, y, 5); - } - -
-class: p5 -type: String ---- - - -# key diff --git a/src/content/reference/en/p5 copy/keyCode.mdx b/src/content/reference/en/p5 copy/keyCode.mdx deleted file mode 100644 index 808526b788..0000000000 --- a/src/content/reference/en/p5 copy/keyCode.mdx +++ /dev/null @@ -1,128 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L184 -title: keyCode -module: Events -submodule: Keyboard -file: src/events/keyboard.js -description: > -

A Number system variable that contains the code of the last - key typed.

- -

All keys have a keyCode. For example, the a key - has the keyCode 65. - - The keyCode variable is helpful for checking whether a special - key has - - been typed. For example, the following conditional checks whether the enter - - key has been typed:

- -
if (keyCode === 13) {
-    // Code to run if the enter key was pressed.
-  }
-
-  
- -

The same code can be written more clearly using the system variable - ENTER - - which has a value of 13:

- -
if (keyCode === ENTER) {
-    // Code to run if the enter key was pressed.
-  }
-
-  
- -

The system variables BACKSPACE, DELETE, - ENTER, RETURN, TAB, - - ESCAPE, SHIFT, CONTROL, - OPTION, ALT, UP_ARROW, - DOWN_ARROW, - - LEFT_ARROW, and RIGHT_ARROW are all helpful - shorthands the key codes of - - special keys. Key codes can be found on websites such as - - keycode.info.

-line: 184 -isConstructor: false -itemtype: property -example: - - |- - -
- - // Click on the canvas to begin detecting key presses. - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square. The last key pressed and its code are displayed at the center.' - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the last key pressed and its code. - text(`${key} : ${keyCode}`, 50, 50); - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - let x = 50; - let y = 50; - - function setup() { - createCanvas(100, 100); - - background(200); - - describe( - 'A gray square with a black circle at its center. The circle moves when the user presses an arrow key. It leaves a trail as it moves.' - ); - } - - function draw() { - // Update x and y if an arrow key is pressed. - if (keyIsPressed === true) { - if (keyCode === UP_ARROW) { - y -= 1; - } else if (keyCode === DOWN_ARROW) { - y += 1; - } else if (keyCode === LEFT_ARROW) { - x -= 1; - } else if (keyCode === RIGHT_ARROW) { - x += 1; - } - } - - // Style the circle. - fill(0); - - // Draw the circle at (x, y). - circle(x, y, 5); - } - -
-class: p5 -type: Integer ---- - - -# keyCode diff --git a/src/content/reference/en/p5 copy/keyIsDown.mdx b/src/content/reference/en/p5 copy/keyIsDown.mdx deleted file mode 100644 index 8afe4b0bdf..0000000000 --- a/src/content/reference/en/p5 copy/keyIsDown.mdx +++ /dev/null @@ -1,142 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L811 -title: keyIsDown -module: Events -submodule: Keyboard -file: src/events/keyboard.js -description: > -

Returns true if the key it’s checking is pressed and - false if not.

- -

keyIsDown() is helpful when checking for multiple different - key presses. - - For example, keyIsDown() can be used to check if both - LEFT_ARROW and - - UP_ARROW are pressed:

- -
if (keyIsDown(LEFT_ARROW) &&
-  keyIsDown(UP_ARROW)) {
-    // Move diagonally.
-  }
-
-  
- -

keyIsDown() can check for key presses using - - keyCode values, as in - keyIsDown(37) or - - keyIsDown(LEFT_ARROW). Key codes can be found on websites such as - - keycode.info.

-line: 811 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click on the canvas to begin detecting key presses. - - let x = 50; - let y = 50; - - function setup() { - createCanvas(100, 100); - - background(200); - - describe( - 'A gray square with a black circle at its center. The circle moves when the user presses an arrow key. It leaves a trail as it moves.' - ); - } - - function draw() { - // Update x and y if an arrow key is pressed. - if (keyIsDown(LEFT_ARROW) === true) { - x -= 1; - } - - if (keyIsDown(RIGHT_ARROW) === true) { - x += 1; - } - - if (keyIsDown(UP_ARROW) === true) { - y -= 1; - } - - if (keyIsDown(DOWN_ARROW) === true) { - y += 1; - } - - // Style the circle. - fill(0); - - // Draw the circle. - circle(x, y, 5); - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - let x = 50; - let y = 50; - - function setup() { - createCanvas(100, 100); - - background(200); - - describe( - 'A gray square with a black circle at its center. The circle moves when the user presses an arrow key. It leaves a trail as it moves.' - ); - } - - function draw() { - // Update x and y if an arrow key is pressed. - if (keyIsDown(37) === true) { - x -= 1; - } - - if (keyIsDown(39) === true) { - x += 1; - } - - if (keyIsDown(38) === true) { - y -= 1; - } - - if (keyIsDown(40) === true) { - y += 1; - } - - // Style the circle. - fill(0); - - // Draw the circle. - circle(x, y, 5); - } - -
-class: p5 -params: - - name: code - description: | -

key to check.

- type: Number -return: - description: whether the key is down or not. - type: Boolean -chainable: false ---- - - -# keyIsDown diff --git a/src/content/reference/en/p5 copy/keyIsPressed.mdx b/src/content/reference/en/p5 copy/keyIsPressed.mdx deleted file mode 100644 index 0b129c49e8..0000000000 --- a/src/content/reference/en/p5 copy/keyIsPressed.mdx +++ /dev/null @@ -1,105 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L10 -title: keyIsPressed -module: Events -submodule: Keyboard -file: src/events/keyboard.js -description: > -

A Boolean system variable that's true if any key - is currently pressed - - and false if not.

-line: 10 -isConstructor: false -itemtype: property -example: - - |- - -
- - // Click on the canvas to begin detecting key presses. - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a white square at its center. The white square turns black when the user presses a key.' - ); - } - - function draw() { - background(200); - - // Style the square. - if (keyIsPressed === true) { - fill(0); - } else { - fill(255); - } - - // Draw the square. - square(25, 25, 50); - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a white square at its center. The white square turns black when the user presses a key.' - ); - } - - function draw() { - background(200); - - // Style the square. - if (keyIsPressed) { - fill(0); - } else { - fill(255); - } - - // Draw the square. - square(25, 25, 50); - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with the word "false" at its center. The word switches to "true" when the user presses a key.' - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the value of keyIsPressed. - text(keyIsPressed, 50, 50); - } - -
-class: p5 -type: Boolean ---- - - -# keyIsPressed diff --git a/src/content/reference/en/p5 copy/keyPressed.mdx b/src/content/reference/en/p5 copy/keyPressed.mdx deleted file mode 100644 index 4a4007f09a..0000000000 --- a/src/content/reference/en/p5 copy/keyPressed.mdx +++ /dev/null @@ -1,192 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L284 -title: keyPressed -module: Events -submodule: Keyboard -file: src/events/keyboard.js -description: > -

A function that's called once when any key is pressed.

- -

Declaring the function keyPressed() sets a code block to run - once - - automatically when the user presses any key:

- -
function keyPressed() {
-    // Code to run.
-  }
-
-  
- -

The key and keyCode - - variables will be updated with the most recently typed value when - - keyPressed() is called by p5.js:

- -
function keyPressed() {
-    if (key === 'c') {
-      // Code to run.
-    }
-
-    if (keyCode === ENTER) {
-      // Code to run.
-    }
-  }
-
-  
- -

The parameter, event, is optional. keyPressed() - is always passed a - - KeyboardEvent - - object with properties that describe the key press event:

- -
function keyPressed(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

Browsers may have default behaviors attached to various key events. For - - example, some browsers may jump to the bottom of a web page when the - - SPACE key is pressed. To prevent any default behavior for this - event, add - - return false; to the end of the function.

-line: 284 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click on the canvas to begin detecting key presses. - - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square changes color when the user presses a key.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Toggle the background color when the user presses a key. - function keyPressed() { - if (value === 0) { - value = 255; - } else { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a white square at its center. The inner square turns black when the user presses the "b" key. It turns white when the user presses the "a" key.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Reassign value when the user presses the 'a' or 'b' key. - function keyPressed() { - if (key === 'a') { - value = 255; - } else if (key === 'b') { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square turns white when the user presses the left arrow key. It turns black when the user presses the right arrow key.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Toggle the background color when the user presses an arrow key. - function keyPressed() { - if (keyCode === LEFT_ARROW) { - value = 255; - } else if (keyCode === RIGHT_ARROW) { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
-class: p5 -params: - - name: event - description: | -

optional KeyboardEvent callback argument.

- type: KeyboardEvent - optional: true -chainable: false ---- - - -# keyPressed diff --git a/src/content/reference/en/p5 copy/keyReleased.mdx b/src/content/reference/en/p5 copy/keyReleased.mdx deleted file mode 100644 index e19da953f1..0000000000 --- a/src/content/reference/en/p5 copy/keyReleased.mdx +++ /dev/null @@ -1,188 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L474 -title: keyReleased -module: Events -submodule: Keyboard -file: src/events/keyboard.js -description: > -

A function that's called once when any key is released.

- -

Declaring the function keyReleased() sets a code block to run - once - - automatically when the user releases any key:

- -
function keyReleased() {
-    // Code to run.
-  }
-
-  
- -

The key and keyCode - - variables will be updated with the most recently released value when - - keyReleased() is called by p5.js:

- -
function keyReleased() {
-    if (key === 'c') {
-      // Code to run.
-    }
-
-    if (keyCode === ENTER) {
-      // Code to run.
-    }
-  }
-
-  
- -

The parameter, event, is optional. keyReleased() - is always passed a - - KeyboardEvent - - object with properties that describe the key press event:

- -
function keyReleased(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

Browsers may have default behaviors attached to various key events. To - - prevent any default behavior for this event, add return false; to - the end - - of the function.

-line: 474 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click on the canvas to begin detecting key presses. - - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square changes color when the user releases a key.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Toggle value when the user releases a key. - function keyReleased() { - if (value === 0) { - value = 255; - } else { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square becomes white when the user releases the "w" key.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Set value to 255 the user releases the 'w' key. - function keyReleased() { - if (key === 'w') { - value = 255; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square turns white when the user presses and releases the left arrow key. It turns black when the user presses and releases the right arrow key.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Toggle the background color when the user releases an arrow key. - function keyReleased() { - if (keyCode === LEFT_ARROW) { - value = 255; - } else if (keyCode === RIGHT_ARROW) { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
-class: p5 -params: - - name: event - description: | -

optional KeyboardEvent callback argument.

- type: KeyboardEvent - optional: true -chainable: false ---- - - -# keyReleased diff --git a/src/content/reference/en/p5 copy/keyTyped.mdx b/src/content/reference/en/p5 copy/keyTyped.mdx deleted file mode 100644 index a591db9e60..0000000000 --- a/src/content/reference/en/p5 copy/keyTyped.mdx +++ /dev/null @@ -1,170 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/keyboard.js#L655 -title: keyTyped -module: Events -submodule: Keyboard -file: src/events/keyboard.js -description: > -

A function that's called once when keys with printable characters are - pressed.

- -

Declaring the function keyTyped() sets a code block to run - once - - automatically when the user presses any key with a printable character such - - as a or 1. Modifier keys such as SHIFT, - CONTROL, and the arrow keys - - will be ignored:

- -
function keyTyped() {
-    // Code to run.
-  }
-
-  
- -

The key and keyCode - - variables will be updated with the most recently released value when - - keyTyped() is called by p5.js:

- -
function keyTyped() {
-    // Check for the "c" character using key.
-    if (key === 'c') {
-      // Code to run.
-    }
-
-    // Check for "c" using keyCode.
-    if (keyCode === 67) {
-      // Code to run.
-    }
-  }
-
-  
- -

The parameter, event, is optional. keyTyped() is - always passed a - - KeyboardEvent - - object with properties that describe the key press event:

- -
function keyReleased(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

Note: Use the keyPressed() function - and - - keyCode system variable to respond to - modifier - - keys such as ALT.

- -

Browsers may have default behaviors attached to various key events. To - - prevent any default behavior for this event, add return false; to - the end - - of the function.

-line: 655 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click on the canvas to begin detecting key presses. - // Note: Pressing special keys such as SPACE have no effect. - - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a white square at its center. The inner square changes color when the user presses a key.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Toggle the square's color when the user types a printable key. - function keyTyped() { - if (value === 0) { - value = 255; - } else { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a white square at its center. The inner square turns black when the user types the "b" key. It turns white when the user types the "a" key.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Reassign value when the user types the 'a' or 'b' key. - function keyTyped() { - if (key === 'a') { - value = 255; - } else if (key === 'b') { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
-class: p5 -params: - - name: event - description: | -

optional KeyboardEvent callback argument.

- type: KeyboardEvent - optional: true -chainable: false ---- - - -# keyTyped diff --git a/src/content/reference/en/p5 copy/lerp.mdx b/src/content/reference/en/p5 copy/lerp.mdx deleted file mode 100644 index 84c4b5bc7a..0000000000 --- a/src/content/reference/en/p5 copy/lerp.mdx +++ /dev/null @@ -1,122 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L332 -title: lerp -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Calculates a number between two numbers at a specific increment.

- -

The amt parameter is the amount to interpolate between the two - numbers. - - 0.0 is equal to the first number, 0.1 is very near the first number, 0.5 is - - half-way in between, and 1.0 is equal to the second number. The - lerp() - - function is convenient for creating motion along a straight path and for - - drawing dotted lines.

- -

If the value of amt is less than 0 or more than 1, - lerp() will return a - - number outside of the original interval. For example, calling - - lerp(0, 10, 1.5) will return 15.

-line: 332 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Declare variables for coordinates. - let a = 20; - let b = 80; - let c = lerp(a, b, 0.2); - let d = lerp(a, b, 0.5); - let e = lerp(a, b, 0.8); - - strokeWeight(5); - - // Draw the original points in black. - stroke(0); - point(a, 50); - point(b, 50); - - // Draw the lerped points in gray. - stroke(100); - point(c, 50); - point(d, 50); - point(e, 50); - - describe('Five points in a horizontal line. The outer points are black and the inner points are gray.'); - } - -
- -
- - let x = 50; - let y = 50; - let targetX = 50; - let targetY = 50; - - function setup() { - createCanvas(100, 100); - - background(200); - - describe('A white circle at the center of a gray canvas. The circle moves to where the user clicks, then moves smoothly back to the center.'); - } - - function draw() { - background(220); - - // Move x and y toward the target. - x = lerp(x, targetX, 0.05); - y = lerp(y, targetY, 0.05); - - // Draw the circle. - circle(x, y, 20); - } - - // Set x and y when the user clicks the mouse. - function mouseClicked() { - x = mouseX; - y = mouseY; - } - -
-class: p5 -params: - - name: start - description: | -

first value.

- type: Number - - name: stop - description: | -

second value.

- type: Number - - name: amt - description: | -

number.

- type: Number -return: - description: lerped value. - type: Number -chainable: false ---- - - -# lerp diff --git a/src/content/reference/en/p5 copy/lerpColor.mdx b/src/content/reference/en/p5 copy/lerpColor.mdx deleted file mode 100644 index d815ba9ddb..0000000000 --- a/src/content/reference/en/p5 copy/lerpColor.mdx +++ /dev/null @@ -1,96 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L949 -title: lerpColor -module: Color -submodule: Creating & Reading -file: src/color/creating_reading.js -description: > -

Blends two colors to find a third color between them.

- -

The amt parameter specifies the amount to interpolate between - the two - - values. 0 is equal to the first color, 0.1 is very near the first color, - - 0.5 is halfway between the two colors, and so on. Negative numbers are set - - to 0. Numbers greater than 1 are set to 1. This differs from the behavior of - - lerp. It's necessary because numbers outside - of the - - interval [0, 1] will produce strange and unexpected colors.

- -

The way that colors are interpolated depends on the current - - colorMode().

-line: 949 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create p5.Color objects to interpolate between. - let from = color(218, 165, 32); - let to = color(72, 61, 139); - - // Create intermediate colors. - let interA = lerpColor(from, to, 0.33); - let interB = lerpColor(from, to, 0.66); - - // Draw the left rectangle. - noStroke(); - fill(from); - rect(10, 20, 20, 60); - - // Draw the left-center rectangle. - fill(interA); - rect(30, 20, 20, 60); - - // Draw the right-center rectangle. - fill(interB); - rect(50, 20, 20, 60); - - // Draw the right rectangle. - fill(to); - rect(70, 20, 20, 60); - - describe( - 'Four rectangles. From left to right, the rectangles are tan, brown, brownish purple, and purple.' - ); - } - -
-class: p5 -params: - - name: c1 - description: > -

interpolate from this color (any value created by the color() - function).

- type: p5.Color - - name: c2 - description: > -

interpolate to this color (any value created by the color() - function).

- type: p5.Color - - name: amt - description: | -

number between 0 and 1.

- type: Number -return: - description: interpolated color. - type: p5.Color -chainable: false ---- - - -# lerpColor diff --git a/src/content/reference/en/p5 copy/let.mdx b/src/content/reference/en/p5 copy/let.mdx deleted file mode 100644 index f04902a9b0..0000000000 --- a/src/content/reference/en/p5 copy/let.mdx +++ /dev/null @@ -1,91 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L7 -title: let -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: > -

Declares a new variable.

- -

A variable is a container for a value. For example, a variable might - - contain a creature's x-coordinate as a Number or its name as a - - String. Variables can change value by reassigning them as - follows:

- -
// Declare the variable x and assign it the
-  value 10.
-
-  let x = 10;
-
-
-  // Reassign x to 50.
-
-  x = 50;
-
-  
- -

Variables have block scope. When a variable is declared between curly - - braces {}, it only exists within the block defined by those - braces. For - - example, the following code would throw a ReferenceError because - x is - - declared within the setup() function's block:

- -
function setup() {
-    createCanvas(100, 100);
-
-    let x = 50;
-  }
-
-
-  function draw() {
-    background(200);
-
-    // x was declared in setup(), so it can't be referenced here.
-    circle(x, 50, 20);
-  }
-
-  
- -

Variables declared outside of all curly braces {} are in the - global - - scope. A variable that's in the global scope can be used and changed - - anywhere in a sketch:

- -
let x = 50;
-
-
-  function setup() {
-    createCanvas(100, 100);
-  }
-
-
-  function draw() {
-    background(200);
-
-    // Change the value of x.
-    x += 10;
-
-    circle(x, 50, 20);
-  }
-
-  
-line: 7 -isConstructor: false -itemtype: property -example: - - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(220);\n\n // Style the text.\n textAlign(CENTER);\n textSize(16);\n\n // Create the message variable.\n let message = 'Hello, \U0001F30D!';\n\n // Display the message.\n text(message, 50, 50);\n\n describe('The text \"Hello, \U0001F30D!\" written on a gray background.');\n}\n\n
\n\n
\n\nlet x = 0;\n\nfunction setup() {\n createCanvas(100, 100);\n\n describe('A white circle moves from left to right against a gray background.');\n}\n\nfunction draw() {\n background(220);\n\n // Change the value of x.\n x += 1;\n\n circle(x, 50, 20);\n}\n\n
" -class: p5 ---- - - -# let diff --git a/src/content/reference/en/p5 copy/lightFalloff.mdx b/src/content/reference/en/p5 copy/lightFalloff.mdx deleted file mode 100644 index e8b8245064..0000000000 --- a/src/content/reference/en/p5 copy/lightFalloff.mdx +++ /dev/null @@ -1,100 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L1161 -title: lightFalloff -module: 3D -submodule: Lights -file: src/webgl/light.js -description: > -

Sets the falloff rate for pointLight() - - and spotLight().

- -

A light’s falloff describes the intensity of its beam at a distance. For - - example, a lantern has a slow falloff, a flashlight has a medium falloff, - - and a laser pointer has a sharp falloff.

- -

lightFalloff() has three parameters, constant, - linear, and - - quadratic. They’re numbers used to calculate falloff at a - distance, d, - - as follows:

- -

falloff = 1 / (constant + d * linear + (d * d) * - quadratic)

- -

Note: constant, linear, and - quadratic should always be set to values - - greater than 0.

-line: 1161 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click to change the falloff rate. - - let useFalloff = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A sphere drawn against a gray background. The intensity of the light changes when the user double-clicks.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Set the light falloff. - if (useFalloff === true) { - lightFalloff(2, 0, 0); - } - - // Add a white point light from the front. - pointLight(255, 255, 255, 0, 0, 100); - - // Style the sphere. - noStroke(); - - // Draw the sphere. - sphere(30); - } - - // Change the falloff value when the user double-clicks. - function doubleClicked() { - useFalloff = true; - } - -
-class: p5 -params: - - name: constant - description: | -

constant value for calculating falloff.

- type: Number - - name: linear - description: | -

linear value for calculating falloff.

- type: Number - - name: quadratic - description: | -

quadratic value for calculating falloff.

- type: Number -chainable: true ---- - - -# lightFalloff diff --git a/src/content/reference/en/p5 copy/lightness.mdx b/src/content/reference/en/p5 copy/lightness.mdx deleted file mode 100644 index 284523dcc8..0000000000 --- a/src/content/reference/en/p5 copy/lightness.mdx +++ /dev/null @@ -1,168 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L1134 -title: lightness -module: Color -submodule: Creating & Reading -file: src/color/creating_reading.js -description: > -

Gets the lightness value of a color.

- -

lightness() extracts the HSL lightness value from a - - p5.Color object, an array of color - components, or - - a CSS color string.

- -

By default, lightness() returns a color's HSL lightness in the - range 0 - - to 100. If the colorMode() is set to - HSL, it - - returns the lightness value in the given range.

-line: 1134 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(50); - - // Use HSL color. - colorMode(HSL); - - // Create a p5.Color object using HSL values. - let c = color(0, 100, 75); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'lightValue' to 75. - let lightValue = lightness(c); - - // Draw the right rectangle. - fill(lightValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is gray.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(50); - - // Use HSL color. - colorMode(HSL); - - // Create a color array. - let c = [0, 100, 75]; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'lightValue' to 75. - let lightValue = lightness(c); - - // Draw the right rectangle. - fill(lightValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is gray.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(50); - - // Use HSL color. - colorMode(HSL); - - // Create a CSS color string. - let c = 'rgb(255, 128, 128)'; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'lightValue' to 75. - let lightValue = lightness(c); - - // Draw the right rectangle. - fill(lightValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is gray.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(50); - - // Use HSL color with values in the range 0-255. - colorMode(HSL, 255); - - // Create a p5.Color object using HSL values. - let c = color(0, 255, 191.5); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'lightValue' to 191.5. - let lightValue = lightness(c); - - // Draw the right rectangle. - fill(lightValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is gray.'); - } - -
-class: p5 -params: - - name: color - description: | -

p5.Color object, array of - color components, or CSS color string.

- type: 'p5.Color|Number[]|String' -return: - description: the lightness value. - type: Number -chainable: false ---- - - -# lightness diff --git a/src/content/reference/en/p5 copy/lights.mdx b/src/content/reference/en/p5 copy/lights.mdx deleted file mode 100644 index a7cf3ba7ae..0000000000 --- a/src/content/reference/en/p5 copy/lights.mdx +++ /dev/null @@ -1,88 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L1077 -title: lights -module: 3D -submodule: Lights -file: src/webgl/light.js -description: | -

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.

-line: 1077 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click to turn on the lights. - - let isLit = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white box drawn against a gray background. The quality of the light changes when the user double-clicks.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Control the lights. - if (isLit === true) { - lights(); - } - - // Draw the box. - box(); - } - - // Turn on the lights when the user double-clicks. - function doubleClicked() { - isLit = true; - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white box drawn against a gray background.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - ambientLight(128, 128, 128); - directionalLight(128, 128, 128, 0, 0, -1); - - // Draw the box. - box(); - } - -
-class: p5 -chainable: true ---- - - -# lights diff --git a/src/content/reference/en/p5 copy/line.mdx b/src/content/reference/en/p5 copy/line.mdx deleted file mode 100644 index b225222235..0000000000 --- a/src/content/reference/en/p5 copy/line.mdx +++ /dev/null @@ -1,194 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L564 -title: line -module: Shape -submodule: 2D Primitives -file: src/core/shape/2d_primitives.js -description: > -

Draws a straight line between two points.

- -

A line's default width is one pixel. The version of line() - with four - - parameters draws the line in 2D. To color a line, use the - - stroke() function. To change its width, - use the - - strokeWeight() function. A line - - can't be filled, so the fill() function - won't - - affect the line's color.

- -

The version of line() with six parameters allows the line to - be drawn in - - 3D space. Doing so requires adding the WEBGL argument to - - createCanvas().

-line: 564 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - line(30, 20, 85, 75); - - describe( - 'A black line on a gray canvas running from top-center to bottom-right.' - ); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the line. - stroke('magenta'); - strokeWeight(5); - - line(30, 20, 85, 75); - - describe( - 'A thick, magenta line on a gray canvas running from top-center to bottom-right.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Top. - line(30, 20, 85, 20); - - // Right. - stroke(126); - line(85, 20, 85, 75); - - // Bottom. - stroke(255); - line(85, 75, 30, 75); - - describe( - 'Three lines drawn in grayscale on a gray canvas. They form the top, right, and bottom sides of a square.' - ); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - line(-20, -30, 35, 25); - - describe( - 'A black line on a gray canvas running from top-center to bottom-right.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A black line connecting two spheres. The scene spins slowly.'); - } - - function draw() { - background(200); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Draw a line. - line(0, 0, 0, 30, 20, -10); - - // Draw the center sphere. - sphere(10); - - // Translate to the second point. - translate(30, 20, -10); - - // Draw the bottom-right sphere. - sphere(10); - } - -
-class: p5 -overloads: - - line: 564 - params: - - name: x1 - description: | -

the x-coordinate of the first point.

- type: Number - - name: y1 - description: | -

the y-coordinate of the first point.

- type: Number - - name: x2 - description: | -

the x-coordinate of the second point.

- type: Number - - name: y2 - description: | -

the y-coordinate of the second point.

- type: Number - chainable: 1 - - line: 696 - params: - - name: x1 - description: '' - type: Number - - name: y1 - description: '' - type: Number - - name: z1 - description: | -

the z-coordinate of the first point.

- type: Number - - name: x2 - description: '' - type: Number - - name: y2 - description: '' - type: Number - - name: z2 - description: | -

the z-coordinate of the second point.

- type: Number - chainable: 1 -chainable: true ---- - - -# line diff --git a/src/content/reference/en/p5 copy/linePerspective.mdx b/src/content/reference/en/p5 copy/linePerspective.mdx deleted file mode 100644 index 80bf539c73..0000000000 --- a/src/content/reference/en/p5 copy/linePerspective.mdx +++ /dev/null @@ -1,164 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L280 -title: linePerspective -module: 3D -submodule: Camera -file: src/webgl/p5.Camera.js -description: > -

Enables or disables perspective for lines in 3D sketches.

- -

In WebGL mode, lines can be drawn with a thinner stroke when they’re - - further from the camera. Doing so gives them a more realistic appearance.

- -

By default, lines are drawn differently based on the type of perspective - - being used:

- -
    - -
  • perspective() and frustum() simulate a realistic - perspective. In - - these modes, stroke weight is affected by the line’s distance from the - - camera. Doing so results in a more natural appearance. - perspective() is - - the default mode for 3D sketches.
  • - -
  • ortho() doesn’t simulate a realistic perspective. In this - mode, stroke - - weights are consistent regardless of the line’s distance from the camera. - - Doing so results in a more predictable and consistent appearance.
  • - -
- -

linePerspective() can override the default line drawing - mode.

- -

The parameter, enable, is optional. It’s a - Boolean value that sets the - - way lines are drawn. If true is passed, as in - linePerspective(true), - - then lines will appear thinner when they are further from the camera. If - - false is passed, as in linePerspective(false), then - lines will have - - consistent stroke weights regardless of their distance from the camera. By - - default, linePerspective() is enabled.

- -

Calling linePerspective() without passing an argument returns - true if - - it's enabled and false if not.

- -

Note: linePerspective() can only be used in WebGL mode.

-line: 280 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Double-click the canvas to toggle the line perspective. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'A white cube with black edges on a gray background. Its edges toggle between thick and thin when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Translate the origin toward the camera. - translate(-10, 10, 600); - - // Rotate the coordinate system. - rotateY(-0.1); - rotateX(-0.1); - - // Draw the row of boxes. - for (let i = 0; i < 6; i += 1) { - translate(0, 0, -40); - box(10); - } - } - - // Toggle the line perspective when the user double-clicks. - function doubleClicked() { - let isEnabled = linePerspective(); - linePerspective(!isEnabled); - } - -
- -
- - // Double-click the canvas to toggle the line perspective. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'A row of cubes with black edges on a gray background. Their edges toggle between thick and thin when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Use an orthographic projection. - ortho(); - - // Translate the origin toward the camera. - translate(-10, 10, 600); - - // Rotate the coordinate system. - rotateY(-0.1); - rotateX(-0.1); - - // Draw the row of boxes. - for (let i = 0; i < 6; i += 1) { - translate(0, 0, -40); - box(10); - } - } - - // Toggle the line perspective when the user double-clicks. - function doubleClicked() { - let isEnabled = linePerspective(); - linePerspective(!isEnabled); - } - -
-class: p5 -overloads: - - line: 280 - params: - - name: enable - description: | -

whether to enable line perspective.

- type: Boolean - - line: 392 - params: [] - return: - description: whether line perspective is enabled. - type: Boolean -chainable: false ---- - - -# linePerspective diff --git a/src/content/reference/en/p5 copy/loadBytes.mdx b/src/content/reference/en/p5 copy/loadBytes.mdx deleted file mode 100644 index 8b02c0683e..0000000000 --- a/src/content/reference/en/p5 copy/loadBytes.mdx +++ /dev/null @@ -1,56 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L986 -title: loadBytes -module: IO -submodule: Input -file: src/io/files.js -description: | -

This method is suitable for fetching files up to size of 64MB.

-line: 986 -isConstructor: false -itemtype: method -example: - - |- - -
- let data; - - function preload() { - data = loadBytes('/assets/mammals.xml'); - } - - function setup() { - for (let i = 0; i < 5; i++) { - console.log(data.bytes[i].toString(16)); - } - describe('no image displayed'); - } -
-class: p5 -params: - - name: file - description: | -

name of the file or URL to load

- type: String - - name: callback - description: | -

function to be executed after loadBytes() - completes

- type: Function - optional: true - - name: errorCallback - description: | -

function to be executed if there - is an error

- type: Function - optional: true -return: - description: an object whose 'bytes' property will be the loaded buffer - type: Object -chainable: false ---- - - -# loadBytes diff --git a/src/content/reference/en/p5 copy/loadFont.mdx b/src/content/reference/en/p5 copy/loadFont.mdx deleted file mode 100644 index 86af4b7123..0000000000 --- a/src/content/reference/en/p5 copy/loadFont.mdx +++ /dev/null @@ -1,171 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/loading_displaying.js#L16 -title: loadFont -module: Typography -submodule: Loading & Displaying -file: src/typography/loading_displaying.js -description: > -

Loads a font and creates a p5.Font - object. - - loadFont() can load fonts in either .otf or .ttf format. Loaded - fonts can - - be used to style text on the canvas and in HTML elements.

- -

The first parameter, path, is the path to a font file. - - Paths to local files should be relative. For example, - - '/assets/inconsolata.otf'. The Inconsolata font used in the - following - - examples can be downloaded for free - - here. - - Paths to remote files should be URLs. For example, - - 'https://example.com/inconsolata.otf'. URLs may be blocked due to - browser - - security.

- -

The second parameter, successCallback, is optional. If a - function is - - passed, it will be called once the font has loaded. The callback function - - may use the new p5.Font object if - needed.

- -

The third parameter, failureCallback, is also optional. If a - function is - - passed, it will be called if the font fails to load. The callback function - - may use the error - - Event - - object if needed.

- -

Fonts can take time to load. Calling loadFont() in - - preload() ensures fonts load before - they're - - used in setup() or - - draw().

-line: 16 -isConstructor: false -itemtype: method -example: - - |- - - -
- - let font; - - function preload() { - font = loadFont('/assets/inconsolata.otf'); - } - - function setup() { - fill('deeppink'); - textFont(font); - textSize(36); - text('p5*js', 10, 50); - - describe('The text "p5*js" written in pink on a white background.'); - } - -
- -
- - function setup() { - loadFont('/assets/inconsolata.otf', font => { - fill('deeppink'); - textFont(font); - textSize(36); - text('p5*js', 10, 50); - - describe('The text "p5*js" written in pink on a white background.'); - }); - } - -
- -
- - function setup() { - loadFont('/assets/inconsolata.otf', success, failure); - } - - function success(font) { - fill('deeppink'); - textFont(font); - textSize(36); - text('p5*js', 10, 50); - - describe('The text "p5*js" written in pink on a white background.'); - } - - function failure(event) { - console.error('Oops!', event); - } - -
- -
- - function preload() { - loadFont('/assets/inconsolata.otf'); - } - - function setup() { - let p = createP('p5*js'); - p.style('color', 'deeppink'); - p.style('font-family', 'Inconsolata'); - p.style('font-size', '36px'); - p.position(10, 50); - - describe('The text "p5*js" written in pink on a white background.'); - } - -
-class: p5 -params: - - name: path - description: | -

path of the font to be loaded.

- type: String - - name: successCallback - description: | -

function called with the - p5.Font object after it - loads.

- type: Function - optional: true - - name: failureCallback - description: | -

function called with the error - Event - object if the font fails to load.

- type: Function - optional: true -return: - description: p5.Font object. - type: p5.Font -chainable: false ---- - - -# loadFont diff --git a/src/content/reference/en/p5 copy/loadImage.mdx b/src/content/reference/en/p5 copy/loadImage.mdx deleted file mode 100644 index 7e5b8bf0b7..0000000000 --- a/src/content/reference/en/p5 copy/loadImage.mdx +++ /dev/null @@ -1,137 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L18 -title: loadImage -module: Image -submodule: Loading & Displaying -file: src/image/loading_displaying.js -description: > -

Loads an image to create a p5.Image - object.

- -

loadImage() interprets the first parameter one of three ways. - If the path - - to an image file is provided, loadImage() will load it. Paths to - local - - files should be relative, such as '/assets/thundercat.jpg'. URLs - such as - - 'https://example.com/thundercat.jpg' may be blocked due to - browser - - security. Raw image data can also be passed as a base64 encoded image in - - the form 'data:image/png;base64,arandomsequenceofcharacters'.

- -

The second parameter is optional. If a function is passed, it will be - - called once the image has loaded. The callback function can optionally use - - the new p5.Image object.

- -

The third parameter is also optional. If a function is passed, it will be - - called if the image fails to load. The callback function can optionally use - - the event error.

- -

Images can take time to load. Calling loadImage() in - - preload() ensures images load before - they're - - used in setup() or draw().

-line: 18 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load the image and create a p5.Image object. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Draw the image. - image(img, 0, 0); - - describe('Image of the underside of a white umbrella and a gridded ceiling.'); - } - -
- -
- - function setup() { - // Call handleImage() once the image loads. - loadImage('/assets/laDefense.jpg', handleImage); - - describe('Image of the underside of a white umbrella and a gridded ceiling.'); - } - - // Display the image. - function handleImage(img) { - image(img, 0, 0); - } - -
- -
- - function setup() { - // Call handleImage() once the image loads or - // call handleError() if an error occurs. - loadImage('/assets/laDefense.jpg', handleImage, handleError); - } - - // Display the image. - function handleImage(img) { - image(img, 0, 0); - - describe('Image of the underside of a white umbrella and a gridded ceiling.'); - } - - // Log the error. - function handleError(event) { - console.error('Oops!', event); - } - -
-class: p5 -params: - - name: path - description: | -

path of the image to be loaded or base64 encoded image.

- type: String - - name: successCallback - description: | -

function called with - p5.Image once it - loads.

- type: function(p5.Image) - optional: true - - name: failureCallback - description: | -

function called with event - error if the image fails to load.

- type: Function(Event) - optional: true -return: - description: the p5.Image object. - type: p5.Image -chainable: false ---- - - -# loadImage diff --git a/src/content/reference/en/p5 copy/loadJSON.mdx b/src/content/reference/en/p5 copy/loadJSON.mdx deleted file mode 100644 index 95fd0552b5..0000000000 --- a/src/content/reference/en/p5 copy/loadJSON.mdx +++ /dev/null @@ -1,288 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L17 -title: loadJSON -module: IO -submodule: Input -file: src/io/files.js -description: > -

Loads a JSON file to create an Object.

- -

JavaScript Object Notation - - (JSON) - - is a standard format for sending data between applications. The format is - - based on JavaScript objects which have keys and values. JSON files store - - data in an object with strings as keys. Values can be strings, numbers, - - Booleans, arrays, null, or other objects.

- -

The first parameter, path, is always a string with the path to - the file. - - Paths to local files should be relative, as in - - loadJSON('/assets/data.json'). URLs such as - - 'https://example.com/data.json' may be blocked due to browser - security.

- -

The second parameter, successCallback, is optional. If a - function is - - passed, as in loadJSON('/assets/data.json', handleData), then the - - handleData() function will be called once the data loads. The - object - - created from the JSON data will be passed to handleData() as its - only argument.

- -

The third parameter, failureCallback, is also optional. If a - function is - - passed, as in loadJSON('/assets/data.json', handleData, - handleFailure), - - then the handleFailure() function will be called if an error - occurs while - - loading. The Error object will be passed to - handleFailure() as its only - - argument.

- -

Note: Data can take time to load. Calling loadJSON() within - - preload() ensures data loads before it's - used in - - setup() or draw().

-line: 17 -isConstructor: false -itemtype: method -example: - - |- - - -
- - let myData; - - // Load the JSON and create an object. - function preload() { - myData = loadJSON('/assets/data.json'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the circle. - fill(myData.color); - noStroke(); - - // Draw the circle. - circle(myData.x, myData.y, myData.d); - - describe('A pink circle on a gray background.'); - } - -
- -
- - let myData; - - // Load the JSON and create an object. - function preload() { - myData = loadJSON('/assets/data.json'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object and make it transparent. - let c = color(myData.color); - c.setAlpha(80); - - // Style the circles. - fill(c); - noStroke(); - - // Iterate over the myData.bubbles array. - for (let b of myData.bubbles) { - // Draw a circle for each bubble. - circle(b.x, b.y, b.d); - } - - describe('Several pink bubbles floating in a blue sky.'); - } - -
- -
- - let myData; - - // Load the GeoJSON and create an object. - function preload() { - myData = loadJSON('https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Get data about the most recent earthquake. - let quake = myData.features[0].properties; - - // Draw a circle based on the earthquake's magnitude. - circle(50, 50, quake.mag * 10); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(11); - - // Display the earthquake's location. - text(quake.place, 5, 80, 100); - - describe(`A white circle on a gray background. The text "${quake.place}" is written beneath the circle.`); - } - -
- -
- - let bigQuake; - - // Load the GeoJSON and preprocess it. - function preload() { - loadJSON( - 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson', - handleData - ); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw a circle based on the earthquake's magnitude. - circle(50, 50, bigQuake.mag * 10); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(11); - - // Display the earthquake's location. - text(bigQuake.place, 5, 80, 100); - - describe(`A white circle on a gray background. The text "${bigQuake.place}" is written beneath the circle.`); - } - - // Find the biggest recent earthquake. - function handleData(data) { - let maxMag = 0; - // Iterate over the earthquakes array. - for (let quake of data.features) { - // Reassign bigQuake if a larger - // magnitude quake is found. - if (quake.properties.mag > maxMag) { - bigQuake = quake.properties; - } - } - } - -
- -
- - let bigQuake; - - // Load the GeoJSON and preprocess it. - function preload() { - loadJSON( - 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson', - handleData, - handleError - ); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw a circle based on the earthquake's magnitude. - circle(50, 50, bigQuake.mag * 10); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(11); - - // Display the earthquake's location. - text(bigQuake.place, 5, 80, 100); - - describe(`A white circle on a gray background. The text "${bigQuake.place}" is written beneath the circle.`); - } - - // Find the biggest recent earthquake. - function handleData(data) { - let maxMag = 0; - // Iterate over the earthquakes array. - for (let quake of data.features) { - // Reassign bigQuake if a larger - // magnitude quake is found. - if (quake.properties.mag > maxMag) { - bigQuake = quake.properties; - } - } - } - - // Log any errors to the console. - function handleError(error) { - console.log('Oops!', error); - } - -
-class: p5 -params: - - name: path - description: | -

path of the JSON file to be loaded.

- type: String - - name: successCallback - description: > -

function to call once the data is loaded. Will be passed the - object.

- type: Function - optional: true - - name: errorCallback - description: > -

function to call if the data fails to load. Will be passed an - Error event object.

- type: Function - optional: true -return: - description: object containing the loaded data. - type: Object -chainable: false ---- - - -# loadJSON diff --git a/src/content/reference/en/p5 copy/loadModel.mdx b/src/content/reference/en/p5 copy/loadModel.mdx deleted file mode 100644 index 56b2230e1e..0000000000 --- a/src/content/reference/en/p5 copy/loadModel.mdx +++ /dev/null @@ -1,469 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/loading.js#L13 -title: loadModel -module: Shape -submodule: 3D Models -file: src/webgl/loading.js -description: > -

Loads a 3D model to create a - - p5.Geometry object.

- -

loadModel() can load 3D models from OBJ and STL files. Once - the model is - - loaded, it can be displayed with the - - model() function, as in - model(shape).

- -

There are three ways to call loadModel() with optional - parameters to help - - process the model.

- -

The first parameter, path, is always a String - with the path to the - - file. Paths to local files should be relative, as in - - loadModel('/assets/model.obj'). URLs such as - - 'https://example.com/model.obj' may be blocked due to browser - security.

- -

Note: When loading a .obj file that references materials - stored in - - .mtl files, p5.js will attempt to load and apply those materials. - - To ensure that the .obj file reads the .mtl file - correctly include the - - .mtl file alongside it.

- -

The first way to call loadModel() has three optional - parameters after the - - file path. The first optional parameter, successCallback, is a - function - - to call once the model loads. For example, - - loadModel('/assets/model.obj', handleModel) will call the - handleModel() - - function once the model loads. The second optional parameter, - - failureCallback, is a function to call if the model fails to - load. For - - example, loadModel('/assets/model.obj', handleModel, - handleFailure) will - - call the handleFailure() function if an error occurs while - loading. The - - third optional parameter, fileType, is the model’s file extension - as a - - string. For example, - - loadModel('/assets/model', handleModel, handleFailure, '.obj') - will try to - - load the file model as a .obj file.

- -

The second way to call loadModel() has four optional - parameters after the - - file path. The first optional parameter is a Boolean value. If - true is - - passed, as in loadModel('/assets/model.obj', true), then the - model will be - - resized to ensure it fits the canvas. The next three parameters are - - successCallback, failureCallback, and - fileType as described above.

- -

The third way to call loadModel() has one optional parameter - after the - - file path. The optional parameter, options, is an - Object with options, - - as in loadModel('/assets/model.obj', options). The - options object can - - have the following properties:

- -
let options = {
-    // Enables standardized size scaling during loading if set to true.
-    normalize: true,
-
-    // Function to call once the model loads.
-    successCallback: handleModel,
-
-    // Function to call if an error occurs while loading.
-    failureCallback: handleError,
-
-    // Model's file extension.
-    fileType: '.stl',
-
-    // Flips the U texture coordinates of the model.
-    flipU: false,
-
-    // Flips the V texture coordinates of the model.
-    flipV: false
-  };
-
-
-  // Pass the options object to loadModel().
-
-  loadModel('/assets/model.obj', options);
-
-  
- -

Models can take time to load. Calling loadModel() in - - preload() ensures models load before - they're - - used in setup() or draw().

- -

Note: There’s no support for colored STL files. STL files with color will - - be rendered without color.

-line: 13 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - // Load the file and create a p5.Geometry object. - function preload() { - shape = loadModel('/assets/teapot.obj'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white teapot drawn against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the shape. - model(shape); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - // Load the file and create a p5.Geometry object. - // Normalize the geometry's size to fit the canvas. - function preload() { - shape = loadModel('/assets/teapot.obj', true); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white teapot drawn against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the shape. - model(shape); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - // Load the file and create a p5.Geometry object. - function preload() { - loadModel('/assets/teapot.obj', true, handleModel); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white teapot drawn against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the shape. - model(shape); - } - - // Set the shape variable and log the geometry's - // ID to the console. - function handleModel(data) { - shape = data; - console.log(shape.gid); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - // Load the file and create a p5.Geometry object. - function preload() { - loadModel('/assets/wrong.obj', true, handleModel, handleError); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white teapot drawn against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the shape. - model(shape); - } - - // Set the shape variable and print the geometry's - // ID to the console. - function handleModel(data) { - shape = data; - console.log(shape.gid); - } - - // Print an error message if the file doesn't load. - function handleError(error) { - console.error('Oops!', error); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - // Load the file and create a p5.Geometry object. - function preload() { - loadModel('/assets/teapot.obj', true, handleModel, handleError, '.obj'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white teapot drawn against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the shape. - model(shape); - } - - // Set the shape variable and print the geometry's - // ID to the console. - function handleModel(data) { - shape = data; - console.log(shape.gid); - } - - // Print an error message if the file doesn't load. - function handleError(error) { - console.error('Oops!', error); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - let options = { - normalize: true, - successCallback: handleModel, - failureCallback: handleError, - fileType: '.obj' - }; - - // Load the file and create a p5.Geometry object. - function preload() { - loadModel('/assets/teapot.obj', options); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white teapot drawn against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the shape. - model(shape); - } - - // Set the shape variable and print the geometry's - // ID to the console. - function handleModel(data) { - shape = data; - console.log(shape.gid); - } - - // Print an error message if the file doesn't load. - function handleError(error) { - console.error('Oops!', error); - } - -
-class: p5 -return: - description: the p5.Geometry object - type: p5.Geometry -overloads: - - line: 13 - params: - - name: path - description: | -

path of the model to be loaded.

- type: String - - name: normalize - description: | -

if true, scale the model to fit the canvas.

- type: Boolean - - name: successCallback - description: | -

function to call once the model is loaded. Will be passed - the p5.Geometry object.

- type: function(p5.Geometry) - optional: true - - name: failureCallback - description: > -

function to call if the model fails to load. Will be passed an - Error event object.

- type: Function(Event) - optional: true - - name: fileType - description: > -

model’s file extension. Either '.obj' or - '.stl'.

- type: String - optional: true - return: - description: the p5.Geometry object - type: p5.Geometry - - line: 324 - params: - - name: path - description: '' - type: String - - name: successCallback - description: '' - type: function(p5.Geometry) - optional: true - - name: failureCallback - description: '' - type: Function(Event) - optional: true - - name: fileType - description: '' - type: String - optional: true - return: - description: new p5.Geometry object. - type: p5.Geometry - - line: 332 - params: - - name: path - description: '' - type: String - - name: options - description: | -

loading options.

- type: Object - optional: true - props: - - name: successCallback - description: '' - type: function(p5.Geometry) - optional: true - - name: failureCallback - description: '' - type: Function(Event) - optional: true - - name: fileType - description: '' - type: String - optional: true - - name: normalize - description: '' - type: Boolean - optional: true - - name: flipU - description: '' - type: Boolean - optional: true - - name: flipV - description: '' - type: Boolean - optional: true - return: - description: new p5.Geometry object. - type: p5.Geometry -chainable: false ---- - - -# loadModel diff --git a/src/content/reference/en/p5 copy/loadPixels.mdx b/src/content/reference/en/p5 copy/loadPixels.mdx deleted file mode 100644 index 424a87765f..0000000000 --- a/src/content/reference/en/p5 copy/loadPixels.mdx +++ /dev/null @@ -1,61 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L946 -title: loadPixels -module: Image -submodule: Pixels -file: src/image/pixels.js -description: | -

Loads the current value of each pixel on the canvas into the - pixels array.

-

loadPixels() must be called before reading from or writing to - pixels.

-line: 946 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/rockies.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0, 100, 100); - - // Get the pixel density. - let d = pixelDensity(); - - // Calculate the halfway index in the pixels array. - let halfImage = 4 * (d * width) * (d * height / 2); - - // Load the pixels array. - loadPixels(); - - // Copy the top half of the canvas to the bottom. - for (let i = 0; i < halfImage; i += 1) { - pixels[i + halfImage] = pixels[i]; - } - - // Update the canvas. - updatePixels(); - - describe('Two identical images of mountain landscapes, one on top of the other.'); - } - -
-class: p5 -chainable: false ---- - - -# loadPixels diff --git a/src/content/reference/en/p5 copy/loadShader.mdx b/src/content/reference/en/p5 copy/loadShader.mdx deleted file mode 100644 index 1180e6c487..0000000000 --- a/src/content/reference/en/p5 copy/loadShader.mdx +++ /dev/null @@ -1,172 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L12 -title: loadShader -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Loads vertex and fragment shaders to create a - - p5.Shader object.

- -

Shaders are programs that run on the graphics processing unit (GPU). They - - can process many pixels at the same time, making them fast for many - - graphics tasks. They’re written in a language called - - GLSL - - and run along with the rest of the code in a sketch.

- -

Once the p5.Shader object is created, - it can be - - used with the shader() function, as in - - shader(myShader). A shader program consists of two files, a - vertex shader - - and a fragment shader. The vertex shader affects where 3D geometry is drawn - - on the screen and the fragment shader affects color.

- -

loadShader() loads the vertex and fragment shaders from their - .vert and - - .frag files. For example, calling - - loadShader('/assets/shader.vert', '/assets/shader.frag') loads - both - - required shaders and returns a p5.Shader - object.

- -

The third parameter, successCallback, is optional. If a - function is - - passed, it will be called once the shader has loaded. The callback function - - can use the new p5.Shader object as its - - parameter.

- -

The fourth parameter, failureCallback, is also optional. If a - function is - - passed, it will be called if the shader fails to load. The callback - - function can use the event error as its parameter.

- -

Shaders can take time to load. Calling loadShader() in - - preload() ensures shaders load before - they're - - used in setup() or draw().

- -

Note: Shaders can only be used in WebGL mode.

-line: 12 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Note: A "uniform" is a global variable within a shader program. - - let mandelbrot; - - // Load the shader and create a p5.Shader object. - function preload() { - mandelbrot = loadShader('/assets/shader.vert', '/assets/shader.frag'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - // Compile and apply the p5.Shader object. - shader(mandelbrot); - - // Set the shader uniform p to an array. - mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); - - // Set the shader uniform r to the value 1.5. - mandelbrot.setUniform('r', 1.5); - - // Add a quad as a display surface for the shader. - quad(-1, -1, 1, -1, 1, 1, -1, 1); - - describe('A black fractal image on a magenta background.'); - } - -
- -
- - // Note: A "uniform" is a global variable within a shader program. - - let mandelbrot; - - // Load the shader and create a p5.Shader object. - function preload() { - mandelbrot = loadShader('/assets/shader.vert', '/assets/shader.frag'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - // Use the p5.Shader object. - shader(mandelbrot); - - // Set the shader uniform p to an array. - mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); - - describe('A fractal image zooms in and out of focus.'); - } - - function draw() { - // Set the shader uniform r to a value that oscillates between 0 and 2. - mandelbrot.setUniform('r', sin(frameCount * 0.01) + 1); - - // Add a quad as a display surface for the shader. - quad(-1, -1, 1, -1, 1, 1, -1, 1); - } - -
-class: p5 -params: - - name: vertFilename - description: | -

path of the vertex shader to be loaded.

- type: String - - name: fragFilename - description: | -

path of the fragment shader to be loaded.

- type: String - - name: successCallback - description: | -

function to call once the shader is loaded. Can be passed the - p5.Shader object.

- type: Function - optional: true - - name: failureCallback - description: | -

function to call if the shader fails to load. Can be passed an - Error event object.

- type: Function - optional: true -return: - description: new shader created from the vertex and fragment shader files. - type: p5.Shader -chainable: false ---- - - -# loadShader diff --git a/src/content/reference/en/p5 copy/loadSound.mdx b/src/content/reference/en/p5 copy/loadSound.mdx deleted file mode 100644 index be9dd1ac29..0000000000 --- a/src/content/reference/en/p5 copy/loadSound.mdx +++ /dev/null @@ -1,78 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L2946 -title: loadSound -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: | -

loadSound() returns a new p5.SoundFile from a specified - path. If called during preload(), the p5.SoundFile will be ready - to play in time for setup() and draw(). If called outside of - preload, the p5.SoundFile will not be ready immediately, so - loadSound accepts a callback as the second parameter. Using a - - local server is recommended when loading external files.

-line: 2946 -isConstructor: false -itemtype: method -example: - - |- - -
- let mySound; - function preload() { - soundFormats('mp3', 'ogg'); - mySound = loadSound('/assets/doorbell'); - } - - function setup() { - let cnv = createCanvas(100, 100); - cnv.mousePressed(canvasPressed); - background(220); - text('tap here to play', 10, 20); - } - - function canvasPressed() { - // playing a sound file on a user gesture - // is equivalent to `userStartAudio()` - mySound.play(); - } -
-class: p5 -params: - - name: path - description: | -

Path to the sound file, or an array with - paths to soundfiles in multiple formats - i.e. ['sound.ogg', 'sound.mp3']. - Alternately, accepts an object: either - from the HTML5 File API, or a p5.File.

- type: String|Array - - name: successCallback - description: | -

Name of a function to call once file loads

- type: Function - optional: true - - name: errorCallback - description: | -

Name of a function to call if there is - an error loading the file.

- type: Function - optional: true - - name: whileLoading - description: | -

Name of a function to call while file is loading. - This function will receive the percentage loaded - so far, from 0.0 to 1.0.

- type: Function - optional: true -return: - description: Returns a p5.SoundFile - type: SoundFile -chainable: false ---- - - -# loadSound diff --git a/src/content/reference/en/p5 copy/loadStrings.mdx b/src/content/reference/en/p5 copy/loadStrings.mdx deleted file mode 100644 index ce011835bc..0000000000 --- a/src/content/reference/en/p5 copy/loadStrings.mdx +++ /dev/null @@ -1,188 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L309 -title: loadStrings -module: IO -submodule: Input -file: src/io/files.js -description: > -

Loads a text file to create an Array.

- -

The first parameter, path, is always a string with the path to - the file. - - Paths to local files should be relative, as in - - loadStrings('/assets/data.txt'). URLs such as - - 'https://example.com/data.txt' may be blocked due to browser - security.

- -

The second parameter, successCallback, is optional. If a - function is - - passed, as in loadStrings('/assets/data.txt', handleData), then - the - - handleData() function will be called once the data loads. The - array - - created from the text data will be passed to handleData() as its - only - - argument.

- -

The third parameter, failureCallback, is also optional. If a - function is - - passed, as in loadStrings('/assets/data.txt', handleData, - handleFailure), - - then the handleFailure() function will be called if an error - occurs while - - loading. The Error object will be passed to - handleFailure() as its only - - argument.

- -

Note: Data can take time to load. Calling loadStrings() within - - preload() ensures data loads before it's - used in - - setup() or draw().

-line: 309 -isConstructor: false -itemtype: method -example: - - |- - - -
- - let myData; - - // Load the text and create an array. - function preload() { - myData = loadStrings('/assets/test.txt'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Select a random line from the text. - let phrase = random(myData); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(12); - - // Display the text. - text(phrase, 10, 50, 90); - - describe(`The text "${phrase}" written in black on a gray background.`); - } - -
- -
- - let lastLine; - - // Load the text and preprocess it. - function preload() { - loadStrings('/assets/test.txt', handleData); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(12); - - // Display the text. - text(lastLine, 10, 50, 90); - - describe('The text "I talk like an orange" written in black on a gray background.'); - } - - // Select the last line from the text. - function handleData(data) { - lastLine = data[data.length - 1]; - } - -
- -
- - let lastLine; - - // Load the text and preprocess it. - function preload() { - loadStrings('/assets/test.txt', handleData, handleError); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(12); - - // Display the text. - text(lastLine, 10, 50, 90); - - describe('The text "I talk like an orange" written in black on a gray background.'); - } - - // Select the last line from the text. - function handleData(data) { - lastLine = data[data.length - 1]; - } - - // Log any errors to the console. - function handleError(error) { - console.error('Oops!', error); - } - -
-class: p5 -params: - - name: path - description: | -

path of the text file to be loaded.

- type: String - - name: successCallback - description: | -

function to call once the data is - loaded. Will be passed the array.

- type: Function - optional: true - - name: errorCallback - description: | -

function to call if the data fails to - load. Will be passed an Error event - object.

- type: Function - optional: true -return: - description: new array containing the loaded text. - type: 'String[]' -chainable: false ---- - - -# loadStrings diff --git a/src/content/reference/en/p5 copy/loadTable.mdx b/src/content/reference/en/p5 copy/loadTable.mdx deleted file mode 100644 index d93e40a3da..0000000000 --- a/src/content/reference/en/p5 copy/loadTable.mdx +++ /dev/null @@ -1,124 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L505 -title: loadTable -module: IO -submodule: Input -file: src/io/files.js -description: > -

Reads the contents of a file or URL and creates a p5.Table object with - - its values. If a file is specified, it must be located in the sketch's - - "data" folder. The filename parameter can also be a URL to a file found - - online. By default, the file is assumed to be comma-separated (in CSV - - format). Table only looks for a header row if the 'header' option is - - included.

- -

This method is asynchronous, meaning it may not finish before the next - - line in your sketch is executed. Calling loadTable() inside preload() - - guarantees to complete the operation before setup() and draw() are called. - - Outside of preload(), you may supply a - callback function to handle the - - object:

- -

All files loaded and saved use UTF-8 encoding. This method is suitable for - fetching files up to size of 64MB.

-line: 505 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Given the following CSV file called "mammals.csv" - // located in the project's "assets" folder: - // - // id,species,name - // 0,Capra hircus,Goat - // 1,Panthera pardus,Leopard - // 2,Equus zebra,Zebra - - let table; - - function preload() { - //my table is comma separated value "csv" - //and has a header specifying the columns labels - table = loadTable('/assets/mammals.csv', 'csv', 'header'); - //the file can be remote - //table = loadTable("https://p5js.org/reference//assets/mammals.csv", - // "csv", "header"); - } - - function setup() { - //count the columns - print(table.getRowCount() + ' total rows in table'); - print(table.getColumnCount() + ' total columns in table'); - - print(table.getColumn('name')); - //["Goat", "Leopard", "Zebra"] - - //cycle through the table - for (let r = 0; r < table.getRowCount(); r++) - 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"`); - } - -
-class: p5 -params: - - name: filename - description: | -

name of the file or URL to load

- type: String - - name: extension - description: | -

parse the table by comma-separated values "csv", semicolon-separated - values "ssv", or tab-separated values "tsv"

- type: String - optional: true - - name: header - description: | -

"header" to indicate table has header row

- type: String - optional: true - - name: callback - description: | -

function to be executed after - loadTable() completes. On success, the - Table object is passed in as the - first argument.

- type: Function - optional: true - - name: errorCallback - description: | -

function to be executed if - there is an error, response is passed - in as first argument

- type: Function - optional: true -return: - description: Table object containing data - type: Object -chainable: false ---- - - -# loadTable diff --git a/src/content/reference/en/p5 copy/loadXML.mdx b/src/content/reference/en/p5 copy/loadXML.mdx deleted file mode 100644 index 859a3c895d..0000000000 --- a/src/content/reference/en/p5 copy/loadXML.mdx +++ /dev/null @@ -1,220 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L780 -title: loadXML -module: IO -submodule: Input -file: src/io/files.js -description: > -

Loads an XML file to create a p5.XML - object.

- -

Extensible Markup Language - - (XML) - - is a standard format for sending data between applications. Like HTML, the - - XML format is based on tags and attributes, as in - - .

- -

The first parameter, path, is always a string with the path to - the file. - - Paths to local files should be relative, as in - - loadXML('/assets/data.xml'). URLs such as - 'https://example.com/data.xml' - - may be blocked due to browser security.

- -

The second parameter, successCallback, is optional. If a - function is - - passed, as in loadXML('/assets/data.xml', handleData), then the - - handleData() function will be called once the data loads. The - - p5.XML object created from the data will be - passed - - to handleData() as its only argument.

- -

The third parameter, failureCallback, is also optional. If a - function is - - passed, as in loadXML('/assets/data.xml', handleData, - handleFailure), then - - the handleFailure() function will be called if an error occurs - while - - loading. The Error object will be passed to - handleFailure() as its only - - argument.

- -

Note: Data can take time to load. Calling loadXML() within - - preload() ensures data loads before it's - used in - - setup() or draw().

-line: 780 -isConstructor: false -itemtype: method -example: - - |- - -
- - let myXML; - - // Load the XML and create a p5.XML object. - function preload() { - myXML = loadXML('/assets/animals.xml'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Get an array with all mammal tags. - let mammals = myXML.getChildren('mammal'); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(14); - - // Iterate over the mammals array. - for (let i = 0; i < mammals.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 25; - - // Get the mammal's common name. - let name = mammals[i].getContent(); - - // Display the mammal's name. - text(name, 20, y); - } - - describe( - 'The words "Goat", "Leopard", and "Zebra" written on three separate lines. The text is black on a gray background.' - ); - } - -
- -
- - let lastMammal; - - // Load the XML and create a p5.XML object. - function preload() { - loadXML('/assets/animals.xml', handleData); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(CENTER, CENTER); - textFont('Courier New'); - textSize(16); - - // Display the content of the last mammal element. - text(lastMammal, 50, 50); - - describe('The word "Zebra" written in black on a gray background.'); - } - - // Get the content of the last mammal element. - function handleData(data) { - // Get an array with all mammal elements. - let mammals = data.getChildren('mammal'); - - // Get the content of the last mammal. - lastMammal = mammals[mammals.length - 1].getContent(); - } - -
- -
- - let lastMammal; - - // Load the XML and preprocess it. - function preload() { - loadXML('/assets/animals.xml', handleData, handleError); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(CENTER, CENTER); - textFont('Courier New'); - textSize(16); - - // Display the content of the last mammal element. - text(lastMammal, 50, 50); - - describe('The word "Zebra" written in black on a gray background.'); - } - - // Get the content of the last mammal element. - function handleData(data) { - // Get an array with all mammal elements. - let mammals = data.getChildren('mammal'); - - // Get the content of the last mammal. - lastMammal = mammals[mammals.length - 1].getContent(); - } - - // Log any errors to the console. - function handleError(error) { - console.error('Oops!', error); - } - -
-class: p5 -params: - - name: path - description: | -

path of the XML file to be loaded.

- type: String - - name: successCallback - description: | -

function to call once the data is - loaded. Will be passed the - p5.XML object.

- type: Function - optional: true - - name: errorCallback - description: | -

function to call if the data fails to - load. Will be passed an Error event - object.

- type: Function - optional: true -return: - description: |- - XML data loaded into a p5.XML - object. - type: p5.XML -chainable: false ---- - - -# loadXML diff --git a/src/content/reference/en/p5 copy/log.mdx b/src/content/reference/en/p5 copy/log.mdx deleted file mode 100644 index c84c6d5a4b..0000000000 --- a/src/content/reference/en/p5 copy/log.mdx +++ /dev/null @@ -1,79 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L423 -title: log -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Calculates the natural logarithm (the base-e logarithm) of a number.

- -

log() expects the n parameter to be a value - greater than 0 because - - the natural logarithm is defined that way.

-line: 423 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Top-left. - let d = log(50); - circle(33, 33, d); - - // Bottom-right. - d = log(500000000); - circle(67, 67, d); - - describe('Two white circles. The circle at the top-left is small. The circle at the bottom-right is about five times larger.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - describe('A series of black dots that get higher slowly from left to right.'); - } - - function draw() { - // Invert the y-axis. - scale(1, -1); - translate(0, -100); - - // Calculate coordinates. - let x = frameCount; - let y = 15 * log(x); - - // Draw a point. - point(x, y); - } - -
-class: p5 -params: - - name: 'n' - description: | -

number greater than 0.

- type: Number -return: - description: natural logarithm of n. - type: Number -chainable: false ---- - - -# log diff --git a/src/content/reference/en/p5 copy/loop.mdx b/src/content/reference/en/p5 copy/loop.mdx deleted file mode 100644 index a73432d2c1..0000000000 --- a/src/content/reference/en/p5 copy/loop.mdx +++ /dev/null @@ -1,111 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L127 -title: loop -module: Structure -submodule: Structure -file: src/core/structure.js -description: > -

Resumes the draw loop after noLoop() - has been - - called.

- -

By default, draw() tries to run 60 times - per - - second. Calling noLoop() stops - - draw() from repeating. The draw loop can be - - restarted by calling loop().

- -

The isLooping() function can be used - to check - - whether a sketch is looping, as in isLooping() === true.

-line: 127 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Turn off the draw loop. - noLoop(); - - describe( - 'A white half-circle on the left edge of a gray square. The circle starts moving to the right when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Calculate the circle's x-coordinate. - let x = frameCount; - - // Draw the circle. - circle(x, 50, 20); - } - - // Resume the draw loop when the user double-clicks. - function doubleClicked() { - loop(); - } - -
- -
- - let startButton; - let stopButton; - - function setup() { - createCanvas(100, 100); - - // Create the button elements and place them - // beneath the canvas. - startButton = createButton('▶'); - startButton.position(0, 100); - startButton.size(50, 20); - stopButton = createButton('◾'); - stopButton.position(50, 100); - stopButton.size(50, 20); - - // Set functions to call when the buttons are pressed. - startButton.mousePressed(loop); - stopButton.mousePressed(noLoop); - - // Slow the frame rate. - frameRate(5); - - describe( - 'A white circle moves randomly on a gray background. Play and stop buttons are shown beneath the canvas. The circle stops or starts moving when the user presses a button.' - ); - } - - function draw() { - background(200); - - // Calculate the circle's coordinates. - let x = random(0, 100); - let y = random(0, 100); - - // Draw the circle. - // Normally, the circle would move from left to right. - circle(x, y, 20); - } - -
-class: p5 -chainable: false ---- - - -# loop diff --git a/src/content/reference/en/p5 copy/mag.mdx b/src/content/reference/en/p5 copy/mag.mdx deleted file mode 100644 index 4d46565b07..0000000000 --- a/src/content/reference/en/p5 copy/mag.mdx +++ /dev/null @@ -1,84 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L481 -title: mag -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Calculates the magnitude, or length, of a vector.

- -

A vector can be thought of in different ways. In one view, a vector is a - - point in space. The vector's components, x and y, - are the point's - - coordinates (x, y). A vector's magnitude is the distance from the - origin - - (0, 0) to (x, y). mag(x, y) is a - shortcut for calling - - dist(0, 0, x, y).

- -

A vector can also be thought of as an arrow pointing in space. This view is - - helpful for programming motion. See p5.Vector for - - more details.

- -

Use p5.Vector.mag() to calculate - the - - magnitude of a p5.Vector object.

-line: 481 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Set the vector's components. - let x = 30; - let y = 40; - - // Calculate the magnitude. - let m = mag(x, y); - - // Style the text. - textSize(16); - - // Display the vector and its magnitude. - line(0, 0, x, y); - text(m, x, y); - - describe('A diagonal line is drawn from the top left of the canvas. The number 50 is written at the end of the line.'); - } - -
-class: p5 -params: - - name: x - description: | -

first component.

- type: Number - - name: 'y' - description: | -

second component.

- type: Number -return: - description: magnitude of vector. - type: Number -chainable: false ---- - - -# mag diff --git a/src/content/reference/en/p5 copy/map.mdx b/src/content/reference/en/p5 copy/map.mdx deleted file mode 100644 index a94e6e4dd7..0000000000 --- a/src/content/reference/en/p5 copy/map.mdx +++ /dev/null @@ -1,119 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L534 -title: map -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Re-maps a number from one range to another.

- -

For example, calling map(2, 0, 10, 0, 100) returns 20. The - first three - - arguments set the original value to 2 and the original range from 0 to 10. - - The last two arguments set the target range from 0 to 100. 20's position - - in the target range [0, 100] is proportional to 2's position in the - - original range [0, 10].

- -

The sixth parameter, withinBounds, is optional. By default, - map() can - - return values outside of the target range. For example, - - map(11, 0, 10, 0, 100) returns 110. Passing true as - the sixth parameter - - constrains the remapped value to the target range. For example, - - map(11, 0, 10, 0, 100, true) returns 100.

-line: 534 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('Two horizontal lines. The top line grows horizontally as the mouse moves to the right. The bottom line also grows horizontally but is scaled to stay on the left half of the canvas.'); - } - - function draw() { - background(200); - - // Draw the top line. - line(0, 25, mouseX, 25); - - // Remap mouseX from [0, 100] to [0, 50]. - let x = map(mouseX, 0, 100, 0, 50); - - // Draw the bottom line. - line(0, 75, x, 75); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A circle changes color from black to white as the mouse moves from left to right.'); - } - - function draw() { - background(200); - - // Remap mouseX from [0, 100] to [0, 255] - let c = map(mouseX, 0, 100, 0, 255); - - // Style the circle. - fill(c); - - // Draw the circle. - circle(50, 50, 20); - } - -
-class: p5 -params: - - name: value - description: | -

the value to be remapped.

- type: Number - - name: start1 - description: | -

lower bound of the value's current range.

- type: Number - - name: stop1 - description: | -

upper bound of the value's current range.

- type: Number - - name: start2 - description: | -

lower bound of the value's target range.

- type: Number - - name: stop2 - description: | -

upper bound of the value's target range.

- type: Number - - name: withinBounds - description: | -

constrain the value to the newly mapped range.

- type: Boolean - optional: true -return: - description: remapped number. - type: Number -chainable: false ---- - - -# map diff --git a/src/content/reference/en/p5 copy/match.mdx b/src/content/reference/en/p5 copy/match.mdx deleted file mode 100644 index c93425e96d..0000000000 --- a/src/content/reference/en/p5 copy/match.mdx +++ /dev/null @@ -1,91 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L60 -title: match -module: Data -submodule: String Functions -file: src/utilities/string_functions.js -description: > -

Applies a regular expression to a string and returns an array with the - - first match.

- -

match() uses regular expressions (regex) to match patterns in - text. For - - example, the regex abc can be used to search a string for the - exact - - sequence of characters abc. See - - MDN. - - for more information about regexes.

- -

The first parameter, str, is the string to search.

- -

The second parameter, regex, is a string with the regular - expression to - - apply. For example, calling match('Hello, p5*js!', '[a-z][0-9]') - would - - return the array ['p5'].

- -

Note: If no matches are found, null is returned.

-line: 60 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let string = 'Hello, p5*js!'; - - // Match the characters that are lowercase - // letters followed by digits. - let matches = match(string, '[a-z][0-9]'); - - // Print the matches array to the console: - // ['p5'] - print(matches); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the matches. - text(matches, 50, 50); - - describe('The text "p5" written in black on a gray canvas.'); - } - -
-class: p5 -params: - - name: str - description: | -

string to search.

- type: String - - name: regexp - description: | -

regular expression to match.

- type: String -return: - description: match if found. - type: 'String[]' -chainable: false ---- - - -# match diff --git a/src/content/reference/en/p5 copy/matchAll.mdx b/src/content/reference/en/p5 copy/matchAll.mdx deleted file mode 100644 index 371d596b61..0000000000 --- a/src/content/reference/en/p5 copy/matchAll.mdx +++ /dev/null @@ -1,107 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L119 -title: matchAll -module: Data -submodule: String Functions -file: src/utilities/string_functions.js -description: > -

Applies a regular expression to a string and returns an array of - matches.

- -

match() uses regular expressions (regex) to match patterns in - text. For - - example, the regex abc can be used to search a string for the - exact - - sequence of characters abc. See - - MDN. - - for more information about regexes. matchAll() is different from - - match() because it returns every match, not - just - - the first.

- -

The first parameter, str, is the string to search.

- -

The second parameter, regex, is a string with the regular - expression to - - apply. For example, calling - - matchAll('p5*js is easier than abc123', '[a-z][0-9]') would - return the - - 2D array [['p5'], ['c1']].

- -

Note: If no matches are found, an empty array [] is - returned.

-line: 119 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let string = 'p5*js is easier than abc123'; - - // Match the character sequences that are - // lowercase letters followed by digits. - let matches = matchAll(string, '[a-z][0-9]'); - - // Print the matches array to the console: - // [['p5'], ['c1']] - print(matches); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Iterate over the matches array. - for (let i = 0; i < matches.length; i += 1) { - - // Calculate the y-coordainate. - let y = (i + 1) * 33; - - // Display the match. - text(matches[i], 50, y); - } - - describe( - 'The text "p5" and "c1" written on separate lines. The text is black on a gray background.' - ); - } - -
-class: p5 -params: - - name: str - description: | -

string to search.

- type: String - - name: regexp - description: | -

regular expression to match.

- type: String -return: - description: matches found. - type: 'String[]' -chainable: false ---- - - -# matchAll diff --git a/src/content/reference/en/p5 copy/max.mdx b/src/content/reference/en/p5 copy/max.mdx deleted file mode 100644 index 0dd0ee142c..0000000000 --- a/src/content/reference/en/p5 copy/max.mdx +++ /dev/null @@ -1,104 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L618 -title: max -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Returns the largest value in a sequence of numbers.

- -

The version of max() with one parameter interprets it as an - array of - - numbers and returns the largest number.

- -

The version of max() with two or more parameters interprets - them as - - individual numbers and returns the largest number.

-line: 618 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Calculate the maximum of 10, 5, and 20. - let m = max(10, 5, 20); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the max. - text(m, 50, 50); - - describe('The number 20 written in the middle of a gray square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of numbers. - let numbers = [10, 5, 20]; - - // Calculate the maximum of the array. - let m = max(numbers); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the max. - text(m, 50, 50); - - describe('The number 20 written in the middle of a gray square.'); - } - -
-class: p5 -return: - description: maximum number. - type: Number -overloads: - - line: 618 - params: - - name: n0 - description: | -

first number to compare.

- type: Number - - name: n1 - description: | -

second number to compare.

- type: Number - return: - description: maximum number. - type: Number - - line: 680 - params: - - name: nums - description: | -

numbers to compare.

- type: 'Number[]' - return: - description: '' - type: Number -chainable: false ---- - - -# max diff --git a/src/content/reference/en/p5 copy/metalness.mdx b/src/content/reference/en/p5 copy/metalness.mdx deleted file mode 100644 index ef378bc2a9..0000000000 --- a/src/content/reference/en/p5 copy/metalness.mdx +++ /dev/null @@ -1,142 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L3069 -title: metalness -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Sets the amount of "metalness" of a - - specularMaterial().

- -

metalness() can make materials appear more metallic. It - affects the way - - materials reflect light sources including - - affects the way materials reflect light sources including - - directionalLight(), - - pointLight(), - - spotLight(), and - - imageLight().

- -

The parameter, metallic, is a number that sets the amount of - metalness. - - metallic must be greater than 1, which is its default value. - Higher - - values, such as metalness(100), make specular materials appear - more - - metallic.

-line: 3069 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'Two blue spheres drawn on a gray background. White light reflects from their surfaces as the mouse moves. The right sphere is more metallic than the left sphere.' - ); - } - - function draw() { - background(200); - - // Turn on an ambient light. - ambientLight(200); - - // Get the mouse's coordinates. - let mx = mouseX - 50; - let my = mouseY - 50; - - // Turn on a white point light that follows the mouse. - pointLight(255, 255, 255, mx, my, 50); - - // Style the spheres. - noStroke(); - fill(30, 30, 255); - specularMaterial(255); - shininess(20); - - // Draw the left sphere with low metalness. - translate(-25, 0, 0); - metalness(1); - sphere(20); - - // Draw the right sphere with high metalness. - translate(50, 0, 0); - metalness(50); - sphere(20); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let img; - - function preload() { - img = loadImage('/assets/outdoor_spheremap.jpg'); - } - - function setup() { - createCanvas(100 ,100 ,WEBGL); - - describe( - 'Two spheres floating above a landscape. The surface of the spheres reflect the landscape. The right sphere is more reflective than the left sphere.' - ); - } - - function draw() { - // Add the panorama. - panorama(img); - - // Enable orbiting with the mouse. - orbitControl(); - - // Use the image as a light source. - imageLight(img); - - // Style the spheres. - noStroke(); - specularMaterial(50); - shininess(200); - - // Draw the left sphere with low metalness. - translate(-25, 0, 0); - metalness(1); - sphere(20); - - // Draw the right sphere with high metalness. - translate(50, 0, 0); - metalness(50); - sphere(20); - } - -
-class: p5 -params: - - name: metallic - description: | -

amount of metalness.

- type: Number -chainable: false ---- - - -# metalness diff --git a/src/content/reference/en/p5 copy/midiToFreq.mdx b/src/content/reference/en/p5 copy/midiToFreq.mdx deleted file mode 100644 index ada29d80ea..0000000000 --- a/src/content/reference/en/p5 copy/midiToFreq.mdx +++ /dev/null @@ -1,66 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L841 -title: midiToFreq -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: | -

Returns the frequency value of a MIDI note value. - General MIDI treats notes as integers where middle C - is 60, C# is 61, D is 62 etc. Useful for generating - musical frequencies with oscillators.

-line: 841 -isConstructor: false -itemtype: method -example: - - |- - -
- let midiNotes = [60, 64, 67, 72]; - let noteIndex = 0; - let midiVal, freq; - - function setup() { - let cnv = createCanvas(100, 100); - cnv.mousePressed(startSound); - osc = new p5.TriOsc(); - env = new p5.Envelope(); - } - - function draw() { - background(220); - text('tap to play', 10, 20); - if (midiVal) { - text('MIDI: ' + midiVal, 10, 40); - text('Freq: ' + freq, 10, 60); - } - } - - function startSound() { - // see also: userStartAudio(); - osc.start(); - - midiVal = midiNotes[noteIndex % midiNotes.length]; - freq = midiToFreq(midiVal); - osc.freq(freq); - env.ramp(osc, 0, 1.0, 0); - - noteIndex++; - } -
-class: p5 -params: - - name: midiNote - description: | -

The number of a MIDI note

- type: Number -return: - description: Frequency value of the given MIDI note - type: Number -chainable: false ---- - - -# midiToFreq diff --git a/src/content/reference/en/p5 copy/millis.mdx b/src/content/reference/en/p5 copy/millis.mdx deleted file mode 100644 index 18f1ac06d0..0000000000 --- a/src/content/reference/en/p5 copy/millis.mdx +++ /dev/null @@ -1,147 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L112 -title: millis -module: IO -submodule: Time & Date -file: src/utilities/time_date.js -description: > -

Returns the number of milliseconds since a sketch started running.

- -

millis() keeps track of how long a sketch has been running in - - milliseconds (thousandths of a second). This information is often - - helpful for timing events and animations.

- -

If a sketch has a - - setup() function, then - millis() begins tracking - - time before the code in setup() runs. If a - - sketch includes a preload() function, - then - - millis() begins tracking time as soon as the code in - - preload() starts running.

-line: 112 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Get the number of milliseconds the sketch has run. - let ms = millis(); - - // Style the text. - textAlign(LEFT, CENTER); - textSize(10); - textFont('Courier New'); - - // Display how long it took setup() to be called. - text(`Startup time: ${round(ms, 2)} ms`, 5, 50, 90); - - describe( - `The text 'Startup time: ${round(ms, 2)} ms' written in black on a gray background.` - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('The text "Running time: S sec" written in black on a gray background. The number S increases as the sketch runs.'); - } - - function draw() { - background(200); - - // Get the number of seconds the sketch has run. - let s = millis() / 1000; - - // Style the text. - textAlign(LEFT, CENTER); - textSize(10); - textFont('Courier New'); - - // Display how long the sketch has run. - text(`Running time: ${nf(s, 1, 1)} sec`, 5, 50, 90); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A white circle oscillates left and right on a gray background.'); - } - - function draw() { - background(200); - - // Get the number of seconds the sketch has run. - let s = millis() / 1000; - - // Calculate an x-coordinate. - let x = 30 * sin(s) + 50; - - // Draw the circle. - circle(x, 50, 30); - } - -
- -
- - // Load the GeoJSON. - function preload() { - loadJSON('https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Get the number of milliseconds the sketch has run. - let ms = millis(); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(11); - - // Display how long it took to load the data. - text(`It took ${round(ms, 2)} ms to load the data`, 5, 50, 100); - - describe( - `The text "It took ${round(ms, 2)} ms to load the data" written in black on a gray background.` - ); - } - -
-class: p5 -return: - description: number of milliseconds since starting the sketch. - type: Number -chainable: false ---- - - -# millis diff --git a/src/content/reference/en/p5 copy/min.mdx b/src/content/reference/en/p5 copy/min.mdx deleted file mode 100644 index 67af3b37f1..0000000000 --- a/src/content/reference/en/p5 copy/min.mdx +++ /dev/null @@ -1,104 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L695 -title: min -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Returns the smallest value in a sequence of numbers.

- -

The version of min() with one parameter interprets it as an - array of - - numbers and returns the smallest number.

- -

The version of min() with two or more parameters interprets - them as - - individual numbers and returns the smallest number.

-line: 695 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Calculate the minimum of 10, 5, and 20. - let m = min(10, 5, 20); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the min. - text(m, 50, 50); - - describe('The number 5 written in the middle of a gray square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of numbers. - let numbers = [10, 5, 20]; - - // Calculate the minimum of the array. - let m = min(numbers); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the min. - text(m, 50, 50); - - describe('The number 5 written in the middle of a gray square.'); - } - -
-class: p5 -return: - description: minimum number. - type: Number -overloads: - - line: 695 - params: - - name: n0 - description: | -

first number to compare.

- type: Number - - name: n1 - description: | -

second number to compare.

- type: Number - return: - description: minimum number. - type: Number - - line: 757 - params: - - name: nums - description: | -

numbers to compare.

- type: 'Number[]' - return: - description: '' - type: Number -chainable: false ---- - - -# min diff --git a/src/content/reference/en/p5 copy/minute.mdx b/src/content/reference/en/p5 copy/minute.mdx deleted file mode 100644 index 3ac966c800..0000000000 --- a/src/content/reference/en/p5 copy/minute.mdx +++ /dev/null @@ -1,47 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L78 -title: minute -module: IO -submodule: Time & Date -file: src/utilities/time_date.js -description: | -

Returns the current minute as a number from 0–59.

-line: 78 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Get the current minute. - let m = minute(); - - // Style the text. - textAlign(LEFT, CENTER); - textSize(12); - textFont('Courier New'); - - // Display the minute. - text(`Current minute: ${m}`, 10, 50, 80); - - describe(`The text 'Current minute: ${m}' written in black on a gray background.`); - } - -
-class: p5 -return: - description: current minute between 0 and 59. - type: Integer -chainable: false ---- - - -# minute diff --git a/src/content/reference/en/p5 copy/model.mdx b/src/content/reference/en/p5 copy/model.mdx deleted file mode 100644 index e925350407..0000000000 --- a/src/content/reference/en/p5 copy/model.mdx +++ /dev/null @@ -1,155 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/loading.js#L991 -title: model -module: Shape -submodule: 3D Models -file: src/webgl/loading.js -description: > -

Draws a p5.Geometry object to the - canvas.

- -

The parameter, model, is the - - p5.Geometry object to draw. - - p5.Geometry objects can be built with - - buildGeometry(), or - - beginGeometry() and - - endGeometry(). They can also be - loaded from - - a file with loadGeometry().

- -

Note: model() can only be used in WebGL mode.

-line: 991 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the p5.Geometry object. - shape = buildGeometry(createShape); - - describe('A white cone drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the p5.Geometry object. - model(shape); - } - - // Create p5.Geometry object from a single cone. - function createShape() { - cone(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the p5.Geometry object. - shape = buildGeometry(createArrow); - - describe('Two white arrows drawn on a gray background. The arrow on the right rotates slowly.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the arrows. - noStroke(); - - // Draw the p5.Geometry object. - model(shape); - - // Translate and rotate the coordinate system. - translate(30, 0, 0); - rotateZ(frameCount * 0.01); - - // Draw the p5.Geometry object again. - model(shape); - } - - function createArrow() { - // Add shapes to the p5.Geometry object. - push(); - rotateX(PI); - cone(10); - translate(0, -10, 0); - cylinder(3, 20); - pop(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let shape; - - // Load the file and create a p5.Geometry object. - function preload() { - shape = loadModel('/assets/octahedron.obj'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white octahedron drawn against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the shape. - model(shape); - } - -
-class: p5 -params: - - name: model - description: | -

3D shape to be drawn.

- type: p5.Geometry -chainable: false ---- - - -# model diff --git a/src/content/reference/en/p5 copy/month.mdx b/src/content/reference/en/p5 copy/month.mdx deleted file mode 100644 index d2e248235c..0000000000 --- a/src/content/reference/en/p5 copy/month.mdx +++ /dev/null @@ -1,47 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L242 -title: month -module: IO -submodule: Time & Date -file: src/utilities/time_date.js -description: | -

Returns the current month as a number from 1–12.

-line: 242 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Get the current month. - let m = month(); - - // Style the text. - textAlign(LEFT, CENTER); - textSize(12); - textFont('Courier New'); - - // Display the month. - text(`Current month: ${m}`, 10, 50, 80); - - describe(`The text 'Current month: ${m}' written in black on a gray background.`); - } - -
-class: p5 -return: - description: current month between 1 and 12. - type: Integer -chainable: false ---- - - -# month diff --git a/src/content/reference/en/p5 copy/mouseButton.mdx b/src/content/reference/en/p5 copy/mouseButton.mdx deleted file mode 100644 index 82128f97a3..0000000000 --- a/src/content/reference/en/p5 copy/mouseButton.mdx +++ /dev/null @@ -1,87 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L687 -title: mouseButton -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A String system variable that contains the value of the last mouse button - - pressed.

- -

The mouseButton variable is either LEFT, - RIGHT, or CENTER, - - depending on which button was pressed last.

- -

Note: Different browsers may track mouseButton differently. - See - - MDN - - for more information.

-line: 687 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with black text at its center. The text changes from 0 to either "left" or "right" when the user clicks a mouse button.' - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the mouse button. - text(mouseButton, 50, 50); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - "A gray square. Different shapes appear at its center depending on the mouse button that's clicked." - ); - } - - function draw() { - background(200); - - if (mouseIsPressed === true) { - if (mouseButton === LEFT) { - circle(50, 50, 50); - } - if (mouseButton === RIGHT) { - square(25, 25, 50); - } - if (mouseButton === CENTER) { - triangle(23, 75, 50, 20, 78, 75); - } - } - } - -
-class: p5 -type: Constant ---- - - -# mouseButton diff --git a/src/content/reference/en/p5 copy/mouseClicked.mdx b/src/content/reference/en/p5 copy/mouseClicked.mdx deleted file mode 100644 index 80bd80b0a2..0000000000 --- a/src/content/reference/en/p5 copy/mouseClicked.mdx +++ /dev/null @@ -1,196 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1443 -title: mouseClicked -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A function that's called once after a mouse button is pressed and - released.

- -

Declaring the function mouseClicked() sets a code block to run - - automatically when the user releases a mouse button after having pressed - - it:

- -
function mouseClicked() {
-    // Code to run.
-  }
-
-  
- -

The mouse system variables, such as mouseX and - - mouseY, will be updated with their most - recent - - value when mouseClicked() is called by p5.js:

- -
function mouseClicked() {
-    if (mouseX < 50) {
-      // Code to run if the mouse is on the left.
-    }
-
-    if (mouseY > 50) {
-      // Code to run if the mouse is near the bottom.
-    }
-  }
-
-  
- -

The parameter, event, is optional. mouseClicked() - is always passed a - - MouseEvent - - object with properties that describe the mouse click event:

- -
function mouseClicked(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

On touchscreen devices, mouseClicked() will run when a user’s - touch - - ends if touchEnded() isn’t declared. - If - - touchEnded() is declared, then - - touchEnded() will run when a user’s - touch - - ends and mouseClicked() won’t.

- -

Browsers may have default behaviors attached to various mouse events. For - - example, some browsers highlight text when the user moves the mouse while - - pressing a mouse button. To prevent any default behavior for this event, - - add return false; to the end of the function.

- -

Note: mousePressed(), - - mouseReleased(), - - and mouseClicked() are all related. - - mousePressed() runs as soon as the - user - - clicks the mouse. mouseReleased() - runs as - - soon as the user releases the mouse click. mouseClicked() runs - - immediately after mouseReleased().

-line: 1443 -isConstructor: false -itemtype: method -example: - - |- - -
- - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square changes color when the user presses and releases a mouse button.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Toggle the square's color when the user clicks. - function mouseClicked() { - if (value === 0) { - value = 255; - } else { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Style the circle. - fill('orange'); - stroke('royalblue'); - strokeWeight(10); - - describe( - 'An orange circle with a thick, blue border drawn on a gray background. When the user presses and holds the mouse, the border becomes thin and pink. When the user releases the mouse, the border becomes thicker and changes color to blue.' - ); - } - - function draw() { - background(220); - - // Draw the circle. - circle(50, 50, 20); - } - - // Set the stroke color and weight as soon as the user clicks. - function mousePressed() { - stroke('deeppink'); - strokeWeight(3); - } - - // Set the stroke and fill colors as soon as the user releases - // the mouse. - function mouseReleased() { - stroke('royalblue'); - - // This is never visible because fill() is called - // in mouseClicked() which runs immediately after - // mouseReleased(); - fill('limegreen'); - } - - // Set the fill color and stroke weight after - // mousePressed() and mouseReleased() are called. - function mouseClicked() { - fill('orange'); - strokeWeight(10); - } - -
-class: p5 -params: - - name: event - description: | -

optional MouseEvent argument.

- type: MouseEvent - optional: true -chainable: false ---- - - -# mouseClicked diff --git a/src/content/reference/en/p5 copy/mouseDragged.mdx b/src/content/reference/en/p5 copy/mouseDragged.mdx deleted file mode 100644 index 26fea21fe9..0000000000 --- a/src/content/reference/en/p5 copy/mouseDragged.mdx +++ /dev/null @@ -1,130 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L982 -title: mouseDragged -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A function that's called when the mouse moves while a button is - pressed.

- -

Declaring the function mouseDragged() sets a code block to run - - automatically when the user clicks and drags the mouse:

- -
function mouseDragged() {
-    // Code to run.
-  }
-
-  
- -

The mouse system variables, such as mouseX and - - mouseY, will be updated with their most - recent - - value when mouseDragged() is called by p5.js:

- -
function mouseDragged() {
-    if (mouseX < 50) {
-      // Code to run if the mouse is on the left.
-    }
-
-    if (mouseY > 50) {
-      // Code to run if the mouse is near the bottom.
-    }
-  }
-
-  
- -

The parameter, event, is optional. mouseDragged() - is always passed a - - MouseEvent - - object with properties that describe the mouse drag event:

- -
function mouseDragged(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

On touchscreen devices, mouseDragged() will run when a user - moves a touch - - point if touchMoved() isn’t declared. - If - - touchMoved() is declared, then - - touchMoved() will run when a user - moves a - - touch point and mouseDragged() won’t.

- -

Browsers may have default behaviors attached to various mouse events. For - - example, some browsers highlight text when the user moves the mouse while - - pressing a mouse button. To prevent any default behavior for this event, - - add return false; to the end of the function.

-line: 982 -isConstructor: false -itemtype: method -example: - - |- - -
- - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square becomes lighter as the user drags the mouse.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - function mouseDragged() { - // Update the grayscale value. - value += 5; - - // Reset the grayscale value. - if (value > 255) { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
-class: p5 -params: - - name: event - description: | -

optional MouseEvent argument.

- type: MouseEvent - optional: true -chainable: false ---- - - -# mouseDragged diff --git a/src/content/reference/en/p5 copy/mouseIsPressed.mdx b/src/content/reference/en/p5 copy/mouseIsPressed.mdx deleted file mode 100644 index 37109eb364..0000000000 --- a/src/content/reference/en/p5 copy/mouseIsPressed.mdx +++ /dev/null @@ -1,73 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L755 -title: mouseIsPressed -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A Boolean system variable that's true if the - mouse is pressed and - - false if not.

-line: 755 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with the word "false" at its center. The word changes to "true" when the user presses a mouse button.' - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the mouseIsPressed variable. - text(mouseIsPressed, 25, 50); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a white square at its center. The inner square turns black when the user presses the mouse.' - ); - } - - function draw() { - background(200); - - // Style the square. - if (mouseIsPressed === true) { - fill(0); - } else { - fill(255); - } - - // Draw the square. - square(25, 25, 50); - } - -
-class: p5 -type: Boolean ---- - - -# mouseIsPressed diff --git a/src/content/reference/en/p5 copy/mouseMoved.mdx b/src/content/reference/en/p5 copy/mouseMoved.mdx deleted file mode 100644 index 14928fdc5e..0000000000 --- a/src/content/reference/en/p5 copy/mouseMoved.mdx +++ /dev/null @@ -1,118 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L896 -title: mouseMoved -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A function that's called when the mouse moves.

- -

Declaring the function mouseMoved() sets a code block to run - - automatically when the user moves the mouse without clicking any mouse - - buttons:

- -
function mouseMoved() {
-    // Code to run.
-  }
-
-  
- -

The mouse system variables, such as mouseX and - - mouseY, will be updated with their most - recent - - value when mouseMoved() is called by p5.js:

- -
function mouseMoved() {
-    if (mouseX < 50) {
-      // Code to run if the mouse is on the left.
-    }
-
-    if (mouseY > 50) {
-      // Code to run if the mouse is near the bottom.
-    }
-  }
-
-  
- -

The parameter, event, is optional. mouseMoved() - is always passed a - - MouseEvent - - object with properties that describe the mouse move event:

- -
function mouseMoved(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

Browsers may have default behaviors attached to various mouse events. For - - example, some browsers highlight text when the user moves the mouse while - - pressing a mouse button. To prevent any default behavior for this event, - - add return false; to the end of the function.

-line: 896 -isConstructor: false -itemtype: method -example: - - |- - -
- - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square becomes lighter as the mouse moves.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - function mouseMoved() { - // Update the grayscale value. - value += 5; - - // Reset the grayscale value. - if (value > 255) { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
-class: p5 -params: - - name: event - description: | -

optional MouseEvent argument.

- type: MouseEvent - optional: true -chainable: false ---- - - -# mouseMoved diff --git a/src/content/reference/en/p5 copy/mousePressed.mdx b/src/content/reference/en/p5 copy/mousePressed.mdx deleted file mode 100644 index 81181859c1..0000000000 --- a/src/content/reference/en/p5 copy/mousePressed.mdx +++ /dev/null @@ -1,193 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1098 -title: mousePressed -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A function that's called once when a mouse button is pressed.

- -

Declaring the function mousePressed() sets a code block to run - - automatically when the user presses a mouse button:

- -
function mousePressed() {
-    // Code to run.
-  }
-
-  
- -

The mouse system variables, such as mouseX and - - mouseY, will be updated with their most - recent - - value when mousePressed() is called by p5.js:

- -
function mousePressed() {
-    if (mouseX < 50) {
-      // Code to run if the mouse is on the left.
-    }
-
-    if (mouseY > 50) {
-      // Code to run if the mouse is near the bottom.
-    }
-  }
-
-  
- -

The parameter, event, is optional. mousePressed() - is always passed a - - MouseEvent - - object with properties that describe the mouse press event:

- -
function mousePressed(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

On touchscreen devices, mousePressed() will run when a user’s - touch - - begins if touchStarted() isn’t - declared. If - - touchStarted() is declared, then - - touchStarted() will run when a - user’s touch - - begins and mousePressed() won’t.

- -

Browsers may have default behaviors attached to various mouse events. For - - example, some browsers highlight text when the user moves the mouse while - - pressing a mouse button. To prevent any default behavior for this event, - - add return false; to the end of the function.

- -

Note: mousePressed(), mouseReleased(), - - and mouseClicked() are all related. - - mousePressed() runs as soon as the user clicks the mouse. - - mouseReleased() runs as soon as the - user - - releases the mouse click. mouseClicked() - - runs immediately after mouseReleased().

-line: 1098 -isConstructor: false -itemtype: method -example: - - |- - -
- - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square becomes lighter when the user presses a mouse button.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - function mousePressed() { - // Update the grayscale value. - value += 5; - - // Reset the grayscale value. - if (value > 255) { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Style the circle. - fill('orange'); - stroke('royalblue'); - strokeWeight(10); - - describe( - 'An orange circle with a thick, blue border drawn on a gray background. When the user presses and holds the mouse, the border becomes thin and pink. When the user releases the mouse, the border becomes thicker and changes color to blue.' - ); - } - - function draw() { - background(220); - - // Draw the circle. - circle(50, 50, 20); - } - - // Set the stroke color and weight as soon as the user clicks. - function mousePressed() { - stroke('deeppink'); - strokeWeight(3); - } - - // Set the stroke and fill colors as soon as the user releases - // the mouse. - function mouseReleased() { - stroke('royalblue'); - - // This is never visible because fill() is called - // in mouseClicked() which runs immediately after - // mouseReleased(); - fill('limegreen'); - } - - // Set the fill color and stroke weight after - // mousePressed() and mouseReleased() are called. - function mouseClicked() { - fill('orange'); - strokeWeight(10); - } - -
-class: p5 -params: - - name: event - description: | -

optional MouseEvent argument.

- type: MouseEvent - optional: true -chainable: false ---- - - -# mousePressed diff --git a/src/content/reference/en/p5 copy/mouseReleased.mdx b/src/content/reference/en/p5 copy/mouseReleased.mdx deleted file mode 100644 index 6f52911162..0000000000 --- a/src/content/reference/en/p5 copy/mouseReleased.mdx +++ /dev/null @@ -1,195 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1270 -title: mouseReleased -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A function that's called once when a mouse button is released.

- -

Declaring the function mouseReleased() sets a code block to - run - - automatically when the user releases a mouse button after having pressed - - it:

- -
function mouseReleased() {
-    // Code to run.
-  }
-
-  
- -

The mouse system variables, such as mouseX and - - mouseY, will be updated with their most - recent - - value when mouseReleased() is called by p5.js:

- -
function mouseReleased() {
-    if (mouseX < 50) {
-      // Code to run if the mouse is on the left.
-    }
-
-    if (mouseY > 50) {
-      // Code to run if the mouse is near the bottom.
-    }
-  }
-
-  
- -

The parameter, event, is optional. - mouseReleased() is always passed a - - MouseEvent - - object with properties that describe the mouse release event:

- -
function mouseReleased(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

On touchscreen devices, mouseReleased() will run when a user’s - touch - - ends if touchEnded() isn’t declared. - If - - touchEnded() is declared, then - - touchEnded() will run when a user’s - touch - - ends and mouseReleased() won’t.

- -

Browsers may have default behaviors attached to various mouse events. For - - example, some browsers highlight text when the user moves the mouse while - - pressing a mouse button. To prevent any default behavior for this event, - - add return false; to the end of the function.

- -

Note: mousePressed(), - mouseReleased(), - - and mouseClicked() are all related. - - mousePressed() runs as soon as the - user - - clicks the mouse. mouseReleased() runs as soon as the user - releases the - - mouse click. mouseClicked() runs - - immediately after mouseReleased().

-line: 1270 -isConstructor: false -itemtype: method -example: - - |- - -
- - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square becomes lighter when the user presses and releases a mouse button.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - function mouseReleased() { - // Update the grayscale value. - value += 5; - - // Reset the grayscale value. - if (value > 255) { - value = 0; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Style the circle. - fill('orange'); - stroke('royalblue'); - strokeWeight(10); - - describe( - 'An orange circle with a thick, blue border drawn on a gray background. When the user presses and holds the mouse, the border becomes thin and pink. When the user releases the mouse, the border becomes thicker and changes color to blue.' - ); - } - - function draw() { - background(220); - - // Draw the circle. - circle(50, 50, 20); - } - - // Set the stroke color and weight as soon as the user clicks. - function mousePressed() { - stroke('deeppink'); - strokeWeight(3); - } - - // Set the stroke and fill colors as soon as the user releases - // the mouse. - function mouseReleased() { - stroke('royalblue'); - - // This is never visible because fill() is called - // in mouseClicked() which runs immediately after - // mouseReleased(); - fill('limegreen'); - } - - // Set the fill color and stroke weight after - // mousePressed() and mouseReleased() are called. - function mouseClicked() { - fill('orange'); - strokeWeight(10); - } - -
-class: p5 -params: - - name: event - description: | -

optional MouseEvent argument.

- type: MouseEvent - optional: true -chainable: false ---- - - -# mouseReleased diff --git a/src/content/reference/en/p5 copy/mouseWheel.mdx b/src/content/reference/en/p5 copy/mouseWheel.mdx deleted file mode 100644 index a659ea3cec..0000000000 --- a/src/content/reference/en/p5 copy/mouseWheel.mdx +++ /dev/null @@ -1,162 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1746 -title: mouseWheel -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A function that's called once when the mouse wheel moves.

- -

Declaring the function mouseWheel() sets a code block to run - - automatically when the user scrolls with the mouse wheel:

- -
function mouseWheel() {
-    // Code to run.
-  }
-
-  
- -

The mouse system variables, such as mouseX and - - mouseY, will be updated with their most - recent - - value when mouseWheel() is called by p5.js:

- -
function mouseWheel() {
-    if (mouseX < 50) {
-      // Code to run if the mouse is on the left.
-    }
-
-    if (mouseY > 50) {
-      // Code to run if the mouse is near the bottom.
-    }
-  }
-
-  
- -

The parameter, event, is optional. mouseWheel() - is always passed a - - MouseEvent - - object with properties that describe the mouse scroll event:

- -
function mouseWheel(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

The event object has many properties including - delta, a Number - - containing the distance that the user scrolled. For example, - event.delta - - might have the value 5 when the user scrolls up. event.delta is - positive - - if the user scrolls up and negative if they scroll down. The signs are - - opposite on macOS with "natural" scrolling enabled.

- -

Browsers may have default behaviors attached to various mouse events. For - - example, some browsers highlight text when the user moves the mouse while - - pressing a mouse button. To prevent any default behavior for this event, - - add return false; to the end of the function.

- -

Note: On Safari, mouseWheel() may only work as expected if - - return false; is added at the end of the function.

-line: 1746 -isConstructor: false -itemtype: method -example: - - |- - -
- - let circleSize = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square. A white circle at its center grows up when the user scrolls the mouse wheel.' - ); - } - - function draw() { - background(200); - - // Draw the circle - circle(50, 50, circleSize); - } - - // Increment circleSize when the user scrolls the mouse wheel. - function mouseWheel() { - circleSize += 1; - // Uncomment to prevent any default behavior. - // return false; - } - -
- -
- - let direction = ''; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square. An arrow at its center points up when the user scrolls up. The arrow points down when the user scrolls down.' - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Draw an arrow that points where - // the mouse last scrolled. - text(direction, 50, 50); - } - - // Change direction when the user scrolls the mouse wheel. - function mouseWheel(event) { - if (event.delta > 0) { - direction = '▲'; - } else { - direction = '▼'; - } - // Uncomment to prevent any default behavior. - // return false; - } - -
-class: p5 -params: - - name: event - description: | -

optional WheelEvent argument.

- type: WheelEvent - optional: true -chainable: false ---- - - -# mouseWheel diff --git a/src/content/reference/en/p5 copy/mouseX.mdx b/src/content/reference/en/p5 copy/mouseX.mdx deleted file mode 100644 index 7c0ba7f4a3..0000000000 --- a/src/content/reference/en/p5 copy/mouseX.mdx +++ /dev/null @@ -1,124 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L119 -title: mouseX -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A Number system variable that tracks the mouse's horizontal - position.

- -

mouseX keeps track of the mouse's position relative to the - - top-left corner of the canvas. For example, if the mouse is 50 pixels from - - the left edge of the canvas, then mouseX will be 50.

- -

If touch is used instead of the mouse, then mouseX will hold - the - - x-coordinate of the most recent touch point.

-line: 119 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe("A vertical black line moves left and right following the mouse's x-position."); - } - - function draw() { - background(200); - - // Draw a vertical line that follows the mouse's x-coordinate. - line(mouseX, 0, mouseX, 100); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe("A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse."); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the mouse's coordinates. - text(`x: ${mouseX} y: ${mouseY}`, 50, 50); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe("A vertical black line moves left and right following the mouse's x-position."); - } - - function draw() { - background(200); - - // Adjust coordinates for WebGL mode. - // The origin (0, 0) is at the center of the canvas. - let mx = mouseX - 50; - - // Draw the line. - line(mx, -50, mx, 50); - } - -
- -
- - let font; - - // Load a font for WebGL mode. - function preload() { - font = loadFont('/assets/inconsolata.otf'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - "A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse." - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - textFont(font); - fill(0); - - // Display the mouse's coordinates. - text(`x: ${mouseX} y: ${mouseY}`, 0, 0); - } - -
-class: p5 -type: Number ---- - - -# mouseX diff --git a/src/content/reference/en/p5 copy/mouseY.mdx b/src/content/reference/en/p5 copy/mouseY.mdx deleted file mode 100644 index dc268025a4..0000000000 --- a/src/content/reference/en/p5 copy/mouseY.mdx +++ /dev/null @@ -1,124 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L226 -title: mouseY -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A Number system variable that tracks the mouse's vertical - position.

- -

mouseY keeps track of the mouse's position relative to the - - top-left corner of the canvas. For example, if the mouse is 50 pixels from - - the top edge of the canvas, then mouseY will be 50.

- -

If touch is used instead of the mouse, then mouseY will hold - the - - y-coordinate of the most recent touch point.

-line: 226 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe("A horizontal black line moves up and down following the mouse's y-position."); - } - - function draw() { - background(200); - - // Draw a horizontal line that follows the mouse's y-coordinate. - line(0, mouseY, 100, mouseY); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe("A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse."); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the mouse's coordinates. - text(`x: ${mouseX} y: ${mouseY}`, 50, 50); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe("A horizontal black line moves up and down following the mouse's y-position."); - } - - function draw() { - background(200); - - // Adjust coordinates for WebGL mode. - // The origin (0, 0) is at the center of the canvas. - let my = mouseY - 50; - - // Draw the line. - line(-50, my, 50, my); - } - -
- -
- - let font; - - // Load a font for WebGL mode. - function preload() { - font = loadFont('/assets/inconsolata.otf'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - "A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse." - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - textFont(font); - fill(0); - - // Display the mouse's coordinates. - text(`x: ${mouseX} y: ${mouseY}`, 0, 0); - } - -
-class: p5 -type: Number ---- - - -# mouseY diff --git a/src/content/reference/en/p5 copy/movedX.mdx b/src/content/reference/en/p5 copy/movedX.mdx deleted file mode 100644 index 454b577166..0000000000 --- a/src/content/reference/en/p5 copy/movedX.mdx +++ /dev/null @@ -1,78 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L12 -title: movedX -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A Number system variable that tracks the mouse's horizontal - movement.

- -

movedX tracks how many pixels the mouse moves left or right - between - - frames. movedX will have a negative value if the mouse moves left - between - - frames and a positive value if it moves right. movedX can be - calculated - - as mouseX - pmouseX.

- -

Note: movedX continues updating even when - - requestPointerLock() is - active. - - But keep in mind that during an active pointer lock, mouseX and pmouseX - - are locked, so movedX is based on - - the - MouseEvent's movementX value - - (which may behave differently in different browsers when the user - - is zoomed in or out).

-line: 12 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square. The text ">>" appears when the user moves the mouse to the right. The text "<<" appears when the user moves the mouse to the left.' - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display >> when movedX is positive and - // << when it's negative. - if (movedX > 0) { - text('>>', 50, 50); - } else if (movedX < 0) { - text('<<', 50, 50); - } - } - -
-class: p5 -type: Number ---- - - -# movedX diff --git a/src/content/reference/en/p5 copy/movedY.mdx b/src/content/reference/en/p5 copy/movedY.mdx deleted file mode 100644 index 00f4a28d5b..0000000000 --- a/src/content/reference/en/p5 copy/movedY.mdx +++ /dev/null @@ -1,78 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L62 -title: movedY -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A Number system variable that tracks the mouse's vertical - movement.

- -

movedY tracks how many pixels the mouse moves up or down - between - - frames. movedY will have a negative value if the mouse moves up - between - - frames and a positive value if it moves down. movedY can be - calculated - - as mouseY - pmouseY.

- -

Note: movedY continues updating even when - - requestPointerLock() is - active. - - But keep in mind that during an active pointer lock, mouseX and pmouseX - - are locked, so movedX is based on - - the - MouseEvent's movementX value - - (which may behave differently in different browsers when the user - - is zoomed in or out).

-line: 62 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square. The text "▲" appears when the user moves the mouse upward. The text "▼" appears when the user moves the mouse downward.' - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display ▼ when movedY is positive and - // ▲ when it's negative. - if (movedY > 0) { - text('▼', 50, 50); - } else if (movedY < 0) { - text('▲', 50, 50); - } - } - -
-class: p5 -type: Number ---- - - -# movedY diff --git a/src/content/reference/en/p5 copy/nf.mdx b/src/content/reference/en/p5 copy/nf.mdx deleted file mode 100644 index ab64244d9f..0000000000 --- a/src/content/reference/en/p5 copy/nf.mdx +++ /dev/null @@ -1,159 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L199 -title: nf -module: Data -submodule: String Functions -file: src/utilities/string_functions.js -description: > -

Converts a Number into a String with a given - number of digits.

- -

nf() converts numbers such as 123.45 into strings - formatted with a set - - number of digits, as in '123.4500'.

- -

The first parameter, num, is the number to convert to a - string. For - - example, calling nf(123.45) returns the string - '123.45'. If an array of - - numbers is passed, as in nf([123.45, 67.89]), an array of - formatted - - strings will be returned.

- -

The second parameter, left, is optional. If a number is - passed, as in - - nf(123.45, 4), it sets the minimum number of digits to include to - the - - left of the decimal place. If left is larger than the number of - digits in - - num, then unused digits will be set to 0. For example, calling - - nf(123.45, 4) returns the string '0123.45'.

- -

The third parameter, right, is also optional. If a number is - passed, as - - in nf(123.45, 4, 1), it sets the minimum number of digits to - include to - - the right of the decimal place. If right is smaller than the - number of - - decimal places in num, then num will be rounded to - the given number of - - decimal places. For example, calling nf(123.45, 4, 1) returns the - string - - '0123.5'. If right is larger than the number of decimal places in - num, - - then unused decimal places will be set to 0. For example, calling - - nf(123.45, 4, 3) returns the string '0123.450'.

- -

When the number is negative, for example, calling nf(-123.45, 5, - 2) - - returns the string '-00123.45'.

-line: 199 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textSize(16); - - // Create a number variable. - let number = 123.45; - - // Display the number as a string. - let formatted = nf(number); - text(formatted, 20, 20); - - let negative = nf(-number, 4, 2); - text(negative, 20, 40); - - // Display the number with four digits - // to the left of the decimal. - let left = nf(number, 4); - text(left, 20, 60); - - // Display the number with four digits - // to the left of the decimal and one - // to the right. - let right = nf(number, 4, 1); - text(right, 20, 80); - - describe( - 'The numbers "123.45", "-0123.45", "0123.45", and "0123.5" written on four separate lines. The text is in black on a gray background.' - ); - } - -
-class: p5 -return: - description: formatted string. - type: String -overloads: - - line: 199 - params: - - name: num - description: | -

number to format.

- type: Number|String - - name: left - description: | -

number of digits to include to the left of - the decimal point.

- type: Integer|String - optional: true - - name: right - description: | -

number of digits to include to the right - of the decimal point.

- type: Integer|String - optional: true - return: - description: formatted string. - type: String - - line: 276 - params: - - name: nums - description: | -

numbers to format.

- type: 'Number[]' - - name: left - description: '' - type: Integer|String - optional: true - - name: right - description: '' - type: Integer|String - optional: true - return: - description: formatted strings. - type: 'String[]' -chainable: false ---- - - -# nf diff --git a/src/content/reference/en/p5 copy/nfc.mdx b/src/content/reference/en/p5 copy/nfc.mdx deleted file mode 100644 index ba49f689fa..0000000000 --- a/src/content/reference/en/p5 copy/nfc.mdx +++ /dev/null @@ -1,153 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L322 -title: nfc -module: Data -submodule: String Functions -file: src/utilities/string_functions.js -description: > -

Converts a Number into a String with commas to - mark units of 1,000.

- -

nfc() converts numbers such as 12345 into strings formatted - with commas - - to mark the thousands place, as in '12,345'.

- -

The first parameter, num, is the number to convert to a - string. For - - example, calling nfc(12345) returns the string - '12,345'.

- -

The second parameter, right, is optional. If a number is - passed, as in - - nfc(12345, 1), it sets the minimum number of digits to include to - the - - right of the decimal place. If right is smaller than the number - of - - decimal places in num, then num will be rounded to - the given number of - - decimal places. For example, calling nfc(12345.67, 1) returns the - string - - '12,345.7'. If right is larger than the number of - decimal places in - - num, then unused decimal places will be set to 0. For example, - calling - - nfc(12345.67, 3) returns the string - '12,345.670'.

-line: 322 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textSize(16); - - // Create a number variable. - let number = 12345; - - // Display the number as a string. - let commas = nfc(number); - text(commas, 15, 33); - - // Display the number with four digits - // to the left of the decimal. - let decimals = nfc(number, 2); - text(decimals, 15, 67); - - describe( - 'The numbers "12,345" and "12,345.00" written on separate lines. The text is in black on a gray background.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of numbers. - let numbers = [12345, 6789]; - - // Convert the numbers to formatted strings. - let formatted = nfc(numbers); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(14); - - // Iterate over the array. - for (let i = 0; i < formatted.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 33; - - // Display the original and formatted numbers. - text(`${numbers[i]} : ${formatted[i]}`, 50, y); - } - - describe( - 'The text "12345 : 12,345" and "6789 : 6,789" written on two separate lines. The text is in black on a gray background.' - ); - } - -
-class: p5 -return: - description: formatted string. - type: String -overloads: - - line: 322 - params: - - name: num - description: | -

number to format.

- type: Number|String - - name: right - description: | -

number of digits to include to the right - of the decimal point.

- type: Integer|String - optional: true - return: - description: formatted string. - type: String - - line: 411 - params: - - name: nums - description: | -

numbers to format.

- type: 'Number[]' - - name: right - description: '' - type: Integer|String - optional: true - return: - description: formatted strings. - type: 'String[]' -chainable: false ---- - - -# nfc diff --git a/src/content/reference/en/p5 copy/nfp.mdx b/src/content/reference/en/p5 copy/nfp.mdx deleted file mode 100644 index dbd80ca5d7..0000000000 --- a/src/content/reference/en/p5 copy/nfp.mdx +++ /dev/null @@ -1,188 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L447 -title: nfp -module: Data -submodule: String Functions -file: src/utilities/string_functions.js -description: > -

Converts a Number into a String with a plus or - minus sign.

- -

nfp() converts numbers such as 123 into strings formatted with - a + or - - - symbol to mark whether they're positive or negative, as in - '+123'.

- -

The first parameter, num, is the number to convert to a - string. For - - example, calling nfp(123.45) returns the string - '+123.45'. If an array - - of numbers is passed, as in nfp([123.45, -6.78]), an array of - formatted - - strings will be returned.

- -

The second parameter, left, is optional. If a number is - passed, as in - - nfp(123.45, 4), it sets the minimum number of digits to include - to the - - left of the decimal place. If left is larger than the number of - digits in - - num, then unused digits will be set to 0. For example, calling - - nfp(123.45, 4) returns the string '+0123.45'.

- -

The third parameter, right, is also optional. If a number is - passed, as - - in nfp(123.45, 4, 1), it sets the minimum number of digits to - include to - - the right of the decimal place. If right is smaller than the - number of - - decimal places in num, then num will be rounded to - the given number of - - decimal places. For example, calling nfp(123.45, 4, 1) returns - the - - string '+0123.5'. If right is larger than the number - of decimal places - - in num, then unused decimal places will be set to 0. For - example, - - calling nfp(123.45, 4, 3) returns the string - '+0123.450'.

-line: 447 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create number variables. - let positive = 123; - let negative = -123; - - // Convert the positive number to a formatted string. - let p = nfp(positive); - - // Convert the negative number to a formatted string - // with four digits to the left of the decimal - // and two digits to the right of the decimal. - let n = nfp(negative, 4, 2); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(14); - - // Display the original and formatted numbers. - text(`${positive} : ${p}`, 50, 33); - text(`${negative} : ${n}`, 50, 67); - - describe( - 'The text "123 : +123" and "-123 : -123.00" written on separate lines. The text is in black on a gray background.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create number variables. - let numbers = [123, -4.56]; - - // Convert the numbers to formatted strings - // with four digits to the left of the decimal - // and one digit to the right of the decimal. - let formatted = nfp(numbers, 4, 1); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(14); - - // Iterate over the array. - for (let i = 0; i < formatted.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 33; - - // Display the original and formatted numbers. - text(`${numbers[i]} : ${formatted[i]}`, 50, y); - } - - describe( - 'The text "123 : +0123.0" and "-4.56 : 00-4.6" written on separate lines. The text is in black on a gray background.' - ); - } - -
-class: p5 -return: - description: formatted string. - type: String -overloads: - - line: 447 - params: - - name: num - description: | -

number to format.

- type: Number - - name: left - description: | -

number of digits to include to the left of the - decimal point.

- type: Integer - optional: true - - name: right - description: | -

number of digits to include to the right of the - decimal point.

- type: Integer - optional: true - return: - description: formatted string. - type: String - - line: 552 - params: - - name: nums - description: | -

numbers to format.

- type: 'Number[]' - - name: left - description: '' - type: Integer - optional: true - - name: right - description: '' - type: Integer - optional: true - return: - description: formatted strings. - type: 'String[]' -chainable: false ---- - - -# nfp diff --git a/src/content/reference/en/p5 copy/nfs.mdx b/src/content/reference/en/p5 copy/nfs.mdx deleted file mode 100644 index 80c144e391..0000000000 --- a/src/content/reference/en/p5 copy/nfs.mdx +++ /dev/null @@ -1,176 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L573 -title: nfs -module: Data -submodule: String Functions -file: src/utilities/string_functions.js -description: > -

Converts a positive Number into a String with an - extra space in front.

- -

nfs() converts positive numbers such as 123.45 into strings - formatted - - with an extra space in front, as in ' 123.45'. Doing so can be helpful for - - aligning positive and negative numbers.

- -

The first parameter, num, is the number to convert to a - string. For - - example, calling nfs(123.45) returns the string ' - 123.45'.

- -

The second parameter, left, is optional. If a number is - passed, as in - - nfs(123.45, 4), it sets the minimum number of digits to include - to the - - left of the decimal place. If left is larger than the number of - digits in - - num, then unused digits will be set to 0. For example, calling - - nfs(123.45, 4) returns the string ' 0123.45'.

- -

The third parameter, right, is also optional. If a number is - passed, as - - in nfs(123.45, 4, 1), it sets the minimum number of digits to - include to - - the right of the decimal place. If right is smaller than the - number of - - decimal places in num, then num will be rounded to - the given number of - - decimal places. For example, calling nfs(123.45, 4, 1) returns - the - - string ' 0123.5'. If right is larger than the number - of decimal places - - in num, then unused decimal places will be set to 0. For - example, - - calling nfs(123.45, 4, 3) returns the string ' - 0123.450'.

-line: 573 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create number variables. - let positive = 123; - let negative = -123; - - // Convert the positive number to a formatted string. - let formatted = nfs(positive); - - // Style the text. - textAlign(CENTER, CENTER); - textFont('Courier New'); - textSize(16); - - // Display the negative number and the formatted positive number. - text(negative, 50, 33); - text(formatted, 50, 67); - - describe( - 'The numbers -123 and 123 written on separate lines. The numbers align vertically. The text is in black on a gray background.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a number variable. - let number = 123.45; - - // Convert the positive number to a formatted string. - // Use four digits to the left of the decimal and - // one digit to the right. - let formatted = nfs(number, 4, 1); - - // Style the text. - textAlign(CENTER, CENTER); - textFont('Courier New'); - textSize(16); - - // Display a negative version of the number and - // the formatted positive version. - text('-0123.5', 50, 33); - text(formatted, 50, 67); - - describe( - 'The numbers "-0123.5" and "0123.5" written on separate lines. The numbers align vertically. The text is in black on a gray background.' - ); - } - -
-class: p5 -return: - description: formatted string. - type: String -overloads: - - line: 573 - params: - - name: num - description: | -

number to format.

- type: Number - - name: left - description: | -

number of digits to include to the left of the - decimal point.

- type: Integer - optional: true - - name: right - description: | -

number of digits to include to the right of the - decimal point.

- type: Integer - optional: true - return: - description: formatted string. - type: String - - line: 669 - params: - - name: nums - description: | -

numbers to format.

- type: Array - - name: left - description: '' - type: Integer - optional: true - - name: right - description: '' - type: Integer - optional: true - return: - description: formatted strings. - type: 'String[]' -chainable: false ---- - - -# nfs diff --git a/src/content/reference/en/p5 copy/noCanvas.mdx b/src/content/reference/en/p5 copy/noCanvas.mdx deleted file mode 100644 index 08fcdda5e5..0000000000 --- a/src/content/reference/en/p5 copy/noCanvas.mdx +++ /dev/null @@ -1,36 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L346 -title: noCanvas -module: Rendering -submodule: Rendering -file: src/core/rendering.js -description: > -

Removes the default canvas.

- -

By default, a 100×100 pixels canvas is created without needing to call - - createCanvas(). - noCanvas() removes the - - default canvas for sketches that don't need it.

-line: 346 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - noCanvas(); - } - -
-class: p5 -chainable: false ---- - - -# noCanvas diff --git a/src/content/reference/en/p5 copy/noCursor.mdx b/src/content/reference/en/p5 copy/noCursor.mdx deleted file mode 100644 index 37ac72c0cf..0000000000 --- a/src/content/reference/en/p5 copy/noCursor.mdx +++ /dev/null @@ -1,38 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L482 -title: noCursor -module: Environment -submodule: Environment -file: src/core/environment.js -description: | -

Hides the cursor from view.

-line: 482 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - // Hide the cursor. - noCursor(); - } - - function draw() { - background(200); - - circle(mouseX, mouseY, 10); - - describe('A white circle on a gray background. The circle follows the mouse as it moves. The cursor is hidden.'); - } - -
-class: p5 -chainable: false ---- - - -# noCursor diff --git a/src/content/reference/en/p5 copy/noDebugMode.mdx b/src/content/reference/en/p5 copy/noDebugMode.mdx deleted file mode 100644 index 19d36eba2b..0000000000 --- a/src/content/reference/en/p5 copy/noDebugMode.mdx +++ /dev/null @@ -1,54 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/interaction.js#L725 -title: noDebugMode -module: 3D -submodule: Interaction -file: src/webgl/interaction.js -description: > -

Turns off debugMode() in a 3D - sketch.

-line: 725 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - // Enable debug mode. - debugMode(); - - describe('A multicolor box on a gray background. A grid and axes icon are displayed near the box. They disappear when the user double-clicks.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the box. - normalMaterial(); - - // Draw the box. box(20, 40); - } - - // Disable debug mode when the user double-clicks. - function doubleClicked() { - noDebugMode(); - } - -
-class: p5 -chainable: false ---- - - -# noDebugMode diff --git a/src/content/reference/en/p5 copy/noErase.mdx b/src/content/reference/en/p5 copy/noErase.mdx deleted file mode 100644 index e959433b77..0000000000 --- a/src/content/reference/en/p5 copy/noErase.mdx +++ /dev/null @@ -1,55 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1716 -title: noErase -module: Color -submodule: Setting -file: src/color/setting.js -description: > -

Ends erasing that was started with erase().

- -

The fill(), stroke(), and - - blendMode() settings will return to - what they - - were prior to calling erase().

-line: 1716 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(235, 145, 15); - - // Draw the left rectangle. - noStroke(); - fill(30, 45, 220); - rect(30, 10, 10, 80); - - // Erase a circle. - erase(); - circle(50, 50, 60); - noErase(); - - // Draw the right rectangle. - rect(70, 10, 10, 80); - - describe('An orange canvas with two tall blue rectangles. A circular hole in the center erases the rectangle on the left but not the one on the right.'); - } - -
-class: p5 -chainable: true ---- - - -# noErase diff --git a/src/content/reference/en/p5 copy/noFill.mdx b/src/content/reference/en/p5 copy/noFill.mdx deleted file mode 100644 index 67a3979778..0000000000 --- a/src/content/reference/en/p5 copy/noFill.mdx +++ /dev/null @@ -1,73 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1257 -title: noFill -module: Color -submodule: Setting -file: src/color/setting.js -description: > -

Disables setting the fill color for shapes.

- -

Calling noFill() is the same as making the fill completely - transparent, - - as in fill(0, 0). If both noStroke() and - - noFill() are called, nothing will be drawn to the screen.

-line: 1257 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw the top square. - square(32, 10, 35); - - // Draw the bottom square. - noFill(); - square(32, 55, 35); - - describe('A white square on above an empty square. Both squares have black outlines.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A purple cube wireframe spinning on a black canvas.'); - } - - function draw() { - background(0); - - // Style the box. - noFill(); - stroke(100, 100, 240); - - // Rotate the coordinates. - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - - // Draw the box. - box(45); - } - -
-class: p5 -chainable: true ---- - - -# noFill diff --git a/src/content/reference/en/p5 copy/noLights.mdx b/src/content/reference/en/p5 copy/noLights.mdx deleted file mode 100644 index 1f85888bf6..0000000000 --- a/src/content/reference/en/p5 copy/noLights.mdx +++ /dev/null @@ -1,79 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L1687 -title: noLights -module: 3D -submodule: Lights -file: src/webgl/light.js -description: > -

Removes all lights from the sketch.

- -

Calling noLights() removes any lights created with - - lights(), - - ambientLight(), - - directionalLight(), - - pointLight(), or - - spotLight(). These functions may be - called - - after noLights() to create a new lighting scheme.

-line: 1687 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('Two spheres drawn against a gray background. The top sphere is white and the bottom sphere is red.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the spheres. - noStroke(); - - // Draw the top sphere. - push(); - translate(0, -25, 0); - sphere(20); - pop(); - - // Turn off the lights. - noLights(); - - // Add a red directional light that points into the screen. - directionalLight(255, 0, 0, 0, 0, -1); - - // Draw the bottom sphere. - push(); - translate(0, 25, 0); - sphere(20); - pop(); - } - -
-class: p5 -chainable: true ---- - - -# noLights diff --git a/src/content/reference/en/p5 copy/noLoop.mdx b/src/content/reference/en/p5 copy/noLoop.mdx deleted file mode 100644 index fe1897a8cb..0000000000 --- a/src/content/reference/en/p5 copy/noLoop.mdx +++ /dev/null @@ -1,139 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L9 -title: noLoop -module: Structure -submodule: Structure -file: src/core/structure.js -description: > -

Stops the code in draw() from running - repeatedly.

- -

By default, draw() tries to run 60 times - per - - second. Calling noLoop() stops draw() from - - repeating. The draw loop can be restarted by calling - - loop(). draw() can be run - - once by calling redraw().

- -

The isLooping() function can be used - to check - - whether a sketch is looping, as in isLooping() === true.

-line: 9 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Turn off the draw loop. - noLoop(); - - describe('A white half-circle on the left edge of a gray square.'); - } - - function draw() { - background(200); - - // Calculate the circle's x-coordinate. - let x = frameCount; - - // Draw the circle. - // Normally, the circle would move from left to right. - circle(x, 50, 20); - } - -
- -
- - // Double-click to stop the draw loop. - - function setup() { - createCanvas(100, 100); - - // Slow the frame rate. - frameRate(5); - - describe('A white circle moves randomly on a gray background. It stops moving when the user double-clicks.'); - } - - function draw() { - background(200); - - // Calculate the circle's coordinates. - let x = random(0, 100); - let y = random(0, 100); - - // Draw the circle. - // Normally, the circle would move from left to right. - circle(x, y, 20); - } - - // Stop the draw loop when the user double-clicks. - function doubleClicked() { - noLoop(); - } - -
- -
- - let startButton; - let stopButton; - - function setup() { - createCanvas(100, 100); - - // Create the button elements and place them - // beneath the canvas. - startButton = createButton('▶'); - startButton.position(0, 100); - startButton.size(50, 20); - stopButton = createButton('◾'); - stopButton.position(50, 100); - stopButton.size(50, 20); - - // Set functions to call when the buttons are pressed. - startButton.mousePressed(loop); - stopButton.mousePressed(noLoop); - - // Slow the frame rate. - frameRate(5); - - describe( - 'A white circle moves randomly on a gray background. Play and stop buttons are shown beneath the canvas. The circle stops or starts moving when the user presses a button.' - ); - } - - function draw() { - background(200); - - // Calculate the circle's coordinates. - let x = random(0, 100); - let y = random(0, 100); - - // Draw the circle. - // Normally, the circle would move from left to right. - circle(x, y, 20); - } - -
-class: p5 -chainable: false ---- - - -# noLoop diff --git a/src/content/reference/en/p5 copy/noSmooth.mdx b/src/content/reference/en/p5 copy/noSmooth.mdx deleted file mode 100644 index a1af76d10d..0000000000 --- a/src/content/reference/en/p5 copy/noSmooth.mdx +++ /dev/null @@ -1,92 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L100 -title: noSmooth -module: Shape -submodule: Attributes -file: src/core/shape/attributes.js -description: > -

Draws certain features with jagged (aliased) edges.

- -

smooth() is active by default. In 2D - mode, - - noSmooth() is helpful for scaling up images without blurring. The - - functions don't affect shapes or fonts.

- -

In WebGL mode, noSmooth() causes all shapes to be drawn with - jagged - - (aliased) edges. The functions don't affect images or fonts.

-line: 100 -isConstructor: false -itemtype: method -example: - - |- - -
- - let heart; - - // Load a pixelated heart image from an image data string. - function preload() { - heart = loadImage('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAAXNSR0IArs4c6QAAAEZJREFUGFd9jcsNACAIQ9tB2MeR3YdBMBBq8CIXPi2vBICIiOwkOedatllqWO6Y8yOWoyuNf1GZwgmf+RRG2YXr+xVFmA8HZ9Mx/KGPMtcAAAAASUVORK5CYII='); - } - - function setup() { - createCanvas(100, 100); - - background(50); - - // Antialiased hearts. - image(heart, 10, 10); - image(heart, 20, 10, 16, 16); - image(heart, 40, 10, 32, 32); - - // Aliased hearts. - noSmooth(); - image(heart, 10, 60); - image(heart, 20, 60, 16, 16); - image(heart, 40, 60, 32, 32); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - circle(0, 0, 80); - - describe('A white circle on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - // Disable smoothing. - noSmooth(); - - background(200); - - circle(0, 0, 80); - - describe('A pixelated white circle on a gray background.'); - } - -
-class: p5 -chainable: true ---- - - -# noSmooth diff --git a/src/content/reference/en/p5 copy/noStroke.mdx b/src/content/reference/en/p5 copy/noStroke.mdx deleted file mode 100644 index 7c4fe80960..0000000000 --- a/src/content/reference/en/p5 copy/noStroke.mdx +++ /dev/null @@ -1,71 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1317 -title: noStroke -module: Color -submodule: Setting -file: src/color/setting.js -description: > -

Disables drawing points, lines, and the outlines of shapes.

- -

Calling noStroke() is the same as making the stroke completely - transparent, - - as in stroke(0, 0). If both noStroke() and - - noFill() are called, nothing will be drawn - to the - - screen.

-line: 1317 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - noStroke(); - square(20, 20, 60); - - describe('A white square with no outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A pink cube with no edge outlines spinning on a black canvas.'); - } - - function draw() { - background(0); - - // Style the box. - noStroke(); - fill(240, 150, 150); - - // Rotate the coordinates. - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - - // Draw the box. - box(45); - } - -
-class: p5 -chainable: true ---- - - -# noStroke diff --git a/src/content/reference/en/p5 copy/noTint.mdx b/src/content/reference/en/p5 copy/noTint.mdx deleted file mode 100644 index e3b0aeea19..0000000000 --- a/src/content/reference/en/p5 copy/noTint.mdx +++ /dev/null @@ -1,51 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L1345 -title: noTint -module: Image -submodule: Loading & Displaying -file: src/image/loading_displaying.js -description: > -

Removes the current tint set by tint().

- -

noTint() restores images to their original colors.

-line: 1345 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Left. - // Tint with a CSS color string. - tint('red'); - image(img, 0, 0); - - // Right. - // Remove the tint. - noTint(); - image(img, 50, 0); - - describe('Two images of an umbrella and a ceiling side-by-side. The image on the left has a red tint.'); - } - -
-class: p5 -chainable: false ---- - - -# noTint diff --git a/src/content/reference/en/p5 copy/noise.mdx b/src/content/reference/en/p5 copy/noise.mdx deleted file mode 100644 index 1b67f49cb9..0000000000 --- a/src/content/reference/en/p5 copy/noise.mdx +++ /dev/null @@ -1,282 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/noise.js#L36 -title: noise -module: Math -submodule: Noise -file: src/math/noise.js -description: > -

Returns random numbers that can be tuned to feel organic.

- -

Values returned by random() and - - randomGaussian() can change by - large - - amounts between function calls. By contrast, values returned by - noise() - - can be made "smooth". Calls to noise() with similar inputs will - produce - - similar outputs. noise() is used to create textures, motion, - shapes, - - terrains, and so on. Ken Perlin invented noise() while animating - the - - original Tron film in the 1980s.

- -

noise() always returns values between 0 and 1. It returns the - same value - - for a given input while a sketch is running. noise() produces - different - - results each time a sketch runs. The - - noiseSeed() function can be used to - generate - - the same sequence of Perlin noise values each time a sketch runs.

- -

The character of the noise can be adjusted in two ways. The first way is to - - scale the inputs. noise() interprets inputs as coordinates. The - sequence - - of noise values will be smoother when the input coordinates are closer. The - - second way is to use the noiseDetail() - - function.

- -

The version of noise() with one parameter computes noise - values in one - - dimension. This dimension can be thought of as space, as in - noise(x), or - - time, as in noise(t).

- -

The version of noise() with two parameters computes noise - values in two - - dimensions. These dimensions can be thought of as space, as in - - noise(x, y), or space and time, as in noise(x, - t).

- -

The version of noise() with three parameters computes noise - values in - - three dimensions. These dimensions can be thought of as space, as in - - noise(x, y, z), or space and time, as in noise(x, y, - t).

-line: 36 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A black dot moves randomly on a gray square.'); - } - - function draw() { - background(200); - - // Calculate the coordinates. - let x = 100 * noise(0.005 * frameCount); - let y = 100 * noise(0.005 * frameCount + 10000); - - // Draw the point. - strokeWeight(5); - point(x, y); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A black dot moves randomly on a gray square.'); - } - - function draw() { - background(200); - - // Set the noise level and scale. - let noiseLevel = 100; - let noiseScale = 0.005; - - // Scale the input coordinate. - let nt = noiseScale * frameCount; - - // Compute the noise values. - let x = noiseLevel * noise(nt); - let y = noiseLevel * noise(nt + 10000); - - // Draw the point. - strokeWeight(5); - point(x, y); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A hilly terrain drawn in gray against a black sky.'); - } - - function draw() { - // Set the noise level and scale. - let noiseLevel = 100; - let noiseScale = 0.02; - - // Scale the input coordinate. - let x = frameCount; - let nx = noiseScale * x; - - // Compute the noise value. - let y = noiseLevel * noise(nx); - - // Draw the line. - line(x, 0, x, y); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A calm sea drawn in gray against a black sky.'); - } - - function draw() { - background(200); - - // Set the noise level and scale. - let noiseLevel = 100; - let noiseScale = 0.002; - - // Iterate from left to right. - for (let x = 0; x < width; x += 1) { - // Scale the input coordinates. - let nx = noiseScale * x; - let nt = noiseScale * frameCount; - - // Compute the noise value. - let y = noiseLevel * noise(nx, nt); - - // Draw the line. - line(x, 0, x, y); - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Set the noise level and scale. - let noiseLevel = 255; - let noiseScale = 0.01; - - // Iterate from top to bottom. - for (let y = 0; y < height; y += 1) { - // Iterate from left to right. - for (let x = 0; x < width; x += 1) { - // Scale the input coordinates. - let nx = noiseScale * x; - let ny = noiseScale * y; - - // Compute the noise value. - let c = noiseLevel * noise(nx, ny); - - // Draw the point. - stroke(c); - point(x, y); - } - } - - describe('A gray cloudy pattern.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A gray cloudy pattern that changes.'); - } - - function draw() { - // Set the noise level and scale. - let noiseLevel = 255; - let noiseScale = 0.009; - - // Iterate from top to bottom. - for (let y = 0; y < height; y += 1) { - // Iterate from left to right. - for (let x = 0; x < width; x += 1) { - // Scale the input coordinates. - let nx = noiseScale * x; - let ny = noiseScale * y; - let nt = noiseScale * frameCount; - - // Compute the noise value. - let c = noiseLevel * noise(nx, ny, nt); - - // Draw the point. - stroke(c); - point(x, y); - } - } - } - -
-class: p5 -params: - - name: x - description: | -

x-coordinate in noise space.

- type: Number - - name: 'y' - description: | -

y-coordinate in noise space.

- type: Number - optional: true - - name: z - description: | -

z-coordinate in noise space.

- type: Number - optional: true -return: - description: Perlin noise value at specified coordinates. - type: Number -chainable: false ---- - - -# noise diff --git a/src/content/reference/en/p5 copy/noiseDetail.mdx b/src/content/reference/en/p5 copy/noiseDetail.mdx deleted file mode 100644 index 973ac515ab..0000000000 --- a/src/content/reference/en/p5 copy/noiseDetail.mdx +++ /dev/null @@ -1,100 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/noise.js#L331 -title: noiseDetail -module: Math -submodule: Noise -file: src/math/noise.js -description: > -

Adjusts the character of the noise produced by the - - noise() function.

- -

Perlin noise values are created by adding layers of noise together. The - - noise layers, called octaves, are similar to harmonics in music. Lower - - octaves contribute more to the output signal. They define the overall - - intensity of the noise. Higher octaves create finer-grained details.

- -

By default, noise values are created by combining four octaves. Each higher - - octave contributes half as much (50% less) compared to its predecessor. - - noiseDetail() changes the number of octaves and the falloff - amount. For - - example, calling noiseDetail(6, 0.25) ensures that - - noise() will use six octaves. Each higher - octave - - will contribute 25% as much (75% less) compared to its predecessor. Falloff - - values between 0 and 1 are valid. However, falloff values greater than 0.5 - - might result in noise values greater than 1.

-line: 331 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Set the noise level and scale. - let noiseLevel = 255; - let noiseScale = 0.02; - - // Iterate from top to bottom. - for (let y = 0; y < height; y += 1) { - // Iterate from left to right. - for (let x = 0; x < width / 2; x += 1) { - // Scale the input coordinates. - let nx = noiseScale * x; - let ny = noiseScale * y; - - // Compute the noise value with six octaves - // and a low falloff factor. - noiseDetail(6, 0.25); - let c = noiseLevel * noise(nx, ny); - - // Draw the left side. - stroke(c); - point(x, y); - - // Compute the noise value with four octaves - // and a high falloff factor. - noiseDetail(4, 0.5); - c = noiseLevel * noise(nx, ny); - - // Draw the right side. - stroke(c); - point(x + 50, y); - } - } - - describe('Two gray cloudy patterns. The pattern on the right is cloudier than the pattern on the left.'); - } - -
-class: p5 -params: - - name: lod - description: | -

number of octaves to be used by the noise.

- type: Number - - name: falloff - description: | -

falloff factor for each octave.

- type: Number -chainable: false ---- - - -# noiseDetail diff --git a/src/content/reference/en/p5 copy/noiseSeed.mdx b/src/content/reference/en/p5 copy/noiseSeed.mdx deleted file mode 100644 index a1f2ce6fbd..0000000000 --- a/src/content/reference/en/p5 copy/noiseSeed.mdx +++ /dev/null @@ -1,68 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/noise.js#L405 -title: noiseSeed -module: Math -submodule: Noise -file: src/math/noise.js -description: > -

Sets the seed value for the noise() - function.

- -

By default, noise() produces different - results - - each time a sketch is run. Calling noiseSeed() with a constant - argument, - - such as noiseSeed(99), makes noise() produce the - - same results each time a sketch is run.

-line: 405 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Set the noise seed for consistent results. - noiseSeed(99); - - describe('A black rectangle that grows randomly, first to the right and then to the left.'); - } - - function draw() { - // Set the noise level and scale. - let noiseLevel = 100; - let noiseScale = 0.005; - - // Scale the input coordinate. - let nt = noiseScale * frameCount; - - // Compute the noise value. - let x = noiseLevel * noise(nt); - - // Draw the line. - line(x, 0, x, height); - } - -
-class: p5 -params: - - name: seed - description: | -

seed value.

- type: Number -chainable: false ---- - - -# noiseSeed diff --git a/src/content/reference/en/p5 copy/norm.mdx b/src/content/reference/en/p5 copy/norm.mdx deleted file mode 100644 index d52a73e4c5..0000000000 --- a/src/content/reference/en/p5 copy/norm.mdx +++ /dev/null @@ -1,69 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L772 -title: norm -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Maps a number from one range to a value between 0 and 1.

- -

For example, norm(2, 0, 10) returns 0.2. 2's position in the - original - - range [0, 10] is proportional to 0.2's position in the range [0, 1]. This - - is the same as calling map(2, 0, 10, 0, 1).

- -

Numbers outside of the original range are not constrained between 0 and 1. - - Out-of-range values are often intentional and useful.

-line: 772 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Use RGB color with values from 0 to 1. - colorMode(RGB, 1); - - describe('A square changes color from black to red as the mouse moves from left to right.'); - } - - function draw() { - // Calculate the redValue. - let redValue = norm(mouseX, 0, 100); - - // Paint the background. - background(redValue, 0, 0); - } - -
-class: p5 -params: - - name: value - description: | -

incoming value to be normalized.

- type: Number - - name: start - description: | -

lower bound of the value's current range.

- type: Number - - name: stop - description: | -

upper bound of the value's current range.

- type: Number -return: - description: normalized number. - type: Number -chainable: false ---- - - -# norm diff --git a/src/content/reference/en/p5 copy/normal.mdx b/src/content/reference/en/p5 copy/normal.mdx deleted file mode 100644 index a109745b80..0000000000 --- a/src/content/reference/en/p5 copy/normal.mdx +++ /dev/null @@ -1,250 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L2097 -title: normal -module: Shape -submodule: Vertex -file: src/core/shape/vertex.js -description: > -

Sets the normal vector for vertices in a custom 3D shape.

- -

3D shapes created with beginShape() - and - - endShape() are made by connecting sets - of - - points called vertices. Each vertex added with - - vertex() has a normal vector that points - away - - from it. The normal vector controls how light reflects off the shape.

- -

normal() can be called two ways with different parameters to - define the - - normal vector's components.

- -

The first way to call normal() has three parameters, - x, y, and z. - - If Numbers are passed, as in normal(1, 2, 3), they - set the x-, y-, and - - z-components of the normal vector.

- -

The second way to call normal() has one parameter, - vector. If a - - p5.Vector object is passed, as in - - normal(myVector), its components will be used to set the normal - vector.

- -

normal() changes the normal vector of vertices added to a - custom shape - - with vertex(). normal() must - be called between - - the beginShape() and - - endShape() functions, just like - - vertex(). The normal vector set by calling - - normal() will affect all following vertices until - normal() is called - - again:

- -
beginShape();
-
-
-  // Set the vertex normal.
-
-  normal(-0.4, -0.4, 0.8);
-
-
-  // Add a vertex.
-
-  vertex(-30, -30, 0);
-
-
-  // Set the vertex normal.
-
-  normal(0, 0, 1);
-
-
-  // Add vertices.
-
-  vertex(30, -30, 0);
-
-  vertex(30, 30, 0);
-
-
-  // Set the vertex normal.
-
-  normal(0.4, -0.4, 0.8);
-
-
-  // Add a vertex.
-
-  vertex(-30, 30, 0);
-
-
-  endShape();
-
-  
-line: 2097 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click the and drag the mouse to view the scene from a different angle. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'A colorful square on a black background. The square changes color and rotates when the user drags the mouse. Parts of its surface reflect light in different directions.' - ); - } - - function draw() { - background(0); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the shape. - normalMaterial(); - noStroke(); - - // Draw the shape. - beginShape(); - vertex(-30, -30, 0); - vertex(30, -30, 0); - vertex(30, 30, 0); - vertex(-30, 30, 0); - endShape(); - } - -
- -
- - // Click the and drag the mouse to view the scene from a different angle. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'A colorful square on a black background. The square changes color and rotates when the user drags the mouse. Parts of its surface reflect light in different directions.' - ); - } - - function draw() { - background(0); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the shape. - normalMaterial(); - noStroke(); - - // Draw the shape. - // Use normal() to set vertex normals. - beginShape(); - normal(-0.4, -0.4, 0.8); - vertex(-30, -30, 0); - - normal(0, 0, 1); - vertex(30, -30, 0); - vertex(30, 30, 0); - - normal(0.4, -0.4, 0.8); - vertex(-30, 30, 0); - endShape(); - } - -
- -
- - // Click the and drag the mouse to view the scene from a different angle. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'A colorful square on a black background. The square changes color and rotates when the user drags the mouse. Parts of its surface reflect light in different directions.' - ); - } - - function draw() { - background(0); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the shape. - normalMaterial(); - noStroke(); - - // Create p5.Vector objects. - let n1 = createVector(-0.4, -0.4, 0.8); - let n2 = createVector(0, 0, 1); - let n3 = createVector(0.4, -0.4, 0.8); - - // Draw the shape. - // Use normal() to set vertex normals. - beginShape(); - normal(n1); - vertex(-30, -30, 0); - - normal(n2); - vertex(30, -30, 0); - vertex(30, 30, 0); - - normal(n3); - vertex(-30, 30, 0); - endShape(); - } - -
-class: p5 -overloads: - - line: 2097 - params: - - name: vector - description: | -

vertex normal as a p5.Vector object.

- type: p5.Vector - chainable: 1 - - line: 2272 - params: - - name: x - description: | -

x-component of the vertex normal.

- type: Number - - name: 'y' - description: | -

y-component of the vertex normal.

- type: Number - - name: z - description: | -

z-component of the vertex normal.

- type: Number - chainable: 1 -chainable: true ---- - - -# normal diff --git a/src/content/reference/en/p5 copy/normalMaterial.mdx b/src/content/reference/en/p5 copy/normalMaterial.mdx deleted file mode 100644 index 0652b349d4..0000000000 --- a/src/content/reference/en/p5 copy/normalMaterial.mdx +++ /dev/null @@ -1,55 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2365 -title: normalMaterial -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Sets the current material as a normal material.

- -

A normal material sets surfaces facing the x-axis to red, those facing the - - y-axis to green, and those facing the z-axis to blue. Normal material isn't - - affected by light. It’s often used as a placeholder material when - debugging.

- -

Note: normalMaterial() can only be used in WebGL mode.

-line: 2365 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A multicolor torus drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the torus. - normalMaterial(); - - // Draw the torus. - torus(30); - } - -
-class: p5 -chainable: true ---- - - -# normalMaterial diff --git a/src/content/reference/en/p5 copy/orbitControl.mdx b/src/content/reference/en/p5 copy/orbitControl.mdx deleted file mode 100644 index be2fd25452..0000000000 --- a/src/content/reference/en/p5 copy/orbitControl.mdx +++ /dev/null @@ -1,203 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/interaction.js#L11 -title: orbitControl -module: 3D -submodule: Interaction -file: src/webgl/interaction.js -description: > -

Allows the user to orbit around a 3D sketch using a mouse, trackpad, or - - touchscreen.

- -

3D sketches are viewed through an imaginary camera. Calling - - orbitControl() within the draw() function allows - - the user to change the camera’s position:

- -
function draw() {
-    background(200);
-
-    // Enable orbiting with the mouse.
-    orbitControl();
-
-    // Rest of sketch.
-  }
-
-  
- -

Left-clicking and dragging or swipe motion will rotate the camera position - - about the center of the sketch. Right-clicking and dragging or multi-swipe - - will pan the camera position without rotation. Using the mouse wheel - - (scrolling) or pinch in/out will move the camera further or closer from the - - center of the sketch.

- -

The first three parameters, sensitivityX, - sensitivityY, and - - sensitivityZ, are optional. They’re numbers that set the sketch’s - - sensitivity to movement along each axis. For example, calling - - orbitControl(1, 2, -1) keeps movement along the x-axis at its - default - - value, makes the sketch twice as sensitive to movement along the y-axis, - - and reverses motion along the z-axis. By default, all sensitivity values - - are 1.

- -

The fourth parameter, options, is also optional. It’s an - object that - - changes the behavior of orbiting. For example, calling - - orbitControl(1, 1, 1, options) keeps the default sensitivity - values while - - changing the behaviors set with options. The object can have the - - following properties:

- -
let options = {
-    // Setting this to false makes mobile interactions smoother by
-    // preventing accidental interactions with the page while orbiting.
-    // By default, it's true.
-    disableTouchActions: true,
-
-    // Setting this to true makes the camera always rotate in the
-    // direction the mouse/touch is moving.
-    // By default, it's false.
-    freeRotation: false
-  };
-
-
-  orbitControl(1, 1, 1, options);
-
-  
-line: 11 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A multicolor box on a gray background. The camera angle changes when the user interacts using a mouse, trackpad, or touchscreen.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the box. - normalMaterial(); - - // Draw the box. - box(30, 50); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A multicolor box on a gray background. The camera angle changes when the user interacts using a mouse, trackpad, or touchscreen.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - // Make the interactions 3X sensitive. - orbitControl(3, 3, 3); - - // Style the box. - normalMaterial(); - - // Draw the box. - box(30, 50); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A multicolor box on a gray background. The camera angle changes when the user interacts using a mouse, trackpad, or touchscreen.'); - } - - function draw() { - background(200); - - // Create an options object. - let options = { - disableTouchActions: false, - freeRotation: true - }; - - // Enable orbiting with the mouse. - // Prevent accidental touch actions on touchscreen devices - // and enable free rotation. - orbitControl(1, 1, 1, options); - - // Style the box. - normalMaterial(); - - // Draw the box. - box(30, 50); - } - -
-class: p5 -params: - - name: sensitivityX - description: | -

sensitivity to movement along the x-axis. Defaults to 1.

- type: Number - optional: true - - name: sensitivityY - description: | -

sensitivity to movement along the y-axis. Defaults to 1.

- type: Number - optional: true - - name: sensitivityZ - description: | -

sensitivity to movement along the z-axis. Defaults to 1.

- type: Number - optional: true - - name: options - description: | -

object with two optional properties, disableTouchActions - and freeRotation. Both are Booleans. disableTouchActions - defaults to true and freeRotation defaults to false.

- type: Object - optional: true -chainable: true ---- - - -# orbitControl diff --git a/src/content/reference/en/p5 copy/ortho.mdx b/src/content/reference/en/p5 copy/ortho.mdx deleted file mode 100644 index 5fb384ba48..0000000000 --- a/src/content/reference/en/p5 copy/ortho.mdx +++ /dev/null @@ -1,168 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L412 -title: ortho -module: 3D -submodule: Camera -file: src/webgl/p5.Camera.js -description: > -

Sets an orthographic projection for the current camera in a 3D sketch.

- -

In an orthographic projection, shapes with the same size always appear the - - same size, regardless of whether they are near or far from the camera.

- -

ortho() changes the camera’s perspective by changing its - viewing frustum - - from a truncated pyramid to a rectangular prism. The camera is placed in - - front of the frustum and views everything between the frustum’s near plane - - and its far plane. ortho() has six optional parameters to define - the - - frustum.

- -

The first four parameters, left, right, - bottom, and top, set the - - coordinates of the frustum’s sides, bottom, and top. For example, calling - - ortho(-100, 100, 200, -200) creates a frustum that’s 200 pixels - wide and - - 400 pixels tall. By default, these coordinates are set based on the - - sketch’s width and height, as in - - ortho(-width / 2, width / 2, -height / 2, height / 2).

- -

The last two parameters, near and far, set the - distance of the - - frustum’s near and far plane from the camera. For example, calling - - ortho(-100, 100, 200, 200, 50, 1000) creates a frustum that’s 200 - pixels - - wide, 400 pixels tall, starts 50 pixels from the camera, and ends 1,000 - - pixels from the camera. By default, near and far are - set to 0 and - - max(width, height) + 800, respectively.

- -

Note: ortho() can only be used in WebGL mode.

-line: 412 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A row of tiny, white cubes on a gray background. All the cubes appear the same size.'); - } - - function draw() { - background(200); - - // Apply an orthographic projection. - ortho(); - - // Translate the origin toward the camera. - translate(-10, 10, 600); - - // Rotate the coordinate system. - rotateY(-0.1); - rotateX(-0.1); - - // Draw the row of boxes. - for (let i = 0; i < 6; i += 1) { - translate(0, 0, -40); - box(10); - } - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Apply an orthographic projection. - // Center the frustum. - // Set its width and height to 20. - // Place its near plane 300 pixels from the camera. - // Place its far plane 350 pixels from the camera. - ortho(-10, 10, -10, 10, 300, 350); - - // Translate the origin toward the camera. - translate(-10, 10, 600); - - // Rotate the coordinate system. - rotateY(-0.1); - rotateX(-0.1); - - // Draw the row of boxes. - for (let i = 0; i < 6; i += 1) { - translate(0, 0, -40); - box(10); - } - } - -
-class: p5 -params: - - name: left - description: > -

x-coordinate of the frustum’s left plane. Defaults to -width / - 2.

- type: Number - optional: true - - name: right - description: > -

x-coordinate of the frustum’s right plane. Defaults to width / - 2.

- type: Number - optional: true - - name: bottom - description: > -

y-coordinate of the frustum’s bottom plane. Defaults to height / - 2.

- type: Number - optional: true - - name: top - description: > -

y-coordinate of the frustum’s top plane. Defaults to -height / - 2.

- type: Number - optional: true - - name: near - description: | -

z-coordinate of the frustum’s near plane. Defaults to 0.

- type: Number - optional: true - - name: far - description: > -

z-coordinate of the frustum’s far plane. Defaults to max(width, - height) + 800.

- type: Number - optional: true -chainable: true ---- - - -# ortho diff --git a/src/content/reference/en/p5 copy/outputVolume.mdx b/src/content/reference/en/p5 copy/outputVolume.mdx deleted file mode 100644 index fe618922fb..0000000000 --- a/src/content/reference/en/p5 copy/outputVolume.mdx +++ /dev/null @@ -1,51 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L738 -title: outputVolume -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: |- -

Scale the output of all sound in this sketch

- Scaled between 0.0 (silence) and 1.0 (full volume). - 1.0 is the maximum amplitude of a digital sound, so multiplying - by greater than 1.0 may cause digital distortion. To - fade, provide a rampTime parameter. For more - complex fades, see the Envelope class. - -

Alternately, you can pass in a signal source such as an - oscillator to modulate the amplitude with an audio signal.

-

How This Works: When you load the p5.sound module, it - creates a single instance of p5sound. All sound objects in this - module output to p5sound before reaching your computer's output. - So if you change the amplitude of p5sound, it impacts all of the - sound in this module.

- -

If no value is provided, returns a Web Audio API Gain Node

-line: 738 -isConstructor: false -itemtype: method -class: p5 -params: - - name: volume - description: | -

Volume (amplitude) between 0.0 - and 1.0 or modulating signal/oscillator

- type: Number|Object - - name: rampTime - description: | -

Fade for t seconds

- type: Number - optional: true - - name: timeFromNow - description: | -

Schedule this event to happen at - t seconds in the future

- type: Number - optional: true -chainable: false ---- - - -# outputVolume diff --git a/src/content/reference/en/p5 copy/p5.Camera.mdx b/src/content/reference/en/p5 copy/p5.Camera.mdx deleted file mode 100644 index cc2090e329..0000000000 --- a/src/content/reference/en/p5 copy/p5.Camera.mdx +++ /dev/null @@ -1,659 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L723 -title: p5.Camera -module: 3D -submodule: Camera -file: src/webgl/p5.Camera.js -description: > -

A class to describe a camera for viewing a 3D sketch.

- -

Each p5.Camera object represents a camera that views a section - of 3D - - space. It stores information about the camera’s position, orientation, and - - projection.

- -

In WebGL mode, the default camera is a p5.Camera object that - can be - - controlled with the camera(), - - perspective(), - - ortho(), and - - frustum() functions. Additional cameras - can be - - created with createCamera() and - activated - - with setCamera().

- -

Note: p5.Camera’s methods operate in two coordinate - systems:

- -
    - -
  • The “world” coordinate system describes positions in terms of their - - relationship to the origin along the x-, y-, and z-axes. For example, - - calling myCamera.setPosition() places the camera in 3D space - using - - "world" coordinates.
  • - -
  • The "local" coordinate system describes positions from the camera's point - - of view: left-right, up-down, and forward-backward. For example, calling - - myCamera.move() moves the camera along its own axes.
  • - -
-line: 723 -isConstructor: true -params: - - name: rendererGL - description: | -

instance of WebGL renderer

- type: RendererGL -example: - - |- - -
- - let cam; - let delta = 0.001; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Camera object. - cam = createCamera(); - - // Place the camera at the top-center. - cam.setPosition(0, -400, 800); - - // Point the camera at the origin. - cam.lookAt(0, 0, 0); - - describe( - 'A white cube on a gray background. The cube goes in and out of view as the camera pans left and right.' - ); - } - - function draw() { - background(200); - - // Turn the camera left and right, called "panning". - cam.pan(delta); - - // Switch directions every 120 frames. - if (frameCount % 120 === 0) { - delta *= -1; - } - - // Draw the box. - box(); - } - -
- -
- - // Double-click to toggle between cameras. - - let cam1; - let cam2; - let isDefaultCamera = true; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the first camera. - // Keep its default settings. - cam1 = createCamera(); - - // Create the second camera. - // Place it at the top-left. - // Point it at the origin. - cam2 = createCamera(); - cam2.setPosition(400, -400, 800); - cam2.lookAt(0, 0, 0); - - // Set the current camera to cam1. - setCamera(cam1); - - describe( - 'A white cube on a gray background. The camera toggles between frontal and aerial views when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Draw the box. - box(); - } - - // Toggle the current camera when the user double-clicks. - function doubleClicked() { - if (isDefaultCamera === true) { - setCamera(cam2); - isDefaultCamera = false; - } else { - setCamera(cam1); - isDefaultCamera = true; - } - } - -
-methods: - perspective: - description: > -

Sets a perspective projection for the camera.

- -

In a perspective projection, shapes that are further from the camera - appear - - smaller than shapes that are near the camera. This technique, called - - foreshortening, creates realistic 3D scenes. It’s applied by default in - new - - p5.Camera objects.

- -

myCamera.perspective() changes the camera’s perspective by - changing its - - viewing frustum. The frustum is the volume of space that’s visible to the - - camera. The frustum’s shape is a pyramid with its top cut off. The camera - - is placed where the top of the pyramid should be and points towards the - - base of the pyramid. It views everything within the frustum.

- -

The first parameter, fovy, is the camera’s vertical field - of view. It’s - - an angle that describes how tall or narrow a view the camera has. For - - example, calling myCamera.perspective(0.5) sets the camera’s - vertical - - field of view to 0.5 radians. By default, fovy is calculated - based on the - - sketch’s height and the camera’s default z-coordinate, which is 800. The - - formula for the default fovy is 2 * atan(height / 2 / - 800).

- -

The second parameter, aspect, is the camera’s aspect - ratio. It’s a number - - that describes the ratio of the top plane’s width to its height. For - - example, calling myCamera.perspective(0.5, 1.5) sets the - camera’s field - - of view to 0.5 radians and aspect ratio to 1.5, which would make shapes - - appear thinner on a square canvas. By default, aspect is set - to - - width / height.

- -

The third parameter, near, is the distance from the camera - to the near - - plane. For example, calling myCamera.perspective(0.5, 1.5, - 100) sets the - - camera’s field of view to 0.5 radians, its aspect ratio to 1.5, and places - - the near plane 100 pixels from the camera. Any shapes drawn less than 100 - - pixels from the camera won’t be visible. By default, near is - set to - - 0.1 * 800, which is 1/10th the default distance between the - camera and - - the origin.

- -

The fourth parameter, far, is the distance from the camera - to the far - - plane. For example, calling myCamera.perspective(0.5, 1.5, 100, - 10000) - - sets the camera’s field of view to 0.5 radians, its aspect ratio to 1.5, - - places the near plane 100 pixels from the camera, and places the far plane - - 10,000 pixels from the camera. Any shapes drawn more than 10,000 pixels - - from the camera won’t be visible. By default, far is set to - 10 * 800, - - which is 10 times the default distance between the camera and the - origin.

- path: p5.Camera/perspective - ortho: - description: > -

Sets an orthographic projection for the camera.

- -

In an orthographic projection, shapes with the same size always appear - the - - same size, regardless of whether they are near or far from the camera.

- -

myCamera.ortho() changes the camera’s perspective by - changing its viewing - - frustum from a truncated pyramid to a rectangular prism. The frustum is - the - - volume of space that’s visible to the camera. The camera is placed in - front - - of the frustum and views everything within the frustum. - myCamera.ortho() - - has six optional parameters to define the viewing frustum.

- -

The first four parameters, left, right, - bottom, and top, set the - - coordinates of the frustum’s sides, bottom, and top. For example, calling - - myCamera.ortho(-100, 100, 200, -200) creates a frustum that’s - 200 pixels - - wide and 400 pixels tall. By default, these dimensions are set based on - - the sketch’s width and height, as in - - myCamera.ortho(-width / 2, width / 2, -height / 2, height / - 2).

- -

The last two parameters, near and far, set - the distance of the - - frustum’s near and far plane from the camera. For example, calling - - myCamera.ortho(-100, 100, 200, -200, 50, 1000) creates a - frustum that’s - - 200 pixels wide, 400 pixels tall, starts 50 pixels from the camera, and - - ends 1,000 pixels from the camera. By default, near and - far are set to - - 0 and max(width, height) + 800, respectively.

- path: p5.Camera/ortho - frustum: - description: > -

Sets the camera's frustum.

- -

In a frustum projection, shapes that are further from the camera appear - - smaller than shapes that are near the camera. This technique, called - - foreshortening, creates realistic 3D scenes.

- -

myCamera.frustum() changes the camera’s perspective by - changing its - - viewing frustum. The frustum is the volume of space that’s visible to the - - camera. The frustum’s shape is a pyramid with its top cut off. The camera - - is placed where the top of the pyramid should be and points towards the - - base of the pyramid. It views everything within the frustum.

- -

The first four parameters, left, right, - bottom, and top, set the - - coordinates of the frustum’s sides, bottom, and top. For example, calling - - myCamera.frustum(-100, 100, 200, -200) creates a frustum - that’s 200 - - pixels wide and 400 pixels tall. By default, these coordinates are set - - based on the sketch’s width and height, as in - - myCamera.frustum(-width / 20, width / 20, height / 20, -height / - 20).

- -

The last two parameters, near and far, set - the distance of the - - frustum’s near and far plane from the camera. For example, calling - - myCamera.frustum(-100, 100, 200, -200, 50, 1000) creates a - frustum that’s - - 200 pixels wide, 400 pixels tall, starts 50 pixels from the camera, and - ends - - 1,000 pixels from the camera. By default, near is set to 0.1 * - 800, which - - is 1/10th the default distance between the camera and the origin. - far is - - set to 10 * 800, which is 10 times the default distance - between the - - camera and the origin.

- path: p5.Camera/frustum - roll: - description: > -

Rotates the camera in a clockwise/counter-clockwise direction.

- -

Rolling rotates the camera without changing its orientation. The - rotation - - happens in the camera’s "local" space.

- -

The parameter, angle, is the angle the camera should - rotate. Passing a - - positive angle, as in myCamera.roll(0.001), rotates the - camera in counter-clockwise direction. - - Passing a negative angle, as in myCamera.roll(-0.001), - rotates the - - camera in clockwise direction.

- -

Note: Angles are interpreted based on the current - - angleMode().

- path: p5.Camera/roll - pan: - description: > -

Rotates the camera left and right.

- -

Panning rotates the camera without changing its position. The rotation - - happens in the camera’s "local" space.

- -

The parameter, angle, is the angle the camera should - rotate. Passing a - - positive angle, as in myCamera.pan(0.001), rotates the camera - to the - - right. Passing a negative angle, as in myCamera.pan(-0.001), - rotates the - - camera to the left.

- -

Note: Angles are interpreted based on the current - - angleMode().

- path: p5.Camera/pan - tilt: - description: > -

Rotates the camera up and down.

- -

Tilting rotates the camera without changing its position. The rotation - - happens in the camera’s "local" space.

- -

The parameter, angle, is the angle the camera should - rotate. Passing a - - positive angle, as in myCamera.tilt(0.001), rotates the - camera down. - - Passing a negative angle, as in myCamera.tilt(-0.001), - rotates the camera - - up.

- -

Note: Angles are interpreted based on the current - - angleMode().

- path: p5.Camera/tilt - lookAt: - description: > -

Points the camera at a location.

- -

myCamera.lookAt() changes the camera’s orientation without - changing its - - position.

- -

The parameters, x, y, and z, are - the coordinates in "world" space - - where the camera should point. For example, calling - - myCamera.lookAt(10, 20, 30) points the camera at the - coordinates - - (10, 20, 30).

- path: p5.Camera/lookAt - camera: - description: > -

Sets the position and orientation of the camera.

- -

myCamera.camera() allows objects to be viewed from - different angles. It - - has nine parameters that are all optional.

- -

The first three parameters, x, y, and - z, are the coordinates of the - - camera’s position in "world" space. For example, calling - - myCamera.camera(0, 0, 0) places the camera at the origin - (0, 0, 0). By - - default, the camera is placed at (0, 0, 800).

- -

The next three parameters, centerX, centerY, - and centerZ are the - - coordinates of the point where the camera faces in "world" space. For - - example, calling myCamera.camera(0, 0, 0, 10, 20, 30) places - the camera - - at the origin (0, 0, 0) and points it at (10, 20, - 30). By default, the - - camera points at the origin (0, 0, 0).

- -

The last three parameters, upX, upY, and - upZ are the components of - - the "up" vector in "local" space. The "up" vector orients the camera’s - - y-axis. For example, calling - - myCamera.camera(0, 0, 0, 10, 20, 30, 0, -1, 0) places the - camera at the - - origin (0, 0, 0), points it at (10, 20, 30), and - sets the "up" vector - - to (0, -1, 0) which is like holding it upside-down. By - default, the "up" - - vector is (0, 1, 0).

- path: p5.Camera/camera - move: - description: > -

Moves the camera along its "local" axes without changing its - orientation.

- -

The parameters, x, y, and z, are - the distances the camera should - - move. For example, calling myCamera.move(10, 20, 30) moves - the camera 10 - - pixels to the right, 20 pixels down, and 30 pixels backward in its "local" - - space.

- path: p5.Camera/move - setPosition: - description: > -

Sets the camera’s position in "world" space without changing its - - orientation.

- -

The parameters, x, y, and z, are - the coordinates where the camera - - should be placed. For example, calling myCamera.setPosition(10, 20, - 30) - - places the camera at coordinates (10, 20, 30) in "world" - space.

- path: p5.Camera/setPosition - set: - description: > -

Sets the camera’s position, orientation, and projection by copying - another - - camera.

- -

The parameter, cam, is the p5.Camera object - to copy. For example, calling - - cam2.set(cam1) will set cam2 using - cam1’s configuration.

- path: p5.Camera/set - slerp: - description: > -

Sets the camera’s position and orientation to values that are - in-between - - those of two other cameras.

- -

myCamera.slerp() uses spherical linear interpolation to - calculate a - - position and orientation that’s in-between two other cameras. Doing so is - - helpful for transitioning smoothly between two perspectives.

- -

The first two parameters, cam0 and cam1, are - the p5.Camera objects - - that should be used to set the current camera.

- -

The third parameter, amt, is the amount to interpolate - between cam0 and - - cam1. 0.0 keeps the camera’s position and orientation equal - to cam0’s, - - 0.5 sets them halfway between cam0’s and cam1’s - , and 1.0 sets the - - position and orientation equal to cam1’s.

- -

For example, calling myCamera.slerp(cam0, cam1, 0.1) sets - cam’s position - - and orientation very close to cam0’s. Calling - - myCamera.slerp(cam0, cam1, 0.9) sets cam’s position and - orientation very - - close to cam1’s.

- -

Note: All of the cameras must use the same projection.

- path: p5.Camera/slerp -properties: - eyeX: - description: | -

The camera’s x-coordinate.

-

By default, the camera’s x-coordinate is set to 0 in "world" space.

- path: p5.Camera/eyeX - eyeY: - description: | -

The camera’s y-coordinate.

-

By default, the camera’s y-coordinate is set to 0 in "world" space.

- path: p5.Camera/eyeY - eyeZ: - description: > -

The camera’s z-coordinate.

- -

By default, the camera’s z-coordinate is set to 800 in "world" - space.

- path: p5.Camera/eyeZ - centerX: - description: > -

The x-coordinate of the place where the camera looks.

- -

By default, the camera looks at the origin (0, 0, 0) in - "world" space, so - - myCamera.centerX is 0.

- path: p5.Camera/centerX - centerY: - description: > -

The y-coordinate of the place where the camera looks.

- -

By default, the camera looks at the origin (0, 0, 0) in - "world" space, so - - myCamera.centerY is 0.

- path: p5.Camera/centerY - centerZ: - description: > -

The y-coordinate of the place where the camera looks.

- -

By default, the camera looks at the origin (0, 0, 0) in - "world" space, so - - myCamera.centerZ is 0.

- path: p5.Camera/centerZ - upX: - description: > -

The x-component of the camera's "up" vector.

- -

The camera's "up" vector orients its y-axis. By default, the "up" - vector is - - (0, 1, 0), so its x-component is 0 in "local" space.

- path: p5.Camera/upX - upY: - description: > -

The y-component of the camera's "up" vector.

- -

The camera's "up" vector orients its y-axis. By default, the "up" - vector is - - (0, 1, 0), so its y-component is 1 in "local" space.

- path: p5.Camera/upY - upZ: - description: > -

The z-component of the camera's "up" vector.

- -

The camera's "up" vector orients its y-axis. By default, the "up" - vector is - - (0, 1, 0), so its z-component is 0 in "local" space.

- path: p5.Camera/upZ -chainable: false ---- - - -# p5.Camera diff --git a/src/content/reference/en/p5 copy/p5.Color.mdx b/src/content/reference/en/p5 copy/p5.Color.mdx deleted file mode 100644 index b804e5ee95..0000000000 --- a/src/content/reference/en/p5 copy/p5.Color.mdx +++ /dev/null @@ -1,116 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/p5.Color.js#L318 -title: p5.Color -module: Color -submodule: Creating & Reading -file: src/color/p5.Color.js -description: > -

A class to describe a color.

- -

Each p5.Color object stores the color mode - - and level maxes that were active during its construction. These values are - - used to interpret the arguments passed to the object's constructor. They - - also determine output formatting such as when - - saturation() is called.

- -

Color is stored internally as an array of ideal RGBA values in floating - - point form, normalized from 0 to 1. These values are used to calculate the - - closest screen colors, which are RGBA levels from 0 to 255. Screen colors - - are sent to the renderer.

- -

When different color representations are calculated, the results are cached - - for performance. These values are normalized, floating-point numbers.

- -

Note: color() is the recommended way to - create an - - instance of this class.

-line: 318 -isConstructor: true -params: - - name: pInst - description: | -

pointer to p5 instance.

- type: P5 - optional: true - - name: vals - description: | -

an array containing the color values - for red, green, blue and alpha channel - or CSS color.

- type: 'Number[]|String' -methods: - toString: - description: > -

Returns the color formatted as a String.

- -

Calling myColor.toString() can be useful for debugging, as - in - - print(myColor.toString()). It's also helpful for using p5.js - with other - - libraries.

- -

The parameter, format, is optional. If a format string is - passed, as in - - myColor.toString('#rrggbb'), it will determine how the color - string is - - formatted. By default, color strings are formatted as 'rgba(r, g, b, - a)'.

- path: p5.Color/toString - setRed: - description: > -

Sets the red component of a color.

- -

The range depends on the colorMode(). In the - - default RGB mode it's between 0 and 255.

- path: p5.Color/setRed - setGreen: - description: > -

Sets the green component of a color.

- -

The range depends on the colorMode(). In the - - default RGB mode it's between 0 and 255.

- path: p5.Color/setGreen - setBlue: - description: > -

Sets the blue component of a color.

- -

The range depends on the colorMode(). In the - - default RGB mode it's between 0 and 255.

- path: p5.Color/setBlue - setAlpha: - description: > -

Sets the alpha (transparency) value of a color.

- -

The range depends on the - - colorMode(). In the default RGB - mode it's - - between 0 and 255.

- path: p5.Color/setAlpha -chainable: false ---- - - -# p5.Color diff --git a/src/content/reference/en/p5 copy/p5.Element.mdx b/src/content/reference/en/p5 copy/p5.Element.mdx deleted file mode 100644 index c07b10ae79..0000000000 --- a/src/content/reference/en/p5 copy/p5.Element.mdx +++ /dev/null @@ -1,545 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/p5.Element.js#L9 -title: p5.Element -module: DOM -submodule: DOM -file: src/core/p5.Element.js -description: > -

A class to describe an - - HTML element.

- -

Sketches can use many elements. Common elements include the drawing canvas, - - buttons, sliders, webcam feeds, and so on.

- -

All elements share the methods of the p5.Element class. - They're created - - with functions such as createCanvas() and - - createButton().

-line: 9 -isConstructor: true -params: - - name: elt - description: | -

wrapped DOM element.

- type: HTMLElement - - name: pInst - description: | -

pointer to p5 instance.

- type: P5 - optional: true -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a button element and - // place it beneath the canvas. - let btn = createButton('change'); - btn.position(0, 100); - - // Call randomColor() when - // the button is pressed. - btn.mousePressed(randomColor); - - describe('A gray square with a button that says "change" beneath it. The square changes color when the user presses the button.'); - } - - // Paint the background either - // red, yellow, blue, or green. - function randomColor() { - let c = random(['red', 'yellow', 'blue', 'green']); - background(c); - } - -
-methods: - parent: - description: > -

Attaches the element to a parent element.

- -

For example, a

element may be used as a box to - - hold two pieces of text, a header and a paragraph. The - -
is the parent element of both the header and - - paragraph.

- -

The parameter parent can have one of three types. - parent can be a - - string with the parent element's ID, as in - - myElement.parent('container'). It can also be another - - p5.Element object, as in - - myElement.parent(myDiv). Finally, parent can be - an HTMLElement - - object, as in myElement.parent(anotherElement).

- -

Calling myElement.parent() without an argument returns the - element's - - parent.

- path: p5.Element/parent - id: - description: > -

Sets the element's ID using a given string.

- -

Calling myElement.id() without an argument returns its ID - as a string.

- path: p5.Element/id - class: - description: > -

Adds a - - class attribute - - to the element using a given string.

- -

Calling myElement.class() without an argument returns a - string with its current classes.

- path: p5.Element/class - mousePressed: - description: > -

Calls a function when the mouse is pressed over the element.

- -

Calling myElement.mousePressed(false) disables the - function.

- -

Note: Some mobile browsers may also trigger this event when the element - - receives a quick tap.

- path: p5.Element/mousePressed - doubleClicked: - description: > -

Calls a function when the mouse is pressed twice over the element.

- -

Calling myElement.doubleClicked(false) disables the - function.

- path: p5.Element/doubleClicked - mouseWheel: - description: > -

Calls a function when the mouse wheel scrolls over the element.

- -

The callback function, fxn, is passed an - event object. event has - - two numeric properties, deltaY and deltaX. - event.deltaY is - - negative if the mouse wheel rotates away from the user. It's positive if - - the mouse wheel rotates toward the user. event.deltaX is - positive if - - the mouse wheel moves to the right. It's negative if the mouse wheel moves - - to the left.

- -

Calling myElement.mouseWheel(false) disables the - function.

- path: p5.Element/mouseWheel - mouseReleased: - description: > -

Calls a function when the mouse is released over the element.

- -

Calling myElement.mouseReleased(false) disables the - function.

- -

Note: Some mobile browsers may also trigger this event when the element - - receives a quick tap.

- path: p5.Element/mouseReleased - mouseClicked: - description: > -

Calls a function when the mouse is pressed and released over the - element.

- -

Calling myElement.mouseReleased(false) disables the - function.

- -

Note: Some mobile browsers may also trigger this event when the element - - receives a quick tap.

- path: p5.Element/mouseClicked - mouseMoved: - description: > -

Calls a function when the mouse moves over the element.

- -

Calling myElement.mouseMoved(false) disables the - function.

- path: p5.Element/mouseMoved - mouseOver: - description: > -

Calls a function when the mouse moves onto the element.

- -

Calling myElement.mouseOver(false) disables the - function.

- path: p5.Element/mouseOver - mouseOut: - description: > -

Calls a function when the mouse moves off the element.

- -

Calling myElement.mouseOut(false) disables the - function.

- path: p5.Element/mouseOut - touchStarted: - description: > -

Calls a function when the element is touched.

- -

Calling myElement.touchStarted(false) disables the - function.

- -

Note: Touch functions only work on mobile devices.

- path: p5.Element/touchStarted - touchMoved: - description: > -

Calls a function when the user touches the element and moves.

- -

Calling myElement.touchMoved(false) disables the - function.

- -

Note: Touch functions only work on mobile devices.

- path: p5.Element/touchMoved - touchEnded: - description: > -

Calls a function when the user stops touching the element.

- -

Calling myElement.touchMoved(false) disables the - function.

- -

Note: Touch functions only work on mobile devices.

- path: p5.Element/touchEnded - dragOver: - description: > -

Calls a function when a file is dragged over the element.

- -

Calling myElement.dragOver(false) disables the - function.

- path: p5.Element/dragOver - dragLeave: - description: > -

Calls a function when a file is dragged off the element.

- -

Calling myElement.dragLeave(false) disables the - function.

- path: p5.Element/dragLeave - addClass: - description: | -

Adds a class to the element.

- path: p5.Element/addClass - removeClass: - description: | -

Removes a class from the element.

- path: p5.Element/removeClass - hasClass: - description: | -

Checks if a class is already applied to element.

- path: p5.Element/hasClass - toggleClass: - description: | -

Toggles whether a class is applied to the element.

- path: p5.Element/toggleClass - child: - description: > -

Attaches the element as a child of another element.

- -

myElement.child() accepts either a string ID, DOM node, or - - p5.Element. For example, - - myElement.child(otherElement). If no argument is provided, an - array of - - children DOM nodes is returned.

- path: p5.Element/child - center: - description: > -

Centers the element either vertically, horizontally, or both.

- -

center() will center the element relative to its parent or - according to - - the page's body if the element has no parent.

- -

If no argument is passed, as in myElement.center() the - element is aligned - - both vertically and horizontally.

- path: p5.Element/center - html: - description: > -

Sets the inner HTML of the element, replacing any existing HTML.

- -

The second parameter, append, is optional. If - true is passed, as in - - myElement.html('hi', true), the HTML is appended instead of - replacing - - existing HTML.

- -

If no arguments are passed, as in myElement.html(), the - element's inner - - HTML is returned.

- path: p5.Element/html - position: - description: > -

Sets the element's position.

- -

The first two parameters, x and y, set the - element's position relative - - to the top-left corner of the web page.

- -

The third parameter, positionType, is optional. It sets - the element's - - positioning - scheme. - - positionType is a string that can be either - 'static', 'fixed', - - 'relative', 'sticky', 'initial', or - 'inherit'.

- -

If no arguments passed, as in myElement.position(), the - method returns - - the element's position in an object, as in { x: 0, y: 0 - }.

- path: p5.Element/position - style: - description: > -

Applies a style to the element by adding a - - CSS declaration.

- -

The first parameter, property, is a string. If the name of - a style - - property is passed, as in myElement.style('color'), the - method returns - - the current value as a string or null if it hasn't been set. - If a - - property:style string is passed, as in - - myElement.style('color:deeppink'), the method sets the style - property - - to value.

- -

The second parameter, value, is optional. It sets the - property's value. - - value can be a string, as in - - myElement.style('color', 'deeppink'), or a - - p5.Color object, as in - - myElement.style('color', myColor).

- path: p5.Element/style - attribute: - description: > -

Adds an - - attribute - - to the element.

- -

This method is useful for advanced tasks. Most commonly-used - attributes, - - such as id, can be set with their dedicated methods. For - example, - - nextButton.id('next') sets an element's id - attribute. Calling - - nextButton.attribute('id', 'next') has the same effect.

- -

The first parameter, attr, is the attribute's name as a - string. Calling - - myElement.attribute('align') returns the attribute's current - value as a - - string or null if it hasn't been set.

- -

The second parameter, value, is optional. It's a string - used to set the - - attribute's value. For example, calling - - myElement.attribute('align', 'center') sets the element's - horizontal - - alignment to center.

- path: p5.Element/attribute - removeAttribute: - description: > -

Removes an attribute from the element.

- -

The parameter attr is the attribute's name as a string. - For example, - - calling myElement.removeAttribute('align') removes its - align - - attribute if it's been set.

- path: p5.Element/removeAttribute - value: - description: > -

Returns or sets the element's value.

- -

Calling myElement.value() returns the element's current - value.

- -

The parameter, value, is an optional number or string. If - provided, - - as in myElement.value(123), it's used to set the element's - value.

- path: p5.Element/value - show: - description: | -

Shows the current element.

- path: p5.Element/show - hide: - description: | -

Hides the current element.

- path: p5.Element/hide - size: - description: > -

Sets the element's width and height.

- -

Calling myElement.size() without an argument returns the - element's size - - as an object with the properties width and - height. For example, - { width: 20, height: 10 }.

-

The first parameter, width, is optional. It's a number - used to set the - - element's width. Calling myElement.size(10)

- -

The second parameter, 'height, is also optional. It's a number - used to set the element's height. For example, calling - myElement.size(20, 10)` sets the element's width to 20 pixels and - height - - to 10 pixels.

- -

The constant AUTO can be used to adjust one dimension at a - time while - - maintaining the aspect ratio, which is width / height. For - example, - - consider an element that's 200 pixels wide and 100 pixels tall. Calling - - myElement.size(20, AUTO) sets the width to 20 pixels and - height to 10 - - pixels.

- -

Note: In the case of elements that need to load data, such as images, - wait - - to call myElement.size() until after the data loads.

- path: p5.Element/size - remove: - description: | -

Removes the element, stops all audio/video streams, and removes all - callback functions.

- path: p5.Element/remove - drop: - description: > -

Calls a function when the user drops a file on the element.

- -

The first parameter, callback, is a function to call once - the file loads. - - The callback function should have one parameter, file, that's - a - - p5.File object. If the user drops - multiple files on - - the element, callback, is called once for each file.

- -

The second parameter, fxn, is a function to call when the - browser detects - - one or more dropped files. The callback function should have one - - parameter, event, that's a - - DragEvent.

- path: p5.Element/drop - draggable: - description: > -

Makes the element draggable.

- -

The parameter, elmnt, is optional. If another - - p5.Element object is passed, as in - - myElement.draggable(otherElement), the other element will - become draggable.

- path: p5.Element/draggable -properties: - elt: - description: > -

The element's underlying HTMLElement object.

- -

The - - HTMLElement - - object's properties and methods can be used directly.

- path: p5.Element/elt - width: - description: | -

A Number property that stores the element's width.

- path: p5.Element/width - height: - description: | -

A Number property that stores the element's height.

- path: p5.Element/height -chainable: false ---- - - -# p5.Element diff --git a/src/content/reference/en/p5 copy/p5.File.mdx b/src/content/reference/en/p5 copy/p5.File.mdx deleted file mode 100644 index 78675c7a98..0000000000 --- a/src/content/reference/en/p5 copy/p5.File.mdx +++ /dev/null @@ -1,153 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L5482 -title: p5.File -module: DOM -submodule: DOM -file: src/dom/dom.js -description: | -

A class to describe a file.

-

p5.File objects are used by - myElement.drop() and - created by - createFileInput.

-line: 5482 -isConstructor: true -params: - - name: file - description: | -

wrapped file.

- type: File -example: - - |- - -
- - // Use the file input to load a - // file and display its info. - - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a file input and place it beneath the canvas. - // Call displayInfo() when the file loads. - let input = createFileInput(displayInfo); - input.position(0, 100); - - describe('A gray square with a file input beneath it. If the user loads a file, its info is written in black.'); - } - - // Display the p5.File's info once it loads. - function displayInfo(file) { - background(200); - - // Display the p5.File's name. - text(file.name, 10, 10, 80, 40); - - // Display the p5.File's type and subtype. - text(`${file.type}/${file.subtype}`, 10, 70); - - // Display the p5.File's size in bytes. - text(file.size, 10, 90); - } - -
- -
- - // Use the file input to select an image to - // load and display. - let img; - - function setup() { - createCanvas(100, 100); - - // Create a file input and place it beneath the canvas. - // Call handleImage() when the file image loads. - let input = createFileInput(handleImage); - input.position(0, 100); - - describe('A gray square with a file input beneath it. If the user selects an image file to load, it is displayed on the square.'); - } - - function draw() { - background(200); - - // Draw the image if it's ready. - if (img) { - image(img, 0, 0, width, height); - } - } - - // Use the p5.File's data once it loads. - function handleImage(file) { - // Check the p5.File's type. - if (file.type === 'image') { - // Create an image using using the p5.File's data. - img = createImg(file.data, ''); - - // Hide the image element so it doesn't appear twice. - img.hide(); - } else { - img = null; - } - } - -
-properties: - file: - description: > -

Underlying - - File - - object. All File properties and methods are accessible.

- path: p5.File/file - type: - description: > -

The file - - MIME type - - as a string.

- -

For example, 'image' and 'text' are both MIME - types.

- path: p5.File/type - subtype: - description: > -

The file subtype as a string.

- -

For example, a file with an 'image' - - MIME type - - may have a subtype such as png or jpeg.

- path: p5.File/subtype - name: - description: | -

The file name as a string.

- path: p5.File/name - size: - description: | -

The number of bytes in the file.

- path: p5.File/size - data: - description: | -

A string containing the file's data.

-

Data can be either image data, text contents, or a parsed object in the - case of JSON and p5.XML objects.

- path: p5.File/data -chainable: false ---- - - -# p5.File diff --git a/src/content/reference/en/p5 copy/p5.Font.mdx b/src/content/reference/en/p5 copy/p5.Font.mdx deleted file mode 100644 index 615d0406ee..0000000000 --- a/src/content/reference/en/p5 copy/p5.Font.mdx +++ /dev/null @@ -1,146 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/p5.Font.js#L13 -title: p5.Font -module: Typography -submodule: Loading & Displaying -file: src/typography/p5.Font.js -description: | -

A class to describe fonts.

-line: 13 -isConstructor: true -params: - - name: pInst - description: | -

pointer to p5 instance.

- type: P5 - optional: true -example: - - |- - -
- - let font; - - function preload() { - // Creates a p5.Font object. - font = loadFont('/assets/inconsolata.otf'); - } - - function setup() { - createCanvas(100, 100); - - // Style the text. - fill('deeppink'); - textFont(font); - textSize(36); - - // Display the text. - text('p5*js', 10, 50); - - describe('The text "p5*js" written in pink on a gray background.'); - } - -
-methods: - textBounds: - description: > -

Returns the bounding box for a string of text written using the - font.

- -

The bounding box is the smallest rectangle that can contain a string of - - text. font.textBounds() returns an object with the bounding - box's - - location and size. For example, calling font.textBounds('p5*js', 5, - 20) - - returns an object in the format - - { x: 5.7, y: 12.1 , w: 9.9, h: 28.6 }. The x and - y properties are - - always the coordinates of the bounding box's top-left corner.

- -

The first parameter, str, is a string of text. The second - and third - - parameters, x and y, are the text's position. By - default, they set the - - coordinates of the bounding box's bottom-left corner. See - - textAlign() for more ways to align - text.

- -

The fourth parameter, fontSize, is optional. It sets the - font size used to - - determine the bounding box. By default, font.textBounds() - will use the - - current textSize().

- path: p5.Font/textBounds - textToPoints: - description: > -

Returns an array of points outlining a string of text written using the - - font.

- -

Each point object in the array has three properties that describe the - - point's location and orientation, called its path angle. For example, - - { x: 10, y: 20, alpha: 450 }.

- -

The first parameter, str, is a string of text. The second - and third - - parameters, x and y, are the text's position. By - default, they set the - - coordinates of the bounding box's bottom-left corner. See - - textAlign() for more ways to align - text.

- -

The fourth parameter, fontSize, is optional. It sets the - text's font - - size. By default, font.textToPoints() will use the current - - textSize().

- -

The fifth parameter, options, is also optional. - font.textToPoints() - - expects an object with the following properties:

- -

sampleFactor is the ratio of the text's path length to the - number of - - samples. It defaults to 0.1. Higher values produce more points along the - - path and are more precise.

- -

simplifyThreshold removes collinear points if it's set to - a number other - - than 0. The value represents the threshold angle to use when determining - - whether two edges are collinear.

- path: p5.Font/textToPoints -properties: - font: - description: | -

The font's underlying - opentype.js - font object.

- path: p5.Font/font -chainable: false ---- - - -# p5.Font diff --git a/src/content/reference/en/p5 copy/p5.Framebuffer.mdx b/src/content/reference/en/p5 copy/p5.Framebuffer.mdx deleted file mode 100644 index 8100f48199..0000000000 --- a/src/content/reference/en/p5 copy/p5.Framebuffer.mdx +++ /dev/null @@ -1,443 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Framebuffer.js#L76 -title: p5.Framebuffer -module: Rendering -file: src/webgl/p5.Framebuffer.js -description: > -

A class to describe a high-performance drawing surface for textures.

- -

Each p5.Framebuffer object provides a dedicated drawing - surface called - - a framebuffer. They're similar to - - p5.Graphics objects but can run much - faster. - - Performance is improved because the framebuffer shares the same WebGL - - context as the canvas used to create it.

- -

p5.Framebuffer objects have all the drawing features of the - main - - canvas. Drawing instructions meant for the framebuffer must be placed - - between calls to - - myBuffer.begin() and - - myBuffer.end(). The resulting - image - - can be applied as a texture by passing the p5.Framebuffer object - to the - - texture() function, as in - texture(myBuffer). - - It can also be displayed on the main canvas by passing it to the - - image() function, as in - image(myBuffer, 0, 0).

- -

Note: createFramebuffer() is - the - - recommended way to create an instance of this class.

-line: 76 -isConstructor: true -params: - - name: target - description: | -

sketch instance or - p5.Graphics - object.

- type: p5.Graphics|p5 - - name: settings - description: | -

configuration options.

- type: Object - optional: true -methods: - resize: - description: > -

Resizes the framebuffer to a given width and height.

- -

The parameters, width and height, set the - dimensions of the - - framebuffer. For example, calling myBuffer.resize(300, 500) - resizes - - the framebuffer to 300×500 pixels, then sets myBuffer.width - to 300 - - and myBuffer.height 500.

- path: p5.Framebuffer/resize - pixelDensity: - description: > -

Sets the framebuffer's pixel density or returns its current - density.

- -

Computer displays are grids of little lights called pixels. A display's - - pixel density describes how many pixels it packs into an area. Displays - - with smaller pixels have a higher pixel density and create sharper - - images.

- -

The parameter, density, is optional. If a number is - passed, as in - - myBuffer.pixelDensity(1), it sets the framebuffer's pixel - density. By - - default, the framebuffer's pixel density will match that of the canvas - - where it was created. All canvases default to match the display's pixel - - density.

- -

Calling myBuffer.pixelDensity() without an argument - returns its current - - pixel density.

- path: p5.Framebuffer/pixelDensity - autoSized: - description: > -

Toggles the framebuffer's autosizing mode or returns the current - mode.

- -

By default, the framebuffer automatically resizes to match the canvas - - that created it. Calling myBuffer.autoSized(false) disables - this - - behavior and calling myBuffer.autoSized(true) re-enables - it.

- -

Calling myBuffer.autoSized() without an argument returns - true if - - the framebuffer automatically resizes and false if not.

- path: p5.Framebuffer/autoSized - createCamera: - description: > -

Creates a new - - p5.Camera object to use with the - framebuffer.

- -

The new camera is initialized with a default position (0, 0, - 800) and a - - default perspective projection. Its properties can be controlled with - - p5.Camera methods such as - myCamera.lookAt(0, 0, 0).

- -

Framebuffer cameras should be created between calls to - - myBuffer.begin() and - - myBuffer.end() like so:

- -
let myCamera;
-
-
-      myBuffer.begin();
-
-
-      // Create the camera for the framebuffer.
-
-      myCamera = myBuffer.createCamera();
-
-
-      myBuffer.end();
-
-      
- -

Calling setCamera() updates the - - framebuffer's projection using the camera. - - resetMatrix() must also be called - for the - - view to change properly:

- -
myBuffer.begin();
-
-
-      // Set the camera for the framebuffer.
-
-      setCamera(myCamera);
-
-
-      // Reset all transformations.
-
-      resetMatrix();
-
-
-      // Draw stuff...
-
-
-      myBuffer.end();
-
-      
- path: p5.Framebuffer/createCamera - remove: - description: > -

Deletes the framebuffer from GPU memory.

- -

Calling myBuffer.remove() frees the GPU memory used by the - framebuffer. - - The framebuffer also uses a bit of memory on the CPU which can be freed - - like so:

- -
// Delete the framebuffer from GPU memory.
-
-      myBuffer.remove();
-
-
-      // Delete the framebuffer from CPU memory.
-
-      myBuffer = undefined;
-
-      
- -

Note: All variables that reference the framebuffer must be assigned - - the value undefined to delete the framebuffer from CPU - memory. If any - - variable still refers to the framebuffer, then it won't be garbage - - collected.

- path: p5.Framebuffer/remove - begin: - description: > -

Begins drawing shapes to the framebuffer.

- -

myBuffer.begin() and myBuffer.end() - - allow shapes to be drawn to the framebuffer. myBuffer.begin() - begins - - drawing to the framebuffer and - - myBuffer.end() stops drawing - to the - - framebuffer. Changes won't be visible until the framebuffer is displayed - - as an image or texture.

- path: p5.Framebuffer/begin - end: - description: > -

Stops drawing shapes to the framebuffer.

- -

myBuffer.begin() and - myBuffer.end() - - allow shapes to be drawn to the framebuffer. - - myBuffer.begin() begins - drawing to - - the framebuffer and myBuffer.end() stops drawing to the - framebuffer. - - Changes won't be visible until the framebuffer is displayed as an image - - or texture.

- path: p5.Framebuffer/end - draw: - description: > -

Draws to the framebuffer by calling a function that contains drawing - - instructions.

- -

The parameter, callback, is a function with the drawing - instructions - - for the framebuffer. For example, calling - myBuffer.draw(myFunction) - - will call a function named myFunction() to draw to the - framebuffer. - - Doing so has the same effect as the following:

- -
myBuffer.begin();
-
-      myFunction();
-
-      myBuffer.end();
-
-      
- path: p5.Framebuffer/draw - loadPixels: - description: > -

Loads the current value of each pixel in the framebuffer into its - - pixels array.

- -

myBuffer.loadPixels() must be called before reading from - or writing to - - myBuffer.pixels.

- path: p5.Framebuffer/loadPixels - get: - description: > -

Gets a pixel or a region of pixels from the framebuffer.

- -

myBuffer.get() is easy to use but it's not as fast as - - myBuffer.pixels. Use - - myBuffer.pixels to read - many pixel - - values.

- -

The version of myBuffer.get() with no parameters returns - the entire - - framebuffer as a a p5.Image - object.

- -

The version of myBuffer.get() with two parameters - interprets them as - - coordinates. It returns an array with the [R, G, B, A] values - of the - - pixel at the given point.

- -

The version of myBuffer.get() with four parameters - interprets them as - - coordinates and dimensions. It returns a subsection of the framebuffer as - - a p5.Image object. The first two - parameters are - - the coordinates for the upper-left corner of the subsection. The last two - - parameters are the width and height of the subsection.

- path: p5.Framebuffer/get - updatePixels: - description: > -

Updates the framebuffer with the RGBA values in the - - pixels array.

- -

myBuffer.updatePixels() only needs to be called after - changing values - - in the myBuffer.pixels - array. Such - - changes can be made directly after calling - - myBuffer.loadPixels().

- path: p5.Framebuffer/updatePixels -properties: - pixels: - description: > -

An array containing the color of each pixel in the framebuffer.

- -

myBuffer.loadPixels() - must be - - called before accessing the myBuffer.pixels array. - - myBuffer.updatePixels() - - must be called after any changes are made.

- -

Note: Updating pixels via this property is slower than drawing to the - - framebuffer directly. Consider using a - - p5.Shader object instead of looping - over - - myBuffer.pixels.

- path: p5.Framebuffer/pixels - color: - description: > -

An object that stores the framebuffer's color data.

- -

Each framebuffer uses a - - WebGLTexture - - object internally to store its color data. The myBuffer.color - property - - makes it possible to pass this data directly to other functions. For - - example, calling texture(myBuffer.color) or - - myShader.setUniform('colorTexture', myBuffer.color) may be - helpful for - - advanced use cases.

- -

Note: By default, a framebuffer's y-coordinates are flipped compared to - - images and videos. It's easy to flip a framebuffer's y-coordinates as - - needed when applying it as a texture. For example, calling - - plane(myBuffer.width, -myBuffer.height) will flip the - framebuffer.

- path: p5.Framebuffer/color - depth: - description: > -

An object that stores the framebuffer's depth data.

- -

Each framebuffer uses a - - WebGLTexture - - object internally to store its depth data. The myBuffer.depth - property - - makes it possible to pass this data directly to other functions. For - - example, calling texture(myBuffer.depth) or - - myShader.setUniform('depthTexture', myBuffer.depth) may be - helpful for - - advanced use cases.

- -

Note: By default, a framebuffer's y-coordinates are flipped compared to - - images and videos. It's easy to flip a framebuffer's y-coordinates as - - needed when applying it as a texture. For example, calling - - plane(myBuffer.width, -myBuffer.height) will flip the - framebuffer.

- path: p5.Framebuffer/depth -chainable: false ---- - - -# p5.Framebuffer diff --git a/src/content/reference/en/p5 copy/p5.Geometry.mdx b/src/content/reference/en/p5 copy/p5.Geometry.mdx deleted file mode 100644 index 0faa7daf7a..0000000000 --- a/src/content/reference/en/p5 copy/p5.Geometry.mdx +++ /dev/null @@ -1,793 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Geometry.js#L13 -title: p5.Geometry -module: Shape -submodule: 3D Primitives -file: src/webgl/p5.Geometry.js -description: > -

A class to describe a 3D shape.

- -

Each p5.Geometry object represents a 3D shape as a set of - connected - - points called vertices. All 3D shapes are made by connecting vertices - to - - form triangles that are stitched together. Each triangular patch on the - - geometry's surface is called a face. The geometry stores information - - about its vertices and faces for use with effects such as lighting and - - texture mapping.

- -

The first parameter, detailX, is optional. If a number is - passed, as in - - new p5.Geometry(24), it sets the number of triangle subdivisions - to use - - along the geometry's x-axis. By default, detailX is 1.

- -

The second parameter, detailY, is also optional. If a number - is passed, - - as in new p5.Geometry(24, 16), it sets the number of triangle - - subdivisions to use along the geometry's y-axis. By default, - detailX is - - 1.

- -

The third parameter, callback, is also optional. If a function - is passed, - - as in new p5.Geometry(24, 16, createShape), it will be called - once to add - - vertices to the new 3D shape.

-line: 13 -isConstructor: true -params: - - name: detailX - description: | -

number of vertices along the x-axis.

- type: Integer - optional: true - - name: detailY - description: | -

number of vertices along the y-axis.

- type: Integer - optional: true - - name: callback - description: | -

function to call once the geometry is created.

- type: Function - optional: true -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - let myGeometry; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Geometry object. - myGeometry = new p5.Geometry(); - - // Create p5.Vector objects to position the vertices. - let v0 = createVector(-40, 0, 0); - let v1 = createVector(0, -40, 0); - let v2 = createVector(40, 0, 0); - - // Add the vertices to the p5.Geometry object's vertices array. - myGeometry.vertices.push(v0, v1, v2); - - describe('A white triangle drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the p5.Geometry object. - model(myGeometry); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let myGeometry; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Geometry object using a callback function. - myGeometry = new p5.Geometry(1, 1, createShape); - - describe('A white triangle drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the p5.Geometry object. - model(myGeometry); - } - - function createShape() { - // Create p5.Vector objects to position the vertices. - let v0 = createVector(-40, 0, 0); - let v1 = createVector(0, -40, 0); - let v2 = createVector(40, 0, 0); - - // "this" refers to the p5.Geometry object being created. - - // Add the vertices to the p5.Geometry object's vertices array. - this.vertices.push(v0, v1, v2); - - // Add an array to list which vertices belong to the face. - // Vertices are listed in clockwise "winding" order from - // left to top to right. - this.faces.push([0, 1, 2]); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - let myGeometry; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Geometry object using a callback function. - myGeometry = new p5.Geometry(1, 1, createShape); - - describe('A white triangle drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the p5.Geometry object. - model(myGeometry); - } - - function createShape() { - // Create p5.Vector objects to position the vertices. - let v0 = createVector(-40, 0, 0); - let v1 = createVector(0, -40, 0); - let v2 = createVector(40, 0, 0); - - // "this" refers to the p5.Geometry object being created. - - // Add the vertices to the p5.Geometry object's vertices array. - this.vertices.push(v0, v1, v2); - - // Add an array to list which vertices belong to the face. - // Vertices are listed in clockwise "winding" order from - // left to top to right. - this.faces.push([0, 1, 2]); - - // Compute the surface normals to help with lighting. - this.computeNormals(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - // Adapted from Paul Wheeler's wonderful p5.Geometry tutorial. - // https://www.paulwheeler.us/articles/custom-3d-geometry-in-p5js/ - // CC-BY-SA 4.0 - - let myGeometry; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the p5.Geometry object. - // Set detailX to 48 and detailY to 2. - // >>> try changing them. - myGeometry = new p5.Geometry(48, 2, createShape); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the p5.Geometry object. - strokeWeight(0.2); - - // Draw the p5.Geometry object. - model(myGeometry); - } - - function createShape() { - // "this" refers to the p5.Geometry object being created. - - // Define the Möbius strip with a few parameters. - let spread = 0.1; - let radius = 30; - let stripWidth = 15; - let xInterval = 4 * PI / this.detailX; - let yOffset = -stripWidth / 2; - let yInterval = stripWidth / this.detailY; - - for (let j = 0; j <= this.detailY; j += 1) { - // Calculate the "vertical" point along the strip. - let v = yOffset + yInterval * j; - - for (let i = 0; i <= this.detailX; i += 1) { - // Calculate the angle of rotation around the strip. - let u = i * xInterval; - - // Calculate the coordinates of the vertex. - let x = (radius + v * cos(u / 2)) * cos(u) - sin(u / 2) * 2 * spread; - let y = (radius + v * cos(u / 2)) * sin(u); - if (u < TWO_PI) { - y += sin(u) * spread; - } else { - y -= sin(u) * spread; - } - let z = v * sin(u / 2) + sin(u / 4) * 4 * spread; - - // Create a p5.Vector object to position the vertex. - let vert = createVector(x, y, z); - - // Add the vertex to the p5.Geometry object's vertices array. - this.vertices.push(vert); - } - } - - // Compute the faces array. - this.computeFaces(); - - // Compute the surface normals to help with lighting. - this.computeNormals(); - } - -
-methods: - calculateBoundingBox: - description: > -

Calculates the position and size of the smallest box that contains the - geometry.

- -

A bounding box is the smallest rectangular prism that contains the - entire - - geometry. It's defined by the box's minimum and maximum coordinates along - - each axis, as well as the size (length) and offset (center).

- -

Calling myGeometry.calculateBoundingBox() returns an - object with four - - properties that describe the bounding box:

- -
// Get myGeometry's bounding box.
-
-      let bbox = myGeometry.calculateBoundingBox();
-
-
-      // Print the bounding box to the console.
-
-      console.log(bbox);
-
-
-      // {
-
-      //  // The minimum coordinate along each axis.
-
-      //  min: { x: -1, y: -2, z: -3 },
-
-      //
-
-      //  // The maximum coordinate along each axis.
-
-      //  max: { x: 1, y: 2, z: 3},
-
-      //
-
-      //  // The size (length) along each axis.
-
-      //  size: { x: 2, y: 4, z: 6},
-
-      //
-
-      //  // The offset (center) along each axis.
-
-      //  offset: { x: 0, y: 0, z: 0}
-
-      // }
-
-      
- path: p5.Geometry/calculateBoundingBox - clearColors: - description: > -

Removes the geometry’s internal colors.

- -

p5.Geometry objects can be created with "internal colors" - assigned to - - vertices or the entire shape. When a geometry has internal colors, - - fill() has no effect. Calling - - myGeometry.clearColors() allows the - - fill() function to apply color to the - geometry.

- path: p5.Geometry/clearColors - saveObj: - description: > -

The saveObj() function exports p5.Geometry - objects as - - 3D models in the Wavefront .obj file format. - - This way, you can use the 3D shapes you create in p5.js in other software - - for rendering, animation, 3D printing, or more.

- -

The exported .obj file will include the faces and vertices of the - p5.Geometry, - - as well as its texture coordinates and normals, if it has them.

- path: p5.Geometry/saveObj - saveStl: - description: > -

The saveStl() function exports p5.Geometry - objects as - - 3D models in the STL stereolithography file format. - - This way, you can use the 3D shapes you create in p5.js in other software - - for rendering, animation, 3D printing, or more.

- -

The exported .stl file will include the faces, vertices, and normals of - the p5.Geometry.

- -

By default, this method saves a text-based .stl file. Alternatively, - you can save a more compact - - but less human-readable binary .stl file by passing { binary: true - } as a second parameter.

- path: p5.Geometry/saveStl - flipU: - description: > -

Flips the geometry’s texture u-coordinates.

- -

In order for texture() to work, - the geometry - - needs a way to map the points on its surface to the pixels in a - rectangular - - image that's used as a texture. The geometry's vertex at coordinates - - (x, y, z) maps to the texture image's pixel at coordinates - (u, v).

- -

The myGeometry.uvs array - stores the - - (u, v) coordinates for each vertex in the order it was added - to the - - geometry. Calling myGeometry.flipU() flips a geometry's - u-coordinates - - so that the texture appears mirrored horizontally.

- -

For example, a plane's four vertices are added clockwise starting from - the - - top-left corner. Here's how calling myGeometry.flipU() would - change a - - plane's texture coordinates:

- -
// Print the original texture coordinates.
-
-      // Output: [0, 0, 1, 0, 0, 1, 1, 1]
-
-      console.log(myGeometry.uvs);
-
-
-      // Flip the u-coordinates.
-
-      myGeometry.flipU();
-
-
-      // Print the flipped texture coordinates.
-
-      // Output: [1, 0, 0, 0, 1, 1, 0, 1]
-
-      console.log(myGeometry.uvs);
-
-
-      // Notice the swaps:
-
-      // Top vertices: [0, 0, 1, 0] --> [1, 0, 0, 0]
-
-      // Bottom vertices: [0, 1, 1, 1] --> [1, 1, 0, 1]
-
-      
- path: p5.Geometry/flipU - flipV: - description: > -

Flips the geometry’s texture v-coordinates.

- -

In order for texture() to work, - the geometry - - needs a way to map the points on its surface to the pixels in a - rectangular - - image that's used as a texture. The geometry's vertex at coordinates - - (x, y, z) maps to the texture image's pixel at coordinates - (u, v).

- -

The myGeometry.uvs array - stores the - - (u, v) coordinates for each vertex in the order it was added - to the - - geometry. Calling myGeometry.flipV() flips a geometry's - v-coordinates - - so that the texture appears mirrored vertically.

- -

For example, a plane's four vertices are added clockwise starting from - the - - top-left corner. Here's how calling myGeometry.flipV() would - change a - - plane's texture coordinates:

- -
// Print the original texture coordinates.
-
-      // Output: [0, 0, 1, 0, 0, 1, 1, 1]
-
-      console.log(myGeometry.uvs);
-
-
-      // Flip the v-coordinates.
-
-      myGeometry.flipV();
-
-
-      // Print the flipped texture coordinates.
-
-      // Output: [0, 1, 1, 1, 0, 0, 1, 0]
-
-      console.log(myGeometry.uvs);
-
-
-      // Notice the swaps:
-
-      // Left vertices: [0, 0] <--> [1, 0]
-
-      // Right vertices: [1, 0] <--> [1, 1]
-
-      
- path: p5.Geometry/flipV - computeFaces: - description: > -

Computes the geometry's faces using its vertices.

- -

All 3D shapes are made by connecting sets of points called - vertices. A - - geometry's surface is formed by connecting vertices to form triangles that - - are stitched together. Each triangular patch on the geometry's surface is - - called a face. myGeometry.computeFaces() performs - the math needed to - - define each face based on the distances between vertices.

- -

The geometry's vertices are stored as p5.Vector - - objects in the myGeometry.vertices - - array. The geometry's first vertex is the - - p5.Vector object at - myGeometry.vertices[0], - - its second vertex is myGeometry.vertices[1], its third vertex - is - - myGeometry.vertices[2], and so on.

- -

Calling myGeometry.computeFaces() fills the - - myGeometry.faces array with - three-element - - arrays that list the vertices that form each face. For example, a geometry - - made from a rectangle has two faces because a rectangle is made by joining - - two triangles. myGeometry.faces for a - - rectangle would be the two-dimensional array - - [[0, 1, 2], [2, 1, 3]]. The first face, - myGeometry.faces[0], is the - - array [0, 1, 2] because it's formed by connecting - - myGeometry.vertices[0], - myGeometry.vertices[1],and - - myGeometry.vertices[2]. The second face, - myGeometry.faces[1], is the - - array [2, 1, 3] because it's formed by connecting - - myGeometry.vertices[2], myGeometry.vertices[1], - and - - myGeometry.vertices[3].

- -

Note: myGeometry.computeFaces() only works when geometries - have four or more vertices.

- path: p5.Geometry/computeFaces - computeNormals: - description: > -

Calculates the normal vector for each vertex on the geometry.

- -

All 3D shapes are made by connecting sets of points called - vertices. A - - geometry's surface is formed by connecting vertices to create triangles - - that are stitched together. Each triangular patch on the geometry's - - surface is called a face. - myGeometry.computeNormals() performs the - - math needed to orient each face. Orientation is important for lighting - - and other effects.

- -

A face's orientation is defined by its normal vector which - points out - - of the face and is normal (perpendicular) to the surface. Calling - - myGeometry.computeNormals() first calculates each face's - normal vector. - - Then it calculates the normal vector for each vertex by averaging the - - normal vectors of the faces surrounding the vertex. The vertex normals - - are stored as p5.Vector objects in - the - - myGeometry.vertexNormals - array.

- -

The first parameter, shadingType, is optional. Passing the - constant - - FLAT, as in myGeometry.computeNormals(FLAT), - provides neighboring - - faces with their own copies of the vertices they share. Surfaces appear - - tiled with flat shading. Passing the constant SMOOTH, as in - - myGeometry.computeNormals(SMOOTH), makes neighboring faces - reuse their - - shared vertices. Surfaces appear smoother with smooth shading. By - - default, shadingType is FLAT.

- -

The second parameter, options, is also optional. If an - object with a - - roundToPrecision property is passed, as in - - myGeometry.computeNormals(SMOOTH, { roundToPrecision: 5 }), - it sets the - - number of decimal places to use for calculations. By default, - - roundToPrecision uses 3 decimal places.

- path: p5.Geometry/computeNormals - normalize: - description: > -

Transforms the geometry's vertices to fit snugly within a 100×100×100 - box - - centered at the origin.

- -

Calling myGeometry.normalize() translates the geometry's - vertices so that - - they're centered at the origin (0, 0, 0). Then it scales the - vertices so - - that they fill a 100×100×100 box. As a result, small geometries will grow - - and large geometries will shrink.

- -

Note: myGeometry.normalize() only works when called in the - - setup() function.

- path: p5.Geometry/normalize -properties: - vertices: - description: > -

An array with the geometry's vertices.

- -

The geometry's vertices are stored as - - p5.Vector objects in the - myGeometry.vertices - - array. The geometry's first vertex is the - - p5.Vector object at - myGeometry.vertices[0], - - its second vertex is myGeometry.vertices[1], its third vertex - is - - myGeometry.vertices[2], and so on.

- path: p5.Geometry/vertices - vertexNormals: - description: > -

An array with the vectors that are normal to the geometry's - vertices.

- -

A face's orientation is defined by its normal vector which - points out - - of the face and is normal (perpendicular) to the surface. Calling - - myGeometry.computeNormals() first calculates each face's - normal - - vector. Then it calculates the normal vector for each vertex by - - averaging the normal vectors of the faces surrounding the vertex. The - - vertex normals are stored as p5.Vector - - objects in the myGeometry.vertexNormals array.

- path: p5.Geometry/vertexNormals - faces: - description: > -

An array that lists which of the geometry's vertices form each of its - - faces.

- -

All 3D shapes are made by connecting sets of points called - vertices. A - - geometry's surface is formed by connecting vertices to form triangles - - that are stitched together. Each triangular patch on the geometry's - - surface is called a face.

- -

The geometry's vertices are stored as - - p5.Vector objects in the - - myGeometry.vertices array. - The - - geometry's first vertex is the p5.Vector - - object at myGeometry.vertices[0], its second vertex is - - myGeometry.vertices[1], its third vertex is - myGeometry.vertices[2], - - and so on.

- -

For example, a geometry made from a rectangle has two faces because a - - rectangle is made by joining two triangles. myGeometry.faces - for a - - rectangle would be the two-dimensional array [[0, 1, 2], [2, 1, - 3]]. - - The first face, myGeometry.faces[0], is the array [0, - 1, 2] because - - it's formed by connecting myGeometry.vertices[0], - - myGeometry.vertices[1],and - myGeometry.vertices[2]. The second face, - - myGeometry.faces[1], is the array [2, 1, 3] - because it's formed by - - connecting myGeometry.vertices[2], - myGeometry.vertices[1],and - - myGeometry.vertices[3].

- path: p5.Geometry/faces - uvs: - description: > -

An array that lists the texture coordinates for each of the geometry's - - vertices.

- -

In order for texture() to work, - the geometry - - needs a way to map the points on its surface to the pixels in a - - rectangular image that's used as a texture. The geometry's vertex at - - coordinates (x, y, z) maps to the texture image's pixel at - coordinates - - (u, v).

- -

The myGeometry.uvs array stores the (u, v) - coordinates for each - - vertex in the order it was added to the geometry. For example, the - - first vertex, myGeometry.vertices[0], has its (u, - v) coordinates - - stored at myGeometry.uvs[0] and - myGeometry.uvs[1].

- path: p5.Geometry/uvs -chainable: false ---- - - -# p5.Geometry diff --git a/src/content/reference/en/p5 copy/p5.Graphics.mdx b/src/content/reference/en/p5 copy/p5.Graphics.mdx deleted file mode 100644 index d0b7c3aff8..0000000000 --- a/src/content/reference/en/p5 copy/p5.Graphics.mdx +++ /dev/null @@ -1,261 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/p5.Graphics.js#L10 -title: p5.Graphics -module: Rendering -submodule: Rendering -file: src/core/p5.Graphics.js -description: > -

A class to describe a drawing surface that's separate from the main - canvas.

- -

Each p5.Graphics object provides a dedicated drawing surface - called a - - graphics buffer. Graphics buffers are helpful when drawing should - happen - - offscreen. For example, separate scenes can be drawn offscreen and - - displayed only when needed.

- -

p5.Graphics objects have nearly all the drawing features of - the main - - canvas. For example, calling the method myGraphics.circle(50, 50, - 20) - - draws to the graphics buffer. The resulting image can be displayed on the - - main canvas by passing the p5.Graphics object to the - - image() function, as in - image(myGraphics, 0, 0).

- -

Note: createGraphics() is the - recommended - - way to create an instance of this class.

-line: 10 -isConstructor: true -params: - - name: width - description: | -

width of the graphics buffer in pixels.

- type: Number - - name: height - description: | -

height of the graphics buffer in pixels.

- type: Number - - name: renderer - description: | -

renderer to use, either P2D or WEBGL.

- type: Constant - - name: pInst - description: | -

sketch instance.

- type: P5 - optional: true - - name: canvas - description: | -

existing <canvas> element to use.

- type: HTMLCanvasElement - optional: true -example: - - |- - -
- - let pg; - - function setup() { - createCanvas(100, 100); - - // Create a p5.Graphics object. - pg = createGraphics(50, 50); - - // Draw to the p5.Graphics object. - pg.background(100); - pg.circle(25, 25, 20); - - describe('A dark gray square with a white circle at its center drawn on a gray background.'); - } - - function draw() { - background(200); - - // Display the p5.Graphics object. - image(pg, 25, 25); - } - -
- -
- - // Click the canvas to display the graphics buffer. - - let pg; - - function setup() { - createCanvas(100, 100); - - // Create a p5.Graphics object. - pg = createGraphics(50, 50); - - describe('A square appears on a gray background when the user presses the mouse. The square cycles between white and black.'); - } - - function draw() { - background(200); - - // Calculate the background color. - let bg = frameCount % 255; - - // Draw to the p5.Graphics object. - pg.background(bg); - - // Display the p5.Graphics object while - // the user presses the mouse. - if (mouseIsPressed === true) { - image(pg, 25, 25); - } - } - -
-methods: - reset: - description: > -

Resets the graphics buffer's transformations and lighting.

- -

By default, the main canvas resets certain transformation and lighting - - values each time draw() executes. - p5.Graphics - - objects must reset these values manually by calling - myGraphics.reset().

- path: p5.Graphics/reset - remove: - description: > -

Removes the graphics buffer from the web page.

- -

Calling myGraphics.remove() removes the graphics buffer's - - element from the web page. The graphics buffer also - uses - - a bit of memory on the CPU that can be freed like so:

- -
// Remove the graphics buffer from the web
-      page.
-
-      myGraphics.remove();
-
-
-      // Delete the graphics buffer from CPU memory.
-
-      myGraphics = undefined;
-
-      
- -

Note: All variables that reference the graphics buffer must be assigned - - the value undefined to delete the graphics buffer from CPU - memory. If any - - variable still refers to the graphics buffer, then it won't be garbage - - collected.

- path: p5.Graphics/remove - createFramebuffer: - description: > -

Creates a new p5.Framebuffer - object with - - the same WebGL context as the graphics buffer.

- -

p5.Framebuffer objects are - separate drawing - - surfaces that can be used as textures in WebGL mode. They're similar to - - p5.Graphics objects and generally - run much - - faster when used as textures. Creating a - - p5.Framebuffer object in the - same context - - as the graphics buffer makes this speedup possible.

- -

The parameter, options, is optional. An object can be - passed to configure - - the p5.Framebuffer object. The - available - - properties are:

- -
    - -
  • format: data format of the texture, either - UNSIGNED_BYTE, FLOAT, or - HALF_FLOAT. Default is UNSIGNED_BYTE.
  • - -
  • channels: whether to store RGB or - RGBA color channels. Default is to match the graphics buffer - which is RGBA.
  • - -
  • depth: whether to include a depth buffer. Default is - true.
  • - -
  • depthFormat: data format of depth information, either - UNSIGNED_INT or FLOAT. Default is - FLOAT.
  • - -
  • stencil: whether to include a stencil buffer for masking. - depth must be true for this feature to work. - Defaults to the value of depth which is - true.
  • - -
  • antialias: whether to perform anti-aliasing. If set to - true, as in { antialias: true }, 2 samples will - be used by default. The number of samples can also be set, as in { - antialias: 4 }. Default is to match setAttributes() which is - false (true in Safari).
  • - -
  • width: width of the p5.Framebuffer object. Default is - to always match the graphics buffer width.
  • - -
  • height: height of the p5.Framebuffer object. Default is - to always match the graphics buffer height.
  • - -
  • density: pixel density of the p5.Framebuffer object. Default is - to always match the graphics buffer pixel density.
  • - -
  • textureFiltering: how to read values from the p5.Framebuffer object. Either - LINEAR (nearby pixels will be interpolated) or - NEAREST (no interpolation). Generally, use - LINEAR when using the texture as an image and - NEAREST if reading the texture as data. Default is - LINEAR.
  • - -
- -

If the width, height, or density - attributes are set, they won't - - automatically match the graphics buffer and must be changed manually.

- path: p5.Graphics/createFramebuffer -chainable: false ---- - - -# p5.Graphics diff --git a/src/content/reference/en/p5 copy/p5.Image.mdx b/src/content/reference/en/p5 copy/p5.Image.mdx deleted file mode 100644 index 63e2a668fe..0000000000 --- a/src/content/reference/en/p5 copy/p5.Image.mdx +++ /dev/null @@ -1,519 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/p5.Image.js#L21 -title: p5.Image -module: Image -submodule: Image -file: src/image/p5.Image.js -description: > -

A class to describe an image.

- -

Images are rectangular grids of pixels that can be displayed and - modified.

- -

Existing images can be loaded by calling - - loadImage(). Blank images can be - created by - - calling createImage(). - p5.Image objects - - have methods for common tasks such as applying filters and modifying - - pixel values.

-line: 21 -isConstructor: true -params: - - name: width - description: '' - type: Number - - name: height - description: '' - type: Number -example: - - |- - -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0); - - describe('An image of a brick wall.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Apply the GRAY filter. - img.filter(GRAY); - - // Display the image. - image(img, 0, 0); - - describe('A grayscale image of a brick wall.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Image object. - let img = createImage(66, 66); - - // Load the image's pixels. - img.loadPixels(); - - // Set the pixels to black. - for (let x = 0; x < img.width; x += 1) { - for (let y = 0; y < img.height; y += 1) { - img.set(x, y, 0); - } - } - - // Update the image. - img.updatePixels(); - - // Display the image. - image(img, 17, 17); - - describe('A black square drawn in the middle of a gray square.'); - } - -
-methods: - pixelDensity: - description: | -

Gets or sets the pixel density for high pixel density displays.

-

By default, the density will be set to 1.

-

Call this method with no arguments to get the default density, or pass - in a number to set the density. If a non-positive number is provided, - it defaults to 1.

- path: p5.Image/pixelDensity - loadPixels: - description: > -

Loads the current value of each pixel in the image into the - img.pixels - - array.

- -

img.loadPixels() must be called before reading or - modifying pixel - - values.

- path: p5.Image/loadPixels - updatePixels: - description: > -

Updates the canvas with the RGBA values in the - - img.pixels array.

- -

img.updatePixels() only needs to be called after changing - values in - - the img.pixels array. Such - changes can be - - made directly after calling - - img.loadPixels() or by - calling - - img.set().

- -

The optional parameters x, y, - width, and height define a - - subsection of the image to update. Doing so can improve performance in - - some cases.

- -

If the image was loaded from a GIF, then calling - img.updatePixels() - - will update the pixels in current frame.

- path: p5.Image/updatePixels - get: - description: > -

Gets a pixel or a region of pixels from the image.

- -

img.get() is easy to use but it's not as fast as - - img.pixels. Use - - img.pixels to read many pixel - values.

- -

The version of img.get() with no parameters returns the - entire image.

- -

The version of img.get() with two parameters, as in - img.get(10, 20), - - interprets them as coordinates. It returns an array with the - - [R, G, B, A] values of the pixel at the given point.

- -

The version of img.get() with four parameters, as in - - img,get(10, 20, 50, 90), interprets them as - - coordinates and dimensions. The first two parameters are the coordinates - - of the upper-left corner of the subsection. The last two parameters are - - the width and height of the subsection. It returns a subsection of the - - canvas in a new p5.Image object.

- -

Use img.get() instead of get() to work directly - - with images.

- path: p5.Image/get - set: - description: > -

Sets the color of one or more pixels within an image.

- -

img.set() is easy to use but it's not as fast as - - img.pixels. Use - - img.pixels to set many pixel - values.

- -

img.set() interprets the first two parameters as x- and - y-coordinates. It - - interprets the last parameter as a grayscale value, a [R, G, B, - A] pixel - - array, a p5.Color object, or another - - p5.Image object.

- -

img.updatePixels() must - be called - - after using img.set() for changes to appear.

- path: p5.Image/set - resize: - description: > -

Resizes the image to a given width and height.

- -

The image's original aspect ratio can be kept by passing 0 for either - - width or height. For example, calling - img.resize(50, 0) on an image - - that was 500 × 300 pixels will resize it to 50 × 30 pixels.

- path: p5.Image/resize - copy: - description: > -

Copies pixels from a source image to this image.

- -

The first parameter, srcImage, is an optional - - p5.Image object to copy. If a source - image isn't - - passed, then img.copy() can copy a region of this image to - another - - region.

- -

The next four parameters, sx, sy, - sw, and sh determine the region - - to copy from the source image. (sx, sy) is the top-left - corner of the - - region. sw and sh are the region's width and - height.

- -

The next four parameters, dx, dy, - dw, and dh determine the region - - of this image to copy into. (dx, dy) is the top-left corner - of the - - region. dw and dh are the region's width and - height.

- -

Calling img.copy() will scale pixels from the source - region if it isn't - - the same size as the destination region.

- path: p5.Image/copy - mask: - description: > -

Masks part of the image with another.

- -

img.mask() uses another p5.Image object's - - alpha channel as the alpha channel for this image. Masks are cumulative - - and can't be removed once applied. If the mask has a different - - pixel density from this image, the mask will be scaled.

- path: p5.Image/mask - filter: - description: > -

Applies an image filter to the image.

- -

The preset options are:

- -

INVERT - - Inverts the colors in the image. No parameter is used.

- -

GRAY - - Converts the image to grayscale. No parameter is used.

- -

THRESHOLD - - Converts the image to black and white. Pixels with a grayscale value - - above a given threshold are converted to white. The rest are converted to - - black. The threshold must be between 0.0 (black) and 1.0 (white). If no - - value is specified, 0.5 is used.

- -

OPAQUE - - Sets the alpha channel to be entirely opaque. No parameter is used.

- -

POSTERIZE - - Limits the number of colors in the image. Each color channel is limited to - - the number of colors specified. Values between 2 and 255 are valid, but - - results are most noticeable with lower values. The default value is 4.

- -

BLUR - - Blurs the image. The level of blurring is specified by a blur radius. - Larger - - values increase the blur. The default value is 4. A gaussian blur is used - - in P2D mode. A box blur is used in WEBGL - mode.

- -

ERODE - - Reduces the light areas. No parameter is used.

- -

DILATE - - Increases the light areas. No parameter is used.

- path: p5.Image/filter - blend: - description: > -

Copies a region of pixels from another image into this one.

- -

The first parameter, srcImage, is the - - p5.Image object to blend.

- -

The next four parameters, sx, sy, - sw, and sh determine the region - - to blend from the source image. (sx, sy) is the top-left - corner of the - - region. sw and sh are the regions width and - height.

- -

The next four parameters, dx, dy, - dw, and dh determine the region - - of the canvas to blend into. (dx, dy) is the top-left corner - of the - - region. dw and dh are the regions width and - height.

- -

The tenth parameter, blendMode, sets the effect used to - blend the images' - - colors. The options are BLEND, DARKEST, - LIGHTEST, DIFFERENCE, - - MULTIPLY, EXCLUSION, SCREEN, - REPLACE, OVERLAY, HARD_LIGHT, - - SOFT_LIGHT, DODGE, BURN, - ADD, or NORMAL.

- path: p5.Image/blend - save: - description: > -

Saves the image to a file.

- -

By default, img.save() saves the image as a PNG image - called - - untitled.png.

- -

The first parameter, filename, is optional. It's a string - that sets the - - file's name. If a file extension is included, as in - - img.save('drawing.png'), then the image will be saved using - that - - format.

- -

The second parameter, extension, is also optional. It sets - the files format. - - Either 'png' or 'jpg' can be used. For example, - img.save('drawing', 'jpg') - - saves the canvas to a file called drawing.jpg.

- -

Note: The browser will either save the file immediately or prompt the - user - - with a dialogue window.

- -

The image will only be downloaded as an animated GIF if it was loaded - - from a GIF file. See saveGif() to - create new - - GIFs.

- path: p5.Image/save - reset: - description: | -

Restarts an animated GIF at its first frame.

- path: p5.Image/reset - getCurrentFrame: - description: | -

Gets the index of the current frame in an animated GIF.

- path: p5.Image/getCurrentFrame - setFrame: - description: | -

Sets the current frame in an animated GIF.

- path: p5.Image/setFrame - numFrames: - description: | -

Returns the number of frames in an animated GIF.

- path: p5.Image/numFrames - play: - description: | -

Plays an animated GIF that was paused with - img.pause().

- path: p5.Image/play - pause: - description: | -

Pauses an animated GIF.

-

The GIF can be resumed by calling - img.play().

- path: p5.Image/pause - delay: - description: > -

Changes the delay between frames in an animated GIF.

- -

The first parameter, delay, is the length of the delay in - milliseconds.

- -

The second parameter, index, is optional. If provided, - only the frame - - at index will have its delay modified. All other frames will - keep - - their default delay.

- path: p5.Image/delay -properties: - width: - description: | -

The image's width in pixels.

- path: p5.Image/width - height: - description: | -

The image's height in pixels.

- path: p5.Image/height - pixels: - description: > -

An array containing the color of each pixel in the image.

- -

Colors are stored as numbers representing red, green, blue, and alpha - - (RGBA) values. img.pixels is a one-dimensional array for - performance - - reasons.

- -

Each pixel occupies four elements in the pixels array, one for each - - RGBA value. For example, the pixel at coordinates (0, 0) stores its - - RGBA values at img.pixels[0], img.pixels[1], - img.pixels[2], - - and img.pixels[3], respectively. The next pixel at - coordinates (1, 0) - - stores its RGBA values at img.pixels[4], - img.pixels[5], - - img.pixels[6], and img.pixels[7]. And so on. The - img.pixels array - - for a 100×100 p5.Image object has - - 100 × 100 × 4 = 40,000 elements.

- -

Accessing the RGBA values for a pixel in the image requires a little - - math as shown in the examples below. The - - img.loadPixels() - - method must be called before accessing the img.pixels array. - The - - img.updatePixels() method - must be - - called after any changes are made.

- path: p5.Image/pixels -chainable: false ---- - - -# p5.Image diff --git a/src/content/reference/en/p5 copy/p5.MediaElement.mdx b/src/content/reference/en/p5 copy/p5.MediaElement.mdx deleted file mode 100644 index ee05412502..0000000000 --- a/src/content/reference/en/p5 copy/p5.MediaElement.mdx +++ /dev/null @@ -1,258 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L4099 -title: p5.MediaElement -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

A class to handle audio and video.

- -

p5.MediaElement extends p5.Element with - - methods to handle audio and video. p5.MediaElement objects are - created by - - calling createVideo, - - createAudio, and - - createCapture.

-line: 4099 -isConstructor: true -params: - - name: elt - description: | -

DOM node that is wrapped

- type: String -example: - - |- - -
- - let capture; - - function setup() { - createCanvas(100, 100); - - // Create a p5.MediaElement using createCapture(). - capture = createCapture(VIDEO); - capture.hide(); - - describe('A webcam feed with inverted colors.'); - } - - function draw() { - // Display the video stream and invert the colors. - image(capture, 0, 0, width, width * capture.height / capture.width); - filter(INVERT); - } - -
-methods: - play: - description: | -

Plays audio or video from a media element.

- path: p5.MediaElement/play - stop: - description: > -

Stops a media element and sets its current time to 0.

- -

Calling media.play() will restart playing audio/video from - the beginning.

- path: p5.MediaElement/stop - pause: - description: > -

Pauses a media element.

- -

Calling media.play() will resume playing audio/video from - the moment it paused.

- path: p5.MediaElement/pause - loop: - description: | -

Plays the audio/video repeatedly in a loop.

- path: p5.MediaElement/loop - noLoop: - description: | -

Stops the audio/video from playing in a loop.

-

The media will stop when it finishes playing.

- path: p5.MediaElement/noLoop - autoplay: - description: > -

Sets the audio/video to play once it's loaded.

- -

The parameter, shouldAutoplay, is optional. Calling - - media.autoplay() without an argument causes the media to play - - automatically. If true is passed, as in - media.autoplay(true), the - - media will automatically play. If false is passed, as in - - media.autoPlay(false), it won't play automatically.

- path: p5.MediaElement/autoplay - volume: - description: > -

Sets the audio/video volume.

- -

Calling media.volume() without an argument returns the - current volume - - as a number in the range 0 (off) to 1 (maximum).

- -

The parameter, val, is optional. It's a number that sets - the volume - - from 0 (off) to 1 (maximum). For example, calling - media.volume(0.5) - - sets the volume to half of its maximum.

- path: p5.MediaElement/volume - speed: - description: > -

Sets the audio/video playback speed.

- -

The parameter, val, is optional. It's a number that sets - the playback - - speed. 1 plays the media at normal speed, 0.5 plays it at half speed, 2 - - plays it at double speed, and so on. -1 plays the media at normal speed - - in reverse.

- -

Calling media.speed() returns the current speed as a - number.

- -

Note: Not all browsers support backward playback. Even if they do, - - playback might not be smooth.

- path: p5.MediaElement/speed - time: - description: > -

Sets the media element's playback time.

- -

The parameter, time, is optional. It's a number that - specifies the - - time, in seconds, to jump to when playback begins.

- -

Calling media.time() without an argument returns the - number of seconds - - the audio/video has played.

- -

Note: Time resets to 0 when looping media restarts.

- path: p5.MediaElement/time - duration: - description: | -

Returns the audio/video's duration in seconds.

- path: p5.MediaElement/duration - onended: - description: > -

Calls a function when the audio/video reaches the end of its - playback.

- -

The element is passed as an argument to the callback function.

- -

Note: The function won't be called if the media is looping.

- path: p5.MediaElement/onended - connect: - description: > -

Sends the element's audio to an output.

- -

The parameter, audioNode, can be an AudioNode - or an object from the - - p5.sound library.

- -

If no element is provided, as in myElement.connect(), the - element - - connects to the main output. All connections are removed by the - - .disconnect() method.

- -

Note: This method is meant to be used with the p5.sound.js addon - library.

- path: p5.MediaElement/connect - disconnect: - description: > -

Disconnect all Web Audio routing, including to the main output.

- -

This is useful if you want to re-route the output through audio - effects, - - for example.

- path: p5.MediaElement/disconnect - showControls: - description: > -

Show the default - - HTMLMediaElement - - controls.

- -

Note: The controls vary between web browsers.

- path: p5.MediaElement/showControls - hideControls: - description: > -

Hide the default - - HTMLMediaElement - - controls.

- path: p5.MediaElement/hideControls - addCue: - description: > -

Schedules a function to call when the audio/video reaches a specific - time - - during its playback.

- -

The first parameter, time, is the time, in seconds, when - the function - - should run. This value is passed to callback as its first - argument.

- -

The second parameter, callback, is the function to call at - the specified - - cue time.

- -

The third parameter, value, is optional and can be any - type of value. - - value is passed to callback.

- -

Calling media.addCue() returns an ID as a string. This is - useful for - - removing the cue later.

- path: p5.MediaElement/addCue - removeCue: - description: | -

Removes a callback based on its ID.

- path: p5.MediaElement/removeCue - clearCues: - description: | -

Removes all functions scheduled with media.addCue().

- path: p5.MediaElement/clearCues -properties: - src: - description: | -

Path to the media element's source as a string.

- path: p5.MediaElement/src -chainable: false ---- - - -# p5.MediaElement diff --git a/src/content/reference/en/p5 copy/p5.NumberDict.mdx b/src/content/reference/en/p5 copy/p5.NumberDict.mdx deleted file mode 100644 index d385eb1468..0000000000 --- a/src/content/reference/en/p5 copy/p5.NumberDict.mdx +++ /dev/null @@ -1,63 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/data/p5.TypedDict.js#L415 -title: p5.NumberDict -module: Data -submodule: Dictionary -file: src/data/p5.TypedDict.js -description: | -

A simple Dictionary class for Numbers.

-line: 415 -isConstructor: true -methods: - add: - description: | -

Add the given number to the value currently stored at the given key. - The sum then replaces the value previously stored in the Dictionary.

- path: p5.NumberDict/add - sub: - description: > -

Subtract the given number from the value currently stored at the given - key. - - The difference then replaces the value previously stored in the - Dictionary.

- path: p5.NumberDict/sub - mult: - description: > -

Multiply the given number with the value currently stored at the given - key. - - The product then replaces the value previously stored in the - Dictionary.

- path: p5.NumberDict/mult - div: - description: > -

Divide the given number with the value currently stored at the given - key. - - The quotient then replaces the value previously stored in the - Dictionary.

- path: p5.NumberDict/div - minValue: - description: | -

Return the lowest number currently stored in the Dictionary.

- path: p5.NumberDict/minValue - maxValue: - description: | -

Return the highest number currently stored in the Dictionary.

- path: p5.NumberDict/maxValue - minKey: - description: | -

Return the lowest key currently used in the Dictionary.

- path: p5.NumberDict/minKey - maxKey: - description: | -

Return the highest key currently used in the Dictionary.

- path: p5.NumberDict/maxKey -chainable: false ---- - - -# p5.NumberDict diff --git a/src/content/reference/en/p5 copy/p5.PrintWriter.mdx b/src/content/reference/en/p5 copy/p5.PrintWriter.mdx deleted file mode 100644 index 7662b4f910..0000000000 --- a/src/content/reference/en/p5 copy/p5.PrintWriter.mdx +++ /dev/null @@ -1,35 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1565 -title: p5.PrintWriter -module: IO -submodule: Output -file: src/io/files.js -description: > -

A class to describe a print stream.

- -

Each p5.PrintWriter object provides a way to save a sequence - of text - - data, called the print stream, to the user's computer. It's a - low-level - - object that enables precise control of text output. Functions such as - - saveStrings() and - - saveJSON() are easier to use for simple - file - - saving.

- -

Note: createWriter() is the - recommended way - - to make an instance of this class.

-line: 1565 ---- - - -# p5.PrintWriter diff --git a/src/content/reference/en/p5 copy/p5.Renderer.mdx b/src/content/reference/en/p5 copy/p5.Renderer.mdx deleted file mode 100644 index 5fa9dd1cd1..0000000000 --- a/src/content/reference/en/p5 copy/p5.Renderer.mdx +++ /dev/null @@ -1,34 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/p5.Renderer.js#L10 -title: p5.Renderer -module: Rendering -submodule: Rendering -file: src/core/p5.Renderer.js -description: | -

Main graphics and rendering context, as well as the base API - implementation for p5.js "core". To be used as the superclass for - Renderer2D and Renderer3D classes, respectively.

-line: 10 -isConstructor: true -params: - - name: elt - description: | -

DOM node that is wrapped

- type: HTMLElement - - name: pInst - description: | -

pointer to p5 instance

- type: P5 - optional: true - - name: isMainCanvas - description: | -

whether we're using it as main canvas

- type: Boolean - optional: true -chainable: false ---- - - -# p5.Renderer diff --git a/src/content/reference/en/p5 copy/p5.Shader.mdx b/src/content/reference/en/p5 copy/p5.Shader.mdx deleted file mode 100644 index 1730091ac1..0000000000 --- a/src/content/reference/en/p5 copy/p5.Shader.mdx +++ /dev/null @@ -1,433 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Shader.js#L11 -title: p5.Shader -module: 3D -submodule: Material -file: src/webgl/p5.Shader.js -description: > -

A class to describe a shader program.

- -

Each p5.Shader object contains a shader program that runs on - the graphics - - processing unit (GPU). Shaders can process many pixels or vertices at the - - same time, making them fast for many graphics tasks. They’re written in a - - language called - - GLSL - - and run along with the rest of the code in a sketch.

- -

A shader program consists of two files, a vertex shader and a fragment - - shader. The vertex shader affects where 3D geometry is drawn on the screen - - and the fragment shader affects color. Once the p5.Shader object - is - - created, it can be used with the shader() - - function, as in shader(myShader).

- -

A shader can optionally describe hooks, which are functions in - GLSL that - - users may choose to provide to customize the behavior of the shader. For the - - vertex or the fragment shader, users can pass in an object where each key is - - the type and name of a hook function, and each value is a string with the - - parameter list and default implementation of the hook. For example, to let - users - - optionally run code at the start of the vertex shader, the options object - could - - include:

- -
{
-    vertex: {
-      'void beforeVertex': '() {}'
-    }
-  }
-
-  
- -

Then, in your vertex shader source, you can run a hook by calling a - function - - with the same name prefixed by HOOK_:

- -
void main() {
-    HOOK_beforeVertex();
-    // Add the rest of your shader code here!
-  }
-
-  
- -

Note: createShader(), - - createFilterShader(), and - - loadShader() are the recommended ways - to - - create an instance of this class.

-line: 11 -isConstructor: true -params: - - name: renderer - description: | -

WebGL context for this shader.

- type: p5.RendererGL - - name: vertSrc - description: | -

source code for the vertex shader program.

- type: String - - name: fragSrc - description: | -

source code for the fragment shader program.

- type: String - - name: options - description: > -

An optional object describing how this shader can - - be augmented with hooks. It can include:

- -
    - -
  • vertex: An object describing the available vertex shader - hooks.
  • - -
  • fragment: An object describing the available frament - shader hooks.
  • - -
- type: Object - optional: true -example: - - |- - -
- - // Note: A "uniform" is a global variable within a shader program. - - // Create a string with the vertex shader program. - // The vertex shader is called for each vertex. - let vertSrc = ` - precision highp float; - uniform mat4 uModelViewMatrix; - uniform mat4 uProjectionMatrix; - - attribute vec3 aPosition; - attribute vec2 aTexCoord; - varying vec2 vTexCoord; - - void main() { - vTexCoord = aTexCoord; - vec4 positionVec4 = vec4(aPosition, 1.0); - gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; - } - `; - - // Create a string with the fragment shader program. - // The fragment shader is called for each pixel. - let fragSrc = ` - precision highp float; - - void main() { - // Set each pixel's RGBA value to yellow. - gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); - } - `; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Shader object. - let myShader = createShader(vertSrc, fragSrc); - - // Apply the p5.Shader object. - shader(myShader); - - // Style the drawing surface. - noStroke(); - - // Add a plane as a drawing surface. - plane(100, 100); - - describe('A yellow square.'); - } - -
- -
- - // Note: A "uniform" is a global variable within a shader program. - - let mandelbrot; - - // Load the shader and create a p5.Shader object. - function preload() { - mandelbrot = loadShader('/assets/shader.vert', '/assets/shader.frag'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - // Use the p5.Shader object. - shader(mandelbrot); - - // Set the shader uniform p to an array. - mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); - - describe('A fractal image zooms in and out of focus.'); - } - - function draw() { - // Set the shader uniform r to a value that oscillates between 0 and 2. - mandelbrot.setUniform('r', sin(frameCount * 0.01) + 1); - - // Add a quad as a display surface for the shader. - quad(-1, -1, 1, -1, 1, 1, -1, 1); - } - -
-methods: - inspectHooks: - description: > -

Logs the hooks available in this shader, and their current - implementation.

- -

Each shader may let you override bits of its behavior. Each bit is - called - - a hook. A hook is either for the vertex shader, if it - affects the - - position of vertices, or in the fragment shader, if it affects - the pixel - - color. This method logs those values to the console, letting you know what - - you are able to use in a call to - - modify().

- -

For example, this shader will produce the following output:

- -
myShader = baseMaterialShader().modify({
-        declarations: 'uniform float time;',
-        'vec3 getWorldPosition': `(vec3 pos) {
-          pos.y += 20. * sin(time * 0.001 + pos.x * 0.05);
-          return pos;
-        }`
-      });
-
-      myShader.inspectHooks();
-
-      
- -
==== Vertex shader hooks: ====
-
-      void beforeVertex() {}
-
-      vec3 getLocalPosition(vec3 position) { return position; }
-
-      [MODIFIED] vec3 getWorldPosition(vec3 pos) {
-            pos.y += 20. * sin(time * 0.001 + pos.x * 0.05);
-            return pos;
-          }
-      vec3 getLocalNormal(vec3 normal) { return normal; }
-
-      vec3 getWorldNormal(vec3 normal) { return normal; }
-
-      vec2 getUV(vec2 uv) { return uv; }
-
-      vec4 getVertexColor(vec4 color) { return color; }
-
-      void afterVertex() {}
-
-
-      ==== Fragment shader hooks: ====
-
-      void beforeFragment() {}
-
-      Inputs getPixelInputs(Inputs inputs) { return inputs; }
-
-      vec4 combineColors(ColorComponents components) {
-                      vec4 color = vec4(0.);
-                      color.rgb += components.diffuse * components.baseColor;
-                      color.rgb += components.ambient * components.ambientColor;
-                      color.rgb += components.specular * components.specularColor;
-                      color.rgb += components.emissive;
-                      color.a = components.opacity;
-                      return color;
-                    }
-      vec4 getFinalColor(vec4 color) { return color; }
-
-      void afterFragment() {}
-
-      
- path: p5.Shader/inspectHooks - modify: - description: > -

Returns a new shader, based on the original, but with custom snippets - - of shader code replacing default behaviour.

- -

Each shader may let you override bits of its behavior. Each bit is - called - - a hook. A hook is either for the vertex shader, if it - affects the - - position of vertices, or in the fragment shader, if it affects - the pixel - - color. You can inspect the different hooks available by calling - - yourShader.inspectHooks(). - You can - - also read the reference for the default material, normal material, color, - line, and point shaders to - - see what hooks they have available.

- -

modify() takes one parameter, hooks, an - object with the hooks you want - - to override. Each key of the hooks object is the name - - of a hook, and the value is a string with the GLSL code for your hook.

- -

If you supply functions that aren't existing hooks, they will get added - at the start of - - the shader as helper functions so that you can use them in your hooks.

- -

To add new uniforms to - your shader, you can pass in a uniforms object containing - - the type and name of the uniform as the key, and a default value or - function returning - - a default value as its value. These will be automatically set when the - shader is set - - with shader(yourShader).

- -

You can also add a declarations key, where the value is a - GLSL string declaring - - custom uniform variables, globals, and functions shared - - between hooks. To add declarations just in a vertex or fragment shader, - add - - vertexDeclarations and fragmentDeclarations - keys.

- path: p5.Shader/modify - copyToContext: - description: > -

Copies the shader from one drawing context to another.

- -

Each p5.Shader object must be compiled by calling - - shader() before it can run. - Compilation happens - - in a drawing context which is usually the main canvas or an instance of - - p5.Graphics. A shader can only be - used in the - - context where it was compiled. The copyToContext() method - compiles the - - shader again and copies it to another drawing context where it can be - - reused.

- -

The parameter, context, is the drawing context where the - shader will be - - used. The shader can be copied to an instance of - - p5.Graphics, as in - - myShader.copyToContext(pg). The shader can also be copied - from a - - p5.Graphics object to the main - canvas using - - the window variable, as in - myShader.copyToContext(window).

- -

Note: A p5.Shader object created - with - - createShader(), - - createFilterShader(), or - - loadShader() - - can be used directly with a p5.Framebuffer - - object created with - - createFramebuffer(). Both - objects - - have the same context as the main canvas.

- path: p5.Shader/copyToContext - setUniform: - description: > -

Sets the shader’s uniform (global) variables.

- -

Shader programs run on the computer’s graphics processing unit (GPU). - - They live in part of the computer’s memory that’s completely separate - - from the sketch that runs them. Uniforms are global variables within a - - shader program. They provide a way to pass values from a sketch running - - on the CPU to a shader program running on the GPU.

- -

The first parameter, uniformName, is a string with the - uniform’s name. - - For the shader above, uniformName would be - 'r'.

- -

The second parameter, data, is the value that should be - used to set the - - uniform. For example, calling myShader.setUniform('r', 0.5) - would set - - the r uniform in the shader above to 0.5. data - should match the - - uniform’s type. Numbers, strings, booleans, arrays, and many types of - - images can all be passed to a shader with setUniform().

- path: p5.Shader/setUniform -chainable: false ---- - - -# p5.Shader diff --git a/src/content/reference/en/p5 copy/p5.StringDict.mdx b/src/content/reference/en/p5 copy/p5.StringDict.mdx deleted file mode 100644 index 5ca466e5d1..0000000000 --- a/src/content/reference/en/p5 copy/p5.StringDict.mdx +++ /dev/null @@ -1,15 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/data/p5.TypedDict.js#L397 -title: p5.StringDict -module: Data -submodule: Dictionary -file: src/data/p5.TypedDict.js -description: | -

A simple Dictionary class for Strings.

-line: 397 ---- - - -# p5.StringDict diff --git a/src/content/reference/en/p5 copy/p5.Table.mdx b/src/content/reference/en/p5 copy/p5.Table.mdx deleted file mode 100644 index 41ad72b0d1..0000000000 --- a/src/content/reference/en/p5 copy/p5.Table.mdx +++ /dev/null @@ -1,213 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/p5.Table.js#L33 -title: p5.Table -module: IO -submodule: Table -file: src/io/p5.Table.js -description: > -

Table objects store data with multiple - rows and columns, much - - like in a traditional spreadsheet. Tables can be generated from - - scratch, dynamically, or using data from an existing file.

-line: 33 -isConstructor: true -params: - - name: rows - description: | -

An array of p5.TableRow objects

- type: 'p5.TableRow[]' - optional: true -methods: - addRow: - description: > -

Use addRow() to add a new row of - data to a p5.Table object. By - default, - - an empty row is created. Typically, you would store a reference to - - the new row in a TableRow object (see newRow in the example above), - - and then set individual values using set().

- -

If a p5.TableRow object is - included as a parameter, then that row is - - duplicated and added to the table.

- path: p5.Table/addRow - removeRow: - description: | -

Removes a row from the table object.

- path: p5.Table/removeRow - getRow: - description: > -

Returns a reference to the specified p5.TableRow. The reference - - can then be used to get and set values of the selected row.

- path: p5.Table/getRow - getRows: - description: > -

Gets all rows from the table. Returns an array of p5.TableRows.

- path: p5.Table/getRows - findRow: - description: | -

Finds the first row in the Table that contains the value - provided, and returns a reference to that row. Even if - multiple rows are possible matches, only the first matching - row is returned. The column to search may be specified by - either its ID or title.

- path: p5.Table/findRow - findRows: - description: | -

Finds the rows in the Table that contain the value - provided, and returns references to those rows. Returns an - Array, so for must be used to iterate through all the rows, - as shown in the example above. The column to search may be - specified by either its ID or title.

- path: p5.Table/findRows - matchRow: - description: | -

Finds the first row in the Table that matches the regular - expression provided, and returns a reference to that row. - Even if multiple rows are possible matches, only the first - matching row is returned. The column to search may be - specified by either its ID or title.

- path: p5.Table/matchRow - matchRows: - description: | -

Finds the rows in the Table that match the regular expression provided, - and returns references to those rows. Returns an array, so for must be - used to iterate through all the rows, as shown in the example. The - column to search may be specified by either its ID or title.

- path: p5.Table/matchRows - getColumn: - description: | -

Retrieves all values in the specified column, and returns them - as an array. The column may be specified by either its ID or title.

- path: p5.Table/getColumn - clearRows: - description: | -

Removes all rows from a Table. While all rows are removed, - columns and column titles are maintained.

- path: p5.Table/clearRows - addColumn: - description: > -

Use addColumn() to add a new - column to a Table object. - - Typically, you will want to specify a title, so the column - - may be easily referenced later by name. (If no title is - - specified, the new column's title will be null.)

- path: p5.Table/addColumn - getColumnCount: - description: | -

Returns the total number of columns in a Table.

- path: p5.Table/getColumnCount - getRowCount: - description: | -

Returns the total number of rows in a Table.

- path: p5.Table/getRowCount - removeTokens: - description: | -

Removes any of the specified characters (or "tokens").

-

If no column is specified, then the values in all columns and - rows are processed. A specific column may be referenced by - either its ID or title.

- path: p5.Table/removeTokens - trim: - description: | -

Trims leading and trailing whitespace, such as spaces and tabs, - from String table values. If no column is specified, then the - values in all columns and rows are trimmed. A specific column - may be referenced by either its ID or title.

- path: p5.Table/trim - removeColumn: - description: > -

Use removeColumn() to remove - an existing column from a Table - - object. The column to be removed may be identified by either - - its title (a String) or its index value (an int). - - removeColumn(0) would remove the first column, removeColumn(1) - - would remove the second column, and so on.

- path: p5.Table/removeColumn - set: - description: | -

Stores a value in the Table's specified row and column. - The row is specified by its ID, while the column may be specified - by either its ID or title.

- path: p5.Table/set - setNum: - description: | -

Stores a Float value in the Table's specified row and column. - The row is specified by its ID, while the column may be specified - by either its ID or title.

- path: p5.Table/setNum - setString: - description: | -

Stores a String value in the Table's specified row and column. - The row is specified by its ID, while the column may be specified - by either its ID or title.

- path: p5.Table/setString - get: - description: | -

Retrieves a value from the Table's specified row and column. - The row is specified by its ID, while the column may be specified by - either its ID or title.

- path: p5.Table/get - getNum: - description: | -

Retrieves a Float value from the Table's specified row and column. - The row is specified by its ID, while the column may be specified by - either its ID or title.

- path: p5.Table/getNum - getString: - description: | -

Retrieves a String value from the Table's specified row and column. - The row is specified by its ID, while the column may be specified by - either its ID or title.

- path: p5.Table/getString - getObject: - description: | -

Retrieves all table data and returns as an object. If a column name is - passed in, each row object will be stored with that attribute as its - title.

- path: p5.Table/getObject - getArray: - description: > -

Retrieves all table data and returns it as a multidimensional - array.

- path: p5.Table/getArray -properties: - columns: - description: > -

An array containing the names of the columns in the table, if the - "header" the table is - - loaded with the "header" parameter.

- path: p5.Table/columns - rows: - description: > -

An array containing the p5.TableRow objects that make up the - - rows of the table. The same result as calling getRows()

- path: p5.Table/rows -chainable: false ---- - - -# p5.Table diff --git a/src/content/reference/en/p5 copy/p5.TableRow.mdx b/src/content/reference/en/p5 copy/p5.TableRow.mdx deleted file mode 100644 index 00081f9654..0000000000 --- a/src/content/reference/en/p5 copy/p5.TableRow.mdx +++ /dev/null @@ -1,66 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/p5.TableRow.js#L9 -title: p5.TableRow -module: IO -submodule: Table -file: src/io/p5.TableRow.js -description: | -

A TableRow object represents a single row of data values, - stored in columns, from a table.

-

A Table Row contains both an ordered array, and an unordered - JSON object.

-line: 9 -isConstructor: true -params: - - name: str - description: | -

optional: populate the row with a - string of values, separated by the - separator

- type: String - optional: true - - name: separator - description: | -

comma separated values (csv) by default

- type: String - optional: true -methods: - set: - description: | -

Stores a value in the TableRow's specified column. - The column may be specified by either its ID or title.

- path: p5.TableRow/set - setNum: - description: | -

Stores a Float value in the TableRow's specified column. - The column may be specified by either its ID or title.

- path: p5.TableRow/setNum - setString: - description: | -

Stores a String value in the TableRow's specified column. - The column may be specified by either its ID or title.

- path: p5.TableRow/setString - get: - description: | -

Retrieves a value from the TableRow's specified column. - The column may be specified by either its ID or title.

- path: p5.TableRow/get - getNum: - description: | -

Retrieves a Float value from the TableRow's specified - column. The column may be specified by either its ID or - title.

- path: p5.TableRow/getNum - getString: - description: | -

Retrieves an String value from the TableRow's specified - column. The column may be specified by either its ID or - title.

- path: p5.TableRow/getString -chainable: false ---- - - -# p5.TableRow diff --git a/src/content/reference/en/p5 copy/p5.TypedDict.mdx b/src/content/reference/en/p5 copy/p5.TypedDict.mdx deleted file mode 100644 index 2bcb7b5752..0000000000 --- a/src/content/reference/en/p5 copy/p5.TypedDict.mdx +++ /dev/null @@ -1,66 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/data/p5.TypedDict.js#L82 -title: p5.TypedDict -module: Data -submodule: Dictionary -file: src/data/p5.TypedDict.js -description: | -

Base class for all p5.Dictionary types. Specifically - typed Dictionary classes inherit from this class.

-line: 82 -isConstructor: true -methods: - size: - description: > -

Returns the number of key-value pairs currently stored in the - Dictionary.

- path: p5.TypedDict/size - hasKey: - description: | -

Returns true if the given key exists in the Dictionary, - otherwise returns false.

- path: p5.TypedDict/hasKey - get: - description: | -

Returns the value stored at the given key.

- path: p5.TypedDict/get - set: - description: > -

Updates the value associated with the given key in case it already - exists - - in the Dictionary. Otherwise a new key-value pair is added.

- path: p5.TypedDict/set - create: - description: | -

Creates a new key-value pair in the Dictionary.

- path: p5.TypedDict/create - clear: - description: | -

Removes all previously stored key-value pairs from the Dictionary.

- path: p5.TypedDict/clear - remove: - description: > -

Removes the key-value pair stored at the given key from the - Dictionary.

- path: p5.TypedDict/remove - print: - description: > -

Logs the set of items currently stored in the Dictionary to the - console.

- path: p5.TypedDict/print - saveTable: - description: | -

Converts the Dictionary into a CSV file for local download.

- path: p5.TypedDict/saveTable - saveJSON: - description: | -

Converts the Dictionary into a JSON file for local download.

- path: p5.TypedDict/saveJSON -chainable: false ---- - - -# p5.TypedDict diff --git a/src/content/reference/en/p5 copy/p5.Vector.mdx b/src/content/reference/en/p5 copy/p5.Vector.mdx deleted file mode 100644 index ff67d7562c..0000000000 --- a/src/content/reference/en/p5 copy/p5.Vector.mdx +++ /dev/null @@ -1,673 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/p5.Vector.js#L11 -title: p5.Vector -module: Math -submodule: Vector -file: src/math/p5.Vector.js -description: > -

A class to describe a two or three-dimensional vector.

- -

A vector can be thought of in different ways. In one view, a vector is like - - an arrow pointing in space. Vectors have both magnitude (length) and - - direction.

- -

p5.Vector objects are often used to program motion because - they simplify - - the math. For example, a moving ball has a position and a velocity. - - Position describes where the ball is in space. The ball's position vector - - extends from the origin to the ball's center. Velocity describes the ball's - - speed and the direction it's moving. If the ball is moving straight up, its - - velocity vector points straight up. Adding the ball's velocity vector to - - its position vector moves it, as in pos.add(vel). Vector math - relies on - - methods inside the p5.Vector class.

- -

Note: createVector() is the - recommended way - - to make an instance of this class.

-line: 11 -isConstructor: true -params: - - name: x - description: | -

x component of the vector.

- type: Number - optional: true - - name: 'y' - description: | -

y component of the vector.

- type: Number - optional: true - - name: z - description: | -

z component of the vector.

- type: Number - optional: true -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create p5.Vector objects. - let p1 = createVector(25, 25); - let p2 = createVector(75, 75); - - // Style the points. - strokeWeight(5); - - // Draw the first point using a p5.Vector. - point(p1); - - // Draw the second point using a p5.Vector's components. - point(p2.x, p2.y); - - describe('Two black dots on a gray square, one at the top left and the other at the bottom right.'); - } - -
- -
- - let pos; - let vel; - - function setup() { - createCanvas(100, 100); - - // Create p5.Vector objects. - pos = createVector(50, 100); - vel = createVector(0, -1); - - describe('A black dot moves from bottom to top on a gray square. The dot reappears at the bottom when it reaches the top.'); - } - - function draw() { - background(200); - - // Add velocity to position. - pos.add(vel); - - // If the dot reaches the top of the canvas, - // restart from the bottom. - if (pos.y < 0) { - pos.y = 100; - } - - // Draw the dot. - strokeWeight(5); - point(pos); - } - -
-methods: - toString: - description: > -

Returns a string representation of a vector.

- -

Calling toString() is useful for printing vectors to the - console while - - debugging.

- path: p5.Vector/toString - set: - description: > -

Sets the vector's x, y, and z - components.

- -

set() can use separate numbers, as in v.set(1, 2, - 3), a - - p5.Vector object, as in - v.set(v2), or an - - array of numbers, as in v.set([1, 2, 3]).

- -

If a value isn't provided for a component, it will be set to 0. For - - example, v.set(4, 5) sets v.x to 4, - v.y to 5, and v.z to 0. - - Calling set() with no arguments, as in v.set(), - sets all the vector's - - components to 0.

- path: p5.Vector/set - copy: - description: > -

Returns a copy of the p5.Vector - object.

- path: p5.Vector/copy - add: - description: > -

Adds to a vector's x, y, and z - components.

- -

add() can use separate numbers, as in v.add(1, 2, - 3), - - another p5.Vector object, as in - v.add(v2), or - - an array of numbers, as in v.add([1, 2, 3]).

- -

If a value isn't provided for a component, it won't change. For - - example, v.add(4, 5) adds 4 to v.x, 5 to - v.y, and 0 to v.z. - - Calling add() with no arguments, as in v.add(), - has no effect.

- -

The static version of add(), as in p5.Vector.add(v2, - v1), returns a new - - p5.Vector object and doesn't change - the - - originals.

- path: p5.Vector/add - rem: - description: > -

Performs modulo (remainder) division with a vector's x, - y, and z - - components.

- -

rem() can use separate numbers, as in v.rem(1, 2, - 3), - - another p5.Vector object, as in - v.rem(v2), or - - an array of numbers, as in v.rem([1, 2, 3]).

- -

If only one value is provided, as in v.rem(2), then all - the components - - will be set to their values modulo 2. If two values are provided, as in - - v.rem(2, 3), then v.z won't change. Calling - rem() with no - - arguments, as in v.rem(), has no effect.

- -

The static version of rem(), as in p5.Vector.rem(v2, - v1), returns a - - new p5.Vector object and doesn't - change the - - originals.

- path: p5.Vector/rem - sub: - description: > -

Subtracts from a vector's x, y, and - z components.

- -

sub() can use separate numbers, as in v.sub(1, 2, - 3), another - - p5.Vector object, as in - v.sub(v2), or an array - - of numbers, as in v.sub([1, 2, 3]).

- -

If a value isn't provided for a component, it won't change. For - - example, v.sub(4, 5) subtracts 4 from v.x, 5 - from v.y, and 0 from v.z. - - Calling sub() with no arguments, as in v.sub(), - has no effect.

- -

The static version of sub(), as in p5.Vector.sub(v2, - v1), returns a new - - p5.Vector object and doesn't change - the - - originals.

- path: p5.Vector/sub - mult: - description: > -

Multiplies a vector's x, y, and - z components.

- -

mult() can use separate numbers, as in v.mult(1, 2, - 3), another - - p5.Vector object, as in - v.mult(v2), or an array - - of numbers, as in v.mult([1, 2, 3]).

- -

If only one value is provided, as in v.mult(2), then all - the components - - will be multiplied by 2. If a value isn't provided for a component, it - - won't change. For example, v.mult(4, 5) multiplies - v.x by 4, v.y by 5, - - and v.z by 1. Calling mult() with no arguments, - as in v.mult(), has - - no effect.

- -

The static version of mult(), as in - p5.Vector.mult(v, 2), returns a new - - p5.Vector object and doesn't change - the - - originals.

- path: p5.Vector/mult - div: - description: > -

Divides a vector's x, y, and z - components.

- -

div() can use separate numbers, as in v.div(1, 2, - 3), another - - p5.Vector object, as in - v.div(v2), or an array - - of numbers, as in v.div([1, 2, 3]).

- -

If only one value is provided, as in v.div(2), then all - the components - - will be divided by 2. If a value isn't provided for a component, it - - won't change. For example, v.div(4, 5) divides - v.x by, v.y by 5, - - and v.z by 1. Calling div() with no arguments, - as in v.div(), has - - no effect.

- -

The static version of div(), as in p5.Vector.div(v, - 2), returns a new - - p5.Vector object and doesn't change - the - - originals.

- path: p5.Vector/div - mag: - description: > -

Calculates the magnitude (length) of the vector.

- -

Use mag() to calculate the magnitude - of a 2D vector - - using components as in mag(x, y).

- path: p5.Vector/mag - magSq: - description: | -

Calculates the magnitude (length) of the vector squared.

- path: p5.Vector/magSq - dot: - description: > -

Calculates the dot product of two vectors.

- -

The dot product is a number that describes the overlap between two - vectors. - - Visually, the dot product can be thought of as the "shadow" one vector - - casts on another. The dot product's magnitude is largest when two vectors - - point in the same or opposite directions. Its magnitude is 0 when two - - vectors form a right angle.

- -

The version of dot() with one parameter interprets it as - another - - p5.Vector object.

- -

The version of dot() with multiple parameters interprets - them as the - - x, y, and z components of another - vector.

- -

The static version of dot(), as in p5.Vector.dot(v1, - v2), is the same - - as calling v1.dot(v2).

- path: p5.Vector/dot - cross: - description: > -

Calculates the cross product of two vectors.

- -

The cross product is a vector that points straight out of the plane - created - - by two vectors. The cross product's magnitude is the area of the - parallelogram - - formed by the original two vectors.

- -

The static version of cross(), as in - p5.Vector.cross(v1, v2), is the same - - as calling v1.cross(v2).

- path: p5.Vector/cross - dist: - description: > -

Calculates the distance between two points represented by vectors.

- -

A point's coordinates can be represented by the components of a vector - - that extends from the origin to the point.

- -

The static version of dist(), as in - p5.Vector.dist(v1, v2), is the same - - as calling v1.dist(v2).

- -

Use dist() to calculate the distance - between points - - using coordinates as in dist(x1, y1, x2, y2).

- path: p5.Vector/dist - normalize: - description: > -

Scales the components of a p5.Vector object so - - that its magnitude is 1.

- -

The static version of normalize(), as in - p5.Vector.normalize(v), - - returns a new p5.Vector object and - doesn't change - - the original.

- path: p5.Vector/normalize - limit: - description: > -

Limits a vector's magnitude to a maximum value.

- -

The static version of limit(), as in - p5.Vector.limit(v, 5), returns a - - new p5.Vector object and doesn't - change the - - original.

- path: p5.Vector/limit - setMag: - description: > -

Sets a vector's magnitude to a given value.

- -

The static version of setMag(), as in - p5.Vector.setMag(v, 10), returns - - a new p5.Vector object and doesn't - change the - - original.

- path: p5.Vector/setMag - heading: - description: > -

Calculates the angle a 2D vector makes with the positive x-axis.

- -

By convention, the positive x-axis has an angle of 0. Angles increase - in - - the clockwise direction.

- -

If the vector was created with - - createVector(), - heading() returns angles - - in the units of the current angleMode().

- -

The static version of heading(), as in - p5.Vector.heading(v), works the - - same way.

- path: p5.Vector/heading - setHeading: - description: > -

Rotates a 2D vector to a specific angle without changing its - magnitude.

- -

By convention, the positive x-axis has an angle of 0. Angles increase - in - - the clockwise direction.

- -

If the vector was created with - - createVector(), - setHeading() uses - - the units of the current angleMode().

- path: p5.Vector/setHeading - rotate: - description: > -

Rotates a 2D vector by an angle without changing its magnitude.

- -

By convention, the positive x-axis has an angle of 0. Angles increase - in - - the clockwise direction.

- -

If the vector was created with - - createVector(), - rotate() uses - - the units of the current angleMode().

- -

The static version of rotate(), as in - p5.Vector.rotate(v, PI), - - returns a new p5.Vector object and - doesn't change - - the original.

- path: p5.Vector/rotate - angleBetween: - description: > -

Calculates the angle between two vectors.

- -

The angles returned are signed, which means that - - v1.angleBetween(v2) === -v2.angleBetween(v1).

- -

If the vector was created with - - createVector(), - angleBetween() returns - - angles in the units of the current - - angleMode().

- path: p5.Vector/angleBetween - lerp: - description: > -

Calculates new x, y, and z - components that are proportionally the - - same distance between two vectors.

- -

The amt parameter is the amount to interpolate between the - old vector and - - the new vector. 0.0 keeps all components equal to the old vector's, 0.5 is - - halfway between, and 1.0 sets all components equal to the new - vector's.

- -

The static version of lerp(), as in - p5.Vector.lerp(v0, v1, 0.5), - - returns a new p5.Vector object and - doesn't change - - the original.

- path: p5.Vector/lerp - slerp: - description: > -

Calculates a new heading and magnitude that are between two - vectors.

- -

The amt parameter is the amount to interpolate between the - old vector and - - the new vector. 0.0 keeps the heading and magnitude equal to the old - - vector's, 0.5 sets them halfway between, and 1.0 sets the heading and - - magnitude equal to the new vector's.

- -

slerp() differs from lerp() because - - it interpolates magnitude. Calling v0.slerp(v1, 0.5) sets - v0's - - magnitude to a value halfway between its original magnitude and - v1's. - - Calling v0.lerp(v1, 0.5) makes no such guarantee.

- -

The static version of slerp(), as in - p5.Vector.slerp(v0, v1, 0.5), - - returns a new p5.Vector object and - doesn't change - - the original.

- path: p5.Vector/slerp - reflect: - description: > -

Reflects a vector about a line in 2D or a plane in 3D.

- -

The orientation of the line or plane is described by a normal vector - that - - points away from the shape.

- -

The static version of reflect(), as in - p5.Vector.reflect(v, n), - - returns a new p5.Vector object and - doesn't change - - the original.

- path: p5.Vector/reflect - array: - description: | -

Returns the vector's components as an array of numbers.

- path: p5.Vector/array - equals: - description: > -

Checks whether all the vector's components are equal to another - vector's.

- -

equals() returns true if the vector's - components are all the same as another - - vector's and false if not.

- -

The version of equals() with one parameter interprets it - as another - - p5.Vector object.

- -

The version of equals() with multiple parameters - interprets them as the - - components of another vector. Any missing parameters are assigned the - value - - 0.

- -

The static version of equals(), as in - p5.Vector.equals(v0, v1), - - interprets both parameters as p5.Vector objects.

- path: p5.Vector/equals - fromAngle: - description: | -

Creates a new 2D vector from an angle.

- path: p5.Vector/fromAngle - fromAngles: - description: | -

Creates a new 3D vector from a pair of ISO spherical angles.

- path: p5.Vector/fromAngles - random2D: - description: | -

Creates a new 2D unit vector with a random heading.

- path: p5.Vector/random2D - random3D: - description: | -

Creates a new 3D unit vector with a random heading.

- path: p5.Vector/random3D - clampToZero: - description: > -

Replaces the components of a p5.Vector that are very close to zero - with zero.

- -

In computers, handling numbers with decimals can give slightly - imprecise answers due to the way those numbers are represented. - - This can make it hard to check if a number is zero, as it may be close but - not exactly zero. - - This method rounds very close numbers to zero to make those checks - easier

- -

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON

- path: p5.Vector/clampToZero -properties: - x: - description: | -

The x component of the vector

- path: p5.Vector/x - 'y': - description: | -

The y component of the vector

- path: p5.Vector/y - z: - description: | -

The z component of the vector

- path: p5.Vector/z -chainable: false ---- - - -# p5.Vector diff --git a/src/content/reference/en/p5 copy/p5.XML.mdx b/src/content/reference/en/p5 copy/p5.XML.mdx deleted file mode 100644 index 71904fded2..0000000000 --- a/src/content/reference/en/p5 copy/p5.XML.mdx +++ /dev/null @@ -1,321 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/p5.XML.js#L9 -title: p5.XML -module: IO -submodule: Input -file: src/io/p5.XML.js -description: > -

A class to describe an XML object.

- -

Each p5.XML object provides an easy way to interact with XML - data. - - Extensible Markup Language - - (XML) - - is a standard format for sending data between applications. Like HTML, the - - XML format is based on tags and attributes, as in - - .

- -

Note: Use loadXML() to load external - XML files.

-line: 9 -isConstructor: true -example: - - |- - -
- - let myXML; - - // Load the XML and create a p5.XML object. - function preload() { - myXML = loadXML('/assets/animals.xml'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Get an array with all mammal tags. - let mammals = myXML.getChildren('mammal'); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(14); - - // Iterate over the mammals array. - for (let i = 0; i < mammals.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 25; - - // Get the mammal's common name. - let name = mammals[i].getContent(); - - // Display the mammal's name. - text(name, 20, y); - } - - describe( - 'The words "Goat", "Leopard", and "Zebra" written on three separate lines. The text is black on a gray background.' - ); - } - -
-methods: - getParent: - description: > -

Returns the element's parent element as a new p5.XML - - object.

- path: p5.XML/getParent - getName: - description: > -

Returns the element's name as a String.

- -

An XML element's name is given by its tag. For example, the element - - JavaScript has the name - language.

- path: p5.XML/getName - setName: - description: > -

Sets the element's tag name.

- -

An XML element's name is given by its tag. For example, the element - - JavaScript has the name - language.

- -

The parameter, name, is the element's new name as a - string. For example, - - calling myXML.setName('planet') will make the element's new - tag name - - .

- path: p5.XML/setName - hasChildren: - description: > -

Returns true if the element has child elements and - false if not.

- path: p5.XML/hasChildren - listChildren: - description: | -

Returns an array with the names of the element's child elements as - Strings.

- path: p5.XML/listChildren - getChildren: - description: > -

Returns an array with the element's child elements as new - - p5.XML objects.

- -

The parameter, name, is optional. If a string is passed, - as in - - myXML.getChildren('cat'), then the method will only return - child elements - - with the tag .

- path: p5.XML/getChildren - getChild: - description: > -

Returns the first matching child element as a new - - p5.XML object.

- -

The parameter, name, is optional. If a string is passed, - as in - - myXML.getChild('cat'), then the first child element with the - tag - - will be returned. If a number is passed, as in - - myXML.getChild(1), then the child element at that index will - be returned.

- path: p5.XML/getChild - addChild: - description: > -

Adds a new child element and returns a reference to it.

- -

The parameter, child, is the p5.XML object to add - - as a child element. For example, calling - myXML.addChild(otherXML) inserts - - otherXML as a child element of myXML.

- path: p5.XML/addChild - removeChild: - description: > -

Removes the first matching child element.

- -

The parameter, name, is the child element to remove. If a - string is - - passed, as in myXML.removeChild('cat'), then the first child - element - - with the tag will be removed. If a number is passed, as - in - - myXML.removeChild(1), then the child element at that index - will be - - removed.

- path: p5.XML/removeChild - getAttributeCount: - description: | -

Returns the number of attributes the element has.

- path: p5.XML/getAttributeCount - listAttributes: - description: > -

Returns an Array with the names of the element's - attributes.

- -

Note: Use - - myXML.getString() or - - myXML.getNum() to return an - attribute's value.

- path: p5.XML/listAttributes - hasAttribute: - description: > -

Returns true if the element has a given attribute and - false if not.

- -

The parameter, name, is a string with the name of the - attribute being - - checked.

- -

Note: Use - - myXML.getString() or - - myXML.getNum() to return an - attribute's value.

- path: p5.XML/hasAttribute - getNum: - description: > -

Return an attribute's value as a Number.

- -

The first parameter, name, is a string with the name of - the attribute - - being checked. For example, calling myXML.getNum('id') - returns the - - element's id attribute as a number.

- -

The second parameter, defaultValue, is optional. If a - number is passed, - - as in myXML.getNum('id', -1), it will be returned if the - attribute - - doesn't exist or can't be converted to a number.

- -

Note: Use - - myXML.getString() or - - myXML.getNum() to return an - attribute's value.

- path: p5.XML/getNum - getString: - description: > -

Return an attribute's value as a string.

- -

The first parameter, name, is a string with the name of - the attribute - - being checked. For example, calling myXML.getString('color') - returns the - - element's id attribute as a string.

- -

The second parameter, defaultValue, is optional. If a - string is passed, - - as in myXML.getString('color', 'deeppink'), it will be - returned if the - - attribute doesn't exist.

- -

Note: Use - - myXML.getString() or - - myXML.getNum() to return an - attribute's value.

- path: p5.XML/getString - setAttribute: - description: > -

Sets an attribute to a given value.

- -

The first parameter, name, is a string with the name of - the attribute - - being set.

- -

The second parameter, value, is the attribute's new value. - For example, - - calling myXML.setAttribute('id', 123) sets the - id attribute to the - - value 123.

- path: p5.XML/setAttribute - getContent: - description: > -

Returns the element's content as a String.

- -

The parameter, defaultValue, is optional. If a string is - passed, as in - - myXML.getContent('???'), it will be returned if the element - has no - - content.

- path: p5.XML/getContent - setContent: - description: > -

Sets the element's content.

- -

An element's content is the text between its tags. For example, the - element - - JavaScript has the content - JavaScript.

- -

The parameter, content, is a string with the element's new - content.

- path: p5.XML/setContent - serialize: - description: > -

Returns the element as a String.

- -

myXML.serialize() is useful for sending the element over - the network or - - saving it to a file.

- path: p5.XML/serialize -chainable: false ---- - - -# p5.XML diff --git a/src/content/reference/en/p5 copy/p5.mdx b/src/content/reference/en/p5 copy/p5.mdx deleted file mode 100644 index c51b8f8bff..0000000000 --- a/src/content/reference/en/p5 copy/p5.mdx +++ /dev/null @@ -1,51 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L12 -title: p5 -module: IO -submodule: Output -file: src/core/main.js -description: > -

This is the p5 instance constructor.

- -

A p5 instance holds all the properties and methods related to - - a p5 sketch. It expects an incoming sketch closure and it can also - - take an optional node parameter for attaching the generated p5 canvas - - to a node. The sketch closure takes the newly created p5 instance as - - its sole argument and may optionally set preload(), - - setup(), and/or - - draw() properties on it for running a - sketch.

- -

A p5 sketch can run in "global" or "instance" mode: - - "global" - all properties and methods are attached to the window - - "instance" - all properties and methods are bound to this p5 object

-line: 12 -isConstructor: true -params: - - name: sketch - description: | -

a closure that can set optional preload(), - setup(), and/or draw() properties on the - given p5 instance

- type: Function(p5) - - name: node - description: | -

element to attach canvas to

- type: HTMLElement - optional: true -chainable: false ---- - - -# p5 diff --git a/src/content/reference/en/p5 copy/pAccelerationX.mdx b/src/content/reference/en/p5 copy/pAccelerationX.mdx deleted file mode 100644 index ab1f3e49d1..0000000000 --- a/src/content/reference/en/p5 copy/pAccelerationX.mdx +++ /dev/null @@ -1,21 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L90 -title: pAccelerationX -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: | -

The system variable pAccelerationX always contains the acceleration of the - device along the x axis in the frame previous to the current frame. Value - is represented as meters per second squared.

-line: 90 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# pAccelerationX diff --git a/src/content/reference/en/p5 copy/pAccelerationY.mdx b/src/content/reference/en/p5 copy/pAccelerationY.mdx deleted file mode 100644 index 188ae8f77c..0000000000 --- a/src/content/reference/en/p5 copy/pAccelerationY.mdx +++ /dev/null @@ -1,21 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L100 -title: pAccelerationY -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: | -

The system variable pAccelerationY always contains the acceleration of the - device along the y axis in the frame previous to the current frame. Value - is represented as meters per second squared.

-line: 100 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# pAccelerationY diff --git a/src/content/reference/en/p5 copy/pAccelerationZ.mdx b/src/content/reference/en/p5 copy/pAccelerationZ.mdx deleted file mode 100644 index f291e6b707..0000000000 --- a/src/content/reference/en/p5 copy/pAccelerationZ.mdx +++ /dev/null @@ -1,21 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L110 -title: pAccelerationZ -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: | -

The system variable pAccelerationZ always contains the acceleration of the - device along the z axis in the frame previous to the current frame. Value - is represented as meters per second squared.

-line: 110 -isConstructor: false -itemtype: property -class: p5 -type: Number ---- - - -# pAccelerationZ diff --git a/src/content/reference/en/p5 copy/pRotationX.mdx b/src/content/reference/en/p5 copy/pRotationX.mdx deleted file mode 100644 index 03d80f8ae5..0000000000 --- a/src/content/reference/en/p5 copy/pRotationX.mdx +++ /dev/null @@ -1,63 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L234 -title: pRotationX -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

The system variable pRotationX always contains the rotation of the - - device along the x axis in the frame previous to the current frame. - - If the sketch angleMode() is set to - DEGREES, - - the value will be -180 to 180. If it is set to RADIANS, the value will - - be -PI to PI.

- -

pRotationX can also be used with rotationX to determine the rotate - - direction of the device along the X-axis.

-line: 234 -isConstructor: false -itemtype: property -example: - - |- - -
- - // A simple if statement looking at whether - // rotationX - pRotationX < 0 is true or not will be - // sufficient for determining the rotate direction - // in most cases. - - // Some extra logic is needed to account for cases where - // the angles wrap around. - let rotateDirection = 'clockwise'; - - // Simple range conversion to make things simpler. - // This is not absolutely necessary but the logic - // will be different in that case. - - let rX = rotationX + 180; - let pRX = pRotationX + 180; - - if ((rX - pRX > 0 && rX - pRX < 270) || rX - pRX < -270) { - rotateDirection = 'clockwise'; - } else if (rX - pRX < 0 || rX - pRX > 270) { - rotateDirection = 'counter-clockwise'; - } - - print(rotateDirection); - describe('no image to display.'); - -
-class: p5 -type: Number ---- - - -# pRotationX diff --git a/src/content/reference/en/p5 copy/pRotationY.mdx b/src/content/reference/en/p5 copy/pRotationY.mdx deleted file mode 100644 index 3a15f47f43..0000000000 --- a/src/content/reference/en/p5 copy/pRotationY.mdx +++ /dev/null @@ -1,62 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L278 -title: pRotationY -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

The system variable pRotationY always contains the rotation of the - - device along the y axis in the frame previous to the current frame. - - If the sketch angleMode() is set to - DEGREES, - - the value will be -90 to 90. If it is set to RADIANS, the value will - - be -PI/2 to PI/2.

- -

pRotationY can also be used with rotationY to determine the rotate - - direction of the device along the Y-axis.

-line: 278 -isConstructor: false -itemtype: property -example: - - |- - -
- - // A simple if statement looking at whether - // rotationY - pRotationY < 0 is true or not will be - // sufficient for determining the rotate direction - // in most cases. - - // Some extra logic is needed to account for cases where - // the angles wrap around. - let rotateDirection = 'clockwise'; - - // Simple range conversion to make things simpler. - // This is not absolutely necessary but the logic - // will be different in that case. - - let rY = rotationY + 180; - let pRY = pRotationY + 180; - - if ((rY - pRY > 0 && rY - pRY < 270) || rY - pRY < -270) { - rotateDirection = 'clockwise'; - } else if (rY - pRY < 0 || rY - pRY > 270) { - rotateDirection = 'counter-clockwise'; - } - print(rotateDirection); - describe('no image to display.'); - -
-class: p5 -type: Number ---- - - -# pRotationY diff --git a/src/content/reference/en/p5 copy/pRotationZ.mdx b/src/content/reference/en/p5 copy/pRotationZ.mdx deleted file mode 100644 index 4ae6d5e63f..0000000000 --- a/src/content/reference/en/p5 copy/pRotationZ.mdx +++ /dev/null @@ -1,58 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L321 -title: pRotationZ -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

The system variable pRotationZ always contains the rotation of the - - device along the z axis in the frame previous to the current frame. - - If the sketch angleMode() is set to - DEGREES, - - the value will be 0 to 360. If it is set to RADIANS, the value will - - be 0 to 2*PI.

- -

pRotationZ can also be used with rotationZ to determine the rotate - - direction of the device along the Z-axis.

-line: 321 -isConstructor: false -itemtype: property -example: - - |- - -
- - // A simple if statement looking at whether - // rotationZ - pRotationZ < 0 is true or not will be - // sufficient for determining the rotate direction - // in most cases. - - // Some extra logic is needed to account for cases where - // the angles wrap around. - let rotateDirection = 'clockwise'; - - if ( - (rotationZ - pRotationZ > 0 && rotationZ - pRotationZ < 270) || - rotationZ - pRotationZ < -270 - ) { - rotateDirection = 'clockwise'; - } else if (rotationZ - pRotationZ < 0 || rotationZ - pRotationZ > 270) { - rotateDirection = 'counter-clockwise'; - } - print(rotateDirection); - describe('no image to display.'); - -
-class: p5 -type: Number ---- - - -# pRotationZ diff --git a/src/content/reference/en/p5 copy/paletteLerp.mdx b/src/content/reference/en/p5 copy/paletteLerp.mdx deleted file mode 100644 index 54e8c9f885..0000000000 --- a/src/content/reference/en/p5 copy/paletteLerp.mdx +++ /dev/null @@ -1,66 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L1079 -title: paletteLerp -module: Color -submodule: Creating & Reading -file: src/color/creating_reading.js -description: > -

Blends multiple colors to find a color between them.

- -

The amt parameter specifies the amount to interpolate between - the color - - stops which are colors at each amt value "location" with - amt values - - that are between 2 color stops interpolating between them based on its - relative - - distance to both.

- -

The way that colors are interpolated depends on the current - - colorMode().

-line: 1079 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(400, 400); - } - - function draw() { - // The background goes from white to red to green to blue fill - background(paletteLerp([ - ['white', 0], - ['red', 0.05], - ['green', 0.25], - ['blue', 1] - ], millis() / 10000 % 1)); - } - -
-class: p5 -params: - - name: colors_stops - description: | -

color stops to interpolate from

- type: '[p5.Color, Number][]' - - name: amt - description: | -

number to use to interpolate relative to color stops

- type: Number -return: - description: interpolated color. - type: p5.Color -chainable: false ---- - - -# paletteLerp diff --git a/src/content/reference/en/p5 copy/panorama.mdx b/src/content/reference/en/p5 copy/panorama.mdx deleted file mode 100644 index 97ee1fd9ca..0000000000 --- a/src/content/reference/en/p5 copy/panorama.mdx +++ /dev/null @@ -1,76 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L1021 -title: panorama -module: 3D -submodule: Lights -file: src/webgl/light.js -description: > -

Creates an immersive 3D background.

- -

panorama() transforms images containing 360˚ content, such as - maps or - - HDRIs, into immersive 3D backgrounds that surround a sketch. Exploring the - - space requires changing the camera's perspective with functions such as - - orbitControl() or - - camera().

-line: 1021 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - let img; - - // Load an image and create a p5.Image object. - function preload() { - img = loadImage('/assets/outdoor_spheremap.jpg'); - } - - function setup() { - createCanvas(100 ,100 ,WEBGL); - - describe('A sphere floating above a landscape. The surface of the sphere reflects the landscape. The full landscape is viewable in 3D as the user drags the mouse.'); - } - - function draw() { - // Add the panorama. - panorama(img); - - // Enable orbiting with the mouse. - orbitControl(); - - // Use the image as a light source. - imageLight(img); - - // Style the sphere. - noStroke(); - specularMaterial(50); - shininess(200); - metalness(100); - - // Draw the sphere. - sphere(30); - } - -
-class: p5 -params: - - name: img - description: | -

360˚ image to use as the background.

- type: p5.Image -chainable: false ---- - - -# panorama diff --git a/src/content/reference/en/p5 copy/perspective.mdx b/src/content/reference/en/p5 copy/perspective.mdx deleted file mode 100644 index 21cca35746..0000000000 --- a/src/content/reference/en/p5 copy/perspective.mdx +++ /dev/null @@ -1,194 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L148 -title: perspective -module: 3D -submodule: Camera -file: src/webgl/p5.Camera.js -description: > -

Sets a perspective projection for the current camera in a 3D sketch.

- -

In a perspective projection, shapes that are further from the camera appear - - smaller than shapes that are near the camera. This technique, called - - foreshortening, creates realistic 3D scenes. It’s applied by default in - - WebGL mode.

- -

perspective() changes the camera’s perspective by changing its - viewing - - frustum. The frustum is the volume of space that’s visible to the camera. - - Its shape is a pyramid with its top cut off. The camera is placed where - - the top of the pyramid should be and views everything between the frustum’s - - top (near) plane and its bottom (far) plane.

- -

The first parameter, fovy, is the camera’s vertical field of - view. It’s - - an angle that describes how tall or narrow a view the camera has. For - - example, calling perspective(0.5) sets the camera’s vertical - field of - - view to 0.5 radians. By default, fovy is calculated based on the - sketch’s - - height and the camera’s default z-coordinate, which is 800. The formula for - - the default fovy is 2 * atan(height / 2 / 800).

- -

The second parameter, aspect, is the camera’s aspect ratio. - It’s a number - - that describes the ratio of the top plane’s width to its height. For - - example, calling perspective(0.5, 1.5) sets the camera’s field of - view to - - 0.5 radians and aspect ratio to 1.5, which would make shapes appear thinner - - on a square canvas. By default, aspect is set to width / - height.

- -

The third parameter, near, is the distance from the camera to - the near - - plane. For example, calling perspective(0.5, 1.5, 100) sets the - camera’s - - field of view to 0.5 radians, its aspect ratio to 1.5, and places the near - - plane 100 pixels from the camera. Any shapes drawn less than 100 pixels - - from the camera won’t be visible. By default, near is set to 0.1 * - 800, - - which is 1/10th the default distance between the camera and the origin.

- -

The fourth parameter, far, is the distance from the camera to - the far - - plane. For example, calling perspective(0.5, 1.5, 100, 10000) - sets the - - camera’s field of view to 0.5 radians, its aspect ratio to 1.5, places the - - near plane 100 pixels from the camera, and places the far plane 10,000 - - pixels from the camera. Any shapes drawn more than 10,000 pixels from the - - camera won’t be visible. By default, far is set to 10 * 800, - which is 10 - - times the default distance between the camera and the origin.

- -

Note: perspective() can only be used in WebGL mode.

-line: 148 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Double-click to squeeze the box. - - let isSqueezed = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white rectangular prism on a gray background. The box appears to become thinner when the user double-clicks.'); - } - - function draw() { - background(200); - - // Place the camera at the top-right. - camera(400, -400, 800); - - if (isSqueezed === true) { - // Set fovy to 0.2. - // Set aspect to 1.5. - perspective(0.2, 1.5); - } - - // Draw the box. - box(); - } - - // Change the camera's perspective when the user double-clicks. - function doubleClicked() { - isSqueezed = true; - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white rectangular prism on a gray background. The prism moves away from the camera until it disappears.'); - } - - function draw() { - background(200); - - // Place the camera at the top-right. - camera(400, -400, 800); - - // Set fovy to 0.2. - // Set aspect to 1.5. - // Set near to 600. - // Set far to 1200. - perspective(0.2, 1.5, 600, 1200); - - // Move the origin away from the camera. - let x = -frameCount; - let y = frameCount; - let z = -2 * frameCount; - translate(x, y, z); - - // Draw the box. - box(); - } - -
-class: p5 -params: - - name: fovy - description: | -

camera frustum vertical field of view. Defaults to - 2 * atan(height / 2 / 800).

- type: Number - optional: true - - name: aspect - description: | -

camera frustum aspect ratio. Defaults to - width / height.

- type: Number - optional: true - - name: near - description: | -

distance from the camera to the near clipping plane. - Defaults to 0.1 * 800.

- type: Number - optional: true - - name: far - description: | -

distance from the camera to the far clipping plane. - Defaults to 10 * 800.

- type: Number - optional: true -chainable: true ---- - - -# perspective diff --git a/src/content/reference/en/p5 copy/pixelDensity.mdx b/src/content/reference/en/p5 copy/pixelDensity.mdx deleted file mode 100644 index 808ebab227..0000000000 --- a/src/content/reference/en/p5 copy/pixelDensity.mdx +++ /dev/null @@ -1,90 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L1005 -title: pixelDensity -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

Sets the pixel density or returns the current density.

- -

Computer displays are grids of little lights called pixels. A - - display's pixel density describes how many pixels it packs into an - - area. Displays with smaller pixels have a higher pixel density and create - - sharper images.

- -

pixelDensity() sets the pixel scaling for high pixel density - displays. - - By default, the pixel density is set to match the display's density. - - Calling pixelDensity(1) turn this off.

- -

Calling pixelDensity() without an argument returns the current - pixel - - density.

-line: 1005 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - // Set the pixel density to 1. - pixelDensity(1); - - // Create a canvas and draw - // a circle. - createCanvas(100, 100); - background(200); - circle(50, 50, 70); - - describe('A fuzzy white circle on a gray canvas.'); - } - -
- -
- - function setup() { - // Set the pixel density to 3. - pixelDensity(3); - - // Create a canvas, paint the - // background, and draw a - // circle. - createCanvas(100, 100); - background(200); - circle(50, 50, 70); - - describe('A sharp white circle on a gray canvas.'); - } - -
-class: p5 -overloads: - - line: 1005 - params: - - name: val - description: | -

desired pixel density.

- type: Number - optional: true - chainable: 1 - - line: 1059 - params: [] - return: - description: current pixel density of the sketch. - type: Number -chainable: true ---- - - -# pixelDensity diff --git a/src/content/reference/en/p5 copy/pixels.mdx b/src/content/reference/en/p5 copy/pixels.mdx deleted file mode 100644 index 7185d708bf..0000000000 --- a/src/content/reference/en/p5 copy/pixels.mdx +++ /dev/null @@ -1,173 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L12 -title: pixels -module: Image -submodule: Pixels -file: src/image/pixels.js -description: > -

An array containing the color of each pixel on the canvas.

- -

Colors are stored as numbers representing red, green, blue, and alpha - - (RGBA) values. pixels is a one-dimensional array for performance - reasons.

- -

Each pixel occupies four elements in the pixels array, one for - each RGBA - - value. For example, the pixel at coordinates (0, 0) stores its RGBA values - - at pixels[0], pixels[1], pixels[2], and - pixels[3], respectively. - - The next pixel at coordinates (1, 0) stores its RGBA values at - pixels[4], - - pixels[5], pixels[6], and pixels[7]. - And so on. The pixels array - - for a 100×100 canvas has 100 × 100 × 4 = 40,000 elements.

- -

Some displays use several smaller pixels to set the color at a single - - point. The pixelDensity() function - returns - - the pixel density of the canvas. High density displays often have a - - pixelDensity() of 2. On such a - display, the - - pixels array for a 100×100 canvas has 200 × 200 × 4 = - - 160,000 elements.

- -

Accessing the RGBA values for a point on the canvas requires a little math - - as shown below. The loadPixels() - function - - must be called before accessing the pixels array. The - - updatePixels() function must be - called - - after any changes are made.

-line: 12 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Load the pixels array. - loadPixels(); - - // Set the dot's coordinates. - let x = 50; - let y = 50; - - // Get the pixel density. - let d = pixelDensity(); - - // Set the pixel(s) at the center of the canvas black. - for (let i = 0; i < d; i += 1) { - for (let j = 0; j < d; j += 1) { - let index = 4 * ((y * d + j) * width * d + (x * d + i)); - // Red. - pixels[index] = 0; - // Green. - pixels[index + 1] = 0; - // Blue. - pixels[index + 2] = 0; - // Alpha. - pixels[index + 3] = 255; - } - } - - // Update the canvas. - updatePixels(); - - describe('A black dot in the middle of a gray rectangle.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Load the pixels array. - loadPixels(); - - // Get the pixel density. - let d = pixelDensity(); - - // Calculate the halfway index in the pixels array. - let halfImage = 4 * (d * width) * (d * height / 2); - - // Make the top half of the canvas red. - for (let i = 0; i < halfImage; i += 4) { - // Red. - pixels[i] = 255; - // Green. - pixels[i + 1] = 0; - // Blue. - pixels[i + 2] = 0; - // Alpha. - pixels[i + 3] = 255; - } - - // Update the canvas. - updatePixels(); - - describe('A red rectangle drawn above a gray rectangle.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Create a p5.Color object. - let pink = color(255, 102, 204); - - // Load the pixels array. - loadPixels(); - - // Get the pixel density. - let d = pixelDensity(); - - // Calculate the halfway index in the pixels array. - let halfImage = 4 * (d * width) * (d * height / 2); - - // Make the top half of the canvas red. - for (let i = 0; i < halfImage; i += 4) { - pixels[i] = red(pink); - pixels[i + 1] = green(pink); - pixels[i + 2] = blue(pink); - pixels[i + 3] = alpha(pink); - } - - // Update the canvas. - updatePixels(); - - describe('A pink rectangle drawn above a gray rectangle.'); - } - -
-class: p5 -type: 'Number[]' ---- - - -# pixels diff --git a/src/content/reference/en/p5 copy/plane.mdx b/src/content/reference/en/p5 copy/plane.mdx deleted file mode 100644 index eefeb29b7a..0000000000 --- a/src/content/reference/en/p5 copy/plane.mdx +++ /dev/null @@ -1,152 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L866 -title: plane -module: Shape -submodule: 3D Primitives -file: src/webgl/3d_primitives.js -description: > -

Draws a plane.

- -

A plane is a four-sided, flat shape with every angle measuring 90˚. It’s - - similar to a rectangle and offers advanced drawing features in WebGL mode.

- -

The first parameter, width, is optional. If a - Number is passed, as in - - plane(20), it sets the plane’s width and height. By default, - width is - - 50.

- -

The second parameter, height, is also optional. If a - Number is passed, - - as in plane(20, 30), it sets the plane’s height. By default, - height is - - set to the plane’s width.

- -

The third parameter, detailX, is also optional. If a - Number is passed, - - as in plane(20, 30, 5) it sets the number of triangle - subdivisions to use - - along the x-axis. All 3D shapes are made by connecting triangles to form - - their surfaces. By default, detailX is 1.

- -

The fourth parameter, detailY, is also optional. If a - Number is passed, - - as in plane(20, 30, 5, 7) it sets the number of triangle - subdivisions to - - use along the y-axis. All 3D shapes are made by connecting triangles to - - form their surfaces. By default, detailY is 1.

- -

Note: plane() can only be used in WebGL mode.

-line: 866 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white plane on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the plane. - plane(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white plane on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the plane. - // Set its width and height to 30. - plane(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white plane on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the plane. - // Set its width to 30 and height to 50. - plane(30, 50); - } - -
-class: p5 -params: - - name: width - description: | -

width of the plane.

- type: Number - optional: true - - name: height - description: | -

height of the plane.

- type: Number - optional: true - - name: detailX - description: | -

number of triangle subdivisions along the x-axis.

- type: Integer - optional: true - - name: detailY - description: | -

number of triangle subdivisions along the y-axis.

- type: Integer - optional: true -chainable: true ---- - - -# plane diff --git a/src/content/reference/en/p5 copy/pmouseX.mdx b/src/content/reference/en/p5 copy/pmouseX.mdx deleted file mode 100644 index 5f5e8ff7f7..0000000000 --- a/src/content/reference/en/p5 copy/pmouseX.mdx +++ /dev/null @@ -1,88 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L333 -title: pmouseX -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A Number system variable that tracks the mouse's previous - horizontal - - position.

- -

pmouseX keeps track of the mouse's position relative to the - - top-left corner of the canvas. Its value is - - mouseX from the previous frame. For - example, if - - the mouse was 50 pixels from the left edge of the canvas during the last - - frame, then pmouseX will be 50.

- -

If touch is used instead of the mouse, then pmouseX will hold - the - - x-coordinate of the last touch point.

- -

Note: pmouseX is reset to the current mouseX - - value at the start of each touch event.

-line: 333 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Slow the frame rate. - frameRate(10); - - describe('A line follows the mouse as it moves. The line grows longer with faster movements.'); - } - - function draw() { - background(200); - - line(pmouseX, pmouseY, mouseX, mouseY); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A line follows the mouse as it moves. The line grows longer with faster movements.'); - } - - function draw() { - background(200); - - // Adjust coordinates for WebGL mode. - // The origin (0, 0) is at the center of the canvas. - let pmx = pmouseX - 50; - let pmy = pmouseY - 50; - let mx = mouseX - 50; - let my = mouseY - 50; - - // Draw the line. - line(pmx, pmy, mx, my); - } - -
-class: p5 -type: Number ---- - - -# pmouseX diff --git a/src/content/reference/en/p5 copy/pmouseY.mdx b/src/content/reference/en/p5 copy/pmouseY.mdx deleted file mode 100644 index 558747e43f..0000000000 --- a/src/content/reference/en/p5 copy/pmouseY.mdx +++ /dev/null @@ -1,88 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L398 -title: pmouseY -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A Number system variable that tracks the mouse's previous - vertical - - position.

- -

pmouseY keeps track of the mouse's position relative to the - - top-left corner of the canvas. Its value is - - mouseY from the previous frame. For - example, if - - the mouse was 50 pixels from the top edge of the canvas during the last - - frame, then pmouseY will be 50.

- -

If touch is used instead of the mouse, then pmouseY will hold - the - - y-coordinate of the last touch point.

- -

Note: pmouseY is reset to the current mouseY - - value at the start of each touch event.

-line: 398 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Slow the frame rate. - frameRate(10); - - describe('A line follows the mouse as it moves. The line grows longer with faster movements.'); - } - - function draw() { - background(200); - - line(pmouseX, pmouseY, mouseX, mouseY); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A line follows the mouse as it moves. The line grows longer with faster movements.'); - } - - function draw() { - background(200); - - // Adjust coordinates for WebGL mode. - // The origin (0, 0) is at the center of the canvas. - let pmx = pmouseX - 50; - let pmy = pmouseY - 50; - let mx = mouseX - 50; - let my = mouseY - 50; - - // Draw the line. - line(pmx, pmy, mx, my); - } - -
-class: p5 -type: Number ---- - - -# pmouseY diff --git a/src/content/reference/en/p5 copy/point.mdx b/src/content/reference/en/p5 copy/point.mdx deleted file mode 100644 index 7912c06cbb..0000000000 --- a/src/content/reference/en/p5 copy/point.mdx +++ /dev/null @@ -1,229 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L721 -title: point -module: Shape -submodule: 2D Primitives -file: src/core/shape/2d_primitives.js -description: > -

Draws a single point in space.

- -

A point's default width is one pixel. To color a point, use the - - stroke() function. To change its width, - use the - - strokeWeight() function. A point - - can't be filled, so the fill() function - won't - - affect the point's color.

- -

The version of point() with two parameters allows the point's - location to - - be set with its x- and y-coordinates, as in point(10, 20).

- -

The version of point() with three parameters allows the point - to be drawn - - in 3D space with x-, y-, and z-coordinates, as in point(10, 20, - 30). - - Doing so requires adding the WEBGL argument to - - createCanvas().

- -

The version of point() with one parameter allows the point's - location to - - be set with a p5.Vector object.

-line: 721 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - - // Making point to 5 pixels - strokeWeight(5); - - - // Top-left. - point(30, 20); - - // Top-right. - point(85, 20); - - // Bottom-right. - point(85, 75); - - // Bottom-left. - point(30, 75); - - describe( - 'Four small, black points drawn on a gray canvas. The points form the corners of a square.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - - // Making point to 5 pixels. - strokeWeight(5); - - - // Top-left. - point(30, 20); - - // Top-right. - point(70, 20); - - // Style the next points. - stroke('purple'); - strokeWeight(10); - - // Bottom-right. - point(70, 80); - - // Bottom-left. - point(30, 80); - - describe( - 'Four points drawn on a gray canvas. Two are black and two are purple. The points form the corners of a square.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - - // Making point to 5 pixels. - strokeWeight(5); - - - // Top-left. - let a = createVector(30, 20); - point(a); - - // Top-right. - let b = createVector(70, 20); - point(b); - - // Bottom-right. - let c = createVector(70, 80); - point(c); - - // Bottom-left. - let d = createVector(30, 80); - point(d); - - describe( - 'Four small, black points drawn on a gray canvas. The points form the corners of a square.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('Two purple points drawn on a gray canvas.'); - } - - function draw() { - background(200); - - // Style the points. - stroke('purple'); - strokeWeight(10); - - // Top-left. - point(-20, -30); - - // Bottom-right. - point(20, 30); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('Two purple points drawn on a gray canvas. The scene spins slowly.'); - } - - function draw() { - background(200); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Style the points. - stroke('purple'); - strokeWeight(10); - - // Top-left. - point(-20, -30, 0); - - // Bottom-right. - point(20, 30, -50); - } - -
-class: p5 -overloads: - - line: 721 - params: - - name: x - description: | -

the x-coordinate.

- type: Number - - name: 'y' - description: | -

the y-coordinate.

- type: Number - - name: z - description: | -

the z-coordinate (for WebGL mode).

- type: Number - optional: true - chainable: 1 - - line: 900 - params: - - name: coordinateVector - description: | -

the coordinate vector.

- type: p5.Vector - chainable: 1 -chainable: true ---- - - -# point diff --git a/src/content/reference/en/p5 copy/pointLight.mdx b/src/content/reference/en/p5 copy/pointLight.mdx deleted file mode 100644 index c6f10715b9..0000000000 --- a/src/content/reference/en/p5 copy/pointLight.mdx +++ /dev/null @@ -1,329 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L683 -title: pointLight -module: 3D -submodule: Lights -file: src/webgl/light.js -description: > -

Creates a light that shines from a point in all directions.

- -

Point lights are like light bulbs that shine in all directions. They can be - - placed at different positions to achieve different lighting effects. A - - maximum of 5 point lights can be active at once.

- -

There are four ways to call pointLight() with parameters to - set the - - light’s color and position.

- -

The first way to call pointLight() has six parameters. The - first three - - parameters, v1, v2, and v3, set the - light’s color using the current - - colorMode(). The last three parameters, - x, - - y, and z, set the light’s position. For example, - - pointLight(255, 0, 0, 50, 0, 0) creates a red (255, 0, - 0) light that - - shines from the coordinates (50, 0, 0).

- -

The second way to call pointLight() has four parameters. The - first three - - parameters, v1, v2, and v3, set the - light’s color using the current - - colorMode(). The last parameter, - position sets - - the light’s position using a p5.Vector - object. - - For example, pointLight(255, 0, 0, lightPos) creates a red - (255, 0, 0) - - light that shines from the position set by the lightPos - vector.

- -

The third way to call pointLight() has four parameters. The - first - - parameter, color, sets the light’s color using a - - p5.Color object or an array of color - values. The - - last three parameters, x, y, and z, set - the light’s position. For - - example, directionalLight(myColor, 50, 0, 0) creates a light that - shines - - from the coordinates (50, 0, 0) with the color value of - myColor.

- -

The fourth way to call pointLight() has two parameters. The - first - - parameter, color, sets the light’s color using a - - p5.Color object or an array of color - values. The - - second parameter, position, sets the light’s position using a - - p5.Vector object. For example, - - directionalLight(myColor, lightPos) creates a light that shines - from the - - position set by the lightPos vector with the color value of - myColor.

-line: 683 -isConstructor: false -itemtype: method -example: - - |- - - -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click to turn on the point light. - - let isLit = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A sphere drawn on a gray background. A red light starts shining from above when the user double-clicks.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Control the light. - if (isLit === true) { - // Add a red point light from above. - // Use RGB values and XYZ coordinates. - pointLight(255, 0, 0, 0, -150, 0); - } - - // Style the sphere. - noStroke(); - - // Draw the sphere. - sphere(30); - } - - // Turn on the point light when the user double-clicks. - function doubleClicked() { - isLit = true; - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Add a red point light from above. - // Use a p5.Color object and XYZ directions. - let c = color(255, 0, 0); - pointLight(c, 0, -150, 0); - - // Style the sphere. - noStroke(); - - // Draw the sphere. - sphere(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Add a red point light from above. - // Use a p5.Color object and a p5.Vector object. - let c = color(255, 0, 0); - let lightPos = createVector(0, -150, 0); - pointLight(c, lightPos); - - // Style the sphere. - noStroke(); - - // Draw the sphere. - sphere(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('Four spheres arranged in a square and drawn on a gray background. The spheres appear bright red toward the center of the square. The color gets darker toward the corners of the square.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Add a red point light that points to the center of the scene. - // Use a p5.Color object and a p5.Vector object. - let c = color(255, 0, 0); - let lightPos = createVector(0, 0, 65); - pointLight(c, lightPos); - - // Style the spheres. - noStroke(); - - // Draw a sphere up and to the left. - push(); - translate(-25, -25, 25); - sphere(10); - pop(); - - // Draw a box up and to the right. - push(); - translate(25, -25, 25); - sphere(10); - pop(); - - // Draw a sphere down and to the left. - push(); - translate(-25, 25, 25); - sphere(10); - pop(); - - // Draw a box down and to the right. - push(); - translate(25, 25, 25); - sphere(10); - pop(); - } - -
-class: p5 -overloads: - - line: 683 - params: - - name: v1 - description: | -

red or hue value in the current - colorMode().

- type: Number - - name: v2 - description: | -

green or saturation value in the current - colorMode().

- type: Number - - name: v3 - description: | -

blue, brightness, or lightness value in the current - colorMode().

- type: Number - - name: x - description: | -

x-coordinate of the light.

- type: Number - - name: 'y' - description: | -

y-coordinate of the light.

- type: Number - - name: z - description: | -

z-coordinate of the light.

- type: Number - chainable: 1 - - line: 890 - params: - - name: v1 - description: '' - type: Number - - name: v2 - description: '' - type: Number - - name: v3 - description: '' - type: Number - - name: position - description: | -

position of the light as a - p5.Vector object.

- type: p5.Vector - chainable: 1 - - line: 900 - params: - - name: color - description: | -

color as a p5.Color object, - an array of color values, or a CSS string.

- type: 'p5.Color|Number[]|String' - - name: x - description: '' - type: Number - - name: 'y' - description: '' - type: Number - - name: z - description: '' - type: Number - chainable: 1 - - line: 910 - params: - - name: color - description: '' - type: 'p5.Color|Number[]|String' - - name: position - description: '' - type: p5.Vector - chainable: 1 -chainable: true ---- - - -# pointLight diff --git a/src/content/reference/en/p5 copy/pop.mdx b/src/content/reference/en/p5 copy/pop.mdx deleted file mode 100644 index 72b5c1db21..0000000000 --- a/src/content/reference/en/p5 copy/pop.mdx +++ /dev/null @@ -1,20 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L553 -title: pop -module: Structure -submodule: Structure -file: src/core/structure.js -description: "

Ends a drawing group that contains its own styles and transformations.

\n

By default, styles such as fill() and\ntransformations such as rotate() are applied to\nall drawing that follows. The push() and pop()\nfunctions can limit the effect of styles and transformations to a specific\ngroup of shapes, images, and text. For example, a group of shapes could be\ntranslated to follow the mouse without affecting the rest of the sketch:

\n
// Begin the drawing group.\npush();\n\n// Translate the origin to the mouse's position.\ntranslate(mouseX, mouseY);\n\n// Style the face.\nnoStroke();\nfill('green');\n\n// Draw the face.\ncircle(0, 0, 60);\n\n// Style the eyes.\nfill('white');\n\n// Draw the left eye.\nellipse(-20, -20, 30, 20);\n\n// Draw the right eye.\nellipse(20, -20, 30, 20);\n\n// End the drawing group.\npop();\n\n// Draw a bug.\nlet x = random(0, 100);\nlet y = random(0, 100);\ntext('\U0001F99F', x, y);\n
\n

In the code snippet above, the bug's position isn't affected by\ntranslate(mouseX, mouseY) because that transformation is contained\nbetween push() and pop(). The bug moves around\nthe entire canvas as expected.

\n

Note: push() and pop() are always called as a\npair. Both functions are required to begin and end a drawing group.

\n

push() and pop() can also be nested to create\nsubgroups. For example, the code snippet above could be changed to give\nmore detail to the frog’s eyes:

\n
// Begin the drawing group.\npush();\n\n// Translate the origin to the mouse's position.\ntranslate(mouseX, mouseY);\n\n// Style the face.\nnoStroke();\nfill('green');\n\n// Draw a face.\ncircle(0, 0, 60);\n\n// Style the eyes.\nfill('white');\n\n// Draw the left eye.\npush();\ntranslate(-20, -20);\nellipse(0, 0, 30, 20);\nfill('black');\ncircle(0, 0, 8);\npop();\n\n// Draw the right eye.\npush();\ntranslate(20, -20);\nellipse(0, 0, 30, 20);\nfill('black');\ncircle(0, 0, 8);\npop();\n\n// End the drawing group.\npop();\n\n// Draw a bug.\nlet x = random(0, 100);\nlet y = random(0, 100);\ntext('\U0001F99F', x, y);\n
\n

In this version, the code to draw each eye is contained between its own\npush() and pop() functions. Doing so makes it\neasier to add details in the correct part of a drawing.

\n

push() and pop() contain the effects of the\nfollowing functions:

\n\n

In WebGL mode, push() and pop() contain the\neffects of a few additional styles:

\n\n" -line: 553 -isConstructor: false -itemtype: method -example: - - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Draw the left circle.\n circle(25, 50, 20);\n\n // Begin the drawing group.\n push();\n\n // Translate the origin to the center.\n translate(50, 50);\n\n // Style the circle.\n strokeWeight(5);\n stroke('royalblue');\n fill('orange');\n\n // Draw the circle.\n circle(0, 0, 20);\n\n // End the drawing group.\n pop();\n\n // Draw the right circle.\n circle(75, 50, 20);\n\n describe(\n 'Three circles drawn in a row on a gray background. The left and right circles are white with thin, black borders. The middle circle is orange with a thick, blue border.'\n );\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Slow the frame rate.\n frameRate(24);\n\n describe('A mosquito buzzes in front of a green frog. The frog follows the mouse as the user moves.');\n}\n\nfunction draw() {\n background(200);\n\n // Begin the drawing group.\n push();\n\n // Translate the origin to the mouse's position.\n translate(mouseX, mouseY);\n\n // Style the face.\n noStroke();\n fill('green');\n\n // Draw a face.\n circle(0, 0, 60);\n\n // Style the eyes.\n fill('white');\n\n // Draw the left eye.\n push();\n translate(-20, -20);\n ellipse(0, 0, 30, 20);\n fill('black');\n circle(0, 0, 8);\n pop();\n\n // Draw the right eye.\n push();\n translate(20, -20);\n ellipse(0, 0, 30, 20);\n fill('black');\n circle(0, 0, 8);\n pop();\n\n // End the drawing group.\n pop();\n\n // Draw a bug.\n let x = random(0, 100);\n let y = random(0, 100);\n text('\U0001F99F', x, y);\n}\n\n
\n\n
\n\n// Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n\n describe(\n 'Two spheres drawn on a gray background. The sphere on the left is red and lit from the front. The sphere on the right is a blue wireframe.'\n );\n}\n\nfunction draw() {\n background(200);\n\n // Enable orbiting with the mouse.\n orbitControl();\n\n // Draw the red sphere.\n push();\n translate(-25, 0, 0);\n noStroke();\n directionalLight(255, 0, 0, 0, 0, -1);\n sphere(20);\n pop();\n\n // Draw the blue sphere.\n push();\n translate(25, 0, 0);\n strokeWeight(0.3);\n stroke(0, 0, 255);\n noFill();\n sphere(20);\n pop();\n}\n\n
" -class: p5 -chainable: false ---- - - -# pop diff --git a/src/content/reference/en/p5 copy/pow.mdx b/src/content/reference/en/p5 copy/pow.mdx deleted file mode 100644 index 18201ec3c2..0000000000 --- a/src/content/reference/en/p5 copy/pow.mdx +++ /dev/null @@ -1,67 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L815 -title: pow -module: Math -submodule: Calculation -file: src/math/calculation.js -description: | -

Calculates exponential expressions such as 23.

-

For example, pow(2, 3) evaluates the expression - 2 × 2 × 2. pow(2, -3) evaluates 1 ÷ - (2 × 2 × 2).

-line: 815 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Set the base of the exponent. - let base = 3; - - // Top-left. - let d = pow(base, 1); - circle(10, 10, d); - - // Left-center. - d = pow(base, 2); - circle(20, 20, d); - - // Right-center. - d = pow(base, 3); - circle(40, 40, d); - - // Bottom-right. - d = pow(base, 4); - circle(80, 80, d); - - describe('A series of circles that grow exponentially from top left to bottom right.'); - } - -
-class: p5 -params: - - name: 'n' - description: | -

base of the exponential expression.

- type: Number - - name: e - description: | -

power by which to raise the base.

- type: Number -return: - description: n^e. - type: Number -chainable: false ---- - - -# pow diff --git a/src/content/reference/en/p5 copy/preload.mdx b/src/content/reference/en/p5 copy/preload.mdx deleted file mode 100644 index 66d5db4378..0000000000 --- a/src/content/reference/en/p5 copy/preload.mdx +++ /dev/null @@ -1,70 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L41 -title: preload -module: Structure -submodule: Structure -file: src/core/main.js -description: > -

A function that's called once to load assets before the sketch runs.

- -

Declaring the function preload() sets a code block to run once - - automatically before setup() or - - draw(). It's used to load assets including - - multimedia files, fonts, data, and 3D models:

- -
function preload() {
-    // Code to run before the rest of the sketch.
-  }
-
-  
- -

Functions such as loadImage(), - - loadFont(), - - loadJSON(), and - - loadModel() are guaranteed to either - - finish loading or raise an error if they're called within - preload(). - - Doing so ensures that assets are available when the sketch begins - - running.

-line: 41 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load an image and create a p5.Image object. - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Draw the image. - image(img, 0, 0); - - describe('A red brick wall.'); - } - -
-class: p5 -chainable: false ---- - - -# preload diff --git a/src/content/reference/en/p5 copy/print.mdx b/src/content/reference/en/p5 copy/print.mdx deleted file mode 100644 index 50137586ae..0000000000 --- a/src/content/reference/en/p5 copy/print.mdx +++ /dev/null @@ -1,55 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L21 -title: print -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

Displays text in the web browser's console.

- -

print() is helpful for printing values while debugging. Each - call to - - print() creates a new line of text.

- -

Note: Call print('\n') to print a blank line. Calling - print() without - - an argument opens the browser's dialog for printing documents.

-line: 21 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - // Prints "hello, world" to the console. - print('hello, world'); - } - -
- -
- - function setup() { - let name = 'ada'; - // Prints "hello, ada" to the console. - print(`hello, ${name}`); - } - -
-class: p5 -params: - - name: contents - description: | -

content to print to the console.

- type: Any -chainable: false ---- - - -# print diff --git a/src/content/reference/en/p5 copy/push.mdx b/src/content/reference/en/p5 copy/push.mdx deleted file mode 100644 index ee1a386cee..0000000000 --- a/src/content/reference/en/p5 copy/push.mdx +++ /dev/null @@ -1,20 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L269 -title: push -module: Structure -submodule: Structure -file: src/core/structure.js -description: "

Begins a drawing group that contains its own styles and transformations.

\n

By default, styles such as fill() and\ntransformations such as rotate() are applied to\nall drawing that follows. The push() and pop()\nfunctions can limit the effect of styles and transformations to a specific\ngroup of shapes, images, and text. For example, a group of shapes could be\ntranslated to follow the mouse without affecting the rest of the sketch:

\n
// Begin the drawing group.\npush();\n\n// Translate the origin to the mouse's position.\ntranslate(mouseX, mouseY);\n\n// Style the face.\nnoStroke();\nfill('green');\n\n// Draw the face.\ncircle(0, 0, 60);\n\n// Style the eyes.\nfill('white');\n\n// Draw the left eye.\nellipse(-20, -20, 30, 20);\n\n// Draw the right eye.\nellipse(20, -20, 30, 20);\n\n// End the drawing group.\npop();\n\n// Draw a bug.\nlet x = random(0, 100);\nlet y = random(0, 100);\ntext('\U0001F99F', x, y);\n
\n

In the code snippet above, the bug's position isn't affected by\ntranslate(mouseX, mouseY) because that transformation is contained\nbetween push() and pop(). The bug moves around\nthe entire canvas as expected.

\n

Note: push() and pop() are always called as a\npair. Both functions are required to begin and end a drawing group.

\n

push() and pop() can also be nested to create\nsubgroups. For example, the code snippet above could be changed to give\nmore detail to the frog’s eyes:

\n
// Begin the drawing group.\npush();\n\n// Translate the origin to the mouse's position.\ntranslate(mouseX, mouseY);\n\n// Style the face.\nnoStroke();\nfill('green');\n\n// Draw a face.\ncircle(0, 0, 60);\n\n// Style the eyes.\nfill('white');\n\n// Draw the left eye.\npush();\ntranslate(-20, -20);\nellipse(0, 0, 30, 20);\nfill('black');\ncircle(0, 0, 8);\npop();\n\n// Draw the right eye.\npush();\ntranslate(20, -20);\nellipse(0, 0, 30, 20);\nfill('black');\ncircle(0, 0, 8);\npop();\n\n// End the drawing group.\npop();\n\n// Draw a bug.\nlet x = random(0, 100);\nlet y = random(0, 100);\ntext('\U0001F99F', x, y);\n
\n

In this version, the code to draw each eye is contained between its own\npush() and pop() functions. Doing so makes it\neasier to add details in the correct part of a drawing.

\n

push() and pop() contain the effects of the\nfollowing functions:

\n\n

In WebGL mode, push() and pop() contain the\neffects of a few additional styles:

\n\n" -line: 269 -isConstructor: false -itemtype: method -example: - - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Draw the left circle.\n circle(25, 50, 20);\n\n // Begin the drawing group.\n push();\n\n // Translate the origin to the center.\n translate(50, 50);\n\n // Style the circle.\n strokeWeight(5);\n stroke('royalblue');\n fill('orange');\n\n // Draw the circle.\n circle(0, 0, 20);\n\n // End the drawing group.\n pop();\n\n // Draw the right circle.\n circle(75, 50, 20);\n\n describe(\n 'Three circles drawn in a row on a gray background. The left and right circles are white with thin, black borders. The middle circle is orange with a thick, blue border.'\n );\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Slow the frame rate.\n frameRate(24);\n\n describe('A mosquito buzzes in front of a green frog. The frog follows the mouse as the user moves.');\n}\n\nfunction draw() {\n background(200);\n\n // Begin the drawing group.\n push();\n\n // Translate the origin to the mouse's position.\n translate(mouseX, mouseY);\n\n // Style the face.\n noStroke();\n fill('green');\n\n // Draw a face.\n circle(0, 0, 60);\n\n // Style the eyes.\n fill('white');\n\n // Draw the left eye.\n push();\n translate(-20, -20);\n ellipse(0, 0, 30, 20);\n fill('black');\n circle(0, 0, 8);\n pop();\n\n // Draw the right eye.\n push();\n translate(20, -20);\n ellipse(0, 0, 30, 20);\n fill('black');\n circle(0, 0, 8);\n pop();\n\n // End the drawing group.\n pop();\n\n // Draw a bug.\n let x = random(0, 100);\n let y = random(0, 100);\n text('\U0001F99F', x, y);\n}\n\n
\n\n
\n\n// Click and drag the mouse to view the scene from different angles.\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n\n describe(\n 'Two spheres drawn on a gray background. The sphere on the left is red and lit from the front. The sphere on the right is a blue wireframe.'\n );\n}\n\nfunction draw() {\n background(200);\n\n // Enable orbiting with the mouse.\n orbitControl();\n\n // Draw the red sphere.\n push();\n translate(-25, 0, 0);\n noStroke();\n directionalLight(255, 0, 0, 0, 0, -1);\n sphere(20);\n pop();\n\n // Draw the blue sphere.\n push();\n translate(25, 0, 0);\n strokeWeight(0.3);\n stroke(0, 0, 255);\n noFill();\n sphere(20);\n pop();\n}\n\n
" -class: p5 -chainable: false ---- - - -# push diff --git a/src/content/reference/en/p5 copy/pwinMouseX.mdx b/src/content/reference/en/p5 copy/pwinMouseX.mdx deleted file mode 100644 index cb869aea71..0000000000 --- a/src/content/reference/en/p5 copy/pwinMouseX.mdx +++ /dev/null @@ -1,99 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L545 -title: pwinMouseX -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A Number variable that tracks the mouse's previous horizontal - position - - within the browser.

- -

pwinMouseX keeps track of the mouse's position relative to the - top-left - - corner of the browser window. Its value is - - winMouseX from the previous frame. For - - example, if the mouse was 50 pixels from - - the left edge of the browser during the last frame, then - pwinMouseX will - - be 50.

- -

On a touchscreen device, pwinMouseX will hold the x-coordinate - of the most - - recent touch point. pwinMouseX is reset to the current - - winMouseX value at the start of each - touch - - event.

- -

Note: Use pmouseX to track the mouse’s - previous - - x-coordinate within the canvas.

-line: 545 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Slow the frame rate. - frameRate(10); - - describe('A gray square. A white circle at its center grows larger when the mouse moves horizontally.'); - } - - function draw() { - background(200); - - // Calculate the circle's diameter. - let d = winMouseX - pwinMouseX; - - // Draw the circle. - circle(50, 50, d); - } - -
- -
- - function setup() { - // Create the canvas and set its position. - let cnv = createCanvas(100, 100); - cnv.position(20, 20); - - describe('A gray square with a number at its center. The number changes as the user moves the mouse vertically.'); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display pwinMouseX. - text(pwinMouseX, 50, 50); - } - -
-class: p5 -type: Number ---- - - -# pwinMouseX diff --git a/src/content/reference/en/p5 copy/pwinMouseY.mdx b/src/content/reference/en/p5 copy/pwinMouseY.mdx deleted file mode 100644 index 2f36580a23..0000000000 --- a/src/content/reference/en/p5 copy/pwinMouseY.mdx +++ /dev/null @@ -1,99 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L616 -title: pwinMouseY -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A Number variable that tracks the mouse's previous vertical - position - - within the browser.

- -

pwinMouseY keeps track of the mouse's position relative to the - top-left - - corner of the browser window. Its value is - - winMouseY from the previous frame. For - - example, if the mouse was 50 pixels from - - the top edge of the browser during the last frame, then - pwinMouseY will - - be 50.

- -

On a touchscreen device, pwinMouseY will hold the y-coordinate - of the most - - recent touch point. pwinMouseY is reset to the current - - winMouseY value at the start of each - touch - - event.

- -

Note: Use pmouseY to track the mouse’s - previous - - y-coordinate within the canvas.

-line: 616 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Slow the frame rate. - frameRate(10); - - describe('A gray square. A white circle at its center grows larger when the mouse moves vertically.'); - } - - function draw() { - background(200); - - // Calculate the circle's diameter. - let d = winMouseY - pwinMouseY; - - // Draw the circle. - circle(50, 50, d); - } - -
- -
- - function setup() { - // Create the canvas and set its position. - let cnv = createCanvas(100, 100); - cnv.position(20, 20); - - describe('A gray square with a number at its center. The number changes as the user moves the mouse vertically.'); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display pwinMouseY. - text(pwinMouseY, 50, 50); - } - -
-class: p5 -type: Number ---- - - -# pwinMouseY diff --git a/src/content/reference/en/p5 copy/quad.mdx b/src/content/reference/en/p5 copy/quad.mdx deleted file mode 100644 index fbc09fa0a3..0000000000 --- a/src/content/reference/en/p5 copy/quad.mdx +++ /dev/null @@ -1,233 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L928 -title: quad -module: Shape -submodule: 2D Primitives -file: src/core/shape/2d_primitives.js -description: > -

Draws a quadrilateral (four-sided shape).

- -

Quadrilaterals include rectangles, squares, rhombuses, and trapezoids. The - - first pair of parameters (x1, y1) sets the quad's first point. - The next - - three pairs of parameters set the coordinates for its next three points - - (x2, y2), (x3, y3), and (x4, y4). - Points should be added in either - - clockwise or counter-clockwise order.

- -

The version of quad() with twelve parameters allows the quad - to be drawn - - in 3D space. Doing so requires adding the WEBGL argument to - - createCanvas().

- -

The thirteenth and fourteenth parameters are optional. In WebGL mode, they - - set the number of segments used to draw the quadrilateral in the x- and - - y-directions. They're both 2 by default.

-line: 928 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - quad(20, 20, 80, 20, 80, 80, 20, 80); - - describe('A white square with a black outline drawn on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - quad(20, 30, 80, 30, 80, 70, 20, 70); - - describe('A white rectangle with a black outline drawn on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - quad(50, 62, 86, 50, 50, 38, 14, 50); - - describe('A white rhombus with a black outline drawn on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - quad(20, 50, 80, 30, 80, 70, 20, 70); - - describe('A white trapezoid with a black outline drawn on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - quad(-30, -30, 30, -30, 30, 30, -30, 30); - - describe('A white square with a black outline drawn on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A wavy white surface spins around on gray canvas.'); - } - - function draw() { - background(200); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Draw the quad. - quad(-30, -30, 0, 30, -30, 0, 30, 30, 20, -30, 30, -20); - } - -
-class: p5 -overloads: - - line: 928 - params: - - name: x1 - description: | -

the x-coordinate of the first point.

- type: Number - - name: y1 - description: | -

the y-coordinate of the first point.

- type: Number - - name: x2 - description: | -

the x-coordinate of the second point.

- type: Number - - name: y2 - description: | -

the y-coordinate of the second point.

- type: Number - - name: x3 - description: | -

the x-coordinate of the third point.

- type: Number - - name: y3 - description: | -

the y-coordinate of the third point.

- type: Number - - name: x4 - description: | -

the x-coordinate of the fourth point.

- type: Number - - name: y4 - description: | -

the y-coordinate of the fourth point.

- type: Number - - name: detailX - description: | -

number of segments in the x-direction.

- type: Integer - optional: true - - name: detailY - description: | -

number of segments in the y-direction.

- type: Integer - optional: true - chainable: 1 - - line: 1048 - params: - - name: x1 - description: '' - type: Number - - name: y1 - description: '' - type: Number - - name: z1 - description: | -

the z-coordinate of the first point.

- type: Number - - name: x2 - description: '' - type: Number - - name: y2 - description: '' - type: Number - - name: z2 - description: | -

the z-coordinate of the second point.

- type: Number - - name: x3 - description: '' - type: Number - - name: y3 - description: '' - type: Number - - name: z3 - description: | -

the z-coordinate of the third point.

- type: Number - - name: x4 - description: '' - type: Number - - name: y4 - description: '' - type: Number - - name: z4 - description: | -

the z-coordinate of the fourth point.

- type: Number - - name: detailX - description: '' - type: Integer - optional: true - - name: detailY - description: '' - type: Integer - optional: true - chainable: 1 -chainable: true ---- - - -# quad diff --git a/src/content/reference/en/p5 copy/quadraticVertex.mdx b/src/content/reference/en/p5 copy/quadraticVertex.mdx deleted file mode 100644 index e319e38769..0000000000 --- a/src/content/reference/en/p5 copy/quadraticVertex.mdx +++ /dev/null @@ -1,303 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L1600 -title: quadraticVertex -module: Shape -submodule: Vertex -file: src/core/shape/vertex.js -description: > -

Adds a quadratic Bézier curve segment to a custom shape.

- -

quadraticVertex() adds a curved segment to custom shapes. The - Bézier - - curve segments it creates are similar to those made by the - - bezierVertex() function. - - quadraticVertex() must be called between the - - beginShape() and - - endShape() functions. The curved segment - uses - - the previous vertex as the first anchor point, so there must be at least - - one call to vertex() before - quadraticVertex() can - - be used.

- -

The first two parameters, cx and cy, set the - curve’s control point. - - The control point "pulls" the curve towards its.

- -

The last two parameters, x3, and y3, set the last - anchor point. The - - last anchor point is where the curve ends.

- -

Bézier curves can also be drawn in 3D using WebGL mode. The 3D version of - - bezierVertex() has eight arguments because each point has x-, y-, - and - - z-coordinates.

- -

Note: quadraticVertex() won’t work when an argument is passed - to - - beginShape().

-line: 1600 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the curve. - noFill(); - - // Draw the curve. - beginShape(); - vertex(20, 20); - quadraticVertex(80, 20, 50, 50); - endShape(); - - describe('A black curve drawn on a gray square. The curve starts at the top-left corner and ends at the center.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw the curve. - noFill(); - beginShape(); - vertex(20, 20); - quadraticVertex(80, 20, 50, 50); - endShape(); - - // Draw red lines from the anchor points to the control point. - stroke(255, 0, 0); - line(20, 20, 80, 20); - line(50, 50, 80, 20); - - // Draw the anchor points in black. - strokeWeight(5); - stroke(0); - point(20, 20); - point(50, 50); - - // Draw the control point in red. - stroke(255, 0, 0); - point(80, 20); - - describe('A black curve that starts at the top-left corner and ends at the center. Its anchor and control points are marked with dots. Red lines connect both anchor points to the control point.'); - } - -
- -
- - // Click the mouse near the red dot in the top-right corner - // and drag to change the curve's shape. - - let x2 = 80; - let y2 = 20; - let isChanging = false; - - function setup() { - createCanvas(100, 100); - - describe('A black curve that starts at the top-left corner and ends at the center. Its anchor and control points are marked with dots. Red lines connect both anchor points to the control point.'); - } - - function draw() { - background(200); - - // Style the curve. - noFill(); - strokeWeight(1); - stroke(0); - - // Draw the curve. - beginShape(); - vertex(20, 20); - quadraticVertex(x2, y2, 50, 50); - endShape(); - - // Draw red lines from the anchor points to the control point. - stroke(255, 0, 0); - line(20, 20, x2, y2); - line(50, 50, x2, y2); - - // Draw the anchor points in black. - strokeWeight(5); - stroke(0); - point(20, 20); - point(50, 50); - - // Draw the control point in red. - stroke(255, 0, 0); - point(x2, y2); - } - - // Start changing the first control point if the user clicks near it. - function mousePressed() { - if (dist(mouseX, mouseY, x2, y2) < 20) { - isChanging = true; - } - } - - // Stop changing the first control point when the user releases the mouse. - function mouseReleased() { - isChanging = false; - } - - // Update the first control point while the user drags the mouse. - function mouseDragged() { - if (isChanging === true) { - x2 = mouseX; - y2 = mouseY; - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - beginShape(); - - // Add the curved segments. - vertex(20, 20); - quadraticVertex(80, 20, 50, 50); - quadraticVertex(20, 80, 80, 80); - - // Add the straight segments. - vertex(80, 10); - vertex(20, 10); - vertex(20, 20); - - // Stop drawing the shape. - endShape(); - - describe('A white puzzle piece drawn on a gray background.'); - } - -
- -
- - // Click the and drag the mouse to view the scene from a different angle. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white puzzle piece on a dark gray background. When the user clicks and drags the scene, the outline of a second puzzle piece is revealed.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the first puzzle piece. - noStroke(); - fill(255); - - // Draw the first puzzle piece. - beginShape(); - vertex(-30, -30, 0); - quadraticVertex(30, -30, 0, 0, 0, 0); - quadraticVertex(-30, 30, 0, 30, 30, 0); - vertex(30, -40, 0); - vertex(-30, -40, 0); - vertex(-30, -30, 0); - endShape(); - - // Style the second puzzle piece. - stroke(255); - noFill(); - - // Draw the second puzzle piece. - beginShape(); - vertex(-30, -30, -20); - quadraticVertex(30, -30, -20, 0, 0, -20); - quadraticVertex(-30, 30, -20, 30, 30, -20); - vertex(30, -40, -20); - vertex(-30, -40, -20); - vertex(-30, -30, -20); - endShape(); - } - -
-class: p5 -overloads: - - line: 1600 - params: - - name: cx - description: | -

x-coordinate of the control point.

- type: Number - - name: cy - description: | -

y-coordinate of the control point.

- type: Number - - name: x3 - description: | -

x-coordinate of the anchor point.

- type: Number - - name: y3 - description: | -

y-coordinate of the anchor point.

- type: Number - chainable: 1 - - line: 1832 - params: - - name: cx - description: '' - type: Number - - name: cy - description: '' - type: Number - - name: cz - description: | -

z-coordinate of the control point.

- type: Number - - name: x3 - description: '' - type: Number - - name: y3 - description: '' - type: Number - - name: z3 - description: | -

z-coordinate of the anchor point.

- type: Number -chainable: true ---- - - -# quadraticVertex diff --git a/src/content/reference/en/p5 copy/radians.mdx b/src/content/reference/en/p5 copy/radians.mdx deleted file mode 100644 index da0adc1ff7..0000000000 --- a/src/content/reference/en/p5 copy/radians.mdx +++ /dev/null @@ -1,53 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L521 -title: radians -module: Math -submodule: Trigonometry -file: src/math/trigonometry.js -description: | -

Converts an angle measured in degrees to its value in radians.

-

Degrees and radians are both units for measuring angles. There are 360˚ in - one full rotation. A full rotation is 2 × π (about 6.28) radians.

-

The same angle can be expressed in with either unit. For example, 90° is a - quarter of a full rotation. The same angle is 2 × π ÷ 4 - (about 1.57) radians.

-line: 521 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Calculate the angle conversion. - let deg = 45; - let rad = radians(deg); - - // Display the angle conversion. - text(`${deg}˚ = ${round(rad, 3)} rad`, 10, 50); - - describe('The text "45˚ = 0.785 rad".'); - } - -
-class: p5 -params: - - name: degrees - description: | -

degree value to convert to radians.

- type: Number -return: - description: converted angle. - type: Number -chainable: false ---- - - -# radians diff --git a/src/content/reference/en/p5 copy/random.mdx b/src/content/reference/en/p5 copy/random.mdx deleted file mode 100644 index aef8e546e8..0000000000 --- a/src/content/reference/en/p5 copy/random.mdx +++ /dev/null @@ -1,48 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/random.js#L86 -title: random -module: Math -submodule: Random -file: src/math/random.js -description: "

Returns a random number or a random element from an array.

\n

random() follows uniform distribution, which means that all outcomes are\nequally likely. When random() is used to generate numbers, all\nnumbers in the output range are equally likely to be returned. When\nrandom() is used to select elements from an array, all elements are\nequally likely to be chosen.

\n

By default, random() produces different results each time a sketch runs.\nThe randomSeed() function can be used to\ngenerate the same sequence of numbers or choices each time a sketch runs.

\n

The version of random() with no parameters returns a random number from 0\nup to but not including 1.

\n

The version of random() with one parameter works one of two ways. If the\nargument passed is a number, random() returns a random number from 0 up\nto but not including the number. For example, calling random(5) returns\nvalues between 0 and 5. If the argument passed is an array, random()\nreturns a random element from that array. For example, calling\nrandom(['\U0001F981', '\U0001F42F', '\U0001F43B']) returns either a lion, tiger, or bear emoji.

\n

The version of random() with two parameters returns a random number from\na given range. The arguments passed set the range's lower and upper bounds.\nFor example, calling random(-5, 10.2) returns values from -5 up to but\nnot including 10.2.

\n" -line: 86 -isConstructor: false -itemtype: method -example: - - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Get random coordinates between 0 and 100.\n let x = random(0, 100);\n let y = random(0, 100);\n\n // Draw a point.\n strokeWeight(5);\n point(x, y);\n\n describe('A black dot appears in a random position on a gray square.');\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Get random coordinates between 0 and 100.\n let x = random(100);\n let y = random(100);\n\n // Draw the point.\n strokeWeight(5);\n point(x, y);\n\n describe('A black dot appears in a random position on a gray square.');\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Create an array of emoji strings.\n let animals = ['\U0001F981', '\U0001F42F', '\U0001F43B'];\n\n // Choose a random element from the array.\n let choice = random(animals);\n\n // Style the text.\n textAlign(CENTER);\n textSize(20);\n\n // Display the emoji.\n text(choice, 50, 50);\n\n describe('An animal face is displayed at random. Either a lion, tiger, or bear.');\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Slow the frame rate.\n frameRate(5);\n\n describe('A black dot moves around randomly on a gray square.');\n}\n\nfunction draw() {\n background(200);\n\n // Get random coordinates between 0 and 100.\n let x = random(100);\n let y = random(100);\n\n // Draw the point.\n strokeWeight(5);\n point(x, y);\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Slow the frame rate.\n frameRate(5);\n\n describe('A black dot moves around randomly in the middle of a gray square.');\n}\n\nfunction draw() {\n background(200);\n\n // Get random coordinates between 45 and 55.\n let x = random(45, 55);\n let y = random(45, 55);\n\n // Draw the point.\n strokeWeight(5);\n point(x, y);\n}\n\n
\n\n
\n\nlet x = 50;\nlet y = 50;\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n describe('A black dot moves around randomly leaving a trail.');\n}\n\nfunction draw() {\n // Update x and y randomly.\n x += random(-1, 1);\n y += random(-1, 1);\n\n // Draw the point.\n point(x, y);\n}\n\n
" -class: p5 -return: - description: random number. - type: Number -overloads: - - line: 86 - params: - - name: min - description: | -

lower bound (inclusive).

- type: Number - optional: true - - name: max - description: | -

upper bound (exclusive).

- type: Number - optional: true - return: - description: random number. - type: Number - - line: 259 - params: - - name: choices - description: | -

array to choose from.

- type: Array - return: - description: random element from the array. - type: '*' -chainable: false ---- - - -# random diff --git a/src/content/reference/en/p5 copy/randomGaussian.mdx b/src/content/reference/en/p5 copy/randomGaussian.mdx deleted file mode 100644 index 24893f378b..0000000000 --- a/src/content/reference/en/p5 copy/randomGaussian.mdx +++ /dev/null @@ -1,104 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/random.js#L292 -title: randomGaussian -module: Math -submodule: Random -file: src/math/random.js -description: > -

Returns a random number fitting a Gaussian, or normal, distribution.

- -

Normal distributions look like bell curves when plotted. Values from a - - normal distribution cluster around a central value called the mean. The - - cluster's standard deviation describes its spread.

- -

By default, randomGaussian() produces different results each - time a - - sketch runs. The randomSeed() function - can be - - used to generate the same sequence of numbers each time a sketch runs.

- -

There's no minimum or maximum value that randomGaussian() - might return. - - Values far from the mean are very unlikely and values near the mean are - - very likely.

- -

The version of randomGaussian() with no parameters returns - values with a - - mean of 0 and standard deviation of 1.

- -

The version of randomGaussian() with one parameter interprets - the - - argument passed as the mean. The standard deviation is 1.

- -

The version of randomGaussian() with two parameters interprets - the first - - argument passed as the mean and the second as the standard deviation.

-line: 292 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - describe('Three horizontal black lines are filled in randomly. The top line spans entire canvas. The middle line is very short. The bottom line spans two-thirds of the canvas.'); - } - - function draw() { - // Style the circles. - noStroke(); - fill(0, 10); - - // Uniform distribution between 0 and 100. - let x = random(100); - let y = 25; - circle(x, y, 5); - - // Gaussian distribution with a mean of 50 and sd of 1. - x = randomGaussian(50); - y = 50; - circle(x, y, 5); - - // Gaussian distribution with a mean of 50 and sd of 10. - x = randomGaussian(50, 10); - y = 75; - circle(x, y, 5); - } - -
-class: p5 -params: - - name: mean - description: | -

mean.

- type: Number - optional: true - - name: sd - description: | -

standard deviation.

- type: Number - optional: true -return: - description: random number. - type: Number -chainable: false ---- - - -# randomGaussian diff --git a/src/content/reference/en/p5 copy/randomSeed.mdx b/src/content/reference/en/p5 copy/randomSeed.mdx deleted file mode 100644 index dbd1a6ae3d..0000000000 --- a/src/content/reference/en/p5 copy/randomSeed.mdx +++ /dev/null @@ -1,71 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/random.js#L37 -title: randomSeed -module: Math -submodule: Random -file: src/math/random.js -description: > -

Sets the seed value for the random() - and - - randomGaussian() functions.

- -

By default, random() and - - randomGaussian() produce different - - results each time a sketch is run. Calling randomSeed() with a - constant - - argument, such as randomSeed(99), makes these functions produce - the same - - results each time a sketch is run.

-line: 37 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Get random coordinates. - let x = random(0, 100); - let y = random(0, 100); - - // Draw the white circle. - circle(x, y, 10); - - // Set a random seed for consistency. - randomSeed(99); - - // Get random coordinates. - x = random(0, 100); - y = random(0, 100); - - // Draw the black circle. - fill(0); - circle(x, y, 10); - - describe('A white circle appears at a random position. A black circle appears at (27.4, 25.8).'); - } - -
-class: p5 -params: - - name: seed - description: | -

seed value.

- type: Number -chainable: false ---- - - -# randomSeed diff --git a/src/content/reference/en/p5 copy/rect.mdx b/src/content/reference/en/p5 copy/rect.mdx deleted file mode 100644 index 6876ab536d..0000000000 --- a/src/content/reference/en/p5 copy/rect.mdx +++ /dev/null @@ -1,209 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L1091 -title: rect -module: Shape -submodule: 2D Primitives -file: src/core/shape/2d_primitives.js -description: > -

Draws a rectangle.

- -

A rectangle is a four-sided shape defined by the x, - y, w, and h - - parameters. x and y set the location of its top-left - corner. w sets - - its width and h sets its height. Every angle in the rectangle - measures - - 90˚. See rectMode() for other ways to - define - - rectangles.

- -

The version of rect() with five parameters creates a rounded - rectangle. The - - fifth parameter sets the radius for all four corners.

- -

The version of rect() with eight parameters also creates a - rounded - - rectangle. Each of the last four parameters set the radius of a corner. The - - radii start with the top-left corner and move clockwise around the - - rectangle. If any of these parameters are omitted, they are set to the - - value of the last radius that was set.

-line: 1091 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - rect(30, 20, 55, 55); - - describe('A white square with a black outline on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - rect(30, 20, 55, 40); - - describe('A white rectangle with a black outline on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Give all corners a radius of 20. - rect(30, 20, 55, 50, 20); - - describe('A white rectangle with a black outline and round edges on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Give each corner a unique radius. - rect(30, 20, 55, 50, 20, 15, 10, 5); - - describe('A white rectangle with a black outline and round edges of different radii.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - rect(-20, -30, 55, 55); - - describe('A white square with a black outline on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white square spins around on gray canvas.'); - } - - function draw() { - background(200); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Draw the rectangle. - rect(-20, -30, 55, 55); - } - -
-class: p5 -overloads: - - line: 1091 - params: - - name: x - description: | -

x-coordinate of the rectangle.

- type: Number - - name: 'y' - description: | -

y-coordinate of the rectangle.

- type: Number - - name: w - description: | -

width of the rectangle.

- type: Number - - name: h - description: | -

height of the rectangle.

- type: Number - optional: true - - name: tl - description: | -

optional radius of top-left corner.

- type: Number - optional: true - - name: tr - description: | -

optional radius of top-right corner.

- type: Number - optional: true - - name: br - description: | -

optional radius of bottom-right corner.

- type: Number - optional: true - - name: bl - description: | -

optional radius of bottom-left corner.

- type: Number - optional: true - chainable: 1 - - line: 1214 - params: - - name: x - description: '' - type: Number - - name: 'y' - description: '' - type: Number - - name: w - description: '' - type: Number - - name: h - description: '' - type: Number - - name: detailX - description: | -

number of segments in the x-direction (for WebGL mode).

- type: Integer - optional: true - - name: detailY - description: | -

number of segments in the y-direction (for WebGL mode).

- type: Integer - optional: true - chainable: 1 -chainable: true ---- - - -# rect diff --git a/src/content/reference/en/p5 copy/rectMode.mdx b/src/content/reference/en/p5 copy/rectMode.mdx deleted file mode 100644 index 5d444cb16e..0000000000 --- a/src/content/reference/en/p5 copy/rectMode.mdx +++ /dev/null @@ -1,142 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L184 -title: rectMode -module: Shape -submodule: Attributes -file: src/core/shape/attributes.js -description: > -

Changes where rectangles and squares are drawn.

- -

By default, the first two parameters of - - rect() and square(), - - are the x- and y-coordinates of the shape's upper left corner. The next - parameters set - - the shape's width and height. This is the same as calling - - rectMode(CORNER).

- -

rectMode(CORNERS) also uses the first two parameters as the - location of - - one of the corners. The next parameters are the location of the opposite - - corner. This mode only works for rect().

- -

rectMode(CENTER) uses the first two parameters as the x- and - - y-coordinates of the shape's center. The next parameters are its width and - - height.

- -

rectMode(RADIUS) also uses the first two parameters as the x- - and - - y-coordinates of the shape's center. The next parameters are - - half of the shape's width and height.

- -

The argument passed to rectMode() must be written in ALL CAPS - because the - - constants CENTER, RADIUS, CORNER, and - CORNERS are defined this way. - - JavaScript is a case-sensitive language.

-line: 184 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - rectMode(CORNER); - fill(255); - rect(25, 25, 50, 50); - - rectMode(CORNERS); - fill(100); - rect(25, 25, 50, 50); - - describe('A small gray square drawn at the top-left corner of a white square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - rectMode(RADIUS); - fill(255); - rect(50, 50, 30, 30); - - rectMode(CENTER); - fill(100); - rect(50, 50, 30, 30); - - describe('A small gray square drawn at the center of a white square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - rectMode(CORNER); - fill(255); - square(25, 25, 50); - - describe('A white square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - rectMode(RADIUS); - fill(255); - square(50, 50, 30); - - rectMode(CENTER); - fill(100); - square(50, 50, 30); - - describe('A small gray square drawn at the center of a white square.'); - } - -
-class: p5 -params: - - name: mode - description: | -

either CORNER, CORNERS, CENTER, or RADIUS

- type: Constant -chainable: true ---- - - -# rectMode diff --git a/src/content/reference/en/p5 copy/red.mdx b/src/content/reference/en/p5 copy/red.mdx deleted file mode 100644 index 819478b246..0000000000 --- a/src/content/reference/en/p5 copy/red.mdx +++ /dev/null @@ -1,158 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L1279 -title: red -module: Color -submodule: Creating & Reading -file: src/color/creating_reading.js -description: > -

Gets the red value of a color.

- -

red() extracts the red value from a - - p5.Color object, an array of color - components, or - - a CSS color string.

- -

By default, red() returns a color's red value in the range 0 - - to 255. If the colorMode() is set to - RGB, it - - returns the red value in the given range.

-line: 1279 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object. - let c = color(175, 100, 220); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'redValue' to 175. - let redValue = red(c); - - // Draw the right rectangle. - fill(redValue, 0, 0); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is red.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a color array. - let c = [175, 100, 220]; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'redValue' to 175. - let redValue = red(c); - - // Draw the right rectangle. - fill(redValue, 0, 0); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is red.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a CSS color string. - let c = 'rgb(175, 100, 220)'; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'redValue' to 175. - let redValue = red(c); - - // Draw the right rectangle. - fill(redValue, 0, 0); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is red.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use RGB color with values in the range 0-100. - colorMode(RGB, 100); - - // Create a p5.Color object. - let c = color(69, 39, 86); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'redValue' to 69. - let redValue = red(c); - - // Draw the right rectangle. - fill(redValue, 0, 0); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is light purple and the right one is red.'); - } - -
-class: p5 -params: - - name: color - description: | -

p5.Color object, array of - color components, or CSS color string.

- type: 'p5.Color|Number[]|String' -return: - description: the red value. - type: Number -chainable: false ---- - - -# red diff --git a/src/content/reference/en/p5 copy/redraw.mdx b/src/content/reference/en/p5 copy/redraw.mdx deleted file mode 100644 index 6519f322f0..0000000000 --- a/src/content/reference/en/p5 copy/redraw.mdx +++ /dev/null @@ -1,117 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/structure.js#L838 -title: redraw -module: Structure -submodule: Structure -file: src/core/structure.js -description: > -

Runs the code in draw() once.

- -

By default, draw() tries to run 60 times - per - - second. Calling noLoop() stops - - draw() from repeating. Calling - redraw() will - - execute the code in the draw() function a - set - - number of times.

- -

The parameter, n, is optional. If a number is passed, as in - redraw(5), - - then the draw loop will run the given number of times. By default, - n is - - 1.

-line: 838 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Double-click the canvas to move the circle. - - let x = 0; - - function setup() { - createCanvas(100, 100); - - // Turn off the draw loop. - noLoop(); - - describe( - 'A white half-circle on the left edge of a gray square. The circle moves a little to the right when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Draw the circle. - circle(x, 50, 20); - - // Increment x. - x += 5; - } - - // Run the draw loop when the user double-clicks. - function doubleClicked() { - redraw(); - } - -
- -
- - // Double-click the canvas to move the circle. - - let x = 0; - - function setup() { - createCanvas(100, 100); - - // Turn off the draw loop. - noLoop(); - - describe( - 'A white half-circle on the left edge of a gray square. The circle hops to the right when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Draw the circle. - circle(x, 50, 20); - - // Increment x. - x += 5; - } - - // Run the draw loop three times when the user double-clicks. - function doubleClicked() { - redraw(3); - } - -
-class: p5 -params: - - name: 'n' - description: > -

number of times to run draw(). Defaults to - 1.

- type: Integer - optional: true -chainable: false ---- - - -# redraw diff --git a/src/content/reference/en/p5 copy/remove.mdx b/src/content/reference/en/p5 copy/remove.mdx deleted file mode 100644 index 552822f5a3..0000000000 --- a/src/content/reference/en/p5 copy/remove.mdx +++ /dev/null @@ -1,57 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L559 -title: remove -module: Structure -submodule: Structure -file: src/core/main.js -description: > -

Removes the sketch from the web page.

- -

Calling remove() stops the draw loop and removes any HTML - elements - - created by the sketch, including the canvas. A new sketch can be - - created by using the p5() constructor, as in - - new p5().

-line: 559 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Double-click to remove the canvas. - - function setup() { - createCanvas(100, 100); - - describe( - 'A white circle on a gray background. The circle follows the mouse as the user moves. The sketch disappears when the user double-clicks.' - ); - } - - function draw() { - // Paint the background repeatedly. - background(200); - - // Draw circles repeatedly. - circle(mouseX, mouseY, 40); - } - - // Remove the sketch when the user double-clicks. - function doubleClicked() { - remove(); - } - -
-class: p5 -chainable: false ---- - - -# remove diff --git a/src/content/reference/en/p5 copy/removeElements.mdx b/src/content/reference/en/p5 copy/removeElements.mdx deleted file mode 100644 index 51e712026b..0000000000 --- a/src/content/reference/en/p5 copy/removeElements.mdx +++ /dev/null @@ -1,85 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L256 -title: removeElements -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Removes all elements created by p5.js, including any event handlers.

- -

There are two exceptions: - - canvas elements created by createCanvas() - - and p5.Render objects created by - - createGraphics().

-line: 256 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a paragraph element and place - // it in the middle of the canvas. - let p = createP('p5*js'); - p.position(25, 25); - - describe('A gray square with the text "p5*js" written in its center. The text disappears when the mouse is pressed.'); - } - - // Remove all elements when the mouse is pressed. - function mousePressed() { - removeElements(); - } - -
- -
- - let slider; - - function setup() { - createCanvas(100, 100); - - // Create a paragraph element and place - // it at the top of the canvas. - let p = createP('p5*js'); - p.position(25, 25); - - // Create a slider element and place it - // beneath the canvas. - slider = createSlider(0, 255, 200); - slider.position(0, 100); - - describe('A gray square with the text "p5*js" written in its center and a range slider beneath it. The square changes color when the slider is moved. The text and slider disappear when the square is double-clicked.'); - } - - function draw() { - // Use the slider value to change the background color. - let g = slider.value(); - background(g); - } - - // Remove all elements when the mouse is double-clicked. - function doubleClicked() { - removeElements(); - } - -
-class: p5 -chainable: false ---- - - -# removeElements diff --git a/src/content/reference/en/p5 copy/removeItem.mdx b/src/content/reference/en/p5 copy/removeItem.mdx deleted file mode 100644 index ba091b00b4..0000000000 --- a/src/content/reference/en/p5 copy/removeItem.mdx +++ /dev/null @@ -1,97 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/data/local_storage.js#L380 -title: removeItem -module: Data -submodule: LocalStorage -file: src/data/local_storage.js -description: > -

Removes an item from the web browser's local storage.

- -

Web browsers can save small amounts of data using the built-in - - localStorage object. - - Data stored in localStorage can be retrieved at any point, even - after - - refreshing a page or restarting the browser. Data are stored as key-value - - pairs.

- -

storeItem() makes it easy to store - values in - - localStorage and removeItem() makes it easy to - delete them.

- -

The parameter, key, is the name of the value to remove as a - string. For - - example, calling removeItem('size') removes the item with the key - size.

- -

Note: Sensitive data such as passwords or personal information shouldn't be - - stored in localStorage.

-line: 380 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Double-click to remove an item from localStorage. - - function setup() { - createCanvas(100, 100); - - // Store the player's name. - storeItem('name', 'Feist'); - - // Store the player's score. - storeItem('score', 1234); - - describe( - 'The text "Feist: 1234" written in black on a gray background. The text "Feist: null" appears when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(14); - - // Retrieve the name. - let name = getItem('name'); - - // Retrieve the score. - let score = getItem('score'); - - // Display the score. - text(`${name}: ${score}`, 50, 50); - } - - // Remove the word from localStorage when the user double-clicks. - function doubleClicked() { - removeItem('score'); - } - -
-class: p5 -params: - - name: key - description: | -

name of the value to remove.

- type: String -chainable: false ---- - - -# removeItem diff --git a/src/content/reference/en/p5 copy/requestPointerLock.mdx b/src/content/reference/en/p5 copy/requestPointerLock.mdx deleted file mode 100644 index 621ce063ce..0000000000 --- a/src/content/reference/en/p5 copy/requestPointerLock.mdx +++ /dev/null @@ -1,85 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L1880 -title: requestPointerLock -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

Locks the mouse pointer to its current position and makes it invisible.

- -

requestPointerLock() allows the mouse to move forever without - leaving the - - screen. Calling requestPointerLock() locks the values of - - mouseX, mouseY, - - pmouseX, and pmouseY. - - movedX and movedY - - continue updating and can be used to get the distance the mouse moved since - - the last frame was drawn. Calling - - exitPointerLock() resumes - updating the - - mouse system variables.

- -

Note: Most browsers require an input, such as a click, before calling - - requestPointerLock(). It’s recommended to call - requestPointerLock() in - - an event function such as doubleClicked().

-line: 1880 -isConstructor: false -itemtype: method -example: - - |- - -
- - let score = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with the text "Score: X" at its center. The score increases when the user moves the mouse upward. It decreases when the user moves the mouse downward.' - ); - } - - function draw() { - background(200); - - // Update the score. - score -= movedY; - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the score. - text(`Score: ${score}`, 50, 50); - } - - // Lock the pointer when the user double-clicks. - function doubleClicked() { - requestPointerLock(); - } - -
-class: p5 -chainable: false ---- - - -# requestPointerLock diff --git a/src/content/reference/en/p5 copy/resetMatrix.mdx b/src/content/reference/en/p5 copy/resetMatrix.mdx deleted file mode 100644 index af797b49db..0000000000 --- a/src/content/reference/en/p5 copy/resetMatrix.mdx +++ /dev/null @@ -1,52 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L246 -title: resetMatrix -module: Transform -submodule: Transform -file: src/core/transform.js -description: | -

Clears all transformations applied to the coordinate system.

-line: 246 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe( - 'Two circles drawn on a gray background. A blue circle is at the top-left and a red circle is at the bottom-right.' - ); - } - - function draw() { - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Draw a blue circle at the coordinates (25, 25). - fill('blue'); - circle(25, 25, 20); - - // Clear all transformations. - // The origin is now at the top-left corner. - resetMatrix(); - - // Draw a red circle at the coordinates (25, 25). - fill('red'); - circle(25, 25, 20); - } - -
-class: p5 -chainable: true ---- - - -# resetMatrix diff --git a/src/content/reference/en/p5 copy/resetShader.mdx b/src/content/reference/en/p5 copy/resetShader.mdx deleted file mode 100644 index 850ca0773c..0000000000 --- a/src/content/reference/en/p5 copy/resetShader.mdx +++ /dev/null @@ -1,95 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1628 -title: resetShader -module: 3D -submodule: Material -file: src/webgl/material.js -description: | -

Restores the default shaders.

-

resetShader() deactivates any shaders previously applied by - shader().

-

Note: Shaders can only be used in WebGL mode.

-line: 1628 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Create a string with the vertex shader program. - // The vertex shader is called for each vertex. - let vertSrc = ` - attribute vec3 aPosition; - attribute vec2 aTexCoord; - uniform mat4 uProjectionMatrix; - uniform mat4 uModelViewMatrix; - varying vec2 vTexCoord; - - void main() { - vTexCoord = aTexCoord; - vec4 position = vec4(aPosition, 1.0); - gl_Position = uProjectionMatrix * uModelViewMatrix * position; - } - `; - - // Create a string with the fragment shader program. - // The fragment shader is called for each pixel. - let fragSrc = ` - precision mediump float; - varying vec2 vTexCoord; - - void main() { - vec2 uv = vTexCoord; - vec3 color = vec3(uv.x, uv.y, min(uv.x + uv.y, 1.0)); - gl_FragColor = vec4(color, 1.0); - } - `; - - let myShader; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Shader object. - myShader = createShader(vertSrc, fragSrc); - - describe( - 'Two rotating cubes on a gray background. The left one has a blue-purple gradient on each face. The right one is red.' - ); - } - - function draw() { - background(200); - - // Draw a box using the p5.Shader. - // shader() sets the active shader to myShader. - shader(myShader); - push(); - translate(-25, 0, 0); - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - box(width / 4); - pop(); - - // Draw a box using the default fill shader. - // resetShader() restores the default fill shader. - resetShader(); - fill(255, 0, 0); - push(); - translate(25, 0, 0); - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - box(width / 4); - pop(); - } - -
-class: p5 -chainable: true ---- - - -# resetShader diff --git a/src/content/reference/en/p5 copy/resizeCanvas.mdx b/src/content/reference/en/p5 copy/resizeCanvas.mdx deleted file mode 100644 index fde0561563..0000000000 --- a/src/content/reference/en/p5 copy/resizeCanvas.mdx +++ /dev/null @@ -1,133 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/rendering.js#L221 -title: resizeCanvas -module: Rendering -submodule: Rendering -file: src/core/rendering.js -description: > -

Resizes the canvas to a given width and height.

- -

resizeCanvas() immediately clears the canvas and calls - - redraw(). It's common to call - resizeCanvas() - - within the body of windowResized() - like - - so:

- -
function windowResized() {
-    resizeCanvas(windowWidth, windowHeight);
-  }
-
-  
- -

The first two parameters, width and height, set - the dimensions of the - - canvas. They also the values of the width - and - - height system variables. For example, - calling - - resizeCanvas(300, 500) resizes the canvas to 300×500 pixels, then - sets - - width to 300 and - - height 500.

- -

The third parameter, noRedraw, is optional. If - true is passed, as in - - resizeCanvas(300, 500, true), then the canvas will be canvas to - 300×500 - - pixels but the redraw() function won't be - called - - immediately. By default, redraw() is - called - - immediately when resizeCanvas() finishes executing.

-line: 221 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Double-click to resize the canvas. - - function setup() { - createCanvas(100, 100); - - describe( - 'A white circle drawn on a gray background. The canvas shrinks by half the first time the user double-clicks.' - ); - } - - function draw() { - background(180); - - // Draw a circle at the center of the canvas. - circle(width / 2, height / 2, 20); - } - - // Resize the canvas when the user double-clicks. - function doubleClicked() { - resizeCanvas(50, 50); - } - -
- -
- - // Resize the web browser to change the canvas size. - - function setup() { - createCanvas(windowWidth, windowHeight); - - describe('A white circle drawn on a gray background.'); - } - - function draw() { - background(180); - - // Draw a circle at the center of the canvas. - circle(width / 2, height / 2, 20); - } - - // Always resize the canvas to fill the browser window. - function windowResized() { - resizeCanvas(windowWidth, windowHeight); - } - -
-class: p5 -params: - - name: width - description: | -

width of the canvas.

- type: Number - - name: height - description: | -

height of the canvas.

- type: Number - - name: noRedraw - description: | -

whether to delay calling - redraw(). Defaults - to false.

- type: Boolean - optional: true -chainable: false ---- - - -# resizeCanvas diff --git a/src/content/reference/en/p5 copy/reverse.mdx b/src/content/reference/en/p5 copy/reverse.mdx deleted file mode 100644 index bf7a6571ac..0000000000 --- a/src/content/reference/en/p5 copy/reverse.mdx +++ /dev/null @@ -1,43 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L141 -title: reverse -module: Data -submodule: Array Functions -file: src/utilities/array_functions.js -description: | -

Reverses the order of an array, maps to Array.reverse()

-line: 141 -deprecated: >- - Use array.reverse() - instead. -isConstructor: false -itemtype: method -example: - - |- - -
- function setup() { - let myArray = ['A', 'B', 'C']; - print(myArray); // ['A','B','C'] - - reverse(myArray); - print(myArray); // ['C','B','A'] - } -
-class: p5 -params: - - name: list - description: | -

Array to reverse

- type: Array -return: - description: the reversed list - type: Array -chainable: false ---- - - -# reverse diff --git a/src/content/reference/en/p5 copy/rotate.mdx b/src/content/reference/en/p5 copy/rotate.mdx deleted file mode 100644 index bbb4f8e5f8..0000000000 --- a/src/content/reference/en/p5 copy/rotate.mdx +++ /dev/null @@ -1,226 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L289 -title: rotate -module: Transform -submodule: Transform -file: src/core/transform.js -description: > -

Rotates the coordinate system.

- -

By default, the positive x-axis points to the right and the positive y-axis - - points downward. The rotate() function changes this orientation - by - - rotating the coordinate system about the origin. Everything drawn after - - rotate() is called will appear to be rotated.

- -

The first parameter, angle, is the amount to rotate. For - example, calling - - rotate(1) rotates the coordinate system clockwise 1 radian which - is - - nearly 57˚. rotate() interprets angle values using the current - - angleMode().

- -

The second parameter, axis, is optional. It's used to orient - 3D rotations - - in WebGL mode. If a p5.Vector is passed, - as in - - rotate(QUARTER_PI, myVector), then the coordinate system will - rotate - - QUARTER_PI radians about myVector. If an array of - vector components is - - passed, as in rotate(QUARTER_PI, [1, 0, 0]), then the coordinate - system - - will rotate QUARTER_PI radians about a vector with the components - - [1, 0, 0].

- -

By default, transformations accumulate. For example, calling - rotate(1) - - twice has the same effect as calling rotate(2) once. The - - push() and pop() functions - - can be used to isolate transformations within distinct drawing groups.

- -

Note: Transformations are reset at the beginning of the draw loop. Calling - - rotate(1) inside the draw() - function won't cause - - shapes to spin.

-line: 289 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe( - "A white rectangle on a gray background. The rectangle's long axis runs from top-left to bottom-right." - ); - } - - function draw() { - background(200); - - // Rotate the coordinate system 1/8 turn. - rotate(QUARTER_PI); - - // Draw a rectangle at coordinates (50, 0). - rect(50, 0, 40, 20); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - "A white rectangle on a gray background. The rectangle's long axis runs from top-left to bottom-right." - ); - } - - function draw() { - background(200); - - // Rotate the coordinate system 1/16 turn. - rotate(QUARTER_PI / 2); - - // Rotate the coordinate system another 1/16 turn. - rotate(QUARTER_PI / 2); - - // Draw a rectangle at coordinates (50, 0). - rect(50, 0, 40, 20); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Use degrees. - angleMode(DEGREES); - - describe( - "A white rectangle on a gray background. The rectangle's long axis runs from top-left to bottom-right." - ); - } - - function draw() { - background(200); - - // Rotate the coordinate system 1/8 turn. - rotate(45); - - // Draw a rectangle at coordinates (50, 0). - rect(50, 0, 40, 20); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - 'A white rectangle on a gray background. The rectangle rotates slowly about the top-left corner. It disappears and reappears periodically.' - ); - } - - function draw() { - background(200); - - // Rotate the coordinate system a little more each frame. - let angle = frameCount * 0.01; - rotate(angle); - - // Draw a rectangle at coordinates (50, 0). - rect(50, 0, 40, 20); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe("A cube on a gray background. The cube's front face points to the top-right."); - } - - function draw() { - background(200); - - // Rotate the coordinate system 1/8 turn about - // the axis [1, 1, 0]. - let axis = createVector(1, 1, 0); - rotate(QUARTER_PI, axis); - - // Draw a box. - box(); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe("A cube on a gray background. The cube's front face points to the top-right."); - } - - function draw() { - background(200); - - // Rotate the coordinate system 1/8 turn about - // the axis [1, 1, 0]. - let axis = [1, 1, 0]; - rotate(QUARTER_PI, axis); - - // Draw a box. - box(); - } - -
-class: p5 -params: - - name: angle - description: > -

angle of rotation in the current angleMode().

- type: Number - - name: axis - description: | -

axis to rotate about in 3D.

- type: 'p5.Vector|Number[]' - optional: true -chainable: true ---- - - -# rotate diff --git a/src/content/reference/en/p5 copy/rotateX.mdx b/src/content/reference/en/p5 copy/rotateX.mdx deleted file mode 100644 index c519976bce..0000000000 --- a/src/content/reference/en/p5 copy/rotateX.mdx +++ /dev/null @@ -1,161 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L470 -title: rotateX -module: Transform -submodule: Transform -file: src/core/transform.js -description: > -

Rotates the coordinate system about the x-axis in WebGL mode.

- -

The parameter, angle, is the amount to rotate. For example, - calling - - rotateX(1) rotates the coordinate system about the x-axis by 1 - radian. - - rotateX() interprets angle values using the current - - angleMode().

- -

By default, transformations accumulate. For example, calling - rotateX(1) - - twice has the same effect as calling rotateX(2) once. The - - push() and pop() functions - - can be used to isolate transformations within distinct drawing groups.

- -

Note: Transformations are reset at the beginning of the draw loop. Calling - - rotateX(1) inside the draw() - function won't cause - - shapes to spin.

-line: 470 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system 1/8 turn. - rotateX(QUARTER_PI); - - // Draw a box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system 1/16 turn. - rotateX(QUARTER_PI / 2); - - // Rotate the coordinate system 1/16 turn. - rotateX(QUARTER_PI / 2); - - // Draw a box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - // Use degrees. - angleMode(DEGREES); - - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system 1/8 turn. - rotateX(45); - - // Draw a box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube rotates slowly against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system a little more each frame. - let angle = frameCount * 0.01; - rotateX(angle); - - // Draw a box. - box(); - } - -
-class: p5 -params: - - name: angle - description: > -

angle of rotation in the current angleMode().

- type: Number -chainable: true ---- - - -# rotateX diff --git a/src/content/reference/en/p5 copy/rotateY.mdx b/src/content/reference/en/p5 copy/rotateY.mdx deleted file mode 100644 index c7976c5a44..0000000000 --- a/src/content/reference/en/p5 copy/rotateY.mdx +++ /dev/null @@ -1,161 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L606 -title: rotateY -module: Transform -submodule: Transform -file: src/core/transform.js -description: > -

Rotates the coordinate system about the y-axis in WebGL mode.

- -

The parameter, angle, is the amount to rotate. For example, - calling - - rotateY(1) rotates the coordinate system about the y-axis by 1 - radian. - - rotateY() interprets angle values using the current - - angleMode().

- -

By default, transformations accumulate. For example, calling - rotateY(1) - - twice has the same effect as calling rotateY(2) once. The - - push() and pop() functions - - can be used to isolate transformations within distinct drawing groups.

- -

Note: Transformations are reset at the beginning of the draw loop. Calling - - rotateY(1) inside the draw() - function won't cause - - shapes to spin.

-line: 606 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system 1/8 turn. - rotateY(QUARTER_PI); - - // Draw a box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system 1/16 turn. - rotateY(QUARTER_PI / 2); - - // Rotate the coordinate system 1/16 turn. - rotateY(QUARTER_PI / 2); - - // Draw a box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - // Use degrees. - angleMode(DEGREES); - - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system 1/8 turn. - rotateY(45); - - // Draw a box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube rotates slowly against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system a little more each frame. - let angle = frameCount * 0.01; - rotateY(angle); - - // Draw a box. - box(); - } - -
-class: p5 -params: - - name: angle - description: > -

angle of rotation in the current angleMode().

- type: Number -chainable: true ---- - - -# rotateY diff --git a/src/content/reference/en/p5 copy/rotateZ.mdx b/src/content/reference/en/p5 copy/rotateZ.mdx deleted file mode 100644 index 317bd7fe88..0000000000 --- a/src/content/reference/en/p5 copy/rotateZ.mdx +++ /dev/null @@ -1,161 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L742 -title: rotateZ -module: Transform -submodule: Transform -file: src/core/transform.js -description: > -

Rotates the coordinate system about the z-axis in WebGL mode.

- -

The parameter, angle, is the amount to rotate. For example, - calling - - rotateZ(1) rotates the coordinate system about the z-axis by 1 - radian. - - rotateZ() interprets angle values using the current - - angleMode().

- -

By default, transformations accumulate. For example, calling - rotateZ(1) - - twice has the same effect as calling rotateZ(2) once. The - - push() and pop() functions - - can be used to isolate transformations within distinct drawing groups.

- -

Note: Transformations are reset at the beginning of the draw loop. Calling - - rotateZ(1) inside the draw() - function won't cause - - shapes to spin.

-line: 742 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system 1/8 turn. - rotateZ(QUARTER_PI); - - // Draw a box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system 1/16 turn. - rotateZ(QUARTER_PI / 2); - - // Rotate the coordinate system 1/16 turn. - rotateZ(QUARTER_PI / 2); - - // Draw a box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - // Use degrees. - angleMode(DEGREES); - - describe('A white cube on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system 1/8 turn. - rotateZ(45); - - // Draw a box. - box(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white cube rotates slowly against a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Rotate the coordinate system a little more each frame. - let angle = frameCount * 0.01; - rotateZ(angle); - - // Draw a box. - box(); - } - -
-class: p5 -params: - - name: angle - description: > -

angle of rotation in the current angleMode().

- type: Number -chainable: true ---- - - -# rotateZ diff --git a/src/content/reference/en/p5 copy/rotationX.mdx b/src/content/reference/en/p5 copy/rotationX.mdx deleted file mode 100644 index 98dfd287dc..0000000000 --- a/src/content/reference/en/p5 copy/rotationX.mdx +++ /dev/null @@ -1,45 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L131 -title: rotationX -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: | -

The system variable rotationX always contains the rotation of the - device along the x axis. If the sketch - angleMode() is set to DEGREES, the value will be -180 to 180. If - it is set to RADIANS, the value will be -PI to PI.

-

Note: The order the rotations are called is important, ie. if used - together, it must be called in the order Z-X-Y or there might be - unexpected behaviour.

-line: 131 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - } - - function draw() { - background(200); - //rotateZ(radians(rotationZ)); - rotateX(radians(rotationX)); - //rotateY(radians(rotationY)); - box(200, 200, 200); - describe(`red horizontal line right, green vertical line bottom. - black background.`); - } - -
-class: p5 -type: Number ---- - - -# rotationX diff --git a/src/content/reference/en/p5 copy/rotationY.mdx b/src/content/reference/en/p5 copy/rotationY.mdx deleted file mode 100644 index f06a033bb7..0000000000 --- a/src/content/reference/en/p5 copy/rotationY.mdx +++ /dev/null @@ -1,45 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L164 -title: rotationY -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: | -

The system variable rotationY always contains the rotation of the - device along the y axis. If the sketch - angleMode() is set to DEGREES, the value will be -90 to 90. If - it is set to RADIANS, the value will be -PI/2 to PI/2.

-

Note: The order the rotations are called is important, ie. if used - together, it must be called in the order Z-X-Y or there might be - unexpected behaviour.

-line: 164 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - } - - function draw() { - background(200); - //rotateZ(radians(rotationZ)); - //rotateX(radians(rotationX)); - rotateY(radians(rotationY)); - box(200, 200, 200); - describe(`red horizontal line right, green vertical line bottom. - black background.`); - } - -
-class: p5 -type: Number ---- - - -# rotationY diff --git a/src/content/reference/en/p5 copy/rotationZ.mdx b/src/content/reference/en/p5 copy/rotationZ.mdx deleted file mode 100644 index 47d6d965aa..0000000000 --- a/src/content/reference/en/p5 copy/rotationZ.mdx +++ /dev/null @@ -1,47 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L197 -title: rotationZ -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: | -

The system variable rotationZ always contains the rotation of the - device along the z axis. If the sketch - angleMode() is set to DEGREES, the value will be 0 to 360. If - it is set to RADIANS, the value will be 0 to 2*PI.

-

Unlike rotationX and rotationY, this variable is available for devices - with a built-in compass only.

-

Note: The order the rotations are called is important, ie. if used - together, it must be called in the order Z-X-Y or there might be - unexpected behaviour.

-line: 197 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - } - - function draw() { - background(200); - rotateZ(radians(rotationZ)); - //rotateX(radians(rotationX)); - //rotateY(radians(rotationY)); - box(200, 200, 200); - describe(`red horizontal line right, green vertical line bottom. - black background.`); - } - -
-class: p5 -type: Number ---- - - -# rotationZ diff --git a/src/content/reference/en/p5 copy/round.mdx b/src/content/reference/en/p5 copy/round.mdx deleted file mode 100644 index 3f6efea6eb..0000000000 --- a/src/content/reference/en/p5 copy/round.mdx +++ /dev/null @@ -1,88 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L861 -title: round -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Calculates the integer closest to a number.

- -

For example, round(133.8) returns the value 134.

- -

The second parameter, decimals, is optional. It sets the - number of - - decimal places to use when rounding. For example, round(12.34, 1) - returns - - 12.3. decimals is 0 by default.

-line: 861 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Round a number. - let x = round(4.2); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the rounded number. - text(x, 50, 50); - - describe('The number 4 written in middle of the canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Round a number to 2 decimal places. - let x = round(12.782383, 2); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the rounded number. - text(x, 50, 50); - - describe('The number 12.78 written in middle of canvas.'); - } - -
-class: p5 -params: - - name: 'n' - description: | -

number to round.

- type: Number - - name: decimals - description: | -

number of decimal places to round to, default is 0.

- type: Number - optional: true -return: - description: rounded number. - type: Integer -chainable: false ---- - - -# round diff --git a/src/content/reference/en/p5 copy/sampleRate.mdx b/src/content/reference/en/p5 copy/sampleRate.mdx deleted file mode 100644 index 3608ee22be..0000000000 --- a/src/content/reference/en/p5 copy/sampleRate.mdx +++ /dev/null @@ -1,26 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L811 -title: sampleRate -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: | -

Returns a number representing the sample rate, in samples per second, - of all sound objects in this audio context. It is determined by the - sampling rate of your operating system's sound card, and it is not - currently possile to change. - It is often 44100, or twice the range of human hearing.

-line: 811 -isConstructor: false -itemtype: method -class: p5 -return: - description: samplerate samples per second - type: Number -chainable: false ---- - - -# sampleRate diff --git a/src/content/reference/en/p5 copy/saturation.mdx b/src/content/reference/en/p5 copy/saturation.mdx deleted file mode 100644 index 7552fe927d..0000000000 --- a/src/content/reference/en/p5 copy/saturation.mdx +++ /dev/null @@ -1,201 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/creating_reading.js#L1415 -title: saturation -module: Color -submodule: Creating & Reading -file: src/color/creating_reading.js -description: > -

Gets the saturation value of a color.

- -

saturation() extracts the saturation value from a - - p5.Color object, an array of color - components, or - - a CSS color string.

- -

Saturation is scaled differently in HSB and HSL. By default, - saturation() - - returns a color's HSL saturation in the range 0 to 100. If the - - colorMode() is set to HSB or HSL, it - returns the - - saturation value in the given mode.

-line: 1415 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(50); - - // Use HSB color. - colorMode(HSB); - - // Create a p5.Color object. - let c = color(0, 50, 100); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'satValue' to 50. - let satValue = saturation(c); - - // Draw the right rectangle. - fill(satValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is dark gray.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(50); - - // Use HSB color. - colorMode(HSB); - - // Create a color array. - let c = [0, 50, 100]; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'satValue' to 100. - let satValue = saturation(c); - - // Draw the right rectangle. - fill(satValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is gray.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(50); - - // Use HSB color. - colorMode(HSB); - - // Create a CSS color string. - let c = 'rgb(255, 128, 128)'; - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'satValue' to 100. - let satValue = saturation(c); - - // Draw the right rectangle. - fill(satValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is gray.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(50); - - // Use HSL color. - colorMode(HSL); - - // Create a p5.Color object. - let c = color(0, 100, 75); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'satValue' to 100. - let satValue = saturation(c); - - // Draw the right rectangle. - fill(satValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is white.'); - } - -
- - |- - -
- - function setup() { - createCanvas(100, 100); - - background(50); - - // Use HSL color with values in the range 0-255. - colorMode(HSL, 255); - - // Create a p5.Color object. - let c = color(0, 255, 191.5); - - // Draw the left rectangle. - noStroke(); - fill(c); - rect(15, 15, 35, 70); - - // Set 'satValue' to 255. - let satValue = saturation(c); - - // Draw the right rectangle. - fill(satValue); - rect(50, 15, 35, 70); - - describe('Two rectangles. The left one is salmon pink and the right one is white.'); - } - -
-class: p5 -params: - - name: color - description: | -

p5.Color object, array of - color components, or CSS color string.

- type: 'p5.Color|Number[]|String' -return: - description: the saturation value - type: Number -chainable: false ---- - - -# saturation diff --git a/src/content/reference/en/p5 copy/save.mdx b/src/content/reference/en/p5 copy/save.mdx deleted file mode 100644 index fb8b67cd74..0000000000 --- a/src/content/reference/en/p5 copy/save.mdx +++ /dev/null @@ -1,140 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1835 -title: save -module: IO -submodule: Output -file: src/io/files.js -description: > -

Saves a given element(image, text, json, csv, wav, or html) to the client's - - computer. The first parameter can be a pointer to element we want to save. - - The element can be one of p5.Element,an - Array of - - Strings, an Array of JSON, a JSON object, a p5.Table - - , a p5.Image, or a p5.SoundFile - (requires - - p5.sound). The second parameter is a filename (including extension).The - - third parameter is for options specific to this type of object. This method - - will save a file that fits the given parameters. - - If it is called without specifying an element, by default it will save the - - whole canvas as an image file. You can optionally specify a filename as - - the first parameter in such a case. - - Note that it is not recommended to - - call this method within draw, as it will open a new save dialog on every - - render.

-line: 1835 -isConstructor: false -itemtype: method -example: - - |2- - -
- // Saves the canvas as an image - cnv = createCanvas(300, 300); - save(cnv, 'myCanvas.jpg'); - - // 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.'); -
- -
- let myTable = new p5.Table(); - // Saves table as html file - save(myTable, 'myTable.html'); - - // Comma Separated Values - save(myTable, 'myTable.csv'); - - // Tab Separated Values - save(myTable, 'myTable.tsv'); - - describe(`An example showing how to save a table in formats of - HTML, CSV and TSV.`); -
- -
- let myJSON = { a: 1, b: true }; - - // Saves pretty JSON - save(myJSON, 'my.json'); - - // 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.`); -
-class: p5 -params: - - name: objectOrFilename - description: | -

If filename is provided, will - save canvas as an image with - either png or jpg extension - depending on the filename. - If object is provided, will - save depending on the object - and filename (see examples - above).

- type: Object|String - optional: true - - name: filename - description: | -

If an object is provided as the first - parameter, then the second parameter - indicates the filename, - and should include an appropriate - file extension (see examples above).

- type: String - optional: true - - name: options - description: | -

Additional options depend on - filetype. For example, when saving JSON, - true indicates that the - output will be optimized for filesize, - rather than readability.

- type: Boolean|String - optional: true -chainable: false ---- - - -# save diff --git a/src/content/reference/en/p5 copy/saveCanvas.mdx b/src/content/reference/en/p5 copy/saveCanvas.mdx deleted file mode 100644 index 159bf101ce..0000000000 --- a/src/content/reference/en/p5 copy/saveCanvas.mdx +++ /dev/null @@ -1,166 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/image.js#L153 -title: saveCanvas -module: Image -submodule: Image -file: src/image/image.js -description: > -

Saves the current canvas as an image.

- -

By default, saveCanvas() saves the canvas as a PNG image - called - - untitled.png.

- -

The first parameter, filename, is optional. It's a string that - sets the - - file's name. If a file extension is included, as in - - saveCanvas('drawing.png'), then the image will be saved using - that - - format.

- -

The second parameter, extension, is also optional. It sets the - files format. - - Either 'png', 'webp', or 'jpg' can be - used. For example, saveCanvas('drawing', 'jpg') - - saves the canvas to a file called drawing.jpg.

- -

Note: The browser will either save the file immediately or prompt the user - - with a dialogue window.

-line: 153 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - background(255); - - // Save the canvas to 'untitled.png'. - saveCanvas(); - - describe('A white square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(255); - - // Save the canvas to 'myCanvas.jpg'. - saveCanvas('myCanvas.jpg'); - - describe('A white square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(255); - - // Save the canvas to 'myCanvas.jpg'. - saveCanvas('myCanvas', 'jpg'); - - describe('A white square.'); - } - -
- -
- - function setup() { - let cnv = createCanvas(100, 100); - - background(255); - - // Save the canvas to 'untitled.png'. - saveCanvas(cnv); - - describe('A white square.'); - } - -
- -
- - function setup() { - let cnv = createCanvas(100, 100); - - background(255); - - // Save the canvas to 'myCanvas.jpg'. - saveCanvas(cnv, 'myCanvas.jpg'); - - describe('A white square.'); - } - -
- -
- - function setup() { - let cnv = createCanvas(100, 100); - - background(255); - - // Save the canvas to 'myCanvas.jpg'. - saveCanvas(cnv, 'myCanvas', 'jpg'); - - describe('A white square.'); - } - -
-class: p5 -overloads: - - line: 153 - params: - - name: selectedCanvas - description: | -

reference to a - specific HTML5 canvas element.

- type: p5.Framebuffer|p5.Element|HTMLCanvasElement - - name: filename - description: | -

file name. Defaults to 'untitled'.

- type: String - optional: true - - name: extension - description: > -

file extension, either 'png', 'webp', or 'jpg'. Defaults to - 'png'.

- type: String - optional: true - - line: 267 - params: - - name: filename - description: '' - type: String - optional: true - - name: extension - description: '' - type: String - optional: true -chainable: false ---- - - -# saveCanvas diff --git a/src/content/reference/en/p5 copy/saveFrames.mdx b/src/content/reference/en/p5 copy/saveFrames.mdx deleted file mode 100644 index 72b8d7d987..0000000000 --- a/src/content/reference/en/p5 copy/saveFrames.mdx +++ /dev/null @@ -1,175 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/image.js#L561 -title: saveFrames -module: Image -submodule: Image -file: src/image/image.js -description: > -

Captures a sequence of frames from the canvas that can be saved as - images.

- -

saveFrames() creates an array of frame objects. Each frame is - stored as - - an object with its file type, file name, and image data as a string. For - - example, the first saved frame might have the following properties:

- -

{ ext: 'png', filename: 'frame0', imageData: - 'data:image/octet-stream;base64, abc123' }.

- -

The first parameter, filename, sets the prefix for the file - names. For - - example, setting the prefix to 'frame' would generate the image - files - - frame0.png, frame1.png, and so on.

- -

The second parameter, extension, sets the file type to either - 'png' or - - 'jpg'.

- -

The third parameter, duration, sets the duration to record in - seconds. - - The maximum duration is 15 seconds.

- -

The fourth parameter, framerate, sets the number of frames to - record per - - second. The maximum frame rate value is 22. Limits are placed on - duration - - and framerate to avoid using too much memory. Recording large - canvases - - can easily crash sketches or even web browsers.

- -

The fifth parameter, callback, is optional. If a function is - passed, - - image files won't be saved by default. The callback function can be used - - to process an array containing the data for each captured frame. The array - - of image data contains a sequence of objects with three properties for each - - frame: imageData, filename, and - extension.

- -

Note: Frames are downloaded as individual image files by default.

-line: 561 -isConstructor: false -itemtype: method -example: - - >- - -
- - - - function setup() { - createCanvas(100, 100); - - describe('A square repeatedly changes color from blue to pink.'); - } - - - function draw() { - let r = frameCount % 255; - let g = 50; - let b = 100; - background(r, g, b); - } - - - // Save the frames when the user presses the 's' key. - - function keyPressed() { - if (key === 's') { - saveFrames('frame', 'png', 1, 5); - } - } - - - -
- - -
- - - - function setup() { - createCanvas(100, 100); - - describe('A square repeatedly changes color from blue to pink.'); - } - - - function draw() { - let r = frameCount % 255; - let g = 50; - let b = 100; - background(r, g, b); - } - - - // Print 5 frames when the user presses the mouse. - - function mousePressed() { - saveFrames('frame', 'png', 1, 5, printFrames); - } - - - // Prints an array of objects containing raw image data, filenames, and - extensions. - - function printFrames(frames) { - for (let frame of frames) { - print(frame); - } - } - - - -
-class: p5 -params: - - name: filename - description: | -

prefix of file name.

- type: String - - name: extension - description: | -

file extension, either 'jpg' or 'png'.

- type: String - - name: duration - description: > -

duration in seconds to record. This parameter will be constrained to be - less or equal to 15.

- type: Number - - name: framerate - description: > -

number of frames to save per second. This parameter will be constrained - to be less or equal to 22.

- type: Number - - name: callback - description: | -

callback function that will be executed - to handle the image data. This function - should accept an array as argument. The - array will contain the specified number of - frames of objects. Each object has three - properties: imageData, filename, and extension.

- type: Function(Array) - optional: true -chainable: false ---- - - -# saveFrames diff --git a/src/content/reference/en/p5 copy/saveGif.mdx b/src/content/reference/en/p5 copy/saveGif.mdx deleted file mode 100644 index 9b520993ac..0000000000 --- a/src/content/reference/en/p5 copy/saveGif.mdx +++ /dev/null @@ -1,119 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L204 -title: saveGif -module: Image -submodule: Loading & Displaying -file: src/image/loading_displaying.js -description: > -

Generates a gif from a sketch and saves it to a file.

- -

saveGif() may be called in setup() or at any - - point while a sketch is running.

- -

The first parameter, fileName, sets the gif's file name.

- -

The second parameter, duration, sets the gif's duration in - seconds.

- -

The third parameter, options, is optional. If an object is - passed, - - saveGif() will use its properties to customize the gif. - saveGif() - - recognizes the properties delay, units, - silent, - - notificationDuration, and notificationID.

-line: 204 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A circle drawn in the middle of a gray square. The circle changes color from black to white, then repeats.'); - } - - function draw() { - background(200); - - // Style the circle. - let c = frameCount % 255; - fill(c); - - // Display the circle. - circle(50, 50, 25); - } - - // Save a 5-second gif when the user presses the 's' key. - function keyPressed() { - if (key === 's') { - saveGif('mySketch', 5); - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A circle drawn in the middle of a gray square. The circle changes color from black to white, then repeats.'); - } - - function draw() { - background(200); - - // Style the circle. - let c = frameCount % 255; - fill(c); - - // Display the circle. - circle(50, 50, 25); - } - - // Save a 5-second gif when the user presses the 's' key. - // Wait 1 second after the key press before recording. - function keyPressed() { - if (key === 's') { - saveGif('mySketch', 5, { delay: 1 }); - } - } - -
-class: p5 -params: - - name: filename - description: | -

file name of gif.

- type: String - - name: duration - description: | -

duration in seconds to capture from the sketch.

- type: Number - - name: options - description: | -

an object that can contain five more properties: - delay, a Number specifying how much time to wait before recording; - units, a String that can be either 'seconds' or 'frames'. By default it's 'seconds’; - silent, a Boolean that defines presence of progress notifications. By default it’s false; - notificationDuration, a Number that defines how long in seconds the final notification - will live. By default it's 0, meaning the notification will never be removed; - notificationID, a String that specifies the id of the notification's DOM element. By default it’s 'progressBar’.

- type: Object - optional: true -chainable: false ---- - - -# saveGif diff --git a/src/content/reference/en/p5 copy/saveJSON.mdx b/src/content/reference/en/p5 copy/saveJSON.mdx deleted file mode 100644 index d5e664d0b2..0000000000 --- a/src/content/reference/en/p5 copy/saveJSON.mdx +++ /dev/null @@ -1,170 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L1979 -title: saveJSON -module: IO -submodule: Output -file: src/io/files.js -description: > -

Saves an Object or Array to a JSON file.

- -

JavaScript Object Notation - - (JSON) - - is a standard format for sending data between applications. The format is - - based on JavaScript objects which have keys and values. JSON files store - - data in an object with strings as keys. Values can be strings, numbers, - - Booleans, arrays, null, or other objects.

- -

The first parameter, json, is the data to save. The data can - be an array, - - as in [1, 2, 3], or an object, as in - - { x: 50, y: 50, color: 'deeppink' }.

- -

The second parameter, filename, is a string that sets the - file's name. - - For example, calling saveJSON([1, 2, 3], 'data.json') saves the - array - - [1, 2, 3] to a file called data.json on the user's - computer.

- -

The third parameter, optimize, is optional. If - true is passed, as in - - saveJSON([1, 2, 3], 'data.json', true), then all unneeded - whitespace will - - be removed to reduce the file size.

- -

Note: The browser will either save the file immediately or prompt the user - - with a dialogue window.

-line: 1979 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(12); - - // Display instructions. - text('Double-click to save', 5, 50, 90); - - describe('The text "Double-click to save" written in black on a gray background.'); - } - - // Save the file when the user double-clicks. - function doubleClicked() { - if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { - // Create an array. - let data = [1, 2, 3]; - - // Save the JSON file. - saveJSON(data, 'numbers.json'); - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(12); - - // Display instructions. - text('Double-click to save', 5, 50, 90); - - describe('The text "Double-click to save" written in black on a gray background.'); - } - - // Save the file when the user double-clicks. - function doubleClicked() { - if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { - // Create an object. - let data = { x: mouseX, y: mouseY }; - - // Save the JSON file. - saveJSON(data, 'state.json'); - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(12); - - // Display instructions. - text('Double-click to save', 5, 50, 90); - - describe('The text "Double-click to save" written in black on a gray background.'); - } - - // Save the file when the user double-clicks. - function doubleClicked() { - if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { - // Create an object. - let data = { x: mouseX, y: mouseY }; - - // Save the JSON file and reduce its size. - saveJSON(data, 'state.json', true); - } - } - -
-class: p5 -params: - - name: json - description: | -

data to save.

- type: Array|Object - - name: filename - description: | -

name of the file to be saved.

- type: String - - name: optimize - description: | -

whether to trim unneeded whitespace. Defaults - to true.

- type: Boolean - optional: true -chainable: false ---- - - -# saveJSON diff --git a/src/content/reference/en/p5 copy/saveSound.mdx b/src/content/reference/en/p5 copy/saveSound.mdx deleted file mode 100644 index 3e8e7d0667..0000000000 --- a/src/content/reference/en/p5 copy/saveSound.mdx +++ /dev/null @@ -1,35 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L1145 -title: saveSound -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: > -

Save a p5.SoundFile as a .wav file. The browser will prompt the user - - to download the file to their device. - - For uploading audio to a server, use - - p5.SoundFile.saveBlob.

-line: 1145 -isConstructor: false -itemtype: method -class: p5 -params: - - name: soundFile - description: | -

p5.SoundFile that you wish to save

- type: p5.SoundFile - - name: fileName - description: | -

name of the resulting .wav file.

- type: String -chainable: false ---- - - -# saveSound diff --git a/src/content/reference/en/p5 copy/saveStrings.mdx b/src/content/reference/en/p5 copy/saveStrings.mdx deleted file mode 100644 index 36c6c448a2..0000000000 --- a/src/content/reference/en/p5 copy/saveStrings.mdx +++ /dev/null @@ -1,185 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L2118 -title: saveStrings -module: IO -submodule: Output -file: src/io/files.js -description: > -

Saves an Array of Strings to a file, one per - line.

- -

The first parameter, list, is an array with the strings to - save.

- -

The second parameter, filename, is a string that sets the - file's name. - - For example, calling saveStrings(['0', '01', '011'], 'data.txt') - saves - - the array ['0', '01', '011'] to a file called - data.txt on the user's - - computer.

- -

The third parameter, extension, is optional. If a string is - passed, as in - - saveStrings(['0', '01', '01'], 'data', 'txt')`, the second - parameter will - - be interpreted as the file name and the third parameter as the extension.

- -

The fourth parameter, isCRLF, is also optional, If - true is passed, as - - in saveStrings(['0', '01', '011'], 'data', 'txt', true), then two - - characters, \r\n , will be added to the end of each string to - create new - - lines in the saved file. \r is a carriage return (CR) and - \n is a line - - feed (LF). By default, only \n (line feed) is added to each - string in - - order to create new lines.

- -

Note: The browser will either save the file immediately or prompt the user - - with a dialogue window.

-line: 2118 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(12); - - // Display instructions. - text('Double-click to save', 5, 50, 90); - - describe('The text "Double-click to save" written in black on a gray background.'); - } - - // Save the file when the user double-clicks. - function doubleClicked() { - if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { - // Create an array. - let data = ['0', '01', '011']; - - // Save the text file. - saveStrings(data, 'data.txt'); - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(12); - - // Display instructions. - text('Double-click to save', 5, 50, 90); - - describe('The text "Double-click to save" written in black on a gray background.'); - } - - // Save the file when the user double-clicks. - function doubleClicked() { - if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { - // Create an array. - // ASCII art courtesy Wikipedia: - // https://en.wikipedia.org/wiki/ASCII_art - let data = [' (\\_/) ', "(='.'=)", '(")_(")']; - - // Save the text file. - saveStrings(data, 'cat', 'txt'); - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textAlign(LEFT, CENTER); - textFont('Courier New'); - textSize(12); - - // Display instructions. - text('Double-click to save', 5, 50, 90); - - describe('The text "Double-click to save" written in black on a gray background.'); - } - - // Save the file when the user double-clicks. - function doubleClicked() { - if (mouseX > 0 && mouseX < 100 && mouseY > 0 && mouseY < 100) { - // Create an array. - // +--+ - // / /| - // +--+ + - // | |/ - // +--+ - let data = [' +--+', ' / /|', '+--+ +', '| |/', '+--+']; - - // Save the text file. - // Use CRLF for line endings. - saveStrings(data, 'box', 'txt', true); - } - } - -
-class: p5 -params: - - name: list - description: | -

data to save.

- type: 'String[]' - - name: filename - description: | -

name of file to be saved.

- type: String - - name: extension - description: | -

format to use for the file.

- type: String - optional: true - - name: isCRLF - description: | -

whether to add \r\n to the end of each - string. Defaults to false.

- type: Boolean - optional: true -chainable: false ---- - - -# saveStrings diff --git a/src/content/reference/en/p5 copy/saveTable.mdx b/src/content/reference/en/p5 copy/saveTable.mdx deleted file mode 100644 index dd6e64ea4d..0000000000 --- a/src/content/reference/en/p5 copy/saveTable.mdx +++ /dev/null @@ -1,70 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/io/files.js#L2275 -title: saveTable -module: IO -submodule: Output -file: src/io/files.js -description: > -

Writes the contents of a Table object - to a file. Defaults to a - - text file with comma-separated-values ('csv') but can also - - use tab separation ('tsv'), or generate an HTML table ('html'). - - The file saving process and location of the saved file will - - vary between web browsers.

-line: 2275 -isConstructor: false -itemtype: method -example: - - |- - -
- let table; - - function setup() { - table = new p5.Table(); - - table.addColumn('id'); - table.addColumn('species'); - table.addColumn('name'); - - let newRow = table.addRow(); - newRow.setNum('id', table.getRowCount() - 1); - newRow.setString('species', 'Panthera leo'); - newRow.setString('name', 'Lion'); - - // 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 -
-class: p5 -params: - - name: Table - description: | -

the Table object to save to a file

- type: p5.Table - - name: filename - description: | -

the filename to which the Table should be saved

- type: String - - name: options - description: | -

can be one of "tsv", "csv", or "html"

- type: String - optional: true -chainable: false ---- - - -# saveTable diff --git a/src/content/reference/en/p5 copy/scale.mdx b/src/content/reference/en/p5 copy/scale.mdx deleted file mode 100644 index a459477d80..0000000000 --- a/src/content/reference/en/p5 copy/scale.mdx +++ /dev/null @@ -1,231 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L878 -title: scale -module: Transform -submodule: Transform -file: src/core/transform.js -description: > -

Scales the coordinate system.

- -

By default, shapes are drawn at their original scale. A rectangle that's 50 - - pixels wide appears to take up half the width of a 100 pixel-wide canvas. - - The scale() function can shrink or stretch the coordinate system - so that - - shapes appear at different sizes. There are two ways to call - scale() with - - parameters that set the scale factor(s).

- -

The first way to call scale() uses numbers to set the amount - of scaling. - - The first parameter, s, sets the amount to scale each axis. For - example, - - calling scale(2) stretches the x-, y-, and z-axes by a factor of - 2. The - - next two parameters, y and z, are optional. They set - the amount to - - scale the y- and z-axes. For example, calling scale(2, 0.5, 1) - stretches - - the x-axis by a factor of 2, shrinks the y-axis by a factor of 0.5, and - - leaves the z-axis unchanged.

- -

The second way to call scale() uses a p5.Vector - - object to set the scale factors. For example, calling - scale(myVector) - - uses the x-, y-, and z-components of myVector to set the amount - of - - scaling along the x-, y-, and z-axes. Doing so is the same as calling - - scale(myVector.x, myVector.y, myVector.z).

- -

By default, transformations accumulate. For example, calling - scale(1) - - twice has the same effect as calling scale(2) once. The - - push() and pop() functions - - can be used to isolate transformations within distinct drawing groups.

- -

Note: Transformations are reset at the beginning of the draw loop. Calling - - scale(2) inside the draw() - function won't cause - - shapes to grow continuously.

-line: 878 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe( - 'Two white squares on a gray background. The larger square appears at the top-center. The smaller square appears at the top-left.' - ); - } - - function draw() { - background(200); - - // Draw a square at (30, 20). - square(30, 20, 40); - - // Scale the coordinate system by a factor of 0.5. - scale(0.5); - - // Draw a square at (30, 20). - // It appears at (15, 10) after scaling. - square(30, 20, 40); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A rectangle and a square drawn in white on a gray background.'); - } - - function draw() { - background(200); - - // Draw a square at (30, 20). - square(30, 20, 40); - - // Scale the coordinate system by factors of - // 0.5 along the x-axis and - // 1.3 along the y-axis. - scale(0.5, 1.3); - - // Draw a square at (30, 20). - // It appears as a rectangle at (15, 26) after scaling. - square(30, 20, 40); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A rectangle and a square drawn in white on a gray background.'); - } - - function draw() { - background(200); - - // Draw a square at (30, 20). - square(30, 20, 40); - - // Create a p5.Vector object. - let v = createVector(0.5, 1.3); - - // Scale the coordinate system by factors of - // 0.5 along the x-axis and - // 1.3 along the y-axis. - scale(v); - - // Draw a square at (30, 20). - // It appears as a rectangle at (15, 26) after scaling. - square(30, 20, 40); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'A red box and a blue box drawn on a gray background. The red box appears embedded in the blue box.' - ); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Style the spheres. - noStroke(); - - // Draw the red sphere. - fill('red'); - box(); - - // Scale the coordinate system by factors of - // 0.5 along the x-axis and - // 1.3 along the y-axis and - // 2 along the z-axis. - scale(0.5, 1.3, 2); - - // Draw the blue sphere. - fill('blue'); - box(); - } - -
-class: p5 -overloads: - - line: 878 - params: - - name: s - description: | -

amount to scale along the positive x-axis.

- type: 'Number|p5.Vector|Number[]' - - name: 'y' - description: > -

amount to scale along the positive y-axis. Defaults to - s.

- type: Number - optional: true - - name: z - description: > -

amount to scale along the positive z-axis. Defaults to - y.

- type: Number - optional: true - chainable: 1 - - line: 1039 - params: - - name: scales - description: | -

vector whose components should be used to scale.

- type: 'p5.Vector|Number[]' - chainable: 1 -chainable: true ---- - - -# scale diff --git a/src/content/reference/en/p5 copy/second.mdx b/src/content/reference/en/p5 copy/second.mdx deleted file mode 100644 index e29042801c..0000000000 --- a/src/content/reference/en/p5 copy/second.mdx +++ /dev/null @@ -1,47 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L277 -title: second -module: IO -submodule: Time & Date -file: src/utilities/time_date.js -description: | -

Returns the current second as a number from 0–59.

-line: 277 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Get the current second. - let s = second(); - - // Style the text. - textAlign(LEFT, CENTER); - textSize(12); - textFont('Courier New'); - - // Display the second. - text(`Current second: ${s}`, 10, 50, 80); - - describe(`The text 'Current second: ${s}' written in black on a gray background.`); - } - -
-class: p5 -return: - description: current second between 0 and 59. - type: Integer -chainable: false ---- - - -# second diff --git a/src/content/reference/en/p5 copy/select.mdx b/src/content/reference/en/p5 copy/select.mdx deleted file mode 100644 index 0ace11ab0d..0000000000 --- a/src/content/reference/en/p5 copy/select.mdx +++ /dev/null @@ -1,113 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L21 -title: select -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Searches the page for the first element that matches the given - - CSS selector string.

- -

The selector string can be an ID, class, tag name, or a combination. - - select() returns a p5.Element object if it - - finds a match and null if not.

- -

The second parameter, container, is optional. It specifies a - container to - - search within. container can be CSS selector string, a - - p5.Element object, or an - - HTMLElement object.

-line: 21 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - background(200); - - // Select the canvas by its tag. - let cnv = select('canvas'); - cnv.style('border', '5px deeppink dashed'); - - describe('A gray square with a dashed pink border.'); - } - -
- -
- - function setup() { - let cnv = createCanvas(100, 100); - - // Add a class attribute to the canvas. - cnv.class('pinkborder'); - - background(200); - - // Select the canvas by its class. - cnv = select('.pinkborder'); - - // Style its border. - cnv.style('border', '5px deeppink dashed'); - - describe('A gray square with a dashed pink border.'); - } - -
- -
- - function setup() { - let cnv = createCanvas(100, 100); - - // Set the canvas' ID. - cnv.id('mycanvas'); - - background(200); - - // Select the canvas by its ID. - cnv = select('#mycanvas'); - - // Style its border. - cnv.style('border', '5px deeppink dashed'); - - describe('A gray square with a dashed pink border.'); - } - -
-class: p5 -params: - - name: selectors - description: | -

CSS selector string of element to search for.

- type: String - - name: container - description: | -

CSS selector string, p5.Element, or - HTMLElement to search within.

- type: String|p5.Element|HTMLElement - optional: true -return: - description: p5.Element containing the element. - type: p5.Element|null -chainable: false ---- - - -# select diff --git a/src/content/reference/en/p5 copy/selectAll.mdx b/src/content/reference/en/p5 copy/selectAll.mdx deleted file mode 100644 index ccd1f3329f..0000000000 --- a/src/content/reference/en/p5 copy/selectAll.mdx +++ /dev/null @@ -1,121 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/dom/dom.js#L109 -title: selectAll -module: DOM -submodule: DOM -file: src/dom/dom.js -description: > -

Searches the page for all elements that matches the given - - CSS selector string.

- -

The selector string can be an ID, class, tag name, or a combination. - - selectAll() returns an array of p5.Element - - objects if it finds any matches and an empty array if none are found.

- -

The second parameter, container, is optional. It specifies a - container to - - search within. container can be CSS selector string, a - - p5.Element object, or an - - HTMLElement object.

-line: 109 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Create three buttons. - createButton('1'); - createButton('2'); - createButton('3'); - - // Select the buttons by their tag. - let buttons = selectAll('button'); - - // Position the buttons. - for (let i = 0; i < 3; i += 1) { - buttons[i].position(0, i * 30); - } - - describe('Three buttons stacked vertically. The buttons are labeled, "1", "2", and "3".'); - } - -
- -
- - function setup() { - // Create three buttons and position them. - let b1 = createButton('1'); - b1.position(0, 0); - let b2 = createButton('2'); - b2.position(0, 30); - let b3 = createButton('3'); - b3.position(0, 60); - - // Add a class attribute to each button. - b1.class('btn'); - b2.class('btn btn-pink'); - b3.class('btn'); - - // Select the buttons by their class. - let buttons = selectAll('.btn'); - let pinkButtons = selectAll('.btn-pink'); - - // Style the selected buttons. - buttons.forEach(setFont); - pinkButtons.forEach(setColor); - - describe('Three buttons stacked vertically. The buttons are labeled, "1", "2", and "3". Buttons "1" and "3" are gray. Button "2" is pink.'); - } - - // Set a button's font to Comic Sans MS. - function setFont(btn) { - btn.style('font-family', 'Comic Sans MS'); - } - - // Set a button's background and font color. - function setColor(btn) { - btn.style('background', 'deeppink'); - btn.style('color', 'white'); - } - -
-class: p5 -params: - - name: selectors - description: | -

CSS selector string of element to search for.

- type: String - - name: container - description: | -

CSS selector string, p5.Element, or - HTMLElement to search within.

- type: String|p5.Element|HTMLElement - optional: true -return: - description: >- - array of p5.Elements containing any elements - found. - type: 'p5.Element[]' -chainable: false ---- - - -# selectAll diff --git a/src/content/reference/en/p5 copy/set.mdx b/src/content/reference/en/p5 copy/set.mdx deleted file mode 100644 index caa9e75a66..0000000000 --- a/src/content/reference/en/p5 copy/set.mdx +++ /dev/null @@ -1,157 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L997 -title: set -module: Image -submodule: Pixels -file: src/image/pixels.js -description: > -

Sets the color of a pixel or draws an image to the canvas.

- -

set() is easy to use but it's not as fast as - - pixels. Use pixels - - to set many pixel values.

- -

set() interprets the first two parameters as x- and - y-coordinates. It - - interprets the last parameter as a grayscale value, a [R, G, B, - A] pixel - - array, a p5.Color object, or a - - p5.Image object. If an image is passed, - the first - - two parameters set the coordinates for the image's upper-left corner, - - regardless of the current imageMode().

- -

updatePixels() must be called - after using - - set() for changes to appear.

-line: 997 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Set four pixels to black. - set(30, 20, 0); - set(85, 20, 0); - set(85, 75, 0); - set(30, 75, 0); - - // Update the canvas. - updatePixels(); - - describe('Four black dots arranged in a square drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a p5.Color object. - let black = color(0); - - // Set four pixels to black. - set(30, 20, black); - set(85, 20, black); - set(85, 75, black); - set(30, 75, black); - - // Update the canvas. - updatePixels(); - - describe('Four black dots arranged in a square drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(255); - - // Draw a horizontal color gradient. - for (let x = 0; x < 100; x += 1) { - for (let y = 0; y < 100; y += 1) { - // Calculate the grayscale value. - let c = map(x, 0, 100, 0, 255); - - // Set the pixel using the grayscale value. - set(x, y, c); - } - } - - // Update the canvas. - updatePixels(); - - describe('A horizontal color gradient from black to white.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/rockies.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Use the image to set all pixels. - set(0, 0, img); - - // Update the canvas. - updatePixels(); - - describe('An image of a mountain landscape.'); - } - -
-class: p5 -params: - - name: x - description: | -

x-coordinate of the pixel.

- type: Number - - name: 'y' - description: | -

y-coordinate of the pixel.

- type: Number - - name: c - description: | -

grayscale value | pixel array | - p5.Color object | p5.Image to copy.

- type: 'Number|Number[]|Object' -chainable: false ---- - - -# set diff --git a/src/content/reference/en/p5 copy/setAttributes.mdx b/src/content/reference/en/p5 copy/setAttributes.mdx deleted file mode 100644 index 368bc49c6c..0000000000 --- a/src/content/reference/en/p5 copy/setAttributes.mdx +++ /dev/null @@ -1,163 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.RendererGL.js#L118 -title: setAttributes -module: Rendering -submodule: Rendering -file: src/webgl/p5.RendererGL.js -description: | -

Set attributes for the WebGL Drawing context. - This is a way of adjusting how the WebGL - renderer works to fine-tune the display and performance.

-

Note that this will reinitialize the drawing context - if called after the WebGL canvas is made.

-

If an object is passed as the parameter, all attributes - not declared in the object will be set to defaults.

-

The available attributes are: -
- alpha - indicates if the canvas contains an alpha buffer - default is true

-

depth - indicates whether the drawing buffer has a depth buffer - of at least 16 bits - default is true

-

stencil - indicates whether the drawing buffer has a stencil buffer - of at least 8 bits

-

antialias - indicates whether or not to perform anti-aliasing - default is false (true in Safari)

-

premultipliedAlpha - indicates that the page compositor will assume - the drawing buffer contains colors with pre-multiplied alpha - default is true

-

preserveDrawingBuffer - if true the buffers will not be cleared and - and will preserve their values until cleared or overwritten by author - (note that p5 clears automatically on draw loop) - default is true

-

perPixelLighting - if true, per-pixel lighting will be used in the - lighting shader otherwise per-vertex lighting is used. - default is true.

-

version - either 1 or 2, to specify which WebGL version to ask for. By - default, WebGL 2 will be requested. If WebGL2 is not available, it will - fall back to WebGL 1. You can check what version is used with by looking at - the global webglVersion property.

-line: 118 -isConstructor: false -itemtype: method -alt: a rotating cube with smoother edges -example: - - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - } - - function draw() { - background(255); - push(); - rotateZ(frameCount * 0.02); - rotateX(frameCount * 0.02); - rotateY(frameCount * 0.02); - fill(0, 0, 0); - box(50); - pop(); - } - -
-
- Now with the antialias attribute set to true. -
-
- - function setup() { - setAttributes('antialias', true); - createCanvas(100, 100, WEBGL); - } - - function draw() { - background(255); - push(); - rotateZ(frameCount * 0.02); - rotateX(frameCount * 0.02); - rotateY(frameCount * 0.02); - fill(0, 0, 0); - box(50); - pop(); - } - -
- -
- - // press the mouse button to disable perPixelLighting - function setup() { - createCanvas(100, 100, WEBGL); - noStroke(); - fill(255); - } - - let lights = [ - { c: '#f00', t: 1.12, p: 1.91, r: 0.2 }, - { c: '#0f0', t: 1.21, p: 1.31, r: 0.2 }, - { c: '#00f', t: 1.37, p: 1.57, r: 0.2 }, - { c: '#ff0', t: 1.12, p: 1.91, r: 0.7 }, - { c: '#0ff', t: 1.21, p: 1.31, r: 0.7 }, - { c: '#f0f', t: 1.37, p: 1.57, r: 0.7 } - ]; - - function draw() { - let t = millis() / 1000 + 1000; - background(0); - directionalLight(color('#222'), 1, 1, 1); - - for (let i = 0; i < lights.length; i++) { - let light = lights[i]; - pointLight( - color(light.c), - p5.Vector.fromAngles(t * light.t, t * light.p, width * light.r) - ); - } - - specularMaterial(255); - sphere(width * 0.1); - - rotateX(t * 0.77); - rotateY(t * 0.83); - rotateZ(t * 0.91); - torus(width * 0.3, width * 0.07, 24, 10); - } - - function mousePressed() { - setAttributes('perPixelLighting', false); - noStroke(); - fill(255); - } - function mouseReleased() { - setAttributes('perPixelLighting', true); - noStroke(); - fill(255); - } - -
-class: p5 -overloads: - - line: 118 - params: - - name: key - description: | -

Name of attribute

- type: String - - name: value - description: | -

New value of named attribute

- type: Boolean - - line: 262 - params: - - name: obj - description: | -

object with key-value pairs

- type: Object -chainable: false ---- - - -# setAttributes diff --git a/src/content/reference/en/p5 copy/setBPM.mdx b/src/content/reference/en/p5 copy/setBPM.mdx deleted file mode 100644 index d2e94a6c5d..0000000000 --- a/src/content/reference/en/p5 copy/setBPM.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L9084 -title: setBPM -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: | -

Set the global tempo, in beats per minute, for all - p5.Parts. This method will impact all active p5.Parts.

-line: 9084 -isConstructor: false -itemtype: method -class: p5 -params: - - name: BPM - description: | -

Beats Per Minute

- type: Number - - name: rampTime - description: | -

Seconds from now

- type: Number -chainable: false ---- - - -# setBPM diff --git a/src/content/reference/en/p5 copy/setCamera.mdx b/src/content/reference/en/p5 copy/setCamera.mdx deleted file mode 100644 index bd4727d474..0000000000 --- a/src/content/reference/en/p5 copy/setCamera.mdx +++ /dev/null @@ -1,81 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/p5.Camera.js#L3897 -title: setCamera -module: 3D -submodule: Camera -file: src/webgl/p5.Camera.js -description: > -

Sets the current (active) camera of a 3D sketch.

- -

setCamera() allows for switching between multiple cameras - created with - - createCamera().

- -

Note: setCamera() can only be used in WebGL mode.

-line: 3897 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Double-click to toggle between cameras. - - let cam1; - let cam2; - let usingCam1 = true; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create the first camera. - // Keep its default settings. - cam1 = createCamera(); - - // Create the second camera. - // Place it at the top-left. - // Point it at the origin. - cam2 = createCamera(); - cam2.setPosition(400, -400, 800); - cam2.lookAt(0, 0, 0); - - // Set the current camera to cam1. - setCamera(cam1); - - describe('A white cube on a gray background. The camera toggles between frontal and aerial views when the user double-clicks.'); - } - - function draw() { - background(200); - - // Draw the box. - box(); - } - - // Toggle the current camera when the user double-clicks. - function doubleClicked() { - if (usingCam1 === true) { - setCamera(cam2); - usingCam1 = false; - } else { - setCamera(cam1); - usingCam1 = true; - } - } - -
-class: p5 -params: - - name: cam - description: | -

camera that should be made active.

- type: p5.Camera -chainable: false ---- - - -# setCamera diff --git a/src/content/reference/en/p5 copy/setMoveThreshold.mdx b/src/content/reference/en/p5 copy/setMoveThreshold.mdx deleted file mode 100644 index 3b90fb5f4d..0000000000 --- a/src/content/reference/en/p5 copy/setMoveThreshold.mdx +++ /dev/null @@ -1,59 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L417 -title: setMoveThreshold -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

The setMoveThreshold() - function is used to set the movement threshold for - - the deviceMoved() function. The - default threshold is set to 0.5.

-line: 417 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Run this example on a mobile device - // You will need to move the device incrementally further - // the closer the square's color gets to white in order to change the value. - - let value = 0; - let threshold = 0.5; - function setup() { - setMoveThreshold(threshold); - } - 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; - threshold = threshold + 0.1; - if (value > 255) { - value = 0; - threshold = 30; - } - setMoveThreshold(threshold); - } - -
-class: p5 -params: - - name: value - description: | -

The threshold value

- type: Number -chainable: false ---- - - -# setMoveThreshold diff --git a/src/content/reference/en/p5 copy/setShakeThreshold.mdx b/src/content/reference/en/p5 copy/setShakeThreshold.mdx deleted file mode 100644 index 30af9eadb0..0000000000 --- a/src/content/reference/en/p5 copy/setShakeThreshold.mdx +++ /dev/null @@ -1,59 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L459 -title: setShakeThreshold -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

The setShakeThreshold() - function is used to set the movement threshold for - - the deviceShaken() function. The - default threshold is set to 30.

-line: 459 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Run this example on a mobile device - // You will need to shake the device more firmly - // the closer the box's fill gets to white in order to change the value. - - let value = 0; - let threshold = 30; - function setup() { - setShakeThreshold(threshold); - } - 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; - threshold = threshold + 5; - if (value > 255) { - value = 0; - threshold = 30; - } - setShakeThreshold(threshold); - } - -
-class: p5 -params: - - name: value - description: | -

The threshold value

- type: Number -chainable: false ---- - - -# setShakeThreshold diff --git a/src/content/reference/en/p5 copy/setup.mdx b/src/content/reference/en/p5 copy/setup.mdx deleted file mode 100644 index 6a71ea6a0f..0000000000 --- a/src/content/reference/en/p5 copy/setup.mdx +++ /dev/null @@ -1,111 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/main.js#L87 -title: setup -module: Structure -submodule: Structure -file: src/core/main.js -description: > -

A function that's called once when the sketch begins running.

- -

Declaring the function setup() sets a code block to run once - - automatically when the sketch starts running. It's used to perform - - setup tasks such as creating the canvas and initializing variables:

- -
function setup() {
-    // Code to run once at the start of the sketch.
-  }
-
-  
- -

Code placed in setup() will run once before code placed in - - draw() begins looping. If the - - preload() is declared, then - setup() will - - run immediately after preload() finishes - - loading assets.

- -

Note: setup() doesn’t have to be declared, but it’s common - practice to do so.

-line: 87 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw the circle. - circle(50, 50, 40); - - describe('A white circle on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Paint the background once. - background(200); - - describe( - 'A white circle on a gray background. The circle follows the mouse as the user moves, leaving a trail.' - ); - } - - function draw() { - // Draw circles repeatedly. - circle(mouseX, mouseY, 40); - } - -
- -
- - let img; - - function preload() { - img = loadImage('/assets/bricks.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Draw the image. - image(img, 0, 0); - - describe( - 'A white circle on a brick wall. The circle follows the mouse as the user moves, leaving a trail.' - ); - } - - function draw() { - // Style the circle. - noStroke(); - - // Draw the circle. - circle(mouseX, mouseY, 10); - } - -
-class: p5 -chainable: false ---- - - -# setup diff --git a/src/content/reference/en/p5 copy/shader.mdx b/src/content/reference/en/p5 copy/shader.mdx deleted file mode 100644 index c8213d9261..0000000000 --- a/src/content/reference/en/p5 copy/shader.mdx +++ /dev/null @@ -1,244 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L682 -title: shader -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Sets the p5.Shader object to apply - while drawing.

- -

Shaders are programs that run on the graphics processing unit (GPU). They - - can process many pixels or vertices at the same time, making them fast for - - many graphics tasks. They’re written in a language called - - GLSL - - and run along with the rest of the code in a sketch. - - p5.Shader objects can be created using - the - - createShader() and - - loadShader() functions.

- -

The parameter, s, is the p5.Shader object to - - apply. For example, calling shader(myShader) applies - myShader to - - process each pixel on the canvas. The shader will be used for:

- -
    - -
  • Fills when a texture is enabled if it includes a uniform - sampler2D.
  • - -
  • Fills when lights are enabled if it includes the attribute - aNormal, or if it has any of the following uniforms: - uUseLighting, uAmbientLightCount, - uDirectionalLightCount, uPointLightCount, - uAmbientColor, uDirectionalDiffuseColors, - uDirectionalSpecularColors, uPointLightLocation, - uPointLightDiffuseColors, uPointLightSpecularColors, - uLightingDirection, or uSpecular.
  • - -
  • Fills whenever there are no lights or textures.
  • - -
  • Strokes if it includes the uniform uStrokeWeight.
  • - -
- -

The source code from a p5.Shader - object's - - fragment and vertex shaders will be compiled the first time it's passed to - - shader(). See - - MDN - - for more information about compiling shaders.

- -

Calling resetShader() restores a - sketch’s - - default shaders.

- -

Note: Shaders can only be used in WebGL mode.

-line: 682 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Note: A "uniform" is a global variable within a shader program. - - // Create a string with the vertex shader program. - // The vertex shader is called for each vertex. - let vertSrc = ` - precision highp float; - uniform mat4 uModelViewMatrix; - uniform mat4 uProjectionMatrix; - - attribute vec3 aPosition; - attribute vec2 aTexCoord; - varying vec2 vTexCoord; - - void main() { - vTexCoord = aTexCoord; - vec4 positionVec4 = vec4(aPosition, 1.0); - gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4; - } - `; - - // Create a string with the fragment shader program. - // The fragment shader is called for each pixel. - let fragSrc = ` - precision highp float; - - void main() { - // Set each pixel's RGBA value to yellow. - gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); - } - `; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Shader object. - let shaderProgram = createShader(vertSrc, fragSrc); - - // Apply the p5.Shader object. - shader(shaderProgram); - - // Style the drawing surface. - noStroke(); - - // Add a plane as a drawing surface. - plane(100, 100); - - describe('A yellow square.'); - } - -
- -
- - // Note: A "uniform" is a global variable within a shader program. - - let mandelbrot; - - // Load the shader and create a p5.Shader object. - function preload() { - mandelbrot = loadShader('/assets/shader.vert', '/assets/shader.frag'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - // Use the p5.Shader object. - shader(mandelbrot); - - // Set the shader uniform p to an array. - mandelbrot.setUniform('p', [-0.74364388703, 0.13182590421]); - - describe('A fractal image zooms in and out of focus.'); - } - - function draw() { - // Set the shader uniform r to a value that oscillates between 0 and 2. - mandelbrot.setUniform('r', sin(frameCount * 0.01) + 1); - - // Add a quad as a display surface for the shader. - quad(-1, -1, 1, -1, 1, 1, -1, 1); - } - -
- -
- - // Note: A "uniform" is a global variable within a shader program. - - let redGreen; - let orangeBlue; - let showRedGreen = false; - - // Load the shader and create two separate p5.Shader objects. - function preload() { - redGreen = loadShader('/assets/shader.vert', '/assets/shader-gradient.frag'); - orangeBlue = loadShader('/assets/shader.vert', '/assets/shader-gradient.frag'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - // Initialize the redGreen shader. - shader(redGreen); - - // Set the redGreen shader's center and background color. - redGreen.setUniform('colorCenter', [1.0, 0.0, 0.0]); - redGreen.setUniform('colorBackground', [0.0, 1.0, 0.0]); - - // Initialize the orangeBlue shader. - shader(orangeBlue); - - // Set the orangeBlue shader's center and background color. - orangeBlue.setUniform('colorCenter', [1.0, 0.5, 0.0]); - orangeBlue.setUniform('colorBackground', [0.226, 0.0, 0.615]); - - describe( - 'The scene toggles between two circular gradients when the user double-clicks. An orange and blue gradient vertically, and red and green gradient moves horizontally.' - ); - } - - function draw() { - // Update the offset values for each shader. - // Move orangeBlue vertically. - // Move redGreen horizontally. - orangeBlue.setUniform('offset', [0, sin(frameCount * 0.01) + 1]); - redGreen.setUniform('offset', [sin(frameCount * 0.01), 1]); - - if (showRedGreen === true) { - shader(redGreen); - } else { - shader(orangeBlue); - } - - // Style the drawing surface. - noStroke(); - - // Add a quad as a drawing surface. - quad(-1, -1, 1, -1, 1, 1, -1, 1); - } - - // Toggle between shaders when the user double-clicks. - function doubleClicked() { - showRedGreen = !showRedGreen; - } - -
-class: p5 -params: - - name: s - description: | -

p5.Shader object - to apply.

- type: p5.Shader -chainable: true ---- - - -# shader diff --git a/src/content/reference/en/p5 copy/shearX.mdx b/src/content/reference/en/p5 copy/shearX.mdx deleted file mode 100644 index 244fea83e2..0000000000 --- a/src/content/reference/en/p5 copy/shearX.mdx +++ /dev/null @@ -1,105 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L1069 -title: shearX -module: Transform -submodule: Transform -file: src/core/transform.js -description: > -

Shears the x-axis so that shapes appear skewed.

- -

By default, the x- and y-axes are perpendicular. The shearX() - function - - transforms the coordinate system so that x-coordinates are translated while - - y-coordinates are fixed.

- -

The first parameter, angle, is the amount to shear. For - example, calling - - shearX(1) transforms all x-coordinates using the formula - - x = x + y * tan(angle). shearX() interprets angle - values using the - - current angleMode().

- -

By default, transformations accumulate. For example, calling - - shearX(1) twice has the same effect as calling - shearX(2) once. The - - push() and - - pop() functions can be used to isolate - - transformations within distinct drawing groups.

- -

Note: Transformations are reset at the beginning of the draw loop. Calling - - shearX(1) inside the draw() - function won't - - cause shapes to shear continuously.

-line: 1069 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A white quadrilateral on a gray background.'); - } - - function draw() { - background(200); - - // Shear the coordinate system along the x-axis. - shearX(QUARTER_PI); - - // Draw the square. - square(0, 0, 50); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Use degrees. - angleMode(DEGREES); - - describe('A white quadrilateral on a gray background.'); - } - - function draw() { - background(200); - - // Shear the coordinate system along the x-axis. - shearX(45); - - // Draw the square. - square(0, 0, 50); - } - -
-class: p5 -params: - - name: angle - description: > -

angle to shear by in the current angleMode().

- type: Number -chainable: true ---- - - -# shearX diff --git a/src/content/reference/en/p5 copy/shearY.mdx b/src/content/reference/en/p5 copy/shearY.mdx deleted file mode 100644 index 007a8b4bfa..0000000000 --- a/src/content/reference/en/p5 copy/shearY.mdx +++ /dev/null @@ -1,105 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L1146 -title: shearY -module: Transform -submodule: Transform -file: src/core/transform.js -description: > -

Shears the y-axis so that shapes appear skewed.

- -

By default, the x- and y-axes are perpendicular. The shearY() - function - - transforms the coordinate system so that y-coordinates are translated while - - x-coordinates are fixed.

- -

The first parameter, angle, is the amount to shear. For - example, calling - - shearY(1) transforms all y-coordinates using the formula - - y = y + x * tan(angle). shearY() interprets angle - values using the - - current angleMode().

- -

By default, transformations accumulate. For example, calling - - shearY(1) twice has the same effect as calling - shearY(2) once. The - - push() and - - pop() functions can be used to isolate - - transformations within distinct drawing groups.

- -

Note: Transformations are reset at the beginning of the draw loop. Calling - - shearY(1) inside the draw() - function won't - - cause shapes to shear continuously.

-line: 1146 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A white quadrilateral on a gray background.'); - } - - function draw() { - background(200); - - // Shear the coordinate system along the y-axis. - shearY(QUARTER_PI); - - // Draw the square. - square(0, 0, 50); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Use degrees. - angleMode(DEGREES); - - describe('A white quadrilateral on a gray background.'); - } - - function draw() { - background(200); - - // Shear the coordinate system along the y-axis. - shearY(45); - - // Draw the square. - square(0, 0, 50); - } - -
-class: p5 -params: - - name: angle - description: > -

angle to shear by in the current angleMode().

- type: Number -chainable: true ---- - - -# shearY diff --git a/src/content/reference/en/p5 copy/shininess.mdx b/src/content/reference/en/p5 copy/shininess.mdx deleted file mode 100644 index a093e246c8..0000000000 --- a/src/content/reference/en/p5 copy/shininess.mdx +++ /dev/null @@ -1,86 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2998 -title: shininess -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Sets the amount of gloss ("shininess") of a - - specularMaterial().

- -

Shiny materials focus reflected light more than dull materials. - - shininess() affects the way materials reflect light sources - including - - directionalLight(), - - pointLight(), - - and spotLight().

- -

The parameter, shine, is a number that sets the amount of - shininess. - - shine must be greater than 1, which is its default value.

-line: 2998 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'Two red spheres drawn on a gray background. White light reflects from their surfaces as the mouse moves. The right sphere is shinier than the left sphere.' - ); - } - - function draw() { - background(200); - - // Turn on a red ambient light. - ambientLight(255, 0, 0); - - // Get the mouse's coordinates. - let mx = mouseX - 50; - let my = mouseY - 50; - - // Turn on a white point light that follows the mouse. - pointLight(255, 255, 255, mx, my, 50); - - // Style the sphere. - noStroke(); - - // Add a specular material with a grayscale value. - specularMaterial(255); - - // Draw the left sphere with low shininess. - translate(-25, 0, 0); - shininess(10); - sphere(20); - - // Draw the right sphere with high shininess. - translate(50, 0, 0); - shininess(100); - sphere(20); - } - -
-class: p5 -params: - - name: shine - description: | -

amount of shine.

- type: Number -chainable: true ---- - - -# shininess diff --git a/src/content/reference/en/p5 copy/shorten.mdx b/src/content/reference/en/p5 copy/shorten.mdx deleted file mode 100644 index a1018f7fb8..0000000000 --- a/src/content/reference/en/p5 copy/shorten.mdx +++ /dev/null @@ -1,44 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L161 -title: shorten -module: Data -submodule: Array Functions -file: src/utilities/array_functions.js -description: | -

Decreases an array by one element and returns the shortened array, - maps to Array.pop().

-line: 161 -deprecated: >- - Use array.pop() - instead. -isConstructor: false -itemtype: method -example: - - |- - -
- function setup() { - let myArray = ['A', 'B', 'C']; - print(myArray); // ['A', 'B', 'C'] - let newArray = shorten(myArray); - print(myArray); // ['A','B','C'] - print(newArray); // ['A','B'] - } -
-class: p5 -params: - - name: list - description: | -

Array to shorten

- type: Array -return: - description: shortened Array - type: Array -chainable: false ---- - - -# shorten diff --git a/src/content/reference/en/p5 copy/shuffle.mdx b/src/content/reference/en/p5 copy/shuffle.mdx deleted file mode 100644 index a4ead252ef..0000000000 --- a/src/content/reference/en/p5 copy/shuffle.mdx +++ /dev/null @@ -1,132 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L185 -title: shuffle -module: Data -submodule: Array Functions -file: src/utilities/array_functions.js -description: > -

Shuffles the elements of an array.

- -

The first parameter, array, is the array to be shuffled. For - example, - - calling shuffle(myArray) will shuffle the elements of - myArray. By - - default, the original array won’t be modified. Instead, a copy will be - - created, shuffled, and returned.

- -

The second parameter, modify, is optional. If - true is passed, as in - - shuffle(myArray, true), then the array will be shuffled in place - without - - making a copy.

-line: 185 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of colors. - let colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']; - - // Create a shuffled copy of the array. - let shuffledColors = shuffle(colors); - - // Draw a row of circles using the original array. - for (let i = 0; i < colors.length; i += 1) { - // Calculate the x-coordinate. - let x = (i + 1) * 12.5; - - // Style the circle. - let c = colors[i]; - fill(c); - - // Draw the circle. - circle(x, 33, 10); - } - - // Draw a row of circles using the original array. - for (let i = 0; i < shuffledColors.length; i += 1) { - // Calculate the x-coordinate. - let x = (i + 1) * 12.5; - - // Style the circle. - let c = shuffledColors[i]; - fill(c); - - // Draw the circle. - circle(x, 67, 10); - } - - describe( - 'Two rows of circles on a gray background. The top row follows the color sequence ROYGBIV. The bottom row has all the same colors but they are shuffled.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of colors. - let colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']; - - // Shuffle the array. - shuffle(colors, true); - - // Draw a row of circles using the original array. - for (let i = 0; i < colors.length; i += 1) { - // Calculate the x-coordinate. - let x = (i + 1) * 12.5; - - // Style the circle. - let c = colors[i]; - fill(c); - - // Draw the circle. - circle(x, 50, 10); - } - - describe( - 'A row of colorful circles on a gray background. Their sequence changes each time the sketch runs.' - ); - } - -
-class: p5 -params: - - name: array - description: | -

array to shuffle.

- type: Array - - name: bool - description: > -

if true, shuffle the original array in place. Defaults to - false.

- type: Boolean - optional: true -return: - description: shuffled array. - type: Array -chainable: false ---- - - -# shuffle diff --git a/src/content/reference/en/p5 copy/sin.mdx b/src/content/reference/en/p5 copy/sin.mdx deleted file mode 100644 index 7f0cba972d..0000000000 --- a/src/content/reference/en/p5 copy/sin.mdx +++ /dev/null @@ -1,107 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L363 -title: sin -module: Math -submodule: Trigonometry -file: src/math/trigonometry.js -description: > -

Calculates the sine of an angle.

- -

sin() is useful for many geometric tasks in creative coding. - The values - - returned oscillate between -1 and 1 as the input angle increases. - sin() - - calculates the sine of an angle, using radians by default, or according to - - if angleMode() setting (RADIANS or - DEGREES).

-line: 363 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A white ball on a string oscillates up and down.'); - } - - function draw() { - background(200); - - // Calculate the coordinates. - let x = 50; - let y = 30 * sin(frameCount * 0.05) + 50; - - // Draw the oscillator. - line(50, y, x, y); - circle(x, y, 20); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - describe('A series of black dots form a wave pattern.'); - } - - function draw() { - // Calculate the coordinates. - let x = frameCount; - let y = 30 * sin(x * 0.1) + 50; - - // Draw the point. - point(x, y); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - describe('A series of black dots form an infinity symbol.'); - } - - function draw() { - // Calculate the coordinates. - let x = 30 * cos(frameCount * 0.1) + 50; - let y = 10 * sin(frameCount * 0.2) + 50; - - // Draw the point. - point(x, y); - } - -
-class: p5 -params: - - name: angle - description: > -

the angle, in radians by default, or according to - - if angleMode() setting (RADIANS or - DEGREES).

- type: Number -return: - description: sine of the angle. - type: Number -chainable: false ---- - - -# sin diff --git a/src/content/reference/en/p5 copy/smooth.mdx b/src/content/reference/en/p5 copy/smooth.mdx deleted file mode 100644 index 2c42bda62c..0000000000 --- a/src/content/reference/en/p5 copy/smooth.mdx +++ /dev/null @@ -1,94 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L303 -title: smooth -module: Shape -submodule: Attributes -file: src/core/shape/attributes.js -description: > -

Draws certain features with smooth (antialiased) edges.

- -

smooth() is active by default. In 2D mode, - - noSmooth() is helpful for scaling up - images - - without blurring. The functions don't affect shapes or fonts.

- -

In WebGL mode, noSmooth() causes all - shapes to - - be drawn with jagged (aliased) edges. The functions don't affect images or - - fonts.

-line: 303 -isConstructor: false -itemtype: method -example: - - |- - -
- - let heart; - - // Load a pixelated heart image from an image data string. - function preload() { - heart = loadImage('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAAXNSR0IArs4c6QAAAEZJREFUGFd9jcsNACAIQ9tB2MeR3YdBMBBq8CIXPi2vBICIiOwkOedatllqWO6Y8yOWoyuNf1GZwgmf+RRG2YXr+xVFmA8HZ9Mx/KGPMtcAAAAASUVORK5CYII='); - } - - function setup() { - createCanvas(100, 100); - - background(50); - - // Antialiased hearts. - image(heart, 10, 10); - image(heart, 20, 10, 16, 16); - image(heart, 40, 10, 32, 32); - - // Aliased hearts. - noSmooth(); - image(heart, 10, 60); - image(heart, 20, 60, 16, 16); - image(heart, 40, 60, 32, 32); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - circle(0, 0, 80); - - describe('A white circle on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - // Disable smoothing. - noSmooth(); - - background(200); - - circle(0, 0, 80); - - describe('A pixelated white circle on a gray background.'); - } - -
-class: p5 -chainable: true ---- - - -# smooth diff --git a/src/content/reference/en/p5 copy/sort.mdx b/src/content/reference/en/p5 copy/sort.mdx deleted file mode 100644 index c2249d926a..0000000000 --- a/src/content/reference/en/p5 copy/sort.mdx +++ /dev/null @@ -1,63 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L300 -title: sort -module: Data -submodule: Array Functions -file: src/utilities/array_functions.js -description: | -

Sorts an array of numbers from smallest to largest, or puts an array of - words in alphabetical order. The original array is not modified; a - re-ordered array is returned. The count parameter states the number of - elements to sort. For example, if there are 12 elements in an array and - count is set to 5, only the first 5 elements in the array will be sorted.

-line: 300 -deprecated: >- - Use array.sort() - instead. -isConstructor: false -itemtype: method -example: - - |- - -
- function setup() { - let words = ['banana', 'apple', 'pear', 'lime']; - print(words); // ['banana', 'apple', 'pear', 'lime'] - let count = 4; // length of array - - words = sort(words, count); - print(words); // ['apple', 'banana', 'lime', 'pear'] - } -
-
- function setup() { - let numbers = [2, 6, 1, 5, 14, 9, 8, 12]; - print(numbers); // [2, 6, 1, 5, 14, 9, 8, 12] - let count = 5; // Less than the length of the array - - numbers = sort(numbers, count); - print(numbers); // [1,2,5,6,14,9,8,12] - } -
-class: p5 -params: - - name: list - description: | -

Array to sort

- type: Array - - name: count - description: | -

number of elements to sort, starting from 0

- type: Integer - optional: true -return: - description: the sorted list - type: Array -chainable: false ---- - - -# sort diff --git a/src/content/reference/en/p5 copy/soundFormats.mdx b/src/content/reference/en/p5 copy/soundFormats.mdx deleted file mode 100644 index 6bc28fe726..0000000000 --- a/src/content/reference/en/p5 copy/soundFormats.mdx +++ /dev/null @@ -1,51 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L925 -title: soundFormats -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: | -

List the SoundFile formats that you will include. LoadSound - will search your directory for these extensions, and will pick - a format that is compatable with the client's web browser. - Here is a free online file - converter.

-line: 925 -isConstructor: false -itemtype: method -example: - - |- - -
- function preload() { - // set the global sound formats - soundFormats('mp3', 'ogg'); - - // load either beatbox.mp3, or .ogg, depending on browser - mySound = loadSound('/assets/beatbox.mp3'); - } - - function setup() { - let cnv = createCanvas(100, 100); - background(220); - text('sound loaded! tap to play', 10, 20, width - 20); - cnv.mousePressed(function() { - mySound.play(); - }); - } -
-class: p5 -params: - - name: formats - description: | -

i.e. 'mp3', 'wav', 'ogg'

- type: String - optional: true - multiple: true -chainable: false ---- - - -# soundFormats diff --git a/src/content/reference/en/p5 copy/soundOut.mdx b/src/content/reference/en/p5 copy/soundOut.mdx deleted file mode 100644 index 2f418a829c..0000000000 --- a/src/content/reference/en/p5 copy/soundOut.mdx +++ /dev/null @@ -1,26 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L782 -title: soundOut -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: > -

p5.soundOut is the p5.sound final output bus. It sends output - to - - the destination of this window's web audio context. It contains - - Web Audio API nodes including a dyanmicsCompressor (.limiter), - - and Gain Nodes for .input and .output.

-line: 782 -isConstructor: false -itemtype: property -class: p5 -type: Object ---- - - -# soundOut diff --git a/src/content/reference/en/p5 copy/specularColor.mdx b/src/content/reference/en/p5 copy/specularColor.mdx deleted file mode 100644 index b23e834ca7..0000000000 --- a/src/content/reference/en/p5 copy/specularColor.mdx +++ /dev/null @@ -1,308 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L205 -title: specularColor -module: 3D -submodule: Lights -file: src/webgl/light.js -description: > -

Sets the specular color for lights.

- -

specularColor() affects lights that bounce off a surface in a - preferred - - direction. These lights include - - directionalLight(), - - pointLight(), and - - spotLight(). The function helps to - create - - highlights on p5.Geometry objects that - are - - styled with specularMaterial(). - If a - - geometry does not use - - specularMaterial(), then - - specularColor() will have no effect.

- -

Note: specularColor() doesn’t affect lights that bounce in all - - directions, including ambientLight() - and - - imageLight().

- -

There are three ways to call specularColor() with optional - parameters to - - set the specular highlight color.

- -

The first way to call specularColor() has two optional - parameters, gray - - and alpha. Grayscale and alpha values between 0 and 255, as in - - specularColor(50) or specularColor(50, 80), can be - passed to set the - - specular highlight color.

- -

The second way to call specularColor() has one optional - parameter, - - color. A p5.Color object, an - array of color - - values, or a CSS color string can be passed to set the specular highlight - - color.

- -

The third way to call specularColor() has four optional - parameters, v1, - - v2, v3, and alpha. RGBA, HSBA, or HSLA - values, as in - - specularColor(255, 0, 0, 80), can be passed to set the specular - highlight - - color. Color values will be interpreted using the current - - colorMode().

-line: 205 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white sphere drawn on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // No specular color. - // Draw the sphere. - sphere(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click the canvas to add a point light. - - let isLit = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A sphere drawn on a gray background. A spotlight starts shining when the user double-clicks.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Style the sphere. - noStroke(); - specularColor(100); - specularMaterial(255, 255, 255); - - // Control the light. - if (isLit === true) { - // Add a white point light from the top-right. - pointLight(255, 255, 255, 30, -20, 40); - } - - // Draw the sphere. - sphere(30); - } - - // Turn on the point light when the user double-clicks. - function doubleClicked() { - isLit = true; - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A black sphere drawn on a gray background. An area on the surface of the sphere is highlighted in blue.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Add a specular highlight. - // Use a p5.Color object. - let c = color('dodgerblue'); - specularColor(c); - - // Add a white point light from the top-right. - pointLight(255, 255, 255, 30, -20, 40); - - // Style the sphere. - noStroke(); - - // Add a white specular material. - specularMaterial(255, 255, 255); - - // Draw the sphere. - sphere(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A black sphere drawn on a gray background. An area on the surface of the sphere is highlighted in blue.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Add a specular highlight. - // Use a CSS color string. - specularColor('#1E90FF'); - - // Add a white point light from the top-right. - pointLight(255, 255, 255, 30, -20, 40); - - // Style the sphere. - noStroke(); - - // Add a white specular material. - specularMaterial(255, 255, 255); - - // Draw the sphere. - sphere(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A black sphere drawn on a gray background. An area on the surface of the sphere is highlighted in blue.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Add a specular highlight. - // Use RGB values. - specularColor(30, 144, 255); - - // Add a white point light from the top-right. - pointLight(255, 255, 255, 30, -20, 40); - - // Style the sphere. - noStroke(); - - // Add a white specular material. - specularMaterial(255, 255, 255); - - // Draw the sphere. - sphere(30); - } - -
-class: p5 -overloads: - - line: 205 - params: - - name: v1 - description: | -

red or hue value in the current - colorMode().

- type: Number - - name: v2 - description: | -

green or saturation value in the current - colorMode().

- type: Number - - name: v3 - description: | -

blue, brightness, or lightness value in the current - colorMode().

- type: Number - chainable: 1 - - line: 423 - params: - - name: gray - description: | -

grayscale value between 0 and 255.

- type: Number - chainable: 1 - - line: 429 - params: - - name: value - description: | -

color as a CSS string.

- type: String - chainable: 1 - - line: 435 - params: - - name: values - description: | -

color as an array of RGBA, HSBA, or HSLA - values.

- type: 'Number[]' - chainable: 1 - - line: 442 - params: - - name: color - description: | -

color as a p5.Color object.

- type: p5.Color - chainable: 1 -chainable: true ---- - - -# specularColor diff --git a/src/content/reference/en/p5 copy/specularMaterial.mdx b/src/content/reference/en/p5 copy/specularMaterial.mdx deleted file mode 100644 index 57e8977cf5..0000000000 --- a/src/content/reference/en/p5 copy/specularMaterial.mdx +++ /dev/null @@ -1,311 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2743 -title: specularMaterial -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Sets the specular color of shapes’ surface material.

- -

The specularMaterial() color sets the components of light - color that - - glossy coats on shapes will reflect. For example, calling - - specularMaterial(255, 255, 0) would cause a shape to reflect red - and - - green light, but not blue light.

- -

Unlike ambientMaterial(), - - specularMaterial() will reflect the full color of light sources - including - - directionalLight(), - - pointLight(), - - and spotLight(). This is what gives it - shapes - - their "shiny" appearance. The material’s shininess can be controlled by the - - shininess() function.

- -

specularMaterial() can be called three ways with different - parameters to - - set the material’s color.

- -

The first way to call specularMaterial() has one parameter, - gray. - - Grayscale values between 0 and 255, as in specularMaterial(50), - can be - - passed to set the material’s color. Higher grayscale values make shapes - - appear brighter.

- -

The second way to call specularMaterial() has one parameter, - color. A - - p5.Color> object, an array of color values, - or a CSS - - color string, as in specularMaterial('magenta'), can be passed to - set the - - material’s color.

- -

The third way to call specularMaterial() has four parameters, - v1, v2, - - v3, and alpha. alpha is optional. RGBA, - HSBA, or HSLA values can be - - passed to set the material’s colors, as in specularMaterial(255, 0, - 0) or - - specularMaterial(255, 0, 0, 30). Color values will be interpreted - using - - the current colorMode().

-line: 2743 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click the canvas to apply a specular material. - - let isGlossy = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A red torus drawn on a gray background. It becomes glossy when the user double-clicks.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on a white point light at the top-right. - pointLight(255, 255, 255, 30, -40, 30); - - // Add a glossy coat if the user has double-clicked. - if (isGlossy === true) { - specularMaterial(255); - shininess(50); - } - - // Style the torus. - noStroke(); - fill(255, 0, 0); - - // Draw the torus. - torus(30); - } - - // Make the torus glossy when the user double-clicks. - function doubleClicked() { - isGlossy = true; - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click the canvas to apply a specular material. - - let isGlossy = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'A red torus drawn on a gray background. It becomes glossy and reflects green light when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on a white point light at the top-right. - pointLight(255, 255, 255, 30, -40, 30); - - // Add a glossy green coat if the user has double-clicked. - if (isGlossy === true) { - specularMaterial(0, 255, 0); - shininess(50); - } - - // Style the torus. - noStroke(); - fill(255, 0, 0); - - // Draw the torus. - torus(30); - } - - // Make the torus glossy when the user double-clicks. - function doubleClicked() { - isGlossy = true; - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click the canvas to apply a specular material. - - let isGlossy = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'A red torus drawn on a gray background. It becomes glossy and reflects green light when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on a white point light at the top-right. - pointLight(255, 255, 255, 30, -40, 30); - - // Add a glossy green coat if the user has double-clicked. - if (isGlossy === true) { - // Create a p5.Color object. - let c = color('green'); - specularMaterial(c); - shininess(50); - } - - // Style the torus. - noStroke(); - fill(255, 0, 0); - - // Draw the torus. - torus(30); - } - - // Make the torus glossy when the user double-clicks. - function doubleClicked() { - isGlossy = true; - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click the canvas to apply a specular material. - - let isGlossy = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'A red torus drawn on a gray background. It becomes glossy and reflects green light when the user double-clicks.' - ); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on a white point light at the top-right. - pointLight(255, 255, 255, 30, -40, 30); - - // Add a glossy green coat if the user has double-clicked. - if (isGlossy === true) { - specularMaterial('#00FF00'); - shininess(50); - } - - // Style the torus. - noStroke(); - fill(255, 0, 0); - - // Draw the torus. - torus(30); - } - - // Make the torus glossy when the user double-clicks. - function doubleClicked() { - isGlossy = true; - } - -
-class: p5 -overloads: - - line: 2743 - params: - - name: gray - description: | -

grayscale value between 0 (black) and 255 (white).

- type: Number - - name: alpha - description: | -

alpha value in the current current - colorMode().

- type: Number - optional: true - chainable: 1 - - line: 2966 - params: - - name: v1 - description: | -

red or hue value in - the current colorMode().

- type: Number - - name: v2 - description: | -

green or saturation value - in the current colorMode().

- type: Number - - name: v3 - description: | -

blue, brightness, or lightness value - in the current colorMode().

- type: Number - - name: alpha - description: '' - type: Number - optional: true - chainable: 1 - - line: 2978 - params: - - name: color - description: | -

color as a p5.Color object, - an array of color values, or a CSS string.

- type: 'p5.Color|Number[]|String' - chainable: 1 -chainable: true ---- - - -# specularMaterial diff --git a/src/content/reference/en/p5 copy/sphere.mdx b/src/content/reference/en/p5 copy/sphere.mdx deleted file mode 100644 index c2ceca44ad..0000000000 --- a/src/content/reference/en/p5 copy/sphere.mdx +++ /dev/null @@ -1,165 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L1227 -title: sphere -module: Shape -submodule: 3D Primitives -file: src/webgl/3d_primitives.js -description: > -

Draws a sphere.

- -

A sphere is a 3D shape with triangular faces that connect to form a round - - surface. Spheres with few faces look like crystals. Spheres with many faces - - have smooth surfaces and look like balls.

- -

The first parameter, radius, is optional. If a - Number is passed, as in - - sphere(20), it sets the radius of the sphere. By default, - radius is 50.

- -

The second parameter, detailX, is also optional. If a - Number is passed, - - as in sphere(20, 5), it sets the number of triangle subdivisions - to use - - along the x-axis. All 3D shapes are made by connecting triangles to form - - their surfaces. By default, detailX is 24.

- -

The third parameter, detailY, is also optional. If a - Number is passed, - - as in sphere(20, 5, 2), it sets the number of triangle - subdivisions to - - use along the y-axis. All 3D shapes are made by connecting triangles to - - form their surfaces. By default, detailY is 16.

- -

Note: sphere() can only be used in WebGL mode.

-line: 1227 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white sphere on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the sphere. - sphere(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white sphere on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the sphere. - // Set its radius to 30. - sphere(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white sphere on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the sphere. - // Set its radius to 30. - // Set its detailX to 6. - sphere(30, 6); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white sphere on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the sphere. - // Set its radius to 30. - // Set its detailX to 24. - // Set its detailY to 4. - sphere(30, 24, 4); - } - -
-class: p5 -params: - - name: radius - description: | -

radius of the sphere. Defaults to 50.

- type: Number - optional: true - - name: detailX - description: | -

number of triangle subdivisions along the x-axis. Defaults to 24.

- type: Integer - optional: true - - name: detailY - description: | -

number of triangle subdivisions along the y-axis. Defaults to 16.

- type: Integer - optional: true -chainable: true ---- - - -# sphere diff --git a/src/content/reference/en/p5 copy/splice.mdx b/src/content/reference/en/p5 copy/splice.mdx deleted file mode 100644 index 866bc4ddef..0000000000 --- a/src/content/reference/en/p5 copy/splice.mdx +++ /dev/null @@ -1,58 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L346 -title: splice -module: Data -submodule: Array Functions -file: src/utilities/array_functions.js -description: | -

Inserts a value or an array of values into an existing array. The first - parameter specifies the initial array to be modified, and the second - parameter defines the data to be inserted. The third parameter is an index - value which specifies the array position from which to insert data. - (Remember that array index numbering starts at zero, so the first position - is 0, the second position is 1, and so on.)

-line: 346 -deprecated: >- - Use array.splice() - instead. -isConstructor: false -itemtype: method -example: - - |- - -
- function setup() { - let myArray = [0, 1, 2, 3, 4]; - let insArray = ['A', 'B', 'C']; - print(myArray); // [0, 1, 2, 3, 4] - print(insArray); // ['A','B','C'] - - splice(myArray, insArray, 3); - print(myArray); // [0,1,2,'A','B','C',3,4] - } -
-class: p5 -params: - - name: list - description: | -

Array to splice into

- type: Array - - name: value - description: | -

value to be spliced in

- type: Any - - name: position - description: | -

in the array from which to insert data

- type: Integer -return: - description: the list - type: Array -chainable: false ---- - - -# splice diff --git a/src/content/reference/en/p5 copy/split.mdx b/src/content/reference/en/p5 copy/split.mdx deleted file mode 100644 index 60b7944313..0000000000 --- a/src/content/reference/en/p5 copy/split.mdx +++ /dev/null @@ -1,87 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L690 -title: split -module: Data -submodule: String Functions -file: src/utilities/string_functions.js -description: > -

Splits a String into pieces and returns an array containing - the pieces.

- -

The first parameter, value, is the string to split.

- -

The second parameter, delim, is the character(s) that should - be used to - - split the string. For example, calling - - split('rock...paper...scissors', '...') would return the array - - ['rock', 'paper', 'scissors'] because there are three periods - ... - - between each word.

-line: 690 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let string = 'rock...paper...scissors'; - - // Split the string at each ... - let words = split(string, '...'); - - // Print the array to the console: - // ["rock", "paper", "scissors"] - print(words); - - // Style the text. - textAlign(CENTER, CENTER); - textFont('Courier New'); - textSize(16); - - // Iterate over the words array. - for (let i = 0; i < words.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 25; - - // Display the word. - text(words[i], 50, y); - } - - describe( - 'The words "rock", "paper", and "scissors" written on separate lines. The text is black on a gray background.' - ); - } - -
-class: p5 -params: - - name: value - description: | -

the String to be split

- type: String - - name: delim - description: | -

the String used to separate the data

- type: String -return: - description: Array of Strings - type: 'String[]' -chainable: false ---- - - -# split diff --git a/src/content/reference/en/p5 copy/splitTokens.mdx b/src/content/reference/en/p5 copy/splitTokens.mdx deleted file mode 100644 index 95d6ef4f8e..0000000000 --- a/src/content/reference/en/p5 copy/splitTokens.mdx +++ /dev/null @@ -1,180 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L751 -title: splitTokens -module: Data -submodule: String Functions -file: src/utilities/string_functions.js -description: > -

Splits a String into pieces and returns an array containing - the pieces.

- -

splitTokens() is an enhanced version of - - split(). It can split a string when any - characters - - from a list are detected.

- -

The first parameter, value, is the string to split.

- -

The second parameter, delim, is optional. It sets the - character(s) that - - should be used to split the string. delim can be a single string, - as in - - splitTokens('rock...paper...scissors...shoot', '...'), or an - array of - - strings, as in - - splitTokens('rock;paper,scissors...shoot, [';', ',', '...']). By - default, - - if no delim characters are specified, then any whitespace - character is - - used to split. Whitespace characters include tab (\t), line feed - (\n), - - carriage return (\r), form feed (\f), and space.

-line: 751 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let string = 'rock paper scissors shoot'; - - // Split the string at each space. - let words = splitTokens(string); - - // Print the array to the console. - print(words); - - // Style the text. - textAlign(CENTER, CENTER); - textFont('Courier New'); - textSize(12); - - // Iterate over the words array. - for (let i = 0; i < words.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 20; - - // Display the word. - text(words[i], 50, y); - } - - describe( - 'The words "rock", "paper", "scissors", and "shoot" written on separate lines. The text is black on a gray background.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let string = 'rock...paper...scissors...shoot'; - - // Split the string at each ... - let words = splitTokens(string, '...'); - - // Print the array to the console. - print(words); - - // Style the text. - textAlign(CENTER, CENTER); - textFont('Courier New'); - textSize(12); - - // Iterate over the words array. - for (let i = 0; i < words.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 20; - - // Display the word. - text(words[i], 50, y); - } - - describe( - 'The words "rock", "paper", "scissors", and "shoot" written on separate lines. The text is black on a gray background.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let string = 'rock;paper,scissors...shoot'; - - // Split the string at each semicolon, comma, or ... - let words = splitTokens(string, [';', ',', '...']); - - // Print the array to the console. - print(words); - - // Style the text. - textAlign(CENTER, CENTER); - textFont('Courier New'); - textSize(12); - - // Iterate over the words array. - for (let i = 0; i < words.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 20; - - // Display the word. - text(words[i], 50, y); - } - - describe( - 'The words "rock", "paper", "scissors", and "shoot" written on separate lines. The text is black on a gray background.' - ); - } - -
-class: p5 -params: - - name: value - description: | -

string to split.

- type: String - - name: delim - description: | -

character(s) to use for splitting the string.

- type: String - optional: true -return: - description: separated strings. - type: 'String[]' -chainable: false ---- - - -# splitTokens diff --git a/src/content/reference/en/p5 copy/spotLight.mdx b/src/content/reference/en/p5 copy/spotLight.mdx deleted file mode 100644 index 3d221dc8f4..0000000000 --- a/src/content/reference/en/p5 copy/spotLight.mdx +++ /dev/null @@ -1,398 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/light.js#L1272 -title: spotLight -module: 3D -submodule: Lights -file: src/webgl/light.js -description: > -

Creates a light that shines from a point in one direction.

- -

Spot lights are like flashlights that shine in one direction creating a - - cone of light. The shape of the cone can be controlled using the angle and - - concentration parameters. A maximum of 5 spot lights can be active at - once.

- -

There are eight ways to call spotLight() with parameters to - set the - - light’s color, position, direction. For example, - - spotLight(255, 0, 0, 0, 0, 0, 1, 0, 0) creates a red (255, - 0, 0) light - - at the origin (0, 0, 0) that points to the right (1, 0, - 0).

- -

The angle parameter is optional. It sets the radius of the - light cone. - - For example, spotLight(255, 0, 0, 0, 0, 0, 1, 0, 0, PI / 16) - creates a - - red (255, 0, 0) light at the origin (0, 0, 0) that - points to the right - - (1, 0, 0) with an angle of PI / 16 radians. By - default, angle is - - PI / 3 radians.

- -

The concentration parameter is also optional. It focuses the - light - - towards the center of the light cone. For example, - - spotLight(255, 0, 0, 0, 0, 0, 1, 0, 0, PI / 16, 50) creates a red - - (255, 0, 0) light at the origin (0, 0, 0) that - points to the right - - (1, 0, 0) with an angle of PI / 16 radians at - concentration of 50. By - - default, concentration is 100.

-line: 1272 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click to adjust the spotlight. - - let isLit = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white sphere drawn on a gray background. A red spotlight starts shining when the user double-clicks.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Control the spotlight. - if (isLit === true) { - // Add a red spot light that shines into the screen. - // Set its angle to PI / 32 radians. - spotLight(255, 0, 0, 0, 0, 100, 0, 0, -1, PI / 32); - } - - // Draw the sphere. - sphere(30); - } - - // Turn on the spotlight when the user double-clicks. - function doubleClicked() { - isLit = true; - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - // Double-click to adjust the spotlight. - - let isLit = false; - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white sphere drawn on a gray background. A red spotlight starts shining when the user double-clicks.'); - } - - function draw() { - background(50); - - // Enable orbiting with the mouse. - orbitControl(); - - // Turn on the lights. - lights(); - - // Control the spotlight. - if (isLit === true) { - // Add a red spot light that shines into the screen. - // Set its angle to PI / 3 radians (default). - // Set its concentration to 1000. - let c = color(255, 0, 0); - let position = createVector(0, 0, 100); - let direction = createVector(0, 0, -1); - spotLight(c, position, direction, PI / 3, 1000); - } - - // Draw the sphere. - sphere(30); - } - - // Turn on the spotlight when the user double-clicks. - function doubleClicked() { - isLit = true; - } - -
-class: p5 -overloads: - - line: 1272 - params: - - name: v1 - description: | -

red or hue value in the current - colorMode().

- type: Number - - name: v2 - description: | -

green or saturation value in the current - colorMode().

- type: Number - - name: v3 - description: | -

blue, brightness, or lightness value in the current - colorMode().

- type: Number - - name: x - description: | -

x-coordinate of the light.

- type: Number - - name: 'y' - description: | -

y-coordinate of the light.

- type: Number - - name: z - description: | -

z-coordinate of the light.

- type: Number - - name: rx - description: | -

x-component of light direction between -1 and 1.

- type: Number - - name: ry - description: | -

y-component of light direction between -1 and 1.

- type: Number - - name: rz - description: | -

z-component of light direction between -1 and 1.

- type: Number - - name: angle - description: | -

angle of the light cone. Defaults to PI / 3.

- type: Number - optional: true - - name: concentration - description: | -

concentration of the light. Defaults to 100.

- type: Number - optional: true - chainable: 1 - - line: 1399 - params: - - name: color - description: | -

color as a p5.Color object, - an array of color values, or a CSS string.

- type: 'p5.Color|Number[]|String' - - name: position - description: > -

position of the light as a p5.Vector - object.

- type: p5.Vector - - name: direction - description: > -

direction of light as a p5.Vector - object.

- type: p5.Vector - - name: angle - description: '' - type: Number - optional: true - - name: concentration - description: '' - type: Number - optional: true - - line: 1408 - params: - - name: v1 - description: '' - type: Number - - name: v2 - description: '' - type: Number - - name: v3 - description: '' - type: Number - - name: position - description: '' - type: p5.Vector - - name: direction - description: '' - type: p5.Vector - - name: angle - description: '' - type: Number - optional: true - - name: concentration - description: '' - type: Number - optional: true - - line: 1418 - params: - - name: color - description: '' - type: 'p5.Color|Number[]|String' - - name: x - description: '' - type: Number - - name: 'y' - description: '' - type: Number - - name: z - description: '' - type: Number - - name: direction - description: '' - type: p5.Vector - - name: angle - description: '' - type: Number - optional: true - - name: concentration - description: '' - type: Number - optional: true - - line: 1428 - params: - - name: color - description: '' - type: 'p5.Color|Number[]|String' - - name: position - description: '' - type: p5.Vector - - name: rx - description: '' - type: Number - - name: ry - description: '' - type: Number - - name: rz - description: '' - type: Number - - name: angle - description: '' - type: Number - optional: true - - name: concentration - description: '' - type: Number - optional: true - - line: 1438 - params: - - name: v1 - description: '' - type: Number - - name: v2 - description: '' - type: Number - - name: v3 - description: '' - type: Number - - name: x - description: '' - type: Number - - name: 'y' - description: '' - type: Number - - name: z - description: '' - type: Number - - name: direction - description: '' - type: p5.Vector - - name: angle - description: '' - type: Number - optional: true - - name: concentration - description: '' - type: Number - optional: true - - line: 1450 - params: - - name: v1 - description: '' - type: Number - - name: v2 - description: '' - type: Number - - name: v3 - description: '' - type: Number - - name: position - description: '' - type: p5.Vector - - name: rx - description: '' - type: Number - - name: ry - description: '' - type: Number - - name: rz - description: '' - type: Number - - name: angle - description: '' - type: Number - optional: true - - name: concentration - description: '' - type: Number - optional: true - - line: 1462 - params: - - name: color - description: '' - type: 'p5.Color|Number[]|String' - - name: x - description: '' - type: Number - - name: 'y' - description: '' - type: Number - - name: z - description: '' - type: Number - - name: rx - description: '' - type: Number - - name: ry - description: '' - type: Number - - name: rz - description: '' - type: Number - - name: angle - description: '' - type: Number - optional: true - - name: concentration - description: '' - type: Number - optional: true -chainable: true ---- - - -# spotLight diff --git a/src/content/reference/en/p5 copy/sq.mdx b/src/content/reference/en/p5 copy/sq.mdx deleted file mode 100644 index da0f2c4024..0000000000 --- a/src/content/reference/en/p5 copy/sq.mdx +++ /dev/null @@ -1,83 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L928 -title: sq -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Calculates the square of a number.

- -

Squaring a number means multiplying the number by itself. For example, - - sq(3) evaluates 3 × 3 which is 9. sq(-3) evaluates - -3 × -3 - - which is also 9. Multiplying two negative numbers produces a positive - - number. The value returned by sq() is always positive.

-line: 928 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Top-left. - let d = sq(3); - circle(33, 33, d); - - // Bottom-right. - d = sq(6); - circle(67, 67, d); - - describe('Two white circles. The circle at the top-left is small. The circle at the bottom-right is four times larger.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - describe('A series of black dots that get higher quickly from left to right.'); - } - - function draw() { - // Invert the y-axis. - scale(1, -1); - translate(0, -100); - - // Calculate the coordinates. - let x = frameCount; - let y = 0.01 * sq(x); - - // Draw the point. - point(x, y); - } - -
-class: p5 -params: - - name: 'n' - description: | -

number to square.

- type: Number -return: - description: squared number. - type: Number -chainable: false ---- - - -# sq diff --git a/src/content/reference/en/p5 copy/sqrt.mdx b/src/content/reference/en/p5 copy/sqrt.mdx deleted file mode 100644 index 5e239f6fe4..0000000000 --- a/src/content/reference/en/p5 copy/sqrt.mdx +++ /dev/null @@ -1,84 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/calculation.js#L988 -title: sqrt -module: Math -submodule: Calculation -file: src/math/calculation.js -description: > -

Calculates the square root of a number.

- -

A number's square root can be multiplied by itself to produce the original - - number. For example, sqrt(9) returns 3 because 3 × 3 = 9. - sqrt() - - always returns a positive value. sqrt() doesn't work with - negative arguments - - such as sqrt(-9).

-line: 988 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Top-left. - let d = sqrt(16); - circle(33, 33, d); - - // Bottom-right. - d = sqrt(1600); - circle(67, 67, d); - - describe('Two white circles. The circle at the top-left is small. The circle at the bottom-right is ten times larger.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - describe('A series of black dots that get higher slowly from left to right.'); - } - - function draw() { - // Invert the y-axis. - scale(1, -1); - translate(0, -100); - - // Calculate the coordinates. - let x = frameCount; - let y = 5 * sqrt(x); - - // Draw the point. - point(x, y); - } - -
-class: p5 -params: - - name: 'n' - description: | -

non-negative number to square root.

- type: Number -return: - description: square root of number. - type: Number -chainable: false ---- - - -# sqrt diff --git a/src/content/reference/en/p5 copy/square.mdx b/src/content/reference/en/p5 copy/square.mdx deleted file mode 100644 index 1e94a0087d..0000000000 --- a/src/content/reference/en/p5 copy/square.mdx +++ /dev/null @@ -1,163 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L1229 -title: square -module: Shape -submodule: 2D Primitives -file: src/core/shape/2d_primitives.js -description: > -

Draws a square.

- -

A square is a four-sided shape defined by the x, - y, and s - - parameters. x and y set the location of its top-left - corner. s sets - - its width and height. Every angle in the square measures 90˚ and all its - - sides are the same length. See rectMode() for - - other ways to define squares.

- -

The version of square() with four parameters creates a rounded - square. - - The fourth parameter sets the radius for all four corners.

- -

The version of square() with seven parameters also creates a - rounded - - square. Each of the last four parameters set the radius of a corner. The - - radii start with the top-left corner and move clockwise around the - - square. If any of these parameters are omitted, they are set to the - - value of the last radius that was set.

-line: 1229 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - square(30, 20, 55); - - describe('A white square with a black outline in on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Give all corners a radius of 20. - square(30, 20, 55, 20); - - describe( - 'A white square with a black outline and round edges on a gray canvas.' - ); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Give each corner a unique radius. - square(30, 20, 55, 20, 15, 10, 5); - - describe('A white square with a black outline and round edges of different radii.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - square(-20, -30, 55); - - describe('A white square with a black outline in on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white square spins around on gray canvas.'); - } - - function draw() { - background(200); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Draw the square. - square(-20, -30, 55); - } - -
-class: p5 -params: - - name: x - description: | -

x-coordinate of the square.

- type: Number - - name: 'y' - description: | -

y-coordinate of the square.

- type: Number - - name: s - description: | -

side size of the square.

- type: Number - - name: tl - description: | -

optional radius of top-left corner.

- type: Number - optional: true - - name: tr - description: | -

optional radius of top-right corner.

- type: Number - optional: true - - name: br - description: | -

optional radius of bottom-right corner.

- type: Number - optional: true - - name: bl - description: | -

optional radius of bottom-left corner.

- type: Number - optional: true -chainable: true ---- - - -# square diff --git a/src/content/reference/en/p5 copy/storeItem.mdx b/src/content/reference/en/p5 copy/storeItem.mdx deleted file mode 100644 index 8552634c5a..0000000000 --- a/src/content/reference/en/p5 copy/storeItem.mdx +++ /dev/null @@ -1,149 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/data/local_storage.js#L10 -title: storeItem -module: Data -submodule: LocalStorage -file: src/data/local_storage.js -description: > -

Stores a value in the web browser's local storage.

- -

Web browsers can save small amounts of data using the built-in - - localStorage object. - - Data stored in localStorage can be retrieved at any point, even - after - - refreshing a page or restarting the browser. Data are stored as key-value - - pairs.

- -

storeItem() makes it easy to store values in - localStorage and - - getItem() makes it easy to retrieve - them.

- -

The first parameter, key, is the name of the value to be - stored as a - - string.

- -

The second parameter, value, is the value to be stored. Values - can have - - any type.

- -

Note: Sensitive data such as passwords or personal information shouldn't be - - stored in localStorage.

-line: 10 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - // Store the player's name. - storeItem('name', 'Feist'); - - // Store the player's score. - storeItem('score', 1234); - - describe('The text "Feist: 1234" written in black on a gray background.'); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(14); - - // Retrieve the name. - let name = getItem('name'); - - // Retrieve the score. - let score = getItem('score'); - - // Display the score. - text(`${name}: ${score}`, 50, 50); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Create an object. - let p = { x: 50, y: 50 }; - - // Store the object. - storeItem('position', p); - - describe('A white circle on a gray background.'); - } - - function draw() { - background(200); - - // Retrieve the object. - let p = getItem('position'); - - // Draw the circle. - circle(p.x, p.y, 30); - } - -
- - function setup() { - createCanvas(100, 100); - - // Create a p5.Color object. - let c = color('deeppink'); - - // Store the object. - storeItem('color', c); - - describe('A pink circle on a gray background.'); - } - - function draw() { - background(200); - - // Retrieve the object. - let c = getItem('color'); - - // Style the circle. - fill(c); - - // Draw the circle. - circle(50, 50, 30); - } - - -class: p5 -params: - - name: key - description: | -

name of the value.

- type: String - - name: value - description: | -

value to be stored.

- type: String|Number|Boolean|Object|Array -chainable: false ---- - - -# storeItem diff --git a/src/content/reference/en/p5 copy/str.mdx b/src/content/reference/en/p5 copy/str.mdx deleted file mode 100644 index c487979761..0000000000 --- a/src/content/reference/en/p5 copy/str.mdx +++ /dev/null @@ -1,135 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L232 -title: str -module: Data -submodule: Conversion -file: src/utilities/conversion.js -description: > -

Converts a Boolean or Number to - String.

- -

str() converts values to strings. See the - - String reference page for guidance on - using - - template literals instead.

- -

The parameter, n, is the value to convert. If n - is a Boolean, as in - - str(false) or str(true), then the value will be - returned as a string, - - as in 'false' or 'true'. If n is a - number, as in str(123), then its - - value will be returned as a string, as in '123'. If an array is - passed, - - as in str([12.34, 56.78]), then an array of strings will be - returned.

-line: 232 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a Boolean variable. - let original = false; - - // Convert the Boolean to a string. - let converted = str(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the original and converted values. - text(`${original} : ${converted}`, 50, 50); - - describe('The text "false : false" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a number variable. - let original = 123; - - // Convert the number to a string. - let converted = str(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the original and converted values. - text(`${original} = ${converted}`, 50, 50); - - describe('The text "123 = 123" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of numbers. - let original = [12, 34, 56]; - - // Convert the numbers to strings. - let strings = str(original); - - // Create an empty string variable. - let final = ''; - - // Concatenate all the strings. - for (let s of strings) { - final += s; - } - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the concatenated string. - text(final, 50, 50); - - describe('The text "123456" written in black on a gray background.'); - } - -
-class: p5 -params: - - name: 'n' - description: | -

value to convert.

- type: String|Boolean|Number -return: - description: converted string. - type: String -chainable: false ---- - - -# str diff --git a/src/content/reference/en/p5 copy/stroke.mdx b/src/content/reference/en/p5 copy/stroke.mdx deleted file mode 100644 index bf086f9b66..0000000000 --- a/src/content/reference/en/p5 copy/stroke.mdx +++ /dev/null @@ -1,311 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/color/setting.js#L1373 -title: stroke -module: Color -submodule: Setting -file: src/color/setting.js -description: > -

Sets the color used to draw points, lines, and the outlines of shapes.

- -

Calling stroke(255, 165, 0) or stroke('orange') - means all shapes drawn - - after calling stroke() will be outlined with the color orange. - The way - - these parameters are interpreted may be changed with the - - colorMode() function.

- -

The version of stroke() with one parameter interprets the - value one of - - three ways. If the parameter is a Number, it's interpreted as a - grayscale - - value. If the parameter is a String, it's interpreted as a CSS - color - - string. A p5.Color object can also be - provided to - - set the stroke color.

- -

The version of stroke() with two parameters interprets the - first one as a - - grayscale value. The second parameter sets the alpha (transparency) value.

- -

The version of stroke() with three parameters interprets them - as RGB, HSB, - - or HSL colors, depending on the current colorMode().

- -

The version of stroke() with four parameters interprets them - as RGBA, HSBA, - - or HSLA colors, depending on the current colorMode(). The last - parameter - - sets the alpha (transparency) value.

-line: 1373 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // A grayscale value. - strokeWeight(4); - stroke(51); - square(20, 20, 60); - - describe('A white square with a dark charcoal gray outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // R, G & B values. - stroke(255, 204, 0); - strokeWeight(4); - square(20, 20, 60); - - describe('A white square with a yellow outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Use HSB color. - colorMode(HSB); - - // H, S & B values. - strokeWeight(4); - stroke(255, 204, 100); - square(20, 20, 60); - - describe('A white square with a royal blue outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // A CSS named color. - stroke('red'); - strokeWeight(4); - square(20, 20, 60); - - describe('A white square with a red outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Three-digit hex RGB notation. - stroke('#fae'); - strokeWeight(4); - square(20, 20, 60); - - describe('A white square with a pink outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Six-digit hex RGB notation. - stroke('#222222'); - strokeWeight(4); - square(20, 20, 60); - - describe('A white square with a black outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Integer RGB notation. - stroke('rgb(0, 255, 0)'); - strokeWeight(4); - square(20, 20, 60); - - describe('A whiite square with a bright green outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Integer RGBA notation. - stroke('rgba(0, 255, 0, 0.25)'); - strokeWeight(4); - square(20, 20, 60); - - describe('A white square with a soft green outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Percentage RGB notation. - stroke('rgb(100%, 0%, 10%)'); - strokeWeight(4); - square(20, 20, 60); - - describe('A white square with a red outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Percentage RGBA notation. - stroke('rgba(100%, 0%, 100%, 0.5)'); - strokeWeight(4); - square(20, 20, 60); - - describe('A white square with a dark fuchsia outline.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // A p5.Color object. - stroke(color(0, 0, 255)); - strokeWeight(4); - square(20, 20, 60); - - describe('A white square with a blue outline.'); - } - -
-class: p5 -overloads: - - line: 1373 - params: - - name: v1 - description: > -

red value if color mode is RGB or hue value if color mode is - HSB.

- type: Number - - name: v2 - description: > -

green value if color mode is RGB or saturation value if color mode - is HSB.

- type: Number - - name: v3 - description: > -

blue value if color mode is RGB or brightness value if color mode - is HSB.

- type: Number - - name: alpha - description: > -

alpha value, controls transparency (0 - transparent, 255 - - opaque).

- type: Number - optional: true - chainable: 1 - - line: 1596 - params: - - name: value - description: | -

a color string.

- type: String - chainable: 1 - - line: 1602 - params: - - name: gray - description: | -

a grayscale value.

- type: Number - - name: alpha - description: '' - type: Number - optional: true - chainable: 1 - - line: 1609 - params: - - name: values - description: | -

an array containing the red, green, blue, - and alpha components of the color.

- type: 'Number[]' - chainable: 1 - - line: 1616 - params: - - name: color - description: | -

the stroke color.

- type: p5.Color - chainable: 1 -chainable: true ---- - - -# stroke diff --git a/src/content/reference/en/p5 copy/strokeCap.mdx b/src/content/reference/en/p5 copy/strokeCap.mdx deleted file mode 100644 index 80965419ab..0000000000 --- a/src/content/reference/en/p5 copy/strokeCap.mdx +++ /dev/null @@ -1,67 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L388 -title: strokeCap -module: Shape -submodule: Attributes -file: src/core/shape/attributes.js -description: > -

Sets the style for rendering the ends of lines.

- -

The caps for line endings are either rounded (ROUND), squared - - (SQUARE), or extended (PROJECT). The default cap is - ROUND.

- -

The argument passed to strokeCap() must be written in ALL CAPS - because - - the constants ROUND, SQUARE, and - PROJECT are defined this way. - - JavaScript is a case-sensitive language.

-line: 388 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - strokeWeight(12); - - // Top. - strokeCap(ROUND); - line(20, 30, 80, 30); - - // Middle. - strokeCap(SQUARE); - line(20, 50, 80, 50); - - // Bottom. - strokeCap(PROJECT); - line(20, 70, 80, 70); - - describe( - 'Three horizontal lines. The top line has rounded ends, the middle line has squared ends, and the bottom line has longer, squared ends.' - ); - } - -
-class: p5 -params: - - name: cap - description: | -

either ROUND, SQUARE, or PROJECT

- type: Constant -chainable: true ---- - - -# strokeCap diff --git a/src/content/reference/en/p5 copy/strokeJoin.mdx b/src/content/reference/en/p5 copy/strokeJoin.mdx deleted file mode 100644 index 46a8a9206f..0000000000 --- a/src/content/reference/en/p5 copy/strokeJoin.mdx +++ /dev/null @@ -1,114 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L442 -title: strokeJoin -module: Shape -submodule: Attributes -file: src/core/shape/attributes.js -description: > -

Sets the style of the joints that connect line segments.

- -

Joints are either mitered (MITER), beveled - (BEVEL), or rounded - - (ROUND). The default joint is MITER in 2D mode and - ROUND in WebGL - - mode.

- -

The argument passed to strokeJoin() must be written in ALL - CAPS because - - the constants MITER, BEVEL, and ROUND - are defined this way. - - JavaScript is a case-sensitive language.

-line: 442 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the line. - noFill(); - strokeWeight(10); - strokeJoin(MITER); - - // Draw the line. - beginShape(); - vertex(35, 20); - vertex(65, 50); - vertex(35, 80); - endShape(); - - describe('A right-facing arrowhead shape with a pointed tip in center of canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the line. - noFill(); - strokeWeight(10); - strokeJoin(BEVEL); - - // Draw the line. - beginShape(); - vertex(35, 20); - vertex(65, 50); - vertex(35, 80); - endShape(); - - describe('A right-facing arrowhead shape with a flat tip in center of canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the line. - noFill(); - strokeWeight(10); - strokeJoin(ROUND); - - // Draw the line. - beginShape(); - vertex(35, 20); - vertex(65, 50); - vertex(35, 80); - endShape(); - - describe('A right-facing arrowhead shape with a rounded tip in center of canvas.'); - } - -
-class: p5 -params: - - name: join - description: | -

either MITER, BEVEL, or ROUND

- type: Constant -chainable: true ---- - - -# strokeJoin diff --git a/src/content/reference/en/p5 copy/strokeWeight.mdx b/src/content/reference/en/p5 copy/strokeWeight.mdx deleted file mode 100644 index 82ebfc13d5..0000000000 --- a/src/content/reference/en/p5 copy/strokeWeight.mdx +++ /dev/null @@ -1,77 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/attributes.js#L541 -title: strokeWeight -module: Shape -submodule: Attributes -file: src/core/shape/attributes.js -description: > -

Sets the width of the stroke used for points, lines, and the outlines of - - shapes.

- -

Note: strokeWeight() is affected by transformations, - especially calls to - - scale().

-line: 541 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Top. - line(20, 20, 80, 20); - - // Middle. - strokeWeight(4); - line(20, 40, 80, 40); - - // Bottom. - strokeWeight(10); - line(20, 70, 80, 70); - - describe('Three horizontal black lines. The top line is thin, the middle is medium, and the bottom is thick.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Top. - line(20, 20, 80, 20); - - // Scale by a factor of 5. - scale(5); - - // Bottom. Coordinates are adjusted for scaling. - line(4, 8, 16, 8); - - describe('Two horizontal black lines. The top line is thin and the bottom is five times thicker than the top.'); - } - -
-class: p5 -params: - - name: weight - description: | -

the weight of the stroke (in pixels).

- type: Number -chainable: true ---- - - -# strokeWeight diff --git a/src/content/reference/en/p5 copy/subset.mdx b/src/content/reference/en/p5 copy/subset.mdx deleted file mode 100644 index 1cf7cb7f4e..0000000000 --- a/src/content/reference/en/p5 copy/subset.mdx +++ /dev/null @@ -1,59 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/array_functions.js#L381 -title: subset -module: Data -submodule: Array Functions -file: src/utilities/array_functions.js -description: | -

Extracts an array of elements from an existing array. The list parameter - defines the array from which the elements will be copied, and the start - and count parameters specify which elements to extract. If no count is - given, elements will be extracted from the start to the end of the array. - When specifying the start, remember that the first array element is 0. - This function does not change the source array.

-line: 381 -deprecated: >- - Use array.slice() - instead. -isConstructor: false -itemtype: method -example: - - |- - -
- function setup() { - let myArray = [1, 2, 3, 4, 5]; - print(myArray); // [1, 2, 3, 4, 5] - - let sub1 = subset(myArray, 0, 3); - let sub2 = subset(myArray, 2, 2); - print(sub1); // [1,2,3] - print(sub2); // [3,4] - } -
-class: p5 -params: - - name: list - description: | -

Array to extract from

- type: Array - - name: start - description: | -

position to begin

- type: Integer - - name: count - description: | -

number of values to extract

- type: Integer - optional: true -return: - description: Array of extracted elements - type: Array -chainable: false ---- - - -# subset diff --git a/src/content/reference/en/p5 copy/tan.mdx b/src/content/reference/en/p5 copy/tan.mdx deleted file mode 100644 index 376d093f33..0000000000 --- a/src/content/reference/en/p5 copy/tan.mdx +++ /dev/null @@ -1,66 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/math/trigonometry.js#L445 -title: tan -module: Math -submodule: Trigonometry -file: src/math/trigonometry.js -description: > -

Calculates the tangent of an angle.

- -

tan() is useful for many geometric tasks in creative coding. - The values - - returned range from -Infinity to Infinity and repeat periodically as the - - input angle increases. tan() calculates the tan of an angle, - using radians - - by default, or according to - - if angleMode() setting (RADIANS or - DEGREES).

-line: 445 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - describe('A series of identical curves drawn with black dots. Each curve starts from the top of the canvas, continues down at a slight angle, flattens out at the middle of the canvas, then continues to the bottom.'); - } - - function draw() { - // Calculate the coordinates. - let x = frameCount; - let y = 5 * tan(x * 0.1) + 50; - - // Draw the point. - point(x, y); - } - -
-class: p5 -params: - - name: angle - description: > -

the angle, in radians by default, or according to - - if angleMode() setting (RADIANS or - DEGREES).

- type: Number -return: - description: tangent of the angle. - type: Number -chainable: false ---- - - -# tan diff --git a/src/content/reference/en/p5 copy/text.mdx b/src/content/reference/en/p5 copy/text.mdx deleted file mode 100644 index eea293bfd8..0000000000 --- a/src/content/reference/en/p5 copy/text.mdx +++ /dev/null @@ -1,96 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/loading_displaying.js#L182 -title: text -module: Typography -submodule: Loading & Displaying -file: src/typography/loading_displaying.js -description: > -

Draws text to the canvas.

- -

The first parameter, str, is the text to be drawn. The second - and third - - parameters, x and y, set the coordinates of the - text's bottom-left - - corner. See textAlign() for other ways - to - - align text.

- -

The fourth and fifth parameters, maxWidth and - maxHeight, are optional. - - They set the dimensions of the invisible rectangle containing the text. By - - default, they set its maximum width and height. See - - rectMode() for other ways to define the - - rectangular text box. Text will wrap to fit within the text box. Text - - outside of the box won't be drawn.

- -

Text can be styled a few ways. Call the fill() - - function to set the text's fill color. Call - - stroke() and - - strokeWeight() to set the text's - outline. - - Call textSize() and - - textFont() to set the text's size and - font, - - respectively.

- -

Note: WEBGL mode only supports fonts loaded with - - loadFont(). Calling - - stroke() has no effect in - WEBGL mode.

-line: 182 -isConstructor: false -itemtype: method -example: - - "\n
\n\nfunction setup() {\n background(200);\n text('hi', 50, 50);\n\n describe('The text \"hi\" written in black in the middle of a gray square.');\n}\n\n
\n\n
\n\nfunction setup() {\n background('skyblue');\n textSize(100);\n text('\U0001F308', 0, 100);\n\n describe('A rainbow in a blue sky.');\n}\n\n
\n\n
\n\nfunction setup() {\n textSize(32);\n fill(255);\n stroke(0);\n strokeWeight(4);\n text('hi', 50, 50);\n\n describe('The text \"hi\" written in white with a black outline.');\n}\n\n
\n\n
\n\nfunction setup() {\n background('black');\n textSize(22);\n fill('yellow');\n text('rainbows', 6, 20);\n fill('cornflowerblue');\n text('rainbows', 6, 45);\n fill('tomato');\n text('rainbows', 6, 70);\n fill('limegreen');\n text('rainbows', 6, 95);\n\n describe('The text \"rainbows\" written on several lines, each in a different color.');\n}\n\n
\n\n
\n\nfunction setup() {\n background(200);\n let s = 'The quick brown fox jumps over the lazy dog.';\n text(s, 10, 10, 70, 80);\n\n describe('The sample text \"The quick brown fox...\" written in black across several lines.');\n}\n\n
\n\n
\n\nfunction setup() {\n background(200);\n rectMode(CENTER);\n let s = 'The quick brown fox jumps over the lazy dog.';\n text(s, 50, 50, 70, 80);\n\n describe('The sample text \"The quick brown fox...\" written in black across several lines.');\n}\n\n
\n\n
\n\nlet font;\n\nfunction preload() {\n font = loadFont('/assets/inconsolata.otf');\n}\n\nfunction setup() {\n createCanvas(100, 100, WEBGL);\n textFont(font);\n textSize(32);\n textAlign(CENTER, CENTER);\n}\n\nfunction draw() {\n background(0);\n rotateY(frameCount / 30);\n text('p5*js', 0, 0);\n\n describe('The text \"p5*js\" written in white and spinning in 3D.');\n}\n\n
" -class: p5 -params: - - name: str - description: | -

text to be displayed.

- type: String|Object|Array|Number|Boolean - - name: x - description: | -

x-coordinate of the text box.

- type: Number - - name: 'y' - description: | -

y-coordinate of the text box.

- type: Number - - name: maxWidth - description: | -

maximum width of the text box. See - rectMode() for - other options.

- type: Number - optional: true - - name: maxHeight - description: | -

maximum height of the text box. See - rectMode() for - other options.

- type: Number - optional: true -chainable: true ---- - - -# text diff --git a/src/content/reference/en/p5 copy/textAlign.mdx b/src/content/reference/en/p5 copy/textAlign.mdx deleted file mode 100644 index 3899f22842..0000000000 --- a/src/content/reference/en/p5 copy/textAlign.mdx +++ /dev/null @@ -1,135 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L11 -title: textAlign -module: Typography -submodule: Attributes -file: src/typography/attributes.js -description: > -

Sets the way text is aligned when text() - is called.

- -

By default, calling text('hi', 10, 20) places the bottom-left - corner of - - the text's bounding box at (10, 20).

- -

The first parameter, horizAlign, changes the way - - text() interprets x-coordinates. By default, - the - - x-coordinate sets the left edge of the bounding box. textAlign() - accepts - - the following values for horizAlign: LEFT, - CENTER, or RIGHT.

- -

The second parameter, vertAlign, is optional. It changes the - way - - text() interprets y-coordinates. By default, - the - - y-coordinate sets the bottom edge of the bounding box. - textAlign() - - accepts the following values for vertAlign: TOP, - BOTTOM, CENTER, - - or BASELINE.

-line: 11 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw a vertical line. - strokeWeight(0.5); - line(50, 0, 50, 100); - - // Top line. - textSize(16); - textAlign(RIGHT); - text('ABCD', 50, 30); - - // Middle line. - textAlign(CENTER); - text('EFGH', 50, 50); - - // Bottom line. - textAlign(LEFT); - text('IJKL', 50, 70); - - describe('The letters ABCD displayed at top-left, EFGH at center, and IJKL at bottom-right. A vertical line divides the canvas in half.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - strokeWeight(0.5); - - // First line. - line(0, 12, width, 12); - textAlign(CENTER, TOP); - text('TOP', 50, 12); - - // Second line. - line(0, 37, width, 37); - textAlign(CENTER, CENTER); - text('CENTER', 50, 37); - - // Third line. - line(0, 62, width, 62); - textAlign(CENTER, BASELINE); - text('BASELINE', 50, 62); - - // Fourth line. - line(0, 97, width, 97); - textAlign(CENTER, BOTTOM); - text('BOTTOM', 50, 97); - - describe('The words "TOP", "CENTER", "BASELINE", and "BOTTOM" each drawn relative to a horizontal line. Their positions demonstrate different vertical alignments.'); - } - -
-class: p5 -overloads: - - line: 11 - params: - - name: horizAlign - description: | -

horizontal alignment, either LEFT, - CENTER, or RIGHT.

- type: Constant - - name: vertAlign - description: | -

vertical alignment, either TOP, - BOTTOM, CENTER, or BASELINE.

- type: Constant - optional: true - chainable: 1 - - line: 98 - params: [] - return: - description: '' - type: Object -chainable: true ---- - - -# textAlign diff --git a/src/content/reference/en/p5 copy/textAscent.mdx b/src/content/reference/en/p5 copy/textAscent.mdx deleted file mode 100644 index b81a657de6..0000000000 --- a/src/content/reference/en/p5 copy/textAscent.mdx +++ /dev/null @@ -1,71 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L337 -title: textAscent -module: Typography -submodule: Attributes -file: src/typography/attributes.js -description: | -

Calculates the ascent of the current font at its current size.

-

The ascent represents the distance, in pixels, of the tallest character - above the baseline.

-line: 337 -isConstructor: false -itemtype: method -example: - - |- - -
- - let font; - - function preload() { - font = loadFont('/assets/inconsolata.otf'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textFont(font); - - // Different for each font. - let fontScale = 0.8; - - let baseY = 75; - strokeWeight(0.5); - - // Draw small text. - textSize(24); - text('dp', 0, baseY); - - // Draw baseline and ascent. - let a = textAscent() * fontScale; - line(0, baseY, 23, baseY); - line(23, baseY - a, 23, baseY); - - // Draw large text. - textSize(48); - text('dp', 45, baseY); - - // Draw baseline and ascent. - a = textAscent() * fontScale; - line(45, baseY, 91, baseY); - line(91, baseY - a, 91, baseY); - - describe('The letters "dp" written twice in different sizes. Each version has a horizontal baseline. A vertical line extends upward from each baseline to the top of the "d".'); - } - -
-class: p5 -return: - description: ascent measured in units of pixels. - type: Number -chainable: false ---- - - -# textAscent diff --git a/src/content/reference/en/p5 copy/textDescent.mdx b/src/content/reference/en/p5 copy/textDescent.mdx deleted file mode 100644 index 15837acff3..0000000000 --- a/src/content/reference/en/p5 copy/textDescent.mdx +++ /dev/null @@ -1,71 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L396 -title: textDescent -module: Typography -submodule: Attributes -file: src/typography/attributes.js -description: | -

Calculates the descent of the current font at its current size.

-

The descent represents the distance, in pixels, of the character with the - longest descender below the baseline.

-line: 396 -isConstructor: false -itemtype: method -example: - - |- - -
- - let font; - - function preload() { - font = loadFont('/assets/inconsolata.otf'); - } - - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the font. - textFont(font); - - // Different for each font. - let fontScale = 0.9; - - let baseY = 75; - strokeWeight(0.5); - - // Draw small text. - textSize(24); - text('dp', 0, baseY); - - // Draw baseline and descent. - let d = textDescent() * fontScale; - line(0, baseY, 23, baseY); - line(23, baseY, 23, baseY + d); - - // Draw large text. - textSize(48); - text('dp', 45, baseY); - - // Draw baseline and descent. - d = textDescent() * fontScale; - line(45, baseY, 91, baseY); - line(91, baseY, 91, baseY + d); - - describe('The letters "dp" written twice in different sizes. Each version has a horizontal baseline. A vertical line extends downward from each baseline to the bottom of the "p".'); - } - -
-class: p5 -return: - description: descent measured in units of pixels. - type: Number -chainable: false ---- - - -# textDescent diff --git a/src/content/reference/en/p5 copy/textFont.mdx b/src/content/reference/en/p5 copy/textFont.mdx deleted file mode 100644 index e5e9fa8da1..0000000000 --- a/src/content/reference/en/p5 copy/textFont.mdx +++ /dev/null @@ -1,127 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/loading_displaying.js#L335 -title: textFont -module: Typography -submodule: Loading & Displaying -file: src/typography/loading_displaying.js -description: > -

Sets the font used by the text() - function.

- -

The first parameter, font, sets the font. - textFont() recognizes either - - a p5.Font object or a string with the name - of a - - system font. For example, 'Courier New'.

- -

The second parameter, size, is optional. It sets the font size - in pixels. - - This has the same effect as calling textSize().

- -

Note: WEBGL mode only supports fonts loaded with - - loadFont().

-line: 335 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - background(200); - textFont('Courier New'); - textSize(24); - text('hi', 35, 55); - - describe('The text "hi" written in a black, monospace font on a gray background.'); - } - -
- -
- - function setup() { - background('black'); - fill('palegreen'); - textFont('Courier New', 10); - text('You turn to the left and see a door. Do you enter?', 5, 5, 90, 90); - text('>', 5, 70); - - describe('A text prompt from a game is written in a green, monospace font on a black background.'); - } - -
- -
- - function setup() { - background(200); - textFont('Verdana'); - let currentFont = textFont(); - text(currentFont, 25, 50); - - describe('The text "Verdana" written in a black, sans-serif font on a gray background.'); - } - -
- -
- - let fontRegular; - let fontItalic; - let fontBold; - - function preload() { - fontRegular = loadFont('/assets/Regular.otf'); - fontItalic = loadFont('/assets/Italic.ttf'); - fontBold = loadFont('/assets/Bold.ttf'); - } - - function setup() { - background(200); - textFont(fontRegular); - text('I am Normal', 10, 30); - textFont(fontItalic); - text('I am Italic', 10, 50); - textFont(fontBold); - text('I am Bold', 10, 70); - - describe('The statements "I am Normal", "I am Italic", and "I am Bold" written in black on separate lines. The statements have normal, italic, and bold fonts, respectively.'); - } - -
-class: p5 -return: - description: current font or p5 Object. - type: Object -overloads: - - line: 335 - params: [] - return: - description: current font or p5 Object. - type: Object - - line: 418 - params: - - name: font - description: | -

font as a p5.Font object or a string.

- type: Object|String - - name: size - description: | -

font size in pixels.

- type: Number - optional: true - chainable: 1 -chainable: false ---- - - -# textFont diff --git a/src/content/reference/en/p5 copy/textLeading.mdx b/src/content/reference/en/p5 copy/textLeading.mdx deleted file mode 100644 index 3b5a22d9a2..0000000000 --- a/src/content/reference/en/p5 copy/textLeading.mdx +++ /dev/null @@ -1,63 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L107 -title: textLeading -module: Typography -submodule: Attributes -file: src/typography/attributes.js -description: > -

Sets the spacing between lines of text when - - text() is called.

- -

Note: Spacing is measured in pixels.

- -

Calling textLeading() without an argument returns the current - spacing.

-line: 107 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // "\n" starts a new line of text. - let lines = 'one\ntwo'; - - // Left. - text(lines, 10, 25); - - // Right. - textLeading(30); - text(lines, 70, 25); - - describe('The words "one" and "two" written on separate lines twice. The words on the left have less vertical spacing than the words on the right.'); - } - -
-class: p5 -overloads: - - line: 107 - params: - - name: leading - description: | -

spacing between lines of text in units of pixels.

- type: Number - chainable: 1 - - line: 142 - params: [] - return: - description: '' - type: Number -chainable: true ---- - - -# textLeading diff --git a/src/content/reference/en/p5 copy/textOutput.mdx b/src/content/reference/en/p5 copy/textOutput.mdx deleted file mode 100644 index 62ea4cb4b5..0000000000 --- a/src/content/reference/en/p5 copy/textOutput.mdx +++ /dev/null @@ -1,186 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/accessibility/outputs.js#L10 -title: textOutput -module: Environment -submodule: Environment -file: src/accessibility/outputs.js -description: > -

Creates a screen reader-accessible description of shapes on the canvas.

- -

textOutput() adds a general description, list of shapes, and - - table of shapes to the web page. The general description includes the - - canvas size, canvas color, and number of shapes. For example, - - Your output is a, 100 by 100 pixels, gray canvas containing the - following 2 shapes:.

- -

A list of shapes follows the general description. The list describes the - - color, location, and area of each shape. For example, - - a red circle at middle covering 3% of the canvas. Each shape can - be - - selected to get more details.

- -

textOutput() uses its table of shapes as a list. The table - describes the - - shape, color, location, coordinates and area. For example, - - red circle location = middle area = 3%. This is different from - - gridOutput(), which uses its table as - a grid.

- -

The display parameter is optional. It determines how the - description is - - displayed. If LABEL is passed, as in - textOutput(LABEL), the description - - will be visible in a div element next to the canvas. Using LABEL - creates - - unhelpful duplicates for screen readers. Only use LABEL during - - development. If FALLBACK is passed, as in - textOutput(FALLBACK), the - - description will only be visible to screen readers. This is the default - - mode.

- -

Read - - Writing - accessible canvas descriptions - - to learn more about making sketches accessible.

- -

textOutput() generates descriptions in English only. Text - drawn with - - text() is not described. Shapes created with - - beginShape() are not described. WEBGL - mode - - and 3D shapes are not supported.

- -

Use describe() and - - describeElement() for more - control - - over canvas descriptions.

-line: 10 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - // Add the text description. - textOutput(); - - // Draw a couple of shapes. - background(200); - fill(255, 0, 0); - circle(20, 20, 20); - fill(0, 0, 255); - square(50, 50, 50); - - // Add a general description of the canvas. - describe('A red circle and a blue square on a gray background.'); - } - -
- -
- - function setup() { - // Add the text description and - // display it for debugging. - textOutput(LABEL); - - // Draw a couple of shapes. - background(200); - fill(255, 0, 0); - circle(20, 20, 20); - fill(0, 0, 255); - square(50, 50, 50); - - // Add a general description of the canvas. - describe('A red circle and a blue square on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - } - - function draw() { - // Add the text description. - textOutput(); - - // Draw a moving circle. - background(200); - let x = frameCount * 0.1; - fill(255, 0, 0); - circle(x, 20, 20); - fill(0, 0, 255); - square(50, 50, 50); - - // Add a general description of the canvas. - describe('A red circle moves from left to right above a blue square.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - } - - function draw() { - // Add the text description and - // display it for debugging. - textOutput(LABEL); - - // Draw a moving circle. - background(200); - let x = frameCount * 0.1; - fill(255, 0, 0); - circle(x, 20, 20); - fill(0, 0, 255); - square(50, 50, 50); - - // Add a general description of the canvas. - describe('A red circle moves from left to right above a blue square.'); - } - -
-class: p5 -params: - - name: display - description: | -

either FALLBACK or LABEL.

- type: Constant - optional: true -chainable: false ---- - - -# textOutput diff --git a/src/content/reference/en/p5 copy/textSize.mdx b/src/content/reference/en/p5 copy/textSize.mdx deleted file mode 100644 index df77510315..0000000000 --- a/src/content/reference/en/p5 copy/textSize.mdx +++ /dev/null @@ -1,65 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L151 -title: textSize -module: Typography -submodule: Attributes -file: src/typography/attributes.js -description: > -

Sets the font size when - - text() is called.

- -

Note: Font size is measured in pixels.

- -

Calling textSize() without an argument returns the current - size.

-line: 151 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Top. - textSize(12); - text('Font Size 12', 10, 30); - - // Middle. - textSize(14); - text('Font Size 14', 10, 60); - - // Bottom. - textSize(16); - text('Font Size 16', 10, 90); - - describe('The text "Font Size 12" drawn small, "Font Size 14" drawn medium, and "Font Size 16" drawn large.'); - } - -
-class: p5 -overloads: - - line: 151 - params: - - name: size - description: | -

size of the letters in units of pixels.

- type: Number - chainable: 1 - - line: 188 - params: [] - return: - description: '' - type: Number -chainable: true ---- - - -# textSize diff --git a/src/content/reference/en/p5 copy/textStyle.mdx b/src/content/reference/en/p5 copy/textStyle.mdx deleted file mode 100644 index 572ca0454c..0000000000 --- a/src/content/reference/en/p5 copy/textStyle.mdx +++ /dev/null @@ -1,79 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L197 -title: textStyle -module: Typography -submodule: Attributes -file: src/typography/attributes.js -description: > -

Sets the style for system fonts when - - text() is called.

- -

The parameter, style, can be either NORMAL, - ITALIC, BOLD, or - - BOLDITALIC.

- -

textStyle() may be overridden by CSS styling. This function - doesn't - - affect fonts loaded with loadFont().

-line: 197 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textSize(12); - textAlign(CENTER); - - // First row. - textStyle(NORMAL); - text('Normal', 50, 15); - - // Second row. - textStyle(ITALIC); - text('Italic', 50, 40); - - // Third row. - textStyle(BOLD); - text('Bold', 50, 65); - - // Fourth row. - textStyle(BOLDITALIC); - text('Bold Italic', 50, 90); - - describe('The words "Normal" displayed normally, "Italic" in italic, "Bold" in bold, and "Bold Italic" in bold italics.'); - } - -
-class: p5 -overloads: - - line: 197 - params: - - name: style - description: | -

styling for text, either NORMAL, - ITALIC, BOLD or BOLDITALIC.

- type: Constant - chainable: 1 - - line: 244 - params: [] - return: - description: '' - type: String -chainable: true ---- - - -# textStyle diff --git a/src/content/reference/en/p5 copy/textWidth.mdx b/src/content/reference/en/p5 copy/textWidth.mdx deleted file mode 100644 index 00721b0fee..0000000000 --- a/src/content/reference/en/p5 copy/textWidth.mdx +++ /dev/null @@ -1,83 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L253 -title: textWidth -module: Typography -submodule: Attributes -file: src/typography/attributes.js -description: | -

Calculates the maximum width of a string of text drawn when - text() is called.

-line: 253 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textSize(28); - strokeWeight(0.5); - - // Calculate the text width. - let s = 'yoyo'; - let w = textWidth(s); - - // Display the text. - text(s, 22, 55); - - // Underline the text. - line(22, 55, 22 + w, 55); - - describe('The word "yoyo" underlined.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textSize(28); - strokeWeight(0.5); - - // Calculate the text width. - // "\n" starts a new line. - let s = 'yo\nyo'; - let w = textWidth(s); - - // Display the text. - text(s, 22, 55); - - // Underline the text. - line(22, 55, 22 + w, 55); - - describe('The word "yo" written twice, one copy beneath the other. The words are divided by a horizontal line.'); - } - -
-class: p5 -params: - - name: str - description: | -

string of text to measure.

- type: String -return: - description: width measured in units of pixels. - type: Number -chainable: false ---- - - -# textWidth diff --git a/src/content/reference/en/p5 copy/textWrap.mdx b/src/content/reference/en/p5 copy/textWrap.mdx deleted file mode 100644 index 0ba2b556a7..0000000000 --- a/src/content/reference/en/p5 copy/textWrap.mdx +++ /dev/null @@ -1,111 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/typography/attributes.js#L462 -title: textWrap -module: Typography -submodule: Attributes -file: src/typography/attributes.js -description: > -

Sets the style for wrapping text when - - text() is called.

- -

The parameter, style, can be one of the following values:

- -

WORD starts new lines of text at spaces. If a string of text - doesn't - - have spaces, it may overflow the text box and the canvas. This is the - - default style.

- -

CHAR starts new lines as needed to stay within the text - box.

- -

textWrap() only works when the maximum width is set for a text - box. For - - example, calling text('Have a wonderful day', 0, 10, 100) sets - the - - maximum width to 100 pixels.

- -

Calling textWrap() without an argument returns the current - style.

-line: 462 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textSize(20); - textWrap(WORD); - - // Display the text. - text('Have a wonderful day', 0, 10, 100); - - describe('The text "Have a wonderful day" written across three lines.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textSize(20); - textWrap(CHAR); - - // Display the text. - text('Have a wonderful day', 0, 10, 100); - - describe('The text "Have a wonderful day" written across two lines.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the text. - textSize(20); - textWrap(CHAR); - - // Display the text. - text('祝你有美好的一天', 0, 10, 100); - - describe('The text "祝你有美好的一天" written across two lines.'); - } - -
-class: p5 -params: - - name: style - description: | -

text wrapping style, either WORD or CHAR.

- type: Constant -return: - description: style - type: String -chainable: false ---- - - -# textWrap diff --git a/src/content/reference/en/p5 copy/texture.mdx b/src/content/reference/en/p5 copy/texture.mdx deleted file mode 100644 index 7258f53ace..0000000000 --- a/src/content/reference/en/p5 copy/texture.mdx +++ /dev/null @@ -1,207 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1716 -title: texture -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Sets the texture that will be used on shapes.

- -

A texture is like a skin that wraps around a shape. texture() - works with - - built-in shapes, such as square() and - - sphere(), and custom shapes created with - - functions such as buildGeometry(). - To - - texture a geometry created with beginShape(), - - uv coordinates must be passed to each - - vertex() call.

- -

The parameter, tex, is the texture to apply. - texture() can use a range - - of sources including images, videos, and offscreen renderers such as - - p5.Graphics and - - p5.Framebuffer objects.

- -

To texture a geometry created with beginShape(), - - you will need to specify uv coordinates in vertex().

- -

Note: texture() can only be used in WebGL mode.

-line: 1716 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load an image and create a p5.Image object. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A spinning cube with an image of a ceiling on each face.'); - } - - function draw() { - background(0); - - // Rotate around the x-, y-, and z-axes. - rotateZ(frameCount * 0.01); - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - - // Apply the image as a texture. - texture(img); - - // Draw the box. - box(50); - } - -
- -
- - let pg; - - function setup() { - createCanvas(100, 100, WEBGL); - - // Create a p5.Graphics object. - pg = createGraphics(100, 100); - - // Draw a circle to the p5.Graphics object. - pg.background(200); - pg.circle(50, 50, 30); - - describe('A spinning cube with circle at the center of each face.'); - } - - function draw() { - background(0); - - // Rotate around the x-, y-, and z-axes. - rotateZ(frameCount * 0.01); - rotateX(frameCount * 0.01); - rotateY(frameCount * 0.01); - - // Apply the p5.Graphics object as a texture. - texture(pg); - - // Draw the box. - box(50); - } - -
- -
- - let vid; - - // Load a video and create a p5.MediaElement object. - function preload() { - vid = createVideo('/assets/fingers.mov'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - // Hide the video. - vid.hide(); - - // Set the video to loop. - vid.loop(); - - describe('A rectangle with video as texture'); - } - - function draw() { - background(0); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Apply the video as a texture. - texture(vid); - - // Draw the rectangle. - rect(-40, -40, 80, 80); - } - -
- -
- - let vid; - - // Load a video and create a p5.MediaElement object. - function preload() { - vid = createVideo('/assets/fingers.mov'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - // Hide the video. - vid.hide(); - - // Set the video to loop. - vid.loop(); - - describe('A rectangle with video as texture'); - } - - function draw() { - background(0); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Set the texture mode. - textureMode(NORMAL); - - // Apply the video as a texture. - texture(vid); - - // Draw a custom shape using uv coordinates. - beginShape(); - vertex(-40, -40, 0, 0); - vertex(40, -40, 1, 0); - vertex(40, 40, 1, 1); - vertex(-40, 40, 0, 1); - endShape(); - } - -
-class: p5 -params: - - name: tex - description: | -

media to use as the texture.

- type: >- - p5.Image|p5.MediaElement|p5.Graphics|p5.Texture|p5.Framebuffer|p5.FramebufferTexture -chainable: true ---- - - -# texture diff --git a/src/content/reference/en/p5 copy/textureMode.mdx b/src/content/reference/en/p5 copy/textureMode.mdx deleted file mode 100644 index 397d1856b9..0000000000 --- a/src/content/reference/en/p5 copy/textureMode.mdx +++ /dev/null @@ -1,254 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L1903 -title: textureMode -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Changes the coordinate system used for textures when they’re applied to - - custom shapes.

- -

In order for texture() to work, a - shape needs a - - way to map the points on its surface to the pixels in an image. Built-in - - shapes such as rect() and - - box() already have these texture mappings - based on - - their vertices. Custom shapes created with - - vertex() require texture mappings to be - passed as - - uv coordinates.

- -

Each call to vertex() must include 5 - arguments, - - as in vertex(x, y, z, u, v), to map the vertex at coordinates - (x, y, z) - - to the pixel at coordinates (u, v) within an image. For example, - the - - corners of a rectangular image are mapped to the corners of a rectangle by - default:

- -
// Apply the image as a texture.
-
-  texture(img);
-
-
-  // Draw the rectangle.
-
-  rect(0, 0, 30, 50);
-
-  
- -

If the image in the code snippet above has dimensions of 300 x 500 pixels, - - the same result could be achieved as follows:

- -
// Apply the image as a texture.
-
-  texture(img);
-
-
-  // Draw the rectangle.
-
-  beginShape();
-
-
-  // Top-left.
-
-  // u: 0, v: 0
-
-  vertex(0, 0, 0, 0, 0);
-
-
-  // Top-right.
-
-  // u: 300, v: 0
-
-  vertex(30, 0, 0, 300, 0);
-
-
-  // Bottom-right.
-
-  // u: 300, v: 500
-
-  vertex(30, 50, 0, 300, 500);
-
-
-  // Bottom-left.
-
-  // u: 0, v: 500
-
-  vertex(0, 50, 0, 0, 500);
-
-
-  endShape();
-
-  
- -

textureMode() changes the coordinate system for uv - coordinates.

- -

The parameter, mode, accepts two possible constants. If - NORMAL is - - passed, as in textureMode(NORMAL), then the texture’s uv - coordinates can - - be provided in the range 0 to 1 instead of the image’s dimensions. This can - - be helpful for using the same code for multiple images of different sizes. - - For example, the code snippet above could be rewritten as follows:

- -
// Set the texture mode to use normalized
-  coordinates.
-
-  textureMode(NORMAL);
-
-
-  // Apply the image as a texture.
-
-  texture(img);
-
-
-  // Draw the rectangle.
-
-  beginShape();
-
-
-  // Top-left.
-
-  // u: 0, v: 0
-
-  vertex(0, 0, 0, 0, 0);
-
-
-  // Top-right.
-
-  // u: 1, v: 0
-
-  vertex(30, 0, 0, 1, 0);
-
-
-  // Bottom-right.
-
-  // u: 1, v: 1
-
-  vertex(30, 50, 0, 1, 1);
-
-
-  // Bottom-left.
-
-  // u: 0, v: 1
-
-  vertex(0, 50, 0, 0, 1);
-
-
-  endShape();
-
-  
- -

By default, mode is IMAGE, which scales uv - coordinates to the - - dimensions of the image. Calling textureMode(IMAGE) applies the - default.

- -

Note: textureMode() can only be used in WebGL mode.

-line: 1903 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load an image and create a p5.Image object. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('An image of a ceiling against a black background.'); - } - - function draw() { - background(0); - - // Apply the image as a texture. - texture(img); - - // Draw the custom shape. - // Use the image's width and height as uv coordinates. - beginShape(); - vertex(-30, -30, 0, 0); - vertex(30, -30, img.width, 0); - vertex(30, 30, img.width, img.height); - vertex(-30, 30, 0, img.height); - endShape(); - } - -
- -
- - let img; - - // Load an image and create a p5.Image object. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('An image of a ceiling against a black background.'); - } - - function draw() { - background(0); - - // Set the texture mode. - textureMode(NORMAL); - - // Apply the image as a texture. - texture(img); - - // Draw the custom shape. - // Use normalized uv coordinates. - beginShape(); - vertex(-30, -30, 0, 0); - vertex(30, -30, 1, 0); - vertex(30, 30, 1, 1); - vertex(-30, 30, 0, 1); - endShape(); - } - -
-class: p5 -params: - - name: mode - description: | -

either IMAGE or NORMAL.

- type: Constant -chainable: false ---- - - -# textureMode diff --git a/src/content/reference/en/p5 copy/textureWrap.mdx b/src/content/reference/en/p5 copy/textureWrap.mdx deleted file mode 100644 index 6734a5325b..0000000000 --- a/src/content/reference/en/p5 copy/textureWrap.mdx +++ /dev/null @@ -1,370 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/material.js#L2082 -title: textureWrap -module: 3D -submodule: Material -file: src/webgl/material.js -description: > -

Changes the way textures behave when a shape’s uv coordinates go beyond the - - texture.

- -

In order for texture() to work, a - shape needs a - - way to map the points on its surface to the pixels in an image. Built-in - - shapes such as rect() and - - box() already have these texture mappings - based on - - their vertices. Custom shapes created with - - vertex() require texture mappings to be - passed as - - uv coordinates.

- -

Each call to vertex() must include 5 - arguments, - - as in vertex(x, y, z, u, v), to map the vertex at coordinates - (x, y, z) - - to the pixel at coordinates (u, v) within an image. For example, - the - - corners of a rectangular image are mapped to the corners of a rectangle by - default:

- -
// Apply the image as a texture.
-
-  texture(img);
-
-
-  // Draw the rectangle.
-
-  rect(0, 0, 30, 50);
-
-  
- -

If the image in the code snippet above has dimensions of 300 x 500 pixels, - - the same result could be achieved as follows:

- -
// Apply the image as a texture.
-
-  texture(img);
-
-
-  // Draw the rectangle.
-
-  beginShape();
-
-
-  // Top-left.
-
-  // u: 0, v: 0
-
-  vertex(0, 0, 0, 0, 0);
-
-
-  // Top-right.
-
-  // u: 300, v: 0
-
-  vertex(30, 0, 0, 300, 0);
-
-
-  // Bottom-right.
-
-  // u: 300, v: 500
-
-  vertex(30, 50, 0, 300, 500);
-
-
-  // Bottom-left.
-
-  // u: 0, v: 500
-
-  vertex(0, 50, 0, 0, 500);
-
-
-  endShape();
-
-  
- -

textureWrap() controls how textures behave when their uv's go - beyond the - - texture. Doing so can produce interesting visual effects such as tiling. - - For example, the custom shape above could have u-coordinates are greater - - than the image’s width:

- -
// Apply the image as a texture.
-
-  texture(img);
-
-
-  // Draw the rectangle.
-
-  beginShape();
-
-  vertex(0, 0, 0, 0, 0);
-
-
-  // Top-right.
-
-  // u: 600
-
-  vertex(30, 0, 0, 600, 0);
-
-
-  // Bottom-right.
-
-  // u: 600
-
-  vertex(30, 50, 0, 600, 500);
-
-
-  vertex(0, 50, 0, 0, 500);
-
-  endShape();
-
-  
- -

The u-coordinates of 600 are greater than the texture image’s width of 300. - - This creates interesting possibilities.

- -

The first parameter, wrapX, accepts three possible constants. - If CLAMP - - is passed, as in textureWrap(CLAMP), the pixels at the edge of - the - - texture will extend to the shape’s edges. If REPEAT is passed, as - in - - textureWrap(REPEAT), the texture will tile repeatedly until - reaching the - - shape’s edges. If MIRROR is passed, as in - textureWrap(MIRROR), the - - texture will tile repeatedly until reaching the shape’s edges, flipping - - its orientation between tiles. By default, textures CLAMP.

- -

The second parameter, wrapY, is optional. It accepts the same - three - - constants, CLAMP, REPEAT, and MIRROR. - If one of these constants is - - passed, as in textureWRAP(MIRROR, REPEAT), then the texture will - MIRROR - - horizontally and REPEAT vertically. By default, - wrapY will be set to - - the same value as wrapX.

- -

Note: textureWrap() can only be used in WebGL mode.

-line: 2082 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - function preload() { - img = loadImage('/assets/rockies128.jpg'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'An image of a landscape occupies the top-left corner of a square. Its edge colors smear to cover the other thre quarters of the square.' - ); - } - - function draw() { - background(0); - - // Set the texture mode. - textureMode(NORMAL); - - // Set the texture wrapping. - // Note: CLAMP is the default mode. - textureWrap(CLAMP); - - // Apply the image as a texture. - texture(img); - - // Style the shape. - noStroke(); - - // Draw the shape. - // Use uv coordinates > 1. - beginShape(); - vertex(-30, -30, 0, 0, 0); - vertex(30, -30, 0, 2, 0); - vertex(30, 30, 0, 2, 2); - vertex(-30, 30, 0, 0, 2); - endShape(); - } - -
- -
- - let img; - - function preload() { - img = loadImage('/assets/rockies128.jpg'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('Four identical images of a landscape arranged in a grid.'); - } - - function draw() { - background(0); - - // Set the texture mode. - textureMode(NORMAL); - - // Set the texture wrapping. - textureWrap(REPEAT); - - // Apply the image as a texture. - texture(img); - - // Style the shape. - noStroke(); - - // Draw the shape. - // Use uv coordinates > 1. - beginShape(); - vertex(-30, -30, 0, 0, 0); - vertex(30, -30, 0, 2, 0); - vertex(30, 30, 0, 2, 2); - vertex(-30, 30, 0, 0, 2); - endShape(); - } - -
- -
- - let img; - - function preload() { - img = loadImage('/assets/rockies128.jpg'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'Four identical images of a landscape arranged in a grid. The images are reflected horizontally and vertically, creating a kaleidoscope effect.' - ); - } - - function draw() { - background(0); - - // Set the texture mode. - textureMode(NORMAL); - - // Set the texture wrapping. - textureWrap(MIRROR); - - // Apply the image as a texture. - texture(img); - - // Style the shape. - noStroke(); - - // Draw the shape. - // Use uv coordinates > 1. - beginShape(); - vertex(-30, -30, 0, 0, 0); - vertex(30, -30, 0, 2, 0); - vertex(30, 30, 0, 2, 2); - vertex(-30, 30, 0, 0, 2); - endShape(); - } - -
- -
- - let img; - - function preload() { - img = loadImage('/assets/rockies128.jpg'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'Four identical images of a landscape arranged in a grid. The top row and bottom row are reflections of each other.' - ); - } - - function draw() { - background(0); - - // Set the texture mode. - textureMode(NORMAL); - - // Set the texture wrapping. - textureWrap(REPEAT, MIRROR); - - // Apply the image as a texture. - texture(img); - - // Style the shape. - noStroke(); - - // Draw the shape. - // Use uv coordinates > 1. - beginShape(); - vertex(-30, -30, 0, 0, 0); - vertex(30, -30, 0, 2, 0); - vertex(30, 30, 0, 2, 2); - vertex(-30, 30, 0, 0, 2); - endShape(); - } - -
-class: p5 -params: - - name: wrapX - description: | -

either CLAMP, REPEAT, or MIRROR

- type: Constant - - name: wrapY - description: | -

either CLAMP, REPEAT, or MIRROR

- type: Constant - optional: true -chainable: false ---- - - -# textureWrap diff --git a/src/content/reference/en/p5 copy/tint.mdx b/src/content/reference/en/p5 copy/tint.mdx deleted file mode 100644 index e99dee4431..0000000000 --- a/src/content/reference/en/p5 copy/tint.mdx +++ /dev/null @@ -1,201 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/loading_displaying.js#L1192 -title: tint -module: Image -submodule: Loading & Displaying -file: src/image/loading_displaying.js -description: > -

Tints images using a color.

- -

The version of tint() with one parameter interprets it one of - four ways. - - If the parameter is a number, it's interpreted as a grayscale value. If the - - parameter is a string, it's interpreted as a CSS color string. An array of - - [R, G, B, A] values or a p5.Color object can - - also be used to set the tint color.

- -

The version of tint() with two parameters uses the first one - as a - - grayscale value and the second as an alpha value. For example, calling - - tint(255, 128) will make an image 50% transparent.

- -

The version of tint() with three parameters interprets them as - RGB or - - HSB values, depending on the current - - colorMode(). The optional fourth - parameter - - sets the alpha value. For example, tint(255, 0, 0, 100) will give - images - - a red tint and make them transparent.

-line: 1192 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Left image. - image(img, 0, 0); - - // Right image. - // Tint with a CSS color string. - tint('red'); - image(img, 50, 0); - - describe('Two images of an umbrella and a ceiling side-by-side. The image on the right has a red tint.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Left image. - image(img, 0, 0); - - // Right image. - // Tint with RGB values. - tint(255, 0, 0); - image(img, 50, 0); - - describe('Two images of an umbrella and a ceiling side-by-side. The image on the right has a red tint.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Left. - image(img, 0, 0); - - // Right. - // Tint with RGBA values. - tint(255, 0, 0, 100); - image(img, 50, 0); - - describe('Two images of an umbrella and a ceiling side-by-side. The image on the right has a transparent red tint.'); - } - -
- -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Left. - image(img, 0, 0); - - // Right. - // Tint with grayscale and alpha values. - tint(255, 180); - image(img, 50, 0); - - describe('Two images of an umbrella and a ceiling side-by-side. The image on the right is transparent.'); - } - -
-class: p5 -overloads: - - line: 1192 - params: - - name: v1 - description: | -

red or hue value.

- type: Number - - name: v2 - description: | -

green or saturation value.

- type: Number - - name: v3 - description: | -

blue or brightness.

- type: Number - - name: alpha - description: '' - type: Number - optional: true - - line: 1318 - params: - - name: value - description: | -

CSS color string.

- type: String - - line: 1323 - params: - - name: gray - description: | -

grayscale value.

- type: Number - - name: alpha - description: '' - type: Number - optional: true - - line: 1329 - params: - - name: values - description: | -

array containing the red, green, blue & - alpha components of the color.

- type: 'Number[]' - - line: 1335 - params: - - name: color - description: | -

the tint color

- type: p5.Color -chainable: false ---- - - -# tint diff --git a/src/content/reference/en/p5 copy/torus.mdx b/src/content/reference/en/p5 copy/torus.mdx deleted file mode 100644 index f0e2740d59..0000000000 --- a/src/content/reference/en/p5 copy/torus.mdx +++ /dev/null @@ -1,200 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/webgl/3d_primitives.js#L2183 -title: torus -module: Shape -submodule: 3D Primitives -file: src/webgl/3d_primitives.js -description: > -

Draws a torus.

- -

A torus is a 3D shape with triangular faces that connect to form a ring. - - Toruses with few faces look flattened. Toruses with many faces have smooth - - surfaces.

- -

The first parameter, radius, is optional. If a - Number is passed, as in - - torus(30), it sets the radius of the ring. By default, - radius is 50.

- -

The second parameter, tubeRadius, is also optional. If a - Number is - - passed, as in torus(30, 15), it sets the radius of the tube. By - default, - - tubeRadius is 10.

- -

The third parameter, detailX, is also optional. If a - Number is passed, - - as in torus(30, 15, 5), it sets the number of edges used to draw - the hole - - of the torus. Using more edges makes the hole look more like a circle. By - - default, detailX is 24.

- -

The fourth parameter, detailY, is also optional. If a - Number is passed, - - as in torus(30, 15, 5, 7), it sets the number of triangle - subdivisions to - - use while filling in the torus’ height. By default, detailY is - 16.

- -

Note: torus() can only be used in WebGL mode.

-line: 2183 -isConstructor: false -itemtype: method -example: - - |- - -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white torus on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the torus. - torus(); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white torus on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the torus. - // Set its radius to 30. - torus(30); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white torus on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the torus. - // Set its radius to 30 and tubeRadius to 15. - torus(30, 15); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white torus on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the torus. - // Set its radius to 30 and tubeRadius to 15. - // Set its detailX to 5. - torus(30, 15, 5); - } - -
- -
- - // Click and drag the mouse to view the scene from different angles. - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white torus on a gray background.'); - } - - function draw() { - background(200); - - // Enable orbiting with the mouse. - orbitControl(); - - // Draw the torus. - // Set its radius to 30 and tubeRadius to 15. - // Set its detailX to 5. - // Set its detailY to 3. - torus(30, 15, 5, 3); - } - -
-class: p5 -params: - - name: radius - description: | -

radius of the torus. Defaults to 50.

- type: Number - optional: true - - name: tubeRadius - description: | -

radius of the tube. Defaults to 10.

- type: Number - optional: true - - name: detailX - description: | -

number of edges that form the hole. Defaults to 24.

- type: Integer - optional: true - - name: detailY - description: | -

number of triangle subdivisions along the y-axis. Defaults to 16.

- type: Integer - optional: true -chainable: true ---- - - -# torus diff --git a/src/content/reference/en/p5 copy/touchEnded.mdx b/src/content/reference/en/p5 copy/touchEnded.mdx deleted file mode 100644 index aebb308dc1..0000000000 --- a/src/content/reference/en/p5 copy/touchEnded.mdx +++ /dev/null @@ -1,196 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/touch.js#L468 -title: touchEnded -module: Events -submodule: Touch -file: src/events/touch.js -description: > -

A function that's called once each time a screen touch ends.

- -

Declaring the function touchEnded() sets a code block to run - - automatically when the user stops touching a touchscreen device:

- -
function touchEnded() {
-    // Code to run.
-  }
-
-  
- -

The touches array will be updated with - the most - - recent touch points when touchEnded() is called by p5.js:

- -
function touchEnded() {
-    // Paint over the background.
-    background(200);
-
-    // Mark each remaining touch point when the user stops
-    // a touch.
-    for (let touch of touches) {
-      circle(touch.x, touch.y, 40);
-    }
-  }
-
-  
- -

The parameter, event, is optional. touchEnded() will be passed - a - - TouchEvent - - object with properties that describe the touch event:

- -
function touchEnded(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

On touchscreen devices, mouseReleased() will - - run when the user’s touch ends if touchEnded() isn’t declared. If - - touchEnded() is declared, then touchEnded() will run - when a user’s - - touch ends and mouseReleased() - won’t.

- -

Note: touchStarted(), - - touchEnded(), and touchMoved() are all - - related. touchStarted() runs as soon - as the - - user touches a touchscreen device. touchEnded() runs as soon as - the user - - ends a touch. touchMoved() runs - repeatedly as - - the user moves any touch points.

-line: 468 -isConstructor: false -itemtype: method -example: - - |- - -
- - // On a touchscreen device, touch the canvas using one or more fingers - // at the same time. - - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square switches color between black and white each time the user stops touching the screen.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Toggle colors when a touch ends. - function touchEnded() { - if (value === 0) { - value = 255; - } else { - value = 0; - } - } - -
- -
- - // On a touchscreen device, touch the canvas using one or more fingers - // at the same time. - - let bgColor = 50; - let fillColor = 255; - let borderWidth = 0.5; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with the number 0 at the top-center. The number tracks the number of places the user is touching the screen. Circles appear at each touch point and change style in response to events.' - ); - } - - function draw() { - background(bgColor); - - // Style the text. - textAlign(CENTER); - textSize(16); - fill(0); - noStroke(); - - // Display the number of touch points. - text(touches.length, 50, 20); - - // Style the touch points. - fill(fillColor); - stroke(0); - strokeWeight(borderWidth); - - // Display the touch points as circles. - for (let touch of touches) { - circle(touch.x, touch.y, 40); - } - } - - // Set the background color to a random grayscale value. - function touchStarted() { - bgColor = random(80, 255); - } - - // Set the fill color to a random grayscale value. - function touchEnded() { - fillColor = random(0, 255); - } - - // Set the stroke weight. - function touchMoved() { - // Increment the border width. - borderWidth += 0.1; - - // Reset the border width once it's too thick. - if (borderWidth > 20) { - borderWidth = 0.5; - } - } - -
-class: p5 -params: - - name: event - description: | -

optional TouchEvent argument.

- type: TouchEvent - optional: true -chainable: false ---- - - -# touchEnded diff --git a/src/content/reference/en/p5 copy/touchMoved.mdx b/src/content/reference/en/p5 copy/touchMoved.mdx deleted file mode 100644 index 80c23b81f8..0000000000 --- a/src/content/reference/en/p5 copy/touchMoved.mdx +++ /dev/null @@ -1,198 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/touch.js#L295 -title: touchMoved -module: Events -submodule: Touch -file: src/events/touch.js -description: > -

A function that's called when the user touches the screen and moves.

- -

Declaring the function touchMoved() sets a code block to run - - automatically when the user touches a touchscreen device and moves:

- -
function touchMoved() {
-    // Code to run.
-  }
-
-  
- -

The touches array will be updated with - the most - - recent touch points when touchMoved() is called by p5.js:

- -
function touchMoved() {
-    // Paint over the background.
-    background(200);
-
-    // Mark each touch point while the user moves.
-    for (let touch of touches) {
-      circle(touch.x, touch.y, 40);
-    }
-  }
-
-  
- -

The parameter, event, is optional. touchMoved() will be passed - a - - TouchEvent - - object with properties that describe the touch event:

- -
function touchMoved(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

On touchscreen devices, mouseDragged() will - - run when the user’s touch points move if touchMoved() isn’t - declared. If - - touchMoved() is declared, then touchMoved() will run - when a user’s - - touch points move and mouseDragged() - won’t.

- -

Note: touchStarted(), - - touchEnded(), and - - touchMoved() are all related. - - touchStarted() runs as soon as the - user - - touches a touchscreen device. touchEnded() - - runs as soon as the user ends a touch. touchMoved() runs - repeatedly as - - the user moves any touch points.

-line: 295 -isConstructor: false -itemtype: method -example: - - |- - -
- - // On a touchscreen device, touch the canvas using one or more fingers - // at the same time. - - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square becomes lighter when the user touches the screen and moves.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - function touchMoved() { - // Update the grayscale value. - value += 5; - - // Reset the grayscale value. - if (value > 255) { - value = 0; - } - } - -
- -
- - // On a touchscreen device, touch the canvas using one or more fingers - // at the same time. - - let bgColor = 50; - let fillColor = 255; - let borderWidth = 0.5; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with the number 0 at the top-center. The number tracks the number of places the user is touching the screen. Circles appear at each touch point and change style in response to events.' - ); - } - - function draw() { - background(bgColor); - - // Style the text. - textAlign(CENTER); - textSize(16); - fill(0); - noStroke(); - - // Display the number of touch points. - text(touches.length, 50, 20); - - // Style the touch points. - fill(fillColor); - stroke(0); - strokeWeight(borderWidth); - - // Display the touch points as circles. - for (let touch of touches) { - circle(touch.x, touch.y, 40); - } - } - - // Set the background color to a random grayscale value. - function touchStarted() { - bgColor = random(80, 255); - } - - // Set the fill color to a random grayscale value. - function touchEnded() { - fillColor = random(0, 255); - } - - // Set the stroke weight. - function touchMoved() { - // Increment the border width. - borderWidth += 0.1; - - // Reset the border width once it's too thick. - if (borderWidth > 20) { - borderWidth = 0.5; - } - } - -
-class: p5 -params: - - name: event - description: | -

optional TouchEvent argument.

- type: TouchEvent - optional: true -chainable: false ---- - - -# touchMoved diff --git a/src/content/reference/en/p5 copy/touchStarted.mdx b/src/content/reference/en/p5 copy/touchStarted.mdx deleted file mode 100644 index fc33b1f1c5..0000000000 --- a/src/content/reference/en/p5 copy/touchStarted.mdx +++ /dev/null @@ -1,197 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/touch.js#L125 -title: touchStarted -module: Events -submodule: Touch -file: src/events/touch.js -description: > -

A function that's called once each time the user touches the screen.

- -

Declaring a function called touchStarted() sets a code block - to run - - automatically each time the user begins touching a touchscreen device:

- -
function touchStarted() {
-    // Code to run.
-  }
-
-  
- -

The touches array will be updated with - the most - - recent touch points when touchStarted() is called by p5.js:

- -
function touchStarted() {
-    // Paint over the background.
-    background(200);
-
-    // Mark each touch point once with a circle.
-    for (let touch of touches) {
-      circle(touch.x, touch.y, 40);
-    }
-  }
-
-  
- -

The parameter, event, is optional. touchStarted() will be - passed a - - TouchEvent - - object with properties that describe the touch event:

- -
function touchStarted(event) {
-    // Code to run that uses the event.
-    console.log(event);
-  }
-
-  
- -

On touchscreen devices, mousePressed() will - - run when a user’s touch starts if touchStarted() isn’t declared. - If - - touchStarted() is declared, then touchStarted() will - run when a user’s - - touch starts and mousePressed() - won’t.

- -

Note: touchStarted(), touchEnded(), and - - touchMoved() are all related. - - touchStarted() runs as soon as the user touches a touchscreen - device. - - touchEnded() runs as soon as the user - ends a - - touch. touchMoved() runs repeatedly as - the - - user moves any touch points.

-line: 125 -isConstructor: false -itemtype: method -example: - - |- - -
- - // On a touchscreen device, touch the canvas using one or more fingers - // at the same time. - - let value = 0; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with a black square at its center. The inner square switches color between black and white each time the user touches the screen.' - ); - } - - function draw() { - background(200); - - // Style the square. - fill(value); - - // Draw the square. - square(25, 25, 50); - } - - // Toggle colors with each touch. - function touchStarted() { - if (value === 0) { - value = 255; - } else { - value = 0; - } - } - -
- -
- - // On a touchscreen device, touch the canvas using one or more fingers - // at the same time. - - let bgColor = 50; - let fillColor = 255; - let borderWidth = 0.5; - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square with the number 0 at the top-center. The number tracks the number of places the user is touching the screen. Circles appear at each touch point and change style in response to events.' - ); - } - - function draw() { - background(bgColor); - - // Style the text. - textAlign(CENTER); - textSize(16); - fill(0); - noStroke(); - - // Display the number of touch points. - text(touches.length, 50, 20); - - // Style the touch points. - fill(fillColor); - stroke(0); - strokeWeight(borderWidth); - - // Display the touch points as circles. - for (let touch of touches) { - circle(touch.x, touch.y, 40); - } - } - - // Set the background color to a random grayscale value. - function touchStarted() { - bgColor = random(80, 255); - } - - // Set the fill color to a random grayscale value. - function touchEnded() { - fillColor = random(0, 255); - } - - // Set the stroke weight. - function touchMoved() { - // Increment the border width. - borderWidth += 0.1; - - // Reset the border width once it's too thick. - if (borderWidth > 20) { - borderWidth = 0.5; - } - } - -
-class: p5 -params: - - name: event - description: | -

optional TouchEvent argument.

- type: TouchEvent - optional: true -chainable: false ---- - - -# touchStarted diff --git a/src/content/reference/en/p5 copy/touches.mdx b/src/content/reference/en/p5 copy/touches.mdx deleted file mode 100644 index 7ad03e1610..0000000000 --- a/src/content/reference/en/p5 copy/touches.mdx +++ /dev/null @@ -1,102 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/touch.js#L10 -title: touches -module: Events -submodule: Touch -file: src/events/touch.js -description: > -

An Array of all the current touch points on a touchscreen - device.

- -

The touches array is empty by default. When the user touches - their - - screen, a new touch point is tracked and added to the array. Touch points - - are Objects with the following properties:

- -
// Iterate over the touches array.
-
-  for (let touch of touches) {
-    // x-coordinate relative to the top-left
-    // corner of the canvas.
-    console.log(touch.x);
-
-    // y-coordinate relative to the top-left
-    // corner of the canvas.
-    console.log(touch.y);
-
-    // x-coordinate relative to the top-left
-    // corner of the browser.
-    console.log(touch.winX);
-
-    // y-coordinate relative to the top-left
-    // corner of the browser.
-    console.log(touch.winY);
-
-    // ID number
-    console.log(touch.id);
-  }
-
-  
-line: 10 -isConstructor: false -itemtype: property -example: - - |- - -
- - // On a touchscreen device, touch the canvas using one or more fingers - // at the same time. - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square. White circles appear where the user touches the square.' - ); - } - - function draw() { - background(200); - - // Draw a circle at each touch point. - for (let touch of touches) { - circle(touch.x, touch.y, 40); - } - } - -
- -
- - // On a touchscreen device, touch the canvas using one or more fingers - // at the same time. - - function setup() { - createCanvas(100, 100); - - describe( - 'A gray square. Labels appear where the user touches the square, displaying the coordinates.' - ); - } - - function draw() { - background(200); - - // Draw a label above each touch point. - for (let touch of touches) { - text(`${touch.x}, ${touch.y}`, touch.x, touch.y - 40); - } - } - -
-class: p5 -type: 'Object[]' ---- - - -# touches diff --git a/src/content/reference/en/p5 copy/translate.mdx b/src/content/reference/en/p5 copy/translate.mdx deleted file mode 100644 index dd725eb199..0000000000 --- a/src/content/reference/en/p5 copy/translate.mdx +++ /dev/null @@ -1,241 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/transform.js#L1223 -title: translate -module: Transform -submodule: Transform -file: src/core/transform.js -description: > -

Translates the coordinate system.

- -

By default, the origin (0, 0) is at the sketch's top-left - corner in 2D - - mode and center in WebGL mode. The translate() function shifts - the origin - - to a different position. Everything drawn after translate() is - called - - will appear to be shifted. There are two ways to call translate() - with - - parameters that set the origin's position.

- -

The first way to call translate() uses numbers to set the - amount of - - translation. The first two parameters, x and y, set - the amount to - - translate along the positive x- and y-axes. For example, calling - - translate(20, 30) translates the origin 20 pixels along the - x-axis and 30 - - pixels along the y-axis. The third parameter, z, is optional. It - sets the - - amount to translate along the positive z-axis. For example, calling - - translate(20, 30, 40) translates the origin 20 pixels along the - x-axis, - - 30 pixels along the y-axis, and 40 pixels along the z-axis.

- -

The second way to call translate() uses a - - p5.Vector object to set the amount of - - translation. For example, calling translate(myVector) uses the - x-, y-, - - and z-components of myVector to set the amount to translate along - the x-, - - y-, and z-axes. Doing so is the same as calling - - translate(myVector.x, myVector.y, myVector.z).

- -

By default, transformations accumulate. For example, calling - - translate(10, 0) twice has the same effect as calling - - translate(20, 0) once. The push() and - - pop() functions can be used to isolate - - transformations within distinct drawing groups.

- -

Note: Transformations are reset at the beginning of the draw loop. Calling - - translate(10, 0) inside the draw() function won't - - cause shapes to move continuously.

-line: 1223 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A white circle on a gray background.'); - } - - function draw() { - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Draw a circle at coordinates (0, 0). - circle(0, 0, 40); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe( - 'Two circles drawn on a gray background. The blue circle on the right overlaps the red circle at the center.' - ); - } - - function draw() { - background(200); - - // Translate the origin to the center. - translate(50, 50); - - // Draw the red circle. - fill('red'); - circle(0, 0, 40); - - // Translate the origin to the right. - translate(25, 0); - - // Draw the blue circle. - fill('blue'); - circle(0, 0, 40); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A white circle moves slowly from left to right on a gray background.'); - } - - function draw() { - background(200); - - // Calculate the x-coordinate. - let x = frameCount * 0.2; - - // Translate the origin. - translate(x, 50); - - // Draw a circle at coordinates (0, 0). - circle(0, 0, 40); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A white circle on a gray background.'); - } - - function draw() { - background(200); - - // Create a p5.Vector object. - let v = createVector(50, 50); - - // Translate the origin by the vector. - translate(v); - - // Draw a circle at coordinates (0, 0). - circle(0, 0, 40); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe( - 'Two spheres sitting side-by-side on gray background. The sphere at the center is red. The sphere on the right is blue.' - ); - } - - function draw() { - background(200); - - // Turn on the lights. - lights(); - - // Style the spheres. - noStroke(); - - // Draw the red sphere. - fill('red'); - sphere(10); - - // Translate the origin to the right. - translate(30, 0, 0); - - // Draw the blue sphere. - fill('blue'); - sphere(10); - } - -
-class: p5 -overloads: - - line: 1223 - params: - - name: x - description: | -

amount to translate along the positive x-axis.

- type: Number - - name: 'y' - description: | -

amount to translate along the positive y-axis.

- type: Number - - name: z - description: | -

amount to translate along the positive z-axis.

- type: Number - optional: true - chainable: 1 - - line: 1394 - params: - - name: vector - description: | -

vector by which to translate.

- type: p5.Vector - chainable: 1 -chainable: true ---- - - -# translate diff --git a/src/content/reference/en/p5 copy/triangle.mdx b/src/content/reference/en/p5 copy/triangle.mdx deleted file mode 100644 index 08f1afb223..0000000000 --- a/src/content/reference/en/p5 copy/triangle.mdx +++ /dev/null @@ -1,104 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/2d_primitives.js#L1385 -title: triangle -module: Shape -submodule: 2D Primitives -file: src/core/shape/2d_primitives.js -description: > -

Draws a triangle.

- -

A triangle is a three-sided shape defined by three points. The - - first two parameters specify the triangle's first point (x1, y1). - The - - middle two parameters specify its second point (x2, y2). And the - last two - - parameters specify its third point (x3, y3).

-line: 1385 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - triangle(30, 75, 58, 20, 86, 75); - - describe('A white triangle with a black outline on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - triangle(-20, 25, 8, -30, 36, 25); - - describe('A white triangle with a black outline on a gray canvas.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white triangle spins around on a gray canvas.'); - } - - function draw() { - background(200); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Draw the triangle. - triangle(-20, 25, 8, -30, 36, 25); - } - -
-class: p5 -params: - - name: x1 - description: | -

x-coordinate of the first point.

- type: Number - - name: y1 - description: | -

y-coordinate of the first point.

- type: Number - - name: x2 - description: | -

x-coordinate of the second point.

- type: Number - - name: y2 - description: | -

y-coordinate of the second point.

- type: Number - - name: x3 - description: | -

x-coordinate of the third point.

- type: Number - - name: y3 - description: | -

y-coordinate of the third point.

- type: Number -chainable: true ---- - - -# triangle diff --git a/src/content/reference/en/p5 copy/trim.mdx b/src/content/reference/en/p5 copy/trim.mdx deleted file mode 100644 index a782306725..0000000000 --- a/src/content/reference/en/p5 copy/trim.mdx +++ /dev/null @@ -1,113 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/string_functions.js#L916 -title: trim -module: Data -submodule: String Functions -file: src/utilities/string_functions.js -description: > -

Removes whitespace from the start and end of a String without - changing the middle.

- -

trim() trims - - whitespace characters - - such as spaces, carriage returns, tabs, Unicode "nbsp" character.

- -

The parameter, str, is the string to trim. If a single string - is passed, - - as in trim(' pad '), a single string is returned. If an array - of - - strings is passed, as in trim([' pad ', '\n space \n']), an - array of - - strings is returned.

-line: 916 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let string = ' p5*js '; - - // Trim the whitespace. - let trimmed = trim(string); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the text. - text(`Hello, ${trimmed}!`, 50, 50); - - describe('The text "Hello, p5*js!" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of strings. - let strings = [' wide ', '\n open ', '\n spaces ']; - - // Trim the whitespace. - let trimmed = trim(strings); - - // Style the text. - textAlign(CENTER, CENTER); - textFont('Courier New'); - textSize(10); - - // Display the text. - text(`${trimmed[0]} ${trimmed[1]} ${trimmed[2]}`, 50, 50); - - describe('The text "wide open spaces" written in black on a gray background.'); - } - -
-class: p5 -return: - description: trimmed string. - type: String -overloads: - - line: 916 - params: - - name: str - description: | -

string to trim.

- type: String - return: - description: trimmed string. - type: String - - line: 984 - params: - - name: strs - description: | -

strings to trim.

- type: 'String[]' - return: - description: trimmed strings. - type: 'String[]' -chainable: false ---- - - -# trim diff --git a/src/content/reference/en/p5 copy/turnAxis.mdx b/src/content/reference/en/p5 copy/turnAxis.mdx deleted file mode 100644 index e8dc93e115..0000000000 --- a/src/content/reference/en/p5 copy/turnAxis.mdx +++ /dev/null @@ -1,54 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/acceleration.js#L378 -title: turnAxis -module: Events -submodule: Acceleration -file: src/events/acceleration.js -description: > -

When a device is rotated, the axis that triggers the deviceTurned() - - method is stored in the turnAxis variable. The turnAxis variable is only - defined within - - the scope of deviceTurned().

-line: 378 -isConstructor: false -itemtype: property -example: - - |- - -
- - // Run this example on a mobile device - // Rotate the device by 90 degrees in the - // X-axis to change the value. - - let value = 0; - 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') { - if (value === 0) { - value = 255; - } else if (value === 255) { - value = 0; - } - } - } - -
-class: p5 -type: String ---- - - -# turnAxis diff --git a/src/content/reference/en/p5 copy/types/Array.mdx b/src/content/reference/en/p5 copy/types/Array.mdx deleted file mode 100644 index 17fe1c2ed3..0000000000 --- a/src/content/reference/en/p5 copy/types/Array.mdx +++ /dev/null @@ -1,269 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L1140 -title: Array -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: > -

A list that keeps several pieces of data in order.

- -

Arrays are helpful for storing related data. They can contain data of any - - type. For example, an array could contain a list of someone's favorite - - colors as strings. Arrays are created as follows:

- -
let myArray = ['deeppink', 'darkorchid',
-  'magenta'];
-
-  
- -

Each piece of data in an array is called an element. Each element has an - - address, or index, within its array. The variable myArray refers - to an - - array with three String elements, - 'deeppink', - - 'darkorchid', and 'magenta'. Arrays are - zero-indexed, which means - - that 'deeppink' is at index 0, 'darkorchid' is at - index 1, and - - 'magenta' is at index 2. Array elements can be accessed using - their - - indices as follows:

- -
let zeroth = myArray[0]; // 'deeppink'
-
-  let first = myArray[1]; // 'darkorchid'
-
-  let second = myArray[2]; // 'magenta'
-
-  
- -

Elements can be added to the end of an array by calling the - - push() - - method as follows:

- -
myArray.push('lavender');
-
-
-  let third = myArray[3]; // 'lavender'
-
-  
- -

See MDN - - for more information about arrays.

-line: 1140 -isConstructor: false -itemtype: property -example: - - >- - -
- - - - // Declare the variable xCoordinates and assign it an array - - // with three numeric elements. - - let xCoordinates = [25, 50, 75]; - - - function setup() { - createCanvas(100, 100); - - describe( - 'Three white circles drawn in a horizontal line on a gray background.' - ); - } - - - function draw() { - background(200); - - // Access the element at index 0, which is 25. - circle(xCoordinates[0], 50, 20); - - // Access the element at index 1, which is 50. - circle(xCoordinates[1], 50, 20); - - // Access the element at index 2, which is 75. - circle(xCoordinates[2], 50, 20); - } - - - -
- - -
- - - - // Declare the variable xCoordinates and assign it an array with three - numeric elements. - - let xCoordinates = [20, 40, 60]; - - - // Add another element to the end of the array. - - xCoordinates.push(80); - - - function setup() { - createCanvas(100, 100); - - describe('Four white circles drawn in a horizontal line on a gray background.'); - } - - - function draw() { - background(200); - - // Access the element at index 0, which is 20. - circle(xCoordinates[0], 50, 20); - - // Access the element at index 1, which is 40. - circle(xCoordinates[1], 50, 20); - - // Access the element at index 2, which is 60. - circle(xCoordinates[2], 50, 20); - - // Access the element at index 3, which is 80. - circle(xCoordinates[3], 50, 20); - } - - - -
- - -
- - - - // Declare the variable xCoordinates and assign it an empty array. - - let xCoordinates = []; - - - function setup() { - createCanvas(100, 100); - - // Add elements to the array using a loop. - for (let x = 20; x < 100; x += 20) { - xCoordinates.push(x); - } - - describe('Four white circles drawn in a horizontal line on a gray background.'); - } - - - function draw() { - background(200); - - // Access the element at index i and use it to draw a circle. - for (let i = 0; i < xCoordinates.length; i += 1) { - circle(xCoordinates[i], 50, 20); - } - } - - - -
- - -
- - - - // Declare the variable xCoordinates and assign it an empty array. - - let xCoordinates = []; - - - function setup() { - createCanvas(100, 100); - - // Add elements to the array using a loop. - for (let x = 20; x < 100; x += 20) { - xCoordinates.push(x); - } - - describe('Four white circles drawn in a horizontal line on a gray background.'); - } - - - function draw() { - background(200); - - // Access each element of the array and use it to draw a circle. - for (let x of xCoordinates) { - circle(x, 50, 20); - } - } - - - -
- - -
- - - - // Declare the variable xCoordinates and assign it an empty array. - - let xCoordinates = []; - - - function setup() { - createCanvas(100, 100); - - // Add elements to the array using a loop. - for (let x = 20; x < 100; x += 20) { - xCoordinates.push(x); - } - - describe( - 'Four white circles in a horizontal line on a gray background. The circles move randomly.' - ); - } - - - function draw() { - background(200); - - for (let i = 0; i < xCoordinates.length; i += 1) { - // Update the element at index i. - xCoordinates[i] += random(-1, 1); - - // Use the element at index i to draw a circle. - circle(xCoordinates[i], 50, 20); - } - } - - - -
-class: p5 ---- - - -# Array diff --git a/src/content/reference/en/p5 copy/types/Boolean.mdx b/src/content/reference/en/p5 copy/types/Boolean.mdx deleted file mode 100644 index 01d02c8de2..0000000000 --- a/src/content/reference/en/p5 copy/types/Boolean.mdx +++ /dev/null @@ -1,273 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L502 -title: Boolean -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: > -

A value that's either true or false.

- -

Boolean values help to make decisions in code. They appear any - time a - - logical condition is checked. For example, the condition - - "Is a mouse button being pressed?" must be either true or - - false:

- -
// If the user presses the mouse, draw a circle
-  at
-
-  // the mouse's location.
-
-  if (mouseIsPressed === true) {
-    circle(mouseX, mouseY, 20);
-  }
-
-  
- -

The if statement checks whether - - mouseIsPressed is - true and draws a - - circle if it is. Boolean expressions such as mouseIsPressed - === true - - evaluate to one of the two possible Boolean values: - true or false.

- -

The === operator (EQUAL) checks whether two values are equal. - If they - - are, the expression evaluates to true. Otherwise, it evaluates to - - false.

- -

Note: There's also a == operator with two = - instead of three. Don't use - - it.

- -

The mouseIsPressed system - variable is - - always true or false, so the code snippet above - could also be written - - as follows:

- -
if (mouseIsPressed) {
-    circle(mouseX, mouseY, 20);
-  }
-
-  
- -

The !== operator (NOT EQUAL) checks whether two values are not - equal, as - - in the following example:

- -
if (2 + 2 !== 4) {
-    text('War is peace.', 50, 50);
-  }
-
-  
- -

Starting from the left, the arithmetic expression 2 + 2 - produces the - - value 4. The Boolean expression 4 !== 4 - evaluates to false because - - 4 is equal to itself. As a result, the if - statement's body is skipped.

- -

Note: There's also a != operator with one = - instead of two. Don't use - - it.

- -

The Boolean operator && (AND) checks whether two - expressions are both - - true:

- -
if (keyIsPressed === true && key === 'p') {
-    text('You pressed the "p" key!', 50, 50);
-  }
-
-  
- -

If the user is pressing a key AND that key is 'p', then a - message will - - display.

- -

The Boolean operator || (OR) checks whether at - least one of two - - expressions is true:

- -
if (keyIsPressed === true || mouseIsPressed ===
-  true) {
-    text('You did something!', 50, 50);
-  }
-
-  
- -

If the user presses a key, or presses a mouse button, or both, then a - - message will display.

- -

The following truth table summarizes a few common scenarios with - && and - - ||:

- -
true && true  // true
-
-  true && false // false
-
-  false && false // false
-
-  true || true  // true
-
-  true || false // true
-
-  false || false // false
-
-  
- -

The relational operators >, << code="">, - >=, and <=< code=""> also produce Boolean - - values:

- -
2 > 1 // true
-
-  2 < 1 // false
-
-  2 >= 2 // true
-
-  2 <= 2="" true="" <="" code=""/>
- -

See if for more information about - if statements and - - Number for more information about - Numbers.

-line: 502 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('A gray square. When the user presses the mouse, a circle appears at that location.'); - } - - function draw() { - background(200); - - // If the user presses the mouse, draw a circle at that location. - if (mouseIsPressed) { - circle(mouseX, mouseY, 20); - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A gray square. When the user presses the mouse, a circle appears at that location.'); - } - - function draw() { - background(200); - - // If the user presses the mouse, draw a circle at that location. - if (mouseIsPressed === true) { - circle(mouseX, mouseY, 20); - } - } - -
- -
- - // Click on the canvas to begin detecting key presses. - - function setup() { - createCanvas(100, 100); - - describe('A gray square that turns pink when the user presses the mouse or a key.'); - } - - function draw() { - background(200); - - // If the user presses the mouse, change the background color. - if (mouseIsPressed === true || keyIsPressed === true) { - background('deeppink'); - } - } - -
- -
- - // Click the canvas to begin detecting key presses. - - // Create a Boolean variable. - let isPlaying = false; - - function setup() { - createCanvas(100, 100); - - describe( - 'The message "Begin?\nY or N" written in green on a black background. The message "Good luck!" appears when they press the "y" key.' - ); - } - - function draw() { - background(0); - - // Style the text. - textAlign(CENTER, CENTER); - textFont('Courier New'); - textSize(16); - fill(0, 255, 0); - - // Display a different message when the user begins playing. - if (isPlaying === false) { - text('Begin?', 50, 40); - text('Y or N', 50, 60); - } else { - text('Good luck!', 50, 50); - } - } - - // Start playing when the user presses the 'y' key. - function keyPressed() { - if (key === 'y') { - isPlaying = true; - } - } - -
-class: p5 ---- - - -# Boolean diff --git a/src/content/reference/en/p5 copy/types/Number.mdx b/src/content/reference/en/p5 copy/types/Number.mdx deleted file mode 100644 index 3dfa850720..0000000000 --- a/src/content/reference/en/p5 copy/types/Number.mdx +++ /dev/null @@ -1,201 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L853 -title: Number -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: > -

A number that can be positive, negative, or zero.

- -

The Number data type is useful for describing values such as - position, - - size, and color. A number can be an integer such as 20 or a decimal number - - such as 12.34. For example, a circle's position and size can be described - - by three numbers:

- -
circle(50, 50, 20);
-
-  
- -
circle(50, 50, 12.34);
-
-  
- -

Numbers support basic arithmetic and follow the standard order of - - operations: Parentheses, Exponents, Multiplication, Division, Addition, - - and Subtraction (PEMDAS). For example, it's common to use arithmetic - - operators with p5.js' system variables that are numbers:

- -
// Draw a circle at the center.
-
-  circle(width / 2, height / 2, 20);
-
-  
- -
// Draw a circle that moves from left to right.
-
-  circle(frameCount * 0.01, 50, 20);
-
-  
- -

Here's a quick overview of the arithmetic operators:

- -
1 + 2 // Add
-
-  1 - 2 // Subtract
-
-  1 * 2 // Multiply
-
-  1 / 2 // Divide
-
-  1 % 2 // Remainder
-
-  1 ** 2 // Exponentiate
-
-  
- -

It's common to update a number variable using arithmetic. For example, an - - object's location can be updated like so:

- -
x = x + 1;
-
-  
- -

The statement above adds 1 to a variable x using the - + operator. The - - addition assignment operator += expresses the same idea:

- -
x += 1;
-
-  
- -

Here's a quick overview of the assignment operators:

- -
x += 2 // Addition assignment
-
-  x -= 2 // Subtraction assignment
-
-  x *= 2 // Multiplication assignment
-
-  x /= 2 // Division assignment
-
-  x %= 2 // Remainder assignment
-
-  
- -

Numbers can be compared using the - - relational operators - - >, << code="">, >=, <=< code="">, - ===, and !==. For example, a sketch's - - frameCount can be used as a - timer:

- -
if (frameCount > 1000) {
-    text('Game over!', 50, 50);
-  }
-
-  
- -

An expression such as frameCount > 1000 evaluates to a - Boolean value - - that's either true or false. The relational - operators all produce - - Boolean values:

- -
2 > 1 // true
-
-  2 < 1 // false
-
-  2 >= 2 // true
-
-  2 <= 2="" true="" !="=" false="" <="" code=""/>
- -

See Boolean for more information about - comparisons and conditions.

- -

Note: There are also == and != operators with one - fewer =. Don't use them.

- -

Expressions with numbers can also produce special values when something - - goes wrong:

- -
sqrt(-1) // NaN
-
-  1 / 0 // Infinity
-
-  
- -

The value NaN stands for - - Not-A-Number. - - NaN appears when calculations or conversions don't work. - Infinity is a - - value that's larger than any number. It appears during certain - - calculations.

-line: 853 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Draw a circle at the center. - circle(50, 50, 70); - - // Draw a smaller circle at the center. - circle(width / 2, height / 2, 30); - - describe('Two concentric, white circles drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - describe('A white circle travels from left to right on a gray background.'); - } - - function draw() { - background(200); - - circle(frameCount * 0.05, 50, 20); - } - -
-class: p5 ---- - - -# Number diff --git a/src/content/reference/en/p5 copy/types/Object.mdx b/src/content/reference/en/p5 copy/types/Object.mdx deleted file mode 100644 index c5c9adf8bb..0000000000 --- a/src/content/reference/en/p5 copy/types/Object.mdx +++ /dev/null @@ -1,91 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L999 -title: Object -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: "

A container for data that's stored as key-value pairs.

\n

Objects help to organize related data of any type, including other objects.\nA value stored in an object can be accessed by name, called its key. Each\nkey-value pair is called a \"property.\" Objects are similar to dictionaries\nin Python and maps in Java and Ruby.

\n

For example, an object could contain the location, size, and appearance of\na dog:

\n
// Declare the dog variable and assign it an object.\nlet dog = { x: 50, y: 50, size: 20, emoji: '\U0001F436' };\n\n// Style the text.\ntextAlign(CENTER, CENTER);\ntextSize(dog.size);\n\n// Draw the dog.\ntext(dog.emoji, dog.x, dog.y);\n
\n

The variable dog is assigned an object with four properties. Objects\nare declared with curly braces {}. Values can be accessed using the dot\noperator, as in dog.size. In the example above, the key size\ncorresponds to the value 20. Objects can also be empty to start:

\n
// Declare a cat variable and assign it an empty object.\nlet cat = {};\n\n// Add properties to the object.\ncat.x = 50;\ncat.y = 50;\ncat.size = 20;\ncat.emoji = '\U0001F431';\n\n// Style the text.\ntextAlign(CENTER, CENTER);\ntextSize(cat.size);\n\n// Draw the cat.\ntext(cat.emoji, cat.x, cat.y);\n
\n

An object's data can be updated while a sketch runs. For example, the cat\ncould run away from the dog by updating its location:

\n
// Run to the right.\ncat.x += 5;\n
\n

If needed, an object's values can be accessed using square brackets []\nand strings instead of dot notation:

\n
// Run to the right.\ncat[\"x\"] += 5;\n
\n

This syntax can be helpful when the key's name has spaces, as in\ncat['height (m)'].

\n" -line: 999 -isConstructor: false -itemtype: property -example: - - |- - -
- - // Declare the variable data and assign it an object with three properties. - let data = { x: 50, y: 50, d: 20 }; - - function setup() { - createCanvas(100, 100); - - describe('A white circle on a gray background.'); - } - - function draw() { - background(200); - - // Access the object's values using the . operator. - circle(data.x, data.y, data.d); - } - -
- -
- - // Declare the variable data and assign it an object with three properties. - let data = { x: 50, y: 50, d: 20 }; - - // Add another property for color. - data.color = 'deeppink'; - - function setup() { - createCanvas(100, 100); - - describe('A pink circle on a gray background.'); - } - - function draw() { - background(200); - - // Access the object's values using the . operator. - fill(data.color); - circle(data.x, data.y, data.d); - } - -
- -
- - // Declare the variable data and assign it an object with three properties. - let data = { x: 50, y: 50, d: 20 }; - - // Add another property for color. - data.color = 'deeppink'; - - function setup() { - createCanvas(100, 100); - - describe('A white circle on a gray background.'); - } - - function draw() { - background(200); - - // Access the object's values using the . operator. - fill(data.color); - circle(data.x, data.y, data.d); - - // Update the object's x and y properties. - data.x += random(-1, 1); - data.y += random(-1, 1); - } - -
-class: p5 ---- - - -# Object diff --git a/src/content/reference/en/p5 copy/types/String.mdx b/src/content/reference/en/p5 copy/types/String.mdx deleted file mode 100644 index e62a9a8b9c..0000000000 --- a/src/content/reference/en/p5 copy/types/String.mdx +++ /dev/null @@ -1,153 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L710 -title: String -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: > -

A sequence of text characters.

- -

The String data type is helpful for working with text. For - example, a - - string could contain a welcome message:

- -
// Use a string literal.
-
-  text('Hello!', 10, 10);
-
-  
- -
// Create a string variable.
-
-  let message = 'Hello!';
-
-
-  // Use the string variable.
-
-  text(message, 10, 10);
-
-  
- -

The most common way to create strings is to use some form of quotations as - - follows:

- -
text("hi", 50, 50);
-
-  
- -
text('hi', 50, 50);
-
-  
- -
text(`hi`, 50, 50);
-
-  
- -

"hi", 'hi', and hi are all string - literals. A "literal" means a - - value was actually written, as in text('hi', 50, 50). By - contrast, - - text(message, 50, 50) uses the variable message, so - it isn't a string - - literal.

- -

Single quotes '' and double quotes "" mean the - same thing. It's nice to - - have the option for cases when a string contains one type of quote:

- -
text("What's up?", 50, 50);
-
-  
- -
text('Air quotes make you look "cool."', 50,
-  50);
-
-  
- -

Backticks `` create template literals. Template literals have - many uses. - - For example, they can contain both single and double quotes as needed:

- -
text(`"Don't you forget about me"`,  10, 10);
-
-  
- -

Template literals are helpful when strings are created from variables like - - so:

- -
let size = random(10, 20);
-
-  circle(50, 50, size);
-
-
-  text(`The circle's diameter is ${size} pixels.`,  10, 10);
-
-  
- -

The size variable's value will replace ${size} - when the string is - - created. ${} is a placeholder for any value. That means an - expression can - - be used, as in ${round(PI, 3)}. All of the following are valid - template - - literals:

- -
text(`π is about ${round(PI, 2)} pixels.`,  10,
-  10);
-
-  text(`It's ${mouseX < width / 2} that I'm on the left half of the canvas.`, 
-  10, 30);
-
-  
- -

Template literals can include several variables:

- -
let x = random(0, 100);
-
-  let y = random(0, 100);
-
-  let size = random(10, 20);
-
-  circle(x, y, size);
-
-
-  text(`The circle at (${x}, ${y}) has a diameter of ${size} pixels.`,  10, 10);
-
-  
- -

Template literals are also helpful for creating multi-line text like - so:

- -
let poem = `My sketch doesn't run;
-
-  it waits for me patiently
-
-  while bugs point the way.`;
-
-
-  text(poem, 10, 10);
-
-  
-line: 710 -isConstructor: false -itemtype: property -example: - - "\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Style the text.\n textAlign(CENTER, CENTER);\n textSize(20);\n\n // Display a welcome message.\n text('Hello!', 50, 50);\n\n describe('The text \"Hello!\" written on a gray background.');\n}\n\n
\n\n
\n\nfunction setup() {\n createCanvas(100, 100);\n\n background(200);\n\n // Style the text.\n textAlign(CENTER, CENTER);\n textSize(20);\n\n // Create a string variable.\n let world = '\U0001F30D';\n\n // Display a welcome message using a template string.\n text(`Hello, ${world}!`, 50, 50);\n\n describe('The text \"Hello, \U0001F30D!\" written on a gray background.');\n}\n\n
" -class: p5 ---- - - -# String diff --git a/src/content/reference/en/p5 copy/unchar.mdx b/src/content/reference/en/p5 copy/unchar.mdx deleted file mode 100644 index 8ef044b393..0000000000 --- a/src/content/reference/en/p5 copy/unchar.mdx +++ /dev/null @@ -1,114 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L731 -title: unchar -module: Data -submodule: Conversion -file: src/utilities/conversion.js -description: > -

Converts a single-character String to a - Number.

- -

unchar() converts single-character strings to their - corresponding - - integer (whole number).

- -

The parameter, n, is the character to convert. For example, - - unchar('A'), returns the number 65. If an array is passed, as in - - unchar(['A', 'B', 'C']), an array of integers is returned.

-line: 731 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a string variable. - let original = 'A'; - - // Convert the string to a number. - let converted = unchar(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the original and converted values. - text(`${original} : ${converted}`, 50, 50); - - describe('The text "A : 65" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of characters. - let original = ['A', 'B', 'C']; - - // Convert the string to a number. - let converted = unchar(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Iterate over elements of the converted array. - for (let i = 0; i < converted.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 25; - - // Display the original and converted values. - text(`${original[i]} : ${converted[i]}`, 50, y); - } - - describe( - 'The text "A : 65", "B : 66", and "C :67" written on three separate lines. The text is in black on a gray background.' - ); - } - -
-class: p5 -return: - description: converted number. - type: Number -overloads: - - line: 731 - params: - - name: 'n' - description: | -

value to convert.

- type: String - return: - description: converted number. - type: Number - - line: 805 - params: - - name: ns - description: | -

values to convert.

- type: 'String[]' - return: - description: converted numbers. - type: 'Number[]' -chainable: false ---- - - -# unchar diff --git a/src/content/reference/en/p5 copy/unhex.mdx b/src/content/reference/en/p5 copy/unhex.mdx deleted file mode 100644 index 5c507abc4c..0000000000 --- a/src/content/reference/en/p5 copy/unhex.mdx +++ /dev/null @@ -1,121 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/conversion.js#L956 -title: unhex -module: Data -submodule: Conversion -file: src/utilities/conversion.js -description: > -

Converts a String with a hexadecimal value to a - Number.

- -

unhex() converts a string with its hexadecimal number value to - a number. - - Hexadecimal (hex) numbers are base-16, which means there are 16 unique - - digits. Hex extends the numbers 0–9 with the letters A–F. For example, the - - number 11 (eleven) in base-10 is written as the letter - B in hex.

- -

The first parameter, n, is the hex string to convert. For - example, - - unhex('FF'), returns the number 255. If an array is passed, as in - - unhex(['00', '80', 'FF']), an array of numbers is returned.

-line: 956 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create a a hex string variable - let original = 'FF'; - - // Convert the hex string to a number. - let converted = unhex(original); - - // Style the text. - textAlign(CENTER, CENTER); - textSize(16); - - // Display the original and converted values. - text(`${original} = ${converted}`, 50, 50); - - describe('The text "FF = 255" written in black on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Create an array of numbers. - let original = ['00', '80', 'FF']; - - // Convert the numbers to hex strings. - // Only use two hex digits. - let converted = unhex(original, 2); - - // Style the text. - textAlign(RIGHT, CENTER); - textSize(16); - - // Iterate over the converted values. - for (let i = 0; i < converted.length; i += 1) { - - // Calculate the y-coordinate. - let y = (i + 1) * 25; - - // Display the original and converted values. - text(`${ original[i]} = ${converted[i]}`, 80, y); - } - - describe( - 'The text "00 = 0", "80 = 128", and "FF = 255" written on three separate lines. The text is in black on a gray background.' - ); - } - -
-class: p5 -return: - description: converted number. - type: Number -overloads: - - line: 956 - params: - - name: 'n' - description: | -

value to convert.

- type: String - return: - description: converted number. - type: Number - - line: 1033 - params: - - name: ns - description: | -

values to convert.

- type: 'String[]' - return: - description: converted numbers. - type: 'Number[]' -chainable: false ---- - - -# unhex diff --git a/src/content/reference/en/p5 copy/updatePixels.mdx b/src/content/reference/en/p5 copy/updatePixels.mdx deleted file mode 100644 index 5de892374b..0000000000 --- a/src/content/reference/en/p5 copy/updatePixels.mdx +++ /dev/null @@ -1,94 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/image/pixels.js#L1118 -title: updatePixels -module: Image -submodule: Pixels -file: src/image/pixels.js -description: > -

Updates the canvas with the RGBA values in the - - pixels array.

- -

updatePixels() only needs to be called after changing values - in the - - pixels array. Such changes can be made - directly - - after calling loadPixels() or by - calling - - set().

-line: 1118 -isConstructor: false -itemtype: method -example: - - |- - -
- - let img; - - // Load the image. - function preload() { - img = loadImage('/assets/rockies.jpg'); - } - - function setup() { - createCanvas(100, 100); - - // Display the image. - image(img, 0, 0, 100, 100); - - // Get the pixel density. - let d = pixelDensity(); - - // Calculate the halfway index in the pixels array. - let halfImage = 4 * (d * width) * (d * height / 2); - - // Load the pixels array. - loadPixels(); - - // Copy the top half of the canvas to the bottom. - for (let i = 0; i < halfImage; i += 1) { - pixels[i + halfImage] = pixels[i]; - } - - // Update the canvas. - updatePixels(); - - describe('Two identical images of mountain landscapes, one on top of the other.'); - } - -
-class: p5 -params: - - name: x - description: | -

x-coordinate of the upper-left corner of region - to update.

- type: Number - optional: true - - name: 'y' - description: | -

y-coordinate of the upper-left corner of region - to update.

- type: Number - optional: true - - name: w - description: | -

width of region to update.

- type: Number - optional: true - - name: h - description: | -

height of region to update.

- type: Number - optional: true -chainable: false ---- - - -# updatePixels diff --git a/src/content/reference/en/p5 copy/userStartAudio.mdx b/src/content/reference/en/p5 copy/userStartAudio.mdx deleted file mode 100644 index 076d8537c5..0000000000 --- a/src/content/reference/en/p5 copy/userStartAudio.mdx +++ /dev/null @@ -1,99 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/lib/addons/p5.sound.js#L198 -title: userStartAudio -module: p5.sound -submodule: p5.sound -file: lib/addons/p5.sound.js -description: >- -

It is not only a good practice to give users control over starting - - audio. This policy is enforced by many web browsers, including iOS and - - Google Chrome, which create the Web Audio API's - - Audio Context - - in a suspended state.

- - -

In these browser-specific policies, sound will not play until a user - - interaction event (i.e. mousePressed()) explicitly resumes - - the AudioContext, or starts an audio node. This can be accomplished by - - calling start() on a p5.Oscillator, - - play() on a p5.SoundFile, or simply - - userStartAudio().

- - -

userStartAudio() starts the AudioContext on a user - - gesture. The default behavior will enable audio on any - - mouseUp or touchEnd event. It can also be placed in a specific - - interaction function, such as mousePressed() as in the - - example below. This method utilizes - - StartAudioContext - - , a library by Yotam Mann (MIT Licence, 2016).

-line: 198 -isConstructor: false -itemtype: method -example: - - |- - -
- function setup() { - // mimics the autoplay policy - getAudioContext().suspend(); - - let mySynth = new p5.MonoSynth(); - - // This won't play until the context has resumed - mySynth.play('A6'); - } - function draw() { - background(220); - textAlign(CENTER, CENTER); - text(getAudioContext().state, width/2, height/2); - } - function mousePressed() { - userStartAudio(); - } -
-class: p5 -params: - - name: elements - description: | -

This argument can be an Element, - Selector String, NodeList, p5.Element, - jQuery Element, or an Array of any of those.

- type: Element|Array - optional: true - - name: callback - description: | -

Callback to invoke when the AudioContext - has started

- type: Function - optional: true -return: - description: |- - Returns a Promise that resolves when - the AudioContext state is 'running' - type: Promise -chainable: false ---- - - -# userStartAudio diff --git a/src/content/reference/en/p5 copy/vertex.mdx b/src/content/reference/en/p5 copy/vertex.mdx deleted file mode 100644 index 92d5bb9138..0000000000 --- a/src/content/reference/en/p5 copy/vertex.mdx +++ /dev/null @@ -1,242 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/shape/vertex.js#L1881 -title: vertex -module: Shape -submodule: Vertex -file: src/core/shape/vertex.js -description: > -

Adds a vertex to a custom shape.

- -

vertex() sets the coordinates of vertices drawn between the - - beginShape() and - - endShape() functions.

- -

The first two parameters, x and y, set the x- and - y-coordinates of the - - vertex.

- -

The third parameter, z, is optional. It sets the z-coordinate - of the - - vertex in WebGL mode. By default, z is 0.

- -

The fourth and fifth parameters, u and v, are - also optional. They set - - the u- and v-coordinates for the vertex’s texture when used with - - endShape(). By default, u - and v are both 0.

-line: 1881 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Style the shape. - strokeWeight(3); - - // Start drawing the shape. - // Only draw the vertices. - beginShape(POINTS); - - // Add the vertices. - vertex(30, 20); - vertex(85, 20); - vertex(85, 75); - vertex(30, 75); - - // Stop drawing the shape. - endShape(); - - describe('Four black dots that form a square are drawn on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Start drawing the shape. - beginShape(); - - // Add vertices. - vertex(30, 20); - vertex(85, 20); - vertex(85, 75); - vertex(30, 75); - - // Stop drawing the shape. - endShape(CLOSE); - - describe('A white square on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - background(200); - - // Start drawing the shape. - beginShape(); - - // Add vertices. - vertex(-20, -30, 0); - vertex(35, -30, 0); - vertex(35, 25, 0); - vertex(-20, 25, 0); - - // Stop drawing the shape. - endShape(CLOSE); - - describe('A white square on a gray background.'); - } - -
- -
- - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A white square spins around slowly on a gray background.'); - } - - function draw() { - background(200); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Start drawing the shape. - beginShape(); - - // Add vertices. - vertex(-20, -30, 0); - vertex(35, -30, 0); - vertex(35, 25, 0); - vertex(-20, 25, 0); - - // Stop drawing the shape. - endShape(CLOSE); - } - -
- -
- - let img; - - // Load an image to apply as a texture. - function preload() { - img = loadImage('/assets/laDefense.jpg'); - } - - function setup() { - createCanvas(100, 100, WEBGL); - - describe('A photograph of a ceiling rotates slowly against a gray background.'); - } - - function draw() { - background(200); - - // Rotate around the y-axis. - rotateY(frameCount * 0.01); - - // Style the shape. - noStroke(); - - // Apply the texture. - texture(img); - textureMode(NORMAL); - - // Start drawing the shape - beginShape(); - - // Add vertices. - vertex(-20, -30, 0, 0, 0); - vertex(35, -30, 0, 1, 0); - vertex(35, 25, 0, 1, 1); - vertex(-20, 25, 0, 0, 1); - - // Stop drawing the shape. - endShape(); - } - -
-class: p5 -overloads: - - line: 1881 - params: - - name: x - description: | -

x-coordinate of the vertex.

- type: Number - - name: 'y' - description: | -

y-coordinate of the vertex.

- type: Number - chainable: 1 - - line: 2052 - params: - - name: x - description: '' - type: Number - - name: 'y' - description: '' - type: Number - - name: z - description: | -

z-coordinate of the vertex. Defaults to 0.

- type: Number - optional: true - chainable: 1 - - line: 2059 - params: - - name: x - description: '' - type: Number - - name: 'y' - description: '' - type: Number - - name: z - description: '' - type: Number - optional: true - - name: u - description: | -

u-coordinate of the vertex's texture. Defaults to 0.

- type: Number - optional: true - - name: v - description: | -

v-coordinate of the vertex's texture. Defaults to 0.

- type: Number - optional: true - chainable: 1 -chainable: true ---- - - -# vertex diff --git a/src/content/reference/en/p5 copy/webglVersion.mdx b/src/content/reference/en/p5 copy/webglVersion.mdx deleted file mode 100644 index 1909f94a86..0000000000 --- a/src/content/reference/en/p5 copy/webglVersion.mdx +++ /dev/null @@ -1,105 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L508 -title: webglVersion -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

A String variable with the WebGL version in use.

- -

webglVersion's value equals one of the following string - constants:

- -
    - -
  • WEBGL2 whose value is 'webgl2',
  • - -
  • WEBGL whose value is 'webgl', or
  • - -
  • P2D whose value is 'p2d'. This is the default - for 2D sketches.
  • - -
- -

See setAttributes() for ways to - set the - - WebGL version.

-line: 508 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - background(200); - - // Display the current WebGL version. - text(webglVersion, 42, 54); - - describe('The text "p2d" written in black on a gray background.'); - } - -
- -
- - let font; - - function preload() { - // Load a font to use. - font = loadFont('/assets/inconsolata.otf'); - } - - function setup() { - // Create a canvas using WEBGL mode. - createCanvas(100, 50, WEBGL); - background(200); - - // Display the current WebGL version. - fill(0); - textFont(font); - text(webglVersion, -15, 5); - - describe('The text "webgl2" written in black on a gray background.'); - } - -
- -
- - let font; - - function preload() { - // Load a font to use. - font = loadFont('/assets/inconsolata.otf'); - } - - function setup() { - // Create a canvas using WEBGL mode. - createCanvas(100, 50, WEBGL); - - // Set WebGL to version 1. - setAttributes({ version: 1 }); - - background(200); - - // Display the current WebGL version. - fill(0); - textFont(font); - text(webglVersion, -14, 5); - - describe('The text "webgl" written in black on a gray background.'); - } - -
-class: p5 -type: String ---- - - -# webglVersion diff --git a/src/content/reference/en/p5 copy/while.mdx b/src/content/reference/en/p5 copy/while.mdx deleted file mode 100644 index 5fdcb2985a..0000000000 --- a/src/content/reference/en/p5 copy/while.mdx +++ /dev/null @@ -1,161 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/reference.js#L1872 -title: while -module: Foundation -submodule: Foundation -file: src/core/reference.js -description: > -

A way to repeat a block of code.

- -

while loops are helpful for repeating statements while a - condition is - - true. They're like if statements that repeat. For - example, a while - - loop makes it easy to express the idea "draw several lines" like so:

- -
// Declare a variable to keep track of
-  iteration.
-
-  let x = 10;
-
-
-  // Repeat as long as x < 100
-
-  while (x < 100) {
-    line(x, 25, x, 75);
-
-    // Increment by 20.
-    x += 20;
-  }
-
-  
- -

The loop's header begins with the keyword while. Loops - generally count up - - or count down as they repeat, or iterate. The statement in parentheses - - x < 100 is a condition the loop checks each time it iterates. If - the - - condition is true, the loop runs the code between the curly - braces {}, - - The code between the curly braces is called the loop's body. If the - - condition is false, the body is skipped and the loop is - stopped.

- -

It's common to create infinite loops accidentally. For example, the - - following loop never stops iterating because it doesn't count up:

- -
// Declare a variable to keep track of
-  iteration.
-
-  let x = 10;
-
-
-  // Repeat as long as x < 100
-
-  while (x < 100) {
-    line(x, 25, x, 75);
-  }
-
-
-  // This should be in the loop's body!
-
-  x += 20;
-
-  
- -

The statement x += 20 appears after the loop's body. That - means the - - variable x is stuck at 10, which is always less - than 100.

- -

while loops are useful when the number of iterations isn't - known in - - advance. For example, concentric circles could be drawn at random - - increments:

- -
let d = 100;
-
-  let minSize = 5;
-
-
-  while (d > minSize) {
-    circle(50, 50, d);
-    d -= random(10);
-  }
-
-  
-line: 1872 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe('Five black vertical lines on a gray background.'); - } - - function draw() { - background(200); - - // Declare a variable to keep track of iteration. - let x = 10; - - // Repeat as long as x < 100 - while (x < 100) { - line(x, 25, x, 75); - - // Increment by 20. - x += 20; - } - } - -
- -
- - function setup() { - createCanvas(100, 100); - - // Slow the frame rate. - frameRate(5); - - describe( - "A gray square with several concentric circles at the center. The circles' sizes decrease at random increments." - ); - } - - function draw() { - background(200); - - let d = 100; - let minSize = 5; - - while (d > minSize) { - circle(50, 50, d); - d -= random(5, 15); - } - } - -
-class: p5 ---- - - -# while diff --git a/src/content/reference/en/p5 copy/width.mdx b/src/content/reference/en/p5 copy/width.mdx deleted file mode 100644 index 0eb6ad07bb..0000000000 --- a/src/content/reference/en/p5 copy/width.mdx +++ /dev/null @@ -1,87 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L812 -title: width -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

A Number variable that stores the width of the canvas in - pixels.

- -

width's default value is 100. Calling - - createCanvas() or - - resizeCanvas() changes the value of - - width. Calling noCanvas() - sets its value to - - 0.

-line: 812 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - background(200); - - // Display the canvas' width. - text(width, 42, 54); - - describe('The number 100 written in black on a gray square.'); - } - -
- -
- - function setup() { - createCanvas(50, 100); - - background(200); - - // Display the canvas' width. - text(width, 21, 54); - - describe('The number 50 written in black on a gray rectangle.'); - } - -
- -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Display the canvas' width. - text(width, 42, 54); - - describe('The number 100 written in black on a gray square. When the mouse is pressed, the square becomes a rectangle and the number becomes 50.'); - } - - // If the mouse is pressed, reisze - // the canvas and display its new - // width. - function mousePressed() { - if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) { - resizeCanvas(50, 100); - background(200); - text(width, 21, 54); - } - } - -
-class: p5 -type: Number ---- - - -# width diff --git a/src/content/reference/en/p5 copy/winMouseX.mdx b/src/content/reference/en/p5 copy/winMouseX.mdx deleted file mode 100644 index ae7dbc3fac..0000000000 --- a/src/content/reference/en/p5 copy/winMouseX.mdx +++ /dev/null @@ -1,61 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L463 -title: winMouseX -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A Number variable that tracks the mouse's horizontal position - within the - - browser.

- -

winMouseX keeps track of the mouse's position relative to the - top-left - - corner of the browser window. For example, if the mouse is 50 pixels from - - the left edge of the browser, then winMouseX will be 50.

- -

On a touchscreen device, winMouseX will hold the x-coordinate - of the most - - recent touch point.

- -

Note: Use mouseX to track the mouse’s - - x-coordinate within the canvas.

-line: 463 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe("A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse."); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the mouse's coordinates within the browser window. - text(`x: ${winMouseX} y: ${winMouseY}`, 50, 50); - } - -
-class: p5 -type: Number ---- - - -# winMouseX diff --git a/src/content/reference/en/p5 copy/winMouseY.mdx b/src/content/reference/en/p5 copy/winMouseY.mdx deleted file mode 100644 index 32c59cba4c..0000000000 --- a/src/content/reference/en/p5 copy/winMouseY.mdx +++ /dev/null @@ -1,61 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/events/mouse.js#L504 -title: winMouseY -module: Events -submodule: Mouse -file: src/events/mouse.js -description: > -

A Number variable that tracks the mouse's vertical position - within the - - browser.

- -

winMouseY keeps track of the mouse's position relative to the - top-left - - corner of the browser window. For example, if the mouse is 50 pixels from - - the top edge of the browser, then winMouseY will be 50.

- -

On a touchscreen device, winMouseY will hold the y-coordinate - of the most - - recent touch point.

- -

Note: Use mouseY to track the mouse’s - - y-coordinate within the canvas.

-line: 504 -isConstructor: false -itemtype: property -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - describe("A gray square. The mouse's x- and y-coordinates are displayed as the user moves the mouse."); - } - - function draw() { - background(200); - - // Style the text. - textAlign(CENTER); - textSize(16); - - // Display the mouse's coordinates within the browser window. - text(`x: ${winMouseX} y: ${winMouseY}`, 50, 50); - } - -
-class: p5 -type: Number ---- - - -# winMouseY diff --git a/src/content/reference/en/p5 copy/windowHeight.mdx b/src/content/reference/en/p5 copy/windowHeight.mdx deleted file mode 100644 index 829ac3d76b..0000000000 --- a/src/content/reference/en/p5 copy/windowHeight.mdx +++ /dev/null @@ -1,43 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L680 -title: windowHeight -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

A Number variable that stores the height of the browser's - viewport.

- -

The layout viewport - - is the area within the browser that's available for drawing.

-line: 680 -isConstructor: false -itemtype: property -alt: This example does not render anything. -example: - - |- - -
- - function setup() { - // Set the canvas' width and height - // using the browser's dimensions. - createCanvas(windowWidth, windowHeight); - - background(200); - - describe('A gray canvas that takes up the entire browser window.'); - } - -
-class: p5 -type: Number ---- - - -# windowHeight diff --git a/src/content/reference/en/p5 copy/windowResized.mdx b/src/content/reference/en/p5 copy/windowResized.mdx deleted file mode 100644 index aed52e6b4b..0000000000 --- a/src/content/reference/en/p5 copy/windowResized.mdx +++ /dev/null @@ -1,64 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L708 -title: windowResized -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

A function that's called when the browser window is resized.

- -

Code placed in the body of windowResized() will run when the - - browser window's size changes. It's a good place to call - - resizeCanvas() or make other - - adjustments to accommodate the new window size.

- -

The event parameter is optional. If added to the function - declaration, it - - can be used for debugging or other purposes.

-line: 708 -isConstructor: false -itemtype: method -alt: This example does not render anything. -example: - - |- - -
- - function setup() { - createCanvas(windowWidth, windowHeight); - - describe('A gray canvas with a white circle at its center. The canvas takes up the entire browser window. It changes size to match the browser window.'); - } - - function draw() { - background(200); - - // Draw a circle at the center. - circle(width / 2, height / 2, 50); - } - - // Resize the canvas when the - // browser's size changes. - function windowResized() { - resizeCanvas(windowWidth, windowHeight); - } - -
-class: p5 -params: - - name: event - description: | -

optional resize Event.

- type: Event - optional: true -chainable: false ---- - - -# windowResized diff --git a/src/content/reference/en/p5 copy/windowWidth.mdx b/src/content/reference/en/p5 copy/windowWidth.mdx deleted file mode 100644 index 26ec5fc2a9..0000000000 --- a/src/content/reference/en/p5 copy/windowWidth.mdx +++ /dev/null @@ -1,43 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/core/environment.js#L652 -title: windowWidth -module: Environment -submodule: Environment -file: src/core/environment.js -description: > -

A Number variable that stores the width of the browser's - viewport.

- -

The layout viewport - - is the area within the browser that's available for drawing.

-line: 652 -isConstructor: false -itemtype: property -alt: This example does not render anything. -example: - - |- - -
- - function setup() { - // Set the canvas' width and height - // using the browser's dimensions. - createCanvas(windowWidth, windowHeight); - - background(200); - - describe('A gray canvas that takes up the entire browser window.'); - } - -
-class: p5 -type: Number ---- - - -# windowWidth diff --git a/src/content/reference/en/p5 copy/year.mdx b/src/content/reference/en/p5 copy/year.mdx deleted file mode 100644 index 04efa83189..0000000000 --- a/src/content/reference/en/p5 copy/year.mdx +++ /dev/null @@ -1,47 +0,0 @@ ---- -# This file was auto-generated. Please do not edit it manually! -# To make changes, edit the comments in the corresponding source file: -# https://github.com/processing/p5.js/blob/v1.11.13/src/utilities/time_date.js#L311 -title: year -module: IO -submodule: Time & Date -file: src/utilities/time_date.js -description: | -

Returns the current year as a number such as 1999.

-line: 311 -isConstructor: false -itemtype: method -example: - - |- - -
- - function setup() { - createCanvas(100, 100); - - background(200); - - // Get the current year. - let y = year(); - - // Style the text. - textAlign(LEFT, CENTER); - textSize(12); - textFont('Courier New'); - - // Display the year. - text(`Current year: ${y}`, 10, 50, 80); - - describe(`The text 'Current year: ${y}' written in black on a gray background.`); - } - -
-class: p5 -return: - description: current year. - type: Integer -chainable: false ---- - - -# year