Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flesh out remaining sections from the docs notebook #3

Open
sritchie opened this issue Jan 26, 2023 · 0 comments
Open

flesh out remaining sections from the docs notebook #3

sritchie opened this issue Jan 26, 2023 · 0 comments

Comments

@sritchie
Copy link
Member

sritchie commented Jan 26, 2023

;; #### Transformations and constraints

;; When wrapping a Movable Point in a mafs/Transform, the point will be
;; transformed too. However, your constrain function will be passed the
;; untransformed point, and its return value will be transformed back into the
;; currently applied transform. In other words, Mafs takes care of the math for
;; you.

;; Let's see a more complex example where we combine more interesting constraint
;; functions with transforms. On the left, we have a point that can only move in
;; whole-number increments within a square, and on the right, a point that can
;; only move in $\pi / 16$ increments in a circle.

;; TODO demo

;; #### Dynamic Movable Points

;; useMovablePoint is a hook that helps you instantiate and manage the state of
;; a MovablePoint. However, if need be, you can also use MovablePoint directly.
;; This can be useful if you need to work with a dynamic number of movable
;; points (since the React "rules of hooks" ban you from dynamically calling
;; hooks).

;; TODO

;; ### Accessing transforms in JavaScript

;; Here's an example of a custom component that uses the hooks approach to
;; render a grid of points. Because we want the grid's points to have a radius
;; of 3 pixels (regardless of the viewport or any transforms), we use the
;; mafs/useTransformContext hook to get the user and view transforms and apply
;; them to the circles' x and y coordinates, but not to their radius (which
;; is in pixels). We also cannot use the CSS transforms approach here, because
;; that would distort each circle.

;; TODO demo

;; ## Animation

;; useStopwatch allows you to start and stop a real-time clock for doing neat
;; things like physics simulations.

;; Pass :startTime (defaults to 0) or :endTime (defaults to Infinity) to
;; constrain the stopwatch.

;; TODO not working yet!

;; ## Examples

;; ### Bézier curves
;; ### Riemann sums
;; ### Fancy parabola
;; ### Projectile motion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant