twitchapon-anim

Basic Twitchapon Receiver/Visuals
git clone git://bsandro.tech/twitchapon-anim
Log | Files | Refs | README | LICENSE

compositemode.go (2258B)


      1 // Copyright 2018 The Ebiten Authors
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //     http://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 package driver
     16 
     17 import (
     18 	"fmt"
     19 )
     20 
     21 type CompositeMode int
     22 
     23 const (
     24 	CompositeModeUnknown    CompositeMode = iota - 1
     25 	CompositeModeSourceOver               // This value must be 0 (= initial value)
     26 	CompositeModeClear
     27 	CompositeModeCopy
     28 	CompositeModeDestination
     29 	CompositeModeDestinationOver
     30 	CompositeModeSourceIn
     31 	CompositeModeDestinationIn
     32 	CompositeModeSourceOut
     33 	CompositeModeDestinationOut
     34 	CompositeModeSourceAtop
     35 	CompositeModeDestinationAtop
     36 	CompositeModeXor
     37 	CompositeModeLighter
     38 	CompositeModeMultiply
     39 
     40 	CompositeModeMax = CompositeModeMultiply
     41 )
     42 
     43 type Operation int
     44 
     45 const (
     46 	Zero Operation = iota
     47 	One
     48 	SrcAlpha
     49 	DstAlpha
     50 	OneMinusSrcAlpha
     51 	OneMinusDstAlpha
     52 	DstColor
     53 )
     54 
     55 func (c CompositeMode) Operations() (src Operation, dst Operation) {
     56 	switch c {
     57 	case CompositeModeSourceOver:
     58 		return One, OneMinusSrcAlpha
     59 	case CompositeModeClear:
     60 		return Zero, Zero
     61 	case CompositeModeCopy:
     62 		return One, Zero
     63 	case CompositeModeDestination:
     64 		return Zero, One
     65 	case CompositeModeDestinationOver:
     66 		return OneMinusDstAlpha, One
     67 	case CompositeModeSourceIn:
     68 		return DstAlpha, Zero
     69 	case CompositeModeDestinationIn:
     70 		return Zero, SrcAlpha
     71 	case CompositeModeSourceOut:
     72 		return OneMinusDstAlpha, Zero
     73 	case CompositeModeDestinationOut:
     74 		return Zero, OneMinusSrcAlpha
     75 	case CompositeModeSourceAtop:
     76 		return DstAlpha, OneMinusSrcAlpha
     77 	case CompositeModeDestinationAtop:
     78 		return OneMinusDstAlpha, SrcAlpha
     79 	case CompositeModeXor:
     80 		return OneMinusDstAlpha, OneMinusSrcAlpha
     81 	case CompositeModeLighter:
     82 		return One, One
     83 	case CompositeModeMultiply:
     84 		return DstColor, Zero
     85 	default:
     86 		panic(fmt.Sprintf("graphics: invalid composite mode: %d", c))
     87 	}
     88 }