====== SHBlendModes ====== ---- dataentry extension ---- type : extension author_mail : shilo86@gmail.com Shilo White description : A category that allows blend modes via presets or custom blends. lastupdate_dt : 2012-03-11 compatible : v1.X depends : tags : blend, blending, mode, blend mode homepage_url : https://gist.github.com/2019733 download_url : https://gist.github.com/gists/2019733/download ---- ===== Properties ===== === blendMode === An integer that specifies a preset blend mode. The initial value is SHBlendModeAuto. @property (nonatomic, assign) SHBlendMode blendMode; See [[shblendmodes#presets|presets]] for valid values. === blendModeName === A readonly string that describes what blending mode is in use. The initial value is "auto". @property (nonatomic, readonly) NSString *blendModeName; === blendModeSourceFactor === An integer that specifies how the red, green, blue, and alpha source blending factors are computed. The following symbolic constants are accepted: GL_ZERO, GL_ONE, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA, and GL_SRC_ALPHA_SATURATE. The initial value is GL_ZERO. @property (nonatomic, assign) GLenum blendModeSourceFactor; Changing this property will automatically set "blendMode" property to SHBlendModeCustom. === blendModeDestinationFactor === An integer that specifies how the red, green, blue, and alpha destination blending factors are computed. Eight symbolic constants are accepted: GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, and GL_ONE_MINUS_DST_ALPHA. The initial value is GL_ZERO. @property (nonatomic, assign) GLenum blendModeDestinationFactor; Changing this property will automatically set "blendMode" property to SHBlendModeCustom. ===== Instance Methods ===== === setBlendModeSourceFactor:destinationFactor:=== Sets the blend mode source factor and destination source factor. See [[shblendmodes#blendModeSourceFactor|blendModeSourceFactor]] and [[shblendmodes#blendModeDestinationFactor|blendModeDestinationFactor]]. - (void)setBlendModeSourceFactor:(GLenum)blendModeSourceFactor destinationFactor:(GLenum)blendModeDestinationFactor; Calling this method will automatically set "blendMode" property to SHBlendModeCustom. ===== Presets ===== * **SHBlendModeAuto** - Blend mode will automatically be handled by Sparrow. (Default) * **SHBlendModeNormal** - The source and destination alpha value will blend normally. * **SHBlendModeInverseMask** - The source alpha will be 100% and the destination alpha value will be 0%. This preset is only useful for drawing an object into a SPRenderTexture. * **SHBlendModeErase** - Erases the pixels behind the object's bound, or if it is a SPImage, the pixels behind it will be erased based on the alpha value of each pixel inside the SPImage. * **SHBlendModeCustom** - Allows you to specify the blend source factor and blend destination factor manually. * More presets to come... ===== Source Code ===== %gist(2019733)%