Skip to content

Visualize Your Ideas With Code

docs: add blog post (#164)

Jacob884bcb244c9d
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 292abad4..5b74cb22 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,7 +1,7 @@
# Contributing to Motion Canvas
-This is an initial version of the Contribution Guide.
-Feel free to discuss it and suggest any changes on [our discord server][discord].
+This is an initial version of the Contribution Guide. Feel free to discuss it
+and suggest any changes on [our discord server][discord].
## Code of Conduct
@@ -10,20 +10,20 @@ Before contributing to the project, please read our
## Reporting a bug
-Before you submit an issue, please search [the issue tracker][issues].
-An issue for your problem might already exist and the discussion might inform
-you of workarounds readily available.
+Before you submit an issue, please search [the issue tracker][issues]. An issue
+for your problem might already exist and the discussion might inform you of
+workarounds readily available.
-You can file new issues by [selecting an issue template][new-issue] and
-filling out the necessary information.
+You can file new issues by [selecting an issue template][new-issue] and filling
+out the necessary information.
## Proposing a Change
-If you intend to change the public API, or make any non-trivial changes to
-the implementation, make sure to [create an issue][new-feature] first. This
-will let us discuss a proposal before you put significant effort into it.
-After a proposal has been discussed it may receive the [accepted][label-accepted]
-label indicating that it's ready to be implemented.
+If you intend to change the public API, or make any non-trivial changes to the
+implementation, make sure to [create an issue][new-feature] first. This will let
+us discuss a proposal before you put significant effort into it. After a
+proposal has been discussed it may receive the [accepted][label-accepted] label
+indicating that it's ready to be implemented.
If you're only fixing a bug, it's fine to submit a pull request right away
without creating an issue but make sure it contains a clear and concise
@@ -32,18 +32,14 @@ description of said bug.
## Working on Issues
Before you start working on an issue make sure that no one is assigned to it.
-Otherwise, you may duplicate other people's efforts.
-If somebody claims an issue but doesn't follow up for more than two weeks, it’s
-fine to take it over, but you should still leave a comment.
-You should also assign yourself to any issue you're working on, to let others know.
+Otherwise, you may duplicate other people's efforts. If somebody claims an issue
+but doesn't follow up for more than two weeks, it’s fine to take it over, but
+you should still leave a comment. You should also assign yourself to any issue
+you're working on, to let others know.
## Semantic Versioning
Motion Canvas follows [semantic versioning][semver].
-Due to [the limitations of `semantic-release`][semantic-release] the major
-version is not set to zero. Nevertheless, Motion Canvas is still in early
-development and breaking changes are very much expected and welcome. Before
-the public release to npm, the version will be reset back to `1.0.0`.
## Making a Pull Request
@@ -62,8 +58,8 @@ the public release to npm, the version will be reset back to `1.0.0`.
```shell
git push origin my-fix-branch
```
-6. In GitHub, send a pull request to [the master branch][master]
- and **request a review** from [aarthificial](https://github.com/aarthificial).
+6. In GitHub, send a pull request to [the master branch][master] and **request a
+ review** from [aarthificial](https://github.com/aarthificial).
### Addressing review feedback
@@ -81,13 +77,16 @@ This Contribution Guide was partially inspired by [React][react] and
[Angular][angular].
[semver]: https://semver.org/
-[discord]: https://www.patreon.com/posts/53003221
-[semantic-release]: https://semantic-release.gitbook.io/semantic-release/support/faq#can-i-set-the-initial-release-version-of-my-package-to-0.0.1
+[discord]: https://discord.gg/XnnWTrHYAW
+[semantic-release]:
+ https://semantic-release.gitbook.io/semantic-release/support/faq#can-i-set-the-initial-release-version-of-my-package-to-0.0.1
[master]: https://github.com/aarthificial/motion-canvas/tree/master
[issues]: https://github.com/motion-canvas/core/issues
[new-issue]: https://github.com/motion-canvas/core/issues/new/choose
-[new-feature]: https://github.com/motion-canvas/core/issues/new?template=feature_request.md
-[commit-format]: https://github.com/angular/angular/blob/main/CONTRIBUTING.md#commit
+[new-feature]:
+ https://github.com/motion-canvas/core/issues/new?template=feature_request.md
+[commit-format]:
+ https://github.com/angular/angular/blob/main/CONTRIBUTING.md#commit
[angular]: https://github.com/angular/angular/blob/main/CONTRIBUTING.md
[react]: https://reactjs.org/docs/how-to-contribute.html
[label-accepted]: https://github.com/motion-canvas/core/labels/accepted
diff --git a/README.md b/README.md
index 1dc2dfdd..12da2732 100644
--- a/README.md
+++ b/README.md
@@ -2,45 +2,10 @@
[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lerna.js.org/)
-## Disclaimer
-
-The API is a subject to change and may vary drastically in newer versions.
-
-[The current documentation][docs] is still lacking and will be expanded in
-the following weeks.
-
## Using Motion Canvas
Check out the [getting started][docs] guide to learn how to use Motion Canvas.
-### Authenticate to GitHub Packages
-
-[Detailed information on how to authenticate][authenticate].
-
-1. Generate a PAT (Personal Access Token).
- 1. On [github.com](https://github.com),
- go to `Settings` > `Developer settings` > `Personal access tokens`.
- 2. Click `Generate new token`.
- 3. Enter the note for your token, for instance `npm`.
- 4. Choose `read:packages` from the available scopes.
- 5. Click `Generate token`
- 6. Copy the generated token.
-2. Log in using npm
- 1. In your terminal, enter the following command:
- ```shell
- npm login --scope=@motion-canvas --registry=https://npm.pkg.github.com
- ```
- 2. Answer the prompt.
- `Username` is your GitHub username,
- `Password` is the token you just generated.
- `Email` is your GitHub email address.
- For instance:
- ```text
- > Username: Jacob
- > Password: ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- ```
-
## Developing Motion Canvas locally
The project is maintained as one monorepo containing the following packages:
@@ -65,10 +30,11 @@ all necessary dependencies.
When developing the core, start both `core:watch` and `template:serve`.
-This will pick up any changes you make to the core package,
-automatically rebuild the `template` project and refresh the page.
+This will pick up any changes you make to the core package, automatically
+rebuild the `template` project and refresh the page.
-Similarly, when developing the 2D package, start `2d:watch` and `template:serve`.
+Similarly, when developing the 2D package, start `2d:watch` and
+`template:serve`.
### Developing UI
@@ -85,7 +51,8 @@ Then, start `player:serve`.
Read through our [Contribution Guide](./CONTRIBUTING.md) to learn how you can
help make Motion Canvas better.
-[authenticate]: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#authenticating-with-a-personal-access-token
+[authenticate]:
+ https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#authenticating-with-a-personal-access-token
[template]: https://github.com/motion-canvas/project-template#using-the-template
-[discord]: https://www.patreon.com/posts/53003221
-[docs]: https://motion-canvas.github.io/guides/getting-started/quickstart
+[discord]: https://discord.gg/XnnWTrHYAW
+[docs]: https://motion-canvas.github.io/docs/quickstart
diff --git a/packages/docs/blog/2022-07-14-hello-world.mdx b/packages/docs/blog/2022-07-14-hello-world.mdx
deleted file mode 100644
index 136853d8..00000000
--- a/packages/docs/blog/2022-07-14-hello-world.mdx
+++ /dev/null
@@ -1,11 +0,0 @@
----
-slug: hello-world
-title: Hello World!
-authors: aarthificial
----
-
-import YouTubeVideo from '@site/src/components/YouTubeVideo';
-
-Hello World!
-
-<YouTubeVideo src="https://www.youtube.com/embed/WTUafAwrunE" />
diff --git a/packages/docs/blog/2023-02-04-public-release.mdx b/packages/docs/blog/2023-02-04-public-release.mdx
new file mode 100644
index 00000000..02f1863f
--- /dev/null
+++ b/packages/docs/blog/2023-02-04-public-release.mdx
@@ -0,0 +1,19 @@
+---
+slug: public-release
+title: Motion Canvas is now Open Source!
+authors: aarthificial
+---
+
+import YouTubeVideo from '@site/src/components/YouTubeVideo';
+
+After months of work, I'm happy to announce that Motion Canvas is ready for the
+public release!
+
+<YouTubeVideo src="https://www.youtube.com/embed/H5GETOP7ivs" />
+
+Don't get me wrong - the road ahead is still long. Plenty of features left to
+implement and tons of bugs to find and fix. But the foundations are here. Motion
+Canvas helped me make most of my videos last year, and I'm positive some of you
+will find it helpful as well.
+
+Head to the [quickstart](/docs/quickstart) guide and give it a try.
diff --git a/packages/docs/docs/getting-started/quickstart.mdx b/packages/docs/docs/getting-started/quickstart.mdx
index 284bdc90..773957d1 100644
--- a/packages/docs/docs/getting-started/quickstart.mdx
+++ b/packages/docs/docs/getting-started/quickstart.mdx
@@ -13,10 +13,11 @@ In this guide, we'll create a simple animation using Motion Canvas.
### Prerequisites
-Make sure that [Node.js](https://nodejs.org/) version 16 or greater is
-installed on your machine.
+Make sure that [Node.js](https://nodejs.org/) version 16 or greater is installed
+on your machine.
:::tip
+
You can run the following command to check if Node.js is already installed:
```bash
@@ -25,9 +26,6 @@ node -v
:::
-If you're using Motion Canvas as part of the Patreon early access, make sure to
-[authenticate to GitHub Packages][autheticate] first.
-
### Creating a new project
Run the following command in order to scaffold a new Motion Canvas project:
@@ -36,8 +34,8 @@ Run the following command in order to scaffold a new Motion Canvas project:
npm init @motion-canvas
```
-Answer the prompts to name your project and select which language you would
-like to use; either TypeScript or plain JavaScript.
+Answer the prompts to name your project and select which language you would like
+to use; either TypeScript or plain JavaScript.
:::tip
@@ -46,8 +44,8 @@ we're using throughout this documentation.
:::
-To complete the scaffolding process, run the following command in your
-newly created project directory:
+To complete the scaffolding process, run the following command in your newly
+created project directory:
```shell
npm install
@@ -69,8 +67,8 @@ animation, but for now there's not much to see.
The scaffolding command will create several files for you, but for now we're
going to focus on `src/scenes/example.tsx`, which is where we can add our
-animations. Open `example.tsx` in a text editor, and replace all code in
-the file with the following snippet.
+animations. Open `example.tsx` in a text editor, and replace all code in the
+file with the following snippet.
<CodeBlock language="tsx" title="src/scenes/example.tsx">
{source}
@@ -118,10 +116,14 @@ export default makeScene2D(function* (view) {
`makeScene2D()` takes a function generator and turns it into a scene which we
then import in our project file. The function generator describes the flow of
-the animation, while the provided `view` argument is used to add elements to
-the scene.
+the animation, while the provided `view` argument is used to add elements to the
+scene.
-In our example we used a `<Circle/>` node to display a circle on the screen:
+You can learn more about scenes, nodes, and this XML-like syntax in the
+[scene hierarchy](/docs/hierarchy) section. For now, what's important is that,
+in our example, we add an individual [`<Circle/>`](/api/2d/components/Circle)
+node to our scene. We make it red, set its width and height as `320` pixels and
+position it `300` pixels left from the center:
```tsx
view.add(
@@ -136,30 +138,11 @@ view.add(
);
```
-You may recognize this XML-like syntax from libraries such as React.
-That's because Motion Canvas uses the same JavaScript syntax extension called
-[JSX](https://reactjs.org/docs/introducing-jsx.html).
-However, it's important to remember that Motion Canvas does **NOT** use React
-itself and any preconceptions you may have due to React will most likely not
-apply.
-
-A `Circle` is just a class and the above JSX code can be written as:
-
-```ts
-view.add(
- new Circle({
- x: -300,
- width: 240,
- height: 240,
- fill: '#ccc',
- }),
-);
-```
-
-To animate our circle we first need to grab a reference to it.
-That's the purpose of the `createRef` function.
-We use it to create a reference and pass it to our circle using the `ref`
-attribute:
+To animate our circle we first need to
+[grab a reference to it](/docs/references). That's the purpose of the
+[`createRef`](/api/core/utils#createRef) function. We use it to create a
+reference and pass it to our circle using the
+[`ref`](/api/2d/components/NodeProps#ref) attribute:
```tsx
// highlight-next-line
@@ -189,8 +172,8 @@ yield *
This snippet may seem a bit confusing so let's break it down.
-Each property of a node can be read and updated throughout the animation.
-For example, in the circle above we defined its `fill` property as `'#e13238'`:
+Each property of a node can be read and updated throughout the animation. For
+example, in the circle above we defined its `fill` property as `'#e13238'`:
```tsx
<Circle
@@ -215,21 +198,21 @@ We can also update it by passing the new value as the first argument:
myCircle().fill('#e6a700');
```
-This will immediately update the color of our circle.
-If we want to transition to a new value over some time,
-we can pass the transition duration (in seconds) as the second argument:
+This will immediately update the color of our circle. If we want to transition
+to a new value over some time, we can pass the transition duration (in seconds)
+as the second argument:
```ts
myCircle().fill('#e6a700', 1);
```
-This creates a tween animation that smoothly changes the fill color over one
-second.
+This [creates a tween animation](/docs/tweening) that smoothly changes the fill
+color over one second.
-Animations in Motion Canvas don't play on their own, we need to explicitly
-tell them to. This is why scenes are declared using generator functions -
-they serve as a description of how the animation should play out. By yielding
-different instructions we can tell the scene animation to do different things.
+Animations in Motion Canvas don't play on their own, we need to explicitly tell
+them to. This is why scenes are declared using generator functions - they serve
+as a description of how the animation should play out. By yielding different
+instructions we can tell the scene animation to do different things.
For example, to play the tween we created, we can do:
@@ -248,8 +231,8 @@ yield * myCircle().fill('#e6a700', 1);
yield * myCircle().fill('#e13238', 1);
```
-But since we're animating the same property,
-we can write it in a more compact way:
+But since we're animating the same property, we can write it in a more compact
+way:
```ts
yield * myCircle().fill('#e6a700', 1).to('#e13238', 1);
@@ -263,8 +246,8 @@ yield * myCircle().fill('#e6a700', 1).to('#e13238', 1);
yield * myCircle().position.x(300, 1).to(-300, 1);
```
-This works, but the position will start animating **after** the fill color.
-To make them happen at the same time, we use the `all()` function:
+This works, but the position will start animating **after** the fill color. To
+make them happen at the same time, we use the [`all`][all] function:
```ts
yield *
@@ -274,8 +257,9 @@ yield *
);
```
-`all()` takes one or more animations and merges them together.
-Now they'll happen at the same time.
+[`all`][all] takes one or more animations and merges them together. Now they'll
+happen at the same time. The [animation flow](/docs/flow) section goes into more
+depth about generators and flow functions such as [`all`][all].
This brings us back to our initial example:
@@ -283,5 +267,6 @@ This brings us back to our initial example:
{source}
</CodeBlock>
-[generators]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*
-[autheticate]: https://github.com/motion-canvas/motion-canvas#authenticate-to-github-packages
+[generators]:
+ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*
+[all]: /api/core/flow#all
diff --git a/packages/docs/docs/intro.md b/packages/docs/docs/intro.md
index e682415f..aaf51dba 100644
--- a/packages/docs/docs/intro.md
+++ b/packages/docs/docs/intro.md
@@ -19,7 +19,7 @@ the animation that could otherwise be tedious. You can learn more about this
functionality in the [time events](/docs/time-events) section.
Motion Canvas is a free and open source project. You can help making it better
-by reporting bugs, requesting features, or contributing to the codebase. If
+by reporting bugs, proposing new features, or contributing to the codebase. If
you're interested, our [contribution guide][contributing] will help you get
started.
diff --git a/packages/docs/docusaurus.config.js b/packages/docs/docusaurus.config.js
index 87e6294e..acde0814 100644
--- a/packages/docs/docusaurus.config.js
+++ b/packages/docs/docusaurus.config.js
@@ -42,10 +42,16 @@ const config = {
},
{to: '/api/core', label: 'API', position: 'left'},
{to: '/blog', label: 'Blog', position: 'left'},
+ {
+ href: 'https://discord.gg/XnnWTrHYAW',
+ position: 'right',
+ className: 'navbar-icon navbar-discord-link',
+ 'aria-label': 'Discord server',
+ },
{
href: 'https://github.com/motion-canvas/motion-canvas',
position: 'right',
- className: 'navbar-github-link',
+ className: 'navbar-icon navbar-github-link',
'aria-label': 'GitHub repository',
},
],
@@ -76,6 +82,10 @@ const config = {
label: 'YouTube',
href: 'https://youtube.com/aarthificial',
},
+ {
+ label: 'Discord',
+ href: 'https://discord.gg/XnnWTrHYAW',
+ },
],
},
{
diff --git a/packages/docs/src/components/YouTubeVideo.tsx b/packages/docs/src/components/YouTubeVideo/index.tsx
similarity index 88%
rename from packages/docs/src/components/YouTubeVideo.tsx
rename to packages/docs/src/components/YouTubeVideo/index.tsx
index 89f1217d..8a125b07 100644
--- a/packages/docs/src/components/YouTubeVideo.tsx
+++ b/packages/docs/src/components/YouTubeVideo/index.tsx
@@ -1,5 +1,7 @@
import React from 'react';
+import styles from './styles.module.css';
+
export interface YouTubeVideoProps {
src: string;
width?: number;
@@ -15,6 +17,7 @@ export default function YouTubeVideo({
}: YouTubeVideoProps): JSX.Element {
return (
<iframe
+ className={styles.root}
width={width ?? 560}
height={height ?? 315}
src={src}
diff --git a/packages/docs/src/components/YouTubeVideo/styles.module.css b/packages/docs/src/components/YouTubeVideo/styles.module.css
new file mode 100644
index 00000000..5c2ec483
--- /dev/null
+++ b/packages/docs/src/components/YouTubeVideo/styles.module.css
@@ -0,0 +1,3 @@
+.root {
+ margin-bottom: var(--ifm-leading);
+}
diff --git a/packages/docs/src/css/custom.css b/packages/docs/src/css/custom.css
index 6b773417..6bab276f 100644
--- a/packages/docs/src/css/custom.css
+++ b/packages/docs/src/css/custom.css
@@ -120,7 +120,7 @@ a.button:hover {
font-weight: 700;
}
-.navbar-github-link {
+.navbar-icon {
transition: background var(--ifm-transition-fast);
width: 2rem;
height: 2rem;
@@ -132,24 +132,36 @@ a.button:hover {
margin-right: var(--ifm-button-padding-vertical);
}
-.navbar-github-link:hover {
+.navbar-icon:hover {
background-color: var(--ifm-color-emphasis-200);
}
-.navbar-github-link::before {
+.navbar-icon::before {
+ background-repeat: no-repeat;
+ background-position: center;
display: flex;
content: '';
- background-image: url('/img/github-icon.svg');
width: 20px;
height: 20px;
- color: red;
+}
+
+.navbar-github-link::before {
+ background-image: url('/img/github-icon.svg');
+}
+
+.navbar-discord-link::before {
+ background-image: url('/img/discord-icon.svg');
}
html[data-theme='dark'] .navbar-github-link::before {
background-image: url('/img/github-icon-dark.svg');
}
-.navbar-sidebar .navbar-github-link {
+html[data-theme='dark'] .navbar-discord-link::before {
+ background-image: url('/img/discord-icon-dark.svg');
+}
+
+.navbar-sidebar .navbar-icon {
display: none;
}
diff --git a/packages/docs/static/img/discord-icon-dark.svg b/packages/docs/static/img/discord-icon-dark.svg
new file mode 100644
index 00000000..d02d8397
--- /dev/null
+++ b/packages/docs/static/img/discord-icon-dark.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -2 127.14 96.36">
+ <path fill="#e3e3e3" d="M107.7,8.07A105.15,105.15,0,0,0,81.47,0a72.06,72.06,0,0,0-3.36,6.83A97.68,97.68,0,0,0,49,6.83,72.37,72.37,0,0,0,45.64,0,105.89,105.89,0,0,0,19.39,8.09C2.79,32.65-1.71,56.6.54,80.21h0A105.73,105.73,0,0,0,32.71,96.36,77.7,77.7,0,0,0,39.6,85.25a68.42,68.42,0,0,1-10.85-5.18c.91-.66,1.8-1.34,2.66-2a75.57,75.57,0,0,0,64.32,0c.87.71,1.76,1.39,2.66,2a68.68,68.68,0,0,1-10.87,5.19,77,77,0,0,0,6.89,11.1A105.25,105.25,0,0,0,126.6,80.22h0C129.24,52.84,122.09,29.11,107.7,8.07ZM42.45,65.69C36.18,65.69,31,60,31,53s5-12.74,11.43-12.74S54,46,53.89,53,48.84,65.69,42.45,65.69Zm42.24,0C78.41,65.69,73.25,60,73.25,53s5-12.74,11.44-12.74S96.23,46,96.12,53,91.08,65.69,84.69,65.69Z"/>
+</svg>
\ No newline at end of file
diff --git a/packages/docs/static/img/discord-icon.svg b/packages/docs/static/img/discord-icon.svg
new file mode 100644
index 00000000..00852e37
--- /dev/null
+++ b/packages/docs/static/img/discord-icon.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -2 127.14 96.36">
+ <path fill="#1c1c1c" d="M107.7,8.07A105.15,105.15,0,0,0,81.47,0a72.06,72.06,0,0,0-3.36,6.83A97.68,97.68,0,0,0,49,6.83,72.37,72.37,0,0,0,45.64,0,105.89,105.89,0,0,0,19.39,8.09C2.79,32.65-1.71,56.6.54,80.21h0A105.73,105.73,0,0,0,32.71,96.36,77.7,77.7,0,0,0,39.6,85.25a68.42,68.42,0,0,1-10.85-5.18c.91-.66,1.8-1.34,2.66-2a75.57,75.57,0,0,0,64.32,0c.87.71,1.76,1.39,2.66,2a68.68,68.68,0,0,1-10.87,5.19,77,77,0,0,0,6.89,11.1A105.25,105.25,0,0,0,126.6,80.22h0C129.24,52.84,122.09,29.11,107.7,8.07ZM42.45,65.69C36.18,65.69,31,60,31,53s5-12.74,11.43-12.74S54,46,53.89,53,48.84,65.69,42.45,65.69Zm42.24,0C78.41,65.69,73.25,60,73.25,53s5-12.74,11.44-12.74S96.23,46,96.12,53,91.08,65.69,84.69,65.69Z"/>
+</svg>
\ No newline at end of file