graphics.go (3489B)
1 // Copyright 2014 Hajime Hoshi 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 ebiten 16 17 import ( 18 "github.com/hajimehoshi/ebiten/v2/internal/driver" 19 ) 20 21 // Filter represents the type of texture filter to be used when an image is maginified or minified. 22 type Filter int 23 24 const ( 25 // FilterNearest represents nearest (crisp-edged) filter 26 FilterNearest Filter = Filter(driver.FilterNearest) 27 28 // FilterLinear represents linear filter 29 FilterLinear Filter = Filter(driver.FilterLinear) 30 31 // filterScreen represents a special filter for screen. Inner usage only. 32 // 33 // Some parameters like a color matrix or color vertex values can be ignored when filterScreen is used. 34 filterScreen Filter = Filter(driver.FilterScreen) 35 ) 36 37 // CompositeMode represents Porter-Duff composition mode. 38 type CompositeMode int 39 40 // This name convention follows CSS compositing: https://drafts.fxtf.org/compositing-2/. 41 // 42 // In the comments, 43 // c_src, c_dst and c_out represent alpha-premultiplied RGB values of source, destination and output respectively. α_src and α_dst represent alpha values of source and destination respectively. 44 const ( 45 // Regular alpha blending 46 // c_out = c_src + c_dst × (1 - α_src) 47 CompositeModeSourceOver CompositeMode = CompositeMode(driver.CompositeModeSourceOver) 48 49 // c_out = 0 50 CompositeModeClear CompositeMode = CompositeMode(driver.CompositeModeClear) 51 52 // c_out = c_src 53 CompositeModeCopy CompositeMode = CompositeMode(driver.CompositeModeCopy) 54 55 // c_out = c_dst 56 CompositeModeDestination CompositeMode = CompositeMode(driver.CompositeModeDestination) 57 58 // c_out = c_src × (1 - α_dst) + c_dst 59 CompositeModeDestinationOver CompositeMode = CompositeMode(driver.CompositeModeDestinationOver) 60 61 // c_out = c_src × α_dst 62 CompositeModeSourceIn CompositeMode = CompositeMode(driver.CompositeModeSourceIn) 63 64 // c_out = c_dst × α_src 65 CompositeModeDestinationIn CompositeMode = CompositeMode(driver.CompositeModeDestinationIn) 66 67 // c_out = c_src × (1 - α_dst) 68 CompositeModeSourceOut CompositeMode = CompositeMode(driver.CompositeModeSourceOut) 69 70 // c_out = c_dst × (1 - α_src) 71 CompositeModeDestinationOut CompositeMode = CompositeMode(driver.CompositeModeDestinationOut) 72 73 // c_out = c_src × α_dst + c_dst × (1 - α_src) 74 CompositeModeSourceAtop CompositeMode = CompositeMode(driver.CompositeModeSourceAtop) 75 76 // c_out = c_src × (1 - α_dst) + c_dst × α_src 77 CompositeModeDestinationAtop CompositeMode = CompositeMode(driver.CompositeModeDestinationAtop) 78 79 // c_out = c_src × (1 - α_dst) + c_dst × (1 - α_src) 80 CompositeModeXor CompositeMode = CompositeMode(driver.CompositeModeXor) 81 82 // Sum of source and destination (a.k.a. 'plus' or 'additive') 83 // c_out = c_src + c_dst 84 CompositeModeLighter CompositeMode = CompositeMode(driver.CompositeModeLighter) 85 86 // The product of source and destination (a.k.a 'multiply blend mode') 87 // c_out = c_src * c_dst 88 CompositeModeMultiply CompositeMode = CompositeMode(driver.CompositeModeMultiply) 89 )