pages/public/kronos/docs/particles.html

42 lines
40 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Particles | The Paper Pilot</title>
<meta name="description" content="The Paper Pilot's Digital Garden">
<meta name="generator" content="VitePress v1.2.2">
<link rel="preload stylesheet" href="/assets/style.ClAGozCE.css" as="style">
<script type="module" src="/assets/app.SC8ZDGoI.js"></script>
<link rel="preload" href="/assets/inter-roman-latin.Di8DUHzh.woff2" as="font" type="font/woff2" crossorigin="">
<link rel="modulepreload" href="/assets/chunks/framework.CK8QU5WH.js">
<link rel="modulepreload" href="/assets/chunks/theme.CZl6ZJLI.js">
<link rel="modulepreload" href="/assets/public_kronos_docs_particles.md.acAe5suw.lean.js">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Pacifico&amp;family=Roboto+Mono:ital,wght@0,400;0,600;1,400&amp;display=swap">
<link rel="manifest" href="/site.webmanifest">
<link rel="alternate" type="text/mf2+html" href="/changelog">
<link rel="alternate" type="application/rss+xml" title="Changelog" href="/changelog/rss">
<link rel="alternate" type="application/atom+xml" title="Changelog" href="/changelog/atom">
<link rel="alternate" type="application/json+xml" title="Changelog" href="/changelog/json">
<meta name="og:description" content="The Paper Pilot's Digital Garden">
<script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
<script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
</head>
<body>
<div id="app"><div class="Layout" data-v-90dd949c data-v-5d98c3a5><!--[--><!--[--><!--]--><!--]--><!--[--><span tabindex="-1" data-v-0f60ec36></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-0f60ec36> Skip to content </a><!--]--><!----><header class="VPNav" data-v-5d98c3a5 data-v-ae24b3ad><div class="VPNavBar has-sidebar top" data-v-ae24b3ad data-v-ccf7ddec><div class="wrapper" data-v-ccf7ddec><div class="container" data-v-ccf7ddec><div class="title" data-v-ccf7ddec><div class="VPNavBarTitle has-sidebar" data-v-ccf7ddec data-v-ab179fa1><a class="title" href="/" data-v-ab179fa1><!--[--><!--]--><!----><span data-v-ab179fa1>The Paper Pilot</span><!--[--><!--]--></a></div></div><div class="content" data-v-ccf7ddec><div class="content-body" data-v-ccf7ddec><!--[--><!--]--><div class="VPNavBarSearch search" data-v-ccf7ddec><!--[--><!----><div id="local-search"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><span class="vp-icon DocSearch-Search-Icon"></span><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key"></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div><!--]--></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-ccf7ddec data-v-7f418b0f><span id="main-nav-aria-label" class="visually-hidden" data-v-7f418b0f>Main Navigation</span><!--[--><!--[--><a class="VPLink link vp-external-link-icon VPNavBarMenuLink" href="https://moddingtree.com" target="_blank" rel="noreferrer" tabindex="0" data-v-7f418b0f data-v-9c663999><!--[--><span data-v-9c663999>Profectus</span><!--]--></a><!--]--><!--[--><a class="VPLink link vp-external-link-icon VPNavBarMenuLink" href="https://incremental.social" target="_blank" rel="noreferrer" tabindex="0" data-v-7f418b0f data-v-9c663999><!--[--><span data-v-9c663999>Incremental Social</span><!--]--></a><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-ccf7ddec data-v-e6aabb21><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title="Switch to dark theme" aria-checked="false" data-v-e6aabb21 data-v-d1f28634 data-v-1d5665e3><span class="check" data-v-1d5665e3><span class="icon" data-v-1d5665e3><!--[--><span class="vpi-sun sun" data-v-d1f28634></span><span class="vpi-moon moon" data-v-d1f28634></span><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-ccf7ddec data-v-0394ad82 data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://code.incremental.social/thepaperpilot" aria-label target="_blank" rel="noopener" data-v-7bc22406 data-v-eee4e7cb><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Forgejo</title><path d="M16.7773 0c1.6018 0 2.9004 1.2986 2.9004 2.9005s-1.2986 2.9004-2.9004 2.9004c-1.0854 0-2.0315-.596-2.5288-1.4787H12.91c-2.3322 0-4.2272 1.8718-4.2649 4.195l-.0007 2.1175a7.0759 7.0759 0 0 1 4.148-1.4205l.1176-.001 1.3385.0002c.4973-.8827 1.4434-1.4788 2.5288-1.4788 1.6018 0 2.9004 1.2986 2.9004 2.9005s-1.2986 2.9004-2.9004 2.9004c-1.0854 0-2.0315-.596-2.5288-1.4787H12.91c-2.3322 0-4.2272 1.8718-4.2649 4.195l-.0007 2.319c.8827.4973 1.4788 1.4434 1.4788 2.5287 0 1.602-1.2986 2.9005-2.9005 2.9005-1.6018 0-2.9004-1.2986-2.9004-2.9005 0-1.0853.596-2.0314 1.4788-2.5287l-.0002-9.9831c0-3.887 3.1195-7.0453 6.9915-7.108l.1176-.001h1.3385C14.7458.5962 15.692 0 16.7773 0ZM7.2227 19.9052c-.6596 0-1.1943.5347-1.1943 1.1943s.5347 1.1943 1.1943 1.1943 1.1944-.5347 1.1944-1.1943-.5348-1.1943-1.1944-1.1943Zm9.5546-10.4644c-.6596 0-1.1944.5347-1.1944 1.1943s.5348 1.1943 1.1944 1.1943c.6596 0 1.1943-.5347 1.1943-1.1943s-.5347-1.1943-1.1943-1.1943Zm0-7.7346c-.6596 0-1.1944.5347-1.1944 1.1943s.5348 1.1943 1.1944 1.1943c.6596 0 1.1943-.5347 1.1943-1.1943s-.5347-1.1943-1.1943-1.1943Z"/></svg></a><a class="VPSocialLink no-icon" href="https://matrix.to/#/@thepaperpilot:incremental.social" aria-label target="_blank" rel="noopener" data-v-7bc22406 data-v-eee4e7c
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> myParticle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> image</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;options_wheel.png&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> spread</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">20</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> gravity</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> time</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> speed</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">() { </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Randomize speed a bit</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (Math.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">random</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">() </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">+</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1.2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 8</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> </span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> },</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> etc</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">...</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><p>Features can be functions or constant. These features will be called when each particle is made, with an <code>id</code> argument, which is assigned based on which of the <code>amount</code> particles being spawned this is. <strong>All of these are optional</strong>, with a default value.</p><p>All distances are in pixels and angles are in degrees, with 0 being up and going clockwise.</p><ul><li><p>time: The amount of time, in seconds, that the particle will last. Default is 3.</p></li><li><p>fadeOutTime: The amount of seconds that fading out at the end should take (part of the total lifetime). Default is 1.</p></li><li><p>fadeInTime: The amount of seconds that fading in should take (part of the total lifetime). Default is 0.</p></li><li><p>image: The image the particle should display. <code>&quot;&quot;</code> will display no image. Default is a generic particle.</p></li><li><p>text: Displays text on the particle. Can use basic HTML.</p></li><li><p>style: Lets you apply other CSS styling to the particle.</p></li><li><p>width, height: The dimensions of the particle. Default is 35 and 35.</p></li><li><p>color: Sets the color of the image to this color.</p></li><li><p>angle: The angle that the particle should face. Default is 0.</p></li><li><p>dir: The initial angle that the particles should move in, before spread is factored in. Default is whatever angle is.</p></li><li><p>spread: If there are several particles, they will be spread out by this many degrees, centered on dir. Default is 30.</p></li><li><p>rotation: The amount that the (visual) angle of the particle should change by. Default is 0.</p></li><li><p>speed: The starting speed of the particle. Default is 15.</p></li><li><p>gravity: The amount the particle should accelerate downwards. Default is 0.</p></li><li><p>x, y: The starting coordinates of the particle. Default is at the mouse position.</p></li><li><p>offset: How far from the start each particle should appear. Default is 10.</p></li><li><p>xVel, yVel: Set initially based on other properties, then used to update movement.</p></li><li><p>layer: When changing tabs, if leaving the <code>layer</code> tab, this particle will be erased.</p></li><li><p>You can add other features to particles, but you must impliment their effects yourself.</p></li></ul><p>Function features: These stay as functions and are for more advanced things. They are optional.</p><ul><li>update(): Called each tick. Lets you do more advanced visual and movement behaviors by changing other properties.</li><li>onClick(), onMouseOver(), onMouseLeave(): Called when the particle is interacted with.</li></ul><p>Other useful things that are not features of the particle object:</p><ul><li>setDir(particle, dir), setSpeed(particle, speed): Set the speed/direction on a particle.</li><li>clearParticles(check): Function to delete particles. With no check, it deletes all particles. Check is a function that takes a particle, and returns true if that particle should be deleted.</li><li>You can use Vue.delete(particles, this.id) to make a particle delete itself.</li><li>mouseX and mouseY are variables that track the mouse position.</li><li>sin(x), cos(x), tan(x): functions that do these operations, with x in degrees. (Instead of radians).</li><li>asin(x), acos(x), atan(x): functions that do these operations, with the returned value in degrees. (instead of radians).</li></ul></div></div></main><footer class="VPDocFooter" data-v-39a288b8 data-v-d4a0bba5><!--[--><!--]--><!----><nav class="prev-next" aria-labelledby="doc-footer-aria-label" data-v-d4a0bba5><span class="visually-hidden" id="doc-footer-aria-label" data-v-d4a0bba5>Pager</span><div class="pager" data-v-d4a0bba5><!----></div><div class="pager" data-v-d4a0bba5><a class="VPLink link pager-link next" href="/garden/my-personal-website" data-v-d4a0bba5><!--[--><span class="desc" data-v-d4a0bba5>Next page</span><span class="title" data-v-d4a0bba5>My Personal Website</span><!--]--></a></div></nav></
<script>window.__VP_HASH_MAP__=JSON.parse("{\"garden_guide-to-incrementals_what-is-content_index.md\":\"BMETYiAP\",\"public_gamedevtree_docs_infoboxes.md\":\"9a47XYCg\",\"public_kronos_docs_getting-started.md\":\"mdR9VU7R\",\"public_kronos_docs_infoboxes.md\":\"cE2lKUcU\",\"garden_video-game-monetization_index.md\":\"eY03jnxc\",\"garden_chat-glue_index.md\":\"DaP2yUVG\",\"garden_federated-identity_index.md\":\"DXhML-Yi\",\"guide-to-incrementals_ludology_appeal-gamers_index.md\":\"B6xF3S0w\",\"garden_activitypub_index.md\":\"CicDcQ2_\",\"garden_fedi-v2_index.md\":\"BeyeCI12\",\"garden_opti-speech_index.md\":\"fV3laAf8\",\"garden_capture-the-citadel_index.md\":\"CzfQmks-\",\"garden_cinny_index.md\":\"6lP2Zwso\",\"garden_artificial-intelligence_index.md\":\"DHIZV-Nf\",\"garden_premium-currency_index.md\":\"CYRzDOj_\",\"public_lit_docs_clickables.md\":\"B6OakSbD\",\"garden_atproto_index.md\":\"DbIIfL4R\",\"changelog_index.md\":\"BSJxDqIW\",\"garden_planar-pioneers_index.md\":\"C66vsCjv\",\"garden_social-media_index.md\":\"BbHjayFv\",\"garden_incremental-social_index.md\":\"B0XsBHzM\",\"public_gamedevtree_docs_!general-info.md\":\"BwFSZwbZ\",\"garden_the-indieweb_signature-blocks_index.md\":\"BSUq9f2h\",\"garden_logseq_index.md\":\"BiLoV0bt\",\"garden_chronological_index.md\":\"CQEy-T7E\",\"garden_the-small-web_index.md\":\"oczIBNHW\",\"garden_freeform-vs-chronological-dichotomy_index.md\":\"CC0rVLI6\",\"public_gamedevtree_docs_custom-tab-layouts.md\":\"DO3JHVjV\",\"guide-to-incrementals_index.md\":\"CnOUEXtw\",\"guide-to-incrementals_design_criticism_index.md\":\"DIKhcyDO\",\"garden_ivy-road_index.md\":\"I5lUYnjM\",\"garden_weird_index.md\":\"5UcMgku5\",\"garden_game-dev-tree_index.md\":\"CXDRxuvP\",\"garden_the-indieweb_amplification_index.md\":\"DT2TYsGY\",\"garden_webrings_index.md\":\"DVn_-9-u\",\"garden_kronos_index.md\":\"iUhWCop9\",\"garden_the-cozy-web_index.md\":\"BEzt5FqQ\",\"public_gamedevtree_docs_buyables.md\":\"DlXMZmV4\",\"public_kronos_readme.md\":\"CgBYWZCx\",\"public_gamedevtree_docs_milestones.md\":\"DiBU9uxR\",\"public_gamedevtree_docs_layer-features.md\":\"y6Ef1VMc\",\"garden_my-personal-website_index.md\":\"BhgZsyb6\",\"public_kronos_changelog.md\":\"CfILpf_9\",\"public_gamedevtree_docs_upgrades.md\":\"Msxg1C07\",\"public_gamedevtree_docs_updating-tmt.md\":\"37YMR_q4\",\"public_lit_readme.md\":\"C6r_DD7H\",\"garden_mbin_index.md\":\"BHK-Iuf3\",\"public_kronos_docs_upgrades.md\":\"CTKgTXEi\",\"guide-to-incrementals_ludology_appeal-developers_index.md\":\"Cm_ScJQR\",\"public_lit_docs_!general-info.md\":\"D6KB8CTG\",\"public_kronos_docs_main-mod-info.md\":\"CV8Og8jf\",\"public_kronos_docs_subtabs-and-microtabs.md\":\"CAfP6QpE\",\"public_kronos_docs_layer-features.md\":\"sKwRGXXx\",\"garden_mtx_index.md\":\"BRzkTeai\",\"garden_freeform_index.md\":\"CvO7JCJh\",\"public_gamedevtree_docs_clickables.md\":\"Cyab8uw5\",\"garden_my-projects_index.md\":\"6zAg17w1\",\"garden_guide-to-incrementals_navigating-criticism_index.md\":\"FUIN6tkG\",\"garden_wanderstop_index.md\":\"BTJMeiHB\",\"public_kronos_docs_achievements.md\":\"DH7Fd1ef\",\"garden_profectus_index.md\":\"ykiRoiHE\",\"garden_davey-wreden_index.md\":\"DUU5axE-\",\"garden_dice-armor_index.md\":\"CHYRQr4z\",\"garden_this-knowledge-hub_index.md\":\"CUdFhZdq\",\"garden_pre-order-bonuses_index.md\":\"C0-qMrbr\",\"guide-to-incrementals_ludology_definition_index.md\":\"D2MCMru0\",\"public_lit_docs_trees-and-tree-customization.md\":\"DpLqj7LC\",\"public_lit_docs_subtabs-and-microtabs.md\":\"DhbrQf33\",\"public_kronos_docs_updating-tmt.md\":\"_8lPgb0z\",\"public_lit_docs_milestones.md\":\"Cf2Qcvln\",\"public_lit_docs_layer-features.md\":\"sExHYK2Z\",\"public_lit_docs_main-mod-info.md\":\"CVm1BK0i\",\"public_lit_old things_2.0-format-changes.md\":\"BUbI7CBx\",\"public_lit_docs_infoboxes.md\":\"BuPTImhx\",\"public_kronos_docs_custom-tab-layouts.md\":\"C9uDrIM0\",\"public_lit_docs_upgrades.md\":\"BttvCS4L\",\"public_lit_docs_bars.md\":\"B1h0O1rn\",\"public_kronos_docs_particles.md\":\"acAe5suw\",\"public_lit_docs_challenges.md\":\"BoYK1lsk\",\"public_kronos_docs_
</body>
</html>