| 1 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::{Mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#, Subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#}; |
| 2 | |
| 3 | use craterust-analyzer cargo palette 0.7.6 crate/::{ |
| 4 | blendrust-analyzer cargo palette 0.7.6 blend/::{BlendFunctionrust-analyzer cargo palette 0.7.6 blend/BlendFunction#, PreAlpharust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#}, |
| 5 | castrust-analyzer cargo palette 0.7.6 cast/::ArrayCastrust-analyzer cargo palette 0.7.6 cast/array/ArrayCast#, |
| 6 | numrust-analyzer cargo palette 0.7.6 num/::{Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics#, IsValidDivisorrust-analyzer cargo palette 0.7.6 num/IsValidDivisor#, MinMaxrust-analyzer cargo palette 0.7.6 num/MinMax#, Onerust-analyzer cargo palette 0.7.6 num/One#, Realrust-analyzer cargo palette 0.7.6 num/Real#, Sqrtrust-analyzer cargo palette 0.7.6 num/Sqrt#, Zerorust-analyzer cargo palette 0.7.6 num/Zero#}, |
| 7 | }; |
| 8 | |
| 9 | use superrust-analyzer cargo palette 0.7.6 blend/::{zip_colorsrust-analyzer cargo palette 0.7.6 blend/zip_colors()., Premultiplyrust-analyzer cargo palette 0.7.6 blend/Premultiply#}; |
| 10 | |
| 11 | /// A pair of blending equations and corresponding parameters. |
| 12 | /// |
| 13 | /// The `Equations` type is similar to how blending works in OpenGL, where a |
| 14 | /// blend function has can be written as `e(sp * S, dp * D)`. `e` is the |
| 15 | /// equation (like `s + d`), `sp` and `dp` are the source and destination |
| 16 | /// parameters, and `S` and `D` are the source and destination colors. |
| 17 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 18 | pub struct Equationsrust-analyzer cargo palette 0.7.6 blend/equations/Equations# { |
| 19 | /// The equation for the color components. |
| 20 | pub color_equationrust-analyzer cargo palette 0.7.6 blend/equations/Equations#color_equation.: Equationrust-analyzer cargo palette 0.7.6 blend/equations/Equation#, |
| 21 | |
| 22 | /// The equation for the alpha component. |
| 23 | pub alpha_equationrust-analyzer cargo palette 0.7.6 blend/equations/Equations#alpha_equation.: Equationrust-analyzer cargo palette 0.7.6 blend/equations/Equation#, |
| 24 | |
| 25 | /// The parameters for the color components. |
| 26 | pub color_parametersrust-analyzer cargo palette 0.7.6 blend/equations/Equations#color_parameters.: Parametersrust-analyzer cargo palette 0.7.6 blend/equations/Parameters#, |
| 27 | |
| 28 | /// The parameters for the alpha component. |
| 29 | pub alpha_parametersrust-analyzer cargo palette 0.7.6 blend/equations/Equations#alpha_parameters.: Parametersrust-analyzer cargo palette 0.7.6 blend/equations/Parameters#, |
| 30 | } |
| 31 | |
| 32 | impl Equationsrust-analyzer cargo palette 0.7.6 blend/equations/Equations# { |
| 33 | /// Create a pair of blending equations, where all the parameters are |
| 34 | /// `One`. |
| 35 | pub fn from_equationsrust-analyzer cargo palette 0.7.6 blend/equations/impl#[Equations]from_equations().(color: Equationrust-analyzer cargo palette 0.7.6 blend/equations/Equation#, alpha: Equationrust-analyzer cargo palette 0.7.6 blend/equations/Equation#) -> Equationsrust-analyzer cargo palette 0.7.6 blend/equations/Equations# { |
| 36 | Equationsrust-analyzer cargo palette 0.7.6 blend/equations/Equations# { |
| 37 | color_equationrust-analyzer cargo palette 0.7.6 blend/equations/Equations#color_equation.: color, |
| 38 | alpha_equationrust-analyzer cargo palette 0.7.6 blend/equations/Equations#alpha_equation.: alpha, |
| 39 | color_parametersrust-analyzer cargo palette 0.7.6 blend/equations/Equations#color_parameters.: Parametersrust-analyzer cargo palette 0.7.6 blend/equations/Parameters# { |
| 40 | sourcerust-analyzer cargo palette 0.7.6 blend/equations/Parameters#source.: Parameterrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#::Onerust-analyzer cargo palette 0.7.6 blend/equations/Parameter#One#, |
| 41 | destinationrust-analyzer cargo palette 0.7.6 blend/equations/Parameters#destination.: Parameterrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#::Onerust-analyzer cargo palette 0.7.6 blend/equations/Parameter#One#, |
| 42 | }, |
| 43 | alpha_parametersrust-analyzer cargo palette 0.7.6 blend/equations/Equations#alpha_parameters.: Parametersrust-analyzer cargo palette 0.7.6 blend/equations/Parameters# { |
| 44 | sourcerust-analyzer cargo palette 0.7.6 blend/equations/Parameters#source.: Parameterrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#::Onerust-analyzer cargo palette 0.7.6 blend/equations/Parameter#One#, |
| 45 | destinationrust-analyzer cargo palette 0.7.6 blend/equations/Parameters#destination.: Parameterrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#::Onerust-analyzer cargo palette 0.7.6 blend/equations/Parameter#One#, |
| 46 | }, |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | /// Create a pair of additive blending equations with the provided |
| 51 | /// parameters. |
| 52 | pub fn from_parametersrust-analyzer cargo palette 0.7.6 blend/equations/impl#[Equations]from_parameters().(source: Parameterrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#, destination: Parameterrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#) -> Equationsrust-analyzer cargo palette 0.7.6 blend/equations/Equations# { |
| 53 | Equationsrust-analyzer cargo palette 0.7.6 blend/equations/Equations# { |
| 54 | color_equationrust-analyzer cargo palette 0.7.6 blend/equations/Equations#color_equation.: Equationrust-analyzer cargo palette 0.7.6 blend/equations/Equation#::Addrust-analyzer cargo palette 0.7.6 blend/equations/Equation#Add#, |
| 55 | alpha_equationrust-analyzer cargo palette 0.7.6 blend/equations/Equations#alpha_equation.: Equationrust-analyzer cargo palette 0.7.6 blend/equations/Equation#::Addrust-analyzer cargo palette 0.7.6 blend/equations/Equation#Add#, |
| 56 | color_parametersrust-analyzer cargo palette 0.7.6 blend/equations/Equations#color_parameters.: Parametersrust-analyzer cargo palette 0.7.6 blend/equations/Parameters# { |
| 57 | sourcerust-analyzer cargo palette 0.7.6 blend/equations/Parameters#source., |
| 58 | destinationrust-analyzer cargo palette 0.7.6 blend/equations/Parameters#destination., |
| 59 | }, |
| 60 | alpha_parametersrust-analyzer cargo palette 0.7.6 blend/equations/Equations#alpha_parameters.: Parametersrust-analyzer cargo palette 0.7.6 blend/equations/Parameters# { |
| 61 | sourcerust-analyzer cargo palette 0.7.6 blend/equations/Parameters#source., |
| 62 | destinationrust-analyzer cargo palette 0.7.6 blend/equations/Parameters#destination., |
| 63 | }, |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | impl<C, S, const N: usize, const M: usize> BlendFunctionrust-analyzer cargo palette 0.7.6 blend/BlendFunction#<C> for Equationsrust-analyzer cargo palette 0.7.6 blend/equations/Equations# |
| 69 | where |
| 70 | C: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# |
| 71 | + Premultiplyrust-analyzer cargo palette 0.7.6 blend/Premultiply#<Scalarrust-analyzer cargo palette 0.7.6 blend/Premultiply#Scalar# = S> |
| 72 | + Mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#<Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#Output# = C> |
| 73 | + Mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#<S, Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#Output# = C> |
| 74 | + ArrayCastrust-analyzer cargo palette 0.7.6 cast/array/ArrayCast#<Arrayrust-analyzer cargo palette 0.7.6 cast/array/ArrayCast#Array# = [S; N]>, |
| 75 | PreAlpharust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#<C>: ArrayCastrust-analyzer cargo palette 0.7.6 cast/array/ArrayCast#<Arrayrust-analyzer cargo palette 0.7.6 cast/array/ArrayCast#Array# = [S; M]>, |
| 76 | S: Realrust-analyzer cargo palette 0.7.6 num/Real# + Onerust-analyzer cargo palette 0.7.6 num/One# + Zerorust-analyzer cargo palette 0.7.6 num/Zero# + MinMaxrust-analyzer cargo palette 0.7.6 num/MinMax# + Sqrtrust-analyzer cargo palette 0.7.6 num/Sqrt# + IsValidDivisorrust-analyzer cargo palette 0.7.6 num/IsValidDivisor# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 77 | { |
| 78 | fn apply_torust-analyzer cargo palette 0.7.6 blend/equations/impl#[Equations][`BlendFunction<C>`]apply_to().(self, source: PreAlpharust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#<C>, destination: PreAlpharust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#<C>) -> PreAlpharust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#<C> { |
| 79 | let (src_color, mut dst_color) = |
| 80 | if matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self.color_equationrust-analyzer cargo palette 0.7.6 blend/equations/Equations#color_equation., Equationrust-analyzer cargo palette 0.7.6 blend/equations/Equation#::Minrust-analyzer cargo palette 0.7.6 blend/equations/Equation#Min# | Equationrust-analyzer cargo palette 0.7.6 blend/equations/Equation#::Maxrust-analyzer cargo palette 0.7.6 blend/equations/Equation#Max#) { |
| 81 | (source.colorrust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#color..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), destination.colorrust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#color..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()) |
| 82 | } else { |
| 83 | let col_src_param = self |
| 84 | .color_parametersrust-analyzer cargo palette 0.7.6 blend/equations/Equations#color_parameters. |
| 85 | .sourcerust-analyzer cargo palette 0.7.6 blend/equations/Parameters#source. |
| 86 | .apply_torust-analyzer cargo palette 0.7.6 blend/equations/impl#[Parameter]apply_to().(source.clonerust-analyzer cargo palette 0.7.6 blend/pre_alpha/impl#[`PreAlpha<C>`][Clone]clone().(), destination.clonerust-analyzer cargo palette 0.7.6 blend/pre_alpha/impl#[`PreAlpha<C>`][Clone]clone().()); |
| 87 | let col_dst_param = self |
| 88 | .color_parametersrust-analyzer cargo palette 0.7.6 blend/equations/Equations#color_parameters. |
| 89 | .destinationrust-analyzer cargo palette 0.7.6 blend/equations/Parameters#destination. |
| 90 | .apply_torust-analyzer cargo palette 0.7.6 blend/equations/impl#[Parameter]apply_to().(source.clonerust-analyzer cargo palette 0.7.6 blend/pre_alpha/impl#[`PreAlpha<C>`][Clone]clone().(), destination.clonerust-analyzer cargo palette 0.7.6 blend/pre_alpha/impl#[`PreAlpha<C>`][Clone]clone().()); |
| 91 | |
| 92 | ( |
| 93 | col_src_param.mul_colorrust-analyzer cargo palette 0.7.6 blend/equations/impl#[`ParamOut<C>`]mul_color().(source.colorrust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#color..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()), |
| 94 | col_dst_param.mul_colorrust-analyzer cargo palette 0.7.6 blend/equations/impl#[`ParamOut<C>`]mul_color().(destination.colorrust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#color..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()), |
| 95 | ) |
| 96 | }; |
| 97 | |
| 98 | let (src_alpha, dst_alpha) = if matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self.alpha_equationrust-analyzer cargo palette 0.7.6 blend/equations/Equations#alpha_equation., Equationrust-analyzer cargo palette 0.7.6 blend/equations/Equation#::Minrust-analyzer cargo palette 0.7.6 blend/equations/Equation#Min# | Equationrust-analyzer cargo palette 0.7.6 blend/equations/Equation#::Maxrust-analyzer cargo palette 0.7.6 blend/equations/Equation#Max#) |
| 99 | { |
| 100 | (source.alpharust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#alpha., destination.alpharust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#alpha.) |
| 101 | } else { |
| 102 | let alpha_src_param = self |
| 103 | .alpha_parametersrust-analyzer cargo palette 0.7.6 blend/equations/Equations#alpha_parameters. |
| 104 | .sourcerust-analyzer cargo palette 0.7.6 blend/equations/Parameters#source. |
| 105 | .apply_torust-analyzer cargo palette 0.7.6 blend/equations/impl#[Parameter]apply_to().(source.clonerust-analyzer cargo palette 0.7.6 blend/pre_alpha/impl#[`PreAlpha<C>`][Clone]clone().(), destination.clonerust-analyzer cargo palette 0.7.6 blend/pre_alpha/impl#[`PreAlpha<C>`][Clone]clone().()); |
| 106 | let alpha_dst_param = self |
| 107 | .alpha_parametersrust-analyzer cargo palette 0.7.6 blend/equations/Equations#alpha_parameters. |
| 108 | .destinationrust-analyzer cargo palette 0.7.6 blend/equations/Parameters#destination. |
| 109 | .apply_torust-analyzer cargo palette 0.7.6 blend/equations/impl#[Parameter]apply_to().(source.clonerust-analyzer cargo palette 0.7.6 blend/pre_alpha/impl#[`PreAlpha<C>`][Clone]clone().(), destination.clonerust-analyzer cargo palette 0.7.6 blend/pre_alpha/impl#[`PreAlpha<C>`][Clone]clone().()); |
| 110 | |
| 111 | ( |
| 112 | alpha_src_param.mul_constantrust-analyzer cargo palette 0.7.6 blend/equations/impl#[`ParamOut<C>`]mul_constant().(source.alpharust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#alpha.), |
| 113 | alpha_dst_param.mul_constantrust-analyzer cargo palette 0.7.6 blend/equations/impl#[`ParamOut<C>`]mul_constant().(destination.alpharust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#alpha.), |
| 114 | ) |
| 115 | }; |
| 116 | |
| 117 | let color_op = match self.color_equationrust-analyzer cargo palette 0.7.6 blend/equations/Equations#color_equation. { |
| 118 | Equationrust-analyzer cargo palette 0.7.6 blend/equations/Equation#::Addrust-analyzer cargo palette 0.7.6 blend/equations/Equation#Add# => |src, dst| src rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().dst, |
| 119 | Equationrust-analyzer cargo palette 0.7.6 blend/equations/Equation#::Subtractrust-analyzer cargo palette 0.7.6 blend/equations/Equation#Subtract# => |src, dst| src rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().dst, |
| 120 | Equationrust-analyzer cargo palette 0.7.6 blend/equations/Equation#::ReverseSubtractrust-analyzer cargo palette 0.7.6 blend/equations/Equation#ReverseSubtract# => |src, dst| dst rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().src, |
| 121 | Equationrust-analyzer cargo palette 0.7.6 blend/equations/Equation#::Minrust-analyzer cargo palette 0.7.6 blend/equations/Equation#Min# => MinMaxrust-analyzer cargo palette 0.7.6 num/MinMax#::minrust-analyzer cargo palette 0.7.6 num/MinMax#min()., |
| 122 | Equationrust-analyzer cargo palette 0.7.6 blend/equations/Equation#::Maxrust-analyzer cargo palette 0.7.6 blend/equations/Equation#Max# => MinMaxrust-analyzer cargo palette 0.7.6 num/MinMax#::maxrust-analyzer cargo palette 0.7.6 num/MinMax#max()., |
| 123 | }; |
| 124 | |
| 125 | let alpha_op = match self.alpha_equationrust-analyzer cargo palette 0.7.6 blend/equations/Equations#alpha_equation. { |
| 126 | Equationrust-analyzer cargo palette 0.7.6 blend/equations/Equation#::Addrust-analyzer cargo palette 0.7.6 blend/equations/Equation#Add# => |src, dst| src rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().dst, |
| 127 | Equationrust-analyzer cargo palette 0.7.6 blend/equations/Equation#::Subtractrust-analyzer cargo palette 0.7.6 blend/equations/Equation#Subtract# => |src, dst| src rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().dst, |
| 128 | Equationrust-analyzer cargo palette 0.7.6 blend/equations/Equation#::ReverseSubtractrust-analyzer cargo palette 0.7.6 blend/equations/Equation#ReverseSubtract# => |src, dst| dst rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().src, |
| 129 | Equationrust-analyzer cargo palette 0.7.6 blend/equations/Equation#::Minrust-analyzer cargo palette 0.7.6 blend/equations/Equation#Min# => MinMaxrust-analyzer cargo palette 0.7.6 num/MinMax#::minrust-analyzer cargo palette 0.7.6 num/MinMax#min()., |
| 130 | Equationrust-analyzer cargo palette 0.7.6 blend/equations/Equation#::Maxrust-analyzer cargo palette 0.7.6 blend/equations/Equation#Max# => MinMaxrust-analyzer cargo palette 0.7.6 num/MinMax#::maxrust-analyzer cargo palette 0.7.6 num/MinMax#max()., |
| 131 | }; |
| 132 | |
| 133 | for (src, dst) in zip_colorsrust-analyzer cargo palette 0.7.6 blend/zip_colors().(src_color, &mut dst_color) { |
| 134 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().dst = color_op(src, dst.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 135 | } |
| 136 | |
| 137 | PreAlpharust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha# { |
| 138 | colorrust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#color.: dst_color, |
| 139 | alpharust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#alpha.: alpha_op(src_alpha, dst_alpha), |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | /// A blending equation. |
| 145 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 146 | pub enum Equationrust-analyzer cargo palette 0.7.6 blend/equations/Equation# { |
| 147 | /// Add the source and destination, according to `sp * S + dp * D`. |
| 148 | Addrust-analyzer cargo palette 0.7.6 blend/equations/Equation#Add#, |
| 149 | |
| 150 | /// Subtract the destination from the source, according to `sp * S - dp * |
| 151 | /// D`. |
| 152 | Subtractrust-analyzer cargo palette 0.7.6 blend/equations/Equation#Subtract#, |
| 153 | |
| 154 | /// Subtract the source from the destination, according to `dp * D - sp * |
| 155 | /// S`. |
| 156 | ReverseSubtractrust-analyzer cargo palette 0.7.6 blend/equations/Equation#ReverseSubtract#, |
| 157 | |
| 158 | /// Create a color where each component is the smallest of each of the |
| 159 | /// source and destination components. A.k.a. component wise min. The |
| 160 | /// parameters are ignored. |
| 161 | Minrust-analyzer cargo palette 0.7.6 blend/equations/Equation#Min#, |
| 162 | |
| 163 | /// Create a color where each component is the largest of each of the |
| 164 | /// source and destination components. A.k.a. component wise max. The |
| 165 | /// parameters are ignored. |
| 166 | Maxrust-analyzer cargo palette 0.7.6 blend/equations/Equation#Max#, |
| 167 | } |
| 168 | |
| 169 | /// A pair of source and destination parameters. |
| 170 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 171 | pub struct Parametersrust-analyzer cargo palette 0.7.6 blend/equations/Parameters# { |
| 172 | /// The source parameter. |
| 173 | pub sourcerust-analyzer cargo palette 0.7.6 blend/equations/Parameters#source.: Parameterrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#, |
| 174 | |
| 175 | /// The destination parameter. |
| 176 | pub destinationrust-analyzer cargo palette 0.7.6 blend/equations/Parameters#destination.: Parameterrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#, |
| 177 | } |
| 178 | |
| 179 | /// A blending parameter. |
| 180 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 181 | pub enum Parameterrust-analyzer cargo palette 0.7.6 blend/equations/Parameter# { |
| 182 | /// A simple 1. |
| 183 | Onerust-analyzer cargo palette 0.7.6 blend/equations/Parameter#One#, |
| 184 | |
| 185 | /// A simple 0. |
| 186 | Zerorust-analyzer cargo palette 0.7.6 blend/equations/Parameter#Zero#, |
| 187 | |
| 188 | /// The source color, or alpha. |
| 189 | SourceColorrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#SourceColor#, |
| 190 | |
| 191 | /// One minus the source color, or alpha. |
| 192 | OneMinusSourceColorrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#OneMinusSourceColor#, |
| 193 | |
| 194 | /// The destination color, or alpha. |
| 195 | DestinationColorrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#DestinationColor#, |
| 196 | |
| 197 | /// One minus the destination color, or alpha. |
| 198 | OneMinusDestinationColorrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#OneMinusDestinationColor#, |
| 199 | |
| 200 | /// The source alpha. |
| 201 | SourceAlpharust-analyzer cargo palette 0.7.6 blend/equations/Parameter#SourceAlpha#, |
| 202 | |
| 203 | /// One minus the source alpha. |
| 204 | OneMinusSourceAlpharust-analyzer cargo palette 0.7.6 blend/equations/Parameter#OneMinusSourceAlpha#, |
| 205 | |
| 206 | /// The destination alpha. |
| 207 | DestinationAlpharust-analyzer cargo palette 0.7.6 blend/equations/Parameter#DestinationAlpha#, |
| 208 | |
| 209 | /// One minus the destination alpha. |
| 210 | OneMinusDestinationAlpharust-analyzer cargo palette 0.7.6 blend/equations/Parameter#OneMinusDestinationAlpha#, |
| 211 | } |
| 212 | |
| 213 | impl Parameterrust-analyzer cargo palette 0.7.6 blend/equations/Parameter# { |
| 214 | fn apply_torust-analyzer cargo palette 0.7.6 blend/equations/impl#[Parameter]apply_to().<C, T, const N: usize>( |
| 215 | &self, |
| 216 | source: PreAlpharust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#<C>, |
| 217 | destination: PreAlpharust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#<C>, |
| 218 | ) -> ParamOutrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#<C> |
| 219 | where |
| 220 | C: Premultiplyrust-analyzer cargo palette 0.7.6 blend/Premultiply#<Scalarrust-analyzer cargo palette 0.7.6 blend/Premultiply#Scalar# = T>, |
| 221 | PreAlpharust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#<C>: ArrayCastrust-analyzer cargo palette 0.7.6 cast/array/ArrayCast#<Arrayrust-analyzer cargo palette 0.7.6 cast/array/ArrayCast#Array# = [T; N]>, |
| 222 | T: Realrust-analyzer cargo palette 0.7.6 num/Real# + Onerust-analyzer cargo palette 0.7.6 num/One# + Zerorust-analyzer cargo palette 0.7.6 num/Zero# + Subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#<Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#Output# = T>, |
| 223 | { |
| 224 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self { |
| 225 | Parameterrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#::Onerust-analyzer cargo palette 0.7.6 blend/equations/Parameter#One# => ParamOutrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#::Constantrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#Constant#(T::onerust-analyzer cargo palette 0.7.6 num/One#one().()), |
| 226 | Parameterrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#::Zerorust-analyzer cargo palette 0.7.6 blend/equations/Parameter#Zero# => ParamOutrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#::Constantrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#Constant#(T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().()), |
| 227 | Parameterrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#::SourceColorrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#SourceColor# => ParamOutrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#::Colorrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#Color#(source), |
| 228 | Parameterrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#::OneMinusSourceColorrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#OneMinusSourceColor# => { |
| 229 | ParamOutrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#::Colorrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#Color#(<[T; N]>::fromrust-analyzer cargo palette 0.7.6 blend/pre_alpha/impl#[`[<C as Premultiply>::Scalar; N]`][`From<PreAlpha<C>>`]from().(source).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`]map().(|a| T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().a).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 230 | } |
| 231 | Parameterrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#::DestinationColorrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#DestinationColor# => ParamOutrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#::Colorrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#Color#(destination), |
| 232 | Parameterrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#::OneMinusDestinationColorrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#OneMinusDestinationColor# => { |
| 233 | ParamOutrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#::Colorrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#Color#(<[T; N]>::fromrust-analyzer cargo palette 0.7.6 blend/pre_alpha/impl#[`[<C as Premultiply>::Scalar; N]`][`From<PreAlpha<C>>`]from().(destination).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`]map().(|a| T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().a).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 234 | } |
| 235 | Parameterrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#::SourceAlpharust-analyzer cargo palette 0.7.6 blend/equations/Parameter#SourceAlpha# => ParamOutrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#::Constantrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#Constant#(source.alpharust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#alpha.), |
| 236 | Parameterrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#::OneMinusSourceAlpharust-analyzer cargo palette 0.7.6 blend/equations/Parameter#OneMinusSourceAlpha# => ParamOutrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#::Constantrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#Constant#(T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().source.alpharust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#alpha.), |
| 237 | Parameterrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#::DestinationAlpharust-analyzer cargo palette 0.7.6 blend/equations/Parameter#DestinationAlpha# => ParamOutrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#::Constantrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#Constant#(destination.alpharust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#alpha.), |
| 238 | Parameterrust-analyzer cargo palette 0.7.6 blend/equations/Parameter#::OneMinusDestinationAlpharust-analyzer cargo palette 0.7.6 blend/equations/Parameter#OneMinusDestinationAlpha# => ParamOutrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#::Constantrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#Constant#(T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().destination.alpharust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#alpha.), |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | enum ParamOutrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#<C: Premultiplyrust-analyzer cargo palette 0.7.6 blend/Premultiply#> { |
| 244 | Colorrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#Color#(PreAlpharust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#<C>), |
| 245 | Constantrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#Constant#(C::Scalarrust-analyzer cargo palette 0.7.6 blend/Premultiply#Scalar#), |
| 246 | } |
| 247 | |
| 248 | impl<C, T> ParamOutrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#<C> |
| 249 | where |
| 250 | C: Mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#<Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#Output# = C> + Mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#<T, Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#Output# = C> + Premultiplyrust-analyzer cargo palette 0.7.6 blend/Premultiply#<Scalarrust-analyzer cargo palette 0.7.6 blend/Premultiply#Scalar# = T>, |
| 251 | T: Mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#<Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#Output# = T> + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 252 | { |
| 253 | fn mul_constantrust-analyzer cargo palette 0.7.6 blend/equations/impl#[`ParamOut<C>`]mul_constant().(self, other: T) -> T { |
| 254 | match self { |
| 255 | ParamOutrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#::Colorrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#Color#(c) => c.alpharust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#alpha. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().other, |
| 256 | ParamOutrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#::Constantrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#Constant#(c) => c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().other, |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | fn mul_colorrust-analyzer cargo palette 0.7.6 blend/equations/impl#[`ParamOut<C>`]mul_color().(self, other: C) -> C { |
| 261 | match self { |
| 262 | ParamOutrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#::Colorrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#Color#(c) => other rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().c.colorrust-analyzer cargo palette 0.7.6 blend/pre_alpha/PreAlpha#color., |
| 263 | ParamOutrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#::Constantrust-analyzer cargo palette 0.7.6 blend/equations/ParamOut#Constant#(c) => other rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().c, |
| 264 | } |
| 265 | } |
| 266 | } |