From 7ff7814725a9b5dae12b6ce30ff49e78a02dc3e1 Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Sun, 24 Nov 2024 18:41:50 -0500 Subject: [PATCH] Rewrite curves release note to be more approachable and add a brief note about color curves (#1844) Co-authored-by: Rich Churcher --- ...rait_for_general_interoperation__Part_I.md | 50 +++++++++++++------ .../0.15/release-notes/_release-notes.toml | 11 +--- 2 files changed, 36 insertions(+), 25 deletions(-) diff --git a/release-content/0.15/release-notes/14630_A_Curve_trait_for_general_interoperation__Part_I.md b/release-content/0.15/release-notes/14630_A_Curve_trait_for_general_interoperation__Part_I.md index 5d2e4138c4..f04538cf9a 100644 --- a/release-content/0.15/release-notes/14630_A_Curve_trait_for_general_interoperation__Part_I.md +++ b/release-content/0.15/release-notes/14630_A_Curve_trait_for_general_interoperation__Part_I.md @@ -1,27 +1,35 @@ -The new `Curve` trait provides a shared interface for curves. +The new [`Curve`] trait provides a shared interface for curves, describing how values of type `T` change as we vary a `f32` parameter `t` over some domain. -`Curve` defines a value of some type `T` -parametrized by a nonempty closed interval of real numbers. That parameter could, -for example, represent time, in which case a `Curve` is thought of as a value -of type `T` that changes over time, as in animation. The parameter -could also represent something like distance or displacement, as in gradients and -spatial curves. +What's changing, and the domain that it's changing *over* are both incredibly flexible. +You might choose to set `T` to store anything from position, to damage to colors (like we did to create) a powerful abstraction for [color gradients](https://docs.rs/bevy/0.15.0/bevy/color/struct.ColorCurve.html). -The curves themselves may be defined in a variety of ways. For example, a curve may be: +As we vary the progress parameter `t`, we could be representing time (like for animation), +or something like distance as for curves that are mapped into 2D or 3D space, +or a fraction of progress between a starting and ending value. + +## Constructing Curves + +Each curve made be defined in a variety of ways. For example, a curve may be: * defined by a function * interpolated from samples * constructed using splines * produced by an easing function -Additionally, the `Curve` API provides adaptors for taking an existing curve and -modifying its output and/or parametrization. It is similar to the `Iterator` -interface in this way. +Take a look at the constructors on the [`Curve`] trait for more details. + +## Modifying curves + +Procedurally modifying curves is a powerful tool for both creating curves with the desired behavior and dynamically altering them. + +Bevy 0.15 provides a number of flexible adaptors for taking an existing curve and +modifying its output and/or parametrization. For example: + ```rust let timed_angles = [ (0.0, 0.0), @@ -49,11 +57,18 @@ A number of other adaptors are also available. For instance: * two curves may be chained together to form a longer curve * two curves may be zipped together to form a curve valued in tuples -The interface additionally provides facilities for rasterization. These allow -a curve to be resampled into an approximation derived from sample interpolation -on the original curve; in practice, this is useful when curves of diverse origin -need to be made uniform at the level of data - e.g. in serialization or when -applying numerical methods. +## Sampling from curves + +Sampling is the process of asking "what is the value of this curve at some particular value of `t`". +Doing so is simple: just call [`Curve::sample`]! + +Much like how vector graphics can be rasterized into pixels, curves can be rasterized into regular, discretized intervals. +By resampling into an approximation derived from sample interpolation +on the original curve, we can make curves of diverse origin +uniform at the level of data. + +While this may seem exotic, this technique is critical for serializing curves or +approximating properties via numerical methods. ```rust // A curve defined by a function, which may be challenging to store as data. @@ -66,3 +81,6 @@ let exponential_curve = FunctionCurve::new( // Internally, this just holds the samples and the parameter interval. let raster_curve = exponential_curve.resample_auto(100).unwrap(); ``` + +[`Curve`]: https://docs.rs/bevy/0.15.0/bevy/math/trait.Curve.html +[`Curve::sample`]: https://docs.rs/bevy/0.15.0/bevy/math/trait.Curve.html#method.sample diff --git a/release-content/0.15/release-notes/_release-notes.toml b/release-content/0.15/release-notes/_release-notes.toml index 8b1daa6797..6ac9405477 100644 --- a/release-content/0.15/release-notes/_release-notes.toml +++ b/release-content/0.15/release-notes/_release-notes.toml @@ -152,8 +152,8 @@ file_name = "15320_Retained_Rendering.md" [[release_notes]] title = "The Curve Trait" authors = ["@mweatherley"] -contributors = ["@alice-i-cecile"] -prs = [14630] +contributors = ["@alice-i-cecile", "@RobWalt", "@mockersf", "@cart"] +prs = [14630, 14976, 15675, 16637] file_name = "14630_A_Curve_trait_for_general_interoperation__Part_I.md" [[release_notes]] @@ -170,13 +170,6 @@ contributors = [] prs = [14106] file_name = "14106_Cyclic_splines.md" -[[release_notes]] -title = "Color gradient curve" -authors = ["@RobWalt"] -contributors = ["@bushrat011899", "@mweatherley"] -prs = [14976] -file_name = "14976_Color_gradient_curve.md" - [[release_notes]] title = "reflect: implement the unique reflect rfc" authors = ["@soqb"]