Skip to content

Commit 7c04271

Browse files
committed
Sync README and crate documentation
1 parent da6c58e commit 7c04271

File tree

2 files changed

+25
-20
lines changed

2 files changed

+25
-20
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# COSMIC TIME
2-
## An animation toolkit for Iced-rs/Iced
2+
## An animation toolkit for [Iced](https://github.com/iced-rs/iced)
33

44
> This Project was build for [Cosmic DE](https://github.com/pop-os/cosmic-epoch). Though this will work for any project that depends on [Iced](https://github.com/iced-rs/iced).
55
@@ -56,12 +56,12 @@ There are some different things here!
5656
> let animation = chain![
5757
5858
Cosmic Time refers to animations as [`Chain`]s because of how we build then.
59-
Each [`Keyframe`] is linked together like a chain. The Cosmic Time API doesn't
59+
Each Keyframe is linked together like a chain. The Cosmic Time API doesn't
6060
say "change your width from 10 to 100". We define each state we want the
6161
widget to have `.width(10)` at `Duration::ZERO` then `.width(100)` at
6262
`Duration::from_secs(10)`. Where the `Duration` is the time after the previous
63-
[`keyframe`]. This is why we call the animations chains. We cannot get to the
64-
next state without animating though all previous [`Keyframe`]s.
63+
keyframe. This is why we call the animations chains. We cannot get to the
64+
next state without animating though all previous Keyframes.
6565

6666
> self.timeline.set_chain(animation).start();
6767

src/lib.rs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
1-
//! An animation toolkit for Iced-rs/Iced
1+
//! An animation toolkit for [Iced](https://github.com/iced-rs/iced)
22
//!
3-
//! The goal of this project is to provide a simple API to build and show
4-
//! complex animations efficiently in applications built with Iced-rs/Iced.
3+
//! > This Project was build for [Cosmic DE](https://github.com/pop-os/cosmic-epoch). Though this will work for any project that depends on [Iced](https://github.com/iced-rs/iced).
54
//!
6-
//! # Projec Goals:
7-
//! * Full compatibility with Iced and Elm Architechture
8-
//! * Ease of use
9-
//! * No math required for any animation
5+
//!
6+
//! The goal of this project is to provide a simple API to build and show
7+
//! complex animations efficiently in applications built with Iced-rs/Iced.
8+
//!
9+
//! # Project Goals:
10+
//! * Full compatibility with Iced and The Elm Architecture.
11+
//! * Ease of use.
12+
//! * No math required for any animation.
1013
//! * No heap allocations in render loop.
11-
//! * Provide additional animatable widgets
12-
//! * Custom widget support (create your own!)
14+
//! * Provide additional animatable widgets.
15+
//! * Custom widget support (create your own!).
1316
//!
1417
//! # Overview
15-
//! To wire cosmic-time into Iced there are four steps to do.
18+
//! To wire cosmic-time into Iced there are five steps to do.
1619
//!
1720
//! 1. Create a [`Timeline`] This is the type that controls the animations.
1821
//! ```ignore
1922
//! struct Counter {
2023
//! timeline: Timeline
2124
//! }
2225
//!
23-
//! // SNIP
26+
//! // ~ SNIP
2427
//!
2528
//! impl Application for Counter {
26-
//! // SNIP
29+
//! // ~ SNIP
2730
//! fn new(_flags: ()) -> (Self, Command<Message>) {
2831
//! (Self { timeline: Timeline::new()}, Command::none())
2932
//! }
3033
//! }
31-
//!
3234
//! ```
3335
//! 2. Add at least one animation to your timeline. This can be done in your
3436
//! Application's `new()` or `update()`, or both!
@@ -45,11 +47,13 @@
4547
//! ```
4648
//! There are some different things here!
4749
//! > static CONTAINER: Lazy<id::Container> = Lazy::new(id::Container::unique);
50+
//!
4851
//! Cosmic Time refers to each animation with an Id. We export our own, but they are
4952
//! Identical to the widget Id's Iced uses for widget operations.
5053
//! Each animatable widget needs an Id. And each Id can only refer to one animation.
5154
//!
5255
//! > let animation = chain![
56+
//!
5357
//! Cosmic Time refers to animations as [`Chain`]s because of how we build then.
5458
//! Each Keyframe is linked together like a chain. The Cosmic Time API doesn't
5559
//! say "change your width from 10 to 100". We define each state we want the
@@ -59,6 +63,7 @@
5963
//! next state without animating though all previous Keyframes.
6064
//!
6165
//! > self.timeline.set_chain(animation).start();
66+
//!
6267
//! Then we need to add the animation to the [`Timeline`]. We call this `.set_chain`,
6368
//! because there can only be one chain per Id.
6469
//! If we `set_chain` with a different animation with the same Id, the first one is
@@ -67,6 +72,7 @@
6772
//! `self.timeline.set_chain(animation1).set_chain(animation2).start()`
6873
//!
6974
//! > .start()
75+
//!
7076
//! This one function call is important enough that we should look at it specifically.
7177
//! Cosmic Time is atomic, given the animation state held in the [`Timeline`] at any
7278
//! given time the global animations will be the exact same. The value used to
@@ -75,7 +81,7 @@
7581
//! Say you have two 5 seconds animations running at the same time. They should end
7682
//! at the same time right? That all depends on when the widget thinks it's animation
7783
//! should start. `.start()` tells all pending animations to start at the moment that
78-
//! `.start()` is called. This guarentees they stay in sync.
84+
//! `.start()` is called. This guarantees they stay in sync.
7985
//! IMPORTANT! Be sure to only call `.start()` once per call to `update()`.
8086
//! The below is incorrect!
8187
//! ```ignore
@@ -93,7 +99,6 @@
9399
//!
94100
//! 4. Map the subscription to update the timeline's state:
95101
//! ```ignore
96-
//! use iced::Command;
97102
//! fn update(&mut self, message: Message) -> Command<Message> {
98103
//! match message {
99104
//! Message::Tick(now) => self.timeline.now(now),
@@ -108,7 +113,7 @@
108113
//! ```
109114
//!
110115
//! All done!
111-
//! There is a bit of wireing to get Cosmic Time working, but after that it's only
116+
//! There is a bit of wiring to get Cosmic Time working, but after that it's only
112117
//! a few lines to create rather complex animations!
113118
//! See the Pong example to see how a full game of pong can be implemented in
114119
//! only a few lines!

0 commit comments

Comments
 (0)