1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//! # Some blend modes
//! Assume that we have to colors called ```src``` and ```dst```<br>
//! The ```output``` is the result color

/// Clear blending mode <br>
/// ```output = (0,0,0,0)```
pub trait Clear {
    type Output;
    fn clear(self,rhs : Self) -> Self::Output;
}

/// Src blending mode <br>
/// ```output = src```
pub trait Src{
    type Output;
    fn src(self,rhs : Self) -> Self::Output;
}

/// Dst blending mode <br>
/// ```output = dst```
pub trait Dst{
    type Output;
    fn dst(self,rhs : Self) -> Self::Output;
}

/// SrcOver blending mode <br>
/// ```output = src + dst * (1 - src.alpha)```
pub trait SrcOver{
    type Output;
    fn src_over(self,rhs : Self) -> Self::Output;
}

/// DstOver blending mode <br>
/// ```output = src * (1 - dst.alpha) + dst```
pub trait DstOver{
    type Output;
    fn dst_over(self, rhs : Self) -> Self::Output;
}

/// SrcIn blending mode <br>
/// ```output = src * dst.alpha ```
pub trait SrcIn{
    type Output;
    fn src_in(self,rhs : Self) -> Self::Output;
}

/// DstIn blending mode <br>
/// ```output = dst * src.alpha ```
pub trait DstIn{
    type Output;
    fn dst_in(self,rhs : Self) -> Self::Output;
}

/// SrcOut blending mode <br>
/// ```output = dst * (1 - src.alpha)```
pub trait SrcOut{
    type Output;
    fn src_out(self, rhs : Self) -> Self::Output;
}

/// SrcOut blending mode <br>
/// ```output = src * (1 - dst.alpha)```
pub trait DstOut{
    type Output;
    fn dst_out(self, rhs : Self) -> Self::Output;
}

/// SrcATop blending mode <br>
/// ```output = src * dst.alpha + dst * (1 - src.alpha)```
pub trait SrcATop{
    type Output;
    fn src_atop(self,rhs : Self) -> Self::Output;
}

/// DstATop blending mode <br>
/// ```output = src * (1 - dst.alpha) + dst * src.alpha```
pub trait DstATop{
    type Output;
    fn dst_atop(self, rhs : Self) -> Self::Output;
}

/// Xor blending mode <br>
/// ```output = src * (1 - dst.alpha) + dst * (1 - src.alpha)```
pub trait Xor{
    type Output;
    fn xor(self, rhs : Self) -> Self::Output;
}

/// Darken blending mode <br>
/// ```output = src.gray < dst.gray ? src : dst```
pub trait Darken{
    type Output;
    fn darken(self,rhs : Self) -> Self::Output;
}

/// Darken blending mode <br>
/// ```output = src.gray > dst.gray ? src : dst```
pub trait Lighten{
    type Output;
    fn lighten(self,rhs : Self) -> Self::Output;
}

/// Multiply blending mode <br>
/// ```output = src * dst```
pub trait Multiply{
    type Output;
    fn multiply(self, rhs : Self) -> Self::Output;
}

/// Screen blending mode <br>
/// ```output = 1 - (1 - src) * (1 - dst)```
pub trait Screen{
    type Output;
    fn screen(self,rhs : Self) -> Self::Output;
}