1
0

compositemode.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // Copyright 2023 The Ebitengine 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. package ebiten
  15. import (
  16. "fmt"
  17. )
  18. // CompositeMode represents Porter-Duff composition mode.
  19. //
  20. // Deprecated: as of v2.5. Use Blend instead.
  21. type CompositeMode int
  22. const (
  23. // CompositeModeCustom indicates to refer Blend.
  24. CompositeModeCustom CompositeMode = iota
  25. // Deprecated: as of v2.5. Use BlendSourceOver instead.
  26. CompositeModeSourceOver
  27. // Deprecated: as of v2.5. Use BlendClear instead.
  28. CompositeModeClear
  29. // Deprecated: as of v2.5. Use BlendCopy instead.
  30. CompositeModeCopy
  31. // Deprecated: as of v2.5. Use BlendDestination instead.
  32. CompositeModeDestination
  33. // Deprecated: as of v2.5. Use BlendDestinationOver instead.
  34. CompositeModeDestinationOver
  35. // Deprecated: as of v2.5. Use BlendSourceIn instead.
  36. CompositeModeSourceIn
  37. // Deprecated: as of v2.5. Use BlendDestinationIn instead.
  38. CompositeModeDestinationIn
  39. // Deprecated: as of v2.5. Use BlendSourceOut instead.
  40. CompositeModeSourceOut
  41. // Deprecated: as of v2.5. Use BlendDestinationOut instead.
  42. CompositeModeDestinationOut
  43. // Deprecated: as of v2.5. Use BlendSourceAtop instead.
  44. CompositeModeSourceAtop
  45. // Deprecated: as of v2.5. Use BlendDestinationAtop instead.
  46. CompositeModeDestinationAtop
  47. // Deprecated: as of v2.5. Use BlendXor instead.
  48. CompositeModeXor
  49. // Deprecated: as of v2.5. Use BlendLighter instead.
  50. CompositeModeLighter
  51. // Deprecated: as of v2.5. Use Blend with BlendFactorDestinationColor and BlendFactorZero instead.
  52. CompositeModeMultiply
  53. )
  54. func (c CompositeMode) blend() Blend {
  55. switch c {
  56. case CompositeModeSourceOver:
  57. return BlendSourceOver
  58. case CompositeModeClear:
  59. return BlendClear
  60. case CompositeModeCopy:
  61. return BlendCopy
  62. case CompositeModeDestination:
  63. return BlendDestination
  64. case CompositeModeDestinationOver:
  65. return BlendDestinationOver
  66. case CompositeModeSourceIn:
  67. return BlendSourceIn
  68. case CompositeModeDestinationIn:
  69. return BlendDestinationIn
  70. case CompositeModeSourceOut:
  71. return BlendSourceOut
  72. case CompositeModeDestinationOut:
  73. return BlendDestinationOut
  74. case CompositeModeSourceAtop:
  75. return BlendSourceAtop
  76. case CompositeModeDestinationAtop:
  77. return BlendDestinationAtop
  78. case CompositeModeXor:
  79. return BlendXor
  80. case CompositeModeLighter:
  81. return BlendLighter
  82. case CompositeModeMultiply:
  83. return Blend{
  84. BlendFactorSourceRGB: BlendFactorDestinationColor,
  85. BlendFactorSourceAlpha: BlendFactorDestinationColor,
  86. BlendFactorDestinationRGB: BlendFactorZero,
  87. BlendFactorDestinationAlpha: BlendFactorZero,
  88. BlendOperationRGB: BlendOperationAdd,
  89. BlendOperationAlpha: BlendOperationAdd,
  90. }
  91. default:
  92. panic(fmt.Sprintf("ebiten: invalid composite mode: %d", c))
  93. }
  94. }